@diagramers/cli 1.0.23 → 1.0.24
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/template-updater.d.ts +2 -0
- package/dist/services/template-updater.d.ts.map +1 -1
- package/dist/services/template-updater.js +66 -14
- package/dist/services/template-updater.js.map +1 -1
- package/package.json +5 -1
- package/templates/api/certs/auth-app-cert.json +13 -0
- package/templates/api/main.ts +10 -0
- package/templates/api/package.json +70 -0
- package/templates/api/src/assets/css/email-template.css +8 -0
- package/templates/api/src/assets/images/logo_large.png +0 -0
- package/templates/api/src/assets/keys/certificate.pem +22 -0
- package/templates/api/src/assets/keys/private-key.pem +28 -0
- package/templates/api/src/config/config-interface.ts +191 -0
- package/templates/api/src/config/development.ts +145 -0
- package/templates/api/src/config/index.ts +59 -0
- package/templates/api/src/config/production.ts +145 -0
- package/templates/api/src/config/staging.ts +144 -0
- package/templates/api/src/config/uat.ts +144 -0
- package/templates/api/src/controllers/account-controller.ts +162 -0
- package/templates/api/src/entities/audit.ts +12 -0
- package/templates/api/src/entities/base-entity.ts +10 -0
- package/templates/api/src/entities/user.ts +71 -0
- package/templates/api/src/helpers/FrameworkHelper.ts +157 -0
- package/templates/api/src/helpers/auth.ts +971 -0
- package/templates/api/src/helpers/cronHelper.ts +170 -0
- package/templates/api/src/helpers/dbcontext.ts +83 -0
- package/templates/api/src/helpers/encryptionHelper.ts +76 -0
- package/templates/api/src/helpers/enums.ts +258 -0
- package/templates/api/src/helpers/handle-response.ts +49 -0
- package/templates/api/src/helpers/httpHelper.ts +75 -0
- package/templates/api/src/helpers/mailer.ts +152 -0
- package/templates/api/src/helpers/result.ts +47 -0
- package/templates/api/src/helpers/string-helper.ts +27 -0
- package/templates/api/src/routes/account-routes.ts +37 -0
- package/templates/api/src/routes/auth-routes.ts +286 -0
- package/templates/api/src/routes/index.ts +92 -0
- package/templates/api/src/schemas/audit.ts +36 -0
- package/templates/api/src/schemas/otp.ts +52 -0
- package/templates/api/src/schemas/session.ts +57 -0
- package/templates/api/src/schemas/user.ts +125 -0
- package/templates/api/src/server/index.ts +86 -0
- package/templates/api/src/server/socket-server-provider.ts +209 -0
- package/templates/api/src/services/account-service.ts +243 -0
- package/templates/api/src/services/audit-service.ts +56 -0
- package/templates/api/tsconfig.json +16 -0
- package/templates/api/webpack.config.js +66 -0
- package/scripts/publish.sh +0 -58
- package/scripts/setup.sh +0 -38
- package/scripts/version.sh +0 -80
- package/src/commands/api.ts +0 -76
- package/src/commands/extend.ts +0 -35
- package/src/commands/init.ts +0 -32
- package/src/commands/update.ts +0 -25
- package/src/config/template-config.ts +0 -111
- package/src/index.ts +0 -41
- package/src/services/api-generator.ts +0 -378
- package/src/services/project-extender.ts +0 -330
- package/src/services/project-initializer.ts +0 -335
- package/src/services/project-updater.ts +0 -117
- package/src/services/relation-generator.ts +0 -203
- package/src/services/table-generator.ts +0 -114
- package/src/services/template-processor.ts +0 -166
- package/src/services/template-updater.ts +0 -184
- package/tsconfig.json +0 -19
@@ -1,184 +0,0 @@
|
|
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
|
-
}
|
package/tsconfig.json
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"compilerOptions": {
|
3
|
-
"target": "ES2020",
|
4
|
-
"module": "commonjs",
|
5
|
-
"lib": ["ES2020"],
|
6
|
-
"outDir": "./dist",
|
7
|
-
"rootDir": "./src",
|
8
|
-
"strict": true,
|
9
|
-
"esModuleInterop": true,
|
10
|
-
"skipLibCheck": true,
|
11
|
-
"forceConsistentCasingInFileNames": true,
|
12
|
-
"resolveJsonModule": true,
|
13
|
-
"declaration": true,
|
14
|
-
"declarationMap": true,
|
15
|
-
"sourceMap": true
|
16
|
-
},
|
17
|
-
"include": ["src/**/*"],
|
18
|
-
"exclude": ["node_modules", "dist"]
|
19
|
-
}
|