@nocobase/cli 1.7.0-beta.21 → 1.7.0-beta.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/package.json +4 -4
- package/src/commands/index.js +1 -0
- package/src/commands/update-deps.js +71 -0
- package/src/commands/upgrade.js +3 -46
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/cli",
|
|
3
|
-
"version": "1.7.0-beta.
|
|
3
|
+
"version": "1.7.0-beta.23",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"nocobase": "./bin/index.js"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@nocobase/app": "1.7.0-beta.
|
|
11
|
+
"@nocobase/app": "1.7.0-beta.23",
|
|
12
12
|
"@types/fs-extra": "^11.0.1",
|
|
13
13
|
"@umijs/utils": "3.5.20",
|
|
14
14
|
"chalk": "^4.1.1",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"tsx": "^4.19.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@nocobase/devtools": "1.7.0-beta.
|
|
29
|
+
"@nocobase/devtools": "1.7.0-beta.23"
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
33
33
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
34
34
|
"directory": "packages/core/cli"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "0c9581f3d38bbf9f93c68d232a48ffa4e7d68390"
|
|
37
37
|
}
|
package/src/commands/index.js
CHANGED
|
@@ -0,0 +1,71 @@
|
|
|
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 { Command } = require('commander');
|
|
12
|
+
const { resolve } = require('path');
|
|
13
|
+
const { run, promptForTs, runAppCommand, hasCorePackages, downloadPro, hasTsNode, checkDBDialect } = require('../util');
|
|
14
|
+
const { existsSync, rmSync } = require('fs');
|
|
15
|
+
const { readJSON, writeJSON } = require('fs-extra');
|
|
16
|
+
const deepmerge = require('deepmerge');
|
|
17
|
+
|
|
18
|
+
const rmAppDir = () => {
|
|
19
|
+
// If ts-node is not installed, do not do the following
|
|
20
|
+
const appDevDir = resolve(process.cwd(), './storage/.app-dev');
|
|
21
|
+
if (existsSync(appDevDir)) {
|
|
22
|
+
rmSync(appDevDir, { recursive: true, force: true });
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @param {Command} cli
|
|
29
|
+
*/
|
|
30
|
+
module.exports = (cli) => {
|
|
31
|
+
cli
|
|
32
|
+
.command('update-deps')
|
|
33
|
+
.option('--force')
|
|
34
|
+
.allowUnknownOption()
|
|
35
|
+
.action(async (options) => {
|
|
36
|
+
if (hasCorePackages() || !hasTsNode()) {
|
|
37
|
+
await downloadPro();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const pkg = require('../../package.json');
|
|
41
|
+
let distTag = 'latest';
|
|
42
|
+
if (pkg.version.includes('alpha')) {
|
|
43
|
+
distTag = 'alpha';
|
|
44
|
+
} else if (pkg.version.includes('beta')) {
|
|
45
|
+
distTag = 'beta';
|
|
46
|
+
}
|
|
47
|
+
const { stdout } = await run('npm', ['info', `@nocobase/cli@${distTag}`, 'version'], {
|
|
48
|
+
stdio: 'pipe',
|
|
49
|
+
});
|
|
50
|
+
if (!options.force && pkg.version === stdout) {
|
|
51
|
+
await downloadPro();
|
|
52
|
+
rmAppDir();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const descPath = resolve(process.cwd(), 'package.json');
|
|
56
|
+
const descJson = await readJSON(descPath, 'utf8');
|
|
57
|
+
const sourcePath = resolve(__dirname, '../../templates/create-app-package.json');
|
|
58
|
+
const sourceJson = await readJSON(sourcePath, 'utf8');
|
|
59
|
+
if (descJson['dependencies']?.['@nocobase/cli']) {
|
|
60
|
+
descJson['dependencies']['@nocobase/cli'] = stdout;
|
|
61
|
+
}
|
|
62
|
+
if (descJson['devDependencies']?.['@nocobase/devtools']) {
|
|
63
|
+
descJson['devDependencies']['@nocobase/devtools'] = stdout;
|
|
64
|
+
}
|
|
65
|
+
const json = deepmerge(descJson, sourceJson);
|
|
66
|
+
await writeJSON(descPath, json, { spaces: 2, encoding: 'utf8' });
|
|
67
|
+
await run('yarn', ['install']);
|
|
68
|
+
await downloadPro();
|
|
69
|
+
rmAppDir();
|
|
70
|
+
});
|
|
71
|
+
};
|
package/src/commands/upgrade.js
CHANGED
|
@@ -29,7 +29,6 @@ async function updatePackage() {
|
|
|
29
29
|
* @param {Command} cli
|
|
30
30
|
*/
|
|
31
31
|
module.exports = (cli) => {
|
|
32
|
-
const { APP_PACKAGE_ROOT } = process.env;
|
|
33
32
|
cli
|
|
34
33
|
.command('upgrade')
|
|
35
34
|
.allowUnknownOption()
|
|
@@ -38,53 +37,11 @@ module.exports = (cli) => {
|
|
|
38
37
|
.option('-S|--skip-code-update')
|
|
39
38
|
.action(async (options) => {
|
|
40
39
|
checkDBDialect();
|
|
41
|
-
if (hasTsNode()) promptForTs();
|
|
42
|
-
if (hasCorePackages()) {
|
|
43
|
-
// await run('yarn', ['install']);
|
|
44
|
-
await downloadPro();
|
|
45
|
-
await runAppCommand('upgrade');
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
40
|
if (options.skipCodeUpdate) {
|
|
49
|
-
await downloadPro();
|
|
50
|
-
await runAppCommand('upgrade');
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
// await runAppCommand('upgrade');
|
|
54
|
-
if (!hasTsNode()) {
|
|
55
|
-
await downloadPro();
|
|
56
|
-
await runAppCommand('upgrade');
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const rmAppDir = () => {
|
|
60
|
-
// If ts-node is not installed, do not do the following
|
|
61
|
-
const appDevDir = resolve(process.cwd(), './storage/.app-dev');
|
|
62
|
-
if (existsSync(appDevDir)) {
|
|
63
|
-
rmSync(appDevDir, { recursive: true, force: true });
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
const pkg = require('../../package.json');
|
|
67
|
-
let distTag = 'latest';
|
|
68
|
-
if (pkg.version.includes('alpha')) {
|
|
69
|
-
distTag = 'alpha';
|
|
70
|
-
} else if (pkg.version.includes('beta')) {
|
|
71
|
-
distTag = 'beta';
|
|
72
|
-
}
|
|
73
|
-
// get latest version
|
|
74
|
-
const { stdout } = await run('npm', ['info', `@nocobase/cli@${distTag}`, 'version'], {
|
|
75
|
-
stdio: 'pipe',
|
|
76
|
-
});
|
|
77
|
-
if (pkg.version === stdout) {
|
|
78
|
-
await downloadPro();
|
|
79
41
|
await runAppCommand('upgrade');
|
|
80
|
-
|
|
81
|
-
|
|
42
|
+
} else {
|
|
43
|
+
await run('nocobase', ['update-deps']);
|
|
44
|
+
await run('nocobase', ['upgrade', '--skip-code-update']);
|
|
82
45
|
}
|
|
83
|
-
await run('yarn', ['add', `@nocobase/cli@${distTag}`, `@nocobase/devtools@${distTag}`, '-W']);
|
|
84
|
-
await updatePackage();
|
|
85
|
-
await run('yarn', ['install']);
|
|
86
|
-
await downloadPro();
|
|
87
|
-
await runAppCommand('upgrade');
|
|
88
|
-
await rmAppDir();
|
|
89
46
|
});
|
|
90
47
|
};
|