create-nocobase-app 1.6.22 → 1.6.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/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 <dbDialect>", "database dialect, current support mysql/postgres", "postgres").option("-e, --env <env>", "environment variables write into .env file", concat, []).description("create a new application").action(async (name, options) => {
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,38 +36,12 @@ 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", "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 = [];
@@ -148,22 +122,25 @@ const _AppGenerator = class _AppGenerator extends Generator {
148
122
  }
149
123
  async writing() {
150
124
  this.checkProjectPath();
151
- this.checkDialect();
152
125
  const { name } = this.context;
153
126
  console.log(`Creating a new NocoBase application at ${chalk.green(name)}`);
154
127
  console.log("Creating files");
128
+ const context = this.getContext();
155
129
  this.copyDirectory({
156
- context: this.getContext(),
130
+ context,
157
131
  path: join(__dirname, "../templates/app"),
158
132
  target: this.cwd
159
133
  });
160
- this.checkDbEnv();
161
- const skipDevDependencies = this.args.skipDevDependencies;
162
- if (skipDevDependencies) {
163
- const json = await fs.readJSON(join(this.cwd, "package.json"), "utf8");
164
- delete json["devDependencies"];
165
- await fs.writeJSON(join(this.cwd, "package.json"), json, { encoding: "utf8", spaces: 2 });
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;
166
142
  }
143
+ await fs.writeJSON(join(this.cwd, "package.json"), json, { encoding: "utf8", spaces: 2 });
167
144
  console.log("");
168
145
  console.log(chalk.green(`$ cd ${name}`));
169
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.22",
3
+ "version": "1.6.24",
4
4
  "main": "src/index.js",
5
5
  "license": "AGPL-3.0",
6
6
  "dependencies": {
@@ -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": "321c0effa18670c0c3edfa09c79d535351ef2b0d"
22
+ "gitHead": "d453b271bc1dedb56af2252dcb5d1a3ab9828ca1"
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 <dbDialect>', 'database dialect, current support mysql/postgres', 'postgres')
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,19 +44,6 @@ class AppGenerator extends Generator {
59
44
  }
60
45
  }
61
46
 
62
- checkDialect() {
63
- const dialect = this.args.dbDialect;
64
- const supportDialects = ['mysql', 'mariadb', '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 = [];
@@ -158,28 +130,33 @@ class AppGenerator extends Generator {
158
130
 
159
131
  async writing() {
160
132
  this.checkProjectPath();
161
- this.checkDialect();
162
133
 
163
134
  const { name } = this.context;
164
135
 
165
136
  console.log(`Creating a new NocoBase application at ${chalk.green(name)}`);
166
137
  console.log('Creating files');
167
138
 
139
+ const context = this.getContext();
140
+
168
141
  this.copyDirectory({
169
- context: this.getContext(),
142
+ context,
170
143
  path: join(__dirname, '../templates/app'),
171
144
  target: this.cwd,
172
145
  });
173
146
 
174
- this.checkDbEnv();
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;
175
153
 
176
- const skipDevDependencies = this.args.skipDevDependencies;
177
- if (skipDevDependencies) {
178
- const json = await fs.readJSON(join(this.cwd, 'package.json'), 'utf8');
179
- delete json['devDependencies'];
180
- 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;
181
157
  }
182
158
 
159
+ await fs.writeJSON(join(this.cwd, 'package.json'), json, { encoding: 'utf8', spaces: 2 });
183
160
  console.log('');
184
161
  console.log(chalk.green(`$ cd ${name}`));
185
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/*/*",
@@ -34,11 +33,10 @@
34
33
  "semver": "^7.7.1"
35
34
  },
36
35
  "dependencies": {
37
- "@nocobase/cli": "{{{version}}}",
38
36
  "pm2": "^6.0.5",
39
- {{{dependencies}}}
40
- },
41
- "devDependencies": {
42
- "@nocobase/devtools": "{{{version}}}"
37
+ "mysql2": "^3.14.0",
38
+ "mariadb": "^3.4.1",
39
+ "pg": "^8.14.1",
40
+ "pg-hstore": "^2.3.4"
43
41
  }
44
- }
42
+ }