@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.
Files changed (134) hide show
  1. package/README.md +125 -36
  2. package/bin/add-project.js +101 -33
  3. package/bin/add-project.js.map +1 -1
  4. package/bin/api.js +49 -15
  5. package/bin/api.js.map +1 -1
  6. package/bin/component-folders.js +56 -7
  7. package/bin/component-folders.js.map +1 -1
  8. package/bin/config.js +206 -170
  9. package/bin/config.js.map +1 -1
  10. package/bin/config.test.js +92 -0
  11. package/bin/config.test.js.map +1 -0
  12. package/bin/consts.js +64 -18
  13. package/bin/consts.js.map +1 -1
  14. package/bin/ditto.js +250 -200
  15. package/bin/ditto.js.map +1 -1
  16. package/bin/generate-suggestions.js +155 -78
  17. package/bin/generate-suggestions.js.map +1 -1
  18. package/bin/generate-suggestions.test.js +189 -0
  19. package/bin/generate-suggestions.test.js.map +1 -0
  20. package/bin/http/fetchComponentFolders.js +60 -8
  21. package/bin/http/fetchComponentFolders.js.map +1 -1
  22. package/bin/http/fetchComponents.js +65 -18
  23. package/bin/http/fetchComponents.js.map +1 -1
  24. package/bin/http/fetchVariants.js +74 -14
  25. package/bin/http/fetchVariants.js.map +1 -1
  26. package/bin/http/importComponents.js +100 -49
  27. package/bin/http/importComponents.js.map +1 -1
  28. package/bin/importComponents.js +61 -10
  29. package/bin/importComponents.js.map +1 -1
  30. package/bin/init/init.js +120 -44
  31. package/bin/init/init.js.map +1 -1
  32. package/bin/init/project.js +160 -83
  33. package/bin/init/project.js.map +1 -1
  34. package/bin/init/project.test.js +49 -0
  35. package/bin/init/project.test.js.map +1 -0
  36. package/bin/init/token.js +134 -74
  37. package/bin/init/token.js.map +1 -1
  38. package/bin/init/token.test.js +69 -0
  39. package/bin/init/token.test.js.map +1 -0
  40. package/bin/output.js +72 -30
  41. package/bin/output.js.map +1 -1
  42. package/bin/pull.js +424 -213
  43. package/bin/pull.js.map +1 -1
  44. package/bin/pull.test.js +410 -0
  45. package/bin/pull.test.js.map +1 -0
  46. package/bin/remove-project.js +91 -27
  47. package/bin/remove-project.js.map +1 -1
  48. package/bin/replace.js +140 -100
  49. package/bin/replace.js.map +1 -1
  50. package/bin/replace.test.js +155 -0
  51. package/bin/replace.test.js.map +1 -0
  52. package/bin/sentry-test.js.map +1 -0
  53. package/bin/types.js +20 -2
  54. package/bin/types.js.map +1 -1
  55. package/bin/utils/cleanFileName.js +32 -8
  56. package/bin/utils/cleanFileName.js.map +1 -1
  57. package/bin/utils/createSentryContext.js +43 -0
  58. package/bin/utils/createSentryContext.js.map +1 -0
  59. package/bin/utils/generateJsDriver.js +114 -51
  60. package/bin/utils/generateJsDriver.js.map +1 -1
  61. package/bin/utils/getSelectedProjects.js +58 -52
  62. package/bin/utils/getSelectedProjects.js.map +1 -1
  63. package/bin/utils/processMetaOption.js +36 -11
  64. package/bin/utils/processMetaOption.js.map +1 -1
  65. package/bin/utils/processMetaOption.test.js +45 -0
  66. package/bin/utils/processMetaOption.test.js.map +1 -0
  67. package/bin/utils/projectsToText.js +52 -19
  68. package/bin/utils/projectsToText.js.map +1 -1
  69. package/bin/utils/promptForProject.js +89 -36
  70. package/bin/utils/promptForProject.js.map +1 -1
  71. package/bin/utils/quit.js +36 -7
  72. package/bin/utils/quit.js.map +1 -1
  73. package/bin/utils/sourcesToText.js +51 -19
  74. package/bin/utils/sourcesToText.js.map +1 -1
  75. package/etsc.config.js +13 -0
  76. package/lib/config.ts +27 -8
  77. package/lib/ditto.ts +6 -0
  78. package/lib/init/project.ts +3 -3
  79. package/lib/pull.ts +190 -52
  80. package/lib/types.ts +24 -7
  81. package/lib/utils/createSentryContext.ts +20 -0
  82. package/lib/utils/generateJsDriver.ts +40 -6
  83. package/lib/utils/quit.ts +2 -3
  84. package/package.json +10 -6
  85. package/tsconfig.json +4 -1
  86. package/bin/lib/add-project.js +0 -36
  87. package/bin/lib/add-project.js.map +0 -1
  88. package/bin/lib/api.js +0 -20
  89. package/bin/lib/api.js.map +0 -1
  90. package/bin/lib/config.js +0 -202
  91. package/bin/lib/config.js.map +0 -1
  92. package/bin/lib/consts.js +0 -21
  93. package/bin/lib/consts.js.map +0 -1
  94. package/bin/lib/ditto.js +0 -121
  95. package/bin/lib/ditto.js.map +0 -1
  96. package/bin/lib/generate-suggestions.js +0 -71
  97. package/bin/lib/generate-suggestions.js.map +0 -1
  98. package/bin/lib/http/fetchComponents.js +0 -13
  99. package/bin/lib/http/fetchComponents.js.map +0 -1
  100. package/bin/lib/http/fetchVariants.js +0 -26
  101. package/bin/lib/http/fetchVariants.js.map +0 -1
  102. package/bin/lib/init/init.js +0 -50
  103. package/bin/lib/init/init.js.map +0 -1
  104. package/bin/lib/init/project.js +0 -108
  105. package/bin/lib/init/project.js.map +0 -1
  106. package/bin/lib/init/token.js +0 -91
  107. package/bin/lib/init/token.js.map +0 -1
  108. package/bin/lib/output.js +0 -34
  109. package/bin/lib/output.js.map +0 -1
  110. package/bin/lib/pull.js +0 -264
  111. package/bin/lib/pull.js.map +0 -1
  112. package/bin/lib/remove-project.js +0 -35
  113. package/bin/lib/remove-project.js.map +0 -1
  114. package/bin/lib/replace.js +0 -107
  115. package/bin/lib/replace.js.map +0 -1
  116. package/bin/lib/types.js +0 -3
  117. package/bin/lib/types.js.map +0 -1
  118. package/bin/lib/utils/cleanFileName.js +0 -11
  119. package/bin/lib/utils/cleanFileName.js.map +0 -1
  120. package/bin/lib/utils/generateJsDriver.js +0 -56
  121. package/bin/lib/utils/generateJsDriver.js.map +0 -1
  122. package/bin/lib/utils/getSelectedProjects.js +0 -61
  123. package/bin/lib/utils/getSelectedProjects.js.map +0 -1
  124. package/bin/lib/utils/processMetaOption.js +0 -15
  125. package/bin/lib/utils/processMetaOption.js.map +0 -1
  126. package/bin/lib/utils/projectsToText.js +0 -25
  127. package/bin/lib/utils/projectsToText.js.map +0 -1
  128. package/bin/lib/utils/promptForProject.js +0 -43
  129. package/bin/lib/utils/promptForProject.js.map +0 -1
  130. package/bin/lib/utils/quit.js +0 -10
  131. package/bin/lib/utils/quit.js.map +0 -1
  132. package/bin/lib/utils/sourcesToText.js +0 -25
  133. package/bin/lib/utils/sourcesToText.js.map +0 -1
  134. package/bin/package.json +0 -76
package/bin/types.js CHANGED
@@ -1,3 +1,21 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
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,"file":"types.js","sourceRoot":"","sources":["../lib/types.ts"],"names":[],"mappings":""}
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
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cleanFileName = void 0;
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
- return fileName
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
- exports.cleanFileName = cleanFileName;
11
- //# sourceMappingURL=cleanFileName.js.map
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,"file":"cleanFileName.js","sourceRoot":"","sources":["../../lib/utils/cleanFileName.ts"],"names":[],"mappings":";;;AAAA,SAAgB,aAAa,CAAC,QAAgB;IAC5C,OAAO,QAAQ;SACZ,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;SAC/B,WAAW,EAAE,CAAC;AACnB,CAAC;AALD,sCAKC"}
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 __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
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
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generateJsDriver = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
9
- const consts_1 = __importDefault(require("../consts"));
10
- const output_1 = __importDefault(require("../output"));
11
- const cleanFileName_1 = require("./cleanFileName");
12
- // compatability with legacy method of specifying project ids
13
- // that is still used by the default format
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
- const fileNames = fs_1.default
29
- .readdirSync(consts_1.default.TEXT_DIR)
30
- .filter((fileName) => /\.json$/.test(fileName));
31
- const sourceIdsByName = sources.reduce((agg, source) => {
32
- if (source.fileName) {
33
- return { ...agg, [(0, cleanFileName_1.cleanFileName)(source.fileName)]: source.id };
34
- }
35
- return agg;
36
- }, {});
37
- const data = fileNames.reduce((obj, fileName) => {
38
- const [sourceId, rest] = fileName.split("__");
39
- const [variantApiId] = rest.split(".");
40
- const projectId = sourceIdsByName[sourceId];
41
- const projectIdStr = stringifySourceId(projectId);
42
- if (!obj[projectIdStr]) {
43
- obj[projectIdStr] = {};
44
- }
45
- obj[projectIdStr][variantApiId] = `require('./${fileName}')`;
46
- return obj;
47
- }, {});
48
- let dataString = `module.exports = ${JSON.stringify(data, null, 2)}`
49
- // remove quotes around require statements
50
- .replace(/"require\((.*)\)"/g, "require($1)");
51
- const filePath = path_1.default.resolve(consts_1.default.TEXT_DIR, "index.js");
52
- fs_1.default.writeFileSync(filePath, dataString, { encoding: "utf8" });
53
- return `Generated .js SDK driver at ${output_1.default.info(filePath)}`;
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
- exports.generateJsDriver = generateJsDriver;
56
- //# sourceMappingURL=generateJsDriver.js.map
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,"file":"generateJsDriver.js","sourceRoot":"","sources":["../../lib/utils/generateJsDriver.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,uDAA+B;AAC/B,uDAA+B;AAE/B,mDAAgD;AAEhD,6DAA6D;AAC7D,2CAA2C;AAC3C,MAAM,iBAAiB,GAAG,CAAC,SAAiB,EAAE,EAAE,CAC9C,SAAS,KAAK,yBAAyB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,SAAS,EAAE,CAAC;AAE/E;;;;;;;;;;GAUG;AAEH,oBAAoB;AACpB,SAAgB,gBAAgB,CAAC,OAAiB;IAChD,MAAM,SAAS,GAAG,YAAE;SACjB,WAAW,CAAC,gBAAM,CAAC,QAAQ,CAAC;SAC5B,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IAElD,MAAM,eAAe,GAA2B,OAAO,CAAC,MAAM,CAC5D,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;QACd,IAAI,MAAM,CAAC,QAAQ,EAAE;YACnB,OAAO,EAAE,GAAG,GAAG,EAAE,CAAC,IAAA,6BAAa,EAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;SAChE;QAED,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAE,CACH,CAAC;IAEF,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,CAC3B,CAAC,GAA2C,EAAE,QAAQ,EAAE,EAAE;QACxD,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC9C,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEvC,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;QAC5C,MAAM,YAAY,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC;QAElD,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;YACtB,GAAG,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC;SACxB;QAED,GAAG,CAAC,YAAY,CAAC,CAAC,YAAY,CAAC,GAAG,cAAc,QAAQ,IAAI,CAAC;QAC7D,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAE,CACH,CAAC;IAEF,IAAI,UAAU,GAAG,oBAAoB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;QAClE,0CAA0C;SACzC,OAAO,CAAC,oBAAoB,EAAE,aAAa,CAAC,CAAC;IAEhD,MAAM,QAAQ,GAAG,cAAI,CAAC,OAAO,CAAC,gBAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC3D,YAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAE7D,OAAO,+BAA+B,gBAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;AAChE,CAAC;AA1CD,4CA0CC"}
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
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 __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
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
- Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.getIsUsingComponents = exports.getSelectedProjects = void 0;
30
- const js_yaml_1 = __importStar(require("js-yaml"));
31
- const consts_1 = require("../consts");
32
- const config_1 = __importDefault(require("../config"));
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
- return typeof json === "object";
41
+ return typeof json === "object";
35
42
  }
36
43
  function yamlToJson(_yaml) {
37
- try {
38
- let configYaml = js_yaml_1.default.load(_yaml);
39
- if (!jsonIsConfigYAML(configYaml)) {
40
- return {};
41
- }
42
- return configYaml;
44
+ try {
45
+ let configYaml = import_js_yaml.default.load(_yaml);
46
+ if (!jsonIsConfigYAML(configYaml)) {
47
+ return {};
43
48
  }
44
- catch (e) {
45
- if (e instanceof js_yaml_1.YAMLException) {
46
- return null;
47
- }
48
- else {
49
- throw e;
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
- * Returns an array containing all valid projects ({ id, name })
55
- * currently contained in the project config file.
56
- */
57
- const getSelectedProjects = (configFile = consts_1.PROJECT_CONFIG_FILE) => config_1.default.parseSourceInformation(configFile).validProjects;
58
- exports.getSelectedProjects = getSelectedProjects;
59
- const getIsUsingComponents = (configFile = consts_1.PROJECT_CONFIG_FILE) => config_1.default.parseSourceInformation(configFile).shouldFetchComponentLibrary;
60
- exports.getIsUsingComponents = getIsUsingComponents;
61
- //# sourceMappingURL=getSelectedProjects.js.map
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,"file":"getSelectedProjects.js","sourceRoot":"","sources":["../../lib/utils/getSelectedProjects.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mDAA8C;AAE9C,sCAAgD;AAEhD,uDAAwD;AAExD,SAAS,gBAAgB,CAAC,IAAa;IACrC,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC;AAClC,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI;QACF,IAAI,UAAU,GAAG,iBAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAClC,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,EAAE;YACjC,OAAO,EAAE,CAAC;SACX;QACD,OAAO,UAAU,CAAC;KACnB;IAAC,OAAO,CAAC,EAAE;QACV,IAAI,CAAC,YAAY,uBAAa,EAAE;YAC9B,OAAO,IAAI,CAAC;SACb;aAAM;YACL,MAAM,CAAC,CAAC;SACT;KACF;AACH,CAAC;AAED;;;GAGG;AACI,MAAM,mBAAmB,GAAG,CAAC,UAAU,GAAG,4BAAmB,EAAE,EAAE,CACtE,gBAAM,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAC,aAAa,CAAC;AAD7C,QAAA,mBAAmB,uBAC0B;AAEnD,MAAM,oBAAoB,GAAG,CAAC,UAAU,GAAG,4BAAmB,EAAE,EAAE,CACvE,gBAAM,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAC,2BAA2B,CAAC;AAD3D,QAAA,oBAAoB,wBACuC"}
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
- Object.defineProperty(exports, "__esModule", { value: true });
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
- const res = {};
5
- if (!Array.isArray(inputArr)) {
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
- exports.default = processMetaOption;
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,"file":"processMetaOption.js","sourceRoot":"","sources":["../../lib/utils/processMetaOption.ts"],"names":[],"mappings":";;AAAA,MAAM,iBAAiB,GAAG,CAAC,QAAyB,EAAE,EAAE;IACtD,MAAM,GAAG,GAA2B,EAAE,CAAC;IAEvC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC5B,OAAO,GAAG,CAAC;KACZ;IAED,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACxC,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,kBAAe,iBAAiB,CAAC"}
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"}