@nocobase/cli 2.1.0-alpha.4 → 2.1.0-alpha.40
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/LICENSE.txt +107 -0
- package/README.md +393 -19
- package/README.zh-CN.md +343 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +135 -0
- package/bin/session-env.js +39 -0
- package/dist/commands/api/resource/create.js +15 -0
- package/dist/commands/api/resource/destroy.js +15 -0
- package/dist/commands/api/resource/get.js +15 -0
- package/dist/commands/api/resource/index.js +20 -0
- package/dist/commands/api/resource/list.js +16 -0
- package/dist/commands/api/resource/query.js +15 -0
- package/dist/commands/api/resource/update.js +15 -0
- package/dist/commands/app/down.js +301 -0
- package/dist/commands/app/logs.js +114 -0
- package/dist/commands/app/restart.js +158 -0
- package/dist/commands/app/start.js +305 -0
- package/dist/commands/app/stop.js +115 -0
- package/dist/commands/app/upgrade.js +636 -0
- 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/{src/cli.js → dist/commands/build.js} +4 -11
- package/dist/commands/config/delete.js +30 -0
- package/dist/commands/config/get.js +29 -0
- package/dist/commands/config/index.js +20 -0
- package/dist/commands/config/list.js +29 -0
- package/dist/commands/config/set.js +35 -0
- package/dist/commands/db/check.js +240 -0
- package/dist/commands/db/logs.js +85 -0
- package/dist/commands/db/ps.js +60 -0
- package/dist/commands/db/shared.js +96 -0
- package/dist/commands/db/start.js +71 -0
- package/dist/commands/db/stop.js +71 -0
- package/{templates/plugin/src/client/models/index.ts → dist/commands/dev.js} +4 -4
- package/{src/commands/locale/react-js-cron/index.js → dist/commands/down.js} +3 -8
- package/dist/commands/download.js +13 -0
- package/dist/commands/env/add.js +366 -0
- package/dist/commands/env/auth.js +130 -0
- package/dist/commands/env/current.js +21 -0
- package/dist/commands/env/info.js +157 -0
- package/dist/commands/env/list.js +44 -0
- package/dist/commands/env/remove.js +84 -0
- package/dist/commands/env/shared.js +158 -0
- package/dist/commands/env/status.js +90 -0
- package/dist/commands/env/update.js +74 -0
- package/dist/commands/env/use.js +38 -0
- package/dist/commands/examples/prompts-stages.js +150 -0
- package/dist/commands/examples/prompts-test.js +181 -0
- package/dist/commands/init.js +1092 -0
- package/dist/commands/install.js +2378 -0
- package/dist/commands/license/activate.js +360 -0
- package/dist/commands/license/env.js +94 -0
- package/dist/commands/license/generate-id.js +108 -0
- package/dist/commands/license/id.js +70 -0
- package/dist/commands/license/index.js +20 -0
- package/dist/commands/license/plugins/clean.js +115 -0
- package/dist/commands/license/plugins/index.js +20 -0
- package/dist/commands/license/plugins/list.js +64 -0
- package/dist/commands/license/plugins/shared.js +325 -0
- package/dist/commands/license/plugins/sync.js +285 -0
- package/dist/commands/license/shared.js +423 -0
- package/dist/commands/license/status.js +64 -0
- package/dist/commands/logs.js +12 -0
- package/dist/commands/plugin/disable.js +86 -0
- package/dist/commands/plugin/enable.js +86 -0
- package/dist/commands/plugin/list.js +82 -0
- package/dist/commands/pm/disable.js +12 -0
- package/dist/commands/pm/enable.js +12 -0
- package/dist/commands/pm/list.js +12 -0
- package/dist/commands/restart.js +12 -0
- package/dist/commands/scaffold/migration.js +38 -0
- package/dist/commands/scaffold/plugin.js +37 -0
- package/dist/commands/self/check.js +71 -0
- package/dist/commands/self/index.js +20 -0
- package/dist/commands/self/update.js +95 -0
- package/dist/commands/session/id.js +24 -0
- package/dist/commands/session/remove.js +57 -0
- package/dist/commands/session/setup.js +62 -0
- package/dist/commands/skills/check.js +69 -0
- package/dist/commands/skills/index.js +20 -0
- package/dist/commands/skills/install.js +80 -0
- package/dist/commands/skills/remove.js +80 -0
- package/dist/commands/skills/update.js +87 -0
- package/dist/commands/source/build.js +58 -0
- package/dist/commands/source/dev.js +182 -0
- package/dist/commands/source/download.js +880 -0
- package/dist/commands/source/publish.js +109 -0
- package/dist/commands/source/registry/logs.js +70 -0
- package/dist/commands/source/registry/start.js +57 -0
- package/dist/commands/source/registry/status.js +33 -0
- package/dist/commands/source/registry/stop.js +48 -0
- package/dist/commands/source/test.js +477 -0
- package/dist/commands/start.js +12 -0
- package/dist/commands/stop.js +12 -0
- package/dist/commands/test.js +12 -0
- package/dist/commands/upgrade.js +12 -0
- package/dist/commands/v1.js +210 -0
- package/dist/generated/command-registry.js +133 -0
- package/dist/help/runtime-help.js +23 -0
- package/dist/lib/api-client.js +329 -0
- package/dist/lib/app-health.js +126 -0
- package/dist/lib/app-managed-resources.js +316 -0
- package/dist/lib/app-runtime.js +180 -0
- package/dist/lib/auth-store.js +368 -0
- package/dist/lib/backup.js +171 -0
- package/dist/lib/bootstrap.js +403 -0
- package/dist/lib/build-config.js +18 -0
- package/dist/lib/builtin-db.js +86 -0
- package/dist/lib/cli-config.js +176 -0
- package/dist/lib/cli-home.js +47 -0
- package/dist/lib/cli-locale.js +129 -0
- package/dist/lib/command-discovery.js +39 -0
- package/dist/lib/db-connection-check.js +158 -0
- package/dist/lib/docker-env-file.js +52 -0
- package/dist/lib/docker-image.js +37 -0
- package/dist/lib/env-auth.js +873 -0
- package/dist/lib/env-config.js +94 -0
- package/dist/lib/env-guard.js +62 -0
- package/dist/lib/generated-command.js +186 -0
- package/dist/lib/http-request.js +49 -0
- package/dist/lib/inquirer-theme.js +17 -0
- package/dist/lib/inquirer.js +244 -0
- package/dist/lib/naming.js +70 -0
- package/dist/lib/object-utils.js +76 -0
- package/dist/lib/openapi.js +62 -0
- package/dist/lib/plugin-storage.js +64 -0
- package/dist/lib/post-processors.js +23 -0
- package/dist/lib/prompt-catalog-core.js +185 -0
- package/dist/lib/prompt-catalog-terminal.js +375 -0
- package/{src/index.js → dist/lib/prompt-catalog.js} +2 -6
- package/dist/lib/prompt-validators.js +240 -0
- package/dist/lib/prompt-web-ui.js +2103 -0
- package/dist/lib/resource-command.js +357 -0
- package/dist/lib/resource-request.js +104 -0
- package/dist/lib/run-npm.js +275 -0
- package/dist/lib/runtime-env-vars.js +32 -0
- package/dist/lib/runtime-generator.js +498 -0
- package/dist/lib/runtime-store.js +56 -0
- package/dist/lib/self-manager.js +301 -0
- package/dist/lib/session-id.js +17 -0
- package/dist/lib/session-integration.js +703 -0
- package/dist/lib/session-store.js +118 -0
- package/dist/lib/skills-manager.js +360 -0
- package/dist/lib/source-publish.js +306 -0
- package/dist/lib/source-registry.js +188 -0
- package/dist/lib/startup-update.js +285 -0
- package/dist/lib/ui.js +155 -0
- package/dist/locale/en-US.json +344 -0
- package/dist/locale/zh-CN.json +344 -0
- package/dist/post-processors/data-modeling.js +84 -0
- package/dist/post-processors/data-source-manager.js +138 -0
- package/dist/post-processors/index.js +19 -0
- package/nocobase-ctl.config.json +388 -0
- package/package.json +100 -26
- package/LICENSE +0 -661
- package/bin/index.js +0 -39
- package/nocobase.conf.tpl +0 -95
- package/src/commands/benchmark.js +0 -73
- package/src/commands/build.js +0 -49
- package/src/commands/clean.js +0 -30
- package/src/commands/client.js +0 -166
- package/src/commands/create-nginx-conf.js +0 -37
- package/src/commands/create-plugin.js +0 -33
- package/src/commands/dev.js +0 -200
- package/src/commands/doc.js +0 -76
- package/src/commands/e2e.js +0 -265
- package/src/commands/global.js +0 -43
- package/src/commands/index.js +0 -45
- package/src/commands/instance-id.js +0 -47
- package/src/commands/locale/cronstrue.js +0 -122
- package/src/commands/locale/react-js-cron/en-US.json +0 -75
- package/src/commands/locale/react-js-cron/zh-CN.json +0 -33
- package/src/commands/locale/react-js-cron/zh-TW.json +0 -33
- package/src/commands/locale.js +0 -81
- package/src/commands/p-test.js +0 -88
- package/src/commands/perf.js +0 -63
- package/src/commands/pkg.js +0 -321
- package/src/commands/pm2.js +0 -37
- package/src/commands/postinstall.js +0 -88
- package/src/commands/start.js +0 -148
- package/src/commands/tar.js +0 -36
- package/src/commands/test-coverage.js +0 -55
- package/src/commands/test.js +0 -107
- package/src/commands/umi.js +0 -33
- package/src/commands/update-deps.js +0 -72
- package/src/commands/upgrade.js +0 -47
- package/src/commands/view-license-key.js +0 -44
- package/src/license.js +0 -76
- package/src/logger.js +0 -75
- package/src/plugin-generator.js +0 -80
- package/src/util.js +0 -517
- package/templates/bundle-status.html +0 -338
- package/templates/create-app-package.json +0 -39
- package/templates/plugin/.npmignore.tpl +0 -2
- package/templates/plugin/README.md.tpl +0 -1
- package/templates/plugin/client.d.ts +0 -2
- package/templates/plugin/client.js +0 -1
- package/templates/plugin/package.json.tpl +0 -11
- package/templates/plugin/server.d.ts +0 -2
- package/templates/plugin/server.js +0 -1
- package/templates/plugin/src/client/client.d.ts +0 -249
- package/templates/plugin/src/client/index.tsx.tpl +0 -1
- package/templates/plugin/src/client/locale.ts +0 -21
- package/templates/plugin/src/client/plugin.tsx.tpl +0 -10
- package/templates/plugin/src/index.ts +0 -2
- package/templates/plugin/src/locale/en-US.json +0 -1
- package/templates/plugin/src/locale/zh-CN.json +0 -1
- package/templates/plugin/src/server/collections/.gitkeep +0 -0
- package/templates/plugin/src/server/index.ts.tpl +0 -1
- package/templates/plugin/src/server/plugin.ts.tpl +0 -19
|
@@ -0,0 +1,275 @@
|
|
|
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
|
+
* This file is part of the NocoBase (R) project.
|
|
11
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
12
|
+
* Authors: NocoBase Team.
|
|
13
|
+
*
|
|
14
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
15
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
16
|
+
*/
|
|
17
|
+
import fs from 'node:fs';
|
|
18
|
+
import fsp from 'node:fs/promises';
|
|
19
|
+
import os from 'node:os';
|
|
20
|
+
import path from 'node:path';
|
|
21
|
+
import spawn from 'cross-spawn';
|
|
22
|
+
const FORWARDED_SIGNALS = ['SIGINT', 'SIGTERM'];
|
|
23
|
+
function resolveCommandName(name) {
|
|
24
|
+
return name;
|
|
25
|
+
}
|
|
26
|
+
function pathExists(candidate) {
|
|
27
|
+
try {
|
|
28
|
+
return Boolean(candidate) && fs.statSync(candidate) !== undefined;
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function isDirectory(candidate) {
|
|
35
|
+
try {
|
|
36
|
+
return Boolean(candidate) && fs.statSync(candidate).isDirectory();
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function hasLocalNocoBaseBinary(candidate) {
|
|
43
|
+
return (pathExists(path.join(candidate, 'node_modules', '.bin', 'nocobase-v1'))
|
|
44
|
+
|| pathExists(path.join(candidate, 'node_modules', '.bin', 'nocobase-v1.cmd')));
|
|
45
|
+
}
|
|
46
|
+
export function resolveCwd(cwd) {
|
|
47
|
+
const next = cwd ?? process.cwd();
|
|
48
|
+
if (path.isAbsolute(next)) {
|
|
49
|
+
return next;
|
|
50
|
+
}
|
|
51
|
+
return path.resolve(process.cwd(), next);
|
|
52
|
+
}
|
|
53
|
+
export function resolveProjectCwd(cwd) {
|
|
54
|
+
const normalizedCwd = typeof cwd === 'string' && cwd.trim() === '' ? undefined : cwd;
|
|
55
|
+
const fallback = resolveCwd(normalizedCwd);
|
|
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();
|
|
64
|
+
while (true) {
|
|
65
|
+
if (hasLocalNocoBaseBinary(current)) {
|
|
66
|
+
return current;
|
|
67
|
+
}
|
|
68
|
+
const parent = path.dirname(current);
|
|
69
|
+
if (parent === current) {
|
|
70
|
+
if (hasExplicitInput) {
|
|
71
|
+
throw new Error(`Couldn't find a NocoBase source project from --cwd: ${fallback}`);
|
|
72
|
+
}
|
|
73
|
+
return fallback;
|
|
74
|
+
}
|
|
75
|
+
current = parent;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export function run(name, args, options) {
|
|
79
|
+
const cwd = resolveCwd(options?.cwd);
|
|
80
|
+
const label = options?.errorName ?? name;
|
|
81
|
+
const command = resolveCommandName(name);
|
|
82
|
+
return new Promise((resolve, reject) => {
|
|
83
|
+
const child = spawn(command, [...args], {
|
|
84
|
+
stdio: options?.stdio ?? 'inherit',
|
|
85
|
+
cwd,
|
|
86
|
+
env: {
|
|
87
|
+
...process.env,
|
|
88
|
+
...options?.env,
|
|
89
|
+
},
|
|
90
|
+
windowsHide: process.platform === 'win32',
|
|
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
|
+
}
|
|
106
|
+
const cleanupSignalForwarding = forwardSignalsToChild(child);
|
|
107
|
+
child.once('error', (error) => {
|
|
108
|
+
cleanupSignalForwarding();
|
|
109
|
+
reject(error);
|
|
110
|
+
});
|
|
111
|
+
child.once('close', (code, signal) => {
|
|
112
|
+
cleanupSignalForwarding();
|
|
113
|
+
if (code === 0) {
|
|
114
|
+
resolve();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (signal) {
|
|
118
|
+
reject(new Error(`${label} exited due to signal ${signal}`));
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
reject(new Error(`${label} exited with code ${code}`));
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function forwardSignalsToChild(child) {
|
|
126
|
+
let forwardedSignalCount = 0;
|
|
127
|
+
const listeners = new Map();
|
|
128
|
+
const isChildRunning = () => child.exitCode === null && child.signalCode === null;
|
|
129
|
+
for (const signal of FORWARDED_SIGNALS) {
|
|
130
|
+
const listener = () => {
|
|
131
|
+
if (!isChildRunning()) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const nextSignal = forwardedSignalCount > 0 ? 'SIGKILL' : signal;
|
|
135
|
+
forwardedSignalCount += 1;
|
|
136
|
+
try {
|
|
137
|
+
child.kill(nextSignal);
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
// Ignore kill errors here and let the child close/error handlers surface the failure.
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
listeners.set(signal, listener);
|
|
144
|
+
process.on(signal, listener);
|
|
145
|
+
}
|
|
146
|
+
return () => {
|
|
147
|
+
for (const [signal, listener] of listeners) {
|
|
148
|
+
process.off(signal, listener);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
export function commandSucceeds(name, args, options) {
|
|
153
|
+
const cwd = resolveCwd(options?.cwd);
|
|
154
|
+
const command = resolveCommandName(name);
|
|
155
|
+
return new Promise((resolve) => {
|
|
156
|
+
const child = spawn(command, [...args], {
|
|
157
|
+
cwd,
|
|
158
|
+
env: {
|
|
159
|
+
...process.env,
|
|
160
|
+
...options?.env,
|
|
161
|
+
},
|
|
162
|
+
stdio: 'ignore',
|
|
163
|
+
windowsHide: process.platform === 'win32',
|
|
164
|
+
});
|
|
165
|
+
child.once('error', () => resolve(false));
|
|
166
|
+
child.once('close', (code) => resolve(code === 0));
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
export function commandOutput(name, args, options) {
|
|
170
|
+
const cwd = resolveCwd(options?.cwd);
|
|
171
|
+
const label = options?.errorName ?? name;
|
|
172
|
+
const command = resolveCommandName(name);
|
|
173
|
+
return new Promise((resolve, reject) => {
|
|
174
|
+
const child = spawn(command, [...args], {
|
|
175
|
+
cwd,
|
|
176
|
+
env: {
|
|
177
|
+
...process.env,
|
|
178
|
+
...options?.env,
|
|
179
|
+
},
|
|
180
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
181
|
+
windowsHide: process.platform === 'win32',
|
|
182
|
+
});
|
|
183
|
+
let stdout = '';
|
|
184
|
+
let stderr = '';
|
|
185
|
+
child.stdout.setEncoding('utf8');
|
|
186
|
+
child.stderr.setEncoding('utf8');
|
|
187
|
+
child.stdout.on('data', (chunk) => {
|
|
188
|
+
stdout += chunk;
|
|
189
|
+
});
|
|
190
|
+
child.stderr.on('data', (chunk) => {
|
|
191
|
+
stderr += chunk;
|
|
192
|
+
});
|
|
193
|
+
child.once('error', reject);
|
|
194
|
+
child.once('close', (code, signal) => {
|
|
195
|
+
if (code === 0) {
|
|
196
|
+
resolve(stdout.trim());
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (signal) {
|
|
200
|
+
reject(new Error(`${label} exited due to signal ${signal}`));
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const details = stderr.trim() || stdout.trim();
|
|
204
|
+
reject(new Error(details ? `${label} exited with code ${code}: ${details}` : `${label} exited with code ${code}`));
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
async function readCommandOutputFile(filePath) {
|
|
209
|
+
try {
|
|
210
|
+
return await fsp.readFile(filePath, 'utf8');
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
return '';
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
export async function commandOutputViaFile(name, args, options) {
|
|
217
|
+
const cwd = resolveCwd(options?.cwd);
|
|
218
|
+
const label = options?.errorName ?? name;
|
|
219
|
+
const command = resolveCommandName(name);
|
|
220
|
+
const captureDir = await fsp.mkdtemp(path.join(os.tmpdir(), 'nocobase-cli-output-'));
|
|
221
|
+
const stdoutPath = path.join(captureDir, 'stdout.log');
|
|
222
|
+
const stderrPath = path.join(captureDir, 'stderr.log');
|
|
223
|
+
const stdoutHandle = await fsp.open(stdoutPath, 'w');
|
|
224
|
+
const stderrHandle = await fsp.open(stderrPath, 'w');
|
|
225
|
+
try {
|
|
226
|
+
const result = await new Promise((resolve, reject) => {
|
|
227
|
+
const child = spawn(command, [...args], {
|
|
228
|
+
cwd,
|
|
229
|
+
env: {
|
|
230
|
+
...process.env,
|
|
231
|
+
...options?.env,
|
|
232
|
+
},
|
|
233
|
+
stdio: ['ignore', stdoutHandle.fd, stderrHandle.fd],
|
|
234
|
+
windowsHide: process.platform === 'win32',
|
|
235
|
+
});
|
|
236
|
+
child.once('error', reject);
|
|
237
|
+
child.once('close', (code, signal) => {
|
|
238
|
+
resolve({ code, signal });
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
await stdoutHandle.close();
|
|
242
|
+
await stderrHandle.close();
|
|
243
|
+
const stdout = await readCommandOutputFile(stdoutPath);
|
|
244
|
+
const stderr = await readCommandOutputFile(stderrPath);
|
|
245
|
+
if (result.code === 0) {
|
|
246
|
+
return stdout.trim();
|
|
247
|
+
}
|
|
248
|
+
if (result.signal) {
|
|
249
|
+
throw new Error(`${label} exited due to signal ${result.signal}`);
|
|
250
|
+
}
|
|
251
|
+
const details = stderr.trim() || stdout.trim();
|
|
252
|
+
throw new Error(details ? `${label} exited with code ${result.code}: ${details}` : `${label} exited with code ${result.code}`);
|
|
253
|
+
}
|
|
254
|
+
finally {
|
|
255
|
+
await Promise.allSettled([stdoutHandle.close(), stderrHandle.close()]);
|
|
256
|
+
await fsp.rm(captureDir, { recursive: true, force: true });
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/** Run `yarn` with the given argument list, inheriting stdio (errors label as `npm` for compatibility). */
|
|
260
|
+
export function runNpm(args, options) {
|
|
261
|
+
return run('yarn', [...args], { ...options, errorName: 'npm' });
|
|
262
|
+
}
|
|
263
|
+
export function runNocoBaseCommand(args, options) {
|
|
264
|
+
const cwd = resolveProjectCwd(options?.cwd);
|
|
265
|
+
const localBin = path.join(cwd, 'node_modules', '.bin');
|
|
266
|
+
return run('nocobase-v1', [...args], {
|
|
267
|
+
...options,
|
|
268
|
+
cwd,
|
|
269
|
+
errorName: 'nocobase command',
|
|
270
|
+
env: {
|
|
271
|
+
PATH: `${localBin}${path.delimiter}${process.env.PATH ?? ''}`,
|
|
272
|
+
...options?.env,
|
|
273
|
+
},
|
|
274
|
+
});
|
|
275
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
import { resolveBuiltinDbConnection } from './builtin-db.js';
|
|
10
|
+
function put(out, key, value) {
|
|
11
|
+
if (value === undefined || value === null) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
out[key] = String(value);
|
|
15
|
+
}
|
|
16
|
+
export async function buildRuntimeEnvVars(runtime) {
|
|
17
|
+
const config = runtime.env.config ?? {};
|
|
18
|
+
const out = {
|
|
19
|
+
...runtime.env.envVars,
|
|
20
|
+
};
|
|
21
|
+
if (runtime.kind !== 'local' && runtime.kind !== 'docker') {
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
if (!config.builtinDb) {
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
const connection = await resolveBuiltinDbConnection(runtime);
|
|
28
|
+
put(out, 'DB_DIALECT', connection.dbDialect);
|
|
29
|
+
put(out, 'DB_HOST', connection.dbHost);
|
|
30
|
+
put(out, 'DB_PORT', connection.dbPort);
|
|
31
|
+
return out;
|
|
32
|
+
}
|