@via-dev/via 0.1.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/LICENSE +21 -0
- package/README.md +87 -0
- package/dist/cli.js +136 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/config.js +124 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/learn.js +112 -0
- package/dist/commands/learn.js.map +1 -0
- package/dist/commands/list.js +38 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/remove.js +82 -0
- package/dist/commands/remove.js.map +1 -0
- package/dist/commands/ui/index.js +23 -0
- package/dist/commands/ui/index.js.map +1 -0
- package/dist/commands/ui/server.js +47 -0
- package/dist/commands/ui/server.js.map +1 -0
- package/dist/commands/ui/static/script.js +101 -0
- package/dist/commands/ui/static/script.js.map +1 -0
- package/dist/commands/ui/static/styles.js +245 -0
- package/dist/commands/ui/static/styles.js.map +1 -0
- package/dist/commands/ui/templates/layout.js +51 -0
- package/dist/commands/ui/templates/layout.js.map +1 -0
- package/dist/commands/use.js +236 -0
- package/dist/commands/use.js.map +1 -0
- package/dist/schema.js +12 -0
- package/dist/schema.js.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/add/file-scanner.js +99 -0
- package/dist/utils/add/file-scanner.js.map +1 -0
- package/dist/utils/add/get-dependencies.js +75 -0
- package/dist/utils/add/get-dependencies.js.map +1 -0
- package/dist/utils/add/meta.js +22 -0
- package/dist/utils/add/meta.js.map +1 -0
- package/dist/utils/add/module-processor.js +140 -0
- package/dist/utils/add/module-processor.js.map +1 -0
- package/dist/utils/ai/blocks.js +22 -0
- package/dist/utils/ai/blocks.js.map +1 -0
- package/dist/utils/ai/detection-prompt.js +173 -0
- package/dist/utils/ai/detection-prompt.js.map +1 -0
- package/dist/utils/ai/models.js +17 -0
- package/dist/utils/ai/models.js.map +1 -0
- package/dist/utils/ai/sdk.js +36 -0
- package/dist/utils/ai/sdk.js.map +1 -0
- package/dist/utils/branding.js +82 -0
- package/dist/utils/branding.js.map +1 -0
- package/dist/utils/constants.js +56 -0
- package/dist/utils/constants.js.map +1 -0
- package/dist/utils/paths.js +14 -0
- package/dist/utils/paths.js.map +1 -0
- package/dist/utils/use/text.js +31 -0
- package/dist/utils/use/text.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.use = exports.smartRename = void 0;
|
|
7
|
+
const promises_1 = require("fs/promises");
|
|
8
|
+
const fs_1 = require("fs");
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const ts_morph_1 = require("ts-morph");
|
|
11
|
+
const zlib_1 = require("zlib");
|
|
12
|
+
const paths_1 = require("../utils/paths");
|
|
13
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
14
|
+
const text_1 = require("../utils/use/text");
|
|
15
|
+
const PROTECTED_KEYWORDS = new Set(['s3', 'sqs', 'sns', 'lambda', 'dynamodb', 'iam', 'cdk', 'construct', 'stack', 'app', 'stage', 'bucket', 'function', 'handler', 'service', 'controller']);
|
|
16
|
+
const smartRename = (text, originalName, newName) => {
|
|
17
|
+
if (!originalName || !newName || originalName === newName)
|
|
18
|
+
return text;
|
|
19
|
+
const toPascal = (s) => s.split(/[-_]/).map(p => p.charAt(0).toUpperCase() + p.slice(1)).join('');
|
|
20
|
+
const toCamel = (s) => {
|
|
21
|
+
const p = toPascal(s);
|
|
22
|
+
return p.charAt(0).toLowerCase() + p.slice(1);
|
|
23
|
+
};
|
|
24
|
+
const toKebab = (s) => s.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase().replace(/_/g, '-');
|
|
25
|
+
const toSnake = (s) => toKebab(s).replace(/-/g, '_');
|
|
26
|
+
const getVariations = (name) => {
|
|
27
|
+
const variations = [name, toPascal(name), toCamel(name), toKebab(name), toSnake(name)];
|
|
28
|
+
const allVariations = [...new Set(variations.flatMap(v => [v, (0, text_1.pluralize)(v), (0, text_1.singularize)(v)]))];
|
|
29
|
+
return allVariations.filter(v => v.length > 0);
|
|
30
|
+
};
|
|
31
|
+
const variations = getVariations(originalName);
|
|
32
|
+
const sortedVariations = variations.sort((a, b) => b.length - a.length);
|
|
33
|
+
// Negative lookahead to prevent matching 'StorageS' in 'StorageStack' as 'storages'
|
|
34
|
+
const regex = new RegExp(sortedVariations.map(v => {
|
|
35
|
+
const escaped = v.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
36
|
+
// For words that might be substrings, enforce word boundaries or boundaries between case changes
|
|
37
|
+
if (v.length < 4)
|
|
38
|
+
return `\\b${escaped}\\b`;
|
|
39
|
+
if (v.toLowerCase().endsWith('s') && !originalName.toLowerCase().endsWith('s')) {
|
|
40
|
+
return `${escaped}(?![a-zA-Z])`;
|
|
41
|
+
}
|
|
42
|
+
return escaped;
|
|
43
|
+
}).join('|'), 'gi');
|
|
44
|
+
return text.replace(regex, (match, offset) => {
|
|
45
|
+
// Skip protected keywords (system terms, AWS services, etc.)
|
|
46
|
+
if (PROTECTED_KEYWORDS.has(match.toLowerCase())) {
|
|
47
|
+
return match;
|
|
48
|
+
}
|
|
49
|
+
// Preserve plurality if possible
|
|
50
|
+
const isPluralMatch = !(0, text_1.isSingluar)(match);
|
|
51
|
+
let target = (0, text_1.isSingluar)(newName) ? newName : (0, text_1.singularize)(newName);
|
|
52
|
+
if (isPluralMatch) {
|
|
53
|
+
target = (0, text_1.pluralize)(target);
|
|
54
|
+
}
|
|
55
|
+
// Check context (surrounding characters for snake_case/kebab-case)
|
|
56
|
+
const prevChar = offset > 0 ? text[offset - 1] : '';
|
|
57
|
+
const nextChar = offset + match.length < text.length ? text[offset + match.length] : '';
|
|
58
|
+
const isSnakeContext = prevChar === '_' || nextChar === '_';
|
|
59
|
+
const isKebabContext = prevChar === '-' || nextChar === '-';
|
|
60
|
+
// Determine casing based on match and context
|
|
61
|
+
if (match === match.toUpperCase() && match.toLowerCase() !== match)
|
|
62
|
+
return target.toUpperCase();
|
|
63
|
+
if (match.includes('_') || isSnakeContext)
|
|
64
|
+
return toSnake(target);
|
|
65
|
+
if (match.includes('-') || isKebabContext)
|
|
66
|
+
return toKebab(target);
|
|
67
|
+
if (match[0] === match[0].toUpperCase())
|
|
68
|
+
return toPascal(target);
|
|
69
|
+
return toCamel(target);
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
exports.smartRename = smartRename;
|
|
73
|
+
const use = async (name, newName) => {
|
|
74
|
+
try {
|
|
75
|
+
const mappingPath = (0, paths_1.getViaDataPath)('mapping.json');
|
|
76
|
+
if (!(0, fs_1.existsSync)(mappingPath)) {
|
|
77
|
+
console.log("Module mapping not found");
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const mappingFile = await (0, promises_1.readFile)(mappingPath, 'utf-8');
|
|
81
|
+
const mapping = JSON.parse(mappingFile);
|
|
82
|
+
const id = mapping[name];
|
|
83
|
+
if (!id) {
|
|
84
|
+
console.log("Module not found");
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
let jsonFile;
|
|
88
|
+
const viaPath = (0, paths_1.getViaDataPath)(`modules/${id}.via`);
|
|
89
|
+
if ((0, fs_1.existsSync)(viaPath)) {
|
|
90
|
+
const buffer = await (0, promises_1.readFile)(viaPath);
|
|
91
|
+
const decompressed = (0, zlib_1.gunzipSync)(buffer);
|
|
92
|
+
jsonFile = JSON.parse(decompressed.toString());
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
console.log("Module file not found");
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const { originalName, deps } = jsonFile;
|
|
99
|
+
const targetName = newName || originalName;
|
|
100
|
+
const allFiles = flattenDeps([deps]);
|
|
101
|
+
const summary = {
|
|
102
|
+
created: [],
|
|
103
|
+
merged: []
|
|
104
|
+
};
|
|
105
|
+
for (const file of allFiles) {
|
|
106
|
+
const { path: filePathRelative, content } = file;
|
|
107
|
+
const renamedPath = (0, exports.smartRename)(filePathRelative, originalName, targetName);
|
|
108
|
+
if (content) {
|
|
109
|
+
// 1. Load file with ts-morph
|
|
110
|
+
const project = new ts_morph_1.Project();
|
|
111
|
+
const sourceFile = project.createSourceFile("temp.ts", content);
|
|
112
|
+
// 2. Targeted renaming using AST traversal and range-based replacement
|
|
113
|
+
const replacements = [];
|
|
114
|
+
sourceFile.forEachDescendant(node => {
|
|
115
|
+
if (ts_morph_1.Node.isIdentifier(node)) {
|
|
116
|
+
const text = node.getText();
|
|
117
|
+
const renamed = (0, exports.smartRename)(text, originalName, targetName);
|
|
118
|
+
if (text !== renamed) {
|
|
119
|
+
replacements.push({ start: node.getStart(), end: node.getEnd(), text: renamed });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else if (ts_morph_1.Node.isStringLiteral(node) || ts_morph_1.Node.isNoSubstitutionTemplateLiteral(node)) {
|
|
123
|
+
const text = node.getLiteralText();
|
|
124
|
+
const renamed = (0, exports.smartRename)(text, originalName, targetName);
|
|
125
|
+
if (text !== renamed) {
|
|
126
|
+
const quote = ts_morph_1.Node.isStringLiteral(node) ? node.getText()[0] : '`';
|
|
127
|
+
replacements.push({ start: node.getStart(), end: node.getEnd(), text: `${quote}${renamed}${quote}` });
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
let finalContent = sourceFile.getFullText();
|
|
132
|
+
replacements.sort((a, b) => b.start - a.start);
|
|
133
|
+
for (const r of replacements) {
|
|
134
|
+
finalContent = finalContent.slice(0, r.start) + r.text + finalContent.slice(r.end);
|
|
135
|
+
}
|
|
136
|
+
sourceFile.replaceWithText(finalContent);
|
|
137
|
+
// 3. Save to disk
|
|
138
|
+
const fullFilePath = (0, path_1.join)(process.cwd(), renamedPath);
|
|
139
|
+
const relativePath = renamedPath;
|
|
140
|
+
await (0, promises_1.mkdir)((0, path_1.dirname)(fullFilePath), { recursive: true });
|
|
141
|
+
if ((0, fs_1.existsSync)(fullFilePath)) {
|
|
142
|
+
const existingContent = await (0, promises_1.readFile)(fullFilePath, 'utf-8');
|
|
143
|
+
const diskProject = new ts_morph_1.Project();
|
|
144
|
+
const existingFile = diskProject.createSourceFile(fullFilePath, existingContent, { overwrite: true });
|
|
145
|
+
mergeSourceFiles(existingFile, sourceFile);
|
|
146
|
+
await (0, promises_1.writeFile)(fullFilePath, existingFile.getFullText());
|
|
147
|
+
summary.merged.push(relativePath);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
await (0, promises_1.writeFile)(fullFilePath, sourceFile.getFullText());
|
|
151
|
+
summary.created.push(relativePath);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
console.log(`\n${chalk_1.default.green.bold('✨ Successfully prepared your new module!')}`);
|
|
156
|
+
console.log(`${chalk_1.default.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')}`);
|
|
157
|
+
if (summary.created.length > 0) {
|
|
158
|
+
console.log(`${chalk_1.default.blue.bold('NEW FILES:')}`);
|
|
159
|
+
summary.created.forEach(f => console.log(` ${chalk_1.default.blue('+')} ${f}`));
|
|
160
|
+
}
|
|
161
|
+
if (summary.merged.length > 0) {
|
|
162
|
+
console.log(`${chalk_1.default.yellow.bold('MERGED FILES:')}`);
|
|
163
|
+
summary.merged.forEach(f => console.log(` ${chalk_1.default.yellow('~')} ${f}`));
|
|
164
|
+
}
|
|
165
|
+
console.log(`${chalk_1.default.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')}`);
|
|
166
|
+
console.log(`${chalk_1.default.white.bold('Next Steps:')}`);
|
|
167
|
+
console.log(` 1. Note: ${chalk_1.default.cyan('Auto-import is not yet supported')}.`);
|
|
168
|
+
console.log(` 2. Manually import ${chalk_1.default.green.bold(targetName)} in your project.`);
|
|
169
|
+
console.log(` 3. Start using your new functionality!\n`);
|
|
170
|
+
}
|
|
171
|
+
catch (e) {
|
|
172
|
+
console.log(chalk_1.default.red.bold("✖ Error while using module:"), e);
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
exports.use = use;
|
|
176
|
+
function mergeSourceFiles(target, source) {
|
|
177
|
+
const sourceDecls = [
|
|
178
|
+
...source.getClasses(),
|
|
179
|
+
...source.getFunctions(),
|
|
180
|
+
...source.getInterfaces(),
|
|
181
|
+
...source.getTypeAliases(),
|
|
182
|
+
...source.getVariableStatements()
|
|
183
|
+
];
|
|
184
|
+
for (const decl of sourceDecls) {
|
|
185
|
+
if (ts_morph_1.Node.isClassDeclaration(decl) || ts_morph_1.Node.isFunctionDeclaration(decl) || ts_morph_1.Node.isInterfaceDeclaration(decl) || ts_morph_1.Node.isTypeAliasDeclaration(decl)) {
|
|
186
|
+
const name = decl.getName();
|
|
187
|
+
if (name) {
|
|
188
|
+
const exists = !!(target.getClass(name) ||
|
|
189
|
+
target.getFunction(name) ||
|
|
190
|
+
target.getInterface(name) ||
|
|
191
|
+
target.getTypeAlias(name));
|
|
192
|
+
if (!exists) {
|
|
193
|
+
target.addStatements(decl.getText());
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
console.warn(`Skipping: "${name}" already exists in the target file.`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
else if (ts_morph_1.Node.isVariableStatement(decl)) {
|
|
201
|
+
for (const varDecl of decl.getDeclarations()) {
|
|
202
|
+
const name = varDecl.getName();
|
|
203
|
+
const exists = !!target.getVariableDeclaration(name);
|
|
204
|
+
if (!exists) {
|
|
205
|
+
target.addStatements(decl.getText());
|
|
206
|
+
break;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// Merge imports as well
|
|
212
|
+
const sourceImports = source.getImportDeclarations();
|
|
213
|
+
const targetImports = target.getImportDeclarations();
|
|
214
|
+
for (const imp of sourceImports) {
|
|
215
|
+
const moduleSpecifier = imp.getModuleSpecifierValue();
|
|
216
|
+
const existingImp = targetImports.find((ti) => ti.getModuleSpecifierValue() === moduleSpecifier);
|
|
217
|
+
if (!existingImp) {
|
|
218
|
+
target.addImportDeclaration(imp.getStructure());
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
const namedImports = imp.getNamedImports();
|
|
222
|
+
for (const ni of namedImports) {
|
|
223
|
+
const niName = ni.getName();
|
|
224
|
+
if (!existingImp.getNamedImports().some((tni) => tni.getName() === niName)) {
|
|
225
|
+
existingImp.addNamedImport(ni.getStructure());
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function flattenDeps(deps) {
|
|
232
|
+
return deps.reduce((acc, dep) => {
|
|
233
|
+
return acc.concat(dep, flattenDeps(dep.dependencies || []));
|
|
234
|
+
}, []);
|
|
235
|
+
}
|
|
236
|
+
//# sourceMappingURL=use.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use.js","sourceRoot":"","sources":["../../src/commands/use.ts"],"names":[],"mappings":";;;;;;AAAA,0CAAyD;AACzD,2BAAgC;AAChC,+BAAqC;AACrC,uCAAqD;AACrD,+BAAkC;AAClC,0CAAgD;AAChD,kDAA0B;AAC1B,4CAAuE;AAGvE,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;AAEtL,MAAM,WAAW,GAAG,CAAC,IAAY,EAAE,YAAoB,EAAE,OAAe,EAAE,EAAE;IACjF,IAA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,CAAC;IAC9D,CAAC,EAAE,EAA0B,CAAC,CAAC;AACjC,CAAC"}
|
package/dist/schema.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.moduleSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.moduleSchema = zod_1.z.object({
|
|
6
|
+
modules: zod_1.z.array(zod_1.z.object({
|
|
7
|
+
moduleName: zod_1.z.string(),
|
|
8
|
+
entryFile: zod_1.z.string(),
|
|
9
|
+
confidence: zod_1.z.enum(["high", "medium", "low"]),
|
|
10
|
+
}))
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAEX,QAAA,YAAY,GAAG,OAAC,CAAC,MAAM,CAAC;IACjC,OAAO,EAAE,OAAC,CAAC,KAAK,CACZ,OAAC,CAAC,MAAM,CAAC;QACL,UAAU,EAAE,OAAC,CAAC,MAAM,EAAE;QACtB,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE;QACrB,UAAU,EAAE,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;KAChD,CAAC,CACL;CACJ,CAAC,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.readFiles = exports.getAllFileAndFolders = void 0;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
const promises_1 = require("fs/promises");
|
|
39
|
+
const constants_1 = require("../constants");
|
|
40
|
+
const fs_1 = require("fs");
|
|
41
|
+
const ENTRY_FILE_REGEX = /\.(module|routes|router|stack|construct)\.(ts|js|tsx|jsx)$/;
|
|
42
|
+
const getAllFileAndFolders = async (dir = '', projectRoot = process.cwd()) => {
|
|
43
|
+
const currentDir = path.join(projectRoot, dir);
|
|
44
|
+
const allFiles = (await (0, promises_1.readdir)(currentDir))
|
|
45
|
+
.filter((file) => !constants_1.IGNORE_LIST.includes(file));
|
|
46
|
+
const folderStructurePromise = allFiles.flatMap(async (file) => {
|
|
47
|
+
const filePath = path.join(currentDir, file);
|
|
48
|
+
const relativePath = path.join(dir, file);
|
|
49
|
+
const stats = await (0, promises_1.stat)(filePath);
|
|
50
|
+
if (!stats.isDirectory()) {
|
|
51
|
+
const fileContent = await (0, promises_1.readFile)(filePath, 'utf-8');
|
|
52
|
+
return {
|
|
53
|
+
fileName: file,
|
|
54
|
+
path: relativePath,
|
|
55
|
+
isDirectory: false,
|
|
56
|
+
content: fileContent,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
const subFolders = await (0, exports.getAllFileAndFolders)(relativePath, projectRoot);
|
|
61
|
+
return [{
|
|
62
|
+
fileName: file,
|
|
63
|
+
path: relativePath,
|
|
64
|
+
isDirectory: true
|
|
65
|
+
}, ...subFolders];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return Promise.all(folderStructurePromise);
|
|
69
|
+
};
|
|
70
|
+
exports.getAllFileAndFolders = getAllFileAndFolders;
|
|
71
|
+
const readFiles = async (dirPath, modulesToProcess = []) => {
|
|
72
|
+
const files = await (0, promises_1.readdir)(dirPath);
|
|
73
|
+
for (const entry of files) {
|
|
74
|
+
if (constants_1.IGNORE_LIST.includes(entry))
|
|
75
|
+
continue;
|
|
76
|
+
const entryPath = path.join(dirPath, entry);
|
|
77
|
+
const relativeEntryPath = path.relative(process.cwd(), entryPath);
|
|
78
|
+
const stats = (0, fs_1.statSync)(entryPath);
|
|
79
|
+
if (stats.isDirectory()) {
|
|
80
|
+
const subFiles = await (0, promises_1.readdir)(entryPath);
|
|
81
|
+
const entryFile = subFiles.find(f => ENTRY_FILE_REGEX.test(f));
|
|
82
|
+
modulesToProcess.push({
|
|
83
|
+
moduleName: entry,
|
|
84
|
+
entryFile: entryFile ? path.join(relativeEntryPath, entryFile) : subFiles.map(f => path.join(relativeEntryPath, f)),
|
|
85
|
+
manual: true
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
modulesToProcess.push({
|
|
90
|
+
moduleName: entry,
|
|
91
|
+
entryFile: relativeEntryPath,
|
|
92
|
+
manual: true
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return modulesToProcess;
|
|
97
|
+
};
|
|
98
|
+
exports.readFiles = readFiles;
|
|
99
|
+
//# sourceMappingURL=file-scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-scanner.js","sourceRoot":"","sources":["../../../src/utils/add/file-scanner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,0CAAsD;AAEtD,4CAA2C;AAC3C,2BAA8B;AAE9B,MAAM,gBAAgB,GAAG,4DAA4D,CAAC;AAE/E,MAAM,oBAAoB,GAAG,KAAK,EAAE,GAAG,GAAG,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,EAA4B,EAAE;IAC1G,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;IAC/C,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAA,kBAAO,EAAC,UAAU,CAAC,CAAC;SACvC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,uBAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IAEnD,MAAM,sBAAsB,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAC,IAAI,EAAC,EAAE;QACzD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QAC7C,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC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AClC,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACtB,MAAM,QAAQ,GAAG,MAAM,IAAA,kBAAO,EAAC,SAAS,CAAC,CAAC;YAC1C,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,CAC5D,CAAC;YAEF,gBAAgB,CAAC,IAAI,CAAC;gBAClB,UAAU,EAAE,KAAK;gBACjB,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC;gBACnH,MAAM,EAAE,IAAI;aACf,CAAC,CAAC;QACP,CAAC;aAAM,CAAC;YACJ,gBAAgB,CAAC,IAAI,CAAC;gBAClB,UAAU,EAAE,KAAK;gBACjB,SAAS,EAAE,iBAAiB;gBAC5B,MAAM,EAAE,IAAI;aACf,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC5B,CAAC,CAAA;AA/BY,QAAA,SAAS,aA+BrB"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNestedDependencies = getNestedDependencies;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
/**
|
|
6
|
+
* Recursively gets dependencies of an entry file in a nested format.
|
|
7
|
+
* @param entryFilePath Absolute or relative path to the entry file.
|
|
8
|
+
* @param project The ts-morph project instance to use.
|
|
9
|
+
* @param visited Optional set of visited file paths to handle cycles.
|
|
10
|
+
*/
|
|
11
|
+
function getNestedDependencies(entryFilePath, project, visited = new Set()) {
|
|
12
|
+
if (visited.has(entryFilePath)) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
visited.add(entryFilePath);
|
|
16
|
+
const sourceFile = project.getSourceFile(entryFilePath);
|
|
17
|
+
if (!sourceFile) {
|
|
18
|
+
console.error(`Source file not found in project: ${entryFilePath}`);
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const content = sourceFile.getFullText();
|
|
22
|
+
const dependencies = [];
|
|
23
|
+
// Extract exported names
|
|
24
|
+
const exportedNames = [];
|
|
25
|
+
sourceFile.getExportedDeclarations().forEach((decls, name) => {
|
|
26
|
+
if (name !== 'default') {
|
|
27
|
+
exportedNames.push(name);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
// Handle default exports by looking at the actual identifier being exported
|
|
31
|
+
decls.forEach(decl => {
|
|
32
|
+
if (ts_morph_1.ts.isVariableDeclaration(decl.compilerNode) ||
|
|
33
|
+
ts_morph_1.ts.isClassDeclaration(decl.compilerNode) ||
|
|
34
|
+
ts_morph_1.ts.isFunctionDeclaration(decl.compilerNode) ||
|
|
35
|
+
ts_morph_1.ts.isInterfaceDeclaration(decl.compilerNode)) {
|
|
36
|
+
const nameNode = decl.compilerNode.name;
|
|
37
|
+
if (nameNode && ts_morph_1.ts.isIdentifier(nameNode)) {
|
|
38
|
+
exportedNames.push(nameNode.text);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
// Check imports
|
|
45
|
+
const importDeclarations = sourceFile.getImportDeclarations();
|
|
46
|
+
for (const imp of importDeclarations) {
|
|
47
|
+
const depSourceFile = imp.getModuleSpecifierSourceFile();
|
|
48
|
+
if (depSourceFile && !depSourceFile.isInNodeModules()) {
|
|
49
|
+
const depPath = depSourceFile.getFilePath();
|
|
50
|
+
const depNode = getNestedDependencies(depPath, project, visited);
|
|
51
|
+
if (depNode) {
|
|
52
|
+
dependencies.push(depNode);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Check exports (e.g., export * from './module')
|
|
57
|
+
const exportDeclarations = sourceFile.getExportDeclarations();
|
|
58
|
+
for (const exp of exportDeclarations) {
|
|
59
|
+
const depSourceFile = exp.getModuleSpecifierSourceFile();
|
|
60
|
+
if (depSourceFile && !depSourceFile.isInNodeModules()) {
|
|
61
|
+
const depPath = depSourceFile.getFilePath();
|
|
62
|
+
const depNode = getNestedDependencies(depPath, project, visited);
|
|
63
|
+
if (depNode) {
|
|
64
|
+
dependencies.push(depNode);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
path: entryFilePath.replace('/virtual', ''),
|
|
70
|
+
content,
|
|
71
|
+
dependencies,
|
|
72
|
+
exportedNames,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=get-dependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-dependencies.js","sourceRoot":"","sources":["../../../src/utils/add/get-dependencies.ts"],"names":[],"mappings":";;AAUA,sDA0EC;AApFD,uCAAuC;AAIvC;;;;;GAKG;AACH,SAAgB,qBAAqB,CACjC,aAAqB,EACrB,OAAgB,EAChB,UAAuB,IAAI,GAAG,EAAE;IAEhC,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAE3B,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IAExD,IAAI,CAAC,UAAU,EAAE,CAAC;QACd,OAAO,CAAC,KAAK,CAAC,qCAAqC,aAAa,EAAE,CAAC,CAAC;QACpE,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,OAAO,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;IACzC,MAAM,YAAY,GAAyB,EAAE,CAAC;IAE9C,yBAAyB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I,OAAO,EAAE,CAAC;gBACV,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC/B,CAAC;QACL,CAAC;IACL,CAAC;IAED,iDAAiD;IACjD,MAAM,kBAAkB,GAAG,UAAU,CAAC,qBAAqB,EAAE,CAAC;IAC9D,KAAK,MAAM,GAAG,IAAI,kBAAkB,EAAE,CAAC;QACnC,MAAM,aAAa,GAAG,GAAG,CAAC,4BAA4B,EAAE,CAAC;QACzD,IAAI,aAAa,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,EAAE,CAAC;YACpD,MAAM,OAAO,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;YAC5C,MAAM,OAAO,GAAG,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YACjE,IAAI,OAAO,EAAE,CAAC;gBACV,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC/B,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO;QACH,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;QAC3C,OAAO;QACP,YAAY;QACZ,aAAa;KAChB,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFileNamesAndFolders = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const getFileNamesAndFolders = (files) => {
|
|
6
|
+
return (0, lodash_1.reduce)(files, (acc, file) => {
|
|
7
|
+
if (file.isDirectory) {
|
|
8
|
+
if (!acc[file.path]) {
|
|
9
|
+
acc[file.path] = [];
|
|
10
|
+
}
|
|
11
|
+
return acc;
|
|
12
|
+
}
|
|
13
|
+
const folder = file.path.replace(`/${file.fileName}`, '');
|
|
14
|
+
// console.log(acc, file.folderName);
|
|
15
|
+
if (acc[folder]) {
|
|
16
|
+
acc[folder].push(file.fileName);
|
|
17
|
+
}
|
|
18
|
+
return acc;
|
|
19
|
+
}, {});
|
|
20
|
+
};
|
|
21
|
+
exports.getFileNamesAndFolders = getFileNamesAndFolders;
|
|
22
|
+
//# sourceMappingURL=meta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.js","sourceRoot":"","sources":["../../../src/utils/add/meta.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAGzB,MAAM,sBAAsB,GAAG,CAAC,KAAsB,EAAE,EAAE;IAC7D,OAAO,IAAA,eAAM,EAAC,KAAK,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QAC/B,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACnB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBAClB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACxB,CAAC;YACD,OAAO,GAAG,CAAC;QACf,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAA;QACzD,qCAAqC;QACrC,IAAI,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACd,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,GAAG,CAAC;IACf,CAAC,EAAE,EAAmC,CAAC,CAAC;AAE5C,CAAC,CAAA;AAhBY,QAAA,sBAAsB,0BAgBlC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.processModules = void 0;
|
|
37
|
+
const path = __importStar(require("path"));
|
|
38
|
+
const promises_1 = require("fs/promises");
|
|
39
|
+
const crypto_1 = require("crypto");
|
|
40
|
+
const ts_morph_1 = require("ts-morph");
|
|
41
|
+
const zlib_1 = require("zlib");
|
|
42
|
+
const get_dependencies_1 = require("./get-dependencies");
|
|
43
|
+
const processModules = async (modules, flattenedFiles, mapping, modulesDir, mappingPath) => {
|
|
44
|
+
const inquirer = (await Promise.resolve().then(() => __importStar(require('inquirer')))).default;
|
|
45
|
+
const { selectedModuleNames } = await inquirer.prompt([
|
|
46
|
+
{
|
|
47
|
+
type: 'checkbox',
|
|
48
|
+
name: 'selectedModuleNames',
|
|
49
|
+
message: modules.some(m => m.manual) ? 'Select entry file to proceed:' : 'Select modules to process:',
|
|
50
|
+
choices: modules.map(m => ({
|
|
51
|
+
name: m.moduleName,
|
|
52
|
+
value: m.moduleName,
|
|
53
|
+
checked: false
|
|
54
|
+
})),
|
|
55
|
+
}
|
|
56
|
+
]);
|
|
57
|
+
const selectedModules = modules.filter(m => selectedModuleNames.includes(m.moduleName));
|
|
58
|
+
if (selectedModules.length === 0) {
|
|
59
|
+
console.log("No modules selected. Exiting.");
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const modulesToProcess = [];
|
|
63
|
+
for (const module of selectedModules) {
|
|
64
|
+
if (Array.isArray(module.entryFile)) {
|
|
65
|
+
const { select } = await Promise.resolve().then(() => __importStar(require("@inquirer/prompts")));
|
|
66
|
+
const entryFile = await select({
|
|
67
|
+
message: `Select an entry file:`,
|
|
68
|
+
choices: module.entryFile.map(m => ({ name: m, value: m })),
|
|
69
|
+
default: module.entryFile?.[0],
|
|
70
|
+
});
|
|
71
|
+
module.entryFile = entryFile;
|
|
72
|
+
module.originalName = path.parse(entryFile).name.split(/[.-]/)[0];
|
|
73
|
+
if (entryFile.length === 0) {
|
|
74
|
+
console.log("No entry file selected. Exiting.");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const { customName } = await inquirer.prompt([
|
|
79
|
+
{
|
|
80
|
+
type: 'input',
|
|
81
|
+
name: 'customName',
|
|
82
|
+
message: `Enter name for module ${module.moduleName}:`,
|
|
83
|
+
default: module.moduleName
|
|
84
|
+
}
|
|
85
|
+
]);
|
|
86
|
+
if (mapping[customName]) {
|
|
87
|
+
console.log(`\nNote: Module "${customName}" already exists and will be updated.\n`);
|
|
88
|
+
}
|
|
89
|
+
modulesToProcess.push({
|
|
90
|
+
...module,
|
|
91
|
+
moduleName: customName,
|
|
92
|
+
originalName: module.originalName || path.parse(module.moduleName).name.split(/[.-]/)[0] // Get base name (e.g., 'user' from 'user.controller.ts', 'storage' from 'storage-stack.ts')
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
const project = new ts_morph_1.Project({
|
|
96
|
+
useInMemoryFileSystem: true,
|
|
97
|
+
compilerOptions: {
|
|
98
|
+
allowJs: true,
|
|
99
|
+
target: ts_morph_1.ts.ScriptTarget.ESNext,
|
|
100
|
+
module: ts_morph_1.ts.ModuleKind.CommonJS,
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
const VIRTUAL_ROOT = "/virtual";
|
|
104
|
+
for (const file of flattenedFiles) {
|
|
105
|
+
if (file.content !== undefined && !file.isDirectory) {
|
|
106
|
+
const virtualPath = path.join(VIRTUAL_ROOT, file.path);
|
|
107
|
+
project.createSourceFile(virtualPath, file.content, { overwrite: true });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const components = modulesToProcess.map(module => {
|
|
111
|
+
const entryFile = module.entryFile;
|
|
112
|
+
const projectRoot = process.cwd();
|
|
113
|
+
const relativeEntryPath = path.isAbsolute(entryFile) ? path.relative(projectRoot, entryFile) : entryFile;
|
|
114
|
+
const virtualEntryPath = path.join(VIRTUAL_ROOT, relativeEntryPath);
|
|
115
|
+
const deps = (0, get_dependencies_1.getNestedDependencies)(virtualEntryPath, project);
|
|
116
|
+
return {
|
|
117
|
+
name: module.moduleName,
|
|
118
|
+
originalName: module.originalName,
|
|
119
|
+
exportedNames: deps?.exportedNames || [],
|
|
120
|
+
deps
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
for (const component of components) {
|
|
124
|
+
const id = mapping[component.name] || (0, crypto_1.randomUUID)();
|
|
125
|
+
if (!mapping[component.name]) {
|
|
126
|
+
mapping[component.name] = id;
|
|
127
|
+
}
|
|
128
|
+
const compressed = (0, zlib_1.gzipSync)(JSON.stringify(component));
|
|
129
|
+
await (0, promises_1.writeFile)(path.join(modulesDir, `${id}.via`), compressed);
|
|
130
|
+
const chalk = (await Promise.resolve().then(() => __importStar(require('chalk')))).default;
|
|
131
|
+
console.log(`\n${chalk.green.bold('✓')} Module ${chalk.cyan(component.name)} saved successfully!`);
|
|
132
|
+
console.log(`${chalk.gray('Example usage:')} ${chalk.white(`via ${component.name} create [newName]`)}\n`);
|
|
133
|
+
}
|
|
134
|
+
await (0, promises_1.writeFile)(mappingPath, JSON.stringify(mapping), 'utf-8');
|
|
135
|
+
for (const sourceFile of project.getSourceFiles()) {
|
|
136
|
+
project.removeSourceFile(sourceFile);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
exports.processModules = processModules;
|
|
140
|
+
//# sourceMappingURL=module-processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-processor.js","sourceRoot":"","sources":["../../../src/utils/add/module-processor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,0CAAwC;AACxC,mCAAoC;AACpC,uCAAuC;AACvC,+BAAgC;AAChC,yDAA2D;AAGpD,MAAM,cAAc,GAAG,KAAK,EAC/B,OAA6F,EAC7F,cAA+B,EAC/B,OAAgB,EAChB,UAAkB,EAClB,WAAmB,EACrB,EAAE;IACA,MAAM,QAAQ,GAAG,CAAC,wDAAa,UAAU,GAAC,CAAC,CAAC,OAAO,CAAC;IAEpD,MAAM,EAAE,mBAAmB,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;QAClD;YACI,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,qBAAqB;YAC3B,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAAC,CAAC,4BAA4B;YACrG,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CA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