@aiot-nexus/plugin-sdk 3.0.2 → 3.1.1
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 +67 -15
- package/dev-host/main.js +8 -5
- package/dist/.generated/plugin-framework-version.d.ts +1 -1
- package/dist/.generated/plugin-framework-version.js +1 -1
- package/dist/.generated/plugin-manifest.schema.json +2 -1
- package/dist/src/cli/run.js +79 -4
- package/dist/src/cli/update-notice.js +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +2 -2
- package/dist/src/scaffold.js +6 -5
- package/dist/src/sdk-info.d.ts +17 -0
- package/dist/src/sdk-info.js +23 -0
- package/dist/src/types.d.ts +1 -0
- package/dist/src/upgrade.d.ts +44 -0
- package/dist/src/upgrade.js +1198 -0
- package/dist/src/validation.js +9 -0
- package/package.json +2 -2
- package/scripts/sdk-update-check.js +1 -1
- package/templates/minimal/README.md.tmpl +3 -3
- package/templates/sqlite/README.md.tmpl +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @aiot-nexus/plugin-sdk
|
|
2
2
|
|
|
3
|
-
> 当前 SDK 包版本为 `3.
|
|
3
|
+
> 当前 SDK 包版本为 `3.1.1`,Framework API 为 `3.1.0`,manifest schema 保持 `1`。Framework 3 将可信插件的 `mainEntry` 直接加载到 Nexus Electron 主进程;它不是安全沙箱。PluginFrame iframe 仍保持 sandbox、无 Node/Electron 访问。宿主运行模型见 [Framework v3 架构](../docs/plugin-framework-v3-architecture.md)。
|
|
4
4
|
|
|
5
5
|
本包提供公开 TypeScript 契约、PluginFrame 浏览器客户端和 `nexus-plugin` CLI。v2 项目升级前请先阅读 [v2 到 v3 迁移说明](../docs/plugin-framework-v2-v3-migration.md)。完整开发流程见 [独立插件开发指南](../docs/standalone-plugin-development-guide.md)。
|
|
6
6
|
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
| 项目 | 固定值 |
|
|
10
10
|
| --- | --- |
|
|
11
|
-
| SDK | `3.
|
|
12
|
-
| Framework API | `3.
|
|
11
|
+
| SDK | `3.1.1` |
|
|
12
|
+
| Framework API | `3.1.0` |
|
|
13
13
|
| Manifest schema | `1` |
|
|
14
14
|
| Node 安装和构建 | `>=16.20.0 <17` |
|
|
15
15
|
| Electron | `22.3.27` |
|
|
@@ -21,9 +21,10 @@
|
|
|
21
21
|
## CLI
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
nexus-plugin info
|
|
24
|
+
nexus-plugin info [--json]
|
|
25
25
|
nexus-plugin validate <plugin-package-directory>
|
|
26
26
|
nexus-plugin create <plugin-id> --template minimal|sqlite --output <parent-directory>
|
|
27
|
+
nexus-plugin upgrade [plugin-project-directory] [--check] [--sdk-source <version-or-local-tgz>]
|
|
27
28
|
nexus-plugin dev [plugin-project-directory]
|
|
28
29
|
nexus-plugin dev:web [plugin-project-directory]
|
|
29
30
|
nexus-plugin dev:nexus [plugin-project-directory] --host <nexus.exe-or-directory>
|
|
@@ -38,7 +39,35 @@ npm run pack:sdk
|
|
|
38
39
|
npm run publish:sdk
|
|
39
40
|
```
|
|
40
41
|
|
|
41
|
-
`pack:sdk` 把离线 tgz 写入 `plugin-sdk/package/`。`publish:sdk` 的 `prepack` 会运行测试、构建和公开文件清单验证。安装阶段和 CLI 启动阶段会非阻塞检查 SDK 更新;设置 `NEXUS_PLUGIN_SDK_UPDATE_CHECK=0` 或 `NO_UPDATE_NOTIFIER=1`
|
|
42
|
+
`pack:sdk` 把离线 tgz 写入 `plugin-sdk/package/`。`publish:sdk` 的 `prepack` 会运行测试、构建和公开文件清单验证。安装阶段和 CLI 启动阶段会非阻塞检查 SDK 更新;设置 `NEXUS_PLUGIN_SDK_UPDATE_CHECK=0` 或 `NO_UPDATE_NOTIFIER=1` 可关闭检查。检查失败不会阻断安装、构建或调试,版本通知本身不会修改依赖;只有显式执行 `upgrade` 才会进入升级事务。
|
|
43
|
+
|
|
44
|
+
## 升级插件工程 SDK
|
|
45
|
+
|
|
46
|
+
标准插件工程的 `nexus-plugin` 来自本地 `@aiot-nexus/plugin-sdk`,因此 CLI 和工程 SDK 是同一个依赖。旧工程应由目标版本的 CLI 执行升级,不能只手工修改 `package.json`,因为 lockfile 和 `node_modules` 仍可能保留旧版本。
|
|
47
|
+
|
|
48
|
+
registry 升级与只读预检:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npx --package=@aiot-nexus/plugin-sdk@3.1.1 nexus-plugin upgrade . --check
|
|
52
|
+
npx --package=@aiot-nexus/plugin-sdk@3.1.1 nexus-plugin upgrade .
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
发布前或本地 tgz:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npx --package=./aiot-nexus-plugin-sdk-3.1.1.tgz nexus-plugin upgrade . \
|
|
59
|
+
--sdk-source ./aiot-nexus-plugin-sdk-3.1.1.tgz
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
CI 可以追加 `--json` 获得 `up-to-date`、`upgrade-available`、`upgraded`、`rolled-back` 或 `blocked`。`--allow-major` 只解除 major 保护,不会改写业务源码;跨 major 必须先阅读迁移指南。`--skip-project-checks` 只跳过项目 typecheck/build,安装后的 SDK、package 和 lockfile 一致性仍会验证。
|
|
63
|
+
|
|
64
|
+
升级器直接修改的范围只有 SDK 依赖、`package-lock.json`、`node_modules` 和命令管理的 SDK tgz。本地包会保存为 `vendor/aiot-nexus-plugin-sdk-<version>.tgz`,下一次本地升级会安全清理上一份由命令管理的版本化归档。Electron、TypeScript、`@types/node` 和 Node engine 只检查不修改;manifest、模板、README、构建脚本和业务依赖不会被覆盖。
|
|
65
|
+
|
|
66
|
+
修改前,命令会在项目根目录创建 `.nexus-plugin-upgrade-recovery/`,持久备份 package、lock、受管 tgz 和标准 `dist/<pluginId>`,并写入 `recovery.json` 阶段记录。成功或确定性回滚后该目录自动删除;硬中断、回滚重装失败或清理失败时保留,后续 upgrade 会停止并要求先按 journal 恢复。不要在项目恢复并完成验证前删除它。
|
|
67
|
+
|
|
68
|
+
安装或项目验证失败时恢复备份,并在原 lockfile 存在时运行 `npm ci`。没有原 lockfile 时会运行 `npm install` 并恢复原 SDK,但无法证明完整传递依赖树与升级前一致,因此返回 `blocked` 并保留恢复数据。标准脚手架 build 的 `dist/<pluginId>` 在回滚范围内;自定义 typecheck/build 若修改其他路径,这些副作用不属于升级事务,项目必须自行管理。
|
|
69
|
+
|
|
70
|
+
SDK `3.0.2` 或 `3.1.0` 升级到 `3.1.1` 后,原有 `hostApiVersion: 3.0.0` 可以保持不变。只有实际使用 `showHostStatusBar` 等 3.1 专属字段时,才把 manifest 声明提升到 `3.1.0`。SDK 3.1.1 修复了 registry 升级时把裸版本号误传给 `npm install` 的问题;全局安装 3.1.0 的用户应先把全局 CLI 更新到 3.1.1。
|
|
42
71
|
|
|
43
72
|
## 创建插件
|
|
44
73
|
|
|
@@ -61,10 +90,32 @@ nexus-plugin create my-frame-plugin \
|
|
|
61
90
|
|
|
62
91
|
```bash
|
|
63
92
|
npm run pack:sdk
|
|
64
|
-
nexus-plugin create my-frame-plugin --sdk-source ./package/aiot-nexus-plugin-sdk-3.
|
|
93
|
+
nexus-plugin create my-frame-plugin --sdk-source ./package/aiot-nexus-plugin-sdk-3.1.1.tgz --install
|
|
65
94
|
```
|
|
66
95
|
|
|
67
|
-
|
|
96
|
+
生成插件后,可以在 `src/manifest.json` 的业务入口中静态控制 Nexus 宿主状态栏。相关 manifest 片段如下,其余必填字段沿用脚手架生成值:
|
|
97
|
+
|
|
98
|
+
```json
|
|
99
|
+
{
|
|
100
|
+
"hostApiVersion": "3.1.0",
|
|
101
|
+
"businessEntries": [
|
|
102
|
+
{
|
|
103
|
+
"businessId": "my-frame-plugin",
|
|
104
|
+
"titleKey": "plugin.displayName",
|
|
105
|
+
"iconKey": "extension",
|
|
106
|
+
"section": "home.main",
|
|
107
|
+
"order": 50,
|
|
108
|
+
"component": "PluginFrame",
|
|
109
|
+
"pageRoute": "my-frame-plugin",
|
|
110
|
+
"showHostStatusBar": false
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
仅显式设置为 `false` 时隐藏。字段省略或设置为 `true` 时显示;离开该业务入口后,宿主状态栏自动恢复。该字段要求 `hostApiVersion >= 3.1.0`。
|
|
117
|
+
|
|
118
|
+
## Framework 3.1 mainEntry
|
|
68
119
|
|
|
69
120
|
`mainEntry` 是可信 Electron 主进程代码,可直接导入 Electron、Node 内置模块和插件本地依赖:
|
|
70
121
|
|
|
@@ -196,11 +247,12 @@ VS Code 模板提供 `Debug Nexus plugin` 和 `Attach Nexus plugin main process
|
|
|
196
247
|
|
|
197
248
|
## 发布前检查
|
|
198
249
|
|
|
199
|
-
1. `hostApiVersion` 为 `3.
|
|
200
|
-
2. `
|
|
201
|
-
3.
|
|
202
|
-
4.
|
|
203
|
-
5.
|
|
204
|
-
6.
|
|
205
|
-
7.
|
|
206
|
-
8.
|
|
250
|
+
1. `hostApiVersion` 为 `3.1.0`,manifest schema 仍为 `1`。
|
|
251
|
+
2. 业务入口的 `showHostStatusBar` 可静态声明是否保留宿主状态栏;省略时默认保留,显式使用时要求 `hostApiVersion >= 3.1.0`。
|
|
252
|
+
3. `activate/deactivate` 同步,operation handler 才使用异步。
|
|
253
|
+
4. Renderer 只使用窄口径 operation,所有输入在 mainEntry 再校验。
|
|
254
|
+
5. 窗口保持 `contextIsolation: true`、`sandbox: true`、`nodeIntegration: false`、`webSecurity: true`。
|
|
255
|
+
6. IPC、protocol、快捷键、菜单和文件路径使用插件命名空间并检测冲突。
|
|
256
|
+
7. `deactivate` 关闭窗口、Session 监听、IPC、protocol、快捷键、定时器、数据库和子进程。
|
|
257
|
+
8. 没有同步长任务、无限载荷、任意命令/SQL/路径透传或日志敏感信息。
|
|
258
|
+
9. 运行 `npm test`、插件构建、正式 Nexus 集成和 Windows 7 真机验收。
|
package/dev-host/main.js
CHANGED
|
@@ -191,13 +191,13 @@ function activatePluginMainEntry() {
|
|
|
191
191
|
throw new Error("Plugin activate export must be a function.");
|
|
192
192
|
}
|
|
193
193
|
if (isAsyncFunction(activate)) {
|
|
194
|
-
throw new Error("Plugin activate must complete synchronously in Framework API 3.
|
|
194
|
+
throw new Error("Plugin activate must complete synchronously in Framework API 3.1.0.");
|
|
195
195
|
}
|
|
196
196
|
activationStarted = true;
|
|
197
197
|
const result = activate(createActivationContext());
|
|
198
198
|
if (isPromiseLike(result)) {
|
|
199
199
|
observeRejectedLifecyclePromise(result, "activate");
|
|
200
|
-
throw new Error("Plugin activate must complete synchronously in Framework API 3.
|
|
200
|
+
throw new Error("Plugin activate must complete synchronously in Framework API 3.1.0.");
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
pluginActivated = true;
|
|
@@ -265,13 +265,13 @@ function deactivatePluginMainEntry(reason) {
|
|
|
265
265
|
return;
|
|
266
266
|
}
|
|
267
267
|
if (typeof deactivate !== "function" || isAsyncFunction(deactivate)) {
|
|
268
|
-
process.stderr.write("[nexus-plugin-dev] plugin deactivate must complete synchronously in Framework API 3.
|
|
268
|
+
process.stderr.write("[nexus-plugin-dev] plugin deactivate must complete synchronously in Framework API 3.1.0.\n");
|
|
269
269
|
return;
|
|
270
270
|
}
|
|
271
271
|
const result = deactivate(reason);
|
|
272
272
|
if (isPromiseLike(result)) {
|
|
273
273
|
observeRejectedLifecyclePromise(result, "deactivate");
|
|
274
|
-
process.stderr.write("[nexus-plugin-dev] plugin deactivate must complete synchronously in Framework API 3.
|
|
274
|
+
process.stderr.write("[nexus-plugin-dev] plugin deactivate must complete synchronously in Framework API 3.1.0.\n");
|
|
275
275
|
}
|
|
276
276
|
} catch (error) {
|
|
277
277
|
process.stderr.write("[nexus-plugin-dev] plugin deactivation failed: " + errorMessage(error) + "\n");
|
|
@@ -440,7 +440,10 @@ async function verifyRendererContextSmoke() {
|
|
|
440
440
|
if (!frame) {
|
|
441
441
|
throw new Error("Plugin renderer frame was not found.");
|
|
442
442
|
}
|
|
443
|
-
if (
|
|
443
|
+
if (!sdk.isPluginFrameworkVersionCompatible(
|
|
444
|
+
configuration.manifest.hostApiVersion,
|
|
445
|
+
sdk.PLUGIN_FRAMEWORK_VERSION
|
|
446
|
+
)
|
|
444
447
|
|| (configuration.manifest.mainEntry && !pluginActivated)
|
|
445
448
|
|| configuration.manifest.minHostVersion === undefined) {
|
|
446
449
|
throw new Error("Development Host API version contract is inconsistent.");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const PLUGIN_FRAMEWORK_VERSION = "3.
|
|
1
|
+
export declare const PLUGIN_FRAMEWORK_VERSION = "3.1.0";
|
|
2
2
|
export declare const PLUGIN_MANIFEST_SCHEMA_VERSION = 1;
|
|
3
3
|
export declare const PLUGIN_COMPATIBLE_VERSION_PATTERN = "^(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))?(\\.(0|[1-9][0-9]*))?$";
|
|
4
4
|
export interface ParsedPluginVersion {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isPluginFrameworkVersionCompatible = exports.comparePluginVersions = exports.parsePluginCompatibleVersion = exports.PLUGIN_COMPATIBLE_VERSION_PATTERN = exports.PLUGIN_MANIFEST_SCHEMA_VERSION = exports.PLUGIN_FRAMEWORK_VERSION = void 0;
|
|
4
|
-
exports.PLUGIN_FRAMEWORK_VERSION = "3.
|
|
4
|
+
exports.PLUGIN_FRAMEWORK_VERSION = "3.1.0";
|
|
5
5
|
exports.PLUGIN_MANIFEST_SCHEMA_VERSION = 1;
|
|
6
6
|
exports.PLUGIN_COMPATIBLE_VERSION_PATTERN = "^(0|[1-9][0-9]*)(\\.(0|[1-9][0-9]*))?(\\.(0|[1-9][0-9]*))?$";
|
|
7
7
|
function parsePluginCompatibleVersion(value) {
|
|
@@ -73,7 +73,8 @@
|
|
|
73
73
|
"component": { "type": "string", "minLength": 1 },
|
|
74
74
|
"pageRoute": { "type": "string", "minLength": 1 },
|
|
75
75
|
"isFullBleed": { "type": "boolean" },
|
|
76
|
-
"showBusinessLogToggle": { "type": "boolean" }
|
|
76
|
+
"showBusinessLogToggle": { "type": "boolean" },
|
|
77
|
+
"showHostStatusBar": { "type": "boolean" }
|
|
77
78
|
}
|
|
78
79
|
},
|
|
79
80
|
"tool": {
|
package/dist/src/cli/run.js
CHANGED
|
@@ -30,7 +30,7 @@ const scaffold_1 = require("../scaffold");
|
|
|
30
30
|
const dev_1 = require("../dev");
|
|
31
31
|
const web_dev_1 = require("../web-dev");
|
|
32
32
|
const nexus_dev_1 = require("../nexus-dev");
|
|
33
|
-
const
|
|
33
|
+
const upgrade_1 = require("../upgrade");
|
|
34
34
|
function runCli(args, io) {
|
|
35
35
|
const command = args[0];
|
|
36
36
|
if (command === "--help" || command === "-h") {
|
|
@@ -38,14 +38,21 @@ function runCli(args, io) {
|
|
|
38
38
|
return 0;
|
|
39
39
|
}
|
|
40
40
|
if (command === "info") {
|
|
41
|
+
if (args.length === 2 && args[1] === "--json") {
|
|
42
|
+
io.stdout(JSON.stringify((0, index_1.getPluginSdkInfo)(), null, 2));
|
|
43
|
+
return 0;
|
|
44
|
+
}
|
|
41
45
|
if (args.length !== 1) {
|
|
42
|
-
return usageError(io, "info
|
|
46
|
+
return usageError(io, "info only accepts --json.");
|
|
43
47
|
}
|
|
44
48
|
io.stdout([
|
|
45
49
|
"SDK version: " + index_1.PLUGIN_SDK_VERSION,
|
|
46
50
|
"Plugin Framework API: " + index_1.PLUGIN_FRAMEWORK_VERSION,
|
|
47
51
|
"Manifest schema: " + index_1.PLUGIN_MANIFEST_SCHEMA_VERSION,
|
|
48
|
-
"Node engine: " +
|
|
52
|
+
"Node engine: " + index_1.PLUGIN_SDK_NODE_ENGINE,
|
|
53
|
+
"npm engine: " + index_1.PLUGIN_SDK_NPM_ENGINE,
|
|
54
|
+
"Electron: " + index_1.PLUGIN_SDK_ELECTRON_VERSION,
|
|
55
|
+
"TypeScript: " + index_1.PLUGIN_SDK_TYPESCRIPT_VERSION
|
|
49
56
|
].join("\n"));
|
|
50
57
|
return 0;
|
|
51
58
|
}
|
|
@@ -65,6 +72,9 @@ function runCli(args, io) {
|
|
|
65
72
|
if (command === "create") {
|
|
66
73
|
return runCreate(args.slice(1), io);
|
|
67
74
|
}
|
|
75
|
+
if (command === "upgrade") {
|
|
76
|
+
return runUpgrade(args.slice(1), io);
|
|
77
|
+
}
|
|
68
78
|
if (command === "dev") {
|
|
69
79
|
return runDev(args.slice(1), io);
|
|
70
80
|
}
|
|
@@ -80,10 +90,12 @@ exports.runCli = runCli;
|
|
|
80
90
|
function usage() {
|
|
81
91
|
return [
|
|
82
92
|
"Usage:",
|
|
83
|
-
" nexus-plugin info",
|
|
93
|
+
" nexus-plugin info [--json]",
|
|
84
94
|
" nexus-plugin validate <plugin-package-directory>",
|
|
85
95
|
" nexus-plugin create <plugin-id> [--template minimal|sqlite] [--output <parent-directory>]",
|
|
86
96
|
" [--display-name <name>] [--sdk-source <version-or-local-tgz>] [--install]",
|
|
97
|
+
" nexus-plugin upgrade [plugin-project-directory] [--check] [--sdk-source <version-or-local-tgz>]",
|
|
98
|
+
" [--allow-major] [--skip-project-checks] [--json]",
|
|
87
99
|
" nexus-plugin dev [plugin-project-directory] [--no-build] [--inspect[=<port>] | --inspect-brk[=<port>]]",
|
|
88
100
|
" [--host-version <X.Y.Z>] [--language <culture>] [--theme system|light|dark] [--surface business|tool|settings]",
|
|
89
101
|
" [--contribution-id <id>] [--no-devtools]",
|
|
@@ -97,6 +109,69 @@ function usage() {
|
|
|
97
109
|
].join("\n");
|
|
98
110
|
}
|
|
99
111
|
exports.usage = usage;
|
|
112
|
+
function runUpgrade(args, io) {
|
|
113
|
+
if (args.length === 1 && (args[0] === "--help" || args[0] === "-h")) {
|
|
114
|
+
io.stdout(usage());
|
|
115
|
+
return 0;
|
|
116
|
+
}
|
|
117
|
+
let projectDirectory = io.cwd();
|
|
118
|
+
let index = 0;
|
|
119
|
+
if (args[0] && !args[0].startsWith("--")) {
|
|
120
|
+
projectDirectory = path.resolve(io.cwd(), args[0]);
|
|
121
|
+
index = 1;
|
|
122
|
+
}
|
|
123
|
+
let sdkSource;
|
|
124
|
+
let checkOnly = false;
|
|
125
|
+
let allowMajor = false;
|
|
126
|
+
let skipProjectChecks = false;
|
|
127
|
+
let json = false;
|
|
128
|
+
const seen = new Set();
|
|
129
|
+
for (; index < args.length; index += 1) {
|
|
130
|
+
const option = args[index];
|
|
131
|
+
if (["--check", "--allow-major", "--skip-project-checks", "--json"].includes(option)) {
|
|
132
|
+
if (seen.has(option)) {
|
|
133
|
+
return usageError(io, "Duplicate option: " + option);
|
|
134
|
+
}
|
|
135
|
+
seen.add(option);
|
|
136
|
+
if (option === "--check") {
|
|
137
|
+
checkOnly = true;
|
|
138
|
+
}
|
|
139
|
+
else if (option === "--allow-major") {
|
|
140
|
+
allowMajor = true;
|
|
141
|
+
}
|
|
142
|
+
else if (option === "--skip-project-checks") {
|
|
143
|
+
skipProjectChecks = true;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
json = true;
|
|
147
|
+
}
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (option !== "--sdk-source") {
|
|
151
|
+
return usageError(io, "Unknown upgrade option: " + option);
|
|
152
|
+
}
|
|
153
|
+
if (seen.has(option)) {
|
|
154
|
+
return usageError(io, "Duplicate option: " + option);
|
|
155
|
+
}
|
|
156
|
+
seen.add(option);
|
|
157
|
+
const value = args[index + 1];
|
|
158
|
+
if (value === undefined || value.startsWith("--")) {
|
|
159
|
+
return usageError(io, option + " requires a value.");
|
|
160
|
+
}
|
|
161
|
+
sdkSource = value;
|
|
162
|
+
index += 1;
|
|
163
|
+
}
|
|
164
|
+
const result = (0, upgrade_1.runPluginSdkUpgrade)({
|
|
165
|
+
projectDirectory,
|
|
166
|
+
workingDirectory: io.cwd(),
|
|
167
|
+
sdkSource,
|
|
168
|
+
checkOnly,
|
|
169
|
+
allowMajor,
|
|
170
|
+
skipProjectChecks
|
|
171
|
+
});
|
|
172
|
+
io.stdout(json ? JSON.stringify(result, null, 2) : (0, upgrade_1.formatPluginSdkUpgradeResult)(result));
|
|
173
|
+
return result.status === "blocked" || result.status === "rolled-back" ? 1 : 0;
|
|
174
|
+
}
|
|
100
175
|
function runNexusDev(args, io) {
|
|
101
176
|
if (args.length === 1 && (args[0] === "--help" || args[0] === "-h")) {
|
|
102
177
|
io.stdout(usage());
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.showSdkUpdateNotice = void 0;
|
|
4
4
|
function showSdkUpdateNotice(args, stdout, updateCheck, currentVersion) {
|
|
5
|
-
if (args.includes("--help") || args.includes("-h") || updateCheck.isDisabled(process.env)) {
|
|
5
|
+
if (args.includes("--help") || args.includes("-h") || args.includes("--json") || updateCheck.isDisabled(process.env)) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
8
|
const cached = updateCheck.readCachedSdkUpdate({ currentVersion });
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import pluginManifestSchema from "../.generated/plugin-manifest.schema.json";
|
|
2
|
-
export declare const PLUGIN_SDK_VERSION = "3.0.2";
|
|
3
2
|
export { pluginManifestSchema };
|
|
4
3
|
export * from "../.generated/plugin-framework-version";
|
|
4
|
+
export * from "./sdk-info";
|
|
5
5
|
export * from "./types";
|
|
6
6
|
export * from "./electron-namespaces";
|
|
7
7
|
export * from "./browser/frame-client";
|
package/dist/src/index.js
CHANGED
|
@@ -17,11 +17,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.pluginManifestSchema =
|
|
20
|
+
exports.pluginManifestSchema = void 0;
|
|
21
21
|
const plugin_manifest_schema_json_1 = __importDefault(require("../.generated/plugin-manifest.schema.json"));
|
|
22
22
|
exports.pluginManifestSchema = plugin_manifest_schema_json_1.default;
|
|
23
|
-
exports.PLUGIN_SDK_VERSION = "3.0.2";
|
|
24
23
|
__exportStar(require("../.generated/plugin-framework-version"), exports);
|
|
24
|
+
__exportStar(require("./sdk-info"), exports);
|
|
25
25
|
__exportStar(require("./types"), exports);
|
|
26
26
|
__exportStar(require("./electron-namespaces"), exports);
|
|
27
27
|
__exportStar(require("./browser/frame-client"), exports);
|
package/dist/src/scaffold.js
CHANGED
|
@@ -29,6 +29,7 @@ const fs = __importStar(require("fs"));
|
|
|
29
29
|
const path = __importStar(require("path"));
|
|
30
30
|
const url_1 = require("url");
|
|
31
31
|
const index_1 = require("./index");
|
|
32
|
+
const sdk_info_1 = require("./sdk-info");
|
|
32
33
|
class PluginScaffoldError extends Error {
|
|
33
34
|
constructor(message, exitCode) {
|
|
34
35
|
super(message);
|
|
@@ -209,9 +210,9 @@ function createPackageJson(options, sdkSource) {
|
|
|
209
210
|
};
|
|
210
211
|
const devDependencies = {
|
|
211
212
|
[sdkPackageName]: sdkSource,
|
|
212
|
-
"@types/node":
|
|
213
|
-
electron:
|
|
214
|
-
typescript:
|
|
213
|
+
"@types/node": sdk_info_1.PLUGIN_SDK_TYPES_NODE_VERSION,
|
|
214
|
+
electron: sdk_info_1.PLUGIN_SDK_ELECTRON_VERSION,
|
|
215
|
+
typescript: sdk_info_1.PLUGIN_SDK_TYPESCRIPT_VERSION
|
|
215
216
|
};
|
|
216
217
|
const packageJson = {
|
|
217
218
|
name: options.pluginId,
|
|
@@ -222,12 +223,12 @@ function createPackageJson(options, sdkSource) {
|
|
|
222
223
|
};
|
|
223
224
|
if (options.template === "sqlite") {
|
|
224
225
|
scripts.build = "npm run rebuild:native && node scripts/build.js && npm run validate";
|
|
225
|
-
scripts["rebuild:native"] = "electron-rebuild -v
|
|
226
|
+
scripts["rebuild:native"] = "electron-rebuild -v " + sdk_info_1.PLUGIN_SDK_ELECTRON_VERSION + " -m . -w better-sqlite3";
|
|
226
227
|
packageJson.dependencies = { "better-sqlite3": "8.7.0" };
|
|
227
228
|
devDependencies["@electron/rebuild"] = "3.7.2";
|
|
228
229
|
}
|
|
229
230
|
packageJson.devDependencies = devDependencies;
|
|
230
|
-
packageJson.engines = { node:
|
|
231
|
+
packageJson.engines = { node: sdk_info_1.PLUGIN_SDK_NODE_ENGINE };
|
|
231
232
|
return packageJson;
|
|
232
233
|
}
|
|
233
234
|
function createManifest(options) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const PLUGIN_SDK_VERSION = "3.1.1";
|
|
2
|
+
export declare const PLUGIN_SDK_NODE_ENGINE = ">=16.20.0 <17";
|
|
3
|
+
export declare const PLUGIN_SDK_NPM_ENGINE = ">=6.13.4";
|
|
4
|
+
export declare const PLUGIN_SDK_ELECTRON_VERSION = "22.3.27";
|
|
5
|
+
export declare const PLUGIN_SDK_TYPESCRIPT_VERSION = "4.9.4";
|
|
6
|
+
export declare const PLUGIN_SDK_TYPES_NODE_VERSION = "16.18.126";
|
|
7
|
+
export interface PluginSdkInfo {
|
|
8
|
+
sdkVersion: string;
|
|
9
|
+
frameworkApiVersion: string;
|
|
10
|
+
manifestSchemaVersion: number;
|
|
11
|
+
nodeEngine: string;
|
|
12
|
+
npmEngine: string;
|
|
13
|
+
electronVersion: string;
|
|
14
|
+
typescriptVersion: string;
|
|
15
|
+
typesNodeVersion: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function getPluginSdkInfo(): PluginSdkInfo;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPluginSdkInfo = exports.PLUGIN_SDK_TYPES_NODE_VERSION = exports.PLUGIN_SDK_TYPESCRIPT_VERSION = exports.PLUGIN_SDK_ELECTRON_VERSION = exports.PLUGIN_SDK_NPM_ENGINE = exports.PLUGIN_SDK_NODE_ENGINE = exports.PLUGIN_SDK_VERSION = void 0;
|
|
4
|
+
const plugin_framework_version_1 = require("../.generated/plugin-framework-version");
|
|
5
|
+
exports.PLUGIN_SDK_VERSION = "3.1.1";
|
|
6
|
+
exports.PLUGIN_SDK_NODE_ENGINE = ">=16.20.0 <17";
|
|
7
|
+
exports.PLUGIN_SDK_NPM_ENGINE = ">=6.13.4";
|
|
8
|
+
exports.PLUGIN_SDK_ELECTRON_VERSION = "22.3.27";
|
|
9
|
+
exports.PLUGIN_SDK_TYPESCRIPT_VERSION = "4.9.4";
|
|
10
|
+
exports.PLUGIN_SDK_TYPES_NODE_VERSION = "16.18.126";
|
|
11
|
+
function getPluginSdkInfo() {
|
|
12
|
+
return {
|
|
13
|
+
sdkVersion: exports.PLUGIN_SDK_VERSION,
|
|
14
|
+
frameworkApiVersion: plugin_framework_version_1.PLUGIN_FRAMEWORK_VERSION,
|
|
15
|
+
manifestSchemaVersion: plugin_framework_version_1.PLUGIN_MANIFEST_SCHEMA_VERSION,
|
|
16
|
+
nodeEngine: exports.PLUGIN_SDK_NODE_ENGINE,
|
|
17
|
+
npmEngine: exports.PLUGIN_SDK_NPM_ENGINE,
|
|
18
|
+
electronVersion: exports.PLUGIN_SDK_ELECTRON_VERSION,
|
|
19
|
+
typescriptVersion: exports.PLUGIN_SDK_TYPESCRIPT_VERSION,
|
|
20
|
+
typesNodeVersion: exports.PLUGIN_SDK_TYPES_NODE_VERSION
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
exports.getPluginSdkInfo = getPluginSdkInfo;
|
package/dist/src/types.d.ts
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export type PluginSdkUpgradeStatus = "up-to-date" | "upgrade-available" | "upgraded" | "rolled-back" | "blocked";
|
|
2
|
+
export type PluginSdkUpgradeCheckStatus = "passed" | "warning" | "skipped" | "failed";
|
|
3
|
+
export interface PluginSdkUpgradeCheck {
|
|
4
|
+
name: string;
|
|
5
|
+
status: PluginSdkUpgradeCheckStatus;
|
|
6
|
+
detail: string;
|
|
7
|
+
}
|
|
8
|
+
export interface PluginSdkUpgradeRollback {
|
|
9
|
+
attempted: boolean;
|
|
10
|
+
succeeded: boolean;
|
|
11
|
+
detail: string;
|
|
12
|
+
}
|
|
13
|
+
export interface PluginSdkUpgradeResult {
|
|
14
|
+
status: PluginSdkUpgradeStatus;
|
|
15
|
+
projectDirectory: string;
|
|
16
|
+
currentVersion: string | null;
|
|
17
|
+
targetVersion: string;
|
|
18
|
+
source: string;
|
|
19
|
+
dependencySection: "dependencies" | "devDependencies" | null;
|
|
20
|
+
changedFiles: string[];
|
|
21
|
+
checks: PluginSdkUpgradeCheck[];
|
|
22
|
+
rollback: PluginSdkUpgradeRollback | null;
|
|
23
|
+
}
|
|
24
|
+
export interface PluginSdkUpgradeOptions {
|
|
25
|
+
projectDirectory: string;
|
|
26
|
+
workingDirectory: string;
|
|
27
|
+
sdkSource?: string;
|
|
28
|
+
checkOnly: boolean;
|
|
29
|
+
allowMajor: boolean;
|
|
30
|
+
skipProjectChecks: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface PluginSdkUpgradeCommandResult {
|
|
33
|
+
status: number | null;
|
|
34
|
+
stdout: string;
|
|
35
|
+
stderr: string;
|
|
36
|
+
error?: Error;
|
|
37
|
+
}
|
|
38
|
+
export interface PluginSdkUpgradeRuntime {
|
|
39
|
+
nodeVersion: string;
|
|
40
|
+
runNpm(args: string[], cwd: string): PluginSdkUpgradeCommandResult;
|
|
41
|
+
runNode(args: string[], cwd: string): PluginSdkUpgradeCommandResult;
|
|
42
|
+
}
|
|
43
|
+
export declare function runPluginSdkUpgrade(options: PluginSdkUpgradeOptions, runtime?: PluginSdkUpgradeRuntime): PluginSdkUpgradeResult;
|
|
44
|
+
export declare function formatPluginSdkUpgradeResult(result: PluginSdkUpgradeResult): string;
|