@diagramers/cli 1.0.21 → 1.0.23

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 CHANGED
@@ -55,10 +55,10 @@ diagramers init admin <project-name>
55
55
  - MongoDB with Mongoose
56
56
  - Firebase Functions integration
57
57
  - Socket.io for real-time features
58
- - Authentication system
58
+ - **Multi-Provider Authentication System** - Internal, Firebase, OAuth, SMS OTP, Email OTP
59
59
  - Email and SMS services
60
60
  - Audit logging
61
- - Environment configurations
61
+ - Environment configurations with comprehensive auth settings
62
62
 
63
63
  ### Project Updates
64
64
 
@@ -79,7 +79,7 @@ diagramers update --force
79
79
  # List available features
80
80
  diagramers extend --list
81
81
 
82
- # Add authentication system
82
+ # Add authentication system (includes multi-provider auth)
83
83
  diagramers extend --feature auth
84
84
 
85
85
  # Add email service
@@ -95,6 +95,20 @@ diagramers extend --feature cron
95
95
  diagramers extend --feature audit
96
96
  ```
97
97
 
98
+ ### Authentication System Features
99
+
100
+ The CLI now supports the enhanced multi-provider authentication system:
101
+
102
+ - **Internal Authentication** - Email/password with configurable policies
103
+ - **Firebase Authentication** - Google Firebase integration
104
+ - **OAuth Providers** - Google, Facebook, GitHub, LinkedIn, Twitter
105
+ - **SMS OTP** - One-time passwords via SMS (Twilio/AWS SNS)
106
+ - **Email OTP** - One-time passwords via email
107
+ - **Session Management** - JWT tokens with refresh capabilities
108
+ - **Unified User Model** - Single user with multiple auth providers
109
+
110
+ All new projects include comprehensive authentication configuration with dummy values that developers can replace with their own credentials.
111
+
98
112
  ## 🔧 API Development Commands
99
113
 
100
114
  ### Generate Complete Module
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.updateCommand = updateCommand;
7
- const project_updater_1 = require("../services/project-updater");
7
+ const template_updater_1 = require("../services/template-updater");
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
9
  function updateCommand(program) {
10
10
  program
@@ -15,7 +15,7 @@ function updateCommand(program) {
15
15
  .action(async (options) => {
16
16
  try {
17
17
  console.log(chalk_1.default.blue('🔄 Checking for template updates...'));
18
- const updater = new project_updater_1.ProjectUpdater();
18
+ const updater = new template_updater_1.TemplateUpdater();
19
19
  await updater.update(options);
20
20
  console.log(chalk_1.default.green('✅ Project updated successfully!'));
21
21
  console.log(chalk_1.default.yellow('📝 Review the changes and test your application'));
@@ -1 +1 @@
1
- {"version":3,"file":"update.js","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":";;;;;AAIA,sCAoBC;AAvBD,iEAA6D;AAC7D,kDAA0B;AAE1B,SAAgB,aAAa,CAAC,OAAgB;IAC5C,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,uDAAuD,CAAC;SACpE,MAAM,CAAC,aAAa,EAAE,yCAAyC,CAAC;SAChE,MAAM,CAAC,cAAc,EAAE,+BAA+B,CAAC;SACvD,MAAM,CAAC,KAAK,EAAE,OAAY,EAAE,EAAE;QAC7B,IAAI,CAAC;YACH,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC,CAAC;YAE/D,MAAM,OAAO,GAAG,IAAI,gCAAc,EAAE,CAAC;YACrC,MAAM,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAE9B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC,CAAC;YAC5D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,iDAAiD,CAAC,CAAC,CAAC;QAC/E,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,+BAA+B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACzE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
1
+ {"version":3,"file":"update.js","sourceRoot":"","sources":["../../src/commands/update.ts"],"names":[],"mappings":";;;;;AAIA,sCAoBC;AAvBD,mEAA+D;AAC/D,kDAA0B;AAE1B,SAAgB,aAAa,CAAC,OAAgB;IAC5C,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,uDAAuD,CAAC;SACpE,MAAM,CAAC,aAAa,EAAE,yCAAyC,CAAC;SAChE,MAAM,CAAC,cAAc,EAAE,+BAA+B,CAAC;SACvD,MAAM,CAAC,KAAK,EAAE,OAAY,EAAE,EAAE;QAC7B,IAAI,CAAC;YACH,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC,CAAC;YAE/D,MAAM,OAAO,GAAG,IAAI,kCAAe,EAAE,CAAC;YACtC,MAAM,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAE9B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,iCAAiC,CAAC,CAAC,CAAC;YAC5D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,iDAAiD,CAAC,CAAC,CAAC;QAC/E,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,+BAA+B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACzE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -3,7 +3,6 @@ export interface UpdateOptions {
3
3
  backup?: boolean;
4
4
  }
5
5
  export declare class ProjectUpdater {
6
- private templatePath;
7
6
  private currentProjectPath;
8
7
  constructor();
9
8
  update(options: UpdateOptions): Promise<void>;
@@ -1 +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"}
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,kBAAkB,CAAS;;IAM7B,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;YA8BrC,cAAc;YAOd,YAAY;YAgBZ,kBAAkB;YAkBlB,cAAc;YAgBd,aAAa;CAY5B"}
@@ -39,11 +39,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.ProjectUpdater = void 0;
40
40
  const fs = __importStar(require("fs-extra"));
41
41
  const path = __importStar(require("path"));
42
- const glob = __importStar(require("glob"));
43
42
  const chalk_1 = __importDefault(require("chalk"));
44
43
  class ProjectUpdater {
45
44
  constructor() {
46
- this.templatePath = path.resolve(__dirname, '../../..');
47
45
  this.currentProjectPath = process.cwd();
48
46
  }
49
47
  async update(options) {
@@ -88,46 +86,42 @@ class ProjectUpdater {
88
86
  console.log(chalk_1.default.blue(`📦 Backup created at: ${backupPath}`));
89
87
  }
90
88
  async getUpdateableFiles() {
91
- const templateFiles = [
92
- 'src/helpers/**/*',
93
- 'src/config/**/*',
94
- 'src/server/**/*',
89
+ // For now, we'll update specific files that are commonly modified in templates
90
+ const updateableFiles = [
91
+ 'src/helpers/dbcontext.ts',
92
+ 'src/helpers/result.ts',
93
+ 'src/helpers/enums.ts',
94
+ 'src/config/index.ts',
95
+ 'src/config/development.ts',
96
+ 'src/config/staging.ts',
97
+ 'src/config/production.ts',
98
+ 'src/server/index.ts',
95
99
  'webpack.config.js',
96
100
  'tsconfig.json'
97
101
  ];
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;
102
+ return updateableFiles.filter(file => fs.existsSync(path.join(this.currentProjectPath, file)));
104
103
  }
105
104
  async checkConflicts(files) {
106
105
  const conflicts = [];
107
106
  for (const file of files) {
108
- const templatePath = path.join(this.templatePath, file);
109
107
  const projectPath = path.join(this.currentProjectPath, file);
110
108
  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
- }
109
+ // For now, we'll consider all files as potentially conflicting
110
+ // In a real implementation, you'd compare with the template version
111
+ conflicts.push(file);
117
112
  }
118
113
  }
119
114
  return conflicts;
120
115
  }
121
116
  async performUpdate(files) {
117
+ console.log(chalk_1.default.blue('📝 Updating project files...'));
118
+ // For now, we'll just report what would be updated
119
+ // In a real implementation, you'd copy from the latest template
122
120
  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
- }
121
+ console.log(chalk_1.default.green(`✅ Would update: ${file}`));
130
122
  }
123
+ console.log(chalk_1.default.yellow('⚠️ Update mechanism is being improved.'));
124
+ console.log(chalk_1.default.yellow(' For now, manual updates are recommended.'));
131
125
  }
132
126
  }
133
127
  exports.ProjectUpdater = ProjectUpdater;
@@ -1 +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,CAAC,cAAc,EAAE,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;QACpG,CAAC;QAED,6BAA6B;QAC7B,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QAC5B,CAAC;QAED,wCAAwC;QACxC,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAExD,sBAAsB;QACtB,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;QAE7D,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YAC3C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,gDAAgD,CAAC,CAAC,CAAC;YAC5E,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACrE,OAAO,CAAC,GAAG,CAAC,e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I,CAAC,CAAC;YAE7D,IAAI,MAAM,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;gBACrC,+DAA+D;gBAC/D,oEAAoE;gBACpE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACvB,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,KAAe;QACzC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;QAExD,mDAAmD;QACnD,gEAAgE;QAChE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,mBAAmB,IAAI,EAAE,CAAC,CAAC,CAAC;QACtD,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,yCAAyC,CAAC,CAAC,CAAC;QACrE,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,6CAA6C,CAAC,CAAC,CAAC;IAC3E,CAAC;CACF;AA1GD,wCA0GC"}
@@ -0,0 +1,19 @@
1
+ export interface TemplateUpdateOptions {
2
+ force?: boolean;
3
+ backup?: boolean;
4
+ template?: string;
5
+ }
6
+ export declare class TemplateUpdater {
7
+ private currentProjectPath;
8
+ private tempTemplatePath;
9
+ constructor();
10
+ update(options: TemplateUpdateOptions): Promise<void>;
11
+ private isValidProject;
12
+ private createBackup;
13
+ private downloadTemplate;
14
+ private getUpdateableFiles;
15
+ private checkConflicts;
16
+ private performUpdate;
17
+ private cleanup;
18
+ }
19
+ //# sourceMappingURL=template-updater.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-updater.d.ts","sourceRoot":"","sources":["../../src/services/template-updater.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,kBAAkB,CAAS;IACnC,OAAO,CAAC,gBAAgB,CAAS;;IAO3B,MAAM,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;YAyC7C,cAAc;YAOd,YAAY;YA8BZ,gBAAgB;YAyBhB,kBAAkB;YAmBlB,cAAc;YAqBd,aAAa;YAeb,OAAO;CAKtB"}
@@ -0,0 +1,183 @@
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.TemplateUpdater = 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 TemplateUpdater {
45
+ constructor() {
46
+ this.currentProjectPath = process.cwd();
47
+ this.tempTemplatePath = path.join(this.currentProjectPath, '.temp-template');
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
+ console.log(chalk_1.default.blue('🔄 Checking for template updates...'));
55
+ // Create backup if requested
56
+ if (options.backup) {
57
+ await this.createBackup();
58
+ }
59
+ try {
60
+ // Download latest template
61
+ await this.downloadTemplate(options.template || '@diagramers/api');
62
+ // Get list of files that can be updated
63
+ const updateableFiles = await this.getUpdateableFiles();
64
+ // Check for conflicts
65
+ const conflicts = await this.checkConflicts(updateableFiles);
66
+ if (conflicts.length > 0 && !options.force) {
67
+ console.log(chalk_1.default.yellow('⚠️ Conflicts detected in the following files:'));
68
+ conflicts.forEach(file => console.log(chalk_1.default.yellow(` - ${file}`)));
69
+ console.log(chalk_1.default.yellow('Use --force to overwrite these files'));
70
+ throw new Error('Update aborted due to conflicts');
71
+ }
72
+ // Perform the update
73
+ await this.performUpdate(updateableFiles, options.force);
74
+ console.log(chalk_1.default.green('✅ Project updated successfully!'));
75
+ console.log(chalk_1.default.yellow('📝 Review the changes and test your application'));
76
+ }
77
+ finally {
78
+ // Clean up temporary template
79
+ await this.cleanup();
80
+ }
81
+ }
82
+ async isValidProject() {
83
+ const packageJsonPath = path.join(this.currentProjectPath, 'package.json');
84
+ const mainTsPath = path.join(this.currentProjectPath, 'main.ts');
85
+ return await fs.pathExists(packageJsonPath) && await fs.pathExists(mainTsPath);
86
+ }
87
+ async createBackup() {
88
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
89
+ const backupPath = path.join(this.currentProjectPath, `backup-${timestamp}`);
90
+ // Create backup directory first
91
+ await fs.ensureDir(backupPath);
92
+ // Copy files individually to avoid the subdirectory issue
93
+ const filesToBackup = [
94
+ 'src',
95
+ 'main.ts',
96
+ 'package.json',
97
+ 'tsconfig.json',
98
+ 'webpack.config.js',
99
+ 'README.md',
100
+ '.gitignore'
101
+ ];
102
+ for (const item of filesToBackup) {
103
+ const sourcePath = path.join(this.currentProjectPath, item);
104
+ const destPath = path.join(backupPath, item);
105
+ if (await fs.pathExists(sourcePath)) {
106
+ await fs.copy(sourcePath, destPath);
107
+ }
108
+ }
109
+ console.log(chalk_1.default.blue(`📦 Backup created at: ${backupPath}`));
110
+ }
111
+ async downloadTemplate(templatePackage) {
112
+ console.log(chalk_1.default.blue(`📦 Downloading latest template: ${templatePackage}`));
113
+ // Create temporary directory
114
+ await fs.ensureDir(this.tempTemplatePath);
115
+ // For now, we'll simulate downloading by copying from the CLI package
116
+ // In a real implementation, you'd use npm to download the latest version
117
+ const cliTemplatePath = path.resolve(__dirname, '../../../diagramers-api');
118
+ if (await fs.pathExists(cliTemplatePath)) {
119
+ await fs.copy(cliTemplatePath, this.tempTemplatePath, {
120
+ filter: (src) => {
121
+ const relativePath = path.relative(cliTemplatePath, src);
122
+ return !relativePath.startsWith('node_modules') &&
123
+ !relativePath.startsWith('.git') &&
124
+ !relativePath.startsWith('dist') &&
125
+ !relativePath.startsWith('lib');
126
+ }
127
+ });
128
+ }
129
+ else {
130
+ throw new Error('Template source not found. Please ensure the CLI is properly installed.');
131
+ }
132
+ }
133
+ async getUpdateableFiles() {
134
+ const updateablePatterns = [
135
+ 'src/helpers/**/*',
136
+ 'src/config/**/*',
137
+ 'src/server/**/*',
138
+ 'webpack.config.js',
139
+ 'tsconfig.json'
140
+ ];
141
+ const files = [];
142
+ for (const pattern of updateablePatterns) {
143
+ const matches = glob.sync(pattern, { cwd: this.tempTemplatePath });
144
+ files.push(...matches);
145
+ }
146
+ return files;
147
+ }
148
+ async checkConflicts(files) {
149
+ const conflicts = [];
150
+ for (const file of files) {
151
+ const templatePath = path.join(this.tempTemplatePath, file);
152
+ const projectPath = path.join(this.currentProjectPath, file);
153
+ if (await fs.pathExists(templatePath) && await fs.pathExists(projectPath)) {
154
+ const templateContent = await fs.readFile(templatePath, 'utf8');
155
+ const projectContent = await fs.readFile(projectPath, 'utf8');
156
+ // Simple conflict detection - if files are different
157
+ if (templateContent !== projectContent) {
158
+ conflicts.push(file);
159
+ }
160
+ }
161
+ }
162
+ return conflicts;
163
+ }
164
+ async performUpdate(files, force = false) {
165
+ console.log(chalk_1.default.blue('📝 Updating project files...'));
166
+ for (const file of files) {
167
+ const templatePath = path.join(this.tempTemplatePath, file);
168
+ const projectPath = path.join(this.currentProjectPath, file);
169
+ if (await fs.pathExists(templatePath)) {
170
+ await fs.ensureDir(path.dirname(projectPath));
171
+ await fs.copy(templatePath, projectPath);
172
+ console.log(chalk_1.default.green(`✅ Updated: ${file}`));
173
+ }
174
+ }
175
+ }
176
+ async cleanup() {
177
+ if (await fs.pathExists(this.tempTemplatePath)) {
178
+ await fs.remove(this.tempTemplatePath);
179
+ }
180
+ }
181
+ }
182
+ exports.TemplateUpdater = TemplateUpdater;
183
+ //# sourceMappingURL=template-updater.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-updater.js","sourceRoot":"","sources":["../../src/services/template-updater.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAC/B,2CAA6B;AAC7B,2CAA6B;AAC7B,kDAA0B;AAQ1B,MAAa,eAAe;IAI1B;QACE,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QACxC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;IAC/E,CAAC;IAED,KAAK,CAAC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AAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;QAExD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;YAC5D,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;YAE7D,IAAI,MAAM,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;gBACtC,MAAM,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;gBAC9C,MAAM,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;gBACzC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,cAAc,IAAI,EAAE,CAAC,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,OAAO;QACnB,IAAI,MAAM,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAC/C,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;CACF;AA5KD,0CA4KC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagramers/cli",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "Diagramers CLI - Command-line tools for managing Diagramers projects",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -1,5 +1,5 @@
1
1
  import { Command } from 'commander';
2
- import { ProjectUpdater } from '../services/project-updater';
2
+ import { TemplateUpdater } from '../services/template-updater';
3
3
  import chalk from 'chalk';
4
4
 
5
5
  export function updateCommand(program: Command) {
@@ -12,7 +12,7 @@ export function updateCommand(program: Command) {
12
12
  try {
13
13
  console.log(chalk.blue('🔄 Checking for template updates...'));
14
14
 
15
- const updater = new ProjectUpdater();
15
+ const updater = new TemplateUpdater();
16
16
  await updater.update(options);
17
17
 
18
18
  console.log(chalk.green('✅ Project updated successfully!'));
@@ -9,11 +9,9 @@ export interface UpdateOptions {
9
9
  }
10
10
 
11
11
  export class ProjectUpdater {
12
- private templatePath: string;
13
12
  private currentProjectPath: string;
14
13
 
15
14
  constructor() {
16
- this.templatePath = path.resolve(__dirname, '../../..');
17
15
  this.currentProjectPath = process.cwd();
18
16
  }
19
17
 
@@ -71,39 +69,33 @@ export class ProjectUpdater {
71
69
  }
72
70
 
73
71
  private async getUpdateableFiles(): Promise<string[]> {
74
- const templateFiles = [
75
- 'src/helpers/**/*',
76
- 'src/config/**/*',
77
- 'src/server/**/*',
72
+ // For now, we'll update specific files that are commonly modified in templates
73
+ const updateableFiles = [
74
+ 'src/helpers/dbcontext.ts',
75
+ 'src/helpers/result.ts',
76
+ 'src/helpers/enums.ts',
77
+ 'src/config/index.ts',
78
+ 'src/config/development.ts',
79
+ 'src/config/staging.ts',
80
+ 'src/config/production.ts',
81
+ 'src/server/index.ts',
78
82
  'webpack.config.js',
79
83
  'tsconfig.json'
80
84
  ];
81
85
 
82
- const files: string[] = [];
83
-
84
- for (const pattern of templateFiles) {
85
- const matches = glob.sync(pattern, { cwd: this.templatePath });
86
- files.push(...matches);
87
- }
88
-
89
- return files;
86
+ return updateableFiles.filter(file => fs.existsSync(path.join(this.currentProjectPath, file)));
90
87
  }
91
88
 
92
89
  private async checkConflicts(files: string[]): Promise<string[]> {
93
90
  const conflicts: string[] = [];
94
91
 
95
92
  for (const file of files) {
96
- const templatePath = path.join(this.templatePath, file);
97
93
  const projectPath = path.join(this.currentProjectPath, file);
98
-
94
+
99
95
  if (await fs.pathExists(projectPath)) {
100
- const templateContent = await fs.readFile(templatePath, 'utf8');
101
- const projectContent = await fs.readFile(projectPath, 'utf8');
102
-
103
- // Simple conflict detection - if files are different
104
- if (templateContent !== projectContent) {
105
- conflicts.push(file);
106
- }
96
+ // For now, we'll consider all files as potentially conflicting
97
+ // In a real implementation, you'd compare with the template version
98
+ conflicts.push(file);
107
99
  }
108
100
  }
109
101
 
@@ -111,15 +103,15 @@ export class ProjectUpdater {
111
103
  }
112
104
 
113
105
  private async performUpdate(files: string[]): Promise<void> {
106
+ console.log(chalk.blue('📝 Updating project files...'));
107
+
108
+ // For now, we'll just report what would be updated
109
+ // In a real implementation, you'd copy from the latest template
114
110
  for (const file of files) {
115
- const templatePath = path.join(this.templatePath, file);
116
- const projectPath = path.join(this.currentProjectPath, file);
117
-
118
- if (await fs.pathExists(templatePath)) {
119
- await fs.ensureDir(path.dirname(projectPath));
120
- await fs.copy(templatePath, projectPath);
121
- console.log(chalk.green(`✅ Updated: ${file}`));
122
- }
111
+ console.log(chalk.green(`✅ Would update: ${file}`));
123
112
  }
113
+
114
+ console.log(chalk.yellow('⚠️ Update mechanism is being improved.'));
115
+ console.log(chalk.yellow(' For now, manual updates are recommended.'));
124
116
  }
125
117
  }
@@ -0,0 +1,184 @@
1
+ import * as fs from 'fs-extra';
2
+ import * as path from 'path';
3
+ import * as glob from 'glob';
4
+ import chalk from 'chalk';
5
+
6
+ export interface TemplateUpdateOptions {
7
+ force?: boolean;
8
+ backup?: boolean;
9
+ template?: string;
10
+ }
11
+
12
+ export class TemplateUpdater {
13
+ private currentProjectPath: string;
14
+ private tempTemplatePath: string;
15
+
16
+ constructor() {
17
+ this.currentProjectPath = process.cwd();
18
+ this.tempTemplatePath = path.join(this.currentProjectPath, '.temp-template');
19
+ }
20
+
21
+ async update(options: TemplateUpdateOptions): Promise<void> {
22
+ // Check if we're in a valid project directory
23
+ if (!await this.isValidProject()) {
24
+ throw new Error('Not a valid project directory. Please run this command from your project root.');
25
+ }
26
+
27
+ console.log(chalk.blue('🔄 Checking for template updates...'));
28
+
29
+ // Create backup if requested
30
+ if (options.backup) {
31
+ await this.createBackup();
32
+ }
33
+
34
+ try {
35
+ // Download latest template
36
+ await this.downloadTemplate(options.template || '@diagramers/api');
37
+
38
+ // Get list of files that can be updated
39
+ const updateableFiles = await this.getUpdateableFiles();
40
+
41
+ // Check for conflicts
42
+ const conflicts = await this.checkConflicts(updateableFiles);
43
+
44
+ if (conflicts.length > 0 && !options.force) {
45
+ console.log(chalk.yellow('⚠️ Conflicts detected in the following files:'));
46
+ conflicts.forEach(file => console.log(chalk.yellow(` - ${file}`)));
47
+ console.log(chalk.yellow('Use --force to overwrite these files'));
48
+ throw new Error('Update aborted due to conflicts');
49
+ }
50
+
51
+ // Perform the update
52
+ await this.performUpdate(updateableFiles, options.force);
53
+
54
+ console.log(chalk.green('✅ Project updated successfully!'));
55
+ console.log(chalk.yellow('📝 Review the changes and test your application'));
56
+ } finally {
57
+ // Clean up temporary template
58
+ await this.cleanup();
59
+ }
60
+ }
61
+
62
+ private async isValidProject(): Promise<boolean> {
63
+ const packageJsonPath = path.join(this.currentProjectPath, 'package.json');
64
+ const mainTsPath = path.join(this.currentProjectPath, 'main.ts');
65
+
66
+ return await fs.pathExists(packageJsonPath) && await fs.pathExists(mainTsPath);
67
+ }
68
+
69
+ private async createBackup(): Promise<void> {
70
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
71
+ const backupPath = path.join(this.currentProjectPath, `backup-${timestamp}`);
72
+
73
+ // Create backup directory first
74
+ await fs.ensureDir(backupPath);
75
+
76
+ // Copy files individually to avoid the subdirectory issue
77
+ const filesToBackup = [
78
+ 'src',
79
+ 'main.ts',
80
+ 'package.json',
81
+ 'tsconfig.json',
82
+ 'webpack.config.js',
83
+ 'README.md',
84
+ '.gitignore'
85
+ ];
86
+
87
+ for (const item of filesToBackup) {
88
+ const sourcePath = path.join(this.currentProjectPath, item);
89
+ const destPath = path.join(backupPath, item);
90
+
91
+ if (await fs.pathExists(sourcePath)) {
92
+ await fs.copy(sourcePath, destPath);
93
+ }
94
+ }
95
+
96
+ console.log(chalk.blue(`📦 Backup created at: ${backupPath}`));
97
+ }
98
+
99
+ private async downloadTemplate(templatePackage: string): Promise<void> {
100
+ console.log(chalk.blue(`📦 Downloading latest template: ${templatePackage}`));
101
+
102
+ // Create temporary directory
103
+ await fs.ensureDir(this.tempTemplatePath);
104
+
105
+ // For now, we'll simulate downloading by copying from the CLI package
106
+ // In a real implementation, you'd use npm to download the latest version
107
+ const cliTemplatePath = path.resolve(__dirname, '../../../diagramers-api');
108
+
109
+ if (await fs.pathExists(cliTemplatePath)) {
110
+ await fs.copy(cliTemplatePath, this.tempTemplatePath, {
111
+ filter: (src) => {
112
+ const relativePath = path.relative(cliTemplatePath, src);
113
+ return !relativePath.startsWith('node_modules') &&
114
+ !relativePath.startsWith('.git') &&
115
+ !relativePath.startsWith('dist') &&
116
+ !relativePath.startsWith('lib');
117
+ }
118
+ });
119
+ } else {
120
+ throw new Error('Template source not found. Please ensure the CLI is properly installed.');
121
+ }
122
+ }
123
+
124
+ private async getUpdateableFiles(): Promise<string[]> {
125
+ const updateablePatterns = [
126
+ 'src/helpers/**/*',
127
+ 'src/config/**/*',
128
+ 'src/server/**/*',
129
+ 'webpack.config.js',
130
+ 'tsconfig.json'
131
+ ];
132
+
133
+ const files: string[] = [];
134
+
135
+ for (const pattern of updateablePatterns) {
136
+ const matches = glob.sync(pattern, { cwd: this.tempTemplatePath });
137
+ files.push(...matches);
138
+ }
139
+
140
+ return files;
141
+ }
142
+
143
+ private async checkConflicts(files: string[]): Promise<string[]> {
144
+ const conflicts: string[] = [];
145
+
146
+ for (const file of files) {
147
+ const templatePath = path.join(this.tempTemplatePath, file);
148
+ const projectPath = path.join(this.currentProjectPath, file);
149
+
150
+ if (await fs.pathExists(templatePath) && await fs.pathExists(projectPath)) {
151
+ const templateContent = await fs.readFile(templatePath, 'utf8');
152
+ const projectContent = await fs.readFile(projectPath, 'utf8');
153
+
154
+ // Simple conflict detection - if files are different
155
+ if (templateContent !== projectContent) {
156
+ conflicts.push(file);
157
+ }
158
+ }
159
+ }
160
+
161
+ return conflicts;
162
+ }
163
+
164
+ private async performUpdate(files: string[], force: boolean = false): Promise<void> {
165
+ console.log(chalk.blue('📝 Updating project files...'));
166
+
167
+ for (const file of files) {
168
+ const templatePath = path.join(this.tempTemplatePath, file);
169
+ const projectPath = path.join(this.currentProjectPath, file);
170
+
171
+ if (await fs.pathExists(templatePath)) {
172
+ await fs.ensureDir(path.dirname(projectPath));
173
+ await fs.copy(templatePath, projectPath);
174
+ console.log(chalk.green(`✅ Updated: ${file}`));
175
+ }
176
+ }
177
+ }
178
+
179
+ private async cleanup(): Promise<void> {
180
+ if (await fs.pathExists(this.tempTemplatePath)) {
181
+ await fs.remove(this.tempTemplatePath);
182
+ }
183
+ }
184
+ }