@diagramers/cli 1.0.23 → 1.0.25
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 +1 -0
- package/dist/services/template-updater.d.ts.map +1 -1
- package/dist/services/template-updater.js +27 -14
- package/dist/services/template-updater.js.map +1 -1
- package/package.json +5 -1
- 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 +1 @@
|
|
1
|
-
{"version":3,"file":"template-updater.d.ts","sourceRoot":"","sources":["../../src/services/template-updater.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"template-updater.d.ts","sourceRoot":"","sources":["../../src/services/template-updater.ts"],"names":[],"mappings":"AAMA,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;YAUhB,eAAe;YAiCf,kBAAkB;YAmBlB,cAAc;YAqBd,aAAa;YAeb,OAAO;CAKtB"}
|
@@ -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 TemplateUpdater {
|
45
46
|
constructor() {
|
46
47
|
this.currentProjectPath = process.cwd();
|
@@ -112,22 +113,34 @@ class TemplateUpdater {
|
|
112
113
|
console.log(chalk_1.default.blue(`📦 Downloading latest template: ${templatePackage}`));
|
113
114
|
// Create temporary directory
|
114
115
|
await fs.ensureDir(this.tempTemplatePath);
|
115
|
-
//
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
116
|
+
// Only download from npm registry
|
117
|
+
await this.downloadFromNpm(templatePackage);
|
118
|
+
}
|
119
|
+
async downloadFromNpm(templatePackage) {
|
120
|
+
const npmCachePath = path.join(this.tempTemplatePath, 'node_modules', templatePackage);
|
121
|
+
try {
|
122
|
+
// Use npm pack to download the package
|
123
|
+
(0, child_process_1.execSync)(`npm pack ${templatePackage} --silent`, {
|
124
|
+
cwd: this.tempTemplatePath,
|
125
|
+
stdio: 'pipe'
|
126
|
+
});
|
127
|
+
// Find the downloaded tarball
|
128
|
+
const files = await fs.readdir(this.tempTemplatePath);
|
129
|
+
const tarball = files.find(file => file.endsWith('.tgz'));
|
130
|
+
if (!tarball) {
|
131
|
+
throw new Error('No tarball found after npm pack');
|
132
|
+
}
|
133
|
+
// Extract the tarball
|
134
|
+
(0, child_process_1.execSync)(`tar -xzf ${tarball} --strip-components=1`, {
|
135
|
+
cwd: this.tempTemplatePath,
|
136
|
+
stdio: 'pipe'
|
127
137
|
});
|
138
|
+
// Clean up tarball
|
139
|
+
await fs.remove(path.join(this.tempTemplatePath, tarball));
|
140
|
+
console.log(chalk_1.default.green(`✅ Template downloaded from npm: ${templatePackage}`));
|
128
141
|
}
|
129
|
-
|
130
|
-
throw new Error(
|
142
|
+
catch (error) {
|
143
|
+
throw new Error(`Failed to download template from npm: ${error.message}`);
|
131
144
|
}
|
132
145
|
}
|
133
146
|
async getUpdateableFiles() {
|
@@ -1 +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;
|
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;AAC1B,iDAAyC;AAQzC,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,MAAM,CAAC,OAA8B;QACzC,8CAA8C;QAC9C,IAAI,CAAC,MAAM,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;QACpG,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC,CAAC;QAE/D,6BAA6B;QAC7B,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QAC5B,CAAC;QAED,IAAI,CAAC;YACH,2BAA2B;YAC3B,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,QAAQ,IAAI,iBAAiB,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,CAAC,aAAa,CAAC,KAAe,EAAE,QAAiB,KAAK;QACjE,OAAO,CAAC,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;AA9LD,0CA8LC"}
|
package/package.json
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
{
|
2
2
|
"name": "@diagramers/cli",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.25",
|
4
4
|
"description": "Diagramers CLI - Command-line tools for managing Diagramers projects",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"bin": {
|
7
7
|
"diagramers": "./dist/index.js"
|
8
8
|
},
|
9
|
+
"files": [
|
10
|
+
"dist/**/*",
|
11
|
+
"templates/**/*"
|
12
|
+
],
|
9
13
|
"scripts": {
|
10
14
|
"build": "tsc",
|
11
15
|
"dev": "ts-node src/index.ts",
|
package/scripts/publish.sh
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# diagramers CLI Publishing Script
|
4
|
-
echo "🚀 Publishing diagramers 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
|
package/scripts/setup.sh
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# diagramers API Template Setup Script
|
4
|
-
echo "🚀 Setting up diagramers 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 " diagramers-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"
|
package/scripts/version.sh
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# Version Management Script for diagramers 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
|
package/src/commands/api.ts
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
import { Command } from 'commander';
|
2
|
-
import { generateModule } from '../services/api-generator';
|
3
|
-
import { generateTable } from '../services/table-generator';
|
4
|
-
import { generateRelation } from '../services/relation-generator';
|
5
|
-
import { processTemplate } from '../services/template-processor';
|
6
|
-
import chalk from 'chalk';
|
7
|
-
|
8
|
-
export function apiCommand(program: Command) {
|
9
|
-
const api = program
|
10
|
-
.command('api')
|
11
|
-
.description('API-specific commands for diagramers projects');
|
12
|
-
|
13
|
-
// Generate module command
|
14
|
-
api
|
15
|
-
.command('generate:module <name>')
|
16
|
-
.description('Generate a new module with entity, schema, service, controller, and routes')
|
17
|
-
.action(async (name: string) => {
|
18
|
-
try {
|
19
|
-
console.log(chalk.blue(`🚀 Generating module: ${name}`));
|
20
|
-
await generateModule(name);
|
21
|
-
console.log(chalk.green(`✅ Module '${name}' generated successfully!`));
|
22
|
-
} catch (error: any) {
|
23
|
-
console.error(chalk.red(`❌ Error generating module: ${error.message}`));
|
24
|
-
process.exit(1);
|
25
|
-
}
|
26
|
-
});
|
27
|
-
|
28
|
-
// Process template command
|
29
|
-
api
|
30
|
-
.command('process:template <name>')
|
31
|
-
.description('Process template files for a new project')
|
32
|
-
.action(async (name: string) => {
|
33
|
-
try {
|
34
|
-
console.log(chalk.blue(`🔧 Processing template for project: ${name}`));
|
35
|
-
await processTemplate(name);
|
36
|
-
console.log(chalk.green(`✅ Template processing completed for '${name}'!`));
|
37
|
-
} catch (error: any) {
|
38
|
-
console.error(chalk.red(`❌ Error processing template: ${error.message}`));
|
39
|
-
process.exit(1);
|
40
|
-
}
|
41
|
-
});
|
42
|
-
|
43
|
-
// Generate table command
|
44
|
-
api
|
45
|
-
.command('generate:table <name>')
|
46
|
-
.description('Generate a new database table with entity and schema only')
|
47
|
-
.action(async (name: string) => {
|
48
|
-
try {
|
49
|
-
console.log(chalk.blue(`🚀 Generating table: ${name}`));
|
50
|
-
await generateTable(name);
|
51
|
-
console.log(chalk.green(`✅ Table '${name}' generated successfully!`));
|
52
|
-
} catch (error: any) {
|
53
|
-
console.error(chalk.red(`❌ Error generating table: ${error.message}`));
|
54
|
-
process.exit(1);
|
55
|
-
}
|
56
|
-
});
|
57
|
-
|
58
|
-
// Generate relation command
|
59
|
-
api
|
60
|
-
.command('generate:relation <table1> <table2>')
|
61
|
-
.description('Generate a relationship between two existing tables')
|
62
|
-
.option('-t, --type <type>', 'Relationship type: one-to-one, one-to-many, many-to-many', 'one-to-one')
|
63
|
-
.action(async (table1: string, table2: string, options: any) => {
|
64
|
-
try {
|
65
|
-
const relationType = options?.type || 'one-to-one';
|
66
|
-
console.log(chalk.blue(`🔗 Creating ${relationType} relationship between ${table1} and ${table2}...`));
|
67
|
-
await generateRelation(table1, table2, relationType);
|
68
|
-
console.log(chalk.green(`✅ Relationship created successfully!`));
|
69
|
-
} catch (error: any) {
|
70
|
-
console.error(chalk.red(`❌ Error creating relationship: ${error.message}`));
|
71
|
-
process.exit(1);
|
72
|
-
}
|
73
|
-
});
|
74
|
-
|
75
|
-
return api;
|
76
|
-
}
|
package/src/commands/extend.ts
DELETED
@@ -1,35 +0,0 @@
|
|
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
|
-
}
|
package/src/commands/init.ts
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
import { Command } from 'commander';
|
2
|
-
import { ProjectInitializer } from '../services/project-initializer';
|
3
|
-
import chalk from 'chalk';
|
4
|
-
|
5
|
-
export function initCommand(program: Command) {
|
6
|
-
program
|
7
|
-
.command('init <template-type> <project-name>')
|
8
|
-
.description('Initialize a new project from the template')
|
9
|
-
.option('-t, --template <template>', 'Template version to use', 'latest')
|
10
|
-
.option('-y, --yes', 'Skip prompts and use defaults')
|
11
|
-
.action(async (templateType: string, projectName: string, options: any) => {
|
12
|
-
try {
|
13
|
-
console.log(chalk.blue(`🚀 Initializing new ${templateType} project: ${projectName}`));
|
14
|
-
|
15
|
-
// Validate template type
|
16
|
-
if (templateType !== 'api' && templateType !== 'admin') {
|
17
|
-
throw new Error(`Unsupported template type: ${templateType}. Supported types: api, admin`);
|
18
|
-
}
|
19
|
-
|
20
|
-
const initializer = new ProjectInitializer();
|
21
|
-
await initializer.initialize(projectName, { ...options, template: templateType });
|
22
|
-
|
23
|
-
console.log(chalk.green(`✅ Project ${projectName} initialized successfully!`));
|
24
|
-
console.log(chalk.yellow(`📁 Navigate to the project: cd ${projectName}`));
|
25
|
-
console.log(chalk.yellow(`🔧 Install dependencies: npm install`));
|
26
|
-
console.log(chalk.yellow(`🚀 Start development: npm run serve`));
|
27
|
-
} catch (error: any) {
|
28
|
-
console.error(chalk.red(`❌ Failed to initialize project: ${error.message}`));
|
29
|
-
process.exit(1);
|
30
|
-
}
|
31
|
-
});
|
32
|
-
}
|
package/src/commands/update.ts
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
import { Command } from 'commander';
|
2
|
-
import { TemplateUpdater } from '../services/template-updater';
|
3
|
-
import chalk from 'chalk';
|
4
|
-
|
5
|
-
export function updateCommand(program: Command) {
|
6
|
-
program
|
7
|
-
.command('update')
|
8
|
-
.description('Update existing project with latest template features')
|
9
|
-
.option('-f, --force', 'Force update even if conflicts detected')
|
10
|
-
.option('-b, --backup', 'Create backup before updating')
|
11
|
-
.action(async (options: any) => {
|
12
|
-
try {
|
13
|
-
console.log(chalk.blue('🔄 Checking for template updates...'));
|
14
|
-
|
15
|
-
const updater = new TemplateUpdater();
|
16
|
-
await updater.update(options);
|
17
|
-
|
18
|
-
console.log(chalk.green('✅ Project updated successfully!'));
|
19
|
-
console.log(chalk.yellow('📝 Review the changes and test your application'));
|
20
|
-
} catch (error: any) {
|
21
|
-
console.error(chalk.red(`❌ Failed to update project: ${error.message}`));
|
22
|
-
process.exit(1);
|
23
|
-
}
|
24
|
-
});
|
25
|
-
}
|
@@ -1,111 +0,0 @@
|
|
1
|
-
export interface TemplateConfig {
|
2
|
-
name: string;
|
3
|
-
version: string;
|
4
|
-
description: string;
|
5
|
-
files: {
|
6
|
-
include: string[];
|
7
|
-
exclude: string[];
|
8
|
-
updateable: string[];
|
9
|
-
customizable: string[];
|
10
|
-
};
|
11
|
-
features: {
|
12
|
-
[key: string]: {
|
13
|
-
name: string;
|
14
|
-
description: string;
|
15
|
-
dependencies: string[];
|
16
|
-
files: string[];
|
17
|
-
};
|
18
|
-
};
|
19
|
-
}
|
20
|
-
|
21
|
-
export const templateConfig: TemplateConfig = {
|
22
|
-
name: 'diagramers-api-template',
|
23
|
-
version: '1.0.0',
|
24
|
-
description: 'Node.js API template with TypeScript, Firebase Functions, and Socket.io',
|
25
|
-
|
26
|
-
files: {
|
27
|
-
include: [
|
28
|
-
'src/**/*',
|
29
|
-
'package.json',
|
30
|
-
'tsconfig.json',
|
31
|
-
'webpack.config.js',
|
32
|
-
'main.ts',
|
33
|
-
'certs/**/*'
|
34
|
-
],
|
35
|
-
exclude: [
|
36
|
-
'node_modules/**',
|
37
|
-
'dist/**',
|
38
|
-
'cli/**',
|
39
|
-
'.git/**',
|
40
|
-
'backup-*/**',
|
41
|
-
'*.log',
|
42
|
-
'.env*'
|
43
|
-
],
|
44
|
-
updateable: [
|
45
|
-
'src/helpers/**/*',
|
46
|
-
'src/config/**/*',
|
47
|
-
'src/server/**/*',
|
48
|
-
'webpack.config.js',
|
49
|
-
'tsconfig.json'
|
50
|
-
],
|
51
|
-
customizable: [
|
52
|
-
'src/controllers/**/*',
|
53
|
-
'src/entities/**/*',
|
54
|
-
'src/routes/**/*',
|
55
|
-
'src/services/**/*',
|
56
|
-
'src/schemas/**/*',
|
57
|
-
'main.ts'
|
58
|
-
]
|
59
|
-
},
|
60
|
-
|
61
|
-
features: {
|
62
|
-
auth: {
|
63
|
-
name: 'Authentication',
|
64
|
-
description: 'JWT-based authentication system',
|
65
|
-
dependencies: ['jsonwebtoken', 'bcryptjs', '@types/jsonwebtoken', '@types/bcryptjs'],
|
66
|
-
files: [
|
67
|
-
'src/features/auth/**/*',
|
68
|
-
'src/helpers/auth.ts'
|
69
|
-
]
|
70
|
-
},
|
71
|
-
email: {
|
72
|
-
name: 'Email System',
|
73
|
-
description: 'Email notification system with templates',
|
74
|
-
dependencies: ['nodemailer', 'handlebars', '@types/nodemailer'],
|
75
|
-
files: [
|
76
|
-
'src/features/email/**/*',
|
77
|
-
'src/helpers/mailer.ts',
|
78
|
-
'src/assets/css/email-template.css'
|
79
|
-
]
|
80
|
-
},
|
81
|
-
socket: {
|
82
|
-
name: 'WebSocket',
|
83
|
-
description: 'Real-time communication with Socket.io',
|
84
|
-
dependencies: ['socket.io', '@types/socket.io'],
|
85
|
-
files: [
|
86
|
-
'src/features/socket/**/*',
|
87
|
-
'src/server/socket-server-provider.ts'
|
88
|
-
]
|
89
|
-
},
|
90
|
-
cron: {
|
91
|
-
name: 'Scheduled Tasks',
|
92
|
-
description: 'Cron job system for scheduled tasks',
|
93
|
-
dependencies: ['node-cron', '@types/node-cron'],
|
94
|
-
files: [
|
95
|
-
'src/features/cron/**/*',
|
96
|
-
'src/helpers/cronHelper.ts'
|
97
|
-
]
|
98
|
-
},
|
99
|
-
audit: {
|
100
|
-
name: 'Audit Logging',
|
101
|
-
description: 'Comprehensive audit logging system',
|
102
|
-
dependencies: [],
|
103
|
-
files: [
|
104
|
-
'src/features/audit/**/*',
|
105
|
-
'src/entities/audit.ts',
|
106
|
-
'src/schemas/audit.ts',
|
107
|
-
'src/services/audit-service.ts'
|
108
|
-
]
|
109
|
-
}
|
110
|
-
}
|
111
|
-
};
|
package/src/index.ts
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
|
3
|
-
import { Command } from 'commander';
|
4
|
-
import { initCommand } from './commands/init';
|
5
|
-
import { updateCommand } from './commands/update';
|
6
|
-
import { extendCommand } from './commands/extend';
|
7
|
-
import { apiCommand } from './commands/api';
|
8
|
-
import chalk from 'chalk';
|
9
|
-
|
10
|
-
const program = new Command();
|
11
|
-
|
12
|
-
program
|
13
|
-
.name('diagramers')
|
14
|
-
.description('CLI tool for managing diagramers projects')
|
15
|
-
.version('1.0.0');
|
16
|
-
|
17
|
-
// Add commands
|
18
|
-
initCommand(program);
|
19
|
-
updateCommand(program);
|
20
|
-
extendCommand(program);
|
21
|
-
apiCommand(program);
|
22
|
-
|
23
|
-
// Add help text
|
24
|
-
program.addHelpText('after', `
|
25
|
-
Examples:
|
26
|
-
$ diagramers init api my-new-project
|
27
|
-
$ diagramers init admin my-admin-dashboard
|
28
|
-
$ diagramers update
|
29
|
-
$ diagramers extend --feature auth
|
30
|
-
$ diagramers api generate:module product
|
31
|
-
$ diagramers api generate:table category
|
32
|
-
$ diagramers api generate:relation product category one-to-many
|
33
|
-
$ diagramers api process:template my-api-project
|
34
|
-
`);
|
35
|
-
|
36
|
-
program.parse();
|
37
|
-
|
38
|
-
// If no command is provided, show help
|
39
|
-
if (!process.argv.slice(2).length) {
|
40
|
-
program.outputHelp();
|
41
|
-
}
|