@saltcorn/cli 1.1.0-beta.9 → 1.1.1-beta.0
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/README.md +77 -54
- package/npm-shrinkwrap.json +1369 -866
- package/oclif.manifest.json +45 -6
- package/package.json +8 -8
- package/src/commands/backup.js +31 -0
- package/src/commands/build-app.js +3 -3
- package/src/commands/build-capacitor-builder.js +64 -0
- package/src/commands/dev/release-resume.js +218 -0
- package/src/commands/dev/release.js +53 -33
- package/src/commands/restore.js +27 -0
- package/src/commands/sync-upload-data.js +1 -1
- package/src/commands/build-cordova-builder.js +0 -50
package/oclif.manifest.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.1.
|
|
2
|
+
"version": "1.1.1-beta.0",
|
|
3
3
|
"commands": {
|
|
4
4
|
"add-schema": {
|
|
5
5
|
"id": "add-schema",
|
|
@@ -53,6 +53,13 @@
|
|
|
53
53
|
"description": "Backup tenant in saltcorn zip format",
|
|
54
54
|
"multiple": false
|
|
55
55
|
},
|
|
56
|
+
"all_tenants": {
|
|
57
|
+
"name": "all_tenants",
|
|
58
|
+
"type": "boolean",
|
|
59
|
+
"char": "a",
|
|
60
|
+
"description": "Backup all tenants in saltcorn zip format",
|
|
61
|
+
"allowNo": false
|
|
62
|
+
},
|
|
56
63
|
"zip": {
|
|
57
64
|
"name": "zip",
|
|
58
65
|
"type": "boolean",
|
|
@@ -163,7 +170,7 @@
|
|
|
163
170
|
"appVersion": {
|
|
164
171
|
"name": "appVersion",
|
|
165
172
|
"type": "option",
|
|
166
|
-
"description": "Version of the mobile app (default
|
|
173
|
+
"description": "Version of the mobile app (default 0.0.1)",
|
|
167
174
|
"multiple": false
|
|
168
175
|
},
|
|
169
176
|
"appIcon": {
|
|
@@ -230,9 +237,9 @@
|
|
|
230
237
|
},
|
|
231
238
|
"args": {}
|
|
232
239
|
},
|
|
233
|
-
"build-
|
|
234
|
-
"id": "build-
|
|
235
|
-
"description": "Build the 'saltcorn/
|
|
240
|
+
"build-capacitor-builder": {
|
|
241
|
+
"id": "build-capacitor-builder",
|
|
242
|
+
"description": "Build the 'saltcorn/capacitor-builder' docker image or pull it from docker hub.",
|
|
236
243
|
"strict": true,
|
|
237
244
|
"pluginName": "@saltcorn/cli",
|
|
238
245
|
"pluginAlias": "@saltcorn/cli",
|
|
@@ -245,10 +252,16 @@
|
|
|
245
252
|
"type": "boolean",
|
|
246
253
|
"description": "run a clean build with --no-cache",
|
|
247
254
|
"allowNo": false
|
|
255
|
+
},
|
|
256
|
+
"pullFromHub": {
|
|
257
|
+
"name": "pullFromHub",
|
|
258
|
+
"type": "boolean",
|
|
259
|
+
"description": "pull the image from docker hub",
|
|
260
|
+
"allowNo": false
|
|
248
261
|
}
|
|
249
262
|
},
|
|
250
263
|
"args": {},
|
|
251
|
-
"help": "Build the 'saltcorn/
|
|
264
|
+
"help": "Build or pull the 'saltcorn/capacitor-builder' docker image. This image is used in the 'build-app' command to run the capacitor commands. Please make sure docker is callable without using root (see rootless mode, or add the user to the docker group)."
|
|
252
265
|
},
|
|
253
266
|
"configuration-check-backups": {
|
|
254
267
|
"id": "configuration-check-backups",
|
|
@@ -1571,6 +1584,32 @@
|
|
|
1571
1584
|
}
|
|
1572
1585
|
}
|
|
1573
1586
|
},
|
|
1587
|
+
"dev:release-resume": {
|
|
1588
|
+
"id": "dev:release-resume",
|
|
1589
|
+
"description": "Release a new saltcorn version",
|
|
1590
|
+
"strict": true,
|
|
1591
|
+
"pluginName": "@saltcorn/cli",
|
|
1592
|
+
"pluginAlias": "@saltcorn/cli",
|
|
1593
|
+
"pluginType": "core",
|
|
1594
|
+
"aliases": [],
|
|
1595
|
+
"hiddenAliases": [],
|
|
1596
|
+
"flags": {
|
|
1597
|
+
"tag": {
|
|
1598
|
+
"name": "tag",
|
|
1599
|
+
"type": "option",
|
|
1600
|
+
"char": "t",
|
|
1601
|
+
"description": "NPM tag",
|
|
1602
|
+
"multiple": false
|
|
1603
|
+
}
|
|
1604
|
+
},
|
|
1605
|
+
"args": {
|
|
1606
|
+
"version": {
|
|
1607
|
+
"name": "version",
|
|
1608
|
+
"description": "New version number",
|
|
1609
|
+
"required": true
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
},
|
|
1574
1613
|
"dev:release": {
|
|
1575
1614
|
"id": "dev:release",
|
|
1576
1615
|
"description": "Release a new saltcorn version",
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@saltcorn/cli",
|
|
3
3
|
"description": "Command-line interface for Saltcorn, open-source no-code platform",
|
|
4
4
|
"homepage": "https://saltcorn.com",
|
|
5
|
-
"version": "1.1.
|
|
5
|
+
"version": "1.1.1-beta.0",
|
|
6
6
|
"author": "Tom Nielsen @glutamate",
|
|
7
7
|
"bin": {
|
|
8
8
|
"saltcorn": "./bin/saltcorn"
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@oclif/core": "^2.16.0",
|
|
13
13
|
"@oclif/plugin-plugins": "^3.9.4",
|
|
14
|
-
"@saltcorn/admin-models": "1.1.
|
|
15
|
-
"@saltcorn/common-code": "1.1.
|
|
16
|
-
"@saltcorn/data": "1.1.
|
|
17
|
-
"@saltcorn/mobile-app": "1.1.
|
|
18
|
-
"@saltcorn/mobile-builder": "1.1.
|
|
19
|
-
"@saltcorn/plugins-loader": "1.1.
|
|
20
|
-
"@saltcorn/server": "1.1.
|
|
14
|
+
"@saltcorn/admin-models": "1.1.1-beta.0",
|
|
15
|
+
"@saltcorn/common-code": "1.1.1-beta.0",
|
|
16
|
+
"@saltcorn/data": "1.1.1-beta.0",
|
|
17
|
+
"@saltcorn/mobile-app": "1.1.1-beta.0",
|
|
18
|
+
"@saltcorn/mobile-builder": "1.1.1-beta.0",
|
|
19
|
+
"@saltcorn/plugins-loader": "1.1.1-beta.0",
|
|
20
|
+
"@saltcorn/server": "1.1.1-beta.0",
|
|
21
21
|
"contractis": "^0.1.0",
|
|
22
22
|
"dateformat": "^3.0.3",
|
|
23
23
|
"inquirer": "^7.3.3",
|
package/src/commands/backup.js
CHANGED
|
@@ -11,6 +11,7 @@ const { getConnectObject } = require("@saltcorn/data/db/connect");
|
|
|
11
11
|
const day = dateFormat(new Date(), "yyyymmdd");
|
|
12
12
|
const connobj = getConnectObject();
|
|
13
13
|
const { init_some_tenants } = require("../common");
|
|
14
|
+
const fs = require("fs");
|
|
14
15
|
|
|
15
16
|
const pgdb = connobj.database;
|
|
16
17
|
|
|
@@ -45,6 +46,32 @@ class BackupCommand extends Command {
|
|
|
45
46
|
const fnm = await create_backup(flags.output);
|
|
46
47
|
console.log(fnm);
|
|
47
48
|
});
|
|
49
|
+
} else if (flags.all_tenants) {
|
|
50
|
+
const db = require("@saltcorn/data/db");
|
|
51
|
+
|
|
52
|
+
const { create_backup } = require("@saltcorn/admin-models/models/backup");
|
|
53
|
+
const { loadAllPlugins } = require("@saltcorn/server/load_plugins");
|
|
54
|
+
const { eachTenant } = require("@saltcorn/admin-models/models/tenant");
|
|
55
|
+
const { init_multi_tenant } = require("@saltcorn/data/db/state");
|
|
56
|
+
let nten = 0,
|
|
57
|
+
nerr = 0;
|
|
58
|
+
const domain_files = {};
|
|
59
|
+
await eachTenant(async () => {
|
|
60
|
+
try {
|
|
61
|
+
nten += 1;
|
|
62
|
+
const domain = db.getTenantSchema();
|
|
63
|
+
await init_multi_tenant(loadAllPlugins, undefined, [domain]);
|
|
64
|
+
console.log("Backup tenant", domain);
|
|
65
|
+
const fnm = await create_backup(flags.output);
|
|
66
|
+
console.log(fnm);
|
|
67
|
+
domain_files[domain] = fnm;
|
|
68
|
+
} catch (e) {
|
|
69
|
+
nerr += 1;
|
|
70
|
+
console.error(e);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
fs.writeFileSync("domain_files.json", JSON.stringify(domain_files));
|
|
74
|
+
console.log("done backup all tenants", nerr, "/", nten, "errors");
|
|
48
75
|
} else if (flags.zip) {
|
|
49
76
|
// zip the saltcorn backup
|
|
50
77
|
const { create_backup } = require("@saltcorn/admin-models/models/backup");
|
|
@@ -115,6 +142,10 @@ BackupCommand.flags = {
|
|
|
115
142
|
char: "t",
|
|
116
143
|
description: "Backup tenant in saltcorn zip format",
|
|
117
144
|
}),
|
|
145
|
+
all_tenants: Flags.boolean({
|
|
146
|
+
char: "a",
|
|
147
|
+
description: "Backup all tenants in saltcorn zip format",
|
|
148
|
+
}),
|
|
118
149
|
zip: Flags.boolean({
|
|
119
150
|
char: "z",
|
|
120
151
|
description: "Backup public in saltcorn zip format",
|
|
@@ -28,7 +28,7 @@ class BuildAppCommand extends Command {
|
|
|
28
28
|
throw new Error("Please specify an entry point for the first view");
|
|
29
29
|
}
|
|
30
30
|
if (!flags.platforms) {
|
|
31
|
-
throw new Error("Please specify
|
|
31
|
+
throw new Error("Please specify a platform (android or iOS)");
|
|
32
32
|
}
|
|
33
33
|
for (const platform of flags.platforms)
|
|
34
34
|
if (!this.supportedPlatforms.includes(platform))
|
|
@@ -61,7 +61,7 @@ class BuildAppCommand extends Command {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
async run() {
|
|
64
|
-
const { flags } = await
|
|
64
|
+
const { flags } = await this.parse(BuildAppCommand);
|
|
65
65
|
this.validateParameters(flags);
|
|
66
66
|
const mobileAppDir = path.join(
|
|
67
67
|
require.resolve("@saltcorn/mobile-app"),
|
|
@@ -200,7 +200,7 @@ BuildAppCommand.flags = {
|
|
|
200
200
|
appVersion: Flags.string({
|
|
201
201
|
name: "app version",
|
|
202
202
|
string: "appVersion",
|
|
203
|
-
description: "Version of the mobile app (default
|
|
203
|
+
description: "Version of the mobile app (default 0.0.1)",
|
|
204
204
|
}),
|
|
205
205
|
appIcon: Flags.string({
|
|
206
206
|
name: "app icon",
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const { Command, Flags } = require("@oclif/core");
|
|
2
|
+
const { join } = require("path");
|
|
3
|
+
const { spawnSync } = require("child_process");
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This is a oclif command to build the 'saltcorn/capacitor-builder' docker image.
|
|
7
|
+
* The image is used in the 'build-app' command to run the capacitor commands.
|
|
8
|
+
* Please make sure docker is callable without sudo (see rootless mode, or add the user to the docker group).
|
|
9
|
+
*/
|
|
10
|
+
class BuildCapacitorBuilder extends Command {
|
|
11
|
+
async run() {
|
|
12
|
+
const { flags } = await this.parse(BuildCapacitorBuilder);
|
|
13
|
+
if (flags.pullFromHub) {
|
|
14
|
+
const result = spawnSync(
|
|
15
|
+
"docker",
|
|
16
|
+
["pull", "saltcorn/capacitor-builder"],
|
|
17
|
+
{ cwd: ".", stdio: "inherit" }
|
|
18
|
+
);
|
|
19
|
+
if (result.error) console.log(result.error.toString());
|
|
20
|
+
} else {
|
|
21
|
+
const dockerDir = join(
|
|
22
|
+
require.resolve("@saltcorn/mobile-builder"),
|
|
23
|
+
"..",
|
|
24
|
+
"..",
|
|
25
|
+
"docker"
|
|
26
|
+
);
|
|
27
|
+
const dArgs = ["build", dockerDir, "--network", "host"];
|
|
28
|
+
if (flags.buildClean) dArgs.push("--no-cache");
|
|
29
|
+
dArgs.push(
|
|
30
|
+
"-f",
|
|
31
|
+
join(dockerDir, "Dockerfile"),
|
|
32
|
+
"-t",
|
|
33
|
+
"saltcorn/capacitor-builder",
|
|
34
|
+
"--progress=plain"
|
|
35
|
+
);
|
|
36
|
+
const result = spawnSync("docker", dArgs, { cwd: ".", stdio: "inherit" });
|
|
37
|
+
if (result.error) console.log(result.error.toString());
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
BuildCapacitorBuilder.description =
|
|
43
|
+
"Build the 'saltcorn/capacitor-builder' docker image or pull it from docker hub.";
|
|
44
|
+
|
|
45
|
+
BuildCapacitorBuilder.help =
|
|
46
|
+
"Build or pull the 'saltcorn/capacitor-builder' docker image. " +
|
|
47
|
+
"This image is used in the 'build-app' command to run the capacitor commands. " +
|
|
48
|
+
"Please make sure docker is callable without using root (see rootless mode, or add the user to the docker group).";
|
|
49
|
+
|
|
50
|
+
BuildCapacitorBuilder.flags = {
|
|
51
|
+
buildClean: Flags.boolean({
|
|
52
|
+
name: "build clean",
|
|
53
|
+
string: "clean",
|
|
54
|
+
description: "run a clean build with --no-cache",
|
|
55
|
+
default: false,
|
|
56
|
+
}),
|
|
57
|
+
pullFromHub: Flags.boolean({
|
|
58
|
+
name: "pull from docker hub",
|
|
59
|
+
description: "pull the image from docker hub",
|
|
60
|
+
default: false,
|
|
61
|
+
}),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
module.exports = BuildCapacitorBuilder;
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @category saltcorn-cli
|
|
3
|
+
* @module commands/release-resume
|
|
4
|
+
*/
|
|
5
|
+
const { Command, Flags, Args } = require("@oclif/core");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const { spawnSync } = require("child_process");
|
|
8
|
+
const { sleep } = require("../../common");
|
|
9
|
+
|
|
10
|
+
const runCmd = (cmd, args, options) => {
|
|
11
|
+
const dirStr =
|
|
12
|
+
options?.cwd && options.cwd !== "." ? ` [cwd=${options.cwd}]` : "";
|
|
13
|
+
console.log(`>${dirStr} ${cmd} ${args.join(" ")}`);
|
|
14
|
+
const res = spawnSync(cmd, args, options);
|
|
15
|
+
if (res.status !== 0)
|
|
16
|
+
throw new Error(
|
|
17
|
+
`Non-zero exit status for command: "${cmd} ${args.join(" ")}" in ${
|
|
18
|
+
options?.cwd || "."
|
|
19
|
+
}`
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* ReleaseResumeCommand Class
|
|
25
|
+
* @extends oclif.Command
|
|
26
|
+
* @category saltcorn-cli
|
|
27
|
+
*/
|
|
28
|
+
class ReleaseResumeCommand extends Command {
|
|
29
|
+
/**
|
|
30
|
+
* @returns {Promise<void>}
|
|
31
|
+
*/
|
|
32
|
+
async run() {
|
|
33
|
+
const {
|
|
34
|
+
args: { version },
|
|
35
|
+
flags,
|
|
36
|
+
} = await this.parse(ReleaseResumeCommand);
|
|
37
|
+
const pkgs = {
|
|
38
|
+
"@saltcorn/db-common": { dir: "db-common", publish: true },
|
|
39
|
+
"@saltcorn/common-code": { dir: "common-code", publish: true },
|
|
40
|
+
"@saltcorn/plugins-loader": { dir: "plugins-loader", publish: true },
|
|
41
|
+
"@saltcorn/sqlite": { dir: "sqlite", publish: true },
|
|
42
|
+
"@saltcorn/sqlite-mobile": { dir: "sqlite-mobile", publish: true },
|
|
43
|
+
"@saltcorn/postgres": { dir: "postgres", publish: true },
|
|
44
|
+
"@saltcorn/types": { dir: "saltcorn-types", publish: true },
|
|
45
|
+
"@saltcorn/builder": { dir: "saltcorn-builder", publish: true },
|
|
46
|
+
"@saltcorn/filemanager": { dir: "filemanager", publish: true },
|
|
47
|
+
"@saltcorn/data": { dir: "saltcorn-data", publish: true },
|
|
48
|
+
"@saltcorn/admin-models": {
|
|
49
|
+
dir: "saltcorn-admin-models",
|
|
50
|
+
publish: true,
|
|
51
|
+
},
|
|
52
|
+
"@saltcorn/random-tests": { dir: "saltcorn-random-tests" },
|
|
53
|
+
"@saltcorn/server": { dir: "server", publish: true },
|
|
54
|
+
"@saltcorn/base-plugin": { dir: "saltcorn-base-plugin", publish: true },
|
|
55
|
+
//"saltcorn-cli", publish: true},
|
|
56
|
+
"@saltcorn/markup": { dir: "saltcorn-markup", publish: true },
|
|
57
|
+
"@saltcorn/mobile-app": { dir: "saltcorn-mobile-app", publish: true },
|
|
58
|
+
"@saltcorn/mobile-builder": {
|
|
59
|
+
dir: "saltcorn-mobile-builder",
|
|
60
|
+
publish: true,
|
|
61
|
+
},
|
|
62
|
+
"@saltcorn/sbadmin2": { dir: "saltcorn-sbadmin2", publish: true },
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const updateDependencies = (json, dpkgnm, version) => {
|
|
66
|
+
if (json.dependencies && json.dependencies[dpkgnm])
|
|
67
|
+
json.dependencies[dpkgnm] = version;
|
|
68
|
+
if (json.devDependencies && json.devDependencies[dpkgnm])
|
|
69
|
+
json.devDependencies[dpkgnm] = version;
|
|
70
|
+
if (json.optionalDependencies && json.optionalDependencies[dpkgnm])
|
|
71
|
+
json.optionalDependencies[dpkgnm] = version;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const updatePkgJson = (dir) => {
|
|
75
|
+
const json = require(`../../../../${dir}/package.json`);
|
|
76
|
+
json.version = version;
|
|
77
|
+
if (json.dependencies || json.devDependencies)
|
|
78
|
+
Object.keys(pkgs).forEach((dpkgnm) => {
|
|
79
|
+
updateDependencies(json, dpkgnm, version);
|
|
80
|
+
});
|
|
81
|
+
updateDependencies(json, "@saltcorn/cli", version);
|
|
82
|
+
fs.writeFileSync(
|
|
83
|
+
`packages/${dir}/package.json`,
|
|
84
|
+
JSON.stringify(json, null, 2)
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
const compileTsFiles = () => {
|
|
88
|
+
runCmd("npm", ["install", "--legacy-peer-deps"], {
|
|
89
|
+
stdio: "inherit",
|
|
90
|
+
cwd: ".",
|
|
91
|
+
});
|
|
92
|
+
runCmd("npm", ["run", "tsc"], {
|
|
93
|
+
stdio: "inherit",
|
|
94
|
+
cwd: ".",
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
const publish = async (dir, tags0) => {
|
|
98
|
+
const tags = !tags0 ? [] : Array.isArray(tags0) ? tags0 : [tags0];
|
|
99
|
+
if (flags.tag) tags.push(flags.tag);
|
|
100
|
+
const firstTag = tags[0];
|
|
101
|
+
runCmd(
|
|
102
|
+
"npm",
|
|
103
|
+
[
|
|
104
|
+
"publish",
|
|
105
|
+
"--access=public",
|
|
106
|
+
...(firstTag ? ["--tag", firstTag] : []),
|
|
107
|
+
],
|
|
108
|
+
{
|
|
109
|
+
stdio: "inherit",
|
|
110
|
+
cwd: `packages/${dir}/`,
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
tags.shift();
|
|
114
|
+
for (const tag of tags) {
|
|
115
|
+
await sleep(7000);
|
|
116
|
+
runCmd("npm", ["dist-tag", "add", `@saltcorn/cli@${version}`, tag], {
|
|
117
|
+
stdio: "inherit",
|
|
118
|
+
cwd: `packages/${dir}/`,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const rootPackageJson = require(`../../../../../package.json`);
|
|
124
|
+
|
|
125
|
+
runCmd("npm", ["install", "--legacy-peer-deps"], {
|
|
126
|
+
stdio: "inherit",
|
|
127
|
+
cwd: `packages/saltcorn-cli/`,
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
runCmd("npm", ["update", "--legacy-peer-deps"], {
|
|
131
|
+
stdio: "inherit",
|
|
132
|
+
cwd: `packages/saltcorn-cli/`,
|
|
133
|
+
});
|
|
134
|
+
runCmd("npm", ["install", "--legacy-peer-deps"], {
|
|
135
|
+
stdio: "inherit",
|
|
136
|
+
cwd: `packages/saltcorn-cli/`,
|
|
137
|
+
});
|
|
138
|
+
runCmd("npm", ["run", "manifest"], {
|
|
139
|
+
stdio: "inherit",
|
|
140
|
+
cwd: `packages/saltcorn-cli/`,
|
|
141
|
+
});
|
|
142
|
+
runCmd("npm", ["install", "--legacy-peer-deps"], {
|
|
143
|
+
stdio: "inherit",
|
|
144
|
+
cwd: ".",
|
|
145
|
+
});
|
|
146
|
+
spawnSync("npm", ["run", "tsc"], {
|
|
147
|
+
stdio: "inherit",
|
|
148
|
+
cwd: ".",
|
|
149
|
+
});
|
|
150
|
+
// do not run 'audit fix' on full point releases, only on -beta.x, -rc.x etc
|
|
151
|
+
/*if (version.includes("-"))
|
|
152
|
+
runCmd("npm", ["audit", "fix"], {
|
|
153
|
+
stdio: "inherit",
|
|
154
|
+
cwd: `packages/saltcorn-cli/`,
|
|
155
|
+
});*/
|
|
156
|
+
await publish("saltcorn-cli", "next");
|
|
157
|
+
fs.writeFileSync(
|
|
158
|
+
`package.json`,
|
|
159
|
+
JSON.stringify(
|
|
160
|
+
{ ...rootPackageJson, workspaces: ["./packages/*"] },
|
|
161
|
+
null,
|
|
162
|
+
2
|
|
163
|
+
)
|
|
164
|
+
); // update Dockerfile
|
|
165
|
+
const dockerfile = fs.readFileSync(`Dockerfile.release`, "utf8");
|
|
166
|
+
fs.writeFileSync(
|
|
167
|
+
`Dockerfile.release`,
|
|
168
|
+
dockerfile.replace(/cli@.* --unsafe/, `cli@${version} --unsafe`)
|
|
169
|
+
);
|
|
170
|
+
const dockerfileWithMobile = fs.readFileSync(
|
|
171
|
+
`Dockerfile.mobile.release`,
|
|
172
|
+
"utf8"
|
|
173
|
+
);
|
|
174
|
+
fs.writeFileSync(
|
|
175
|
+
`Dockerfile.mobile.release`,
|
|
176
|
+
dockerfileWithMobile.replace(/cli@.* --unsafe/, `cli@${version} --unsafe`)
|
|
177
|
+
);
|
|
178
|
+
//git commit tag and push
|
|
179
|
+
runCmd("git", ["commit", "-am", "v" + version], {
|
|
180
|
+
stdio: "inherit",
|
|
181
|
+
});
|
|
182
|
+
runCmd("git", ["tag", "-a", "v" + version, "-m", "v" + version], {
|
|
183
|
+
stdio: "inherit",
|
|
184
|
+
});
|
|
185
|
+
runCmd("git", ["push", "origin", "v" + version], {
|
|
186
|
+
stdio: "inherit",
|
|
187
|
+
});
|
|
188
|
+
runCmd("git", ["push"], {
|
|
189
|
+
stdio: "inherit",
|
|
190
|
+
});
|
|
191
|
+
console.log("Now run:\n");
|
|
192
|
+
console.log("npm install --legacy-peer-deps && npm run tsc\n");
|
|
193
|
+
this.exit(0);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* @type {string}
|
|
199
|
+
*/
|
|
200
|
+
ReleaseResumeCommand.description = `Release a new saltcorn version`;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* @type {object}
|
|
204
|
+
*/
|
|
205
|
+
ReleaseResumeCommand.args = {
|
|
206
|
+
version: Args.string({
|
|
207
|
+
required: true,
|
|
208
|
+
description: "New version number",
|
|
209
|
+
}),
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
ReleaseResumeCommand.flags = {
|
|
213
|
+
tag: Flags.string({
|
|
214
|
+
char: "t",
|
|
215
|
+
description: "NPM tag",
|
|
216
|
+
}),
|
|
217
|
+
};
|
|
218
|
+
module.exports = ReleaseResumeCommand;
|
|
@@ -7,6 +7,19 @@ const fs = require("fs");
|
|
|
7
7
|
const { spawnSync } = require("child_process");
|
|
8
8
|
const { sleep } = require("../../common");
|
|
9
9
|
|
|
10
|
+
const runCmd = (cmd, args, options) => {
|
|
11
|
+
const dirStr =
|
|
12
|
+
options?.cwd && options.cwd !== "." ? ` [cwd=${options.cwd}]` : "";
|
|
13
|
+
console.log(`>${dirStr} ${cmd} ${args.join(" ")}`);
|
|
14
|
+
const res = spawnSync(cmd, args, options);
|
|
15
|
+
if (res.status !== 0)
|
|
16
|
+
throw new Error(
|
|
17
|
+
`Non-zero exit status for command: "${cmd} ${args.join(" ")}" in ${
|
|
18
|
+
options?.cwd || "."
|
|
19
|
+
}`
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
10
23
|
/**
|
|
11
24
|
* ReleaseCommand Class
|
|
12
25
|
* @extends oclif.Command
|
|
@@ -21,7 +34,7 @@ class ReleaseCommand extends Command {
|
|
|
21
34
|
args: { version },
|
|
22
35
|
flags,
|
|
23
36
|
} = await this.parse(ReleaseCommand);
|
|
24
|
-
|
|
37
|
+
runCmd("git", ["pull"], {
|
|
25
38
|
stdio: "inherit",
|
|
26
39
|
cwd: ".",
|
|
27
40
|
});
|
|
@@ -32,7 +45,7 @@ class ReleaseCommand extends Command {
|
|
|
32
45
|
});
|
|
33
46
|
console.log("\n");
|
|
34
47
|
|
|
35
|
-
|
|
48
|
+
runCmd("git", ["show", "--summary"], {
|
|
36
49
|
stdio: "inherit",
|
|
37
50
|
cwd: ".",
|
|
38
51
|
});
|
|
@@ -89,11 +102,11 @@ class ReleaseCommand extends Command {
|
|
|
89
102
|
);
|
|
90
103
|
};
|
|
91
104
|
const compileTsFiles = () => {
|
|
92
|
-
|
|
105
|
+
runCmd("npm", ["install", "--legacy-peer-deps"], {
|
|
93
106
|
stdio: "inherit",
|
|
94
107
|
cwd: ".",
|
|
95
108
|
});
|
|
96
|
-
|
|
109
|
+
runCmd("npm", ["run", "tsc"], {
|
|
97
110
|
stdio: "inherit",
|
|
98
111
|
cwd: ".",
|
|
99
112
|
});
|
|
@@ -102,17 +115,12 @@ class ReleaseCommand extends Command {
|
|
|
102
115
|
const tags = !tags0 ? [] : Array.isArray(tags0) ? tags0 : [tags0];
|
|
103
116
|
if (flags.tag) tags.push(flags.tag);
|
|
104
117
|
const firstTag = tags[0];
|
|
105
|
-
|
|
106
|
-
`packages/${dir}$ npm publish --access=public ${
|
|
107
|
-
firstTag ? `--tag ${firstTag}` : ""
|
|
108
|
-
}`
|
|
109
|
-
);
|
|
110
|
-
spawnSync(
|
|
118
|
+
runCmd(
|
|
111
119
|
"npm",
|
|
112
120
|
[
|
|
113
121
|
"publish",
|
|
114
122
|
"--access=public",
|
|
115
|
-
...(firstTag ? [
|
|
123
|
+
...(firstTag ? ["--tag", firstTag] : []),
|
|
116
124
|
],
|
|
117
125
|
{
|
|
118
126
|
stdio: "inherit",
|
|
@@ -121,11 +129,8 @@ class ReleaseCommand extends Command {
|
|
|
121
129
|
);
|
|
122
130
|
tags.shift();
|
|
123
131
|
for (const tag of tags) {
|
|
124
|
-
await sleep(
|
|
125
|
-
|
|
126
|
-
`packages/${dir}$ npm dist-tag add @saltcorn/cli@${version} ${tag}`
|
|
127
|
-
);
|
|
128
|
-
spawnSync("npm", ["dist-tag", "add", `@saltcorn/cli@${version}`, tag], {
|
|
132
|
+
await sleep(7000);
|
|
133
|
+
runCmd("npm", ["dist-tag", "add", `@saltcorn/cli@${version}`, tag], {
|
|
129
134
|
stdio: "inherit",
|
|
130
135
|
cwd: `packages/${dir}/`,
|
|
131
136
|
});
|
|
@@ -135,14 +140,11 @@ class ReleaseCommand extends Command {
|
|
|
135
140
|
const rootPackageJson = require(`../../../../../package.json`);
|
|
136
141
|
|
|
137
142
|
compileTsFiles();
|
|
138
|
-
//for each package:
|
|
143
|
+
//for each package:1
|
|
139
144
|
// 1. update version
|
|
140
145
|
// 2. update dependencies for other packages
|
|
141
146
|
// 3. publish
|
|
142
|
-
|
|
143
|
-
stdio: "inherit",
|
|
144
|
-
cwd: `packages/saltcorn-cli/`,
|
|
145
|
-
});
|
|
147
|
+
|
|
146
148
|
for (const p of Object.values(pkgs)) {
|
|
147
149
|
updatePkgJson(p.dir);
|
|
148
150
|
if (p.publish) {
|
|
@@ -152,6 +154,15 @@ class ReleaseCommand extends Command {
|
|
|
152
154
|
}
|
|
153
155
|
await sleep(5000);
|
|
154
156
|
|
|
157
|
+
runCmd("npm", ["cache", "clear", "--force"], {
|
|
158
|
+
stdio: "inherit",
|
|
159
|
+
cwd: `.`,
|
|
160
|
+
});
|
|
161
|
+
runCmd("npm", ["cache", "clean", "--force"], {
|
|
162
|
+
stdio: "inherit",
|
|
163
|
+
cwd: `.`,
|
|
164
|
+
});
|
|
165
|
+
|
|
155
166
|
// for cli:
|
|
156
167
|
// 1. update version
|
|
157
168
|
// 2. update dependencies for other pkgs
|
|
@@ -161,26 +172,36 @@ class ReleaseCommand extends Command {
|
|
|
161
172
|
fs.writeFileSync(
|
|
162
173
|
`package.json`,
|
|
163
174
|
JSON.stringify({ ...rootPackageJson, workspaces: undefined }, null, 2)
|
|
164
|
-
);
|
|
165
|
-
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
runCmd("npm", ["install", "--legacy-peer-deps"], {
|
|
166
178
|
stdio: "inherit",
|
|
167
179
|
cwd: `packages/saltcorn-cli/`,
|
|
168
180
|
});
|
|
169
|
-
|
|
181
|
+
|
|
182
|
+
runCmd("npm", ["update", "--legacy-peer-deps"], {
|
|
170
183
|
stdio: "inherit",
|
|
171
184
|
cwd: `packages/saltcorn-cli/`,
|
|
172
185
|
});
|
|
173
|
-
|
|
186
|
+
runCmd("npm", ["install", "--legacy-peer-deps"], {
|
|
174
187
|
stdio: "inherit",
|
|
175
188
|
cwd: `packages/saltcorn-cli/`,
|
|
176
189
|
});
|
|
177
|
-
|
|
190
|
+
runCmd("npm", ["run", "manifest"], {
|
|
191
|
+
stdio: "inherit",
|
|
192
|
+
cwd: `packages/saltcorn-cli/`,
|
|
193
|
+
});
|
|
194
|
+
runCmd("npm", ["install", "--legacy-peer-deps"], {
|
|
195
|
+
stdio: "inherit",
|
|
196
|
+
cwd: ".",
|
|
197
|
+
});
|
|
198
|
+
spawnSync("npm", ["run", "tsc"], {
|
|
178
199
|
stdio: "inherit",
|
|
179
200
|
cwd: ".",
|
|
180
201
|
});
|
|
181
202
|
// do not run 'audit fix' on full point releases, only on -beta.x, -rc.x etc
|
|
182
203
|
/*if (version.includes("-"))
|
|
183
|
-
|
|
204
|
+
runCmd("npm", ["audit", "fix"], {
|
|
184
205
|
stdio: "inherit",
|
|
185
206
|
cwd: `packages/saltcorn-cli/`,
|
|
186
207
|
});*/
|
|
@@ -201,21 +222,20 @@ class ReleaseCommand extends Command {
|
|
|
201
222
|
dockerfileWithMobile.replace(/cli@.* --unsafe/, `cli@${version} --unsafe`)
|
|
202
223
|
);
|
|
203
224
|
//git commit tag and push
|
|
204
|
-
|
|
225
|
+
runCmd("git", ["commit", "-am", "v" + version], {
|
|
205
226
|
stdio: "inherit",
|
|
206
227
|
});
|
|
207
|
-
|
|
228
|
+
runCmd("git", ["tag", "-a", "v" + version, "-m", "v" + version], {
|
|
208
229
|
stdio: "inherit",
|
|
209
230
|
});
|
|
210
|
-
|
|
231
|
+
runCmd("git", ["push", "origin", "v" + version], {
|
|
211
232
|
stdio: "inherit",
|
|
212
233
|
});
|
|
213
|
-
|
|
234
|
+
runCmd("git", ["push"], {
|
|
214
235
|
stdio: "inherit",
|
|
215
236
|
});
|
|
216
237
|
console.log("Now run:\n");
|
|
217
|
-
console.log("
|
|
218
|
-
console.log(" rm -rf node_modules\n");
|
|
238
|
+
console.log("npm install --legacy-peer-deps && npm run tsc\n");
|
|
219
239
|
this.exit(0);
|
|
220
240
|
}
|
|
221
241
|
}
|