@diagramers/cli 2.0.3 → 4.0.1
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 +413 -642
- package/dist/commands/admin.d.ts +1 -1
- package/dist/commands/admin.d.ts.map +1 -1
- package/dist/commands/admin.js +33 -224
- package/dist/commands/admin.js.map +1 -1
- package/dist/services/project-initializer.js +3 -3
- package/package.json +3 -3
package/dist/commands/admin.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/commands/admin.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../src/commands/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,WAgD5C"}
|
package/dist/commands/admin.js
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
"use strict";
|
2
|
-
// Admin CLI commands have been removed. Start your new admin CLI implementation here.
|
3
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
4
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
5
4
|
};
|
@@ -7,243 +6,53 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
6
|
exports.adminCommand = adminCommand;
|
8
7
|
const chalk_1 = __importDefault(require("chalk"));
|
9
8
|
const child_process_1 = require("child_process");
|
10
|
-
const fs_1 = __importDefault(require("fs"));
|
11
|
-
const path_1 = __importDefault(require("path"));
|
12
|
-
const glob_1 = __importDefault(require("glob"));
|
13
|
-
// Utility to read .templateignore and filter files
|
14
|
-
function getTemplateFiles(templateDir) {
|
15
|
-
const ignorePath = path_1.default.join(templateDir, '.templateignore');
|
16
|
-
let ignorePatterns = [];
|
17
|
-
if (fs_1.default.existsSync(ignorePath)) {
|
18
|
-
ignorePatterns = fs_1.default.readFileSync(ignorePath, 'utf8')
|
19
|
-
.split('\n')
|
20
|
-
.map(line => line.trim())
|
21
|
-
.filter(line => line && !line.startsWith('#'));
|
22
|
-
}
|
23
|
-
// Get all files, then filter out ignored
|
24
|
-
const allFiles = glob_1.default.sync('**/*', { cwd: templateDir, dot: true, nodir: true });
|
25
|
-
if (ignorePatterns.length === 0)
|
26
|
-
return allFiles;
|
27
|
-
// Use glob to filter
|
28
|
-
const ignored = new Set(ignorePatterns.flatMap(pattern => glob_1.default.sync(pattern, { cwd: templateDir, dot: true, nodir: true })));
|
29
|
-
return allFiles.filter(f => !ignored.has(f));
|
30
|
-
}
|
31
|
-
// Example usage in a stub for processAdminTemplate
|
32
|
-
async function processAdminTemplate(projectName) {
|
33
|
-
const templateDir = path_1.default.resolve(__dirname, '../../../diagramers-admin');
|
34
|
-
const destDir = path_1.default.resolve(process.cwd(), projectName);
|
35
|
-
if (!fs_1.default.existsSync(destDir))
|
36
|
-
fs_1.default.mkdirSync(destDir, { recursive: true });
|
37
|
-
const files = getTemplateFiles(templateDir);
|
38
|
-
for (const relPath of files) {
|
39
|
-
const srcPath = path_1.default.join(templateDir, relPath);
|
40
|
-
const destPath = path_1.default.join(destDir, relPath);
|
41
|
-
const destFolder = path_1.default.dirname(destPath);
|
42
|
-
if (!fs_1.default.existsSync(destFolder))
|
43
|
-
fs_1.default.mkdirSync(destFolder, { recursive: true });
|
44
|
-
fs_1.default.copyFileSync(srcPath, destPath);
|
45
|
-
}
|
46
|
-
console.log(chalk_1.default.green(`✅ Admin template processed for '${projectName}' (ignored files excluded)`));
|
47
|
-
}
|
48
|
-
async function getLatestAdminVersion() {
|
49
|
-
try {
|
50
|
-
return (0, child_process_1.execSync)('npm view @diagramers/admin version', { encoding: 'utf8', timeout: 5000 }).trim();
|
51
|
-
}
|
52
|
-
catch {
|
53
|
-
return 'latest';
|
54
|
-
}
|
55
|
-
}
|
56
|
-
async function initAdminProject(projectName, options) {
|
57
|
-
try {
|
58
|
-
let version = options.version || 'latest';
|
59
|
-
let npxPrefix = '--ignore-existing';
|
60
|
-
if (options.version) {
|
61
|
-
console.log(chalk_1.default.blue(`ℹ️ Using user-specified @diagramers/admin version: ${version}`));
|
62
|
-
}
|
63
|
-
else {
|
64
|
-
version = 'latest';
|
65
|
-
console.log(chalk_1.default.blue(`ℹ️ Using @diagramers/admin@latest (always fetches the latest from npm, ignoring cache)`));
|
66
|
-
}
|
67
|
-
let command = `npx ${npxPrefix} @diagramers/admin@${version} init ${projectName}`;
|
68
|
-
if (options.framework) {
|
69
|
-
command += ` --framework ${options.framework}`;
|
70
|
-
}
|
71
|
-
if (options.apiUrl) {
|
72
|
-
command += ` --api-url ${options.apiUrl}`;
|
73
|
-
}
|
74
|
-
if (options.port) {
|
75
|
-
command += ` --port ${options.port}`;
|
76
|
-
}
|
77
|
-
if (options.yes) {
|
78
|
-
command += ` --yes`;
|
79
|
-
}
|
80
|
-
console.log(chalk_1.default.gray(`Executing: ${command}`));
|
81
|
-
(0, child_process_1.execSync)(command, { stdio: 'inherit' });
|
82
|
-
console.log(chalk_1.default.green(`✅ Admin application '${projectName}' initialized successfully!`));
|
83
|
-
console.log(chalk_1.default.blue(`📁 Project created at: ${process.cwd()}/${projectName}`));
|
84
|
-
console.log(chalk_1.default.blue(`🚀 To start development: cd ${projectName} && npm start`));
|
85
|
-
}
|
86
|
-
catch (error) {
|
87
|
-
console.error(chalk_1.default.red(`❌ Failed to initialize admin project: ${error.message}`));
|
88
|
-
process.exit(1);
|
89
|
-
}
|
90
|
-
}
|
91
9
|
function adminCommand(program) {
|
92
10
|
const admin = program
|
93
11
|
.command('admin')
|
94
12
|
.description('Admin-specific commands for Diagramers projects');
|
95
|
-
// Version command
|
96
13
|
admin
|
97
|
-
.command('
|
98
|
-
.description('
|
99
|
-
.option('-
|
100
|
-
.
|
14
|
+
.command('init <projectName>')
|
15
|
+
.description('Initialize a new admin application')
|
16
|
+
.option('-f, --framework <framework>', 'Framework to use (react, vue, angular)', 'react')
|
17
|
+
.option('-a, --api-url <url>', 'API URL for backend integration', 'http://localhost:3000')
|
18
|
+
.option('-p, --port <port>', 'Port number for development server', '3000')
|
19
|
+
.option('-v, --version <version>', 'Specific version to use')
|
20
|
+
.option('-y, --yes', 'Skip prompts and use defaults')
|
21
|
+
.action(async (projectName, options) => {
|
101
22
|
try {
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
const versionInfo = (0, child_process_1.execSync)(`npm view @diagramers/admin@${options.check} version`, {
|
106
|
-
encoding: 'utf8',
|
107
|
-
timeout: 5000,
|
108
|
-
}).trim();
|
109
|
-
console.log(chalk_1.default.green(`✅ Version ${options.check} exists: ${versionInfo}`));
|
110
|
-
}
|
111
|
-
catch (error) {
|
112
|
-
console.log(chalk_1.default.red(`❌ Version ${options.check} not found`));
|
113
|
-
try {
|
114
|
-
const versionsOutput = (0, child_process_1.execSync)('npm view @diagramers/admin versions --json', {
|
115
|
-
encoding: 'utf8',
|
116
|
-
timeout: 10000,
|
117
|
-
});
|
118
|
-
const versions = JSON.parse(versionsOutput);
|
119
|
-
const recentVersions = Array.isArray(versions) ? versions.slice(-5) : [versions];
|
120
|
-
console.log(chalk_1.default.yellow('\n📦 Recent available versions:'));
|
121
|
-
recentVersions.forEach((version) => {
|
122
|
-
console.log(chalk_1.default.yellow(` ${version}`));
|
123
|
-
});
|
124
|
-
}
|
125
|
-
catch (versionError) {
|
126
|
-
console.log(chalk_1.default.gray('Could not fetch available versions'));
|
127
|
-
}
|
128
|
-
}
|
23
|
+
let version = options.version || 'latest';
|
24
|
+
if (options.version) {
|
25
|
+
console.log(chalk_1.default.blue(`ℹ️ Using user-specified @diagramers/admin version: ${version}`));
|
129
26
|
}
|
130
27
|
else {
|
131
|
-
|
132
|
-
|
133
|
-
const latestVersion = (0, child_process_1.execSync)('npm view @diagramers/admin version', {
|
134
|
-
encoding: 'utf8',
|
135
|
-
timeout: 5000,
|
136
|
-
}).trim();
|
137
|
-
console.log(chalk_1.default.green(`Latest: ${latestVersion}`));
|
138
|
-
}
|
139
|
-
catch (error) {
|
140
|
-
console.log(chalk_1.default.red('Could not fetch latest version'));
|
141
|
-
}
|
142
|
-
try {
|
143
|
-
const localVersion = (0, child_process_1.execSync)('npm list @diagramers/admin --depth=0', {
|
144
|
-
encoding: 'utf8',
|
145
|
-
timeout: 5000,
|
146
|
-
});
|
147
|
-
console.log(chalk_1.default.blue('Local project version:'));
|
148
|
-
console.log(localVersion);
|
149
|
-
}
|
150
|
-
catch (error) {
|
151
|
-
console.log(chalk_1.default.gray('No local @diagramers/admin installation found'));
|
152
|
-
}
|
28
|
+
version = 'latest';
|
29
|
+
console.log(chalk_1.default.blue(`ℹ️ Using @diagramers/admin@latest (fetches the latest from npm)`));
|
153
30
|
}
|
31
|
+
let command = `npx @diagramers/admin@${version} init ${projectName}`;
|
32
|
+
if (options.framework) {
|
33
|
+
command += ` --framework ${options.framework}`;
|
34
|
+
}
|
35
|
+
if (options.apiUrl) {
|
36
|
+
command += ` --api-url ${options.apiUrl}`;
|
37
|
+
}
|
38
|
+
if (options.port) {
|
39
|
+
command += ` --port ${options.port}`;
|
40
|
+
}
|
41
|
+
if (options.yes) {
|
42
|
+
command += ` --yes`;
|
43
|
+
}
|
44
|
+
console.log(chalk_1.default.gray(`Executing: ${command}`));
|
45
|
+
(0, child_process_1.execSync)(command, { stdio: 'inherit' });
|
46
|
+
console.log(chalk_1.default.green(`✅ Admin application '${projectName}' initialized successfully!`));
|
47
|
+
console.log(chalk_1.default.blue(`📁 Project created at: ${process.cwd()}/${projectName}`));
|
48
|
+
console.log(chalk_1.default.blue(`🚀 To start development: cd ${projectName} && npm start`));
|
154
49
|
}
|
155
50
|
catch (error) {
|
156
|
-
console.error(chalk_1.default.red(`❌
|
157
|
-
process.exit(1);
|
158
|
-
}
|
159
|
-
});
|
160
|
-
// Generate admin module
|
161
|
-
admin
|
162
|
-
.command('generate:module <name>')
|
163
|
-
.description('Generate a new admin module (feature folder/component/page)')
|
164
|
-
.action(async (name) => {
|
165
|
-
try {
|
166
|
-
console.log(chalk_1.default.blue(`🚀 Generating admin module: ${name}`));
|
167
|
-
await generateAdminModule(name);
|
168
|
-
console.log(chalk_1.default.green(`✅ Admin module '${name}' generated successfully!`));
|
169
|
-
}
|
170
|
-
catch (error) {
|
171
|
-
console.error(chalk_1.default.red(`❌ Error generating admin module: ${error.message}`));
|
172
|
-
process.exit(1);
|
173
|
-
}
|
174
|
-
});
|
175
|
-
// Generate admin page
|
176
|
-
admin
|
177
|
-
.command('generate:page <name>')
|
178
|
-
.description('Generate a new page in the admin dashboard')
|
179
|
-
.action(async (name) => {
|
180
|
-
try {
|
181
|
-
console.log(chalk_1.default.blue(`🚀 Generating admin page: ${name}`));
|
182
|
-
await generateAdminPage(name);
|
183
|
-
console.log(chalk_1.default.green(`✅ Admin page '${name}' generated successfully!`));
|
184
|
-
}
|
185
|
-
catch (error) {
|
186
|
-
console.error(chalk_1.default.red(`❌ Error generating admin page: ${error.message}`));
|
187
|
-
process.exit(1);
|
188
|
-
}
|
189
|
-
});
|
190
|
-
// Generate admin component
|
191
|
-
admin
|
192
|
-
.command('generate:component <name>')
|
193
|
-
.description('Generate a new reusable component in the admin project')
|
194
|
-
.action(async (name) => {
|
195
|
-
try {
|
196
|
-
console.log(chalk_1.default.blue(`🚀 Generating admin component: ${name}`));
|
197
|
-
await generateAdminComponent(name);
|
198
|
-
console.log(chalk_1.default.green(`✅ Admin component '${name}' generated successfully!`));
|
199
|
-
}
|
200
|
-
catch (error) {
|
201
|
-
console.error(chalk_1.default.red(`❌ Error generating admin component: ${error.message}`));
|
202
|
-
process.exit(1);
|
203
|
-
}
|
204
|
-
});
|
205
|
-
// Generate admin service
|
206
|
-
admin
|
207
|
-
.command('generate:service <name>')
|
208
|
-
.description('Generate a new service (API integration or business logic) in the admin project')
|
209
|
-
.action(async (name) => {
|
210
|
-
try {
|
211
|
-
console.log(chalk_1.default.blue(`🚀 Generating admin service: ${name}`));
|
212
|
-
await generateAdminService(name);
|
213
|
-
console.log(chalk_1.default.green(`✅ Admin service '${name}' generated successfully!`));
|
214
|
-
}
|
215
|
-
catch (error) {
|
216
|
-
console.error(chalk_1.default.red(`❌ Error generating admin service: ${error.message}`));
|
217
|
-
process.exit(1);
|
218
|
-
}
|
219
|
-
});
|
220
|
-
// Process admin template
|
221
|
-
admin
|
222
|
-
.command('process:template <projectName>')
|
223
|
-
.description('Process the admin template for a new project (branding, API URL, etc.)')
|
224
|
-
.action(async (projectName) => {
|
225
|
-
try {
|
226
|
-
console.log(chalk_1.default.blue(`🔧 Processing admin template for project: ${projectName}`));
|
227
|
-
await processAdminTemplate(projectName);
|
228
|
-
console.log(chalk_1.default.green(`✅ Admin template processed for '${projectName}'!`));
|
229
|
-
}
|
230
|
-
catch (error) {
|
231
|
-
console.error(chalk_1.default.red(`❌ Error processing admin template: ${error.message}`));
|
51
|
+
console.error(chalk_1.default.red(`❌ Failed to initialize admin project: ${error.message}`));
|
232
52
|
process.exit(1);
|
233
53
|
}
|
234
54
|
});
|
235
|
-
//
|
236
|
-
admin
|
237
|
-
.command('init <project-name>')
|
238
|
-
.description('Initialize a new admin application (uses latest @diagramers/admin by default)')
|
239
|
-
.option('-f, --framework <framework>', 'Framework to use (react, vue, angular)', 'react')
|
240
|
-
.option('-a, --api-url <url>', 'API URL for backend integration', 'http://localhost:3000')
|
241
|
-
.option('-p, --port <port>', 'Port number for development server', '3000')
|
242
|
-
.option('-v, --version <version>', 'Specific version to use')
|
243
|
-
.option('-y, --yes', 'Skip prompts and use defaults')
|
244
|
-
.action(async (projectName, options) => {
|
245
|
-
await initAdminProject(projectName, options);
|
246
|
-
});
|
55
|
+
// Add more admin commands here as needed
|
247
56
|
return admin;
|
248
57
|
}
|
249
58
|
//# sourceMappingURL=admin.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../src/commands/admin.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../src/commands/admin.ts"],"names":[],"m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AAC;YAC5C,CAAC;YACD,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;gBACjB,OAAO,IAAI,WAAW,OAAO,CAAC,IAAI,EAAE,CAAC;YACvC,CAAC;YACD,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;gBAChB,OAAO,IAAI,QAAQ,CAAC;YACtB,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,cAAc,OAAO,EAAE,CAAC,CAAC,CAAC;YACjD,IAAA,wBAAQ,EAAC,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;YACxC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,wBAAwB,WAAW,6BAA6B,CAAC,CAAC,CAAC;YAC3F,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,0BAA0B,OAAO,CAAC,GAAG,EAAE,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC;YAClF,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,+BAA+B,WAAW,eAAe,CAAC,CAAC,CAAC;QACrF,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,yCAAyC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACnF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,yCAAyC;IACzC,OAAO,KAAK,CAAC;AACf,CAAC"}
|
@@ -60,7 +60,7 @@ class ProjectInitializer {
|
|
60
60
|
async initialize(projectName, options) {
|
61
61
|
const projectPath = path.resolve(process.cwd(), projectName);
|
62
62
|
const templateType = options.template || 'api';
|
63
|
-
const targetVersion = options.version || (templateType === 'admin' ? '
|
63
|
+
const targetVersion = options.version || (templateType === 'admin' ? 'latest' : 'latest');
|
64
64
|
if (templateType === 'admin') {
|
65
65
|
// Handle admin projects differently - let admin CLI handle directory creation
|
66
66
|
await this.initializeAdminProject(projectPath, projectName, targetVersion, options);
|
@@ -80,8 +80,8 @@ class ProjectInitializer {
|
|
80
80
|
async initializeAdminProject(projectPath, projectName, targetVersion, options) {
|
81
81
|
console.log(chalk_1.default.blue(`🚀 Initializing admin project: ${projectName}`));
|
82
82
|
try {
|
83
|
-
// Use the admin
|
84
|
-
const adminCommand = `
|
83
|
+
// Use the local admin package's bin entry directly
|
84
|
+
const adminCommand = `diagramers-admin-init ${projectName}`;
|
85
85
|
// Add options if provided
|
86
86
|
const commandOptions = [];
|
87
87
|
if (options.yes)
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@diagramers/cli",
|
3
|
-
"version": "
|
3
|
+
"version": "4.0.1",
|
4
4
|
"description": "Diagramers CLI - Command-line tools for managing Diagramers projects",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"bin": {
|
@@ -15,8 +15,7 @@
|
|
15
15
|
"dev": "ts-node src/index.ts",
|
16
16
|
"start": "node dist/index.js",
|
17
17
|
"clean": "rm -rf dist",
|
18
|
-
"test": "echo \"No tests specified\" && exit 0"
|
19
|
-
"publish": "./scripts/publish.sh"
|
18
|
+
"test": "echo \"No tests specified\" && exit 0"
|
20
19
|
},
|
21
20
|
"dependencies": {
|
22
21
|
"@types/js-yaml": "^4.0.9",
|
@@ -26,6 +25,7 @@
|
|
26
25
|
"glob": "^10.3.10",
|
27
26
|
"inquirer": "^9.2.12",
|
28
27
|
"js-yaml": "^4.1.0",
|
28
|
+
"make-error": "^1.3.6",
|
29
29
|
"yaml": "^2.3.4"
|
30
30
|
},
|
31
31
|
"devDependencies": {
|