@nocobase/cli 2.1.0-alpha.16 → 2.1.0-alpha.18

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.
Files changed (105) hide show
  1. package/LICENSE.txt +107 -0
  2. package/README.md +134 -63
  3. package/bin/run.cmd +3 -0
  4. package/bin/run.js +87 -0
  5. package/dist/commands/api/index.js +8 -0
  6. package/dist/commands/env/add.js +53 -0
  7. package/dist/commands/env/auth.js +36 -0
  8. package/dist/commands/env/index.js +27 -0
  9. package/dist/commands/env/list.js +31 -0
  10. package/dist/commands/env/remove.js +54 -0
  11. package/dist/commands/env/update.js +58 -0
  12. package/dist/commands/env/use.js +26 -0
  13. package/dist/commands/resource/create.js +15 -0
  14. package/dist/commands/resource/destroy.js +15 -0
  15. package/dist/commands/resource/get.js +15 -0
  16. package/dist/commands/resource/index.js +7 -0
  17. package/dist/commands/resource/list.js +16 -0
  18. package/dist/commands/resource/query.js +15 -0
  19. package/dist/commands/resource/update.js +15 -0
  20. package/dist/generated/command-registry.js +88 -0
  21. package/dist/lib/api-client.js +199 -0
  22. package/dist/lib/auth-store.js +155 -0
  23. package/dist/lib/bootstrap.js +349 -0
  24. package/dist/lib/build-config.js +10 -0
  25. package/dist/lib/cli-home.js +30 -0
  26. package/dist/lib/env-auth.js +405 -0
  27. package/dist/lib/generated-command.js +142 -0
  28. package/dist/lib/naming.js +70 -0
  29. package/dist/lib/openapi.js +254 -0
  30. package/dist/lib/post-processors.js +23 -0
  31. package/dist/lib/resource-command.js +335 -0
  32. package/dist/lib/resource-request.js +104 -0
  33. package/dist/lib/runtime-generator.js +408 -0
  34. package/dist/lib/runtime-store.js +56 -0
  35. package/dist/lib/ui.js +169 -0
  36. package/dist/post-processors/data-modeling.js +66 -0
  37. package/dist/post-processors/data-source-manager.js +114 -0
  38. package/dist/post-processors/index.js +19 -0
  39. package/nocobase-ctl.config.json +327 -0
  40. package/package.json +50 -25
  41. package/LICENSE +0 -201
  42. package/bin/index.js +0 -39
  43. package/nocobase.conf.tpl +0 -184
  44. package/src/cli.js +0 -28
  45. package/src/commands/benchmark.js +0 -73
  46. package/src/commands/build.js +0 -81
  47. package/src/commands/clean.js +0 -30
  48. package/src/commands/client.js +0 -168
  49. package/src/commands/create-nginx-conf.js +0 -53
  50. package/src/commands/create-plugin.js +0 -33
  51. package/src/commands/dev.js +0 -290
  52. package/src/commands/doc.js +0 -76
  53. package/src/commands/e2e.js +0 -265
  54. package/src/commands/global.js +0 -43
  55. package/src/commands/index.js +0 -45
  56. package/src/commands/instance-id.js +0 -47
  57. package/src/commands/locale/cronstrue.js +0 -122
  58. package/src/commands/locale/react-js-cron/en-US.json +0 -75
  59. package/src/commands/locale/react-js-cron/index.js +0 -17
  60. package/src/commands/locale/react-js-cron/zh-CN.json +0 -33
  61. package/src/commands/locale/react-js-cron/zh-TW.json +0 -33
  62. package/src/commands/locale.js +0 -81
  63. package/src/commands/p-test.js +0 -88
  64. package/src/commands/perf.js +0 -63
  65. package/src/commands/pkg.js +0 -321
  66. package/src/commands/pm2.js +0 -37
  67. package/src/commands/postinstall.js +0 -88
  68. package/src/commands/start.js +0 -148
  69. package/src/commands/tar.js +0 -36
  70. package/src/commands/test-coverage.js +0 -55
  71. package/src/commands/test.js +0 -107
  72. package/src/commands/umi.js +0 -33
  73. package/src/commands/update-deps.js +0 -72
  74. package/src/commands/upgrade.js +0 -47
  75. package/src/commands/view-license-key.js +0 -44
  76. package/src/index.js +0 -14
  77. package/src/license.js +0 -76
  78. package/src/logger.js +0 -75
  79. package/src/plugin-generator.js +0 -80
  80. package/src/util.js +0 -607
  81. package/templates/bundle-status.html +0 -338
  82. package/templates/create-app-package.json +0 -39
  83. package/templates/plugin/.npmignore.tpl +0 -2
  84. package/templates/plugin/README.md.tpl +0 -1
  85. package/templates/plugin/client-v2.d.ts +0 -2
  86. package/templates/plugin/client-v2.js +0 -1
  87. package/templates/plugin/client.d.ts +0 -2
  88. package/templates/plugin/client.js +0 -1
  89. package/templates/plugin/package.json.tpl +0 -12
  90. package/templates/plugin/server.d.ts +0 -2
  91. package/templates/plugin/server.js +0 -1
  92. package/templates/plugin/src/client/client.d.ts +0 -249
  93. package/templates/plugin/src/client/index.tsx.tpl +0 -1
  94. package/templates/plugin/src/client/locale.ts +0 -21
  95. package/templates/plugin/src/client/models/index.ts +0 -12
  96. package/templates/plugin/src/client/plugin.tsx.tpl +0 -10
  97. package/templates/plugin/src/client-v2/client.d.ts +0 -103
  98. package/templates/plugin/src/client-v2/index.tsx.tpl +0 -1
  99. package/templates/plugin/src/client-v2/plugin.tsx.tpl +0 -7
  100. package/templates/plugin/src/index.ts +0 -2
  101. package/templates/plugin/src/locale/en-US.json +0 -1
  102. package/templates/plugin/src/locale/zh-CN.json +0 -1
  103. package/templates/plugin/src/server/collections/.gitkeep +0 -0
  104. package/templates/plugin/src/server/index.ts.tpl +0 -1
  105. package/templates/plugin/src/server/plugin.ts.tpl +0 -19
package/src/license.js DELETED
@@ -1,76 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- const chalk = require('chalk');
11
- const { resolve } = require('path');
12
- const fs = require('fs-extra');
13
- const { keyDecrypt, getEnvAsync } = require('@nocobase/license-kit');
14
- const { isEnvMatch } = require('@nocobase/plugin-license/utils/env');
15
- const { logger } = require('./logger');
16
- const { pick } = require('lodash');
17
-
18
- exports.getAccessKeyPair = async function () {
19
- const keyFile = resolve(process.cwd(), 'storage/.license/license-key');
20
- if (!fs.existsSync(keyFile)) {
21
- logger.info('License key not found');
22
- return {};
23
- }
24
- logger.info('License key found');
25
- let keyData = {};
26
- try {
27
- const str = fs.readFileSync(keyFile, 'utf-8');
28
- const keyDataStr = keyDecrypt(str);
29
- keyData = JSON.parse(keyDataStr);
30
- } catch (error) {
31
- showLicenseInfo(LicenseKeyError.parseFailed);
32
- throw new Error(LicenseKeyError.parseFailed.title);
33
- }
34
- const env = await getEnvAsync();
35
- const isEnvMatched = await isEnvMatch(env, keyData);
36
- if (!isEnvMatched) {
37
- showLicenseInfo({
38
- ...LicenseKeyError.notMatch,
39
- env,
40
- });
41
- throw new Error(LicenseKeyError.notMatch.title);
42
- }
43
- const { accessKeyId, accessKeySecret } = keyData;
44
- return { accessKeyId, accessKeySecret };
45
- };
46
-
47
- const LicenseKeyError = {
48
- notExist: {
49
- title: 'License key not found',
50
- content:
51
- 'Please go to the license settings page to obtain the Instance ID for the current environment, and then generate the license key on the service platform.',
52
- },
53
- parseFailed: {
54
- title: 'Invalid license key format',
55
- content: 'Please check your license key, or regenerate the license key on the service platform.',
56
- },
57
- notMatch: {
58
- title: 'License key not match current environment',
59
- content:
60
- 'Please go to the license settings page to obtain the Instance ID for the current environment, and then regenerate the license key on the service platform.',
61
- },
62
- notValid: {
63
- title: 'Invalid license key',
64
- content:
65
- 'Please go to the license settings page to obtain the Instance ID for the current environment, and then regenerate the license key on the service platform.',
66
- },
67
- };
68
-
69
- exports.LicenseKeyError = LicenseKeyError;
70
-
71
- function showLicenseInfo({ title, content, env }) {
72
- logger.error(title + '. ' + content);
73
- logger.error('Current environment', pick(env, ['sys', 'osVer', 'db']));
74
- }
75
-
76
- exports.showLicenseInfo = showLicenseInfo;
package/src/logger.js DELETED
@@ -1,75 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- const fs = require('fs');
11
- const path = require('path');
12
- const winston = require('winston');
13
- require('winston-daily-rotate-file');
14
-
15
- function ensureDir(dir) {
16
- if (!fs.existsSync(dir)) {
17
- fs.mkdirSync(dir, { recursive: true });
18
- }
19
- }
20
-
21
- function createSystemLogger({ dirname, filename, defaultMeta = {} }) {
22
- ensureDir(dirname);
23
-
24
- const commonFormat = winston.format.combine(
25
- winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
26
- winston.format.printf((info) => {
27
- const meta = info.meta ? JSON.stringify(info.meta) : '';
28
- return `${info.timestamp} [${info.level}] ${info.message} ${meta}`;
29
- }),
30
- );
31
-
32
- const consoleFormat = winston.format.combine(winston.format.colorize(), commonFormat);
33
-
34
- const fileTransport = new winston.transports.DailyRotateFile({
35
- dirname,
36
- filename: `${filename}_%DATE%.log`,
37
- datePattern: 'YYYY-MM-DD',
38
- zippedArchive: false,
39
- format: commonFormat,
40
- });
41
-
42
- const consoleTransport = new winston.transports.Console({
43
- format: consoleFormat,
44
- });
45
-
46
- const logger = winston.createLogger({
47
- level: 'info',
48
- transports: [consoleTransport, fileTransport],
49
- defaultMeta,
50
- });
51
-
52
- const wrap = (level) => (message, meta) => {
53
- logger.log({ level, message, meta });
54
- return logger;
55
- };
56
-
57
- return {
58
- info: wrap('info'),
59
- warn: wrap('warn'),
60
- error: wrap('error'),
61
- };
62
- }
63
-
64
- const getLoggerFilePath = (...paths) => {
65
- return path.resolve(process.env.LOGGER_BASE_PATH || path.resolve(process.cwd(), 'storage', 'logs'), ...paths);
66
- };
67
-
68
- const logger = createSystemLogger({
69
- dirname: getLoggerFilePath('main'),
70
- filename: 'system',
71
- });
72
-
73
- module.exports = {
74
- logger,
75
- };
@@ -1,80 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- const chalk = require('chalk');
11
- const { existsSync } = require('fs');
12
- const { join, resolve } = require('path');
13
- const { Generator } = require('@umijs/utils');
14
- const { readFile, writeFile } = require('fs').promises;
15
- const { genTsConfigPaths } = require('./util');
16
-
17
- const execa = require('execa');
18
-
19
- function camelize(str) {
20
- return str.trim().replace(/[-_\s]+(.)?/g, (match, c) => c.toUpperCase());
21
- }
22
-
23
- function capitalize(string) {
24
- return string.charAt(0).toUpperCase() + string.slice(1);
25
- }
26
-
27
- async function getProjectName() {
28
- const content = await readFile(resolve(process.cwd(), 'package.json'), 'utf-8');
29
- const json = JSON.parse(content);
30
- return json.name;
31
- }
32
-
33
- async function getProjectVersion() {
34
- const content = await readFile(resolve(process.cwd(), 'lerna.json'), 'utf-8');
35
- const json = JSON.parse(content);
36
- return json.version || '0.1.0';
37
- }
38
-
39
- class PluginGenerator extends Generator {
40
- constructor(options) {
41
- const { log, context = {}, ...opts } = options;
42
- super(opts);
43
- this.context = context;
44
- this.log = log || console.log;
45
- }
46
-
47
- async getContext() {
48
- const { name } = this.context;
49
- const nocobaseVersion = require('@nocobase/server/package.json').version;
50
- const packageVersion = await getProjectVersion();
51
- return {
52
- ...this.context,
53
- packageName: name,
54
- packageVersion,
55
- nocobaseVersion,
56
- pascalCaseName: capitalize(camelize(name.split('/').pop())),
57
- };
58
- }
59
-
60
- async writing() {
61
- const { name } = this.context;
62
- const target = resolve(process.cwd(), 'packages/plugins/', name);
63
- if (existsSync(target)) {
64
- this.log(chalk.red(`[${name}] plugin already exists.`));
65
- return;
66
- }
67
- this.log('Creating plugin');
68
- this.copyDirectory({
69
- target,
70
- context: await this.getContext(),
71
- path: join(__dirname, '../templates/plugin'),
72
- });
73
- this.log('');
74
- genTsConfigPaths();
75
- execa.sync('yarn', ['postinstall'], { shell: true, stdio: 'inherit' });
76
- this.log(`The plugin folder is in ${chalk.green(`packages/plugins/${name}`)}`);
77
- }
78
- }
79
-
80
- exports.PluginGenerator = PluginGenerator;