@nocobase/cli 2.1.0-beta.27 → 2.1.0-beta.30
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 +14 -0
- package/README.zh-CN.md +14 -0
- package/bin/run.js +3 -0
- package/bin/session-env.js +27 -0
- package/dist/commands/app/down.js +47 -9
- package/dist/commands/app/logs.js +17 -0
- package/dist/commands/app/restart.js +23 -1
- package/dist/commands/app/start.js +17 -0
- package/dist/commands/app/stop.js +17 -0
- package/dist/commands/app/upgrade.js +22 -2
- package/dist/commands/db/check.js +6 -4
- package/dist/commands/db/ps.js +1 -1
- package/dist/commands/env/add.js +3 -2
- package/dist/commands/env/auth.js +1 -1
- package/dist/commands/env/current.js +21 -0
- package/dist/commands/env/info.js +4 -3
- package/dist/commands/env/list.js +8 -14
- package/dist/commands/env/remove.js +2 -2
- package/dist/commands/env/status.js +90 -0
- package/dist/commands/env/update.js +1 -1
- package/dist/commands/env/use.js +11 -1
- package/dist/commands/install.js +10 -4
- package/dist/commands/license/activate.js +20 -24
- package/dist/commands/license/id.js +17 -2
- package/dist/commands/license/plugins/clean.js +17 -2
- package/dist/commands/license/plugins/list.js +17 -2
- package/dist/commands/license/plugins/sync.js +22 -5
- package/dist/commands/license/shared.js +15 -6
- package/dist/commands/license/status.js +17 -2
- package/dist/commands/plugin/disable.js +25 -4
- package/dist/commands/plugin/enable.js +25 -4
- package/dist/commands/plugin/list.js +25 -4
- 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/source/dev.js +19 -1
- package/dist/commands/source/download.js +10 -8
- package/dist/lib/app-managed-resources.js +5 -3
- package/dist/lib/app-runtime.js +1 -1
- package/dist/lib/auth-store.js +28 -11
- package/dist/lib/docker-image.js +37 -0
- package/dist/lib/env-guard.js +61 -0
- package/dist/lib/generated-command.js +16 -0
- package/dist/lib/plugin-storage.js +1 -64
- package/dist/lib/resource-command.js +15 -0
- package/dist/lib/runtime-generator.js +1 -1
- 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/package.json +3 -3
|
@@ -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 { access, lstat,
|
|
10
|
+
import { access, lstat, readlink, rm } from 'node:fs/promises';
|
|
11
11
|
async function pathExists(target) {
|
|
12
12
|
try {
|
|
13
13
|
await access(target);
|
|
@@ -28,69 +28,6 @@ export function resolvePluginStoragePath(storagePath) {
|
|
|
28
28
|
}
|
|
29
29
|
return path.resolve(process.cwd(), 'storage', 'plugins');
|
|
30
30
|
}
|
|
31
|
-
async function getStoragePluginNames(target) {
|
|
32
|
-
const plugins = [];
|
|
33
|
-
const items = await readdir(target);
|
|
34
|
-
for (const item of items) {
|
|
35
|
-
const itemPath = path.resolve(target, item);
|
|
36
|
-
if (item.startsWith('@')) {
|
|
37
|
-
const statResult = await stat(itemPath);
|
|
38
|
-
if (!statResult.isDirectory()) {
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
const children = await getStoragePluginNames(itemPath);
|
|
42
|
-
plugins.push(...children.map((child) => `${item}/${child}`));
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
if (await pathExists(path.resolve(itemPath, 'package.json'))) {
|
|
46
|
-
plugins.push(item);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return plugins;
|
|
50
|
-
}
|
|
51
|
-
async function ensureOrgDirectory(nodeModulesPath, pluginName) {
|
|
52
|
-
if (!pluginName.startsWith('@')) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const [orgName] = pluginName.split('/');
|
|
56
|
-
await mkdir(path.resolve(nodeModulesPath, orgName), { recursive: true });
|
|
57
|
-
}
|
|
58
|
-
async function isSymlinkValid(linkPath, targetPath) {
|
|
59
|
-
try {
|
|
60
|
-
if (await pathExists(linkPath)) {
|
|
61
|
-
const realPath = await realpath(linkPath);
|
|
62
|
-
return realPath === targetPath;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
catch {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
async function createStoragePluginSymlink(storagePluginsPath, nodeModulesPath, pluginName) {
|
|
71
|
-
const targetPath = path.resolve(storagePluginsPath, pluginName);
|
|
72
|
-
if (!(await pathExists(targetPath))) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
await ensureOrgDirectory(nodeModulesPath, pluginName);
|
|
76
|
-
const linkPath = path.resolve(nodeModulesPath, pluginName);
|
|
77
|
-
if (await isSymlinkValid(linkPath, targetPath)) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
await rm(linkPath, { recursive: true, force: true });
|
|
81
|
-
await symlink(targetPath, linkPath, 'dir');
|
|
82
|
-
}
|
|
83
|
-
export async function createStoragePluginsSymlink(storagePath, nodeModulesPath = String(process.env.NODE_MODULES_PATH ?? '').trim()) {
|
|
84
|
-
if (!nodeModulesPath) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const storagePluginsPath = resolvePluginStoragePath(storagePath);
|
|
88
|
-
if (!(await pathExists(storagePluginsPath))) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
const pluginNames = await getStoragePluginNames(storagePluginsPath);
|
|
92
|
-
await Promise.all(pluginNames.map(async (pluginName) => await createStoragePluginSymlink(storagePluginsPath, nodeModulesPath, pluginName)));
|
|
93
|
-
}
|
|
94
31
|
export async function removeStoragePluginSymlink(pluginName, storagePath, nodeModulesPath = String(process.env.NODE_MODULES_PATH ?? '').trim()) {
|
|
95
32
|
if (!nodeModulesPath) {
|
|
96
33
|
return false;
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import { Flags } from '@oclif/core';
|
|
10
|
+
import { ensureCrossEnvConfirmed } from './env-guard.js';
|
|
10
11
|
import { executeResourceRequest } from './resource-request.js';
|
|
11
12
|
import { setVerboseMode } from './ui.js';
|
|
12
13
|
function parseJson(value, flagName) {
|
|
@@ -95,6 +96,11 @@ export const resourceBaseFlags = {
|
|
|
95
96
|
description: 'Show detailed progress output',
|
|
96
97
|
default: false,
|
|
97
98
|
}),
|
|
99
|
+
yes: Flags.boolean({
|
|
100
|
+
char: 'y',
|
|
101
|
+
description: 'Confirm using --env when it targets a different env than the current env',
|
|
102
|
+
default: false,
|
|
103
|
+
}),
|
|
98
104
|
env: Flags.string({
|
|
99
105
|
char: 'e',
|
|
100
106
|
description: 'Environment name',
|
|
@@ -331,6 +337,15 @@ export function buildQueryArgs(flags) {
|
|
|
331
337
|
}
|
|
332
338
|
export async function runResourceCommand(command, action, flags, args) {
|
|
333
339
|
setVerboseMode(Boolean(flags.verbose));
|
|
340
|
+
const confirmed = await ensureCrossEnvConfirmed({
|
|
341
|
+
command,
|
|
342
|
+
requestedEnv: flags.env,
|
|
343
|
+
yes: flags.yes,
|
|
344
|
+
});
|
|
345
|
+
if (!confirmed) {
|
|
346
|
+
command.log('Canceled.');
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
334
349
|
const response = await executeResourceRequest({
|
|
335
350
|
envName: flags.env,
|
|
336
351
|
baseUrl: flags['api-base-url'],
|
|
@@ -18,7 +18,7 @@ import { createHash } from 'node:crypto';
|
|
|
18
18
|
import { loadBuildConfig } from './build-config.js';
|
|
19
19
|
import { toKebabCase, toLogicalActionName, toLogicalResourceName, toResourceSegments } from './naming.js';
|
|
20
20
|
import { collectOperations } from './openapi.js';
|
|
21
|
-
const RESERVED_FLAG_NAMES = new Set(['api-base-url', 'base-url', 'env', 'token', 'json-output', 'body', 'body-file']);
|
|
21
|
+
const RESERVED_FLAG_NAMES = new Set(['api-base-url', 'base-url', 'env', 'token', 'json-output', 'body', 'body-file', 'yes']);
|
|
22
22
|
function matchesPattern(value, pattern) {
|
|
23
23
|
if (!value) {
|
|
24
24
|
return false;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
export function resolveSessionIdentity() {
|
|
10
|
+
const sessionId = String(process.env.NB_SESSION_ID ?? '').trim();
|
|
11
|
+
if (sessionId) {
|
|
12
|
+
return {
|
|
13
|
+
id: sessionId,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|