@gadmin2n/cli 0.0.85 → 0.0.87
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/actions/index.d.ts +1 -0
- package/actions/index.js +1 -0
- package/actions/template.action.d.ts +7 -0
- package/actions/template.action.js +386 -0
- package/commands/command.loader.js +2 -0
- package/commands/template.command.d.ts +5 -0
- package/commands/template.command.js +34 -0
- package/package.json +2 -2
package/actions/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from './build.action';
|
|
|
3
3
|
export * from './generate.action';
|
|
4
4
|
export * from './info.action';
|
|
5
5
|
export * from './new.action';
|
|
6
|
+
export * from './template.action';
|
|
6
7
|
export * from './update.action';
|
|
7
8
|
export * from './start.action';
|
|
8
9
|
export * from './add.action';
|
package/actions/index.js
CHANGED
|
@@ -19,6 +19,7 @@ __exportStar(require("./build.action"), exports);
|
|
|
19
19
|
__exportStar(require("./generate.action"), exports);
|
|
20
20
|
__exportStar(require("./info.action"), exports);
|
|
21
21
|
__exportStar(require("./new.action"), exports);
|
|
22
|
+
__exportStar(require("./template.action"), exports);
|
|
22
23
|
__exportStar(require("./update.action"), exports);
|
|
23
24
|
__exportStar(require("./start.action"), exports);
|
|
24
25
|
__exportStar(require("./add.action"), exports);
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.TemplateAction = void 0;
|
|
13
|
+
const chalk = require("chalk");
|
|
14
|
+
const fs = require("fs");
|
|
15
|
+
const path = require("path");
|
|
16
|
+
const inquirer = require("inquirer");
|
|
17
|
+
const abstract_action_1 = require("./abstract.action");
|
|
18
|
+
const EXCLUDES = [
|
|
19
|
+
'node_modules',
|
|
20
|
+
'.git',
|
|
21
|
+
'dist',
|
|
22
|
+
'generated',
|
|
23
|
+
'.DS_Store',
|
|
24
|
+
'.env.local',
|
|
25
|
+
'readme.md'
|
|
26
|
+
];
|
|
27
|
+
function shouldExclude(filePath) {
|
|
28
|
+
const parts = filePath.split('/');
|
|
29
|
+
for (const pattern of EXCLUDES) {
|
|
30
|
+
if (parts.includes(pattern))
|
|
31
|
+
return true;
|
|
32
|
+
if (filePath === pattern)
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
function collectFiles(dir, base = '') {
|
|
38
|
+
const results = [];
|
|
39
|
+
const entries = fs.readdirSync(path.join(dir, base), { withFileTypes: true });
|
|
40
|
+
for (const entry of entries) {
|
|
41
|
+
const rel = base ? `${base}/${entry.name}` : entry.name;
|
|
42
|
+
if (shouldExclude(rel))
|
|
43
|
+
continue;
|
|
44
|
+
if (entry.isDirectory()) {
|
|
45
|
+
results.push(...collectFiles(dir, rel));
|
|
46
|
+
}
|
|
47
|
+
else if (entry.isFile()) {
|
|
48
|
+
results.push(rel);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return results.sort();
|
|
52
|
+
}
|
|
53
|
+
function resolveTemplatePath() {
|
|
54
|
+
// Try to read gadmin-cli.json from current project
|
|
55
|
+
const configPaths = [
|
|
56
|
+
path.join(process.cwd(), 'server/gadmin-cli.json'),
|
|
57
|
+
path.join(process.cwd(), 'gadmin-cli.json'),
|
|
58
|
+
];
|
|
59
|
+
let templateName;
|
|
60
|
+
for (const configPath of configPaths) {
|
|
61
|
+
if (fs.existsSync(configPath)) {
|
|
62
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
63
|
+
templateName = config.template;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (!templateName) {
|
|
68
|
+
throw new Error('Cannot find "template" field in gadmin-cli.json. ' +
|
|
69
|
+
'Make sure you are in a gadmin2 project root directory.');
|
|
70
|
+
}
|
|
71
|
+
// Resolve @gadmin2n/schematics package path
|
|
72
|
+
// Try multiple locations: project's node_modules, CLI's own node_modules
|
|
73
|
+
let schematicsRoot;
|
|
74
|
+
const searchPaths = [
|
|
75
|
+
process.cwd(),
|
|
76
|
+
path.join(process.cwd(), 'server'),
|
|
77
|
+
path.resolve(__dirname, '..'), // CLI package root
|
|
78
|
+
];
|
|
79
|
+
for (const searchPath of searchPaths) {
|
|
80
|
+
try {
|
|
81
|
+
const pkgPath = require.resolve('@gadmin2n/schematics/package.json', {
|
|
82
|
+
paths: [searchPath],
|
|
83
|
+
});
|
|
84
|
+
schematicsRoot = path.dirname(pkgPath);
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
catch (_a) {
|
|
88
|
+
// continue trying next path
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (!schematicsRoot) {
|
|
92
|
+
throw new Error('Cannot resolve @gadmin2n/schematics package. ' +
|
|
93
|
+
'Make sure it is installed.');
|
|
94
|
+
}
|
|
95
|
+
// Check dist path first (published package), then src path (yalc/dev link)
|
|
96
|
+
// Also try with name variants (gadmin2n → gadmin2) for backward compatibility
|
|
97
|
+
const nameVariants = [templateName];
|
|
98
|
+
if (templateName.startsWith('gadmin2n-')) {
|
|
99
|
+
nameVariants.push(templateName.replace('gadmin2n-', 'gadmin2-'));
|
|
100
|
+
}
|
|
101
|
+
else if (templateName.startsWith('gadmin2-')) {
|
|
102
|
+
nameVariants.push(templateName.replace('gadmin2-', 'gadmin2n-'));
|
|
103
|
+
}
|
|
104
|
+
for (const name of nameVariants) {
|
|
105
|
+
const distPath = path.join(schematicsRoot, 'dist/lib/application/files', name);
|
|
106
|
+
const srcPath = path.join(schematicsRoot, 'src/lib/application/files', name);
|
|
107
|
+
if (fs.existsSync(distPath))
|
|
108
|
+
return distPath;
|
|
109
|
+
if (fs.existsSync(srcPath))
|
|
110
|
+
return srcPath;
|
|
111
|
+
}
|
|
112
|
+
throw new Error(`Template directory not found for "${templateName}" in ${schematicsRoot}`);
|
|
113
|
+
}
|
|
114
|
+
function createUnifiedDiff(filePath, instanceContent, templateContent) {
|
|
115
|
+
const instanceLines = instanceContent.split('\n');
|
|
116
|
+
const templateLines = templateContent.split('\n');
|
|
117
|
+
// Simple line-by-line diff output
|
|
118
|
+
const lines = [];
|
|
119
|
+
lines.push(chalk.bold(`--- a/${filePath} (instance)`));
|
|
120
|
+
lines.push(chalk.bold(`+++ b/${filePath} (template)`));
|
|
121
|
+
// Find differing regions using a simple approach
|
|
122
|
+
const maxLen = Math.max(instanceLines.length, templateLines.length);
|
|
123
|
+
const hunks = [];
|
|
124
|
+
let currentHunk = null;
|
|
125
|
+
for (let i = 0; i < maxLen; i++) {
|
|
126
|
+
const a = i < instanceLines.length ? instanceLines[i] : undefined;
|
|
127
|
+
const b = i < templateLines.length ? templateLines[i] : undefined;
|
|
128
|
+
if (a !== b) {
|
|
129
|
+
if (!currentHunk) {
|
|
130
|
+
currentHunk = { start: i, instanceLines: [], templateLines: [] };
|
|
131
|
+
}
|
|
132
|
+
if (a !== undefined)
|
|
133
|
+
currentHunk.instanceLines.push(a);
|
|
134
|
+
if (b !== undefined)
|
|
135
|
+
currentHunk.templateLines.push(b);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
if (currentHunk) {
|
|
139
|
+
hunks.push(currentHunk);
|
|
140
|
+
currentHunk = null;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (currentHunk)
|
|
145
|
+
hunks.push(currentHunk);
|
|
146
|
+
// Output hunks with context
|
|
147
|
+
for (const hunk of hunks.slice(0, 10)) { // Limit to first 10 hunks
|
|
148
|
+
const contextStart = Math.max(0, hunk.start - 2);
|
|
149
|
+
lines.push(chalk.cyan(`@@ -${hunk.start + 1},${hunk.instanceLines.length} +${hunk.start + 1},${hunk.templateLines.length} @@`));
|
|
150
|
+
// Context before
|
|
151
|
+
for (let i = contextStart; i < hunk.start; i++) {
|
|
152
|
+
if (i < instanceLines.length) {
|
|
153
|
+
lines.push(` ${instanceLines[i]}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
// Removed lines (instance)
|
|
157
|
+
for (const line of hunk.instanceLines) {
|
|
158
|
+
lines.push(chalk.red(`-${line}`));
|
|
159
|
+
}
|
|
160
|
+
// Added lines (template)
|
|
161
|
+
for (const line of hunk.templateLines) {
|
|
162
|
+
lines.push(chalk.green(`+${line}`));
|
|
163
|
+
}
|
|
164
|
+
// Context after
|
|
165
|
+
const afterStart = hunk.start + Math.max(hunk.instanceLines.length, hunk.templateLines.length);
|
|
166
|
+
for (let i = afterStart; i < Math.min(afterStart + 2, instanceLines.length); i++) {
|
|
167
|
+
lines.push(` ${instanceLines[i]}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (hunks.length > 10) {
|
|
171
|
+
lines.push(chalk.yellow(` ... and ${hunks.length - 10} more hunks`));
|
|
172
|
+
}
|
|
173
|
+
return lines.join('\n');
|
|
174
|
+
}
|
|
175
|
+
function createConflictContent(instanceContent, templateContent) {
|
|
176
|
+
return [
|
|
177
|
+
'<<<<<<< INSTANCE',
|
|
178
|
+
instanceContent,
|
|
179
|
+
'=======',
|
|
180
|
+
templateContent,
|
|
181
|
+
'>>>>>>> TEMPLATE',
|
|
182
|
+
].join('\n');
|
|
183
|
+
}
|
|
184
|
+
class TemplateAction extends abstract_action_1.AbstractAction {
|
|
185
|
+
handle(inputs, options) {
|
|
186
|
+
var _a;
|
|
187
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
+
const subcommand = (_a = inputs.find((i) => i.name === 'subcommand')) === null || _a === void 0 ? void 0 : _a.value;
|
|
189
|
+
if (subcommand === 'diff') {
|
|
190
|
+
yield this.handleDiff(options);
|
|
191
|
+
}
|
|
192
|
+
else if (subcommand === 'update') {
|
|
193
|
+
yield this.handleUpdate(options);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
handleDiff(options) {
|
|
198
|
+
var _a;
|
|
199
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
+
const noContent = (_a = options.find((o) => o.name === 'no-content')) === null || _a === void 0 ? void 0 : _a.value;
|
|
201
|
+
let templateDir;
|
|
202
|
+
try {
|
|
203
|
+
templateDir = resolveTemplatePath();
|
|
204
|
+
}
|
|
205
|
+
catch (err) {
|
|
206
|
+
console.error(chalk.red(err.message));
|
|
207
|
+
process.exit(1);
|
|
208
|
+
}
|
|
209
|
+
const instanceDir = process.cwd();
|
|
210
|
+
console.info(`\n${chalk.gray('Template:')} ${templateDir}`);
|
|
211
|
+
console.info(`${chalk.gray('Instance:')} ${instanceDir}\n`);
|
|
212
|
+
const templateFiles = collectFiles(templateDir);
|
|
213
|
+
const instanceFiles = collectFiles(instanceDir);
|
|
214
|
+
const templateSet = new Set(templateFiles);
|
|
215
|
+
const instanceSet = new Set(instanceFiles);
|
|
216
|
+
// Modified: both have, content differs
|
|
217
|
+
const modified = [];
|
|
218
|
+
// Only in template (would be added on update)
|
|
219
|
+
const onlyInTemplate = [];
|
|
220
|
+
// Only in instance (instance-specific)
|
|
221
|
+
const onlyInInstance = [];
|
|
222
|
+
for (const file of templateFiles) {
|
|
223
|
+
if (instanceSet.has(file)) {
|
|
224
|
+
const tContent = fs.readFileSync(path.join(templateDir, file), 'utf-8');
|
|
225
|
+
const iContent = fs.readFileSync(path.join(instanceDir, file), 'utf-8');
|
|
226
|
+
if (tContent !== iContent) {
|
|
227
|
+
modified.push(file);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
onlyInTemplate.push(file);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
for (const file of instanceFiles) {
|
|
235
|
+
if (!templateSet.has(file)) {
|
|
236
|
+
onlyInInstance.push(file);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
// Summary
|
|
240
|
+
console.info(chalk.bold('═══════════════════════════════════════════════════'));
|
|
241
|
+
console.info(chalk.bold(' Template Diff Summary'));
|
|
242
|
+
console.info(chalk.bold('═══════════════════════════════════════════════════\n'));
|
|
243
|
+
if (modified.length > 0) {
|
|
244
|
+
console.info(chalk.yellow(`📝 Modified (${modified.length} files)`));
|
|
245
|
+
for (const f of modified) {
|
|
246
|
+
console.info(` ${f}`);
|
|
247
|
+
}
|
|
248
|
+
console.info();
|
|
249
|
+
}
|
|
250
|
+
if (onlyInTemplate.length > 0) {
|
|
251
|
+
console.info(chalk.green(`➕ Only in template (${onlyInTemplate.length} files)`));
|
|
252
|
+
for (const f of onlyInTemplate) {
|
|
253
|
+
console.info(` ${f}`);
|
|
254
|
+
}
|
|
255
|
+
console.info();
|
|
256
|
+
}
|
|
257
|
+
if (onlyInInstance.length > 0) {
|
|
258
|
+
console.info(chalk.cyan(`📄 Only in instance (${onlyInInstance.length} files)`));
|
|
259
|
+
for (const f of onlyInInstance) {
|
|
260
|
+
console.info(` ${f}`);
|
|
261
|
+
}
|
|
262
|
+
console.info();
|
|
263
|
+
}
|
|
264
|
+
if (modified.length === 0 && onlyInTemplate.length === 0 && onlyInInstance.length === 0) {
|
|
265
|
+
console.info(chalk.green('✅ No differences found. Instance matches template.\n'));
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
// Show diff content for modified files
|
|
269
|
+
if (!noContent && modified.length > 0) {
|
|
270
|
+
console.info(chalk.bold('───────────────────────────────────────────────────'));
|
|
271
|
+
console.info(chalk.bold(' File Diffs (instance vs template)'));
|
|
272
|
+
console.info(chalk.bold('───────────────────────────────────────────────────\n'));
|
|
273
|
+
for (const file of modified) {
|
|
274
|
+
const tContent = fs.readFileSync(path.join(templateDir, file), 'utf-8');
|
|
275
|
+
const iContent = fs.readFileSync(path.join(instanceDir, file), 'utf-8');
|
|
276
|
+
const diff = createUnifiedDiff(file, iContent, tContent);
|
|
277
|
+
console.info(diff);
|
|
278
|
+
console.info();
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
handleUpdate(options) {
|
|
284
|
+
var _a, _b;
|
|
285
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
286
|
+
const dryRun = (_a = options.find((o) => o.name === 'dry-run')) === null || _a === void 0 ? void 0 : _a.value;
|
|
287
|
+
const autoYes = (_b = options.find((o) => o.name === 'yes')) === null || _b === void 0 ? void 0 : _b.value;
|
|
288
|
+
let templateDir;
|
|
289
|
+
try {
|
|
290
|
+
templateDir = resolveTemplatePath();
|
|
291
|
+
}
|
|
292
|
+
catch (err) {
|
|
293
|
+
console.error(chalk.red(err.message));
|
|
294
|
+
process.exit(1);
|
|
295
|
+
}
|
|
296
|
+
const instanceDir = process.cwd();
|
|
297
|
+
console.info(`\n${chalk.gray('Template:')} ${templateDir}`);
|
|
298
|
+
console.info(`${chalk.gray('Instance:')} ${instanceDir}\n`);
|
|
299
|
+
const templateFiles = collectFiles(templateDir);
|
|
300
|
+
const instanceFiles = collectFiles(instanceDir);
|
|
301
|
+
const instanceSet = new Set(instanceFiles);
|
|
302
|
+
// Categorize changes (template → instance direction)
|
|
303
|
+
const toUpdate = []; // exists in both, content differs
|
|
304
|
+
const toAdd = []; // only in template
|
|
305
|
+
for (const file of templateFiles) {
|
|
306
|
+
if (instanceSet.has(file)) {
|
|
307
|
+
const tContent = fs.readFileSync(path.join(templateDir, file), 'utf-8');
|
|
308
|
+
const iContent = fs.readFileSync(path.join(instanceDir, file), 'utf-8');
|
|
309
|
+
if (tContent !== iContent) {
|
|
310
|
+
toUpdate.push(file);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
else {
|
|
314
|
+
toAdd.push(file);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (toUpdate.length === 0 && toAdd.length === 0) {
|
|
318
|
+
console.info(chalk.green('✅ Instance is up to date with template.\n'));
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
// Summary
|
|
322
|
+
console.info(chalk.bold('═══════════════════════════════════════════════════'));
|
|
323
|
+
console.info(chalk.bold(' Template Update Summary'));
|
|
324
|
+
console.info(chalk.bold('═══════════════════════════════════════════════════\n'));
|
|
325
|
+
if (toUpdate.length > 0) {
|
|
326
|
+
console.info(chalk.yellow(`📝 To update (${toUpdate.length} files) — conflict markers will be added`));
|
|
327
|
+
for (const f of toUpdate) {
|
|
328
|
+
console.info(` ${f}`);
|
|
329
|
+
}
|
|
330
|
+
console.info();
|
|
331
|
+
}
|
|
332
|
+
if (toAdd.length > 0) {
|
|
333
|
+
console.info(chalk.green(`➕ To add (${toAdd.length} files)`));
|
|
334
|
+
for (const f of toAdd) {
|
|
335
|
+
console.info(` ${f}`);
|
|
336
|
+
}
|
|
337
|
+
console.info();
|
|
338
|
+
}
|
|
339
|
+
console.info(chalk.gray('───────────────────────────────────────────────────'));
|
|
340
|
+
console.info(chalk.gray(` Total: ${toUpdate.length} update | ${toAdd.length} add`));
|
|
341
|
+
console.info(chalk.gray('───────────────────────────────────────────────────\n'));
|
|
342
|
+
if (dryRun) {
|
|
343
|
+
console.info(chalk.gray('(dry-run mode, no changes made)\n'));
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
// Confirm
|
|
347
|
+
if (!autoYes) {
|
|
348
|
+
const { confirm } = yield inquirer.prompt([
|
|
349
|
+
{
|
|
350
|
+
type: 'confirm',
|
|
351
|
+
name: 'confirm',
|
|
352
|
+
message: 'Proceed with update?',
|
|
353
|
+
default: false,
|
|
354
|
+
},
|
|
355
|
+
]);
|
|
356
|
+
if (!confirm) {
|
|
357
|
+
console.info('Cancelled.\n');
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
// Execute
|
|
362
|
+
let conflictCount = 0;
|
|
363
|
+
for (const file of toUpdate) {
|
|
364
|
+
const tContent = fs.readFileSync(path.join(templateDir, file), 'utf-8');
|
|
365
|
+
const iContent = fs.readFileSync(path.join(instanceDir, file), 'utf-8');
|
|
366
|
+
const conflictContent = createConflictContent(iContent, tContent);
|
|
367
|
+
fs.writeFileSync(path.join(instanceDir, file), conflictContent, 'utf-8');
|
|
368
|
+
conflictCount++;
|
|
369
|
+
}
|
|
370
|
+
for (const file of toAdd) {
|
|
371
|
+
const destPath = path.join(instanceDir, file);
|
|
372
|
+
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
373
|
+
fs.copyFileSync(path.join(templateDir, file), destPath);
|
|
374
|
+
}
|
|
375
|
+
console.info(chalk.bold('\n✅ Update complete!\n'));
|
|
376
|
+
if (conflictCount > 0) {
|
|
377
|
+
console.info(chalk.yellow(`⚠️ ${conflictCount} files have conflict markers. ` +
|
|
378
|
+
`Search for "<<<<<<< INSTANCE" to resolve them.\n`));
|
|
379
|
+
}
|
|
380
|
+
if (toAdd.length > 0) {
|
|
381
|
+
console.info(chalk.green(` ${toAdd.length} files added.\n`));
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
exports.TemplateAction = TemplateAction;
|
|
@@ -10,6 +10,7 @@ const generate_command_1 = require("./generate.command");
|
|
|
10
10
|
const info_command_1 = require("./info.command");
|
|
11
11
|
const new_command_1 = require("./new.command");
|
|
12
12
|
const start_command_1 = require("./start.command");
|
|
13
|
+
const template_command_1 = require("./template.command");
|
|
13
14
|
const update_command_1 = require("./update.command");
|
|
14
15
|
class CommandLoader {
|
|
15
16
|
static load(program) {
|
|
@@ -18,6 +19,7 @@ class CommandLoader {
|
|
|
18
19
|
new start_command_1.StartCommand(new actions_1.StartAction()).load(program);
|
|
19
20
|
new info_command_1.InfoCommand(new actions_1.InfoAction()).load(program);
|
|
20
21
|
new update_command_1.UpdateCommand(new actions_1.UpdateAction()).load(program);
|
|
22
|
+
new template_command_1.TemplateCommand(new actions_1.TemplateAction()).load(program);
|
|
21
23
|
new add_command_1.AddCommand(new actions_1.AddAction()).load(program);
|
|
22
24
|
new generate_command_1.GenerateCommand(new actions_1.GenerateAction()).load(program);
|
|
23
25
|
this.handleInvalidCommand(program);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.TemplateCommand = void 0;
|
|
13
|
+
const abstract_command_1 = require("./abstract.command");
|
|
14
|
+
class TemplateCommand extends abstract_command_1.AbstractCommand {
|
|
15
|
+
load(program) {
|
|
16
|
+
program
|
|
17
|
+
.command('template <subcommand>')
|
|
18
|
+
.alias('tpl')
|
|
19
|
+
.description('Compare or sync with the project template.')
|
|
20
|
+
.option('--no-content', 'Only show file list, skip inline diff content (for diff).')
|
|
21
|
+
.option('-d, --dry-run', 'Show what would be updated without making changes (for update).')
|
|
22
|
+
.option('-y, --yes', 'Skip confirmation prompt (for update).')
|
|
23
|
+
.action((subcommand, command) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const inputs = [];
|
|
25
|
+
inputs.push({ name: 'subcommand', value: subcommand });
|
|
26
|
+
const options = [];
|
|
27
|
+
options.push({ name: 'no-content', value: !command.content });
|
|
28
|
+
options.push({ name: 'dry-run', value: !!command.dryRun });
|
|
29
|
+
options.push({ name: 'yes', value: !!command.yes });
|
|
30
|
+
yield this.action.handle(inputs, options);
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.TemplateCommand = TemplateCommand;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gadmin2n/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.87",
|
|
4
4
|
"description": "Gadmin - modern, fast, powerful node.js web framework (@cli)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@angular-devkit/core": "13.3.2",
|
|
48
48
|
"@angular-devkit/schematics": "13.3.2",
|
|
49
49
|
"@angular-devkit/schematics-cli": "13.3.2",
|
|
50
|
-
"@gadmin2n/schematics": "^0.0.
|
|
50
|
+
"@gadmin2n/schematics": "^0.0.70",
|
|
51
51
|
"abc": "^0.6.1",
|
|
52
52
|
"chalk": "3.0.0",
|
|
53
53
|
"chokidar": "3.5.3",
|