flare-plugin-sdk 0.1.0-beta.1 → 0.1.0-beta.4

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.
Files changed (3) hide show
  1. package/README.md +47 -14
  2. package/bin/cli.mjs +59 -0
  3. package/package.json +3 -1
package/README.md CHANGED
@@ -1,12 +1,42 @@
1
1
  # Flare Plugin SDK
2
2
 
3
- `flare-plugin-sdk` contains editor types, a local package command,
3
+ `flare-plugin-sdk` contains a project initializer, editor types, a local package command,
4
4
  templates, examples, and a portable AI authoring skill for Social Plugin API v1.
5
5
  Flare provides the plugin runtime. Supported targets are Android, JVM Desktop,
6
6
  iOS, and native macOS, not Web. Use a Flare build that includes Plugins in Settings;
7
7
  this SDK does not promise a minimum public app release.
8
8
 
9
- ## Install for development
9
+ ## Create a plugin
10
+
11
+ With Node 22 or newer, run:
12
+
13
+ ```sh
14
+ npx flare-plugin-sdk@next init my-plugin
15
+ ```
16
+
17
+ This copies the GitHub template bundled with that SDK version into `my-plugin`:
18
+
19
+ ```text
20
+ my-plugin/
21
+ manifest.json
22
+ plugin.js
23
+ assets/icon.png
24
+ README.md
25
+ ```
26
+
27
+ The directory name becomes the plugin and platform display name. The initializer
28
+ generates unique plugin/platform IDs; keep them stable after publication. New and
29
+ empty directories are accepted, including `init .` in an empty current directory.
30
+ Non-empty directories, files, and symbolic links are rejected without overwriting
31
+ them. The command uses bundled files only and does not install dependencies,
32
+ initialize Git, contact your website, or publish anything. Run
33
+ `npx flare-plugin-sdk@next --help` for usage.
34
+
35
+ Adapt the illustrative API endpoints, replace the placeholder icon, and follow
36
+ the generated README. In Desktop or native macOS, select the generated directory
37
+ in Settings → Plugins → Plugin development to validate and reload it.
38
+
39
+ ## Install for editor types and packaging
10
40
 
11
41
  Install the npm preview:
12
42
 
@@ -29,9 +59,10 @@ These local checks and packaging commands do not publish anything.
29
59
 
30
60
  ## Create and develop a plugin
31
61
 
32
- 1. Copy the contents of `node_modules/flare-plugin-sdk/skill/flare-plugin/assets/github-template/`
33
- into your plugin repository. Replace its IDs, icon, and illustrative website
34
- endpoints using evidence from the real API.
62
+ 1. Create a plugin with the initializer above, or manually copy the contents of
63
+ `node_modules/flare-plugin-sdk/skill/flare-plugin/assets/github-template/` into
64
+ your repository. Manual copies retain example IDs and names; replace them.
65
+ Adapt the icon and illustrative website endpoints using evidence from the real API.
35
66
  2. Read the [complete developer guide](https://github.com/DimensionDev/Flare/tree/feature/plugin/feature/plugin/sdk/skill/flare-plugin).
36
67
  The same guide is bundled at `skill/flare-plugin/README.md` inside the npm package,
37
68
  with all authentication, capability, runtime, data, testing, and publication references.
@@ -43,7 +74,7 @@ These local checks and packaging commands do not publish anything.
43
74
  5. For local file installation, package that directory from your plugin project:
44
75
 
45
76
  ```sh
46
- npx flare-plugin-pack ./dist ./plugin.fpp
77
+ npx --package=flare-plugin-sdk@next flare-plugin-pack ./dist ./plugin.fpp
47
78
  ```
48
79
 
49
80
  The packer accepts plugin files only, so keep source, `.git`, `package.json`,
@@ -85,9 +116,11 @@ All documentation is in English. The complete Pixelfed adapter is bundled at
85
116
 
86
117
  From `feature/plugin/sdk`, run `npm ci` and `npm test` with Node 22 or newer.
87
118
  The tests build an npm tarball, check its complete resource set and license,
88
- install it offline in an empty project, type-check an actual consumer, and run
89
- the installed package command against the bundled template. They do not contact
90
- a website or publish to npm. Flare's Host and platform acceptance checks are
119
+ install it offline in an empty project, invoke the actual npx initializer,
120
+ type-check a consumer, and package both the generated project and bundled template.
121
+ Initializer tests cover valid unique IDs, empty/nested/Unicode paths, invalid
122
+ arguments, and preserving existing directories, files, and symlinks. They do not
123
+ contact a website or publish to npm. Flare's Host and platform acceptance checks are
91
124
  documented in `skill/flare-plugin/references/testing.md`.
92
125
 
93
126
  ## Publish this SDK (maintainers)
@@ -121,12 +154,12 @@ Public OIDC publications from this public repository receive provenance automati
121
154
  For subsequent releases:
122
155
 
123
156
  1. Update the SDK version and lockfile together, for example with
124
- `npm version 0.1.0-beta.2 --no-git-tag-version`, and commit the tested changes.
125
- 2. Tag that commit `plugin-sdk-v0.1.0-beta.2` and push only that tag when ready to publish.
157
+ `npm version prerelease --preid beta --no-git-tag-version`, and commit the tested changes.
158
+ 2. Tag that commit `plugin-sdk-v<version>` using the new version and push only that tag when ready to publish.
126
159
  The workflow rejects a tag that does not exactly match `package.json`.
127
160
  3. The workflow validates the tarball first, then publishes prereleases to `next`
128
161
  and stable versions to `latest`. Existing app workflows exclude SDK tags.
129
162
 
130
- The **Plugin SDK** workflow runs validation on relevant pull requests. Its manual
131
- **Run workflow** action also validates only, even when a tag is selected; publishing
132
- requires a push of a matching `plugin-sdk-v*` tag. Updating a PR never publishes npm.
163
+ Run the **Plugin SDK** workflow manually to validate a branch or tag; this does not
164
+ publish, even when a tag is selected. Publishing requires a push of a matching
165
+ `plugin-sdk-v*` tag. Branch pushes and pull requests do not start this workflow.
package/bin/cli.mjs ADDED
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { randomUUID } from "node:crypto";
4
+ import { cp, lstat, mkdir, readdir, readFile, writeFile } from "node:fs/promises";
5
+ import { basename, join, resolve } from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+
8
+ const usage = "Usage: flare-plugin-sdk init <directory>";
9
+
10
+ async function main() {
11
+ const args = process.argv.slice(2);
12
+ if (args.includes("--help") || args.includes("-h")) {
13
+ console.log(usage);
14
+ return;
15
+ }
16
+ if (args.length !== 2 || args[0] !== "init" || !args[1] || args[1].startsWith("-")) {
17
+ throw new Error(usage);
18
+ }
19
+
20
+ const target = resolve(args[1]);
21
+ const name = basename(target);
22
+ if (!name.trim() || /[\u0000-\u001f\u007f]/.test(args[1])) {
23
+ throw new Error("Choose a directory name without control characters or blank text");
24
+ }
25
+ const metadata = await lstat(target).catch((error) => {
26
+ if (error.code !== "ENOENT") throw error;
27
+ });
28
+ if (metadata && (!metadata.isDirectory() || metadata.isSymbolicLink() || (await readdir(target)).length)) {
29
+ throw new Error("Destination must be a new or empty directory, not a file or symbolic link");
30
+ }
31
+
32
+ const template = fileURLToPath(new URL("../skill/flare-plugin/assets/github-template/", import.meta.url));
33
+ const manifestPath = join(template, "manifest.json");
34
+ const manifest = JSON.parse(await readFile(manifestPath, "utf8"));
35
+ const identity = randomUUID().replaceAll("-", "");
36
+ manifest.id = `local.plugin.p${identity}`;
37
+ manifest.name = name;
38
+ manifest.platform.id = `Plugin${identity}`;
39
+ manifest.platform.name = name;
40
+
41
+ await mkdir(target, { recursive: true });
42
+ for (const entry of await readdir(template)) {
43
+ if (entry === "manifest.json") continue;
44
+ await cp(join(template, entry), join(target, entry), {
45
+ recursive: true,
46
+ force: false,
47
+ errorOnExist: true,
48
+ });
49
+ }
50
+ await writeFile(join(target, "manifest.json"), `${JSON.stringify(manifest, null, 2)}\n`, { flag: "wx" });
51
+
52
+ console.log(`Created ${target}\nPlugin ID: ${manifest.id}\nPlatform ID: ${manifest.platform.id}`);
53
+ console.log("Adapt the example API in plugin.js and README.md, then load this directory in Flare's Plugin development.");
54
+ }
55
+
56
+ main().catch((error) => {
57
+ console.error(error.message);
58
+ process.exitCode = 1;
59
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flare-plugin-sdk",
3
- "version": "0.1.0-beta.1",
3
+ "version": "0.1.0-beta.4",
4
4
  "description": "Types, tooling, templates and authoring references for Flare plugins",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "homepage": "https://github.com/DimensionDev/Flare#plugins-beta",
@@ -13,10 +13,12 @@
13
13
  "url": "https://github.com/DimensionDev/Flare/issues"
14
14
  },
15
15
  "bin": {
16
+ "flare-plugin-sdk": "bin/cli.mjs",
16
17
  "flare-plugin-pack": "skill/flare-plugin/pack.mjs"
17
18
  },
18
19
  "types": "skill/flare-plugin/flare-plugin.d.ts",
19
20
  "files": [
21
+ "bin/",
20
22
  "skill/flare-plugin/"
21
23
  ],
22
24
  "engines": {