@diagramers/cli 1.0.8 → 1.0.10
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/dist/services/project-initializer.d.ts +2 -1
- package/dist/services/project-initializer.d.ts.map +1 -1
- package/dist/services/project-initializer.js +43 -6
- package/dist/services/project-initializer.js.map +1 -1
- package/package.json +2 -2
- package/scripts/publish.sh +2 -2
- package/scripts/setup.sh +3 -3
- package/scripts/version.sh +1 -1
- package/src/config/template-config.ts +1 -1
- package/src/index.ts +6 -6
- package/src/services/project-initializer.ts +51 -7
@@ -3,11 +3,12 @@ export interface InitOptions {
|
|
3
3
|
yes?: boolean;
|
4
4
|
}
|
5
5
|
export declare class ProjectInitializer {
|
6
|
-
private templatePath;
|
7
6
|
private templateFiles;
|
8
7
|
constructor();
|
9
8
|
initialize(projectName: string, options: InitOptions): Promise<void>;
|
9
|
+
private installApiPackage;
|
10
10
|
private copyTemplateFiles;
|
11
|
+
private cleanup;
|
11
12
|
private updatePackageJson;
|
12
13
|
private createGitignore;
|
13
14
|
private createReadme;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"project-initializer.d.ts","sourceRoot":"","sources":["../../src/services/project-initializer.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"project-initializer.d.ts","sourceRoot":"","sources":["../../src/services/project-initializer.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,aAAa,CAOnB;;IAMI,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;YAgC5D,iBAAiB;YAcjB,iBAAiB;YAwCjB,OAAO;YAcP,iBAAiB;YAiBjB,eAAe;YAyDf,YAAY;CAoE3B"}
|
@@ -41,6 +41,7 @@ const fs = __importStar(require("fs-extra"));
|
|
41
41
|
const path = __importStar(require("path"));
|
42
42
|
const glob = __importStar(require("glob"));
|
43
43
|
const chalk_1 = __importDefault(require("chalk"));
|
44
|
+
const child_process_1 = require("child_process");
|
44
45
|
class ProjectInitializer {
|
45
46
|
constructor() {
|
46
47
|
this.templateFiles = [
|
@@ -51,8 +52,7 @@ class ProjectInitializer {
|
|
51
52
|
'main.ts',
|
52
53
|
'certs/**/*'
|
53
54
|
];
|
54
|
-
//
|
55
|
-
this.templatePath = path.resolve(__dirname, '../../..');
|
55
|
+
// No need for template path as we'll use npm package
|
56
56
|
}
|
57
57
|
async initialize(projectName, options) {
|
58
58
|
const projectPath = path.resolve(process.cwd(), projectName);
|
@@ -62,7 +62,9 @@ class ProjectInitializer {
|
|
62
62
|
}
|
63
63
|
// Create project directory
|
64
64
|
await fs.ensureDir(projectPath);
|
65
|
-
//
|
65
|
+
// Install the @diagramers/api package
|
66
|
+
await this.installApiPackage(projectPath);
|
67
|
+
// Copy template files from the installed package
|
66
68
|
await this.copyTemplateFiles(projectPath);
|
67
69
|
// Update package.json with project name
|
68
70
|
await this.updatePackageJson(projectPath, projectName);
|
@@ -70,18 +72,37 @@ class ProjectInitializer {
|
|
70
72
|
await this.createGitignore(projectPath);
|
71
73
|
// Create README
|
72
74
|
await this.createReadme(projectPath, projectName);
|
75
|
+
// Clean up the temporary installation
|
76
|
+
await this.cleanup(projectPath);
|
73
77
|
console.log(chalk_1.default.green(`✅ Project structure created successfully`));
|
74
78
|
}
|
79
|
+
async installApiPackage(projectPath) {
|
80
|
+
console.log(chalk_1.default.blue('📦 Installing @diagramers/api template...'));
|
81
|
+
try {
|
82
|
+
// Install the API package temporarily
|
83
|
+
(0, child_process_1.execSync)('npm install @diagramers/api --no-save', {
|
84
|
+
cwd: projectPath,
|
85
|
+
stdio: 'inherit'
|
86
|
+
});
|
87
|
+
}
|
88
|
+
catch (error) {
|
89
|
+
throw new Error(`Failed to install @diagramers/api package: ${error.message}`);
|
90
|
+
}
|
91
|
+
}
|
75
92
|
async copyTemplateFiles(projectPath) {
|
93
|
+
const nodeModulesPath = path.join(projectPath, 'node_modules', '@diagramers', 'api');
|
94
|
+
if (!await fs.pathExists(nodeModulesPath)) {
|
95
|
+
throw new Error('@diagramers/api package not found in node_modules');
|
96
|
+
}
|
76
97
|
for (const pattern of this.templateFiles) {
|
77
98
|
try {
|
78
99
|
const files = glob.sync(pattern, {
|
79
|
-
cwd:
|
80
|
-
ignore: ['node_modules/**', 'dist/**', '
|
100
|
+
cwd: nodeModulesPath,
|
101
|
+
ignore: ['node_modules/**', 'dist/**', '.git/**'],
|
81
102
|
nodir: false
|
82
103
|
});
|
83
104
|
for (const file of files) {
|
84
|
-
const sourcePath = path.join(
|
105
|
+
const sourcePath = path.join(nodeModulesPath, file);
|
85
106
|
const destPath = path.join(projectPath, file);
|
86
107
|
if (await fs.pathExists(sourcePath)) {
|
87
108
|
const stat = await fs.stat(sourcePath);
|
@@ -104,12 +125,28 @@ class ProjectInitializer {
|
|
104
125
|
}
|
105
126
|
}
|
106
127
|
}
|
128
|
+
async cleanup(projectPath) {
|
129
|
+
// Remove the temporary node_modules
|
130
|
+
const nodeModulesPath = path.join(projectPath, 'node_modules');
|
131
|
+
if (await fs.pathExists(nodeModulesPath)) {
|
132
|
+
await fs.remove(nodeModulesPath);
|
133
|
+
}
|
134
|
+
// Remove package-lock.json if it exists
|
135
|
+
const packageLockPath = path.join(projectPath, 'package-lock.json');
|
136
|
+
if (await fs.pathExists(packageLockPath)) {
|
137
|
+
await fs.remove(packageLockPath);
|
138
|
+
}
|
139
|
+
}
|
107
140
|
async updatePackageJson(projectPath, projectName) {
|
108
141
|
const packageJsonPath = path.join(projectPath, 'package.json');
|
109
142
|
if (await fs.pathExists(packageJsonPath)) {
|
110
143
|
const packageJson = await fs.readJson(packageJsonPath);
|
111
144
|
packageJson.name = projectName;
|
112
145
|
packageJson.description = `API project: ${projectName}`;
|
146
|
+
// Remove the bin field if it exists (this is for CLI packages)
|
147
|
+
if (packageJson.bin) {
|
148
|
+
delete packageJson.bin;
|
149
|
+
}
|
113
150
|
await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
|
114
151
|
}
|
115
152
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"project-initializer.js","sourceRoot":"","sources":["../../src/services/project-initializer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAC/B,2CAA6B;AAC7B,2CAA6B;AAC7B,kDAA0B;
|
1
|
+
{"version":3,"file":"project-initializer.js","sourceRoot":"","sources":["../../src/services/project-initializer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAC/B,2CAA6B;AAC7B,2CAA6B;AAC7B,kDAA0B;AAC1B,iDAAyC;AAOzC,MAAa,kBAAkB;IAU7B;QATQ,kBAAa,GAAa;YAChC,UAAU;YACV,cAAc;YACd,eAAe;YACf,mBAAmB;YACnB,SAAS;YACT,YAAY;SACb,CAAC;QAGA,qDAAqD;IACvD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,WAAmB,EAAE,OAAoB;QACxD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,WAAW,CAAC,CAAC;QAE7D,4CAA4C;QAC5C,IAAI,MAAM,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,qBAAqB,WAAW,iBAAiB,CAAC,CAAC;QACrE,CAAC;QAED,2BAA2B;QAC3B,MAAM,EAAE,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAEhC,sCAAsC;QACtC,MAAM,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;QAE1C,iDAAiD;QACjD,MAAM,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;QAE1C,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AC7E,CAAC;IAEO,KAAK,CAAC,YAAY,CAAC,WAAmB,EAAE,WAAmB;QACjE,MAAM,aAAa,GAAG,KAAK,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+DzC,CAAC;QAEE,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,EAAE,aAAa,CAAC,CAAC;IACzE,CAAC;CACF;AAhQD,gDAgQC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@diagramers/cli",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.10",
|
4
4
|
"description": "Diagramers CLI - Command-line tools for managing Diagramers projects",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"bin": {
|
@@ -31,7 +31,7 @@
|
|
31
31
|
"ts-node": "^10.9.2"
|
32
32
|
},
|
33
33
|
"keywords": [
|
34
|
-
"
|
34
|
+
"diagramers",
|
35
35
|
"cli",
|
36
36
|
"command-line",
|
37
37
|
"templates",
|
package/scripts/publish.sh
CHANGED
package/scripts/setup.sh
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/bin/bash
|
2
2
|
|
3
|
-
#
|
4
|
-
echo "🚀 Setting up
|
3
|
+
# diagramers API Template Setup Script
|
4
|
+
echo "🚀 Setting up diagramers API Template..."
|
5
5
|
|
6
6
|
# Check if Node.js is installed
|
7
7
|
if ! command -v node &> /dev/null; then
|
@@ -32,7 +32,7 @@ cd ..
|
|
32
32
|
echo "✅ Setup complete!"
|
33
33
|
echo ""
|
34
34
|
echo "🎉 You can now use the CLI to create new projects:"
|
35
|
-
echo "
|
35
|
+
echo " diagramers-api init my-new-project"
|
36
36
|
echo ""
|
37
37
|
echo "📚 For more information, see the README.md file"
|
38
38
|
echo "🔧 To start development: npm run serve"
|
package/scripts/version.sh
CHANGED
@@ -19,7 +19,7 @@ export interface TemplateConfig {
|
|
19
19
|
}
|
20
20
|
|
21
21
|
export const templateConfig: TemplateConfig = {
|
22
|
-
name: '
|
22
|
+
name: 'diagramers-api-template',
|
23
23
|
version: '1.0.0',
|
24
24
|
description: 'Node.js API template with TypeScript, Firebase Functions, and Socket.io',
|
25
25
|
|
package/src/index.ts
CHANGED
@@ -9,8 +9,8 @@ import chalk from 'chalk';
|
|
9
9
|
const program = new Command();
|
10
10
|
|
11
11
|
program
|
12
|
-
.name('
|
13
|
-
.description('CLI tool for managing
|
12
|
+
.name('diagramers')
|
13
|
+
.description('CLI tool for managing diagramers projects')
|
14
14
|
.version('1.0.0');
|
15
15
|
|
16
16
|
// Add commands
|
@@ -21,10 +21,10 @@ extendCommand(program);
|
|
21
21
|
// Add help text
|
22
22
|
program.addHelpText('after', `
|
23
23
|
Examples:
|
24
|
-
$
|
25
|
-
$
|
26
|
-
$
|
27
|
-
$
|
24
|
+
$ diagramers init api my-new-project
|
25
|
+
$ diagramers init admin my-admin-dashboard
|
26
|
+
$ diagramers update
|
27
|
+
$ diagramers extend --feature auth
|
28
28
|
`);
|
29
29
|
|
30
30
|
program.parse();
|
@@ -2,6 +2,7 @@ import * as fs from 'fs-extra';
|
|
2
2
|
import * as path from 'path';
|
3
3
|
import * as glob from 'glob';
|
4
4
|
import chalk from 'chalk';
|
5
|
+
import { execSync } from 'child_process';
|
5
6
|
|
6
7
|
export interface InitOptions {
|
7
8
|
template?: string;
|
@@ -9,7 +10,6 @@ export interface InitOptions {
|
|
9
10
|
}
|
10
11
|
|
11
12
|
export class ProjectInitializer {
|
12
|
-
private templatePath: string;
|
13
13
|
private templateFiles: string[] = [
|
14
14
|
'src/**/*',
|
15
15
|
'package.json',
|
@@ -20,8 +20,7 @@ export class ProjectInitializer {
|
|
20
20
|
];
|
21
21
|
|
22
22
|
constructor() {
|
23
|
-
//
|
24
|
-
this.templatePath = path.resolve(__dirname, '../../..');
|
23
|
+
// No need for template path as we'll use npm package
|
25
24
|
}
|
26
25
|
|
27
26
|
async initialize(projectName: string, options: InitOptions): Promise<void> {
|
@@ -35,7 +34,10 @@ export class ProjectInitializer {
|
|
35
34
|
// Create project directory
|
36
35
|
await fs.ensureDir(projectPath);
|
37
36
|
|
38
|
-
//
|
37
|
+
// Install the @diagramers/api package
|
38
|
+
await this.installApiPackage(projectPath);
|
39
|
+
|
40
|
+
// Copy template files from the installed package
|
39
41
|
await this.copyTemplateFiles(projectPath);
|
40
42
|
|
41
43
|
// Update package.json with project name
|
@@ -47,20 +49,43 @@ export class ProjectInitializer {
|
|
47
49
|
// Create README
|
48
50
|
await this.createReadme(projectPath, projectName);
|
49
51
|
|
52
|
+
// Clean up the temporary installation
|
53
|
+
await this.cleanup(projectPath);
|
54
|
+
|
50
55
|
console.log(chalk.green(`✅ Project structure created successfully`));
|
51
56
|
}
|
52
57
|
|
58
|
+
private async installApiPackage(projectPath: string): Promise<void> {
|
59
|
+
console.log(chalk.blue('📦 Installing @diagramers/api template...'));
|
60
|
+
|
61
|
+
try {
|
62
|
+
// Install the API package temporarily
|
63
|
+
execSync('npm install @diagramers/api --no-save', {
|
64
|
+
cwd: projectPath,
|
65
|
+
stdio: 'inherit'
|
66
|
+
});
|
67
|
+
} catch (error: any) {
|
68
|
+
throw new Error(`Failed to install @diagramers/api package: ${error.message}`);
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
53
72
|
private async copyTemplateFiles(projectPath: string): Promise<void> {
|
73
|
+
const nodeModulesPath = path.join(projectPath, 'node_modules', '@diagramers', 'api');
|
74
|
+
|
75
|
+
if (!await fs.pathExists(nodeModulesPath)) {
|
76
|
+
throw new Error('@diagramers/api package not found in node_modules');
|
77
|
+
}
|
78
|
+
|
54
79
|
for (const pattern of this.templateFiles) {
|
55
80
|
try {
|
56
81
|
const files = glob.sync(pattern, {
|
57
|
-
cwd:
|
58
|
-
ignore: ['node_modules/**', 'dist/**', '
|
82
|
+
cwd: nodeModulesPath,
|
83
|
+
ignore: ['node_modules/**', 'dist/**', '.git/**'],
|
59
84
|
nodir: false
|
60
85
|
});
|
61
86
|
|
62
87
|
for (const file of files) {
|
63
|
-
const sourcePath = path.join(
|
88
|
+
const sourcePath = path.join(nodeModulesPath, file);
|
64
89
|
const destPath = path.join(projectPath, file);
|
65
90
|
|
66
91
|
if (await fs.pathExists(sourcePath)) {
|
@@ -84,6 +109,20 @@ export class ProjectInitializer {
|
|
84
109
|
}
|
85
110
|
}
|
86
111
|
|
112
|
+
private async cleanup(projectPath: string): Promise<void> {
|
113
|
+
// Remove the temporary node_modules
|
114
|
+
const nodeModulesPath = path.join(projectPath, 'node_modules');
|
115
|
+
if (await fs.pathExists(nodeModulesPath)) {
|
116
|
+
await fs.remove(nodeModulesPath);
|
117
|
+
}
|
118
|
+
|
119
|
+
// Remove package-lock.json if it exists
|
120
|
+
const packageLockPath = path.join(projectPath, 'package-lock.json');
|
121
|
+
if (await fs.pathExists(packageLockPath)) {
|
122
|
+
await fs.remove(packageLockPath);
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
87
126
|
private async updatePackageJson(projectPath: string, projectName: string): Promise<void> {
|
88
127
|
const packageJsonPath = path.join(projectPath, 'package.json');
|
89
128
|
|
@@ -92,6 +131,11 @@ export class ProjectInitializer {
|
|
92
131
|
packageJson.name = projectName;
|
93
132
|
packageJson.description = `API project: ${projectName}`;
|
94
133
|
|
134
|
+
// Remove the bin field if it exists (this is for CLI packages)
|
135
|
+
if (packageJson.bin) {
|
136
|
+
delete packageJson.bin;
|
137
|
+
}
|
138
|
+
|
95
139
|
await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
|
96
140
|
}
|
97
141
|
}
|