@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
@@ -1,25 +1,58 @@
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]="5e28c3ce-4de9-550f-b217-136daac25752")}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 });
4
13
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getSourceUrl = void 0;
7
- const output_1 = __importDefault(require("../output"));
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;
21
+ };
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 projectsToText_exports = {};
32
+ __export(projectsToText_exports, {
33
+ default: () => projectsToText_default,
34
+ getSourceUrl: () => getSourceUrl
35
+ });
36
+ module.exports = __toCommonJS(projectsToText_exports);
37
+ var import_output = __toESM(require("../output"));
8
38
  const getSourceUrl = (sourceId) => {
9
- let base = "https://app.dittowords.com";
10
- if (sourceId === "ditto_component_library") {
11
- return `${base}/components`;
12
- }
13
- return `${base}/doc/${sourceId}`;
39
+ let base = "https://app.dittowords.com";
40
+ if (sourceId === "ditto_component_library") {
41
+ return `${base}/components`;
42
+ }
43
+ return `${base}/doc/${sourceId}`;
14
44
  };
15
- exports.getSourceUrl = getSourceUrl;
16
45
  const projectsToText = (projects) => {
17
- return ((projects || []).reduce((outputString, { name, id }) => outputString +
18
- ("\n" +
19
- "- " +
20
- output_1.default.info(name) +
21
- " " +
22
- output_1.default.subtle((0, exports.getSourceUrl)(id))), "") + "\n");
46
+ return (projects || []).reduce(
47
+ (outputString, { name, id }) => outputString + ("\n- " + import_output.default.info(name) + " " + import_output.default.subtle(getSourceUrl(id))),
48
+ ""
49
+ ) + "\n";
23
50
  };
24
- exports.default = projectsToText;
25
- //# sourceMappingURL=projectsToText.js.map
51
+ var projectsToText_default = projectsToText;
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ getSourceUrl
55
+ });
56
+ //# sourceMappingURL=projectsToText.js.map
57
+
58
+ //# debugId=5e28c3ce-4de9-550f-b217-136daac25752
@@ -1 +1 @@
1
- {"version":3,"file":"projectsToText.js","sourceRoot":"","sources":["../../lib/utils/projectsToText.ts"],"names":[],"mappings":";;;;;;AAAA,uDAA+B;AAGxB,MAAM,YAAY,GAAG,CAAC,QAAgB,EAAE,EAAE;IAC/C,IAAI,IAAI,GAAG,4BAA4B,CAAC;IAExC,IAAI,QAAQ,KAAK,yBAAyB,EAAE;QAC1C,OAAO,GAAG,IAAI,aAAa,CAAC;KAC7B;IAED,OAAO,GAAG,IAAI,QAAQ,QAAQ,EAAE,CAAC;AACnC,CAAC,CAAC;AARW,QAAA,YAAY,gBAQvB;AAEF,MAAM,cAAc,GAAG,CAAC,QAAmB,EAAE,EAAE;IAC7C,OAAO,CACL,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,MAAM,CACrB,CAAC,YAAY,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,CAC7B,YAAY;QACZ,CAAC,IAAI;YACH,IAAI;YACJ,gBAAM,CAAC,IAAI,CAAC,IAAI,CAAC;YACjB,GAAG;YACH,gBAAM,CAAC,MAAM,CAAC,IAAA,oBAAY,EAAC,EAAE,CAAC,CAAC,CAAC,EACpC,EAAE,CACH,GAAG,IAAI,CACT,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,cAAc,CAAC"}
1
+ {"version":3,"sources":["../../lib/utils/projectsToText.ts"],"sourcesContent":["import output from \"../output\";\nimport { Project } from \"../types\";\n\nexport const getSourceUrl = (sourceId: string) => {\n let base = \"https://app.dittowords.com\";\n\n if (sourceId === \"ditto_component_library\") {\n return `${base}/components`;\n }\n\n return `${base}/doc/${sourceId}`;\n};\n\nconst projectsToText = (projects: Project[]) => {\n return (\n (projects || []).reduce(\n (outputString, { name, id }) =>\n outputString +\n (\"\\n\" +\n \"- \" +\n output.info(name) +\n \" \" +\n output.subtle(getSourceUrl(id))),\n \"\"\n ) + \"\\n\"\n );\n};\n\nexport default projectsToText;\n"],"names":["output"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;AAGZ,MAAM,eAAe,CAAC,aAAqB;AAChD,MAAI,OAAO;AAEX,MAAI,aAAa,2BAA2B;AAC1C,WAAO,GAAG,IAAI;AAAA,EAChB;AAEA,SAAO,GAAG,IAAI,QAAQ,QAAQ;AAChC;AAEA,MAAM,iBAAiB,CAAC,aAAwB;AAC9C,UACG,YAAY,CAAC,GAAG;AAAA,IACf,CAAC,cAAc,EAAE,MAAM,GAAG,MACxB,gBACC,SAEC,cAAAA,QAAO,KAAK,IAAI,IAChB,MACA,cAAAA,QAAO,OAAO,aAAa,EAAE,CAAC;AAAA,IAClC;AAAA,EACF,IAAI;AAER;AAEA,IAAO,yBAAQ","debug_id":"5e28c3ce-4de9-550f-b217-136daac25752"}
@@ -1,43 +1,96 @@
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]="c2b32c60-9b9e-5fd5-a0cf-c7abcca52fb8")}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 });
4
13
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
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;
21
+ };
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 __async = (__this, __arguments, generator) => {
32
+ return new Promise((resolve, reject) => {
33
+ var fulfilled = (value) => {
34
+ try {
35
+ step(generator.next(value));
36
+ } catch (e) {
37
+ reject(e);
38
+ }
39
+ };
40
+ var rejected = (value) => {
41
+ try {
42
+ step(generator.throw(value));
43
+ } catch (e) {
44
+ reject(e);
45
+ }
46
+ };
47
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
48
+ step((generator = generator.apply(__this, __arguments)).next());
49
+ });
50
+ };
51
+ var promptForProject_exports = {};
52
+ __export(promptForProject_exports, {
53
+ default: () => promptForProject_default
54
+ });
55
+ module.exports = __toCommonJS(promptForProject_exports);
56
+ var import_output = __toESM(require("../output"));
57
+ var import_projectsToText = require("./projectsToText");
6
58
  const { AutoComplete } = require("enquirer");
7
- const output_1 = __importDefault(require("../output"));
8
- const projectsToText_1 = require("./projectsToText");
9
59
  function formatProjectChoice(project) {
10
- return (project.name + " " + output_1.default.subtle(project.url || (0, projectsToText_1.getSourceUrl)(project.id)));
60
+ return project.name + " " + import_output.default.subtle(project.url || (0, import_projectsToText.getSourceUrl)(project.id));
11
61
  }
12
62
  function parseResponse(response) {
13
- if (!response) {
14
- return null;
15
- }
16
- const [, name, id] = response.split(/^(.*)\s.*http.*\/(\w+).*$/);
17
- if (id === "all") {
18
- return { name, id: "ditto_component_library" };
19
- }
20
- return { name, id };
63
+ if (!response) {
64
+ return null;
65
+ }
66
+ const [, name, id] = response.split(/^(.*)\s.*http.*\/(\w+).*$/);
67
+ if (id === "all") {
68
+ return { name, id: "ditto_component_library" };
69
+ }
70
+ return { name, id };
21
71
  }
22
- const promptForProject = async ({ message, projects, limit = 10, }) => {
23
- output_1.default.nl();
24
- const choices = projects.map(formatProjectChoice);
25
- const prompt = new AutoComplete({
26
- name: "project",
27
- message,
28
- limit,
29
- choices,
30
- });
31
- let response;
32
- try {
33
- response = await prompt.run();
34
- }
35
- catch (e) {
36
- // this catch handles the case where someone presses
37
- // Ctrl + C to kill the AutoComplete process
38
- response = null;
39
- }
40
- return parseResponse(response);
41
- };
42
- exports.default = promptForProject;
43
- //# sourceMappingURL=promptForProject.js.map
72
+ const promptForProject = (_0) => __async(void 0, [_0], function* ({
73
+ message,
74
+ projects,
75
+ limit = 10
76
+ }) {
77
+ import_output.default.nl();
78
+ const choices = projects.map(formatProjectChoice);
79
+ const prompt = new AutoComplete({
80
+ name: "project",
81
+ message,
82
+ limit,
83
+ choices
84
+ });
85
+ let response;
86
+ try {
87
+ response = yield prompt.run();
88
+ } catch (e) {
89
+ response = null;
90
+ }
91
+ return parseResponse(response);
92
+ });
93
+ var promptForProject_default = promptForProject;
94
+ //# sourceMappingURL=promptForProject.js.map
95
+
96
+ //# debugId=c2b32c60-9b9e-5fd5-a0cf-c7abcca52fb8
@@ -1 +1 @@
1
- {"version":3,"file":"promptForProject.js","sourceRoot":"","sources":["../../lib/utils/promptForProject.ts"],"names":[],"mappings":";;;;;AAAA,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAE7C,uDAA+B;AAE/B,qDAAgD;AAEhD,SAAS,mBAAmB,CAAC,OAAgB;IAC3C,OAAO,CACL,OAAO,CAAC,IAAI,GAAG,GAAG,GAAG,gBAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,IAAA,6BAAY,EAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAC5E,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,QAAgB;IACrC,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,IAAI,CAAC;KACb;IAED,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAEjE,IAAI,EAAE,KAAK,KAAK,EAAE;QAChB,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,yBAAyB,EAAE,CAAC;KAChD;IAED,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;AACtB,CAAC;AAQD,MAAM,gBAAgB,GAAG,KAAK,EAAE,EAC9B,OAAO,EACP,QAAQ,EACR,KAAK,GAAG,EAAE,GACU,EAAE,EAAE;IACxB,gBAAM,CAAC,EAAE,EAAE,CAAC;IAEZ,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC;QAC9B,IAAI,EAAE,SAAS;QACf,OAAO;QACP,KAAK;QACL,OAAO;KACR,CAAC,CAAC;IAEH,IAAI,QAAQ,CAAC;IAEb,IAAI;QACF,QAAQ,GAAG,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC;KAC/B;IAAC,OAAO,CAAC,EAAE;QACV,oDAAoD;QACpD,4CAA4C;QAC5C,QAAQ,GAAG,IAAI,CAAC;KACjB;IAED,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC,CAAC;AAEF,kBAAe,gBAAgB,CAAC"}
1
+ {"version":3,"sources":["../../lib/utils/promptForProject.ts"],"sourcesContent":["const { AutoComplete } = require(\"enquirer\");\n\nimport output from \"../output\";\nimport { Project } from \"../types\";\nimport { getSourceUrl } from \"./projectsToText\";\n\nfunction formatProjectChoice(project: Project) {\n return (\n project.name + \" \" + output.subtle(project.url || getSourceUrl(project.id))\n );\n}\n\nfunction parseResponse(response: string) {\n if (!response) {\n return null;\n }\n\n const [, name, id] = response.split(/^(.*)\\s.*http.*\\/(\\w+).*$/);\n\n if (id === \"all\") {\n return { name, id: \"ditto_component_library\" };\n }\n\n return { name, id };\n}\n\ninterface ProjectPromptParams {\n message: string;\n projects: Project[];\n limit?: number;\n}\n\nconst promptForProject = async ({\n message,\n projects,\n limit = 10,\n}: ProjectPromptParams) => {\n output.nl();\n\n const choices = projects.map(formatProjectChoice);\n const prompt = new AutoComplete({\n name: \"project\",\n message,\n limit,\n choices,\n });\n\n let response;\n\n try {\n response = await prompt.run();\n } catch (e) {\n // this catch handles the case where someone presses\n // Ctrl + C to kill the AutoComplete process\n response = null;\n }\n\n return parseResponse(response);\n};\n\nexport default promptForProject;\n"],"names":["output"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,oBAAmB;AAEnB,4BAA6B;AAJ7B,MAAM,EAAE,aAAa,IAAI,QAAQ,UAAU;AAM3C,SAAS,oBAAoB,SAAkB;AAC7C,SACE,QAAQ,OAAO,MAAM,cAAAA,QAAO,OAAO,QAAQ,WAAO,oCAAa,QAAQ,EAAE,CAAC;AAE9E;AAEA,SAAS,cAAc,UAAkB;AACvC,MAAI,CAAC,UAAU;AACb,WAAO;AAAA,EACT;AAEA,QAAM,CAAC,EAAE,MAAM,EAAE,IAAI,SAAS,MAAM,2BAA2B;AAE/D,MAAI,OAAO,OAAO;AAChB,WAAO,EAAE,MAAM,IAAI,0BAA0B;AAAA,EAC/C;AAEA,SAAO,EAAE,MAAM,GAAG;AACpB;AAQA,MAAM,mBAAmB,CAAO,OAIL,iBAJK,KAIL,WAJK;AAAA,EAC9B;AAAA,EACA;AAAA,EACA,QAAQ;AACV,GAA2B;AACzB,gBAAAA,QAAO,GAAG;AAEV,QAAM,UAAU,SAAS,IAAI,mBAAmB;AAChD,QAAM,SAAS,IAAI,aAAa;AAAA,IAC9B,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,MAAI;AAEJ,MAAI;AACF,eAAW,MAAM,OAAO,IAAI;AAAA,EAC9B,SAAS,GAAG;AAGV,eAAW;AAAA,EACb;AAEA,SAAO,cAAc,QAAQ;AAC/B;AAEA,IAAO,2BAAQ","debug_id":"c2b32c60-9b9e-5fd5-a0cf-c7abcca52fb8"}
package/bin/utils/quit.js CHANGED
@@ -1,10 +1,39 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.quit = 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]="4e7dfedc-459a-5b77-bc0f-5524b331ec6d")}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 quit_exports = {};
22
+ __export(quit_exports, {
23
+ quit: () => quit
24
+ });
25
+ module.exports = __toCommonJS(quit_exports);
4
26
  function quit(message, exitCode = 2) {
5
- console.log(`\n${message}\n`);
6
- process.exitCode = exitCode;
7
- process.exit();
27
+ if (message)
28
+ console.log(`
29
+ ${message}
30
+ `);
31
+ process.exitCode = exitCode;
8
32
  }
9
- exports.quit = quit;
10
- //# sourceMappingURL=quit.js.map
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ quit
36
+ });
37
+ //# sourceMappingURL=quit.js.map
38
+
39
+ //# debugId=4e7dfedc-459a-5b77-bc0f-5524b331ec6d
@@ -1 +1 @@
1
- {"version":3,"file":"quit.js","sourceRoot":"","sources":["../../lib/utils/quit.ts"],"names":[],"mappings":";;;AAAA,SAAgB,IAAI,CAAC,OAAe,EAAE,QAAQ,GAAG,CAAC;IAChD,OAAO,CAAC,GAAG,CAAC,KAAK,OAAO,IAAI,CAAC,CAAC;IAC9B,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC5B,OAAO,CAAC,IAAI,EAAE,CAAC;AACjB,CAAC;AAJD,oBAIC"}
1
+ {"version":3,"sources":["../../lib/utils/quit.ts"],"sourcesContent":["export function quit(message: string | null, exitCode = 2) {\n if (message) console.log(`\\n${message}\\n`);\n process.exitCode = exitCode;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,SAAS,KAAK,SAAwB,WAAW,GAAG;AACzD,MAAI;AAAS,YAAQ,IAAI;AAAA,EAAK,OAAO;AAAA,CAAI;AACzC,UAAQ,WAAW;AACrB","debug_id":"4e7dfedc-459a-5b77-bc0f-5524b331ec6d"}
@@ -1,25 +1,57 @@
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]="c6e0760f-496a-5973-a0e9-8a4b5186d73d")}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 });
4
13
  };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const output_1 = __importDefault(require("../output"));
7
- const projectsToText_1 = __importDefault(require("./projectsToText"));
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;
21
+ };
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 sourcesToText_exports = {};
32
+ __export(sourcesToText_exports, {
33
+ default: () => sourcesToText_default
34
+ });
35
+ module.exports = __toCommonJS(sourcesToText_exports);
36
+ var import_output = __toESM(require("../output"));
37
+ var import_projectsToText = __toESM(require("./projectsToText"));
8
38
  const sourcesToText = (projects, componentLibrary) => {
9
- let message = "";
10
- if (componentLibrary) {
11
- message += `the ${output_1.default.info("Ditto Component Library")}`;
12
- if ((projects || []).length) {
13
- message += " and ";
14
- }
15
- else {
16
- message += "..";
17
- }
18
- }
39
+ let message = "";
40
+ if (componentLibrary) {
41
+ message += `the ${import_output.default.info("Ditto Component Library")}`;
19
42
  if ((projects || []).length) {
20
- message += `the following projects: ${(0, projectsToText_1.default)(projects)}\n`;
43
+ message += " and ";
44
+ } else {
45
+ message += "..";
21
46
  }
22
- return message;
47
+ }
48
+ if ((projects || []).length) {
49
+ message += `the following projects: ${(0, import_projectsToText.default)(projects)}
50
+ `;
51
+ }
52
+ return message;
23
53
  };
24
- exports.default = sourcesToText;
25
- //# sourceMappingURL=sourcesToText.js.map
54
+ var sourcesToText_default = sourcesToText;
55
+ //# sourceMappingURL=sourcesToText.js.map
56
+
57
+ //# debugId=c6e0760f-496a-5973-a0e9-8a4b5186d73d
@@ -1 +1 @@
1
- {"version":3,"file":"sourcesToText.js","sourceRoot":"","sources":["../../lib/utils/sourcesToText.ts"],"names":[],"mappings":";;;;;AAAA,uDAA+B;AAC/B,sEAA8C;AAG9C,MAAM,aAAa,GAAG,CAAC,QAAmB,EAAE,gBAAyB,EAAE,EAAE;IACvE,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,IAAI,gBAAgB,EAAE;QACpB,OAAO,IAAI,OAAO,gBAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,EAAE,CAAC;QAE3D,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;YAC3B,OAAO,IAAI,OAAO,CAAC;SACpB;aAAM;YACL,OAAO,IAAI,IAAI,CAAC;SACjB;KACF;IAED,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;QAC3B,OAAO,IAAI,2BAA2B,IAAA,wBAAc,EAAC,QAAQ,CAAC,IAAI,CAAC;KACpE;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,kBAAe,aAAa,CAAC"}
1
+ {"version":3,"sources":["../../lib/utils/sourcesToText.ts"],"sourcesContent":["import output from \"../output\";\nimport projectsToText from \"./projectsToText\";\nimport { Project } from \"../types\";\n\nconst sourcesToText = (projects: Project[], componentLibrary: boolean) => {\n let message = \"\";\n\n if (componentLibrary) {\n message += `the ${output.info(\"Ditto Component Library\")}`;\n\n if ((projects || []).length) {\n message += \" and \";\n } else {\n message += \"..\";\n }\n }\n\n if ((projects || []).length) {\n message += `the following projects: ${projectsToText(projects)}\\n`;\n }\n\n return message;\n};\n\nexport default sourcesToText;\n"],"names":["output","projectsToText"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;AACnB,4BAA2B;AAG3B,MAAM,gBAAgB,CAAC,UAAqB,qBAA8B;AACxE,MAAI,UAAU;AAEd,MAAI,kBAAkB;AACpB,eAAW,OAAO,cAAAA,QAAO,KAAK,yBAAyB,CAAC;AAExD,SAAK,YAAY,CAAC,GAAG,QAAQ;AAC3B,iBAAW;AAAA,IACb,OAAO;AACL,iBAAW;AAAA,IACb;AAAA,EACF;AAEA,OAAK,YAAY,CAAC,GAAG,QAAQ;AAC3B,eAAW,+BAA2B,sBAAAC,SAAe,QAAQ,CAAC;AAAA;AAAA,EAChE;AAEA,SAAO;AACT;AAEA,IAAO,wBAAQ","debug_id":"c6e0760f-496a-5973-a0e9-8a4b5186d73d"}
package/etsc.config.js ADDED
@@ -0,0 +1,13 @@
1
+ const dotenv = require("dotenv");
2
+ dotenv.config();
3
+
4
+ module.exports = {
5
+ esbuild: {
6
+ platform: "node",
7
+ packages: "external",
8
+ define: {
9
+ "process.env.ENV": `"${process.env.ENV || "production"}"`,
10
+ "process.env.SENTRY_DSN": `"${process.env.SENTRY_DSN}"`,
11
+ },
12
+ },
13
+ };
package/lib/config.ts CHANGED
@@ -2,14 +2,15 @@ import fs from "fs";
2
2
  import path from "path";
3
3
  import url from "url";
4
4
  import yaml from "js-yaml";
5
+ import * as Sentry from "@sentry/node";
5
6
 
6
- import output from "./output";
7
7
  import consts from "./consts";
8
- import { Project, ConfigYAML } from "./types";
8
+ import { createSentryContext } from "./utils/createSentryContext";
9
+ import { Project, ConfigYAML, SourceInformation } from "./types";
9
10
 
10
11
  export const DEFAULT_CONFIG_JSON: ConfigYAML = {
11
12
  sources: {
12
- components: { enabled: true },
13
+ components: true,
13
14
  },
14
15
  variants: true,
15
16
  format: "flat",
@@ -154,6 +155,7 @@ function getToken(file: string, host: string) {
154
155
  const hostEntry = data[justTheHost(host)];
155
156
  if (!hostEntry) return undefined;
156
157
  const { length } = hostEntry;
158
+
157
159
  return hostEntry[length - 1].token;
158
160
  }
159
161
 
@@ -186,7 +188,7 @@ function dedupeProjectName(projectNames: Set<string>, projectName: string) {
186
188
  * - an array of valid, deduped projects
187
189
  * - the `variants` and `format` config options
188
190
  */
189
- function parseSourceInformation(file?: string) {
191
+ function parseSourceInformation(file?: string): SourceInformation {
190
192
  const {
191
193
  sources,
192
194
  variants,
@@ -220,11 +222,23 @@ function parseSourceInformation(file?: string) {
220
222
  validProjects.push(project);
221
223
  });
222
224
 
223
- const shouldFetchComponentLibrary = Boolean(sources?.components?.enabled);
224
-
225
+ const shouldFetchComponentLibrary = Boolean(sources?.components);
226
+ const componentRoot =
227
+ typeof sources?.components === "object"
228
+ ? sources.components.root
229
+ : undefined;
230
+ const componentFolders =
231
+ typeof sources?.components === "object"
232
+ ? sources.components.folders
233
+ : undefined;
234
+
235
+ /**
236
+ * If it's not specified to fetch projects or the component library, then there
237
+ * is no source data to pull.
238
+ */
225
239
  const hasSourceData = !!validProjects.length || shouldFetchComponentLibrary;
226
240
 
227
- return {
241
+ const result = {
228
242
  hasSourceData,
229
243
  validProjects,
230
244
  shouldFetchComponentLibrary,
@@ -235,8 +249,13 @@ function parseSourceInformation(file?: string) {
235
249
  hasTopLevelProjectsField: !!projectsRoot,
236
250
  hasTopLevelComponentsField: !!componentsRoot,
237
251
  hasComponentLibraryInProjects,
238
- componentFolders: sources?.components?.folders || null,
252
+ componentRoot,
253
+ componentFolders,
239
254
  };
255
+
256
+ Sentry.setContext("config", createSentryContext(result));
257
+
258
+ return result;
240
259
  }
241
260
 
242
261
  export default {
package/lib/ditto.ts CHANGED
@@ -5,6 +5,8 @@ import { program } from "commander";
5
5
  import "v8-compile-cache";
6
6
  import fs from "fs";
7
7
  import path from "path";
8
+ import * as Sentry from "@sentry/node";
9
+ import { version as release } from "../package.json";
8
10
 
9
11
  import { init, needsTokenOrSource } from "./init/init";
10
12
  import { pull } from "./pull";
@@ -18,6 +20,9 @@ import processMetaOption from "./utils/processMetaOption";
18
20
  import { importComponents } from "./importComponents";
19
21
  import { showComponentFolders } from "./component-folders";
20
22
 
23
+ const environment = process.env.ENV || "development";
24
+ Sentry.init({ dsn: process.env.SENTRY_DSN, environment, release });
25
+
21
26
  function getVersion(): string {
22
27
  const packageJsonPath = path.join(__dirname, "..", "package.json");
23
28
  const packageJsonContent = fs.readFileSync(packageJsonPath, "utf8");
@@ -155,6 +160,7 @@ const setupCommands = () => {
155
160
  if (commandConfig.name === "project") {
156
161
  const command =
157
162
  `${commandConfig.name} ${nestedCommand.name}` as Command;
163
+
158
164
  return executeCommand(command, options);
159
165
  }
160
166
  });
@@ -17,7 +17,7 @@ import { quit } from "../utils/quit";
17
17
  function saveProject(file: string, name: string, id: string) {
18
18
  if (id === "components") {
19
19
  config.writeProjectConfigData(file, {
20
- sources: { components: { enabled: true } },
20
+ sources: { components: true },
21
21
  });
22
22
  return;
23
23
  }
@@ -105,7 +105,7 @@ export const collectAndSaveSource = async (
105
105
  const token = config.getToken(consts.CONFIG_FILE, consts.API_HOST);
106
106
  const project = await collectSource(token, components);
107
107
  if (!project) {
108
- quit("", 0);
108
+ quit(null, 0);
109
109
  return;
110
110
  }
111
111
 
@@ -126,7 +126,7 @@ export const collectAndSaveSource = async (
126
126
  await askForAnotherToken();
127
127
  await collectAndSaveSource({ components });
128
128
  } else {
129
- quit("", 2);
129
+ quit(null, 2);
130
130
  }
131
131
  }
132
132
  };