@dittowords/cli 3.10.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -36
- package/bin/add-project.js +101 -33
- package/bin/add-project.js.map +1 -1
- package/bin/api.js +49 -15
- package/bin/api.js.map +1 -1
- package/bin/component-folders.js +56 -7
- package/bin/component-folders.js.map +1 -1
- package/bin/config.js +206 -170
- package/bin/config.js.map +1 -1
- package/bin/config.test.js +92 -0
- package/bin/config.test.js.map +1 -0
- package/bin/consts.js +64 -18
- package/bin/consts.js.map +1 -1
- package/bin/ditto.js +250 -200
- package/bin/ditto.js.map +1 -1
- package/bin/generate-suggestions.js +155 -78
- package/bin/generate-suggestions.js.map +1 -1
- package/bin/generate-suggestions.test.js +189 -0
- package/bin/generate-suggestions.test.js.map +1 -0
- package/bin/http/fetchComponentFolders.js +60 -8
- package/bin/http/fetchComponentFolders.js.map +1 -1
- package/bin/http/fetchComponents.js +65 -18
- package/bin/http/fetchComponents.js.map +1 -1
- package/bin/http/fetchVariants.js +74 -14
- package/bin/http/fetchVariants.js.map +1 -1
- package/bin/http/importComponents.js +100 -49
- package/bin/http/importComponents.js.map +1 -1
- package/bin/importComponents.js +61 -10
- package/bin/importComponents.js.map +1 -1
- package/bin/init/init.js +120 -44
- package/bin/init/init.js.map +1 -1
- package/bin/init/project.js +160 -83
- package/bin/init/project.js.map +1 -1
- package/bin/init/project.test.js +49 -0
- package/bin/init/project.test.js.map +1 -0
- package/bin/init/token.js +134 -74
- package/bin/init/token.js.map +1 -1
- package/bin/init/token.test.js +69 -0
- package/bin/init/token.test.js.map +1 -0
- package/bin/output.js +72 -30
- package/bin/output.js.map +1 -1
- package/bin/pull.js +424 -213
- package/bin/pull.js.map +1 -1
- package/bin/pull.test.js +410 -0
- package/bin/pull.test.js.map +1 -0
- package/bin/remove-project.js +91 -27
- package/bin/remove-project.js.map +1 -1
- package/bin/replace.js +140 -100
- package/bin/replace.js.map +1 -1
- package/bin/replace.test.js +155 -0
- package/bin/replace.test.js.map +1 -0
- package/bin/sentry-test.js.map +1 -0
- package/bin/types.js +20 -2
- package/bin/types.js.map +1 -1
- package/bin/utils/cleanFileName.js +32 -8
- package/bin/utils/cleanFileName.js.map +1 -1
- package/bin/utils/createSentryContext.js +43 -0
- package/bin/utils/createSentryContext.js.map +1 -0
- package/bin/utils/generateJsDriver.js +114 -51
- package/bin/utils/generateJsDriver.js.map +1 -1
- package/bin/utils/getSelectedProjects.js +58 -52
- package/bin/utils/getSelectedProjects.js.map +1 -1
- package/bin/utils/processMetaOption.js +36 -11
- package/bin/utils/processMetaOption.js.map +1 -1
- package/bin/utils/processMetaOption.test.js +45 -0
- package/bin/utils/processMetaOption.test.js.map +1 -0
- package/bin/utils/projectsToText.js +52 -19
- package/bin/utils/projectsToText.js.map +1 -1
- package/bin/utils/promptForProject.js +89 -36
- package/bin/utils/promptForProject.js.map +1 -1
- package/bin/utils/quit.js +36 -7
- package/bin/utils/quit.js.map +1 -1
- package/bin/utils/sourcesToText.js +51 -19
- package/bin/utils/sourcesToText.js.map +1 -1
- package/etsc.config.js +13 -0
- package/lib/config.ts +27 -8
- package/lib/ditto.ts +6 -0
- package/lib/init/project.ts +3 -3
- package/lib/pull.ts +190 -52
- package/lib/types.ts +24 -7
- package/lib/utils/createSentryContext.ts +20 -0
- package/lib/utils/generateJsDriver.ts +40 -6
- package/lib/utils/quit.ts +2 -3
- package/package.json +10 -6
- package/tsconfig.json +4 -1
- package/bin/lib/add-project.js +0 -36
- package/bin/lib/add-project.js.map +0 -1
- package/bin/lib/api.js +0 -20
- package/bin/lib/api.js.map +0 -1
- package/bin/lib/config.js +0 -202
- package/bin/lib/config.js.map +0 -1
- package/bin/lib/consts.js +0 -21
- package/bin/lib/consts.js.map +0 -1
- package/bin/lib/ditto.js +0 -121
- package/bin/lib/ditto.js.map +0 -1
- package/bin/lib/generate-suggestions.js +0 -71
- package/bin/lib/generate-suggestions.js.map +0 -1
- package/bin/lib/http/fetchComponents.js +0 -13
- package/bin/lib/http/fetchComponents.js.map +0 -1
- package/bin/lib/http/fetchVariants.js +0 -26
- package/bin/lib/http/fetchVariants.js.map +0 -1
- package/bin/lib/init/init.js +0 -50
- package/bin/lib/init/init.js.map +0 -1
- package/bin/lib/init/project.js +0 -108
- package/bin/lib/init/project.js.map +0 -1
- package/bin/lib/init/token.js +0 -91
- package/bin/lib/init/token.js.map +0 -1
- package/bin/lib/output.js +0 -34
- package/bin/lib/output.js.map +0 -1
- package/bin/lib/pull.js +0 -264
- package/bin/lib/pull.js.map +0 -1
- package/bin/lib/remove-project.js +0 -35
- package/bin/lib/remove-project.js.map +0 -1
- package/bin/lib/replace.js +0 -107
- package/bin/lib/replace.js.map +0 -1
- package/bin/lib/types.js +0 -3
- package/bin/lib/types.js.map +0 -1
- package/bin/lib/utils/cleanFileName.js +0 -11
- package/bin/lib/utils/cleanFileName.js.map +0 -1
- package/bin/lib/utils/generateJsDriver.js +0 -56
- package/bin/lib/utils/generateJsDriver.js.map +0 -1
- package/bin/lib/utils/getSelectedProjects.js +0 -61
- package/bin/lib/utils/getSelectedProjects.js.map +0 -1
- package/bin/lib/utils/processMetaOption.js +0 -15
- package/bin/lib/utils/processMetaOption.js.map +0 -1
- package/bin/lib/utils/projectsToText.js +0 -25
- package/bin/lib/utils/projectsToText.js.map +0 -1
- package/bin/lib/utils/promptForProject.js +0 -43
- package/bin/lib/utils/promptForProject.js.map +0 -1
- package/bin/lib/utils/quit.js +0 -10
- package/bin/lib/utils/quit.js.map +0 -1
- package/bin/lib/utils/sourcesToText.js +0 -25
- package/bin/lib/utils/sourcesToText.js.map +0 -1
- package/bin/package.json +0 -76
|
@@ -1,93 +1,170 @@
|
|
|
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]="aa8e9998-6730-545b-965d-fd7d54610668")}catch(e){}}();
|
|
3
|
+
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __defProps = Object.defineProperties;
|
|
7
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
8
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
9
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
11
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
12
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
14
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
15
|
+
var __spreadValues = (a, b) => {
|
|
16
|
+
for (var prop in b || (b = {}))
|
|
17
|
+
if (__hasOwnProp.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
if (__getOwnPropSymbols)
|
|
20
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
21
|
+
if (__propIsEnum.call(b, prop))
|
|
22
|
+
__defNormalProp(a, prop, b[prop]);
|
|
23
|
+
}
|
|
24
|
+
return a;
|
|
4
25
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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 __async = (__this, __arguments, generator) => {
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
var fulfilled = (value) => {
|
|
51
|
+
try {
|
|
52
|
+
step(generator.next(value));
|
|
53
|
+
} catch (e) {
|
|
54
|
+
reject(e);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var rejected = (value) => {
|
|
58
|
+
try {
|
|
59
|
+
step(generator.throw(value));
|
|
60
|
+
} catch (e) {
|
|
61
|
+
reject(e);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
65
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
var generate_suggestions_exports = {};
|
|
69
|
+
__export(generate_suggestions_exports, {
|
|
70
|
+
findComponentsInJSXFiles: () => findComponentsInJSXFiles,
|
|
71
|
+
generateSuggestions: () => generateSuggestions
|
|
72
|
+
});
|
|
73
|
+
module.exports = __toCommonJS(generate_suggestions_exports);
|
|
74
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
75
|
+
var import_glob = __toESM(require("glob"));
|
|
76
|
+
var import_parser = require("@babel/parser");
|
|
77
|
+
var import_traverse = __toESM(require("@babel/traverse"));
|
|
78
|
+
var import_fetchComponents = require("./http/fetchComponents");
|
|
79
|
+
function generateSuggestions(flags) {
|
|
80
|
+
return __async(this, null, function* () {
|
|
81
|
+
const components = yield (0, import_fetchComponents.fetchComponents)(__spreadValues({}, flags.componentFolder ? { componentFolder: flags.componentFolder } : {}));
|
|
16
82
|
const directory = flags.directory || ".";
|
|
17
|
-
const results =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
83
|
+
const results = yield findComponentsInJSXFiles({
|
|
84
|
+
directory,
|
|
85
|
+
files: flags.files,
|
|
86
|
+
components
|
|
21
87
|
});
|
|
22
|
-
// Display results to user
|
|
23
88
|
console.log(JSON.stringify(results, null, 2));
|
|
89
|
+
});
|
|
24
90
|
}
|
|
25
|
-
|
|
26
|
-
|
|
91
|
+
function findComponentsInJSXFiles(params) {
|
|
92
|
+
return __async(this, null, function* () {
|
|
27
93
|
const result = {};
|
|
28
|
-
const files = params.files ||
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
});
|
|
94
|
+
const files = params.files || import_glob.default.sync(`${params.directory}/**/*.+(jsx|tsx)`, {
|
|
95
|
+
ignore: "**/node_modules/**"
|
|
96
|
+
});
|
|
32
97
|
const promises = [];
|
|
33
98
|
for (const file of files) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
// Remove from result if no occurrences were found
|
|
77
|
-
if (Object.keys(result[compApiId]["occurrences"]).length === 0) {
|
|
78
|
-
delete result[compApiId];
|
|
79
|
-
}
|
|
99
|
+
promises.push(
|
|
100
|
+
import_fs_extra.default.readFile(file, "utf-8").then((code) => {
|
|
101
|
+
const ast = (0, import_parser.parse)(code, {
|
|
102
|
+
sourceType: "module",
|
|
103
|
+
plugins: ["jsx", "typescript"]
|
|
104
|
+
});
|
|
105
|
+
(0, import_traverse.default)(ast, {
|
|
106
|
+
JSXText(path) {
|
|
107
|
+
for (const [compApiId, component] of Object.entries(
|
|
108
|
+
params.components
|
|
109
|
+
)) {
|
|
110
|
+
if (!result[compApiId]) {
|
|
111
|
+
result[compApiId] = __spreadProps(__spreadValues({
|
|
112
|
+
apiId: compApiId
|
|
113
|
+
}, component), {
|
|
114
|
+
occurrences: {}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (path.node.value.includes(component.text)) {
|
|
118
|
+
const escapedText = component.text.replace(
|
|
119
|
+
/[.*+?^${}()|[\]\\]/g,
|
|
120
|
+
"\\$&"
|
|
121
|
+
);
|
|
122
|
+
const regex = new RegExp(escapedText, "g");
|
|
123
|
+
let match;
|
|
124
|
+
while ((match = regex.exec(path.node.value)) !== null) {
|
|
125
|
+
const lines = path.node.value.slice(0, match.index).split("\n");
|
|
126
|
+
if (!path.node.loc) {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const lineNumber = path.node.loc.start.line + lines.length - 1;
|
|
130
|
+
const codeLines = code.split("\n");
|
|
131
|
+
const line = codeLines[lineNumber - 1];
|
|
132
|
+
const preview = replaceAt(
|
|
133
|
+
line,
|
|
134
|
+
match.index,
|
|
135
|
+
component.text,
|
|
136
|
+
`${component.text}`
|
|
137
|
+
);
|
|
138
|
+
if (!result[compApiId]["occurrences"][file]) {
|
|
139
|
+
result[compApiId]["occurrences"][file] = [];
|
|
80
140
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
141
|
+
result[compApiId]["occurrences"][file].push({
|
|
142
|
+
lineNumber,
|
|
143
|
+
preview
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (Object.keys(result[compApiId]["occurrences"]).length === 0) {
|
|
148
|
+
delete result[compApiId];
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
})
|
|
154
|
+
);
|
|
84
155
|
}
|
|
85
|
-
|
|
156
|
+
yield Promise.all(promises);
|
|
86
157
|
return result;
|
|
158
|
+
});
|
|
87
159
|
}
|
|
88
|
-
exports.findComponentsInJSXFiles = findComponentsInJSXFiles;
|
|
89
160
|
function replaceAt(str, index, searchString, replacement) {
|
|
90
|
-
|
|
91
|
-
str.substring(index, str.length).replace(searchString, replacement));
|
|
161
|
+
return str.substring(0, index) + str.substring(index, str.length).replace(searchString, replacement);
|
|
92
162
|
}
|
|
93
|
-
|
|
163
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
164
|
+
0 && (module.exports = {
|
|
165
|
+
findComponentsInJSXFiles,
|
|
166
|
+
generateSuggestions
|
|
167
|
+
});
|
|
168
|
+
//# sourceMappingURL=generate-suggestions.js.map
|
|
169
|
+
|
|
170
|
+
//# debugId=aa8e9998-6730-545b-965d-fd7d54610668
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../lib/generate-suggestions.ts"],"sourcesContent":["import fs from \"fs-extra\";\nimport glob from \"glob\";\nimport { parse } from \"@babel/parser\";\nimport traverse from \"@babel/traverse\";\n\nimport {\n FetchComponentResponse,\n FetchComponentResponseComponent,\n fetchComponents,\n} from \"./http/fetchComponents\";\n\ninterface Occurrence {\n lineNumber: number;\n preview: string;\n}\n\ninterface Result extends FetchComponentResponseComponent {\n apiId: string;\n occurrences: {\n [file: string]: Occurrence[];\n };\n}\n\nasync function generateSuggestions(flags: {\n directory?: string;\n files?: string[];\n componentFolder?: string;\n}) {\n const components = await fetchComponents({\n ...(flags.componentFolder ? { componentFolder: flags.componentFolder} : {})\n });\n const directory = flags.directory || \".\";\n\n const results: { [apiId: string]: Result } = await findComponentsInJSXFiles({\n directory,\n files: flags.files,\n components,\n });\n\n // Display results to user\n console.log(JSON.stringify(results, null, 2));\n}\n\nasync function findComponentsInJSXFiles(params: {\n directory: string;\n files?: string[];\n components: FetchComponentResponse;\n}): Promise<{ [apiId: string]: Result }> {\n const result: { [apiId: string]: Result } = {};\n const files =\n params.files ||\n glob.sync(`${params.directory}/**/*.+(jsx|tsx)`, {\n ignore: \"**/node_modules/**\",\n });\n\n const promises: Promise<any>[] = [];\n\n for (const file of files) {\n promises.push(\n fs.readFile(file, \"utf-8\").then((code) => {\n const ast = parse(code, {\n sourceType: \"module\",\n plugins: [\"jsx\", \"typescript\"],\n });\n\n traverse(ast, {\n JSXText(path) {\n for (const [compApiId, component] of Object.entries(\n params.components\n )) {\n // If we haven't seen this component before, add it to the result\n if (!result[compApiId]) {\n result[compApiId] = {\n apiId: compApiId,\n ...component,\n occurrences: {},\n };\n }\n\n if (path.node.value.includes(component.text)) {\n // Escape all special characters from the text so we can use it in a regex\n const escapedText = component.text.replace(\n /[.*+?^${}()|[\\]\\\\]/g,\n \"\\\\$&\"\n );\n const regex = new RegExp(escapedText, \"g\");\n let match;\n while ((match = regex.exec(path.node.value)) !== null) {\n const lines = path.node.value\n .slice(0, match.index)\n .split(\"\\n\");\n\n if (!path.node.loc) {\n continue;\n }\n\n const lineNumber =\n path.node.loc.start.line + lines.length - 1;\n\n const codeLines = code.split(\"\\n\");\n const line = codeLines[lineNumber - 1];\n const preview = replaceAt(\n line,\n match.index,\n component.text,\n `${component.text}`\n );\n\n // Initialize the occurrences array if it doesn't exist\n if (!result[compApiId][\"occurrences\"][file]) {\n result[compApiId][\"occurrences\"][file] = [];\n }\n\n result[compApiId][\"occurrences\"][file].push({\n lineNumber,\n preview,\n });\n }\n }\n\n // Remove from result if no occurrences were found\n if (Object.keys(result[compApiId][\"occurrences\"]).length === 0) {\n delete result[compApiId];\n }\n }\n },\n });\n })\n );\n }\n\n await Promise.all(promises);\n\n return result;\n}\n\nfunction replaceAt(\n str: string,\n index: number,\n searchString: string,\n replacement: string\n) {\n return (\n str.substring(0, index) +\n str.substring(index, str.length).replace(searchString, replacement)\n );\n}\n\nexport { findComponentsInJSXFiles, generateSuggestions };\n"],"names":["glob","fs","traverse"],"mappings":"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","debug_id":"aa8e9998-6730-545b-965d-fd7d54610668"}
|
|
@@ -0,0 +1,189 @@
|
|
|
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]="cdb7db76-ad87-5dd1-9a42-8bd41ecc9bd6")}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 __async = (__this, __arguments, generator) => {
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
var fulfilled = (value) => {
|
|
29
|
+
try {
|
|
30
|
+
step(generator.next(value));
|
|
31
|
+
} catch (e) {
|
|
32
|
+
reject(e);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var rejected = (value) => {
|
|
36
|
+
try {
|
|
37
|
+
step(generator.throw(value));
|
|
38
|
+
} catch (e) {
|
|
39
|
+
reject(e);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
43
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
var import_promises = __toESM(require("fs/promises"));
|
|
47
|
+
var import_path = __toESM(require("path"));
|
|
48
|
+
var import_generate_suggestions = require("./generate-suggestions");
|
|
49
|
+
describe("findTextInJSXFiles", () => {
|
|
50
|
+
function createTempFile(filename, content) {
|
|
51
|
+
return __async(this, null, function* () {
|
|
52
|
+
const filePath = import_path.default.join(".", filename);
|
|
53
|
+
yield import_promises.default.writeFile(filePath, content);
|
|
54
|
+
return filePath;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function deleteTempFile(filename) {
|
|
58
|
+
return __async(this, null, function* () {
|
|
59
|
+
const filePath = import_path.default.join(".", filename);
|
|
60
|
+
yield import_promises.default.unlink(filePath);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
it("should return an empty obj when no files are found", () => __async(exports, null, function* () {
|
|
64
|
+
const result = yield (0, import_generate_suggestions.findComponentsInJSXFiles)({
|
|
65
|
+
directory: ".",
|
|
66
|
+
components: {}
|
|
67
|
+
});
|
|
68
|
+
expect(result).toEqual({});
|
|
69
|
+
}));
|
|
70
|
+
it("should return an empty obj when searchString is not found in any file", () => __async(exports, null, function* () {
|
|
71
|
+
const file1 = yield createTempFile("file1.jsx", "<div>No match</div>");
|
|
72
|
+
const file2 = yield createTempFile("file2.tsx", "<div>No match</div>");
|
|
73
|
+
const result = yield (0, import_generate_suggestions.findComponentsInJSXFiles)({
|
|
74
|
+
directory: ".",
|
|
75
|
+
components: {
|
|
76
|
+
acomponent: {
|
|
77
|
+
name: "A Component",
|
|
78
|
+
text: "A Component",
|
|
79
|
+
status: "NONE",
|
|
80
|
+
folder: null
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
expect(result).toEqual({});
|
|
85
|
+
yield deleteTempFile(file1);
|
|
86
|
+
yield deleteTempFile(file2);
|
|
87
|
+
}));
|
|
88
|
+
it("should return an array with correct occurrences when searchString is found", () => __async(exports, null, function* () {
|
|
89
|
+
const file1 = yield createTempFile(
|
|
90
|
+
"file1.jsx",
|
|
91
|
+
`<div>Test searchString and another searchString</div>`
|
|
92
|
+
);
|
|
93
|
+
const expectedResult = {
|
|
94
|
+
"search-string": {
|
|
95
|
+
apiId: "search-string",
|
|
96
|
+
folder: null,
|
|
97
|
+
name: "Search String",
|
|
98
|
+
occurrences: {
|
|
99
|
+
[file1]: [
|
|
100
|
+
{
|
|
101
|
+
lineNumber: 1,
|
|
102
|
+
preview: "<div>Test searchString and another searchString</div>"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
lineNumber: 1,
|
|
106
|
+
preview: "<div>Test searchString and another searchString</div>"
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
status: "NONE",
|
|
111
|
+
text: "searchString"
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const result = yield (0, import_generate_suggestions.findComponentsInJSXFiles)({
|
|
115
|
+
directory: ".",
|
|
116
|
+
components: {
|
|
117
|
+
"search-string": {
|
|
118
|
+
name: "Search String",
|
|
119
|
+
text: "searchString",
|
|
120
|
+
status: "NONE",
|
|
121
|
+
folder: null
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
expect(result).toEqual(expectedResult);
|
|
126
|
+
yield deleteTempFile(file1);
|
|
127
|
+
}));
|
|
128
|
+
it("-f flag works", () => __async(exports, null, function* () {
|
|
129
|
+
const file1 = yield createTempFile(
|
|
130
|
+
"file1.jsx",
|
|
131
|
+
`<div>Test searchString and another searchString</div>`
|
|
132
|
+
);
|
|
133
|
+
const expectedResult = {
|
|
134
|
+
"search-string": {
|
|
135
|
+
apiId: "search-string",
|
|
136
|
+
folder: null,
|
|
137
|
+
name: "Search String",
|
|
138
|
+
occurrences: {
|
|
139
|
+
[file1]: [
|
|
140
|
+
{
|
|
141
|
+
lineNumber: 1,
|
|
142
|
+
preview: "<div>Test searchString and another searchString</div>"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
lineNumber: 1,
|
|
146
|
+
preview: "<div>Test searchString and another searchString</div>"
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
status: "NONE",
|
|
151
|
+
text: "searchString"
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const result = yield (0, import_generate_suggestions.findComponentsInJSXFiles)({
|
|
155
|
+
directory: ".",
|
|
156
|
+
files: ["file1.jsx"],
|
|
157
|
+
components: {
|
|
158
|
+
"search-string": {
|
|
159
|
+
name: "Search String",
|
|
160
|
+
text: "searchString",
|
|
161
|
+
status: "NONE",
|
|
162
|
+
folder: null
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
expect(result).toEqual(expectedResult);
|
|
167
|
+
try {
|
|
168
|
+
const result2 = yield (0, import_generate_suggestions.findComponentsInJSXFiles)({
|
|
169
|
+
directory: ".",
|
|
170
|
+
files: ["file2.jsx"],
|
|
171
|
+
components: {
|
|
172
|
+
"search-string": {
|
|
173
|
+
name: "Search String",
|
|
174
|
+
text: "searchString",
|
|
175
|
+
status: "NONE",
|
|
176
|
+
folder: null
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
expect(false).toEqual(true);
|
|
181
|
+
} catch (e) {
|
|
182
|
+
expect(true).toEqual(true);
|
|
183
|
+
}
|
|
184
|
+
yield deleteTempFile(file1);
|
|
185
|
+
}));
|
|
186
|
+
});
|
|
187
|
+
//# sourceMappingURL=generate-suggestions.test.js.map
|
|
188
|
+
|
|
189
|
+
//# debugId=cdb7db76-ad87-5dd1-9a42-8bd41ecc9bd6
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../lib/generate-suggestions.test.ts"],"sourcesContent":["import fs from \"fs/promises\";\nimport path from \"path\";\nimport { findComponentsInJSXFiles } from \"./generate-suggestions\";\n\ndescribe(\"findTextInJSXFiles\", () => {\n async function createTempFile(filename, content) {\n const filePath = path.join(\".\", filename);\n await fs.writeFile(filePath, content);\n return filePath;\n }\n\n async function deleteTempFile(filename) {\n const filePath = path.join(\".\", filename);\n await fs.unlink(filePath);\n }\n\n it(\"should return an empty obj when no files are found\", async () => {\n const result = await findComponentsInJSXFiles({\n directory: \".\",\n components: {},\n });\n\n expect(result).toEqual({});\n });\n\n it(\"should return an empty obj when searchString is not found in any file\", async () => {\n const file1 = await createTempFile(\"file1.jsx\", \"<div>No match</div>\");\n const file2 = await createTempFile(\"file2.tsx\", \"<div>No match</div>\");\n\n const result = await findComponentsInJSXFiles({\n directory: \".\",\n components: {\n acomponent: {\n name: \"A Component\",\n text: \"A Component\",\n status: \"NONE\",\n folder: null,\n },\n },\n });\n\n expect(result).toEqual({});\n\n await deleteTempFile(file1);\n await deleteTempFile(file2);\n });\n\n it(\"should return an array with correct occurrences when searchString is found\", async () => {\n const file1 = await createTempFile(\n \"file1.jsx\",\n `<div>Test searchString and another searchString</div>`\n );\n\n const expectedResult = {\n \"search-string\": {\n apiId: \"search-string\",\n folder: null,\n name: \"Search String\",\n occurrences: {\n [file1]: [\n {\n lineNumber: 1,\n preview: \"<div>Test searchString and another searchString</div>\",\n },\n {\n lineNumber: 1,\n preview: \"<div>Test searchString and another searchString</div>\",\n },\n ],\n },\n status: \"NONE\",\n text: \"searchString\",\n },\n };\n\n const result = await findComponentsInJSXFiles({\n directory: \".\",\n components: {\n \"search-string\": {\n name: \"Search String\",\n text: \"searchString\",\n status: \"NONE\",\n folder: null,\n },\n },\n });\n\n expect(result).toEqual(expectedResult);\n\n await deleteTempFile(file1);\n });\n\n it(\"-f flag works\", async () => {\n const file1 = await createTempFile(\n \"file1.jsx\",\n `<div>Test searchString and another searchString</div>`\n );\n\n const expectedResult = {\n \"search-string\": {\n apiId: \"search-string\",\n folder: null,\n name: \"Search String\",\n occurrences: {\n [file1]: [\n {\n lineNumber: 1,\n preview: \"<div>Test searchString and another searchString</div>\",\n },\n {\n lineNumber: 1,\n preview: \"<div>Test searchString and another searchString</div>\",\n },\n ],\n },\n status: \"NONE\",\n text: \"searchString\",\n },\n };\n\n const result = await findComponentsInJSXFiles({\n directory: \".\",\n files: [\"file1.jsx\"],\n components: {\n \"search-string\": {\n name: \"Search String\",\n text: \"searchString\",\n status: \"NONE\",\n folder: null,\n },\n },\n });\n\n expect(result).toEqual(expectedResult);\n\n try {\n const result2 = await findComponentsInJSXFiles({\n directory: \".\",\n files: [\"file2.jsx\"],\n components: {\n \"search-string\": {\n name: \"Search String\",\n text: \"searchString\",\n status: \"NONE\",\n folder: null,\n },\n },\n });\n\n expect(false).toEqual(true);\n } catch {\n expect(true).toEqual(true);\n }\n\n await deleteTempFile(file1);\n });\n});\n"],"names":["path","fs"],"mappings":"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","debug_id":"cdb7db76-ad87-5dd1-9a42-8bd41ecc9bd6"}
|
|
@@ -1,11 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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]="9bc7c4e1-465b-5786-8656-d536f004e70b")}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 __async = (__this, __arguments, generator) => {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
var fulfilled = (value) => {
|
|
24
|
+
try {
|
|
25
|
+
step(generator.next(value));
|
|
26
|
+
} catch (e) {
|
|
27
|
+
reject(e);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
var rejected = (value) => {
|
|
31
|
+
try {
|
|
32
|
+
step(generator.throw(value));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
38
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
var fetchComponentFolders_exports = {};
|
|
42
|
+
__export(fetchComponentFolders_exports, {
|
|
43
|
+
fetchComponentFolders: () => fetchComponentFolders
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(fetchComponentFolders_exports);
|
|
46
|
+
var import_api = require("../api");
|
|
47
|
+
function fetchComponentFolders() {
|
|
48
|
+
return __async(this, null, function* () {
|
|
49
|
+
const api = (0, import_api.createApiClient)();
|
|
50
|
+
const { data } = yield api.get(
|
|
51
|
+
"/component-folders",
|
|
52
|
+
{}
|
|
53
|
+
);
|
|
8
54
|
return data;
|
|
55
|
+
});
|
|
9
56
|
}
|
|
10
|
-
|
|
11
|
-
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
fetchComponentFolders
|
|
60
|
+
});
|
|
61
|
+
//# sourceMappingURL=fetchComponentFolders.js.map
|
|
62
|
+
|
|
63
|
+
//# debugId=9bc7c4e1-465b-5786-8656-d536f004e70b
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../lib/http/fetchComponentFolders.ts"],"sourcesContent":["import { createApiClient } from \"../api\";\n\ninterface FetchComponentFoldersResponse {\n [id: string]: string;\n}\n\nexport async function fetchComponentFolders(): Promise<FetchComponentFoldersResponse> {\n const api = createApiClient();\n\n const { data } = await api.get<FetchComponentFoldersResponse>(\n \"/component-folders\",\n {}\n );\n\n return data;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAgC;AAMhC,SAAsB,wBAAgE;AAAA;AACpF,UAAM,UAAM,4BAAgB;AAE5B,UAAM,EAAE,KAAK,IAAI,MAAM,IAAI;AAAA,MACzB;AAAA,MACA,CAAC;AAAA,IACH;AAEA,WAAO;AAAA,EACT;AAAA","debug_id":"9bc7c4e1-465b-5786-8656-d536f004e70b"}
|