@dittowords/cli 3.10.1 → 4.0.0-alpha.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/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 +204 -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 +362 -221
- 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 +90 -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 +8 -2
- package/lib/ditto.ts +6 -0
- package/lib/init/project.ts +2 -2
- package/lib/pull.ts +22 -2
- package/lib/utils/createSentryContext.ts +20 -0
- 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
|
@@ -1,25 +1,58 @@
|
|
|
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]="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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
25
|
-
|
|
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,"
|
|
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
|
|
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]="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
|
-
|
|
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
|
-
|
|
60
|
+
return project.name + " " + import_output.default.subtle(project.url || (0, import_projectsToText.getSourceUrl)(project.id));
|
|
11
61
|
}
|
|
12
62
|
function parseResponse(response) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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 =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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,"
|
|
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
|
-
|
|
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]="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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
27
|
+
if (message)
|
|
28
|
+
console.log(`
|
|
29
|
+
${message}
|
|
30
|
+
`);
|
|
31
|
+
process.exitCode = exitCode;
|
|
8
32
|
}
|
|
9
|
-
|
|
10
|
-
|
|
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
|
package/bin/utils/quit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
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
|
|
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]="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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
43
|
+
message += " and ";
|
|
44
|
+
} else {
|
|
45
|
+
message += "..";
|
|
21
46
|
}
|
|
22
|
-
|
|
47
|
+
}
|
|
48
|
+
if ((projects || []).length) {
|
|
49
|
+
message += `the following projects: ${(0, import_projectsToText.default)(projects)}
|
|
50
|
+
`;
|
|
51
|
+
}
|
|
52
|
+
return message;
|
|
23
53
|
};
|
|
24
|
-
|
|
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,"
|
|
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,10 +2,11 @@ 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
8
|
import { Project, ConfigYAML } from "./types";
|
|
9
|
+
import { createSentryContext } from "./utils/createSentryContext";
|
|
9
10
|
|
|
10
11
|
export const DEFAULT_CONFIG_JSON: ConfigYAML = {
|
|
11
12
|
sources: {
|
|
@@ -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
|
|
|
@@ -224,7 +226,7 @@ function parseSourceInformation(file?: string) {
|
|
|
224
226
|
|
|
225
227
|
const hasSourceData = !!validProjects.length || shouldFetchComponentLibrary;
|
|
226
228
|
|
|
227
|
-
|
|
229
|
+
const result = {
|
|
228
230
|
hasSourceData,
|
|
229
231
|
validProjects,
|
|
230
232
|
shouldFetchComponentLibrary,
|
|
@@ -237,6 +239,10 @@ function parseSourceInformation(file?: string) {
|
|
|
237
239
|
hasComponentLibraryInProjects,
|
|
238
240
|
componentFolders: sources?.components?.folders || null,
|
|
239
241
|
};
|
|
242
|
+
|
|
243
|
+
Sentry.setContext("config", createSentryContext(result));
|
|
244
|
+
|
|
245
|
+
return result;
|
|
240
246
|
}
|
|
241
247
|
|
|
242
248
|
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
|
});
|
package/lib/init/project.ts
CHANGED
|
@@ -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(
|
|
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(
|
|
129
|
+
quit(null, 2);
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
};
|
package/lib/pull.ts
CHANGED
|
@@ -2,6 +2,7 @@ import fs from "fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
|
|
4
4
|
import ora from "ora";
|
|
5
|
+
import * as Sentry from "@sentry/node";
|
|
5
6
|
|
|
6
7
|
import { createApiClient } from "./api";
|
|
7
8
|
import config from "./config";
|
|
@@ -14,6 +15,8 @@ import { cleanFileName } from "./utils/cleanFileName";
|
|
|
14
15
|
import { SourceInformation, Token, Project, SupportedFormat } from "./types";
|
|
15
16
|
import { fetchVariants } from "./http/fetchVariants";
|
|
16
17
|
import { kMaxLength } from "buffer";
|
|
18
|
+
import { quit } from "./utils/quit";
|
|
19
|
+
import { AxiosError } from "axios";
|
|
17
20
|
|
|
18
21
|
const SUPPORTED_FORMATS: SupportedFormat[] = [
|
|
19
22
|
"flat",
|
|
@@ -402,12 +405,29 @@ export interface PullOptions {
|
|
|
402
405
|
meta?: Record<string, string>;
|
|
403
406
|
}
|
|
404
407
|
|
|
405
|
-
export const pull = (options?: PullOptions) => {
|
|
408
|
+
export const pull = async (options?: PullOptions) => {
|
|
406
409
|
const meta = options ? options.meta : {};
|
|
407
410
|
const token = config.getToken(consts.CONFIG_FILE, consts.API_HOST);
|
|
408
411
|
const sourceInformation = config.parseSourceInformation();
|
|
409
412
|
|
|
410
|
-
|
|
413
|
+
try {
|
|
414
|
+
return await downloadAndSave(sourceInformation, token, { meta });
|
|
415
|
+
} catch (e) {
|
|
416
|
+
Sentry.captureException(e);
|
|
417
|
+
if (e instanceof AxiosError) {
|
|
418
|
+
return quit(
|
|
419
|
+
output.errorText(
|
|
420
|
+
"Something went wrong connecting to Ditto servers. Please contact support or try again later."
|
|
421
|
+
)
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
return quit(
|
|
426
|
+
output.errorText(
|
|
427
|
+
"Something went wrong. Please contact support or try again later."
|
|
428
|
+
)
|
|
429
|
+
);
|
|
430
|
+
}
|
|
411
431
|
};
|
|
412
432
|
|
|
413
433
|
export default {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type SentryContext = Record<
|
|
2
|
+
string,
|
|
3
|
+
string | number | boolean | null | undefined
|
|
4
|
+
>;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Sentry context only supports properties one layer deep
|
|
8
|
+
*/
|
|
9
|
+
export function createSentryContext(obj: unknown) {
|
|
10
|
+
if (typeof obj !== "object") return {};
|
|
11
|
+
|
|
12
|
+
const ctx: SentryContext = {};
|
|
13
|
+
for (const key in obj) {
|
|
14
|
+
const k = key as keyof typeof obj;
|
|
15
|
+
const r = obj[k];
|
|
16
|
+
ctx[k] = typeof r === "object" || Array.isArray(r) ? JSON.stringify(r) : r;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return ctx;
|
|
20
|
+
}
|
package/lib/utils/quit.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dittowords/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.0",
|
|
4
4
|
"description": "Command Line Interface for Ditto (dittowords.com).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "bin/index.js",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"prepublish": "
|
|
8
|
+
"prepublish": "etsc && sentry-cli sourcemaps inject ./bin && npx sentry-cli sourcemaps upload ./bin --release=\"$(cat package.json | jq -r '.version')\"",
|
|
9
9
|
"prepare": "husky install",
|
|
10
|
-
"start": "
|
|
11
|
-
"sync": "
|
|
12
|
-
"dev": "
|
|
10
|
+
"start": "etsc && node bin/ditto.js",
|
|
11
|
+
"sync": "etsc && node bin/ditto.js pull",
|
|
12
|
+
"dev": "etsc --watch"
|
|
13
13
|
},
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
"url": "https://github.com/dittowords/cli/issues"
|
|
20
20
|
},
|
|
21
21
|
"author": "Ditto Tech Inc.",
|
|
22
|
-
"license": "MIT",
|
|
23
22
|
"keywords": [
|
|
24
23
|
"ditto",
|
|
25
24
|
"dittowords",
|
|
@@ -36,11 +35,15 @@
|
|
|
36
35
|
"devDependencies": {
|
|
37
36
|
"@babel/preset-env": "^7.20.2",
|
|
38
37
|
"@babel/preset-typescript": "^7.18.6",
|
|
38
|
+
"@sentry/cli": "^2.20.5",
|
|
39
39
|
"@tsconfig/node16": "^1.0.3",
|
|
40
40
|
"@types/jest": "^26.0.9",
|
|
41
41
|
"@types/js-yaml": "^4.0.5",
|
|
42
42
|
"@types/node": "^18.0.0",
|
|
43
43
|
"babel-jest": "^29.3.1",
|
|
44
|
+
"dotenv": "^16.3.1",
|
|
45
|
+
"esbuild": "^0.19.2",
|
|
46
|
+
"esbuild-node-tsc": "^2.0.5",
|
|
44
47
|
"husky": "^7.0.4",
|
|
45
48
|
"jest": "^29.3.1",
|
|
46
49
|
"lint-staged": "^11.2.4",
|
|
@@ -55,6 +58,7 @@
|
|
|
55
58
|
"@babel/parser": "^7.21.4",
|
|
56
59
|
"@babel/traverse": "^7.21.4",
|
|
57
60
|
"@babel/types": "^7.21.4",
|
|
61
|
+
"@sentry/node": "^7.64.0",
|
|
58
62
|
"@types/babel-traverse": "^6.25.7",
|
|
59
63
|
"@types/fs-extra": "^11.0.1",
|
|
60
64
|
"axios": "^0.27.2",
|
package/tsconfig.json
CHANGED
|
@@ -7,7 +7,10 @@
|
|
|
7
7
|
"resolveJsonModule": true,
|
|
8
8
|
"strictNullChecks": true,
|
|
9
9
|
"sourceMap": true,
|
|
10
|
+
// Set `sourceRoot` to "/" to strip the build path prefix from
|
|
11
|
+
// generated source code references. This will improve issue grouping in Sentry.
|
|
12
|
+
"sourceRoot": "/",
|
|
10
13
|
"strict": true
|
|
11
14
|
},
|
|
12
|
-
"include": ["lib
|
|
15
|
+
"include": ["lib/**/*.ts"]
|
|
13
16
|
}
|