create-nocobase-app 1.6.21 → 1.6.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/lib/cli.js +1 -1
- package/lib/generator.js +16 -58
- package/package.json +3 -3
- package/src/cli.js +1 -1
- package/src/generator.js +19 -61
- package/templates/app/{package.json.tpl → package.json} +9 -9
package/lib/cli.js
CHANGED
|
@@ -14,7 +14,7 @@ const { AppGenerator } = require("./generator");
|
|
|
14
14
|
const { concat } = require("./util");
|
|
15
15
|
const packageJson = require("../package.json");
|
|
16
16
|
const cli = new Command("create-nocobase");
|
|
17
|
-
cli.arguments("<name>", "directory of new NocoBase app").option("--quickstart", "quickstart app creation").option("--skip-dev-dependencies").option("-a, --all-db-dialect", "install all database dialect dependencies").option("-d, --db-dialect
|
|
17
|
+
cli.arguments("<name>", "directory of new NocoBase app").option("--quickstart", "quickstart app creation").option("--skip-dev-dependencies").option("-a, --all-db-dialect", "install all database dialect dependencies").option("-d, --db-dialect [dbDialect]", "database dialect, current support postgres, mysql, mariadb, kingbase").option("-e, --env <env>", "environment variables write into .env file", concat, []).description("create a new application").action(async (name, options) => {
|
|
18
18
|
if (options.quickstart) {
|
|
19
19
|
console.log(`\u26A0\uFE0F ${chalk.yellow("quickstart option is deprecated")}`);
|
|
20
20
|
}
|
package/lib/generator.js
CHANGED
|
@@ -36,61 +36,23 @@ const _AppGenerator = class _AppGenerator extends Generator {
|
|
|
36
36
|
}
|
|
37
37
|
return items;
|
|
38
38
|
}
|
|
39
|
-
checkDbEnv() {
|
|
40
|
-
const dialect = this.args.dbDialect;
|
|
41
|
-
const env = this.env;
|
|
42
|
-
if (dialect === "sqlite") {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
if (!env.DB_DATABASE || !env.DB_USER || !env.DB_PASSWORD) {
|
|
46
|
-
console.log(
|
|
47
|
-
chalk.red(
|
|
48
|
-
`Please set DB_HOST, DB_PORT, DB_DATABASE, DB_USER, DB_PASSWORD in .env file to complete database settings`
|
|
49
|
-
)
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
39
|
checkProjectPath() {
|
|
54
40
|
if (existsSync(this.cwd)) {
|
|
55
41
|
console.log(chalk.red("Project directory already exists"));
|
|
56
42
|
process.exit(1);
|
|
57
43
|
}
|
|
58
44
|
}
|
|
59
|
-
checkDialect() {
|
|
60
|
-
const dialect = this.args.dbDialect;
|
|
61
|
-
const supportDialects = ["mysql", "mariadb", "sqlite", "postgres"];
|
|
62
|
-
if (!supportDialects.includes(dialect)) {
|
|
63
|
-
console.log(
|
|
64
|
-
`dialect ${chalk.red(dialect)} is not supported, currently supported dialects are ${chalk.green(
|
|
65
|
-
supportDialects.join(",")
|
|
66
|
-
)}.`
|
|
67
|
-
);
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
45
|
getContext() {
|
|
72
46
|
const env = this.env;
|
|
73
47
|
const envs = [];
|
|
74
48
|
const dependencies = [];
|
|
75
|
-
const { dbDialect
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
dependencies.push(`"pg-hstore": "^2.3.4"`);
|
|
81
|
-
dependencies.push(`"sqlite3": "^5.0.8"`);
|
|
82
|
-
}
|
|
49
|
+
const { dbDialect } = this.args;
|
|
50
|
+
dependencies.push(`"mysql2": "^3.14.0"`);
|
|
51
|
+
dependencies.push(`"mariadb": "^3.4.1"`);
|
|
52
|
+
dependencies.push(`"pg": "^8.14.1"`);
|
|
53
|
+
dependencies.push(`"pg-hstore": "^2.3.4"`);
|
|
83
54
|
switch (dbDialect) {
|
|
84
|
-
case "sqlite":
|
|
85
|
-
if (!allDbDialect) {
|
|
86
|
-
dependencies.push(`"sqlite3": "^5.0.8"`);
|
|
87
|
-
}
|
|
88
|
-
envs.push(`DB_STORAGE=${env.DB_STORAGE || "storage/db/nocobase.sqlite"}`);
|
|
89
|
-
break;
|
|
90
55
|
case "mysql":
|
|
91
|
-
if (!allDbDialect) {
|
|
92
|
-
dependencies.push(`"mysql2": "^3.11.0"`);
|
|
93
|
-
}
|
|
94
56
|
envs.push(`DB_HOST=${env.DB_HOST || "localhost"}`);
|
|
95
57
|
envs.push(`DB_PORT=${env.DB_PORT || 3306}`);
|
|
96
58
|
envs.push(`DB_DATABASE=${env.DB_DATABASE || ""}`);
|
|
@@ -98,9 +60,6 @@ const _AppGenerator = class _AppGenerator extends Generator {
|
|
|
98
60
|
envs.push(`DB_PASSWORD=${env.DB_PASSWORD || ""}`);
|
|
99
61
|
break;
|
|
100
62
|
case "mariadb":
|
|
101
|
-
if (!allDbDialect) {
|
|
102
|
-
dependencies.push(`"mariadb": "^2.5.6"`);
|
|
103
|
-
}
|
|
104
63
|
envs.push(`DB_HOST=${env.DB_HOST || "localhost"}`);
|
|
105
64
|
envs.push(`DB_PORT=${env.DB_PORT || 3306}`);
|
|
106
65
|
envs.push(`DB_DATABASE=${env.DB_DATABASE || ""}`);
|
|
@@ -109,10 +68,6 @@ const _AppGenerator = class _AppGenerator extends Generator {
|
|
|
109
68
|
break;
|
|
110
69
|
case "kingbase":
|
|
111
70
|
case "postgres":
|
|
112
|
-
if (!allDbDialect) {
|
|
113
|
-
dependencies.push(`"pg": "^8.7.3"`);
|
|
114
|
-
dependencies.push(`"pg-hstore": "^2.3.4"`);
|
|
115
|
-
}
|
|
116
71
|
envs.push(`DB_HOST=${env.DB_HOST || "localhost"}`);
|
|
117
72
|
envs.push(`DB_PORT=${env.DB_PORT || 5432}`);
|
|
118
73
|
envs.push(`DB_DATABASE=${env.DB_DATABASE || ""}`);
|
|
@@ -167,22 +122,25 @@ const _AppGenerator = class _AppGenerator extends Generator {
|
|
|
167
122
|
}
|
|
168
123
|
async writing() {
|
|
169
124
|
this.checkProjectPath();
|
|
170
|
-
this.checkDialect();
|
|
171
125
|
const { name } = this.context;
|
|
172
126
|
console.log(`Creating a new NocoBase application at ${chalk.green(name)}`);
|
|
173
127
|
console.log("Creating files");
|
|
128
|
+
const context = this.getContext();
|
|
174
129
|
this.copyDirectory({
|
|
175
|
-
context
|
|
130
|
+
context,
|
|
176
131
|
path: join(__dirname, "../templates/app"),
|
|
177
132
|
target: this.cwd
|
|
178
133
|
});
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
134
|
+
const json = {
|
|
135
|
+
name: context.name,
|
|
136
|
+
...await fs.readJSON(join(this.cwd, "package.json"), "utf8")
|
|
137
|
+
};
|
|
138
|
+
json["dependencies"]["@nocobase/cli"] = context.version;
|
|
139
|
+
if (!this.args.skipDevDependencies) {
|
|
140
|
+
json["devDependencies"] = json["devDependencies"] || {};
|
|
141
|
+
json["devDependencies"]["@nocobase/devtools"] = context.version;
|
|
185
142
|
}
|
|
143
|
+
await fs.writeJSON(join(this.cwd, "package.json"), json, { encoding: "utf8", spaces: 2 });
|
|
186
144
|
console.log("");
|
|
187
145
|
console.log(chalk.green(`$ cd ${name}`));
|
|
188
146
|
console.log(chalk.green(`$ yarn install`));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-nocobase-app",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.23",
|
|
4
4
|
"main": "src/index.js",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"dependencies": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"chalk": "^4.1.1",
|
|
10
10
|
"commander": "^9.2.0",
|
|
11
11
|
"fs-extra": "^11.3.0",
|
|
12
|
-
"tar": "
|
|
12
|
+
"tar": "^7.4.3"
|
|
13
13
|
},
|
|
14
14
|
"bin": {
|
|
15
15
|
"create-nocobase-app": "./bin/index.js"
|
|
@@ -19,5 +19,5 @@
|
|
|
19
19
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
20
20
|
"directory": "packages/core/create-nocobase-app"
|
|
21
21
|
},
|
|
22
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "2ec917c09dc303978bdd33893d27c775d532c8f9"
|
|
23
23
|
}
|
package/src/cli.js
CHANGED
|
@@ -21,7 +21,7 @@ cli
|
|
|
21
21
|
.option('--quickstart', 'quickstart app creation')
|
|
22
22
|
.option('--skip-dev-dependencies')
|
|
23
23
|
.option('-a, --all-db-dialect', 'install all database dialect dependencies')
|
|
24
|
-
.option('-d, --db-dialect
|
|
24
|
+
.option('-d, --db-dialect [dbDialect]', 'database dialect, current support postgres, mysql, mariadb, kingbase')
|
|
25
25
|
.option('-e, --env <env>', 'environment variables write into .env file', concat, [])
|
|
26
26
|
.description('create a new application')
|
|
27
27
|
.action(async (name, options) => {
|
package/src/generator.js
CHANGED
|
@@ -37,21 +37,6 @@ class AppGenerator extends Generator {
|
|
|
37
37
|
return items;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
checkDbEnv() {
|
|
41
|
-
const dialect = this.args.dbDialect;
|
|
42
|
-
const env = this.env;
|
|
43
|
-
if (dialect === 'sqlite') {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
if (!env.DB_DATABASE || !env.DB_USER || !env.DB_PASSWORD) {
|
|
47
|
-
console.log(
|
|
48
|
-
chalk.red(
|
|
49
|
-
`Please set DB_HOST, DB_PORT, DB_DATABASE, DB_USER, DB_PASSWORD in .env file to complete database settings`,
|
|
50
|
-
),
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
40
|
checkProjectPath() {
|
|
56
41
|
if (existsSync(this.cwd)) {
|
|
57
42
|
console.log(chalk.red('Project directory already exists'));
|
|
@@ -59,44 +44,19 @@ class AppGenerator extends Generator {
|
|
|
59
44
|
}
|
|
60
45
|
}
|
|
61
46
|
|
|
62
|
-
checkDialect() {
|
|
63
|
-
const dialect = this.args.dbDialect;
|
|
64
|
-
const supportDialects = ['mysql', 'mariadb', 'sqlite', 'postgres'];
|
|
65
|
-
if (!supportDialects.includes(dialect)) {
|
|
66
|
-
console.log(
|
|
67
|
-
`dialect ${chalk.red(dialect)} is not supported, currently supported dialects are ${chalk.green(
|
|
68
|
-
supportDialects.join(','),
|
|
69
|
-
)}.`,
|
|
70
|
-
);
|
|
71
|
-
process.exit(1);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
47
|
getContext() {
|
|
76
48
|
const env = this.env;
|
|
77
49
|
const envs = [];
|
|
78
50
|
const dependencies = [];
|
|
79
|
-
const { dbDialect
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
dependencies.push(`"pg-hstore": "^2.3.4"`);
|
|
86
|
-
dependencies.push(`"sqlite3": "^5.0.8"`);
|
|
87
|
-
}
|
|
51
|
+
const { dbDialect } = this.args;
|
|
52
|
+
|
|
53
|
+
dependencies.push(`"mysql2": "^3.14.0"`);
|
|
54
|
+
dependencies.push(`"mariadb": "^3.4.1"`);
|
|
55
|
+
dependencies.push(`"pg": "^8.14.1"`);
|
|
56
|
+
dependencies.push(`"pg-hstore": "^2.3.4"`);
|
|
88
57
|
|
|
89
58
|
switch (dbDialect) {
|
|
90
|
-
case 'sqlite':
|
|
91
|
-
if (!allDbDialect) {
|
|
92
|
-
dependencies.push(`"sqlite3": "^5.0.8"`);
|
|
93
|
-
}
|
|
94
|
-
envs.push(`DB_STORAGE=${env.DB_STORAGE || 'storage/db/nocobase.sqlite'}`);
|
|
95
|
-
break;
|
|
96
59
|
case 'mysql':
|
|
97
|
-
if (!allDbDialect) {
|
|
98
|
-
dependencies.push(`"mysql2": "^3.11.0"`);
|
|
99
|
-
}
|
|
100
60
|
envs.push(`DB_HOST=${env.DB_HOST || 'localhost'}`);
|
|
101
61
|
envs.push(`DB_PORT=${env.DB_PORT || 3306}`);
|
|
102
62
|
envs.push(`DB_DATABASE=${env.DB_DATABASE || ''}`);
|
|
@@ -104,9 +64,6 @@ class AppGenerator extends Generator {
|
|
|
104
64
|
envs.push(`DB_PASSWORD=${env.DB_PASSWORD || ''}`);
|
|
105
65
|
break;
|
|
106
66
|
case 'mariadb':
|
|
107
|
-
if (!allDbDialect) {
|
|
108
|
-
dependencies.push(`"mariadb": "^2.5.6"`);
|
|
109
|
-
}
|
|
110
67
|
envs.push(`DB_HOST=${env.DB_HOST || 'localhost'}`);
|
|
111
68
|
envs.push(`DB_PORT=${env.DB_PORT || 3306}`);
|
|
112
69
|
envs.push(`DB_DATABASE=${env.DB_DATABASE || ''}`);
|
|
@@ -115,10 +72,6 @@ class AppGenerator extends Generator {
|
|
|
115
72
|
break;
|
|
116
73
|
case 'kingbase':
|
|
117
74
|
case 'postgres':
|
|
118
|
-
if (!allDbDialect) {
|
|
119
|
-
dependencies.push(`"pg": "^8.7.3"`);
|
|
120
|
-
dependencies.push(`"pg-hstore": "^2.3.4"`);
|
|
121
|
-
}
|
|
122
75
|
envs.push(`DB_HOST=${env.DB_HOST || 'localhost'}`);
|
|
123
76
|
envs.push(`DB_PORT=${env.DB_PORT || 5432}`);
|
|
124
77
|
envs.push(`DB_DATABASE=${env.DB_DATABASE || ''}`);
|
|
@@ -177,28 +130,33 @@ class AppGenerator extends Generator {
|
|
|
177
130
|
|
|
178
131
|
async writing() {
|
|
179
132
|
this.checkProjectPath();
|
|
180
|
-
this.checkDialect();
|
|
181
133
|
|
|
182
134
|
const { name } = this.context;
|
|
183
135
|
|
|
184
136
|
console.log(`Creating a new NocoBase application at ${chalk.green(name)}`);
|
|
185
137
|
console.log('Creating files');
|
|
186
138
|
|
|
139
|
+
const context = this.getContext();
|
|
140
|
+
|
|
187
141
|
this.copyDirectory({
|
|
188
|
-
context
|
|
142
|
+
context,
|
|
189
143
|
path: join(__dirname, '../templates/app'),
|
|
190
144
|
target: this.cwd,
|
|
191
145
|
});
|
|
192
146
|
|
|
193
|
-
|
|
147
|
+
const json = {
|
|
148
|
+
name: context.name,
|
|
149
|
+
...(await fs.readJSON(join(this.cwd, 'package.json'), 'utf8')),
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
json['dependencies']['@nocobase/cli'] = context.version;
|
|
194
153
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
delete json['devDependencies'];
|
|
199
|
-
await fs.writeJSON(join(this.cwd, 'package.json'), json, { encoding: 'utf8', spaces: 2 });
|
|
154
|
+
if (!this.args.skipDevDependencies) {
|
|
155
|
+
json['devDependencies'] = json['devDependencies'] || {};
|
|
156
|
+
json['devDependencies']['@nocobase/devtools'] = context.version;
|
|
200
157
|
}
|
|
201
158
|
|
|
159
|
+
await fs.writeJSON(join(this.cwd, 'package.json'), json, { encoding: 'utf8', spaces: 2 });
|
|
202
160
|
console.log('');
|
|
203
161
|
console.log(chalk.green(`$ cd ${name}`));
|
|
204
162
|
console.log(chalk.green(`$ yarn install`));
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "{{{name}}}",
|
|
3
2
|
"private": true,
|
|
4
3
|
"workspaces": [
|
|
5
4
|
"packages/*/*",
|
|
@@ -28,15 +27,16 @@
|
|
|
28
27
|
"@types/react-dom": "^18.0.0",
|
|
29
28
|
"react-router-dom": "6.28.1",
|
|
30
29
|
"react-router": "6.28.1",
|
|
31
|
-
"async": "3.2.6",
|
|
30
|
+
"async": "^3.2.6",
|
|
32
31
|
"antd": "5.12.8",
|
|
33
|
-
"rollup": "4.24.0"
|
|
32
|
+
"rollup": "4.24.0",
|
|
33
|
+
"semver": "^7.7.1"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
36
|
+
"pm2": "^6.0.5",
|
|
37
|
+
"mysql2": "^3.14.0",
|
|
38
|
+
"mariadb": "^3.4.1",
|
|
39
|
+
"pg": "^8.14.1",
|
|
40
|
+
"pg-hstore": "^2.3.4"
|
|
41
41
|
}
|
|
42
|
-
}
|
|
42
|
+
}
|