-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cordova-consent): generate constants
- Loading branch information
Showing
5 changed files
with
107 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,84 @@ | ||
import _ from 'lodash' | ||
import { pkgsDirJoin } from '../utils' | ||
import { buildUtils, warnMessage } from './shared' | ||
import { | ||
buildUtils, | ||
renderJavaContants, | ||
renderSwiftContants, | ||
renderTsContants, | ||
warnMessage, | ||
} from './shared' | ||
|
||
const Actions = _.mapValues( | ||
{ | ||
ready: null, | ||
requestInfoUpdate: null, | ||
isFormAvailable: null, | ||
loadForm: null, | ||
getStatus: null, | ||
showForm: null, | ||
reset: null, | ||
}, | ||
(v, k) => (v === null ? k : v) as string, | ||
) | ||
|
||
const Events = _.mapValues( | ||
{ ready: null }, | ||
(v, k) => `consent.${v === null ? k : v}`, | ||
) | ||
|
||
function buildJava(): string { | ||
const linesActions = renderJavaContants(Actions) | ||
const linesEvents = renderJavaContants(Events) | ||
|
||
return `// ${warnMessage} | ||
package cordova.plugin.consent; | ||
public final class Generated { | ||
public final class Actions { | ||
${linesActions} | ||
} | ||
public final class Events { | ||
${linesEvents} | ||
} | ||
} | ||
` | ||
} | ||
|
||
function buildSwift(): string { | ||
const linesEvents = renderSwiftContants(Events) | ||
|
||
return `// ${warnMessage} | ||
struct AMCEvents { | ||
${linesEvents} | ||
} | ||
` | ||
} | ||
|
||
function buildTypeScript(): string { | ||
return `// ${warnMessage} | ||
import { exec } from 'cordova' | ||
export enum NativeActions { | ||
${renderTsContants(Actions)} | ||
} | ||
export enum Events { | ||
${renderTsContants(Events)} | ||
} | ||
${buildUtils('Consent')} | ||
` | ||
} | ||
|
||
export default () => ({ | ||
files: [{ path: 'cordova-consent/ts/generated.ts', f: buildTypeScript }], | ||
files: [ | ||
{ path: 'cordova-consent/src/android/Generated.java', f: buildJava }, | ||
{ | ||
path: 'cordova-consent/src/ios/AMCGenerated.swift', | ||
f: buildSwift, | ||
}, | ||
{ path: 'cordova-consent/ts/generated.ts', f: buildTypeScript }, | ||
], | ||
pkgDir: pkgsDirJoin('cordova-consent'), | ||
tagertDir: 'src/cordova/plugin/consent', | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
package cordova.plugin.consent; | ||
|
||
public final class Generated { | ||
public final class Actions { | ||
public static final String GET_STATUS = "getStatus"; | ||
public static final String IS_FORM_AVAILABLE = "isFormAvailable"; | ||
public static final String LOAD_FORM = "loadForm"; | ||
public static final String READY = "ready"; | ||
public static final String REQUEST_INFO_UPDATE = "requestInfoUpdate"; | ||
public static final String SHOW_FORM = "showForm"; | ||
} | ||
|
||
public final class Events { | ||
public static final String READY = "consent.ready"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
struct AMCEvents { | ||
static let ready = "consent.ready" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters