@nocobase/cli 2.1.0-beta.35 → 2.1.0-beta.36
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/dist/commands/app/upgrade.js +38 -16
- package/dist/commands/backup/create.js +147 -0
- package/dist/commands/backup/index.js +20 -0
- package/dist/commands/backup/restore.js +105 -0
- package/dist/commands/env/add.js +63 -9
- package/dist/commands/env/auth.js +85 -11
- package/dist/commands/init.js +71 -13
- package/dist/commands/install.js +140 -11
- package/dist/commands/license/activate.js +6 -4
- package/dist/commands/source/publish.js +17 -0
- package/dist/commands/v1.js +210 -0
- package/dist/lib/app-managed-resources.js +20 -1
- package/dist/lib/app-runtime.js +13 -4
- package/dist/lib/auth-store.js +28 -5
- package/dist/lib/backup.js +171 -0
- package/dist/lib/bootstrap.js +23 -13
- package/dist/lib/env-config.js +6 -0
- package/dist/lib/run-npm.js +35 -9
- package/dist/lib/source-publish.js +20 -1
- package/dist/lib/source-registry.js +2 -2
- package/package.json +6 -3
package/dist/lib/run-npm.js
CHANGED
|
@@ -31,6 +31,14 @@ function pathExists(candidate) {
|
|
|
31
31
|
return false;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
+
function isDirectory(candidate) {
|
|
35
|
+
try {
|
|
36
|
+
return Boolean(candidate) && fs.statSync(candidate).isDirectory();
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
34
42
|
function hasLocalNocoBaseBinary(candidate) {
|
|
35
43
|
return (pathExists(path.join(candidate, 'node_modules', '.bin', 'nocobase-v1'))
|
|
36
44
|
|| pathExists(path.join(candidate, 'node_modules', '.bin', 'nocobase-v1.cmd')));
|
|
@@ -45,19 +53,23 @@ export function resolveCwd(cwd) {
|
|
|
45
53
|
export function resolveProjectCwd(cwd) {
|
|
46
54
|
const normalizedCwd = typeof cwd === 'string' && cwd.trim() === '' ? undefined : cwd;
|
|
47
55
|
const fallback = resolveCwd(normalizedCwd);
|
|
48
|
-
const
|
|
49
|
-
|
|
56
|
+
const hasExplicitInput = normalizedCwd !== undefined;
|
|
57
|
+
if (hasExplicitInput && !pathExists(fallback)) {
|
|
58
|
+
throw new Error(`The specified --cwd does not exist: ${fallback}`);
|
|
59
|
+
}
|
|
60
|
+
if (hasExplicitInput && !isDirectory(fallback)) {
|
|
61
|
+
throw new Error(`The specified --cwd is not a directory: ${fallback}`);
|
|
62
|
+
}
|
|
63
|
+
let current = hasExplicitInput ? fallback : process.cwd();
|
|
50
64
|
while (true) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
: normalizedCwd
|
|
54
|
-
? path.resolve(current, normalizedCwd)
|
|
55
|
-
: current;
|
|
56
|
-
if (hasLocalNocoBaseBinary(candidate)) {
|
|
57
|
-
return candidate;
|
|
65
|
+
if (hasLocalNocoBaseBinary(current)) {
|
|
66
|
+
return current;
|
|
58
67
|
}
|
|
59
68
|
const parent = path.dirname(current);
|
|
60
69
|
if (parent === current) {
|
|
70
|
+
if (hasExplicitInput) {
|
|
71
|
+
throw new Error(`Couldn't find a NocoBase source project from --cwd: ${fallback}`);
|
|
72
|
+
}
|
|
61
73
|
return fallback;
|
|
62
74
|
}
|
|
63
75
|
current = parent;
|
|
@@ -77,6 +89,20 @@ export function run(name, args, options) {
|
|
|
77
89
|
},
|
|
78
90
|
windowsHide: process.platform === 'win32',
|
|
79
91
|
});
|
|
92
|
+
if (options?.stdio === 'pipe') {
|
|
93
|
+
child.stdout?.setEncoding('utf8');
|
|
94
|
+
child.stderr?.setEncoding('utf8');
|
|
95
|
+
if (options.onStdout) {
|
|
96
|
+
child.stdout?.on('data', (chunk) => {
|
|
97
|
+
options.onStdout?.(String(chunk));
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (options.onStderr) {
|
|
101
|
+
child.stderr?.on('data', (chunk) => {
|
|
102
|
+
options.onStderr?.(String(chunk));
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
80
106
|
const cleanupSignalForwarding = forwardSignalsToChild(child);
|
|
81
107
|
child.once('error', (error) => {
|
|
82
108
|
cleanupSignalForwarding();
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import path from 'node:path';
|
|
10
|
-
import { commandOutput, resolveProjectCwd, run } from './run-npm.js';
|
|
10
|
+
import { commandOutput, resolveProjectCwd, run, runNocoBaseCommand } from './run-npm.js';
|
|
11
11
|
import { DEFAULT_SOURCE_REGISTRY_PORT, parseSourceRegistryUrl, resolveSourceRegistryInfo } from './source-registry.js';
|
|
12
12
|
function trimValue(value) {
|
|
13
13
|
return String(value ?? '').trim();
|
|
@@ -98,6 +98,16 @@ async function commitSourceSnapshotVersion(params) {
|
|
|
98
98
|
errorName: 'git commit',
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
|
+
async function buildSourceSnapshot(params) {
|
|
102
|
+
const args = ['build'];
|
|
103
|
+
if (!params.buildDts) {
|
|
104
|
+
args.push('--no-dts');
|
|
105
|
+
}
|
|
106
|
+
await runNocoBaseCommand(args, {
|
|
107
|
+
cwd: params.cwd,
|
|
108
|
+
stdio: params.stdio,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
101
111
|
async function createSourcePublishStash(params) {
|
|
102
112
|
if (!(await hasLocalGitChanges(params.cwd))) {
|
|
103
113
|
return undefined;
|
|
@@ -158,6 +168,8 @@ export async function publishSourceSnapshot(params) {
|
|
|
158
168
|
const version = buildSnapshotVersion(baseVersion, gitSha, params.now);
|
|
159
169
|
const temporaryBranch = buildSourcePublishBranchName(gitSha, params.now);
|
|
160
170
|
const stdio = params.verbose ? 'inherit' : 'ignore';
|
|
171
|
+
const shouldBuild = params.build !== false;
|
|
172
|
+
const shouldBuildDts = params.buildDts !== false;
|
|
161
173
|
let stash;
|
|
162
174
|
let onTemporaryBranch = false;
|
|
163
175
|
let branchCreated = false;
|
|
@@ -186,6 +198,13 @@ export async function publishSourceSnapshot(params) {
|
|
|
186
198
|
errorName: 'git stash apply',
|
|
187
199
|
});
|
|
188
200
|
}
|
|
201
|
+
if (shouldBuild) {
|
|
202
|
+
await buildSourceSnapshot({
|
|
203
|
+
cwd: projectRoot,
|
|
204
|
+
buildDts: shouldBuildDts,
|
|
205
|
+
stdio,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
189
208
|
await run('yarn', ['lerna', 'version', version, '--force-publish=*', '--no-git-tag-version', '-y'], {
|
|
190
209
|
cwd: projectRoot,
|
|
191
210
|
errorName: 'lerna version',
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import fsp from 'node:fs/promises';
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
import { commandOutput, commandSucceeds, resolveCwd, resolveProjectCwd, run } from './run-npm.js';
|
|
12
|
-
import {
|
|
12
|
+
import { resolveCliHomeDir } from './cli-home.js';
|
|
13
13
|
export const DEFAULT_SOURCE_REGISTRY_HOST = '127.0.0.1';
|
|
14
14
|
export const DEFAULT_SOURCE_REGISTRY_PORT = 4873;
|
|
15
15
|
export const DEFAULT_SOURCE_REGISTRY_CONTAINER_NAME = 'nb-source-registry';
|
|
@@ -31,7 +31,7 @@ function asPosixPathForDockerMount(value) {
|
|
|
31
31
|
return resolveCwd(value).replace(/\\/g, '/');
|
|
32
32
|
}
|
|
33
33
|
export function resolveSourceRegistryRootDir() {
|
|
34
|
-
return path.join(
|
|
34
|
+
return path.join(resolveCliHomeDir(), 'verdaccio');
|
|
35
35
|
}
|
|
36
36
|
export function resolveSourceRegistryConfigPath() {
|
|
37
37
|
return path.join(resolveSourceRegistryRootDir(), 'config.yaml');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/cli",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.36",
|
|
4
4
|
"description": "NocoBase Command Line Tool",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/generated/command-registry.js",
|
|
@@ -67,6 +67,9 @@
|
|
|
67
67
|
"self": {
|
|
68
68
|
"description": "Inspect or update the NocoBase CLI itself."
|
|
69
69
|
},
|
|
70
|
+
"backup": {
|
|
71
|
+
"description": "Create and restore NocoBase backups."
|
|
72
|
+
},
|
|
70
73
|
"skills": {
|
|
71
74
|
"description": "Inspect or synchronize NocoBase AI coding skills for the current workspace."
|
|
72
75
|
},
|
|
@@ -93,7 +96,7 @@
|
|
|
93
96
|
"ora": "^8.2.0",
|
|
94
97
|
"pg": "^8.14.1",
|
|
95
98
|
"picocolors": "^1.1.1",
|
|
96
|
-
"tar": "^7.
|
|
99
|
+
"tar": "^7.5.15"
|
|
97
100
|
},
|
|
98
101
|
"devDependencies": {
|
|
99
102
|
"@types/node": "^18.19.130",
|
|
@@ -105,5 +108,5 @@
|
|
|
105
108
|
"type": "git",
|
|
106
109
|
"url": "git+https://github.com/nocobase/nocobase.git"
|
|
107
110
|
},
|
|
108
|
-
"gitHead": "
|
|
111
|
+
"gitHead": "397d45c744f6eb48b3a0cd785c87cbf1257c3513"
|
|
109
112
|
}
|