@nocobase/cli 0.7.7-alpha.1 → 0.8.0-alpha.2

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/bin/index.js CHANGED
@@ -15,6 +15,7 @@ const env = {
15
15
  DB_TIMEZONE: '+00:00',
16
16
  DEFAULT_STORAGE_TYPE: 'local',
17
17
  LOCAL_STORAGE_DEST: 'storage/uploads',
18
+ MFSU_AD: 'none',
18
19
  };
19
20
 
20
21
  if (!process.env.APP_ENV_PATH && process.argv[2] && process.argv[2] === 'test') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/cli",
3
- "version": "0.7.7-alpha.1",
3
+ "version": "0.8.0-alpha.2",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "licenses": [
@@ -23,12 +23,12 @@
23
23
  "serve": "^13.0.2"
24
24
  },
25
25
  "devDependencies": {
26
- "@nocobase/devtools": "0.7.7-alpha.1"
26
+ "@nocobase/devtools": "0.8.0-alpha.2"
27
27
  },
28
28
  "repository": {
29
29
  "type": "git",
30
30
  "url": "git+https://github.com/nocobase/nocobase.git",
31
31
  "directory": "packages/core/cli"
32
32
  },
33
- "gitHead": "f82374e6f9daaf71ba63eaf156468ea7ddc042da"
33
+ "gitHead": "03b3fe7e826f3bba2b2f178dbed245a941d8eb7b"
34
34
  }
@@ -1,5 +1,5 @@
1
1
  const { Command } = require('commander');
2
- const { run, isDev, promptForTs } = require('../util');
2
+ const { run, isDev, isProd, promptForTs } = require('../util');
3
3
 
4
4
  /**
5
5
  *
@@ -23,7 +23,7 @@ module.exports = (cli) => {
23
23
  `./packages/${APP_PACKAGE_ROOT}/server/src/index.ts`,
24
24
  ...process.argv.slice(2),
25
25
  ]);
26
- } else {
26
+ } else if (isProd()) {
27
27
  run('node', [`./packages/${APP_PACKAGE_ROOT}/server/lib/index.js`, ...process.argv.slice(2)]);
28
28
  }
29
29
  });
@@ -15,17 +15,17 @@ module.exports = (cli) => {
15
15
  .option('--raw')
16
16
  .option('-S|--skip-code-update')
17
17
  .action(async (options) => {
18
- promptForTs();
19
- if (options.skipCodeUpdate) {
20
- await runAppCommand('upgrade');
18
+ if (!hasTsNode()) {
21
19
  return;
22
20
  }
21
+ promptForTs();
23
22
  if (hasCorePackages()) {
24
- await run('yarn', ['install']);
23
+ // await run('yarn', ['install']);
25
24
  await runAppCommand('upgrade');
26
25
  return;
27
26
  }
28
- if (!hasTsNode()) {
27
+ if (options.skipCodeUpdate) {
28
+ await runAppCommand('upgrade');
29
29
  return;
30
30
  }
31
31
  const version = await getVersion();
@@ -34,11 +34,13 @@ class PluginGenerator extends Generator {
34
34
  async getContext() {
35
35
  const { name } = this.context;
36
36
  const packageName = await getProjectName();
37
+ const nocobaseVersion = require('@nocobase/server/package.json').version;
37
38
  const packageVersion = await getProjectVersion();
38
39
  return {
39
40
  ...this.context,
40
- packageName: `@${packageName}/${name}`,
41
- packageVersion: packageVersion,
41
+ packageName: `@${packageName}/plugin-${name}`,
42
+ packageVersion,
43
+ nocobaseVersion,
42
44
  pascalCaseName: capitalize(camelize(name)),
43
45
  };
44
46
  }
package/src/util.js CHANGED
@@ -30,11 +30,26 @@ exports.isDev = function isDev() {
30
30
  return exports.hasTsNode();
31
31
  };
32
32
 
33
+ const isProd = () => {
34
+ const { APP_PACKAGE_ROOT } = process.env;
35
+ const file = `./packages/${APP_PACKAGE_ROOT}/server/lib/index.js`;
36
+ if (!existsSync(resolve(process.cwd(), file))) {
37
+ console.log('For production environment, please build the code first.');
38
+ console.log();
39
+ console.log(chalk.yellow('$ yarn build'));
40
+ console.log();
41
+ process.exit(1);
42
+ }
43
+ return true;
44
+ };
45
+
46
+ exports.isProd = isProd;
47
+
33
48
  exports.nodeCheck = () => {
34
49
  if (!exports.hasTsNode()) {
35
50
  console.log('Please install all dependencies');
36
51
  console.log(chalk.yellow('$ yarn install'));
37
- process.exit(0);
52
+ process.exit(1);
38
53
  }
39
54
  };
40
55
 
@@ -100,8 +115,9 @@ exports.runInstall = async () => {
100
115
  '-s',
101
116
  ];
102
117
  await exports.run('ts-node', argv);
103
- } else {
104
- const argv = [`./packages/${APP_PACKAGE_ROOT}/server/lib/index.js`, 'install', '-s'];
118
+ } else if (isProd()) {
119
+ const file = `./packages/${APP_PACKAGE_ROOT}/server/lib/index.js`;
120
+ const argv = [file, 'install', '-s'];
105
121
  await exports.run('node', argv);
106
122
  }
107
123
  };
@@ -120,7 +136,7 @@ exports.runAppCommand = async (command, args = []) => {
120
136
  ...args,
121
137
  ];
122
138
  await exports.run('ts-node', argv);
123
- } else {
139
+ } else if (isProd()) {
124
140
  const argv = [`./packages/${APP_PACKAGE_ROOT}/server/lib/index.js`, command, ...args];
125
141
  await exports.run('node', argv);
126
142
  }
@@ -2,9 +2,8 @@
2
2
  "name": "{{{packageName}}}",
3
3
  "version": "{{{packageVersion}}}",
4
4
  "main": "lib/server/index.js",
5
- "dependencies": {},
6
- "peerDependencies": {
7
- "@nocobase/server": "*",
8
- "@nocobase/test": "*"
5
+ "devDependencies": {
6
+ "@nocobase/server": "{{{nocobaseVersion}}}",
7
+ "@nocobase/test": "{{{nocobaseVersion}}}"
9
8
  }
10
9
  }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+
3
+ export default React.memo((props) => {
4
+ return <>{props.children}</>;
5
+ });
@@ -1,32 +1 @@
1
- import { InstallOptions, Plugin } from '@nocobase/server';
2
-
3
- export class {{{pascalCaseName}}}Plugin extends Plugin {
4
- getName(): string {
5
- return this.getPackageName(__dirname);
6
- }
7
-
8
- beforeLoad() {
9
- // TODO
10
- }
11
-
12
- async load() {
13
- // TODO
14
- // Visit: http://localhost:13000/api/test{{{pascalCaseName}}}:getInfo
15
- this.app.resource({
16
- name: 'test{{{pascalCaseName}}}',
17
- actions: {
18
- async getInfo(ctx, next) {
19
- ctx.body = `Hello {{{name}}}!`;
20
- next();
21
- },
22
- },
23
- });
24
- this.app.acl.allow('test{{{pascalCaseName}}}', 'getInfo');
25
- }
26
-
27
- async install(options: InstallOptions) {
28
- // TODO
29
- }
30
- }
31
-
32
- export default {{{pascalCaseName}}}Plugin;
1
+ export { default } from './plugin';
@@ -0,0 +1,19 @@
1
+ import { InstallOptions, Plugin } from '@nocobase/server';
2
+
3
+ export class {{{pascalCaseName}}}Plugin extends Plugin {
4
+ afterAdd() {}
5
+
6
+ beforeLoad() {}
7
+
8
+ async load() {}
9
+
10
+ async install(options?: InstallOptions) {}
11
+
12
+ async afterEnable() {}
13
+
14
+ async afterDisable() {}
15
+
16
+ async remove() {}
17
+ }
18
+
19
+ export default {{{pascalCaseName}}}Plugin;
@@ -1 +0,0 @@
1
- // TODO
File without changes
File without changes
File without changes