@nocobase/cli 1.5.0-beta.1 → 1.6.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/nocobase.conf.tpl +1 -0
- package/package.json +4 -4
- package/src/commands/pkg.js +33 -10
package/nocobase.conf.tpl
CHANGED
|
@@ -70,6 +70,7 @@ server {
|
|
|
70
70
|
proxy_http_version 1.1;
|
|
71
71
|
proxy_set_header Upgrade $http_upgrade;
|
|
72
72
|
proxy_set_header Connection 'upgrade';
|
|
73
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
73
74
|
proxy_set_header Host $host;
|
|
74
75
|
add_header Cache-Control 'no-cache, no-store';
|
|
75
76
|
proxy_cache_bypass $http_upgrade;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0-alpha.2",
|
|
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.
|
|
11
|
+
"@nocobase/app": "1.6.0-alpha.2",
|
|
12
12
|
"@types/fs-extra": "^11.0.1",
|
|
13
13
|
"@umijs/utils": "3.5.20",
|
|
14
14
|
"chalk": "^4.1.1",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"tsx": "^4.19.0"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@nocobase/devtools": "1.
|
|
28
|
+
"@nocobase/devtools": "1.6.0-alpha.2"
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
31
31
|
"type": "git",
|
|
32
32
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
33
33
|
"directory": "packages/core/cli"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "08bbc34c21727fc0ad0880f397a42bf7741091ee"
|
|
36
36
|
}
|
package/src/commands/pkg.js
CHANGED
|
@@ -58,14 +58,16 @@ class Package {
|
|
|
58
58
|
return [version, this.data.versions[version].dist.tarball];
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
version =
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
const keys = version.split('.');
|
|
62
|
+
const length = keys.length;
|
|
63
|
+
|
|
64
|
+
if (version.includes('rc')) {
|
|
65
|
+
version = version.split('-').shift();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (length === 5) {
|
|
69
|
+
keys.pop();
|
|
70
|
+
version = keys.join('.');
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
if (version === 'latest') {
|
|
@@ -93,11 +95,25 @@ class Package {
|
|
|
93
95
|
return false;
|
|
94
96
|
}
|
|
95
97
|
|
|
98
|
+
async isDownloaded(version) {
|
|
99
|
+
const packageFile = path.resolve(process.env.PLUGIN_STORAGE_PATH, this.packageName, 'package.json');
|
|
100
|
+
if (await fs.exists(packageFile)) {
|
|
101
|
+
const json = await fs.readJson(packageFile);
|
|
102
|
+
if (json.version === version) {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
|
|
96
109
|
async download(options = {}) {
|
|
97
110
|
if (await this.isDevPackage()) {
|
|
98
111
|
console.log(chalk.yellowBright(`Skipped: ${this.packageName} is dev package`));
|
|
99
112
|
return;
|
|
100
113
|
}
|
|
114
|
+
if (await this.isDownloaded(options.version)) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
101
117
|
await this.getInfo();
|
|
102
118
|
if (!this.data) {
|
|
103
119
|
console.log(chalk.redBright(`Download failed: ${this.packageName} package does not exist`));
|
|
@@ -105,6 +121,9 @@ class Package {
|
|
|
105
121
|
}
|
|
106
122
|
try {
|
|
107
123
|
const [version, url] = this.getTarball(options.version);
|
|
124
|
+
if (await this.isDownloaded(version)) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
108
127
|
const response = await axios({
|
|
109
128
|
url,
|
|
110
129
|
responseType: 'stream',
|
|
@@ -200,8 +219,12 @@ module.exports = (cli) => {
|
|
|
200
219
|
.command('download-pro')
|
|
201
220
|
.option('-V, --version [version]')
|
|
202
221
|
.action(async () => {
|
|
203
|
-
const {
|
|
204
|
-
|
|
222
|
+
const {
|
|
223
|
+
NOCOBASE_PKG_URL = 'https://pkg.nocobase.com/',
|
|
224
|
+
NOCOBASE_PKG_USERNAME,
|
|
225
|
+
NOCOBASE_PKG_PASSWORD,
|
|
226
|
+
} = process.env;
|
|
227
|
+
if (!(NOCOBASE_PKG_USERNAME && NOCOBASE_PKG_PASSWORD)) {
|
|
205
228
|
return;
|
|
206
229
|
}
|
|
207
230
|
const credentials = { username: NOCOBASE_PKG_USERNAME, password: NOCOBASE_PKG_PASSWORD };
|