@diagramers/cli 1.0.6

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.
Files changed (46) hide show
  1. package/README.md +91 -0
  2. package/dist/commands/extend.d.ts +3 -0
  3. package/dist/commands/extend.d.ts.map +1 -0
  4. package/dist/commands/extend.js +37 -0
  5. package/dist/commands/extend.js.map +1 -0
  6. package/dist/commands/init.d.ts +3 -0
  7. package/dist/commands/init.d.ts.map +1 -0
  8. package/dist/commands/init.js +31 -0
  9. package/dist/commands/init.js.map +1 -0
  10. package/dist/commands/update.d.ts +3 -0
  11. package/dist/commands/update.d.ts.map +1 -0
  12. package/dist/commands/update.js +29 -0
  13. package/dist/commands/update.js.map +1 -0
  14. package/dist/config/template-config.d.ts +21 -0
  15. package/dist/config/template-config.d.ts.map +1 -0
  16. package/dist/config/template-config.js +93 -0
  17. package/dist/config/template-config.js.map +1 -0
  18. package/dist/index.d.ts +3 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +30 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/services/project-extender.d.ts +15 -0
  23. package/dist/services/project-extender.d.ts.map +1 -0
  24. package/dist/services/project-extender.js +207 -0
  25. package/dist/services/project-extender.js.map +1 -0
  26. package/dist/services/project-initializer.d.ts +15 -0
  27. package/dist/services/project-initializer.d.ts.map +1 -0
  28. package/dist/services/project-initializer.js +240 -0
  29. package/dist/services/project-initializer.js.map +1 -0
  30. package/dist/services/project-updater.d.ts +16 -0
  31. package/dist/services/project-updater.d.ts.map +1 -0
  32. package/dist/services/project-updater.js +134 -0
  33. package/dist/services/project-updater.js.map +1 -0
  34. package/package.json +51 -0
  35. package/scripts/publish.sh +58 -0
  36. package/scripts/setup.sh +38 -0
  37. package/scripts/version.sh +80 -0
  38. package/src/commands/extend.ts +35 -0
  39. package/src/commands/init.ts +27 -0
  40. package/src/commands/update.ts +25 -0
  41. package/src/config/template-config.ts +111 -0
  42. package/src/index.ts +35 -0
  43. package/src/services/project-extender.ts +196 -0
  44. package/src/services/project-initializer.ts +224 -0
  45. package/src/services/project-updater.ts +125 -0
  46. package/tsconfig.json +19 -0
@@ -0,0 +1,240 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.ProjectInitializer = void 0;
40
+ const fs = __importStar(require("fs-extra"));
41
+ const path = __importStar(require("path"));
42
+ const glob = __importStar(require("glob"));
43
+ const chalk_1 = __importDefault(require("chalk"));
44
+ class ProjectInitializer {
45
+ constructor() {
46
+ this.templateFiles = [
47
+ 'src/**/*',
48
+ 'package.json',
49
+ 'tsconfig.json',
50
+ 'webpack.config.js',
51
+ 'main.ts',
52
+ 'certs/**/*'
53
+ ];
54
+ // Get the path to the template (parent directory of CLI)
55
+ this.templatePath = path.resolve(__dirname, '../../..');
56
+ }
57
+ async initialize(projectName, options) {
58
+ const projectPath = path.resolve(process.cwd(), projectName);
59
+ // Check if project directory already exists
60
+ if (await fs.pathExists(projectPath)) {
61
+ throw new Error(`Project directory ${projectName} already exists`);
62
+ }
63
+ // Create project directory
64
+ await fs.ensureDir(projectPath);
65
+ // Copy template files
66
+ await this.copyTemplateFiles(projectPath);
67
+ // Update package.json with project name
68
+ await this.updatePackageJson(projectPath, projectName);
69
+ // Create .gitignore
70
+ await this.createGitignore(projectPath);
71
+ // Create README
72
+ await this.createReadme(projectPath, projectName);
73
+ console.log(chalk_1.default.green(`✅ Project structure created successfully`));
74
+ }
75
+ async copyTemplateFiles(projectPath) {
76
+ for (const pattern of this.templateFiles) {
77
+ try {
78
+ const files = glob.sync(pattern, {
79
+ cwd: this.templatePath,
80
+ ignore: ['node_modules/**', 'dist/**', 'cli/**', '.git/**'],
81
+ nodir: false
82
+ });
83
+ for (const file of files) {
84
+ const sourcePath = path.join(this.templatePath, file);
85
+ const destPath = path.join(projectPath, file);
86
+ if (await fs.pathExists(sourcePath)) {
87
+ const stat = await fs.stat(sourcePath);
88
+ if (stat.isDirectory()) {
89
+ // Copy directory
90
+ await fs.ensureDir(destPath);
91
+ await fs.copy(sourcePath, destPath);
92
+ }
93
+ else {
94
+ // Copy file
95
+ await fs.ensureDir(path.dirname(destPath));
96
+ await fs.copy(sourcePath, destPath);
97
+ }
98
+ }
99
+ }
100
+ }
101
+ catch (error) {
102
+ // Log warning but continue with other files
103
+ console.log(chalk_1.default.yellow(`⚠️ Warning: Could not copy pattern '${pattern}': ${error.message}`));
104
+ }
105
+ }
106
+ }
107
+ async updatePackageJson(projectPath, projectName) {
108
+ const packageJsonPath = path.join(projectPath, 'package.json');
109
+ if (await fs.pathExists(packageJsonPath)) {
110
+ const packageJson = await fs.readJson(packageJsonPath);
111
+ packageJson.name = projectName;
112
+ packageJson.description = `API project: ${projectName}`;
113
+ await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
114
+ }
115
+ }
116
+ async createGitignore(projectPath) {
117
+ const gitignoreContent = `
118
+ # Dependencies
119
+ node_modules/
120
+ npm-debug.log*
121
+ yarn-debug.log*
122
+ yarn-error.log*
123
+
124
+ # Build outputs
125
+ dist/
126
+ build/
127
+ *.tsbuildinfo
128
+
129
+ # Environment variables
130
+ .env
131
+ .env.local
132
+ .env.development.local
133
+ .env.test.local
134
+ .env.production.local
135
+
136
+ # IDE
137
+ .vscode/
138
+ .idea/
139
+ *.swp
140
+ *.swo
141
+
142
+ # OS
143
+ .DS_Store
144
+ Thumbs.db
145
+
146
+ # Logs
147
+ logs
148
+ *.log
149
+
150
+ # Runtime data
151
+ pids
152
+ *.pid
153
+ *.seed
154
+ *.pid.lock
155
+
156
+ # Coverage directory used by tools like istanbul
157
+ coverage/
158
+
159
+ # Firebase
160
+ .firebase/
161
+ firebase-debug.log
162
+ firestore-debug.log
163
+ ui-debug.log
164
+
165
+ # Temporary folders
166
+ tmp/
167
+ temp/
168
+ `.trim();
169
+ await fs.writeFile(path.join(projectPath, '.gitignore'), gitignoreContent);
170
+ }
171
+ async createReadme(projectPath, projectName) {
172
+ const readmeContent = `# ${projectName}
173
+
174
+ A Node.js API project built with TypeScript and Firebase Functions.
175
+
176
+ ## Features
177
+
178
+ - Express.js server with TypeScript
179
+ - Firebase Functions integration
180
+ - Socket.io for real-time communication
181
+ - MongoDB with Mongoose
182
+ - Authentication system
183
+ - Email notifications
184
+ - Cron jobs
185
+ - Audit logging
186
+
187
+ ## Getting Started
188
+
189
+ 1. Install dependencies:
190
+ \`\`\`bash
191
+ npm install
192
+ \`\`\`
193
+
194
+ 2. Set up environment variables:
195
+ - Copy \`.env.example\` to \`.env\`
196
+ - Update the values according to your configuration
197
+
198
+ 3. Start development server:
199
+ \`\`\`bash
200
+ npm run serve
201
+ \`\`\`
202
+
203
+ ## Available Scripts
204
+
205
+ - \`npm run serve\` - Start development server
206
+ - \`npm run build:dev\` - Build for development
207
+ - \`npm run build:prod\` - Build for production
208
+ - \`npm run deploy\` - Deploy to Firebase
209
+
210
+ ## Project Structure
211
+
212
+ \`\`\`
213
+ src/
214
+ ├── config/ # Configuration files
215
+ ├── controllers/ # Route controllers
216
+ ├── entities/ # Database entities
217
+ ├── helpers/ # Utility functions
218
+ ├── routes/ # API routes
219
+ ├── schemas/ # Validation schemas
220
+ ├── server/ # Server setup
221
+ └── services/ # Business logic
222
+ \`\`\`
223
+
224
+ ## Contributing
225
+
226
+ 1. Fork the repository
227
+ 2. Create a feature branch
228
+ 3. Make your changes
229
+ 4. Test thoroughly
230
+ 5. Submit a pull request
231
+
232
+ ## License
233
+
234
+ MIT
235
+ `;
236
+ await fs.writeFile(path.join(projectPath, 'README.md'), readmeContent);
237
+ }
238
+ }
239
+ exports.ProjectInitializer = ProjectInitializer;
240
+ //# sourceMappingURL=project-initializer.js.map
@@ -0,0 +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;AAO1B,MAAa,kBAAkB;IAW7B;QATQ,kBAAa,GAAa;YAChC,UAAU;YACV,cAAc;YACd,eAAe;YACf,mBAAmB;YACnB,SAAS;YACT,YAAY;SACb,CAAC;QAGA,yDAAyD;QACzD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,WAAmB,EAAE,OAAoB;QACxD,MAAM,WAAW,GAAG,IAAI,CAAC,O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M,EAAE,CAAC,EAAE,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,eAAe,CAAC,WAAmB;QAC/C,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmD5B,CAAC,IAAI,EAAE,CAAC;QAEL,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,EAAE,gBAAgB,CAAC,CAAC;IAC7E,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;AArND,gDAqNC"}
@@ -0,0 +1,16 @@
1
+ export interface UpdateOptions {
2
+ force?: boolean;
3
+ backup?: boolean;
4
+ }
5
+ export declare class ProjectUpdater {
6
+ private templatePath;
7
+ private currentProjectPath;
8
+ constructor();
9
+ update(options: UpdateOptions): Promise<void>;
10
+ private isValidProject;
11
+ private createBackup;
12
+ private getUpdateableFiles;
13
+ private checkConflicts;
14
+ private performUpdate;
15
+ }
16
+ //# sourceMappingURL=project-updater.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-updater.d.ts","sourceRoot":"","sources":["../../src/services/project-updater.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,kBAAkB,CAAS;;IAO7B,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;YA8BrC,cAAc;YAOd,YAAY;YAgBZ,kBAAkB;YAmBlB,cAAc;YAqBd,aAAa;CAY5B"}
@@ -0,0 +1,134 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.ProjectUpdater = void 0;
40
+ const fs = __importStar(require("fs-extra"));
41
+ const path = __importStar(require("path"));
42
+ const glob = __importStar(require("glob"));
43
+ const chalk_1 = __importDefault(require("chalk"));
44
+ class ProjectUpdater {
45
+ constructor() {
46
+ this.templatePath = path.resolve(__dirname, '../../..');
47
+ this.currentProjectPath = process.cwd();
48
+ }
49
+ async update(options) {
50
+ // Check if we're in a valid project directory
51
+ if (!await this.isValidProject()) {
52
+ throw new Error('Not a valid project directory. Please run this command from your project root.');
53
+ }
54
+ // Create backup if requested
55
+ if (options.backup) {
56
+ await this.createBackup();
57
+ }
58
+ // Get list of files that can be updated
59
+ const updateableFiles = await this.getUpdateableFiles();
60
+ // Check for conflicts
61
+ const conflicts = await this.checkConflicts(updateableFiles);
62
+ if (conflicts.length > 0 && !options.force) {
63
+ console.log(chalk_1.default.yellow('⚠️ Conflicts detected in the following files:'));
64
+ conflicts.forEach(file => console.log(chalk_1.default.yellow(` - ${file}`)));
65
+ console.log(chalk_1.default.yellow('Use --force to overwrite these files'));
66
+ throw new Error('Update aborted due to conflicts');
67
+ }
68
+ // Perform the update
69
+ await this.performUpdate(updateableFiles);
70
+ console.log(chalk_1.default.green('✅ Project updated successfully!'));
71
+ }
72
+ async isValidProject() {
73
+ const packageJsonPath = path.join(this.currentProjectPath, 'package.json');
74
+ const mainTsPath = path.join(this.currentProjectPath, 'main.ts');
75
+ return await fs.pathExists(packageJsonPath) && await fs.pathExists(mainTsPath);
76
+ }
77
+ async createBackup() {
78
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
79
+ const backupPath = path.join(this.currentProjectPath, `backup-${timestamp}`);
80
+ await fs.copy(this.currentProjectPath, backupPath, {
81
+ filter: (src) => {
82
+ const relativePath = path.relative(this.currentProjectPath, src);
83
+ return !relativePath.startsWith('node_modules') &&
84
+ !relativePath.startsWith('.git') &&
85
+ !relativePath.startsWith('backup-');
86
+ }
87
+ });
88
+ console.log(chalk_1.default.blue(`📦 Backup created at: ${backupPath}`));
89
+ }
90
+ async getUpdateableFiles() {
91
+ const templateFiles = [
92
+ 'src/helpers/**/*',
93
+ 'src/config/**/*',
94
+ 'src/server/**/*',
95
+ 'webpack.config.js',
96
+ 'tsconfig.json'
97
+ ];
98
+ const files = [];
99
+ for (const pattern of templateFiles) {
100
+ const matches = glob.sync(pattern, { cwd: this.templatePath });
101
+ files.push(...matches);
102
+ }
103
+ return files;
104
+ }
105
+ async checkConflicts(files) {
106
+ const conflicts = [];
107
+ for (const file of files) {
108
+ const templatePath = path.join(this.templatePath, file);
109
+ const projectPath = path.join(this.currentProjectPath, file);
110
+ if (await fs.pathExists(projectPath)) {
111
+ const templateContent = await fs.readFile(templatePath, 'utf8');
112
+ const projectContent = await fs.readFile(projectPath, 'utf8');
113
+ // Simple conflict detection - if files are different
114
+ if (templateContent !== projectContent) {
115
+ conflicts.push(file);
116
+ }
117
+ }
118
+ }
119
+ return conflicts;
120
+ }
121
+ async performUpdate(files) {
122
+ for (const file of files) {
123
+ const templatePath = path.join(this.templatePath, file);
124
+ const projectPath = path.join(this.currentProjectPath, file);
125
+ if (await fs.pathExists(templatePath)) {
126
+ await fs.ensureDir(path.dirname(projectPath));
127
+ await fs.copy(templatePath, projectPath);
128
+ console.log(chalk_1.default.green(`✅ Updated: ${file}`));
129
+ }
130
+ }
131
+ }
132
+ }
133
+ exports.ProjectUpdater = ProjectUpdater;
134
+ //# sourceMappingURL=project-updater.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-updater.js","sourceRoot":"","sources":["../../src/services/project-updater.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAC/B,2CAA6B;AAC7B,2CAA6B;AAC7B,kDAA0B;AAO1B,MAAa,cAAc;IAIzB;QACE,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACxD,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAsB;QACjC,8CAA8C;QAC9C,IAAI,CAAC,MAAM,IAAI,CAA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CAAC,CAAC;gBACzC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAlHD,wCAkHC"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@diagramers/cli",
3
+ "version": "1.0.6",
4
+ "description": "Diagramers CLI - Command-line tools for managing Diagramers projects",
5
+ "main": "dist/index.js",
6
+ "bin": {
7
+ "diagramers": "./dist/index.js"
8
+ },
9
+ "scripts": {
10
+ "build": "tsc",
11
+ "dev": "ts-node src/index.ts",
12
+ "start": "node dist/index.js",
13
+ "clean": "rm -rf dist",
14
+ "test": "echo \"No tests specified\" && exit 0",
15
+ "publish": "./scripts/publish.sh"
16
+ },
17
+ "dependencies": {
18
+ "commander": "^11.1.0",
19
+ "inquirer": "^9.2.12",
20
+ "chalk": "^4.1.2",
21
+ "fs-extra": "^11.2.0",
22
+ "glob": "^10.3.10",
23
+ "yaml": "^2.3.4"
24
+ },
25
+ "devDependencies": {
26
+ "@types/inquirer": "^9.0.7",
27
+ "@types/fs-extra": "^11.0.4",
28
+ "@types/glob": "^8.1.0",
29
+ "@types/node": "^20.10.0",
30
+ "typescript": "^5.4.5",
31
+ "ts-node": "^10.9.2"
32
+ },
33
+ "keywords": [
34
+ "diagrammers",
35
+ "cli",
36
+ "command-line",
37
+ "templates",
38
+ "nodejs",
39
+ "typescript"
40
+ ],
41
+ "author": "Diagramers Team",
42
+ "license": "MIT",
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/diagramers/diagramers-cli.git"
46
+ },
47
+ "bugs": {
48
+ "url": "https://github.com/diagramers/diagramers-cli/issues"
49
+ },
50
+ "homepage": "https://github.com/diagramers/diagramers-cli#readme"
51
+ }
@@ -0,0 +1,58 @@
1
+ #!/bin/bash
2
+
3
+ # Diagrammers CLI Publishing Script
4
+ echo "🚀 Publishing Diagrammers CLI..."
5
+
6
+ # Check if user is logged into npm
7
+ if ! npm whoami &> /dev/null; then
8
+ echo "❌ You need to be logged into npm. Run: npm login"
9
+ exit 1
10
+ fi
11
+
12
+ # Build the project first
13
+ echo "🔧 Building CLI..."
14
+ npm run build
15
+
16
+ # Make sure the CLI binary is executable
17
+ chmod +x dist/index.js
18
+
19
+ # Check if package.json is properly configured
20
+ if ! grep -q '"name": "@diagramers/cli"' package.json; then
21
+ echo "❌ Package name not set correctly in package.json"
22
+ exit 1
23
+ fi
24
+
25
+ # Check if version is set
26
+ if ! grep -q '"version":' package.json; then
27
+ echo "❌ Version not set in package.json"
28
+ exit 1
29
+ fi
30
+
31
+ # Show what will be published
32
+ echo "📦 Files that will be published:"
33
+ npm pack --dry-run
34
+
35
+ echo ""
36
+ echo "⚠️ Review the files above. Continue with publishing? (y/N)"
37
+ read -r response
38
+
39
+ if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]; then
40
+ echo "🚀 Publishing to npm..."
41
+ npm publish --access public
42
+
43
+ if [ $? -eq 0 ]; then
44
+ echo "✅ Successfully published to npm!"
45
+ echo ""
46
+ echo "🎉 Users can now install your CLI tool with:"
47
+ echo " npm install -g @diagramers/cli"
48
+ echo ""
49
+ echo "📚 Or use it directly:"
50
+ echo " npx @diagramers/cli init api my-project"
51
+ else
52
+ echo "❌ Failed to publish to npm"
53
+ exit 1
54
+ fi
55
+ else
56
+ echo "❌ Publishing cancelled"
57
+ exit 1
58
+ fi
@@ -0,0 +1,38 @@
1
+ #!/bin/bash
2
+
3
+ # Diagrammers API Template Setup Script
4
+ echo "🚀 Setting up Diagrammers API Template..."
5
+
6
+ # Check if Node.js is installed
7
+ if ! command -v node &> /dev/null; then
8
+ echo "❌ Node.js is not installed. Please install Node.js first."
9
+ exit 1
10
+ fi
11
+
12
+ # Check if npm is installed
13
+ if ! command -v npm &> /dev/null; then
14
+ echo "❌ npm is not installed. Please install npm first."
15
+ exit 1
16
+ fi
17
+
18
+ echo "✅ Node.js and npm are installed"
19
+
20
+ # Install dependencies for the main template
21
+ echo "📦 Installing template dependencies..."
22
+ npm install
23
+
24
+ # Build and setup CLI
25
+ echo "🔧 Setting up CLI tool..."
26
+ cd cli
27
+ npm install
28
+ npm run build
29
+ npm link
30
+ cd ..
31
+
32
+ echo "✅ Setup complete!"
33
+ echo ""
34
+ echo "🎉 You can now use the CLI to create new projects:"
35
+ echo " diagrammers-api init my-new-project"
36
+ echo ""
37
+ echo "📚 For more information, see the README.md file"
38
+ echo "🔧 To start development: npm run serve"
@@ -0,0 +1,80 @@
1
+ #!/bin/bash
2
+
3
+ # Version Management Script for Diagrammers API Template
4
+
5
+ # Function to update version in package.json
6
+ update_version() {
7
+ local new_version=$1
8
+ local file=$2
9
+
10
+ if [[ "$OSTYPE" == "darwin"* ]]; then
11
+ # macOS
12
+ sed -i '' "s/\"version\": \"[^\"]*\"/\"version\": \"$new_version\"/" "$file"
13
+ else
14
+ # Linux
15
+ sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"$new_version\"/" "$file"
16
+ fi
17
+ }
18
+
19
+ # Function to show current version
20
+ show_version() {
21
+ echo "📦 Current versions:"
22
+ echo "Main package: $(grep '"version"' package.json | head -1 | sed 's/.*"version": "\([^"]*\)".*/\1/')"
23
+ echo "CLI package: $(grep '"version"' cli/package.json | head -1 | sed 's/.*"version": "\([^"]*\)".*/\1/')"
24
+ }
25
+
26
+ # Function to update both versions
27
+ update_both_versions() {
28
+ local new_version=$1
29
+ echo "🔄 Updating version to $new_version..."
30
+
31
+ update_version "$new_version" "package.json"
32
+ update_version "$new_version" "cli/package.json"
33
+
34
+ echo "✅ Versions updated successfully!"
35
+ show_version
36
+ }
37
+
38
+ # Main script logic
39
+ case "$1" in
40
+ "show")
41
+ show_version
42
+ ;;
43
+ "patch")
44
+ current_version=$(grep '"version"' package.json | head -1 | sed 's/.*"version": "\([^"]*\)".*/\1/')
45
+ new_version=$(echo "$current_version" | awk -F. '{print $1"."$2"."$3+1}')
46
+ update_both_versions "$new_version"
47
+ ;;
48
+ "minor")
49
+ current_version=$(grep '"version"' package.json | head -1 | sed 's/.*"version": "\([^"]*\)".*/\1/')
50
+ new_version=$(echo "$current_version" | awk -F. '{print $1"."$2+1".0"}')
51
+ update_both_versions "$new_version"
52
+ ;;
53
+ "major")
54
+ current_version=$(grep '"version"' package.json | head -1 | sed 's/.*"version": "\([^"]*\)".*/\1/')
55
+ new_version=$(echo "$current_version" | awk -F. '{print $1+1".0.0"}')
56
+ update_both_versions "$new_version"
57
+ ;;
58
+ "set")
59
+ if [ -z "$2" ]; then
60
+ echo "❌ Please provide a version number"
61
+ echo "Usage: ./version.sh set 1.2.3"
62
+ exit 1
63
+ fi
64
+ update_both_versions "$2"
65
+ ;;
66
+ *)
67
+ echo "📋 Version Management Script"
68
+ echo ""
69
+ echo "Usage:"
70
+ echo " ./version.sh show - Show current versions"
71
+ echo " ./version.sh patch - Increment patch version (1.0.0 -> 1.0.1)"
72
+ echo " ./version.sh minor - Increment minor version (1.0.0 -> 1.1.0)"
73
+ echo " ./version.sh major - Increment major version (1.0.0 -> 2.0.0)"
74
+ echo " ./version.sh set <version> - Set specific version (e.g., 1.2.3)"
75
+ echo ""
76
+ echo "Examples:"
77
+ echo " ./version.sh patch"
78
+ echo " ./version.sh set 1.5.0"
79
+ ;;
80
+ esac
@@ -0,0 +1,35 @@
1
+ import { Command } from 'commander';
2
+ import { ProjectExtender } from '../services/project-extender';
3
+ import chalk from 'chalk';
4
+
5
+ export function extendCommand(program: Command) {
6
+ program
7
+ .command('extend')
8
+ .description('Extend project with additional features')
9
+ .option('-f, --feature <feature>', 'Feature to add (auth, email, socket, etc.)')
10
+ .option('-l, --list', 'List available features')
11
+ .action(async (options: any) => {
12
+ try {
13
+ if (options.list) {
14
+ const extender = new ProjectExtender();
15
+ await extender.listFeatures();
16
+ return;
17
+ }
18
+
19
+ if (!options.feature) {
20
+ console.log(chalk.red('❌ Please specify a feature to add or use --list to see available features'));
21
+ process.exit(1);
22
+ }
23
+
24
+ console.log(chalk.blue(`🔧 Adding feature: ${options.feature}`));
25
+
26
+ const extender = new ProjectExtender();
27
+ await extender.addFeature(options.feature);
28
+
29
+ console.log(chalk.green(`✅ Feature ${options.feature} added successfully!`));
30
+ } catch (error: any) {
31
+ console.error(chalk.red(`❌ Failed to add feature: ${error.message}`));
32
+ process.exit(1);
33
+ }
34
+ });
35
+ }