@picloom/create-plugin 0.1.0 → 0.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 +5 -1
- package/index.js +1 -1
- package/package.json +2 -2
- package/template/README.md +6 -2
- package/template/package.json +3 -3
- package/template/tsconfig.json +7 -2
- package/template/scripts/build.ts +0 -75
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ checkout, Node.js or npm CLI is required.
|
|
|
6
6
|
Create a project:
|
|
7
7
|
|
|
8
8
|
```sh
|
|
9
|
-
bun create @picloom/plugin@0.1.
|
|
9
|
+
bun create @picloom/plugin@0.1.1 ./my-plugin
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
The destination must not exist; its parent must exist. `--help` prints usage.
|
|
@@ -26,3 +26,7 @@ maintainers use [tool maintenance](https://github.com/llleixx/picloom/blob/main/
|
|
|
26
26
|
|
|
27
27
|
目标目录必须不存在,父目录必须存在。工具只复制日期路径插件模板并提示下一步,
|
|
28
28
|
不安装依赖、不启动服务、不发布代码。生成后按项目内 README 修改、构建和安装插件。
|
|
29
|
+
|
|
30
|
+
Generated projects use `@picloom/plugin-sdk` for contracts and runtime helpers, and `@picloom/plugin-tools` for ZIP builds. No build script is copied. Use creator 0.1.1, tools 0.1.0 and plugin SDK 0.1.0.
|
|
31
|
+
|
|
32
|
+
生成项目依赖 SDK 与开发工具包,不复制构建实现;使用脚手架 0.1.1、工具 0.1.0 和插件 SDK 0.1.0 的 npm 精确版本。
|
package/index.js
CHANGED
|
@@ -46,7 +46,7 @@ if (args.length === 1 && ["--help", "-h"].includes(args[0])) {
|
|
|
46
46
|
pkg.name = name;
|
|
47
47
|
await writeFile(packagePath, JSON.stringify(pkg, null, 2) + "\n");
|
|
48
48
|
console.log(
|
|
49
|
-
`Created ${target}\n\nNext:\n cd ${JSON.stringify(args[0])}\n bun install\n bun run build\n\nUpload dist/${manifest.id}-${manifest.version}.zip to Picloom.`,
|
|
49
|
+
`Created ${target}\n\nNext:\n cd ${JSON.stringify(args[0])}\n bun install\n bun run typecheck\n bun run build\n\nUpload dist/${manifest.id}-${manifest.version}.zip to Picloom.`,
|
|
50
50
|
);
|
|
51
51
|
} catch (error) {
|
|
52
52
|
console.error(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picloom/create-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Create a standalone Picloom plugin project",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
],
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/llleixx/picloom.git",
|
|
21
|
+
"url": "git+https://github.com/llleixx/picloom-tooling.git",
|
|
22
22
|
"directory": "tools/create-plugin"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
package/template/README.md
CHANGED
|
@@ -8,11 +8,12 @@ Node.js and npm CLI are not required.
|
|
|
8
8
|
|
|
9
9
|
```sh
|
|
10
10
|
bun install
|
|
11
|
+
bun run typecheck
|
|
11
12
|
bun run build
|
|
12
13
|
```
|
|
13
14
|
|
|
14
15
|
Commit the generated `bun.lock`. To check types without building, run
|
|
15
|
-
`bun run typecheck`.
|
|
16
|
+
`bun run typecheck`. Type checking and ZIP building are separate commands under Bun. Builds call `@picloom/plugin-tools`; no build implementation is copied into the project.
|
|
16
17
|
|
|
17
18
|
- `plugin.json`: plugin ID, version, kind and API version. Replace the
|
|
18
19
|
generated `example.*` ID with your own stable ID before sharing.
|
|
@@ -53,7 +54,7 @@ for retries, cancellation and instance lifecycle.
|
|
|
53
54
|
|
|
54
55
|
本项目只需 Bun 1.4.3+。修改 `plugin.json` 的身份信息和 `src/index.ts` 的实现,
|
|
55
56
|
执行 `bun install`、`bun run build`,将生成的 `bun.lock` 提交到自己的插件仓库。
|
|
56
|
-
|
|
57
|
+
类型检查单独运行 `bun run typecheck`;构建调用 `@picloom/plugin-tools` 输出 `dist/<插件ID>-<版本>.zip`,无需系统 `zip` 命令。
|
|
57
58
|
|
|
58
59
|
用 Owner 账号在独立测试实例中安装 ZIP,确认加载成功后,在上传配置中选择插件并
|
|
59
60
|
关联可用存储组。上传 PNG,确认日期路径和公开链接。改代码后增加清单版本,重新
|
|
@@ -65,3 +66,6 @@ for retries, cancellation and instance lifecycle.
|
|
|
65
66
|
入口从清单读取身份字段;`package.json` 的版本不是插件版本。构建会加载入口,
|
|
66
67
|
不要在模块顶层执行远端操作。Sharp 的开发依赖提供类型,运行时使用宿主实例。
|
|
67
68
|
其他类型和完整接口见上方文档链接。
|
|
69
|
+
|
|
70
|
+
The current creator/tool versions are not yet published; use their local tarballs for validation.
|
|
71
|
+
当前脚手架和工具版本尚未发布,请使用本地压缩包验证。
|
package/template/package.json
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"typecheck": "bun run --bun tsc --noEmit",
|
|
8
|
-
"build": "bun
|
|
8
|
+
"build": "bun --bun picloom-plugin build"
|
|
9
9
|
},
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@picloom/plugin-sdk": "0.1.0",
|
|
12
12
|
"@types/bun": "1.3.10",
|
|
13
|
-
"fflate": "0.8.2",
|
|
14
13
|
"sharp": "0.34.5",
|
|
15
|
-
"typescript": "5.9.3"
|
|
14
|
+
"typescript": "5.9.3",
|
|
15
|
+
"@picloom/plugin-tools": "0.1.0"
|
|
16
16
|
},
|
|
17
17
|
"engines": {
|
|
18
18
|
"bun": ">=1.4.3"
|
package/template/tsconfig.json
CHANGED
|
@@ -8,8 +8,13 @@
|
|
|
8
8
|
"noEmit": true,
|
|
9
9
|
"resolveJsonModule": true,
|
|
10
10
|
"esModuleInterop": true,
|
|
11
|
-
"types": [
|
|
11
|
+
"types": [
|
|
12
|
+
"bun"
|
|
13
|
+
],
|
|
12
14
|
"skipLibCheck": false
|
|
13
15
|
},
|
|
14
|
-
"include": [
|
|
16
|
+
"include": [
|
|
17
|
+
"src/**/*.ts",
|
|
18
|
+
"plugin.json"
|
|
19
|
+
]
|
|
15
20
|
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { mkdir } from "node:fs/promises";
|
|
2
|
-
import { resolve } from "node:path";
|
|
3
|
-
import { strToU8, zipSync } from "fflate";
|
|
4
|
-
import manifest from "../plugin.json";
|
|
5
|
-
|
|
6
|
-
if (
|
|
7
|
-
!/^[a-z][a-z0-9._-]{0,99}$/.test(manifest.id) ||
|
|
8
|
-
manifest.id.startsWith("builtin.") ||
|
|
9
|
-
!/^[0-9][a-zA-Z0-9.+-]{0,63}$/.test(manifest.version) ||
|
|
10
|
-
!["path", "storage", "processor"].includes(manifest.kind) ||
|
|
11
|
-
manifest.apiVersion !== 1 ||
|
|
12
|
-
manifest.entry !== "index.js"
|
|
13
|
-
)
|
|
14
|
-
throw new Error(
|
|
15
|
-
"Invalid plugin.json: check id, version, kind, apiVersion and entry",
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
const build = await Bun.build({
|
|
19
|
-
entrypoints: ["src/index.ts"],
|
|
20
|
-
target: "bun",
|
|
21
|
-
format: "esm",
|
|
22
|
-
naming: "index.js",
|
|
23
|
-
plugins: [
|
|
24
|
-
{
|
|
25
|
-
name: "host-sharp",
|
|
26
|
-
setup(builder) {
|
|
27
|
-
builder.onResolve({ filter: /^sharp(?:\/|$)/ }, () => {
|
|
28
|
-
throw new Error(
|
|
29
|
-
"Use services.images.sharp; do not import the Sharp runtime",
|
|
30
|
-
);
|
|
31
|
-
});
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
});
|
|
36
|
-
if (!build.success) throw new Error(build.logs.join("\n"));
|
|
37
|
-
if (build.outputs.length !== 1 || build.outputs[0]?.kind !== "entry-point")
|
|
38
|
-
throw new Error(
|
|
39
|
-
"This template packages one JavaScript entry only; additional assets need explicit packaging",
|
|
40
|
-
);
|
|
41
|
-
const code = await build.outputs[0].text();
|
|
42
|
-
// Bundling must leave only Bun/Node builtins. Do not ship unresolved packages/assets.
|
|
43
|
-
const imports = new Bun.Transpiler({ loader: "js", target: "bun" }).scanImports(
|
|
44
|
-
code,
|
|
45
|
-
);
|
|
46
|
-
const { isBuiltin } = await import("node:module");
|
|
47
|
-
for (const item of imports) {
|
|
48
|
-
if (
|
|
49
|
-
item.path !== "bun" &&
|
|
50
|
-
!item.path.startsWith("bun:") &&
|
|
51
|
-
!isBuiltin(item.path)
|
|
52
|
-
)
|
|
53
|
-
throw new Error(`Unbundled runtime import: ${item.path}`);
|
|
54
|
-
}
|
|
55
|
-
// Evaluate the developer's own entry to catch a mismatched/missing default export.
|
|
56
|
-
// Keep plugin top-level code free of network requests and other side effects.
|
|
57
|
-
const { default: definition } = await import(
|
|
58
|
-
`data:text/javascript;base64,${Buffer.from(code).toString("base64")}`
|
|
59
|
-
);
|
|
60
|
-
for (const field of ["id", "version", "kind", "apiVersion"] as const) {
|
|
61
|
-
if (definition?.[field] !== manifest[field])
|
|
62
|
-
throw new Error(
|
|
63
|
-
`Plugin default export does not match plugin.json: ${field}`,
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
const zip = zipSync({
|
|
67
|
-
"plugin.json": strToU8(JSON.stringify(manifest, null, 2) + "\n"),
|
|
68
|
-
"index.js": strToU8(code),
|
|
69
|
-
});
|
|
70
|
-
if (zip.byteLength > 20 * 1024 * 1024)
|
|
71
|
-
throw new Error("Plugin ZIP exceeds Picloom's 20 MiB upload limit");
|
|
72
|
-
await mkdir("dist", { recursive: true });
|
|
73
|
-
const output = resolve("dist", `${manifest.id}-${manifest.version}.zip`);
|
|
74
|
-
await Bun.write(output, zip);
|
|
75
|
-
console.log(output);
|