@dittowords/cli 3.10.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -36
- package/bin/add-project.js +101 -33
- package/bin/add-project.js.map +1 -1
- package/bin/api.js +49 -15
- package/bin/api.js.map +1 -1
- package/bin/component-folders.js +56 -7
- package/bin/component-folders.js.map +1 -1
- package/bin/config.js +206 -170
- package/bin/config.js.map +1 -1
- package/bin/config.test.js +92 -0
- package/bin/config.test.js.map +1 -0
- package/bin/consts.js +64 -18
- package/bin/consts.js.map +1 -1
- package/bin/ditto.js +250 -200
- package/bin/ditto.js.map +1 -1
- package/bin/generate-suggestions.js +155 -78
- package/bin/generate-suggestions.js.map +1 -1
- package/bin/generate-suggestions.test.js +189 -0
- package/bin/generate-suggestions.test.js.map +1 -0
- package/bin/http/fetchComponentFolders.js +60 -8
- package/bin/http/fetchComponentFolders.js.map +1 -1
- package/bin/http/fetchComponents.js +65 -18
- package/bin/http/fetchComponents.js.map +1 -1
- package/bin/http/fetchVariants.js +74 -14
- package/bin/http/fetchVariants.js.map +1 -1
- package/bin/http/importComponents.js +100 -49
- package/bin/http/importComponents.js.map +1 -1
- package/bin/importComponents.js +61 -10
- package/bin/importComponents.js.map +1 -1
- package/bin/init/init.js +120 -44
- package/bin/init/init.js.map +1 -1
- package/bin/init/project.js +160 -83
- package/bin/init/project.js.map +1 -1
- package/bin/init/project.test.js +49 -0
- package/bin/init/project.test.js.map +1 -0
- package/bin/init/token.js +134 -74
- package/bin/init/token.js.map +1 -1
- package/bin/init/token.test.js +69 -0
- package/bin/init/token.test.js.map +1 -0
- package/bin/output.js +72 -30
- package/bin/output.js.map +1 -1
- package/bin/pull.js +424 -213
- package/bin/pull.js.map +1 -1
- package/bin/pull.test.js +410 -0
- package/bin/pull.test.js.map +1 -0
- package/bin/remove-project.js +91 -27
- package/bin/remove-project.js.map +1 -1
- package/bin/replace.js +140 -100
- package/bin/replace.js.map +1 -1
- package/bin/replace.test.js +155 -0
- package/bin/replace.test.js.map +1 -0
- package/bin/sentry-test.js.map +1 -0
- package/bin/types.js +20 -2
- package/bin/types.js.map +1 -1
- package/bin/utils/cleanFileName.js +32 -8
- package/bin/utils/cleanFileName.js.map +1 -1
- package/bin/utils/createSentryContext.js +43 -0
- package/bin/utils/createSentryContext.js.map +1 -0
- package/bin/utils/generateJsDriver.js +114 -51
- package/bin/utils/generateJsDriver.js.map +1 -1
- package/bin/utils/getSelectedProjects.js +58 -52
- package/bin/utils/getSelectedProjects.js.map +1 -1
- package/bin/utils/processMetaOption.js +36 -11
- package/bin/utils/processMetaOption.js.map +1 -1
- package/bin/utils/processMetaOption.test.js +45 -0
- package/bin/utils/processMetaOption.test.js.map +1 -0
- package/bin/utils/projectsToText.js +52 -19
- package/bin/utils/projectsToText.js.map +1 -1
- package/bin/utils/promptForProject.js +89 -36
- package/bin/utils/promptForProject.js.map +1 -1
- package/bin/utils/quit.js +36 -7
- package/bin/utils/quit.js.map +1 -1
- package/bin/utils/sourcesToText.js +51 -19
- package/bin/utils/sourcesToText.js.map +1 -1
- package/etsc.config.js +13 -0
- package/lib/config.ts +27 -8
- package/lib/ditto.ts +6 -0
- package/lib/init/project.ts +3 -3
- package/lib/pull.ts +190 -52
- package/lib/types.ts +24 -7
- package/lib/utils/createSentryContext.ts +20 -0
- package/lib/utils/generateJsDriver.ts +40 -6
- package/lib/utils/quit.ts +2 -3
- package/package.json +10 -6
- package/tsconfig.json +4 -1
- package/bin/lib/add-project.js +0 -36
- package/bin/lib/add-project.js.map +0 -1
- package/bin/lib/api.js +0 -20
- package/bin/lib/api.js.map +0 -1
- package/bin/lib/config.js +0 -202
- package/bin/lib/config.js.map +0 -1
- package/bin/lib/consts.js +0 -21
- package/bin/lib/consts.js.map +0 -1
- package/bin/lib/ditto.js +0 -121
- package/bin/lib/ditto.js.map +0 -1
- package/bin/lib/generate-suggestions.js +0 -71
- package/bin/lib/generate-suggestions.js.map +0 -1
- package/bin/lib/http/fetchComponents.js +0 -13
- package/bin/lib/http/fetchComponents.js.map +0 -1
- package/bin/lib/http/fetchVariants.js +0 -26
- package/bin/lib/http/fetchVariants.js.map +0 -1
- package/bin/lib/init/init.js +0 -50
- package/bin/lib/init/init.js.map +0 -1
- package/bin/lib/init/project.js +0 -108
- package/bin/lib/init/project.js.map +0 -1
- package/bin/lib/init/token.js +0 -91
- package/bin/lib/init/token.js.map +0 -1
- package/bin/lib/output.js +0 -34
- package/bin/lib/output.js.map +0 -1
- package/bin/lib/pull.js +0 -264
- package/bin/lib/pull.js.map +0 -1
- package/bin/lib/remove-project.js +0 -35
- package/bin/lib/remove-project.js.map +0 -1
- package/bin/lib/replace.js +0 -107
- package/bin/lib/replace.js.map +0 -1
- package/bin/lib/types.js +0 -3
- package/bin/lib/types.js.map +0 -1
- package/bin/lib/utils/cleanFileName.js +0 -11
- package/bin/lib/utils/cleanFileName.js.map +0 -1
- package/bin/lib/utils/generateJsDriver.js +0 -56
- package/bin/lib/utils/generateJsDriver.js.map +0 -1
- package/bin/lib/utils/getSelectedProjects.js +0 -61
- package/bin/lib/utils/getSelectedProjects.js.map +0 -1
- package/bin/lib/utils/processMetaOption.js +0 -15
- package/bin/lib/utils/processMetaOption.js.map +0 -1
- package/bin/lib/utils/projectsToText.js +0 -25
- package/bin/lib/utils/projectsToText.js.map +0 -1
- package/bin/lib/utils/promptForProject.js +0 -43
- package/bin/lib/utils/promptForProject.js.map +0 -1
- package/bin/lib/utils/quit.js +0 -10
- package/bin/lib/utils/quit.js.map +0 -1
- package/bin/lib/utils/sourcesToText.js +0 -25
- package/bin/lib/utils/sourcesToText.js.map +0 -1
- package/bin/package.json +0 -76
package/bin/types.js
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3a899a8b-8170-53ae-808a-dea1164e29fe")}catch(e){}}();
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
17
|
+
var types_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(types_exports);
|
|
19
|
+
//# sourceMappingURL=types.js.map
|
|
20
|
+
|
|
21
|
+
//# debugId=3a899a8b-8170-53ae-808a-dea1164e29fe
|
package/bin/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../lib/types.ts"],"sourcesContent":["export interface Project {\n name: string;\n id: string;\n url?: string;\n fileName?: string;\n status?: string;\n exclude_components?: boolean;\n}\n\nexport type ComponentSource = ComponentFolder & {\n type: \"components\";\n fileName: string;\n variant: string;\n};\n\nexport type Source = (Project & { type?: undefined }) | ComponentSource;\n\nexport interface ComponentFolder {\n id: string;\n name: string;\n status?: string;\n}\n\nexport type SupportedFormat =\n | \"flat\"\n | \"structured\"\n | \"android\"\n | \"ios-strings\"\n | \"ios-stringsdict\"\n | \"icu\";\n\ntype ComponentsSourceBool = boolean;\ntype ComponentsSourceConfig = {\n root?: boolean | { status: string };\n folders?: ComponentFolder[];\n};\ntype ComponentsSource = ComponentsSourceBool | ComponentsSourceConfig;\n\nexport interface ConfigYAML {\n sources?: {\n components?: ComponentsSource;\n projects?: Project[];\n };\n format?: SupportedFormat;\n status?: string;\n variants?: boolean;\n richText?: boolean;\n\n // these are legacy fields - if they exist, we should output\n // a deprecation error, and suggest that they nest them under\n // a top-level `sources` property\n components?: boolean;\n projects?: Project[];\n}\n\nexport interface SourceInformation {\n hasSourceData: boolean;\n hasTopLevelProjectsField: boolean;\n hasTopLevelComponentsField: boolean;\n hasComponentLibraryInProjects: boolean;\n validProjects: Project[];\n shouldFetchComponentLibrary: boolean;\n variants: boolean;\n format: string | string[] | undefined;\n status: string | undefined;\n richText: boolean | undefined;\n componentRoot: boolean | { status: string } | undefined;\n componentFolders: ComponentFolder[] | undefined;\n}\n\nexport type Token = string | undefined;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA","debug_id":"3a899a8b-8170-53ae-808a-dea1164e29fe"}
|
|
@@ -1,11 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f67d3041-1c22-5f35-849f-38d800c218aa")}catch(e){}}();
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
var cleanFileName_exports = {};
|
|
22
|
+
__export(cleanFileName_exports, {
|
|
23
|
+
cleanFileName: () => cleanFileName
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(cleanFileName_exports);
|
|
4
26
|
function cleanFileName(fileName) {
|
|
5
|
-
|
|
6
|
-
.replace(/\s{1,}/g, "-")
|
|
7
|
-
.replace(/[^a-zA-Z0-9-_.]/g, "")
|
|
8
|
-
.toLowerCase();
|
|
27
|
+
return fileName.replace(/\s{1,}/g, "-").replace(/[^a-zA-Z0-9-_.]/g, "").toLowerCase();
|
|
9
28
|
}
|
|
10
|
-
|
|
11
|
-
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
cleanFileName
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=cleanFileName.js.map
|
|
34
|
+
|
|
35
|
+
//# debugId=f67d3041-1c22-5f35-849f-38d800c218aa
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../lib/utils/cleanFileName.ts"],"sourcesContent":["export function cleanFileName(fileName: string): string {\n return fileName\n .replace(/\\s{1,}/g, \"-\")\n .replace(/[^a-zA-Z0-9-_.]/g, \"\")\n .toLowerCase();\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,cAAc,UAA0B;AACtD,SAAO,SACJ,QAAQ,WAAW,GAAG,EACtB,QAAQ,oBAAoB,EAAE,EAC9B,YAAY;AACjB","debug_id":"f67d3041-1c22-5f35-849f-38d800c218aa"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="38a5733b-13a9-57f6-843f-d2de84c4c1d0")}catch(e){}}();
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
var createSentryContext_exports = {};
|
|
22
|
+
__export(createSentryContext_exports, {
|
|
23
|
+
createSentryContext: () => createSentryContext
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(createSentryContext_exports);
|
|
26
|
+
function createSentryContext(obj) {
|
|
27
|
+
if (typeof obj !== "object")
|
|
28
|
+
return {};
|
|
29
|
+
const ctx = {};
|
|
30
|
+
for (const key in obj) {
|
|
31
|
+
const k = key;
|
|
32
|
+
const r = obj[k];
|
|
33
|
+
ctx[k] = typeof r === "object" || Array.isArray(r) ? JSON.stringify(r) : r;
|
|
34
|
+
}
|
|
35
|
+
return ctx;
|
|
36
|
+
}
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
createSentryContext
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=createSentryContext.js.map
|
|
42
|
+
|
|
43
|
+
//# debugId=38a5733b-13a9-57f6-843f-d2de84c4c1d0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../lib/utils/createSentryContext.ts"],"sourcesContent":["type SentryContext = Record<\n string,\n string | number | boolean | null | undefined\n>;\n\n/**\n * Sentry context only supports properties one layer deep\n */\nexport function createSentryContext(obj: unknown) {\n if (typeof obj !== \"object\") return {};\n\n const ctx: SentryContext = {};\n for (const key in obj) {\n const k = key as keyof typeof obj;\n const r = obj[k];\n ctx[k] = typeof r === \"object\" || Array.isArray(r) ? JSON.stringify(r) : r;\n }\n\n return ctx;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQO,SAAS,oBAAoB,KAAc;AAChD,MAAI,OAAO,QAAQ;AAAU,WAAO,CAAC;AAErC,QAAM,MAAqB,CAAC;AAC5B,aAAW,OAAO,KAAK;AACrB,UAAM,IAAI;AACV,UAAM,IAAI,IAAI,CAAC;AACf,QAAI,CAAC,IAAI,OAAO,MAAM,YAAY,MAAM,QAAQ,CAAC,IAAI,KAAK,UAAU,CAAC,IAAI;AAAA,EAC3E;AAEA,SAAO;AACT","debug_id":"38a5733b-13a9-57f6-843f-d2de84c4c1d0"}
|
|
@@ -1,56 +1,119 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="abf6148b-b36f-5809-b765-ac588ff7207f")}catch(e){}}();
|
|
3
|
+
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __defProps = Object.defineProperties;
|
|
7
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
9
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
11
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
12
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
14
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
15
|
+
var __spreadValues = (a, b) => {
|
|
16
|
+
for (var prop in b || (b = {}))
|
|
17
|
+
if (__hasOwnProp.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
if (__getOwnPropSymbols)
|
|
20
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
21
|
+
if (__propIsEnum.call(b, prop))
|
|
22
|
+
__defNormalProp(a, prop, b[prop]);
|
|
23
|
+
}
|
|
24
|
+
return a;
|
|
4
25
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
26
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
27
|
+
var __export = (target, all) => {
|
|
28
|
+
for (var name in all)
|
|
29
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
30
|
+
};
|
|
31
|
+
var __copyProps = (to, from, except, desc) => {
|
|
32
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
33
|
+
for (let key of __getOwnPropNames(from))
|
|
34
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
35
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
36
|
+
}
|
|
37
|
+
return to;
|
|
38
|
+
};
|
|
39
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
40
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
41
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
42
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
43
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
44
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
45
|
+
mod
|
|
46
|
+
));
|
|
47
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
48
|
+
var generateJsDriver_exports = {};
|
|
49
|
+
__export(generateJsDriver_exports, {
|
|
50
|
+
generateJsDriver: () => generateJsDriver
|
|
51
|
+
});
|
|
52
|
+
module.exports = __toCommonJS(generateJsDriver_exports);
|
|
53
|
+
var import_fs = __toESM(require("fs"));
|
|
54
|
+
var import_path = __toESM(require("path"));
|
|
55
|
+
var import_consts = __toESM(require("../consts"));
|
|
56
|
+
var import_output = __toESM(require("../output"));
|
|
57
|
+
var import_cleanFileName = require("./cleanFileName");
|
|
14
58
|
const stringifySourceId = (projectId) => projectId === "ditto_component_library" ? projectId : `project_${projectId}`;
|
|
15
|
-
/**
|
|
16
|
-
* Generates an index.js file that can be consumed
|
|
17
|
-
* by an SDK - this is a big DX improvement because
|
|
18
|
-
* it provides a single entry point to get all data
|
|
19
|
-
* (including variants) instead of having to import
|
|
20
|
-
* each generated file individually.
|
|
21
|
-
*
|
|
22
|
-
* The generated file will have a unified format
|
|
23
|
-
* independent of the CLI configuration used to fetch
|
|
24
|
-
* data from Ditto.
|
|
25
|
-
*/
|
|
26
|
-
// TODO: support ESM
|
|
27
59
|
function generateJsDriver(sources) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
60
|
+
const sourceIdsByName = sources.reduce(
|
|
61
|
+
(agg, source) => {
|
|
62
|
+
if (source.fileName) {
|
|
63
|
+
return __spreadProps(__spreadValues({}, agg), { [(0, import_cleanFileName.cleanFileName)(source.fileName)]: source.id });
|
|
64
|
+
}
|
|
65
|
+
return agg;
|
|
66
|
+
},
|
|
67
|
+
{}
|
|
68
|
+
);
|
|
69
|
+
const projectFileNames = import_fs.default.readdirSync(import_consts.default.TEXT_DIR).filter(
|
|
70
|
+
(fileName) => /\.json$/.test(fileName) && !/^components__/.test(fileName)
|
|
71
|
+
);
|
|
72
|
+
const data = projectFileNames.reduce(
|
|
73
|
+
(obj, fileName) => {
|
|
74
|
+
const [sourceId, rest] = fileName.split("__");
|
|
75
|
+
const [variantApiId] = rest.split(".");
|
|
76
|
+
const projectId = sourceIdsByName[sourceId];
|
|
77
|
+
const projectIdStr = stringifySourceId(projectId);
|
|
78
|
+
if (!obj[projectIdStr]) {
|
|
79
|
+
obj[projectIdStr] = {};
|
|
80
|
+
}
|
|
81
|
+
obj[projectIdStr][variantApiId] = `require('./${fileName}')`;
|
|
82
|
+
return obj;
|
|
83
|
+
},
|
|
84
|
+
{}
|
|
85
|
+
);
|
|
86
|
+
const componentData = {};
|
|
87
|
+
sources.filter((s) => s.type === "components").forEach((componentSource) => {
|
|
88
|
+
var _a, _b;
|
|
89
|
+
if (componentSource.type !== "components")
|
|
90
|
+
return;
|
|
91
|
+
(_b = componentData[_a = componentSource.variant]) != null ? _b : componentData[_a] = [];
|
|
92
|
+
componentData[componentSource.variant].push(
|
|
93
|
+
`...require('./${componentSource.fileName}')`
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
Object.keys(componentData).forEach((key) => {
|
|
97
|
+
var _a;
|
|
98
|
+
(_a = data.ditto_component_library) != null ? _a : data.ditto_component_library = {};
|
|
99
|
+
let str = "{";
|
|
100
|
+
componentData[key].forEach((k, i) => {
|
|
101
|
+
str += k;
|
|
102
|
+
if (i < componentData[key].length - 1)
|
|
103
|
+
str += ", ";
|
|
104
|
+
});
|
|
105
|
+
str += "}";
|
|
106
|
+
data.ditto_component_library[key] = str;
|
|
107
|
+
});
|
|
108
|
+
let dataString = `module.exports = ${JSON.stringify(data, null, 2)}`.replace(/"require\((.*)\)"/g, "require($1)").replace(/"\{/g, "{").replace(/\}"/g, "}");
|
|
109
|
+
const filePath = import_path.default.resolve(import_consts.default.TEXT_DIR, "index.js");
|
|
110
|
+
import_fs.default.writeFileSync(filePath, dataString, { encoding: "utf8" });
|
|
111
|
+
return `Generated .js SDK driver at ${import_output.default.info(filePath)}`;
|
|
54
112
|
}
|
|
55
|
-
|
|
56
|
-
|
|
113
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
114
|
+
0 && (module.exports = {
|
|
115
|
+
generateJsDriver
|
|
116
|
+
});
|
|
117
|
+
//# sourceMappingURL=generateJsDriver.js.map
|
|
118
|
+
|
|
119
|
+
//# debugId=abf6148b-b36f-5809-b765-ac588ff7207f
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../lib/utils/generateJsDriver.ts"],"sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport consts from \"../consts\";\nimport output from \"../output\";\nimport { Source } from \"../types\";\nimport { cleanFileName } from \"./cleanFileName\";\n\n// compatability with legacy method of specifying project ids\n// that is still used by the default format\nconst stringifySourceId = (projectId: string) =>\n projectId === \"ditto_component_library\" ? projectId : `project_${projectId}`;\n\n/**\n * Generates an index.js file that can be consumed\n * by an SDK - this is a big DX improvement because\n * it provides a single entry point to get all data\n * (including variants) instead of having to import\n * each generated file individually.\n *\n * The generated file will have a unified format\n * independent of the CLI configuration used to fetch\n * data from Ditto.\n */\n\n// TODO: support ESM\nexport function generateJsDriver(sources: Source[]) {\n const sourceIdsByName: Record<string, string> = sources.reduce(\n (agg, source) => {\n if (source.fileName) {\n return { ...agg, [cleanFileName(source.fileName)]: source.id };\n }\n\n return agg;\n },\n {}\n );\n\n const projectFileNames = fs\n .readdirSync(consts.TEXT_DIR)\n .filter(\n (fileName) => /\\.json$/.test(fileName) && !/^components__/.test(fileName)\n );\n\n type DriverFile = Record<string, Record<string, string | object>>;\n const data: DriverFile = projectFileNames.reduce(\n (obj: Record<string, Record<string, string>>, fileName) => {\n const [sourceId, rest] = fileName.split(\"__\");\n const [variantApiId] = rest.split(\".\");\n\n const projectId = sourceIdsByName[sourceId];\n const projectIdStr = stringifySourceId(projectId);\n\n if (!obj[projectIdStr]) {\n obj[projectIdStr] = {};\n }\n\n obj[projectIdStr][variantApiId] = `require('./${fileName}')`;\n return obj;\n },\n {}\n );\n\n // Create arrays of stringified \"...require()\" statements,\n // each of which corresponds to one of the component files\n // (which are created on a per-component-folder basis)\n const componentData: Record<string, string[]> = {};\n sources\n .filter((s) => s.type === \"components\")\n .forEach((componentSource) => {\n if (componentSource.type !== \"components\") return;\n componentData[componentSource.variant] ??= [];\n componentData[componentSource.variant].push(\n `...require('./${componentSource.fileName}')`\n );\n });\n // Convert each array of stringified \"...require()\" statements\n // into a unified string, and set it on the final data object\n // that will be written to the driver file\n Object.keys(componentData).forEach((key) => {\n data.ditto_component_library ??= {};\n\n let str = \"{\";\n componentData[key].forEach((k, i) => {\n str += k;\n if (i < componentData[key].length - 1) str += \", \";\n });\n str += \"}\";\n data.ditto_component_library[key] = str;\n });\n\n let dataString = `module.exports = ${JSON.stringify(data, null, 2)}`\n // remove quotes around require statements\n .replace(/\"require\\((.*)\\)\"/g, \"require($1)\")\n // remove quotes around opening & closing curlies\n .replace(/\"\\{/g, \"{\")\n .replace(/\\}\"/g, \"}\");\n\n const filePath = path.resolve(consts.TEXT_DIR, \"index.js\");\n fs.writeFileSync(filePath, dataString, { encoding: \"utf8\" });\n\n return `Generated .js SDK driver at ${output.info(filePath)}`;\n}\n"],"names":["fs","consts","path","output"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAe;AACf,kBAAiB;AACjB,oBAAmB;AACnB,oBAAmB;AAEnB,2BAA8B;AAI9B,MAAM,oBAAoB,CAAC,cACzB,cAAc,4BAA4B,YAAY,WAAW,SAAS;AAerE,SAAS,iBAAiB,SAAmB;AAClD,QAAM,kBAA0C,QAAQ;AAAA,IACtD,CAAC,KAAK,WAAW;AACf,UAAI,OAAO,UAAU;AACnB,eAAO,iCAAK,MAAL,EAAU,KAAC,oCAAc,OAAO,QAAQ,CAAC,GAAG,OAAO,GAAG;AAAA,MAC/D;AAEA,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AAEA,QAAM,mBAAmB,UAAAA,QACtB,YAAY,cAAAC,QAAO,QAAQ,EAC3B;AAAA,IACC,CAAC,aAAa,UAAU,KAAK,QAAQ,KAAK,CAAC,gBAAgB,KAAK,QAAQ;AAAA,EAC1E;AAGF,QAAM,OAAmB,iBAAiB;AAAA,IACxC,CAAC,KAA6C,aAAa;AACzD,YAAM,CAAC,UAAU,IAAI,IAAI,SAAS,MAAM,IAAI;AAC5C,YAAM,CAAC,YAAY,IAAI,KAAK,MAAM,GAAG;AAErC,YAAM,YAAY,gBAAgB,QAAQ;AAC1C,YAAM,eAAe,kBAAkB,SAAS;AAEhD,UAAI,CAAC,IAAI,YAAY,GAAG;AACtB,YAAI,YAAY,IAAI,CAAC;AAAA,MACvB;AAEA,UAAI,YAAY,EAAE,YAAY,IAAI,cAAc,QAAQ;AACxD,aAAO;AAAA,IACT;AAAA,IACA,CAAC;AAAA,EACH;AAKA,QAAM,gBAA0C,CAAC;AACjD,UACG,OAAO,CAAC,MAAM,EAAE,SAAS,YAAY,EACrC,QAAQ,CAAC,oBAAoB;AApElC;AAqEM,QAAI,gBAAgB,SAAS;AAAc;AAC3C,6BAAc,gBAAgB,aAA9B,gCAA2C,CAAC;AAC5C,kBAAc,gBAAgB,OAAO,EAAE;AAAA,MACrC,iBAAiB,gBAAgB,QAAQ;AAAA,IAC3C;AAAA,EACF,CAAC;AAIH,SAAO,KAAK,aAAa,EAAE,QAAQ,CAAC,QAAQ;AA9E9C;AA+EI,eAAK,4BAAL,iBAAK,0BAA4B,CAAC;AAElC,QAAI,MAAM;AACV,kBAAc,GAAG,EAAE,QAAQ,CAAC,GAAG,MAAM;AACnC,aAAO;AACP,UAAI,IAAI,cAAc,GAAG,EAAE,SAAS;AAAG,eAAO;AAAA,IAChD,CAAC;AACD,WAAO;AACP,SAAK,wBAAwB,GAAG,IAAI;AAAA,EACtC,CAAC;AAED,MAAI,aAAa,oBAAoB,KAAK,UAAU,MAAM,MAAM,CAAC,CAAC,GAE/D,QAAQ,sBAAsB,aAAa,EAE3C,QAAQ,QAAQ,GAAG,EACnB,QAAQ,QAAQ,GAAG;AAEtB,QAAM,WAAW,YAAAC,QAAK,QAAQ,cAAAD,QAAO,UAAU,UAAU;AACzD,YAAAD,QAAG,cAAc,UAAU,YAAY,EAAE,UAAU,OAAO,CAAC;AAE3D,SAAO,+BAA+B,cAAAG,QAAO,KAAK,QAAQ,CAAC;AAC7D","debug_id":"abf6148b-b36f-5809-b765-ac588ff7207f"}
|
|
@@ -1,61 +1,67 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
})
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3231592f-fedc-5607-aa4c-eae91957e0ed")}catch(e){}}();
|
|
3
|
+
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
24
13
|
};
|
|
25
|
-
var
|
|
26
|
-
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
27
21
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
28
|
+
mod
|
|
29
|
+
));
|
|
30
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
|
+
var getSelectedProjects_exports = {};
|
|
32
|
+
__export(getSelectedProjects_exports, {
|
|
33
|
+
getIsUsingComponents: () => getIsUsingComponents,
|
|
34
|
+
getSelectedProjects: () => getSelectedProjects
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(getSelectedProjects_exports);
|
|
37
|
+
var import_js_yaml = __toESM(require("js-yaml"));
|
|
38
|
+
var import_consts = require("../consts");
|
|
39
|
+
var import_config = __toESM(require("../config"));
|
|
33
40
|
function jsonIsConfigYAML(json) {
|
|
34
|
-
|
|
41
|
+
return typeof json === "object";
|
|
35
42
|
}
|
|
36
43
|
function yamlToJson(_yaml) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
return configYaml;
|
|
44
|
+
try {
|
|
45
|
+
let configYaml = import_js_yaml.default.load(_yaml);
|
|
46
|
+
if (!jsonIsConfigYAML(configYaml)) {
|
|
47
|
+
return {};
|
|
43
48
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
49
|
+
return configYaml;
|
|
50
|
+
} catch (e) {
|
|
51
|
+
if (e instanceof import_js_yaml.YAMLException) {
|
|
52
|
+
return null;
|
|
53
|
+
} else {
|
|
54
|
+
throw e;
|
|
51
55
|
}
|
|
56
|
+
}
|
|
52
57
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
const getSelectedProjects = (configFile = import_consts.PROJECT_CONFIG_FILE) => import_config.default.parseSourceInformation(configFile).validProjects;
|
|
59
|
+
const getIsUsingComponents = (configFile = import_consts.PROJECT_CONFIG_FILE) => import_config.default.parseSourceInformation(configFile).shouldFetchComponentLibrary;
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
getIsUsingComponents,
|
|
63
|
+
getSelectedProjects
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=getSelectedProjects.js.map
|
|
66
|
+
|
|
67
|
+
//# debugId=3231592f-fedc-5607-aa4c-eae91957e0ed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../lib/utils/getSelectedProjects.ts"],"sourcesContent":["import fs from \"fs\";\nimport yaml, { YAMLException } from \"js-yaml\";\n\nimport { PROJECT_CONFIG_FILE } from \"../consts\";\nimport { ConfigYAML, Project } from \"../types\";\nimport Config, { DEFAULT_CONFIG_JSON } from \"../config\";\n\nfunction jsonIsConfigYAML(json: unknown): json is ConfigYAML {\n return typeof json === \"object\";\n}\n\nfunction yamlToJson(_yaml: string): ConfigYAML | null {\n try {\n let configYaml = yaml.load(_yaml);\n if (!jsonIsConfigYAML(configYaml)) {\n return {};\n }\n return configYaml;\n } catch (e) {\n if (e instanceof YAMLException) {\n return null;\n } else {\n throw e;\n }\n }\n}\n\n/**\n * Returns an array containing all valid projects ({ id, name })\n * currently contained in the project config file.\n */\nexport const getSelectedProjects = (configFile = PROJECT_CONFIG_FILE) =>\n Config.parseSourceInformation(configFile).validProjects;\n\nexport const getIsUsingComponents = (configFile = PROJECT_CONFIG_FILE) =>\n Config.parseSourceInformation(configFile).shouldFetchComponentLibrary;\n"],"names":["yaml","Config"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,qBAAoC;AAEpC,oBAAoC;AAEpC,oBAA4C;AAE5C,SAAS,iBAAiB,MAAmC;AAC3D,SAAO,OAAO,SAAS;AACzB;AAEA,SAAS,WAAW,OAAkC;AACpD,MAAI;AACF,QAAI,aAAa,eAAAA,QAAK,KAAK,KAAK;AAChC,QAAI,CAAC,iBAAiB,UAAU,GAAG;AACjC,aAAO,CAAC;AAAA,IACV;AACA,WAAO;AAAA,EACT,SAAS,GAAG;AACV,QAAI,aAAa,8BAAe;AAC9B,aAAO;AAAA,IACT,OAAO;AACL,YAAM;AAAA,IACR;AAAA,EACF;AACF;AAMO,MAAM,sBAAsB,CAAC,aAAa,sCAC/C,cAAAC,QAAO,uBAAuB,UAAU,EAAE;AAErC,MAAM,uBAAuB,CAAC,aAAa,sCAChD,cAAAA,QAAO,uBAAuB,UAAU,EAAE","debug_id":"3231592f-fedc-5607-aa4c-eae91957e0ed"}
|
|
@@ -1,15 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c525184f-324d-5943-8f1b-e87d9ab60ce4")}catch(e){}}();
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
var processMetaOption_exports = {};
|
|
22
|
+
__export(processMetaOption_exports, {
|
|
23
|
+
default: () => processMetaOption_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(processMetaOption_exports);
|
|
3
26
|
const processMetaOption = (inputArr) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return res;
|
|
7
|
-
}
|
|
8
|
-
inputArr.forEach((element) => {
|
|
9
|
-
const [key, value] = element.split(":");
|
|
10
|
-
res[key] = value;
|
|
11
|
-
});
|
|
27
|
+
const res = {};
|
|
28
|
+
if (!Array.isArray(inputArr)) {
|
|
12
29
|
return res;
|
|
30
|
+
}
|
|
31
|
+
inputArr.forEach((element) => {
|
|
32
|
+
const [key, value] = element.split(":");
|
|
33
|
+
res[key] = value;
|
|
34
|
+
});
|
|
35
|
+
return res;
|
|
13
36
|
};
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=processMetaOption.js.map
|
|
37
|
+
var processMetaOption_default = processMetaOption;
|
|
38
|
+
//# sourceMappingURL=processMetaOption.js.map
|
|
39
|
+
|
|
40
|
+
//# debugId=c525184f-324d-5943-8f1b-e87d9ab60ce4
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../lib/utils/processMetaOption.ts"],"sourcesContent":["const processMetaOption = (inputArr: string[] | null) => {\n const res: Record<string, string> = {};\n\n if (!Array.isArray(inputArr)) {\n return res;\n }\n\n inputArr.forEach((element) => {\n const [key, value] = element.split(\":\");\n res[key] = value;\n });\n\n return res;\n};\n\nexport default processMetaOption;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAM,oBAAoB,CAAC,aAA8B;AACvD,QAAM,MAA8B,CAAC;AAErC,MAAI,CAAC,MAAM,QAAQ,QAAQ,GAAG;AAC5B,WAAO;AAAA,EACT;AAEA,WAAS,QAAQ,CAAC,YAAY;AAC5B,UAAM,CAAC,KAAK,KAAK,IAAI,QAAQ,MAAM,GAAG;AACtC,QAAI,GAAG,IAAI;AAAA,EACb,CAAC;AAED,SAAO;AACT;AAEA,IAAO,4BAAQ","debug_id":"c525184f-324d-5943-8f1b-e87d9ab60ce4"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ebbc53d3-6211-5d1c-95c9-289cf0e1f003")}catch(e){}}();
|
|
3
|
+
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
+
mod
|
|
25
|
+
));
|
|
26
|
+
var import_processMetaOption = __toESM(require("./processMetaOption"));
|
|
27
|
+
describe("processMetaOption tests", () => {
|
|
28
|
+
it("It parses correctly", () => {
|
|
29
|
+
expect(
|
|
30
|
+
(0, import_processMetaOption.default)(["githubActionRequest:true", "trigger:manual"])
|
|
31
|
+
).toEqual({
|
|
32
|
+
githubActionRequest: "true",
|
|
33
|
+
trigger: "manual"
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
it("Malformed doesnt crash", () => {
|
|
37
|
+
expect((0, import_processMetaOption.default)(["context:github-action", "trigger"])).toEqual({
|
|
38
|
+
context: "github-action",
|
|
39
|
+
trigger: void 0
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=processMetaOption.test.js.map
|
|
44
|
+
|
|
45
|
+
//# debugId=ebbc53d3-6211-5d1c-95c9-289cf0e1f003
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../lib/utils/processMetaOption.test.ts"],"sourcesContent":["import processMetaOption from \"./processMetaOption\";\n\ndescribe(\"processMetaOption tests\", () => {\n it(\"It parses correctly\", () => {\n expect(\n processMetaOption([\"githubActionRequest:true\", \"trigger:manual\"])\n ).toEqual({\n githubActionRequest: \"true\",\n trigger: \"manual\",\n });\n });\n it(\"Malformed doesnt crash\", () => {\n expect(processMetaOption([\"context:github-action\", \"trigger\"])).toEqual({\n context: \"github-action\",\n trigger: undefined,\n });\n });\n});\n"],"names":["processMetaOption"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA8B;AAE9B,SAAS,2BAA2B,MAAM;AACxC,KAAG,uBAAuB,MAAM;AAC9B;AAAA,UACE,yBAAAA,SAAkB,CAAC,4BAA4B,gBAAgB,CAAC;AAAA,IAClE,EAAE,QAAQ;AAAA,MACR,qBAAqB;AAAA,MACrB,SAAS;AAAA,IACX,CAAC;AAAA,EACH,CAAC;AACD,KAAG,0BAA0B,MAAM;AACjC,eAAO,yBAAAA,SAAkB,CAAC,yBAAyB,SAAS,CAAC,CAAC,EAAE,QAAQ;AAAA,MACtE,SAAS;AAAA,MACT,SAAS;AAAA,IACX,CAAC;AAAA,EACH,CAAC;AACH,CAAC","debug_id":"ebbc53d3-6211-5d1c-95c9-289cf0e1f003"}
|