@picloom/create-plugin 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +31 -2
- package/index.js +59 -0
- package/package.json +25 -4
- package/template/LICENSE +21 -0
- package/template/README.md +71 -0
- package/template/gitignore +4 -0
- package/template/package.json +20 -0
- package/template/plugin.json +7 -0
- package/template/src/index.ts +40 -0
- package/template/tsconfig.json +20 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 lllei
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @picloom/create-plugin
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Create a standalone Picloom plugin project with Bun 1.4.3+. No main repository
|
|
4
|
+
checkout, Node.js or npm CLI is required.
|
|
5
|
+
|
|
6
|
+
Create a project:
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
bun create @picloom/plugin@0.1.1 ./my-plugin
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The destination must not exist; its parent must exist. `--help` prints usage.
|
|
13
|
+
The tool copies a date path plugin template and prints next steps. It does not
|
|
14
|
+
install dependencies, start a service, or publish anything. Follow the generated
|
|
15
|
+
README to edit, build and install the plugin.
|
|
16
|
+
|
|
17
|
+
See [quick start](https://llleixx.github.io/picloom/development/plugin-tooling.html)
|
|
18
|
+
for the full workflow and optional local tarball usage. Package
|
|
19
|
+
maintainers use [tool maintenance](https://github.com/llleixx/picloom/blob/main/docs/development/plugin-tooling-maintenance.md).
|
|
20
|
+
|
|
21
|
+
## 中文
|
|
22
|
+
|
|
23
|
+
使用 Bun 1.4.3+ 创建独立插件项目,无需主仓库、Node.js 或 npm CLI。
|
|
24
|
+
使用上方命令创建项目,完整流程与可选本地压缩包用法见
|
|
25
|
+
[快速开始](https://llleixx.github.io/picloom/development/plugin-tooling.html#本地压缩包)。
|
|
26
|
+
|
|
27
|
+
目标目录必须不存在,父目录必须存在。工具只复制日期路径插件模板并提示下一步,
|
|
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
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import {
|
|
3
|
+
cp,
|
|
4
|
+
mkdir,
|
|
5
|
+
readFile,
|
|
6
|
+
readdir,
|
|
7
|
+
rename,
|
|
8
|
+
writeFile,
|
|
9
|
+
} from "node:fs/promises";
|
|
10
|
+
import { basename, resolve } from "node:path";
|
|
11
|
+
import { fileURLToPath } from "node:url";
|
|
12
|
+
|
|
13
|
+
const args = process.argv.slice(2);
|
|
14
|
+
if (args.length === 1 && ["--help", "-h"].includes(args[0])) {
|
|
15
|
+
console.log("Usage: bun create @picloom/plugin <new-directory>");
|
|
16
|
+
} else if (args.length !== 1 || args[0].startsWith("-")) {
|
|
17
|
+
console.error("Usage: bun create @picloom/plugin <new-directory>");
|
|
18
|
+
process.exitCode = 1;
|
|
19
|
+
} else {
|
|
20
|
+
try {
|
|
21
|
+
const target = resolve(args[0]);
|
|
22
|
+
// Refuse even empty existing directories: never merge into a user's project.
|
|
23
|
+
await mkdir(target);
|
|
24
|
+
const template = fileURLToPath(new URL("./template/", import.meta.url));
|
|
25
|
+
for (const entry of await readdir(template)) {
|
|
26
|
+
await cp(resolve(template, entry), resolve(target, entry), {
|
|
27
|
+
recursive: true,
|
|
28
|
+
force: false,
|
|
29
|
+
errorOnExist: true,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
// Package managers may rename/omit .gitignore when packing, so ship it under a plain name.
|
|
33
|
+
await rename(resolve(target, "gitignore"), resolve(target, ".gitignore"));
|
|
34
|
+
const name =
|
|
35
|
+
basename(target)
|
|
36
|
+
.toLowerCase()
|
|
37
|
+
.replace(/[^a-z0-9._-]/g, "-")
|
|
38
|
+
.replace(/^[^a-z]+/, "")
|
|
39
|
+
.slice(0, 80) || "my-plugin";
|
|
40
|
+
const manifestPath = resolve(target, "plugin.json");
|
|
41
|
+
const manifest = JSON.parse(await readFile(manifestPath, "utf8"));
|
|
42
|
+
manifest.id = `example.${name}`;
|
|
43
|
+
await writeFile(manifestPath, JSON.stringify(manifest, null, 2) + "\n");
|
|
44
|
+
const packagePath = resolve(target, "package.json");
|
|
45
|
+
const pkg = JSON.parse(await readFile(packagePath, "utf8"));
|
|
46
|
+
pkg.name = name;
|
|
47
|
+
await writeFile(packagePath, JSON.stringify(pkg, null, 2) + "\n");
|
|
48
|
+
console.log(
|
|
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
|
+
);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error(
|
|
53
|
+
error.code === "EEXIST"
|
|
54
|
+
? "Target already exists. Choose a new directory; no existing files were changed."
|
|
55
|
+
: `Could not create plugin: ${error.message}`,
|
|
56
|
+
);
|
|
57
|
+
process.exitCode = 1;
|
|
58
|
+
}
|
|
59
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@picloom/create-plugin",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Create a standalone Picloom plugin project",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"create-plugin": "./index.js"
|
|
9
|
+
},
|
|
10
|
+
"engines": {
|
|
11
|
+
"bun": ">=1.4.3"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"index.js",
|
|
15
|
+
"template",
|
|
16
|
+
"README.md",
|
|
17
|
+
"LICENSE"
|
|
18
|
+
],
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/llleixx/picloom-tooling.git",
|
|
22
|
+
"directory": "tools/create-plugin"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/template/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 lllei
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# My Picloom plugin
|
|
2
|
+
|
|
3
|
+
A standalone plugin project using Bun 1.4.3+ and Picloom plugin API 1. Use a
|
|
4
|
+
separate Picloom 0.1.0 development test instance for installation and uploads.
|
|
5
|
+
Node.js and npm CLI are not required.
|
|
6
|
+
|
|
7
|
+
## Develop
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
bun install
|
|
11
|
+
bun run typecheck
|
|
12
|
+
bun run build
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Commit the generated `bun.lock`. To check types without building, run
|
|
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.
|
|
17
|
+
|
|
18
|
+
- `plugin.json`: plugin ID, version, kind and API version. Replace the
|
|
19
|
+
generated `example.*` ID with your own stable ID before sharing.
|
|
20
|
+
- `src/index.ts`: localized display text (`defaultLocale` and `messages`), configuration and implementation. It reads identity fields from
|
|
21
|
+
the manifest and initially generates UTC date paths. It omits `configSchema`
|
|
22
|
+
because it has no custom configuration; the host accepts only `{}`.
|
|
23
|
+
- `package.json`: development dependencies and commands; its version is not the
|
|
24
|
+
plugin version. The project is private to prevent accidental npm publication.
|
|
25
|
+
- `dist/<plugin-id>-<version>.zip`: build output, containing `plugin.json` and
|
|
26
|
+
bundled `index.js` at the ZIP root. No system `zip` command is required.
|
|
27
|
+
|
|
28
|
+
Build loads your entry to check its identity, so keep module top-level code free
|
|
29
|
+
of external side effects. Sharp is a development dependency for SDK types;
|
|
30
|
+
use `services.images.sharp` at runtime. The template bundles JavaScript only;
|
|
31
|
+
extra assets and native modules require explicit packaging.
|
|
32
|
+
|
|
33
|
+
## Install and update
|
|
34
|
+
|
|
35
|
+
1. Sign in to the test instance as Owner and upload the ZIP in plugin management.
|
|
36
|
+
2. Review the identity, confirm trust, and check that the plugin loaded.
|
|
37
|
+
3. Select your path plugin in a test upload profile with an available storage group.
|
|
38
|
+
4. Upload a PNG and open its returned link. The starter path contains the UTC date
|
|
39
|
+
and file ID, plus the profile's public prefix.
|
|
40
|
+
5. After code changes, increment `plugin.json`'s version, rebuild and install.
|
|
41
|
+
In the profile choose the new version, preview and apply the upgrade.
|
|
42
|
+
|
|
43
|
+
Installation does not activate a plugin automatically. Same-version replacement
|
|
44
|
+
and source hot reload are not supported. See [packaging and upgrades](https://llleixx.github.io/picloom/development/plugin-release.html)
|
|
45
|
+
for configuration migrations and dependency restrictions.
|
|
46
|
+
|
|
47
|
+
For other plugin types and adapting the examples, follow
|
|
48
|
+
[quick start](https://llleixx.github.io/picloom/development/plugin-tooling.html#使用教程示例).
|
|
49
|
+
See [host services](https://llleixx.github.io/picloom/development/plugin-services.html)
|
|
50
|
+
for configuration, secrets and state, and [errors and concurrency](https://llleixx.github.io/picloom/development/plugin-errors.html)
|
|
51
|
+
for retries, cancellation and instance lifecycle.
|
|
52
|
+
|
|
53
|
+
## 中文
|
|
54
|
+
|
|
55
|
+
本项目只需 Bun 1.4.3+。修改 `plugin.json` 的身份信息和 `src/index.ts` 的实现,
|
|
56
|
+
执行 `bun install`、`bun run build`,将生成的 `bun.lock` 提交到自己的插件仓库。
|
|
57
|
+
类型检查单独运行 `bun run typecheck`;构建调用 `@picloom/plugin-tools` 输出 `dist/<插件ID>-<版本>.zip`,无需系统 `zip` 命令。
|
|
58
|
+
|
|
59
|
+
用 Owner 账号在独立测试实例中安装 ZIP,确认加载成功后,在上传配置中选择插件并
|
|
60
|
+
关联可用存储组。上传 PNG,确认日期路径和公开链接。改代码后增加清单版本,重新
|
|
61
|
+
构建安装,再选择新版本、预览并应用升级;安装新版不会自动切换已有配置。
|
|
62
|
+
|
|
63
|
+
模板没有自定义配置项,因此省略 `configSchema`,宿主只接受空配置 `{}`;添加配置项时再声明对象 Schema。
|
|
64
|
+
|
|
65
|
+
名称和简介通过 `nameKey/descriptionKey` 引用入口的 `messages` 字典,`defaultLocale` 指定内容默认语言。
|
|
66
|
+
入口从清单读取身份字段;`package.json` 的版本不是插件版本。构建会加载入口,
|
|
67
|
+
不要在模块顶层执行远端操作。Sharp 的开发依赖提供类型,运行时使用宿主实例。
|
|
68
|
+
其他类型和完整接口见上方文档链接。
|
|
69
|
+
|
|
70
|
+
The current creator/tool versions are not yet published; use their local tarballs for validation.
|
|
71
|
+
当前脚手架和工具版本尚未发布,请使用本地压缩包验证。
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "my-plugin",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"typecheck": "bun run --bun tsc --noEmit",
|
|
8
|
+
"build": "bun --bun picloom-plugin build"
|
|
9
|
+
},
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@picloom/plugin-sdk": "0.1.0",
|
|
12
|
+
"@types/bun": "1.3.10",
|
|
13
|
+
"sharp": "0.34.5",
|
|
14
|
+
"typescript": "5.9.3",
|
|
15
|
+
"@picloom/plugin-tools": "0.1.0"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"bun": ">=1.4.3"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PluginError, type Definition } from "@picloom/plugin-sdk";
|
|
2
|
+
import manifest from "../plugin.json";
|
|
3
|
+
|
|
4
|
+
// Narrow JSON strings through validation, rather than duplicating identity values.
|
|
5
|
+
const { kind, apiVersion } = manifest;
|
|
6
|
+
if (kind !== "path" || apiVersion !== 1)
|
|
7
|
+
throw new Error("This implementation requires kind=path and apiVersion=1");
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
id: manifest.id,
|
|
11
|
+
defaultLocale: "en-US",
|
|
12
|
+
nameKey: "package.name",
|
|
13
|
+
messages: { "en-US": { "package.name": "My date path" } },
|
|
14
|
+
version: manifest.version,
|
|
15
|
+
kind,
|
|
16
|
+
apiVersion,
|
|
17
|
+
configSchemaVersion: 1,
|
|
18
|
+
async createInstance() {
|
|
19
|
+
return {
|
|
20
|
+
async generate({ fileId, uploadedAt, metadata }) {
|
|
21
|
+
const extensions: Record<string, string> = {
|
|
22
|
+
"image/jpeg": "jpg",
|
|
23
|
+
"image/png": "png",
|
|
24
|
+
"image/gif": "gif",
|
|
25
|
+
"image/webp": "webp",
|
|
26
|
+
"image/avif": "avif",
|
|
27
|
+
"image/svg+xml": "svg",
|
|
28
|
+
};
|
|
29
|
+
const extension = extensions[metadata.mimeType ?? ""];
|
|
30
|
+
if (!extension)
|
|
31
|
+
throw new PluginError("UNSUPPORTED", "Unsupported image format");
|
|
32
|
+
const date = new Date(uploadedAt)
|
|
33
|
+
.toISOString()
|
|
34
|
+
.slice(0, 10)
|
|
35
|
+
.replaceAll("-", "/");
|
|
36
|
+
return { logicalKey: `${date}/${fileId}.${extension}` };
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
} satisfies Definition<"path">;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "Preserve",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"strict": true,
|
|
7
|
+
"noUncheckedIndexedAccess": true,
|
|
8
|
+
"noEmit": true,
|
|
9
|
+
"resolveJsonModule": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"types": [
|
|
12
|
+
"bun"
|
|
13
|
+
],
|
|
14
|
+
"skipLibCheck": false
|
|
15
|
+
},
|
|
16
|
+
"include": [
|
|
17
|
+
"src/**/*.ts",
|
|
18
|
+
"plugin.json"
|
|
19
|
+
]
|
|
20
|
+
}
|