@octonodes/cli 0.0.3 → 0.1.0
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 +161 -18
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -1
- package/dist/plugins/artifact.d.ts +11 -0
- package/dist/plugins/artifact.d.ts.map +1 -0
- package/dist/plugins/artifact.js +115 -0
- package/dist/plugins/artifact.js.map +1 -0
- package/dist/plugins/build.d.ts +3 -0
- package/dist/plugins/build.d.ts.map +1 -0
- package/dist/plugins/build.js +215 -0
- package/dist/plugins/build.js.map +1 -0
- package/dist/plugins/constants.d.ts +6 -0
- package/dist/plugins/constants.d.ts.map +1 -0
- package/dist/plugins/constants.js +31 -0
- package/dist/plugins/constants.js.map +1 -0
- package/dist/plugins/create.d.ts +2 -0
- package/dist/plugins/create.d.ts.map +1 -0
- package/dist/plugins/create.js +68 -0
- package/dist/plugins/create.js.map +1 -0
- package/dist/plugins/index.d.ts +3 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +78 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/publish.d.ts +2 -0
- package/dist/plugins/publish.d.ts.map +1 -0
- package/dist/plugins/publish.js +53 -0
- package/dist/plugins/publish.js.map +1 -0
- package/dist/plugins/types.d.ts +19 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +3 -0
- package/dist/plugins/types.js.map +1 -0
- package/package.json +15 -8
package/README.md
CHANGED
|
@@ -1,29 +1,172 @@
|
|
|
1
1
|
# @octonodes/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Command-line access to the public [Octonode cloud API](https://octonodes.com/api/docs). The CLI
|
|
4
|
+
wraps `@octonodes/sdk`, so every generated SDK operation is available without writing TypeScript.
|
|
5
|
+
|
|
6
|
+
## Create and publish plugins
|
|
4
7
|
|
|
5
8
|
```sh
|
|
6
|
-
|
|
9
|
+
octonodes plugin create my-integrations
|
|
10
|
+
cd my-integrations
|
|
11
|
+
npm install
|
|
12
|
+
npm test
|
|
13
|
+
octonodes plugin validate dist/plugins/my-integrations
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Define plugins in `plugins/**/*.plugin.ts` using `@octonodes/sdk/plugins`.
|
|
17
|
+
`octonodes plugin build` creates a standalone artifact per plugin; pass one entry
|
|
18
|
+
path to build only that plugin. `octonodes plugin test <directory> <node-id> --input
|
|
19
|
+
'{...}'` invokes a built node and reports failures with a nonzero exit code.
|
|
20
|
+
|
|
21
|
+
Set `scope: ["public"]` in the definition for community discovery, rebuild, then:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
octonodes login
|
|
25
|
+
octonodes plugin publish dist/plugins/my-integrations --registry https://your-marketplace.example
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Use `OCTONODE_MARKETPLACE_URL` to save the registry endpoint. Publishing uploads
|
|
29
|
+
the built artifact through the existing marketplace protocol; it never publishes
|
|
30
|
+
to npm. `OCTONODE_MARKETPLACE_TOKEN` overrides normal CLI authentication. Use
|
|
31
|
+
`--org` and `--team` for organization/group scopes. Each plugin has an independent
|
|
32
|
+
version, and unchanged build hashes are required before upload.
|
|
33
|
+
|
|
34
|
+
## Run
|
|
35
|
+
|
|
36
|
+
Use it directly with `npx`:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
npx @octonodes/cli --help
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Or install it globally. The installed command is `octonodes`:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
npm install --global @octonodes/cli
|
|
46
|
+
octonodes --version
|
|
47
|
+
```
|
|
7
48
|
|
|
8
|
-
|
|
9
|
-
|
|
49
|
+
## Sign in
|
|
50
|
+
|
|
51
|
+
The default login opens GitHub authentication in your browser and signs in as the same user as
|
|
52
|
+
Octonode Studio:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
octonodes login
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
If the browser cannot open, visit the URL printed by the command. The CLI receives the result on a
|
|
59
|
+
temporary loopback callback, stores the refreshable session in `~/.octonode/session.json`, and
|
|
60
|
+
refreshes expired access tokens automatically.
|
|
61
|
+
|
|
62
|
+
For terminal-only login, request an email code:
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
octonodes login --email you@example.com
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
You can also save an existing personal, service, public, or agent API token:
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
octonodes login --token octo_pat_...
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
For CI and temporary shell sessions, set `OCTONODE_TOKEN` instead of saving a login:
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
export OCTONODE_TOKEN=octo_svc_...
|
|
78
|
+
octonodes projects.api.get
|
|
10
79
|
```
|
|
11
80
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
81
|
+
Authentication is resolved in this order: `OCTONODE_TOKEN`, a saved API token, then a saved Studio
|
|
82
|
+
session.
|
|
83
|
+
|
|
84
|
+
## Find operations
|
|
85
|
+
|
|
86
|
+
List every operation or filter by name:
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
octonodes operations
|
|
90
|
+
octonodes operations projects
|
|
91
|
+
octonodes operations workflows
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Operation names follow the SDK property path and HTTP method. For example,
|
|
95
|
+
`GET /api/projects/{projectId}` becomes `projects.api.projectId.get`. Use the
|
|
96
|
+
[API reference](https://octonodes.com/api/docs) to find endpoints and their parameters.
|
|
97
|
+
|
|
98
|
+
## Call the API
|
|
99
|
+
|
|
100
|
+
Pass path parameters, query parameters, and request bodies together as JSON through `--input`:
|
|
101
|
+
|
|
102
|
+
```sh
|
|
103
|
+
# List projects
|
|
104
|
+
octonodes projects.api.get
|
|
105
|
+
|
|
106
|
+
# Read one project
|
|
107
|
+
octonodes projects.api.projectId.get \
|
|
108
|
+
--input '{"path":{"projectId":"project_123"}}'
|
|
109
|
+
|
|
110
|
+
# List runs with query parameters
|
|
111
|
+
octonodes runs.api.get \
|
|
112
|
+
--input '{"query":{"workflowId":"daily-report","limit":20}}'
|
|
113
|
+
|
|
114
|
+
# Search project knowledge
|
|
115
|
+
octonodes knowledge.api.search.post \
|
|
116
|
+
--input '{"query":{"workspace":"acme","project":"support"},"body":{"query":"refund policy","topK":5}}'
|
|
117
|
+
|
|
118
|
+
# Cancel an execution
|
|
119
|
+
octonodes executions.api.runId.cancel.post \
|
|
120
|
+
--input '{"path":{"runId":"run_123"}}'
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Normal responses are printed as formatted JSON. Server-sent event operations print one JSON value
|
|
124
|
+
per line, which works well with `jq` and shell pipelines:
|
|
125
|
+
|
|
126
|
+
```sh
|
|
127
|
+
octonodes workflows.api.workflowId.run.post \
|
|
128
|
+
--input '{"path":{"workflowId":"daily-report"},"body":{"input":{"date":"2026-09-18"}}}' \
|
|
129
|
+
| jq -c .
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Run `octonodes <operation> --help` for the accepted flags. The exact input shape for each operation
|
|
133
|
+
is defined by the exported TypeScript types in `@octonodes/sdk`. For workflow behavior and setup,
|
|
134
|
+
see the [Playbook documentation](https://playbook.octonodes.com/docs); for shared examples, browse
|
|
135
|
+
the [Octonode community](https://community.octonodes.com/community).
|
|
136
|
+
|
|
137
|
+
## Configuration
|
|
138
|
+
|
|
139
|
+
| Variable | Purpose |
|
|
140
|
+
| --- | --- |
|
|
141
|
+
| `OCTONODE_TOKEN` | Overrides every saved login. |
|
|
142
|
+
| `OCTONODE_URL` | Overrides `https://api.octonode.dev`. |
|
|
143
|
+
| `OCTONODE_CONFIG_DIR` | Overrides the default `~/.octonode` directory. |
|
|
144
|
+
|
|
145
|
+
Use `--base-url <url>` to override the API URL for one login or API command:
|
|
146
|
+
|
|
147
|
+
```sh
|
|
148
|
+
octonodes projects.api.get --base-url http://localhost:4000
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Log out
|
|
152
|
+
|
|
153
|
+
```sh
|
|
154
|
+
octonodes logout
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Logout revokes a saved Studio refresh session and removes saved CLI credentials. Static API tokens
|
|
158
|
+
must still be revoked in Studio. The command cannot unset `OCTONODE_TOKEN` from your shell.
|
|
159
|
+
|
|
160
|
+
Saved files and their parent directory use user-only permissions. Keep service and personal tokens
|
|
161
|
+
out of shell history, logs, and source control.
|
|
16
162
|
|
|
17
|
-
|
|
18
|
-
Supabase redirect allow list must contain `http://127.0.0.1:*/auth/callback/**` for browser
|
|
19
|
-
login.
|
|
163
|
+
## Documentation
|
|
20
164
|
|
|
21
|
-
|
|
22
|
-
|
|
165
|
+
- [API reference](https://octonodes.com/api/docs)
|
|
166
|
+
- [Playbook documentation](https://playbook.octonodes.com/docs)
|
|
167
|
+
- [Octonode community](https://community.octonodes.com/community)
|
|
23
168
|
|
|
24
|
-
|
|
25
|
-
credentials. Static API tokens must still be revoked in Studio, and logout cannot unset
|
|
26
|
-
`OCTONODE_TOKEN` in your shell.
|
|
169
|
+
## SDK
|
|
27
170
|
|
|
28
|
-
|
|
29
|
-
|
|
171
|
+
Use [`@octonodes/sdk`](https://www.npmjs.com/package/@octonodes/sdk) for typed application code and
|
|
172
|
+
direct access to the same API operations.
|
package/dist/index.js
CHANGED
|
@@ -52,6 +52,10 @@ function flag(name) {
|
|
|
52
52
|
return value;
|
|
53
53
|
}
|
|
54
54
|
function usage(topic) {
|
|
55
|
+
if (topic === "plugin") {
|
|
56
|
+
process.stdout.write(require("./plugins/constants").PLUGIN_HELP);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
55
59
|
if (topic === "login") {
|
|
56
60
|
process.stdout.write(`Usage:\n octonodes login [--base-url <url>]\n octonodes login --email <email> [--base-url <url>]\n octonodes login --token <api-token>\n\nOpens GitHub login in your browser and signs in as the same user as Octonode Studio. Use --email for terminal email-code login, or --token for a personal, service, public, or agent API token.\n`);
|
|
57
61
|
return;
|
|
@@ -68,6 +72,7 @@ function usage(topic) {
|
|
|
68
72
|
process.stdout.write(`Usage:\n octonodes ${topic} [--input <json>] [--base-url <url>]\n`);
|
|
69
73
|
return;
|
|
70
74
|
}
|
|
75
|
+
process.stdout.write("Plugin development: octonodes plugin <create|build|validate|test|publish> (see octonodes plugin --help)\n\n");
|
|
71
76
|
process.stdout.write(`octonodes v${VERSION}\n\nUsage:\n octonodes login [--base-url <url>]\n octonodes login --email <email> [--base-url <url>]\n octonodes login --token <api-token>\n octonodes logout\n octonodes operations [filter]\n octonodes <operation> [--input <json>] [--base-url <url>]\n\nFlags:\n -h, --h, --help Show help\n -v, --version Show version\n\nEnvironment:\n OCTONODE_TOKEN Overrides the saved login\n OCTONODE_URL Overrides ${sdk_1.OCTONODE_API_URL}\n OCTONODE_CONFIG_DIR Overrides ~/.octonode\n`);
|
|
72
77
|
}
|
|
73
78
|
async function main() {
|
|
@@ -79,6 +84,11 @@ async function main() {
|
|
|
79
84
|
}
|
|
80
85
|
if (helpRequested)
|
|
81
86
|
return usage(command.startsWith("-") ? undefined : command);
|
|
87
|
+
if (command === "plugin") {
|
|
88
|
+
if (argv.length === 1)
|
|
89
|
+
return usage("plugin");
|
|
90
|
+
return (await import("./plugins/index.js")).pluginCommand(argv.slice(1), VERSION);
|
|
91
|
+
}
|
|
82
92
|
if (command === "login") {
|
|
83
93
|
const baseUrl = flag("--base-url") ?? process.env.OCTONODE_URL ?? sdk_1.OCTONODE_API_URL;
|
|
84
94
|
process.stdout.write(`${await (0, auth_1.login)(baseUrl, { token: flag("--token"), email: flag("--email") })}\n`);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,wCAAgF;AAChF,iCAAoD;AAEpD,MAAM,OAAO,GAAI,OAAO,CAAC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|
+
export declare const fileHash: (path: string) => string;
|
|
3
|
+
export declare function safePath(path: string): void;
|
|
4
|
+
export declare function pluginFiles(root: string, prefix?: string): string[];
|
|
5
|
+
export declare function loadManifest(directory: string): PluginManifest;
|
|
6
|
+
/** Publishing is data-only: no contributor modules or lifecycle scripts are executed. */
|
|
7
|
+
export declare function verifyBuild(directory: string): {
|
|
8
|
+
manifest: PluginManifest;
|
|
9
|
+
files: string[];
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=artifact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact.d.ts","sourceRoot":"","sources":["../../src/plugins/artifact.ts"],"names":[],"mappings":"AAGA,OAAO,EAA8B,cAAc,EAAwB,MAAM,wBAAwB,CAAC;AAK1G,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,KAAG,MACuB,CAAC;AAEhE,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAc3C;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,SAAK,GAAG,MAAM,EAAE,CAc/D;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,CAsB9D;AAED,yFAAyF;AACzF,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG;IAAE,QAAQ,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,CA4D5F"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fileHash = void 0;
|
|
4
|
+
exports.safePath = safePath;
|
|
5
|
+
exports.pluginFiles = pluginFiles;
|
|
6
|
+
exports.loadManifest = loadManifest;
|
|
7
|
+
exports.verifyBuild = verifyBuild;
|
|
8
|
+
const node_crypto_1 = require("node:crypto");
|
|
9
|
+
const node_fs_1 = require("node:fs");
|
|
10
|
+
const node_path_1 = require("node:path");
|
|
11
|
+
const plugins_1 = require("@octonodes/sdk/plugins");
|
|
12
|
+
const yaml_1 = require("yaml");
|
|
13
|
+
const constants_1 = require("./constants");
|
|
14
|
+
const fileHash = (path) => (0, node_crypto_1.createHash)("sha256").update((0, node_fs_1.readFileSync)(path)).digest("hex");
|
|
15
|
+
exports.fileHash = fileHash;
|
|
16
|
+
function safePath(path) {
|
|
17
|
+
if (!path ||
|
|
18
|
+
(0, node_path_1.isAbsolute)(path) ||
|
|
19
|
+
path.includes("\\") ||
|
|
20
|
+
path
|
|
21
|
+
.split("/")
|
|
22
|
+
.some((part) => !part || part === "." || part === ".." || part.includes(":") || constants_1.FORBIDDEN_PART.test(part))) {
|
|
23
|
+
throw new Error(`Unsafe plugin file: ${path}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function pluginFiles(root, prefix = "") {
|
|
27
|
+
if (!(0, node_fs_1.lstatSync)((0, node_path_1.join)(root, prefix)).isDirectory())
|
|
28
|
+
throw new Error(`Not a plugin directory: ${root}`);
|
|
29
|
+
return (0, node_fs_1.readdirSync)((0, node_path_1.join)(root, prefix))
|
|
30
|
+
.sort()
|
|
31
|
+
.flatMap((name) => {
|
|
32
|
+
const path = prefix ? `${prefix}/${name}` : name;
|
|
33
|
+
safePath(path);
|
|
34
|
+
const stat = (0, node_fs_1.lstatSync)((0, node_path_1.join)(root, path));
|
|
35
|
+
if (stat.isSymbolicLink())
|
|
36
|
+
throw new Error(`Plugin files cannot be symbolic links: ${path}`);
|
|
37
|
+
if (stat.isDirectory())
|
|
38
|
+
return pluginFiles(root, path);
|
|
39
|
+
if (!stat.isFile())
|
|
40
|
+
throw new Error(`Plugin asset must be a regular file: ${path}`);
|
|
41
|
+
return [path];
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function loadManifest(directory) {
|
|
45
|
+
if ((0, node_fs_1.lstatSync)(directory).isSymbolicLink())
|
|
46
|
+
throw new Error("Plugin directory cannot be a symbolic link");
|
|
47
|
+
const definitions = constants_1.DEFINITION_FILES.filter((name) => (0, node_fs_1.existsSync)((0, node_path_1.join)(directory, name)));
|
|
48
|
+
if (definitions.length !== 1)
|
|
49
|
+
throw new Error("Keep exactly one plugin definition in the package");
|
|
50
|
+
const path = (0, node_path_1.join)(directory, definitions[0]);
|
|
51
|
+
const stat = (0, node_fs_1.lstatSync)(path);
|
|
52
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.size > 1_048_576)
|
|
53
|
+
throw new Error("Invalid plugin definition file");
|
|
54
|
+
const document = (0, yaml_1.parseDocument)((0, node_fs_1.readFileSync)(path, "utf8"), { uniqueKeys: true, version: "1.2" });
|
|
55
|
+
(0, yaml_1.visit)(document, {
|
|
56
|
+
Alias() {
|
|
57
|
+
throw new Error("Plugin definitions cannot contain YAML aliases");
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
if (document.errors.length || document.warnings.length)
|
|
61
|
+
throw new Error("Invalid plugin definition YAML/JSON");
|
|
62
|
+
const data = document.toJS({ maxAliasCount: 0 });
|
|
63
|
+
if (definitions[0] === "octonode.plugin.json")
|
|
64
|
+
return plugins_1.PluginManifest.parse(data);
|
|
65
|
+
if (data?.apiVersion !== plugins_1.SETTINGS_API_VERSION)
|
|
66
|
+
throw new Error("Unsupported plugin apiVersion");
|
|
67
|
+
return plugins_1.PluginManifest.parse(data.plugin);
|
|
68
|
+
}
|
|
69
|
+
/** Publishing is data-only: no contributor modules or lifecycle scripts are executed. */
|
|
70
|
+
function verifyBuild(directory) {
|
|
71
|
+
const manifest = loadManifest(directory);
|
|
72
|
+
const files = pluginFiles(directory);
|
|
73
|
+
if (!files.includes(constants_1.BUILD_RECORD))
|
|
74
|
+
throw new Error("Missing build record; run octonodes plugin build first");
|
|
75
|
+
const record = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(directory, constants_1.BUILD_RECORD), "utf8"));
|
|
76
|
+
if (record.format !== 1 ||
|
|
77
|
+
!record.files ||
|
|
78
|
+
typeof record.files !== "object" ||
|
|
79
|
+
Array.isArray(record.files)) {
|
|
80
|
+
throw new Error("Invalid plugin build record");
|
|
81
|
+
}
|
|
82
|
+
const expected = Object.keys(record.files).sort();
|
|
83
|
+
if (JSON.stringify(expected) !==
|
|
84
|
+
JSON.stringify(files.filter((name) => name !== constants_1.BUILD_RECORD).sort())) {
|
|
85
|
+
throw new Error("Plugin files changed since build; rebuild before publishing");
|
|
86
|
+
}
|
|
87
|
+
for (const file of expected) {
|
|
88
|
+
if (record.files[file] !== (0, exports.fileHash)((0, node_path_1.join)(directory, file)))
|
|
89
|
+
throw new Error(`Plugin file changed since build: ${file}`);
|
|
90
|
+
}
|
|
91
|
+
if (!expected.includes("dist/index.js") ||
|
|
92
|
+
!manifest.nodes.length ||
|
|
93
|
+
manifest.nodes.some((node) => node.command !== `node dist/index.js ${node.id}`))
|
|
94
|
+
throw new Error("Invalid built plugin runner");
|
|
95
|
+
const ui = manifest.nodes.flatMap((node) => Object.entries(node.ui?.renderers ?? {}).flatMap(([renderer, definition]) => Object.entries(definition.targets).map(([target, path]) => ({
|
|
96
|
+
nodeId: node.id,
|
|
97
|
+
apiVersion: node.ui.apiVersion,
|
|
98
|
+
renderer,
|
|
99
|
+
target,
|
|
100
|
+
path,
|
|
101
|
+
}))));
|
|
102
|
+
for (const entry of new Set(ui.map(({ path }) => path))) {
|
|
103
|
+
if (!expected.includes(entry) || (0, node_fs_1.lstatSync)((0, node_path_1.join)(directory, entry)).size > plugins_1.PLUGIN_UI_BUNDLE_MAX_BYTES)
|
|
104
|
+
throw new Error(`Invalid plugin UI bundle: ${entry}`);
|
|
105
|
+
}
|
|
106
|
+
if (JSON.stringify(record.ui ?? []) !==
|
|
107
|
+
JSON.stringify(ui.map((declaration) => ({
|
|
108
|
+
...declaration,
|
|
109
|
+
size: (0, node_fs_1.lstatSync)((0, node_path_1.join)(directory, declaration.path)).size,
|
|
110
|
+
sha256: (0, exports.fileHash)((0, node_path_1.join)(directory, declaration.path)),
|
|
111
|
+
}))))
|
|
112
|
+
throw new Error("Invalid plugin UI build record");
|
|
113
|
+
return { manifest, files };
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=artifact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact.js","sourceRoot":"","sources":["../../src/plugins/artifact.ts"],"names":[],"mappings":";;;AAWA,4BAcC;AAED,kCAcC;AAED,oCAsBC;AAGD,kCA4DC;AAhID,6CAAyC;AACzC,qCAA2E;AAC3E,yCAA6C;AAC7C,oDAA0G;AAC1G,+BAA4C;AAC5C,2CAA6E;AAGtE,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAU,EAAE,CAC/C,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAA,sBAAY,EAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AADnD,QAAA,QAAQ,YAC2C;AAEhE,SAAgB,QAAQ,CAAC,IAAY;IACnC,IACE,CAAC,IAAI;QACL,IAAA,sBAAU,EAAC,IAAI,CAAC;QAChB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QACnB,IAAI;aACD,KAAK,CAAC,GAAG,CAAC;aACV,IAAI,CACH,CAAC,IAAI,EAAE,EAAE,CACP,CAAC,IAAI,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,0BAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAC5F,EACH,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC;AACH,CAAC;AAED,SAAgB,WAAW,CAAC,IAAY,EAAE,MAAM,GAAG,EAAE;IACnD,IAAI,CAAC,IAAA,mBAAS,EAAC,IAAA,gBAAI,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,WAAW,EAAE;QAC9C,MAAM,IAAI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A,mBAAS,EAAC,IAAA,gBAAI,EAAC,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI;YACvD,MAAM,EAAE,IAAA,gBAAQ,EAAC,IAAA,gBAAI,EAAC,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;SACpD,CAAC,CAAC,CACJ;QAED,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/plugins/build.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAc3C,wBAAsB,YAAY,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,SAAgB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAkO/F"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildPlugins = buildPlugins;
|
|
4
|
+
const node_child_process_1 = require("node:child_process");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const node_module_1 = require("node:module");
|
|
8
|
+
const esbuild_1 = require("esbuild");
|
|
9
|
+
const yaml_1 = require("yaml");
|
|
10
|
+
const plugins_1 = require("@octonodes/sdk/plugins");
|
|
11
|
+
const constants_1 = require("./constants");
|
|
12
|
+
const artifact_1 = require("./artifact");
|
|
13
|
+
function directory(root, path) {
|
|
14
|
+
let current = root;
|
|
15
|
+
for (const part of path.split("/")) {
|
|
16
|
+
current = (0, node_path_1.join)(current, part);
|
|
17
|
+
if (!(0, node_fs_1.existsSync)(current))
|
|
18
|
+
(0, node_fs_1.mkdirSync)(current);
|
|
19
|
+
const stat = (0, node_fs_1.lstatSync)(current);
|
|
20
|
+
if (stat.isSymbolicLink() || !stat.isDirectory())
|
|
21
|
+
throw new Error(`Build directory must be a real directory: ${current}`);
|
|
22
|
+
}
|
|
23
|
+
return current;
|
|
24
|
+
}
|
|
25
|
+
async function buildPlugins(entry, root = process.cwd()) {
|
|
26
|
+
root = (0, node_path_1.resolve)(root);
|
|
27
|
+
const entries = entry
|
|
28
|
+
? [(0, node_path_1.resolve)(root, entry)]
|
|
29
|
+
: (0, node_fs_1.globSync)("plugins/**/*.plugin.ts", { cwd: root })
|
|
30
|
+
.sort()
|
|
31
|
+
.map((file) => (0, node_path_1.resolve)(root, file));
|
|
32
|
+
if (!entries.length)
|
|
33
|
+
throw new Error("No plugins found in plugins/**/*.plugin.ts");
|
|
34
|
+
const output = directory(root, "dist/plugins");
|
|
35
|
+
const staging = (0, node_fs_1.mkdtempSync)((0, node_path_1.join)(output, ".build-"));
|
|
36
|
+
const prepared = [];
|
|
37
|
+
try {
|
|
38
|
+
// Inspect CommonJS bundles independently of the author's package module type.
|
|
39
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(staging, "package.json"), '{"type":"commonjs"}\n');
|
|
40
|
+
for (const [index, source] of entries.entries()) {
|
|
41
|
+
const sourcePath = (0, node_path_1.relative)(root, source).replaceAll("\\", "/");
|
|
42
|
+
(0, artifact_1.safePath)(sourcePath);
|
|
43
|
+
const staged = (0, node_path_1.join)(staging, String(index));
|
|
44
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(staged, "dist"), { recursive: true });
|
|
45
|
+
const runner = (0, node_path_1.join)(staged, "dist/index.js");
|
|
46
|
+
const result = await (0, esbuild_1.build)({
|
|
47
|
+
absWorkingDir: root,
|
|
48
|
+
stdin: {
|
|
49
|
+
contents: `export { default as plugin } from ${JSON.stringify(source)}; export { startPlugin } from "@octonodes/sdk/plugins";`,
|
|
50
|
+
resolveDir: root,
|
|
51
|
+
sourcefile: "octonode-entry.ts",
|
|
52
|
+
loader: "ts",
|
|
53
|
+
},
|
|
54
|
+
outfile: runner,
|
|
55
|
+
bundle: true,
|
|
56
|
+
platform: "node",
|
|
57
|
+
format: "cjs",
|
|
58
|
+
target: "node24",
|
|
59
|
+
metafile: true,
|
|
60
|
+
logLevel: "silent",
|
|
61
|
+
legalComments: "eof",
|
|
62
|
+
banner: {
|
|
63
|
+
js: 'globalThis.console = new (require("node:console").Console)({ stdout: process.stderr, stderr: process.stderr });',
|
|
64
|
+
},
|
|
65
|
+
logOverride: {
|
|
66
|
+
"unsupported-require-call": "warning",
|
|
67
|
+
"unsupported-dynamic-import": "warning",
|
|
68
|
+
"empty-import-meta": "error",
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
// esbuild cannot make computed imports or native modules portable. Fail instead of shipping a broken bundle.
|
|
72
|
+
if (result.warnings.length)
|
|
73
|
+
throw new Error(result.warnings.map((warning) => warning.text).join("\n"));
|
|
74
|
+
for (const info of Object.values(result.metafile.outputs)) {
|
|
75
|
+
for (const dependency of info.imports) {
|
|
76
|
+
if (dependency.external && !(0, node_module_1.isBuiltin)(dependency.path))
|
|
77
|
+
throw new Error(`Unbundled dependency: ${dependency.path}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const metadata = JSON.parse((0, node_child_process_1.execFileSync)(process.execPath, [
|
|
81
|
+
"-e",
|
|
82
|
+
`
|
|
83
|
+
console = new (require('node:console').Console)({ stdout: process.stderr, stderr: process.stderr });
|
|
84
|
+
const { plugin } = require(process.argv[1]);
|
|
85
|
+
process.stdout.write(JSON.stringify({ manifest: plugin.manifest, assets: plugin.assets ?? [] }));
|
|
86
|
+
`,
|
|
87
|
+
runner,
|
|
88
|
+
], { cwd: root, encoding: "utf8", timeout: 30_000, maxBuffer: 2 * 1024 * 1024 }));
|
|
89
|
+
const manifest = plugins_1.PluginManifest.parse(metadata.manifest);
|
|
90
|
+
if (!manifest.nodes.length)
|
|
91
|
+
throw new Error(`Plugin ${manifest.id} must expose at least one node`);
|
|
92
|
+
if (prepared.some((plugin) => plugin.manifest.id === manifest.id))
|
|
93
|
+
throw new Error(`Duplicate plugin id: ${manifest.id}`);
|
|
94
|
+
const uiDeclarations = manifest.nodes.flatMap((node) => Object.entries(node.ui?.renderers ?? {}).flatMap(([renderer, definition]) => Object.entries(definition.targets).map(([target, path]) => ({
|
|
95
|
+
nodeId: node.id,
|
|
96
|
+
apiVersion: node.ui.apiVersion,
|
|
97
|
+
renderer,
|
|
98
|
+
target: target,
|
|
99
|
+
path,
|
|
100
|
+
}))));
|
|
101
|
+
const uiEntries = [...new Set(uiDeclarations.map(({ path }) => path))];
|
|
102
|
+
for (const entry of uiEntries) {
|
|
103
|
+
(0, artifact_1.safePath)(entry);
|
|
104
|
+
if (constants_1.RESERVED_ASSETS.has(entry.split("/")[0]))
|
|
105
|
+
throw new Error(`UI entry overwrites a generated file: ${entry}`);
|
|
106
|
+
}
|
|
107
|
+
if (!Array.isArray(metadata.assets) ||
|
|
108
|
+
metadata.assets.some((path) => typeof path !== "string"))
|
|
109
|
+
throw new Error("assets must be an array of file paths");
|
|
110
|
+
for (const asset of metadata.assets) {
|
|
111
|
+
(0, artifact_1.safePath)(asset);
|
|
112
|
+
if (uiEntries.includes(asset))
|
|
113
|
+
throw new Error(`Asset duplicates a UI entry: ${asset}`);
|
|
114
|
+
if (constants_1.RESERVED_ASSETS.has(asset.split("/")[0]))
|
|
115
|
+
throw new Error(`Asset overwrites a generated file: ${asset}`);
|
|
116
|
+
let current = root;
|
|
117
|
+
for (const part of asset.split("/")) {
|
|
118
|
+
current = (0, node_path_1.join)(current, part);
|
|
119
|
+
if ((0, node_fs_1.lstatSync)(current).isSymbolicLink())
|
|
120
|
+
throw new Error(`Asset cannot be a symbolic link: ${asset}`);
|
|
121
|
+
}
|
|
122
|
+
if (!(0, node_fs_1.lstatSync)(current).isFile())
|
|
123
|
+
throw new Error(`Declare individual asset files: ${asset}`);
|
|
124
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)((0, node_path_1.join)(staged, asset)), { recursive: true });
|
|
125
|
+
(0, node_fs_1.cpSync)(current, (0, node_path_1.join)(staged, asset));
|
|
126
|
+
}
|
|
127
|
+
for (const entry of uiEntries) {
|
|
128
|
+
let current = root;
|
|
129
|
+
for (const part of entry.split("/")) {
|
|
130
|
+
current = (0, node_path_1.join)(current, part);
|
|
131
|
+
if ((0, node_fs_1.lstatSync)(current).isSymbolicLink())
|
|
132
|
+
throw new Error(`UI entry cannot be a symbolic link: ${entry}`);
|
|
133
|
+
}
|
|
134
|
+
if (!(0, node_fs_1.lstatSync)(current).isFile())
|
|
135
|
+
throw new Error(`UI entry must be a file: ${entry}`);
|
|
136
|
+
directory(staged, (0, node_path_1.dirname)(entry));
|
|
137
|
+
const ui = await (0, esbuild_1.build)({
|
|
138
|
+
absWorkingDir: root,
|
|
139
|
+
stdin: {
|
|
140
|
+
contents: `import extension from ${JSON.stringify(current)}; import { startExtension } from "@octonodes/ui-extensions/react"; startExtension(extension);`,
|
|
141
|
+
resolveDir: root,
|
|
142
|
+
sourcefile: "octonode-ui-entry.ts",
|
|
143
|
+
loader: "ts",
|
|
144
|
+
},
|
|
145
|
+
outfile: (0, node_path_1.join)(staged, entry),
|
|
146
|
+
bundle: true,
|
|
147
|
+
platform: "browser",
|
|
148
|
+
format: "iife",
|
|
149
|
+
target: "es2021",
|
|
150
|
+
minify: true,
|
|
151
|
+
metafile: true,
|
|
152
|
+
logLevel: "silent",
|
|
153
|
+
legalComments: "eof",
|
|
154
|
+
});
|
|
155
|
+
if (ui.warnings.length)
|
|
156
|
+
throw new Error(ui.warnings.map((warning) => warning.text).join("\n"));
|
|
157
|
+
if (Object.values(ui.metafile.outputs).some((output) => output.imports.some((dependency) => dependency.external)))
|
|
158
|
+
throw new Error(`UI entry has an unbundled dependency: ${entry}`);
|
|
159
|
+
if ((0, node_fs_1.statSync)((0, node_path_1.join)(staged, entry)).size > plugins_1.PLUGIN_UI_BUNDLE_MAX_BYTES)
|
|
160
|
+
throw new Error(`UI entry exceeds 512 KiB: ${entry}`);
|
|
161
|
+
}
|
|
162
|
+
const serialized = JSON.stringify(manifest);
|
|
163
|
+
(0, node_fs_1.writeFileSync)(runner, (0, node_fs_1.readFileSync)(runner, "utf8") +
|
|
164
|
+
`\nif (require.main === module) {
|
|
165
|
+
if (JSON.stringify(module.exports.plugin.manifest) !== ${JSON.stringify(serialized)}) throw new Error("Plugin definition changed at runtime; keep metadata independent of the environment");
|
|
166
|
+
module.exports.startPlugin(module.exports.plugin);
|
|
167
|
+
}\n`);
|
|
168
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(staged, "octonode.yml"), (0, yaml_1.stringify)({ apiVersion: plugins_1.SETTINGS_API_VERSION, plugin: manifest }));
|
|
169
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(staged, "package.json"), JSON.stringify({
|
|
170
|
+
name: `octonode-plugin-${manifest.id}`,
|
|
171
|
+
version: manifest.version,
|
|
172
|
+
private: true,
|
|
173
|
+
type: "commonjs",
|
|
174
|
+
engines: { node: ">=24" },
|
|
175
|
+
license: manifest.license,
|
|
176
|
+
}, null, 2) + "\n");
|
|
177
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(staged, "README.md"), `# ${manifest.name}\n\n${manifest.description ?? ""}\n\n${manifest.nodes
|
|
178
|
+
.map((node) => `## ${node.label ?? node.id}\n\n${node.description ?? ""}\n\nNode: \`${manifest.id}/${node.id}\`\n\nInputs:\n\`\`\`json\n${JSON.stringify(node.inputs ?? {}, null, 2)}\n\`\`\`\n\nOutputs:\n\`\`\`json\n${JSON.stringify(node.outputs ?? {}, null, 2)}\n\`\`\`\n`)
|
|
179
|
+
.join("\n")}\nCredentials (supplied by each installer):\n\`\`\`json\n${JSON.stringify(manifest.connections ?? {}, null, 2)}\n\`\`\`\n`);
|
|
180
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(staged, constants_1.BUILD_RECORD), JSON.stringify({
|
|
181
|
+
format: 1,
|
|
182
|
+
files: Object.fromEntries((0, artifact_1.pluginFiles)(staged).map((file) => [file, (0, artifact_1.fileHash)((0, node_path_1.join)(staged, file))])),
|
|
183
|
+
ui: uiDeclarations.map((declaration) => ({
|
|
184
|
+
...declaration,
|
|
185
|
+
size: (0, node_fs_1.statSync)((0, node_path_1.join)(staged, declaration.path)).size,
|
|
186
|
+
sha256: (0, artifact_1.fileHash)((0, node_path_1.join)(staged, declaration.path)),
|
|
187
|
+
})),
|
|
188
|
+
}, null, 2) + "\n");
|
|
189
|
+
(0, artifact_1.verifyBuild)(staged);
|
|
190
|
+
const destination = (0, node_path_1.join)(output, manifest.id);
|
|
191
|
+
// Only replace a complete, unchanged artifact produced by this builder.
|
|
192
|
+
if ((0, node_fs_1.existsSync)(destination))
|
|
193
|
+
(0, artifact_1.verifyBuild)(destination);
|
|
194
|
+
prepared.push({ manifest, directory: destination, staged });
|
|
195
|
+
}
|
|
196
|
+
for (const [index, plugin] of prepared.entries()) {
|
|
197
|
+
const backup = (0, node_path_1.join)(staging, `previous-${index}`);
|
|
198
|
+
if ((0, node_fs_1.existsSync)(plugin.directory))
|
|
199
|
+
(0, node_fs_1.renameSync)(plugin.directory, backup);
|
|
200
|
+
try {
|
|
201
|
+
(0, node_fs_1.renameSync)(plugin.staged, plugin.directory);
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
if ((0, node_fs_1.existsSync)(backup))
|
|
205
|
+
(0, node_fs_1.renameSync)(backup, plugin.directory);
|
|
206
|
+
throw error;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return prepared.map(({ manifest, directory }) => ({ manifest, directory }));
|
|
210
|
+
}
|
|
211
|
+
finally {
|
|
212
|
+
(0, node_fs_1.rmSync)(staging, { recursive: true, force: true });
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/plugins/build.ts"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,CAAC;gBACf,IAAI,IAAA,oBAAU,EAAC,MAAM,CAAC;oBAAE,IAAA,oBAAU,EAAC,MAAM,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;gBAC7D,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QACD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IAC9E,CAAC;YAAS,CAAC;QACT,IAAA,gBAAM,EAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const BUILD_RECORD = "octonode-build.json";
|
|
2
|
+
export declare const DEFINITION_FILES: string[];
|
|
3
|
+
export declare const FORBIDDEN_PART: RegExp;
|
|
4
|
+
export declare const RESERVED_ASSETS: Set<string>;
|
|
5
|
+
export declare const PLUGIN_HELP = "Usage:\n octonodes plugin create <name>\n octonodes plugin build [plugins/example.plugin.ts]\n octonodes plugin validate <built-directory>\n octonodes plugin test <built-directory> [node-id] --input <json>\n octonodes plugin publish <built-directory> --registry <url> [--org <id>] [--team <id>]\n\nBuild discovers plugins/**/*.plugin.ts and writes dist/plugins/<id>.\nDefinitions execute locally during build. Only build trusted source.\nPublishing uses OCTONODE_MARKETPLACE_URL and OCTONODE_MARKETPLACE_TOKEN when set,\nor the saved octonodes login / OCTONODE_TOKEN. It never publishes to npm.\n";
|
|
6
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/plugins/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,wBAAwB,CAAC;AAClD,eAAO,MAAM,gBAAgB,UAK5B,CAAC;AACF,eAAO,MAAM,cAAc,QAA4D,CAAC;AACxF,eAAO,MAAM,eAAe,aAM1B,CAAC;AACH,eAAO,MAAM,WAAW,8lBAWvB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PLUGIN_HELP = exports.RESERVED_ASSETS = exports.FORBIDDEN_PART = exports.DEFINITION_FILES = exports.BUILD_RECORD = void 0;
|
|
4
|
+
exports.BUILD_RECORD = "octonode-build.json";
|
|
5
|
+
exports.DEFINITION_FILES = [
|
|
6
|
+
"octonode.yml",
|
|
7
|
+
"octonode.yaml",
|
|
8
|
+
"octonode.json",
|
|
9
|
+
"octonode.plugin.json",
|
|
10
|
+
];
|
|
11
|
+
exports.FORBIDDEN_PART = /^(?:\.env(?:\..*)?|\.git|node_modules)$|\.(?:pem|key)$/i;
|
|
12
|
+
exports.RESERVED_ASSETS = new Set([
|
|
13
|
+
...exports.DEFINITION_FILES,
|
|
14
|
+
exports.BUILD_RECORD,
|
|
15
|
+
"package.json",
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
]);
|
|
19
|
+
exports.PLUGIN_HELP = `Usage:
|
|
20
|
+
octonodes plugin create <name>
|
|
21
|
+
octonodes plugin build [plugins/example.plugin.ts]
|
|
22
|
+
octonodes plugin validate <built-directory>
|
|
23
|
+
octonodes plugin test <built-directory> [node-id] --input <json>
|
|
24
|
+
octonodes plugin publish <built-directory> --registry <url> [--org <id>] [--team <id>]
|
|
25
|
+
|
|
26
|
+
Build discovers plugins/**/*.plugin.ts and writes dist/plugins/<id>.
|
|
27
|
+
Definitions execute locally during build. Only build trusted source.
|
|
28
|
+
Publishing uses OCTONODE_MARKETPLACE_URL and OCTONODE_MARKETPLACE_TOKEN when set,
|
|
29
|
+
or the saved octonodes login / OCTONODE_TOKEN. It never publishes to npm.
|
|
30
|
+
`;
|
|
31
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/plugins/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG,qBAAqB,CAAC;AACrC,QAAA,gBAAgB,GAAG;IAC9B,cAAc;IACd,eAAe;IACf,eAAe;IACf,sBAAsB;CACvB,CAAC;AACW,QAAA,cAAc,GAAG,yDAAyD,CAAC;AAC3E,QAAA,eAAe,GAAG,IAAI,GAAG,CAAC;IACrC,GAAG,wBAAgB;IACnB,oBAAY;IACZ,cAAc;IACd,MAAM;IACN,WAAW;CACZ,CAAC,CAAC;AACU,QAAA,WAAW,GAAG;;;;;;;;;;;CAW1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/plugins/create.ts"],"names":[],"mappings":"AAGA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAoFlE"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPlugin = createPlugin;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
function createPlugin(name, version) {
|
|
7
|
+
if (!/^[a-z0-9][a-z0-9-]*$/.test(name))
|
|
8
|
+
throw new Error("Plugin name must be lowercase alphanumeric/dash");
|
|
9
|
+
const root = (0, node_path_1.resolve)(name);
|
|
10
|
+
(0, node_fs_1.mkdirSync)(root); // Never overwrite an existing project.
|
|
11
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(root, "plugins"));
|
|
12
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(root, "tests"));
|
|
13
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(root, "package.json"), JSON.stringify({
|
|
14
|
+
name,
|
|
15
|
+
private: true,
|
|
16
|
+
engines: { node: ">=24" },
|
|
17
|
+
scripts: {
|
|
18
|
+
build: "tsc --noEmit && octonodes plugin build",
|
|
19
|
+
test: "npm run build && node --test tests/*.test.cjs",
|
|
20
|
+
},
|
|
21
|
+
dependencies: { "@octonodes/sdk": version },
|
|
22
|
+
devDependencies: {
|
|
23
|
+
"@octonodes/cli": version,
|
|
24
|
+
typescript: "5.9.3",
|
|
25
|
+
"@types/node": "^24.0.0",
|
|
26
|
+
},
|
|
27
|
+
}, null, 2) + "\n");
|
|
28
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(root, "tsconfig.json"), JSON.stringify({
|
|
29
|
+
compilerOptions: {
|
|
30
|
+
target: "ES2024",
|
|
31
|
+
module: "Node16",
|
|
32
|
+
strict: true,
|
|
33
|
+
skipLibCheck: true,
|
|
34
|
+
noEmit: true,
|
|
35
|
+
},
|
|
36
|
+
include: ["plugins/**/*.ts", "src/**/*.ts"],
|
|
37
|
+
}, null, 2) + "\n");
|
|
38
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(root, ".gitignore"), "node_modules/\ndist/\n.env\n.env.*\n");
|
|
39
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(root, "plugins", `${name}.plugin.ts`), `import { definePlugin, defineNode } from "@octonodes/sdk/plugins";
|
|
40
|
+
|
|
41
|
+
export default definePlugin({
|
|
42
|
+
id: ${JSON.stringify(name)}, name: ${JSON.stringify(name)}, version: "0.1.0", license: "MIT",
|
|
43
|
+
scope: ["user"],
|
|
44
|
+
nodes: [defineNode({
|
|
45
|
+
id: "echo", label: "Echo text",
|
|
46
|
+
inputs: { type: "object", properties: { text: { type: "string" } }, required: ["text"] },
|
|
47
|
+
outputs: { type: "object", properties: { text: { type: "string" } }, required: ["text"] },
|
|
48
|
+
defaults: { text: "hello" },
|
|
49
|
+
run: ({ text }) => ({ text }),
|
|
50
|
+
})],
|
|
51
|
+
});
|
|
52
|
+
`);
|
|
53
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(root, "tests/plugin.test.cjs"), `const { test } = require("node:test");
|
|
54
|
+
const assert = require("node:assert/strict");
|
|
55
|
+
const { execFileSync } = require("node:child_process");
|
|
56
|
+
test("echo runs through the packaged plugin", () => {
|
|
57
|
+
const result = JSON.parse(execFileSync(process.execPath, ["dist/index.js", "echo"], {
|
|
58
|
+
cwd: ${JSON.stringify(`dist/plugins/${name}`)}, encoding: "utf8",
|
|
59
|
+
input: JSON.stringify({octonode:"1",type:"invoke",invocationId:"test",inputs:{text:"hello"}}),
|
|
60
|
+
}));
|
|
61
|
+
assert.equal(result.status, "ok");
|
|
62
|
+
assert.deepEqual(result.outputs, {text:"hello"});
|
|
63
|
+
});
|
|
64
|
+
`);
|
|
65
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(root, "README.md"), `# ${name}\n\nRun \`npm install\`, then \`npm test\`. Define additional plugins in \`plugins/*.plugin.ts\`.\n\nAll metadata belongs in code; \`dist/plugins/<id>/octonode.yml\` is generated.\nSet \`scope: ["public"]\` to share publicly. Configure \`OCTONODE_MARKETPLACE_URL\`, run \`octonodes login\`, then \`octonodes plugin publish dist/plugins/${name}\`.\nBuild executes local source; only build trusted projects. Keep secrets out of definitions and assets.\n`);
|
|
66
|
+
return root;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/plugins/create.ts"],"names":[],"mappings":";;AAGA,oCAoFC;AAvFD,qCAAmD;AACnD,yCAA0C;AAE1C,SAAgB,YAAY,CAAC,IAAY,EAAE,OAAe;IACxD,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,MAAM,IAAI,GAAG,IAAA,mBAAO,EAAC,IAAI,CAAC,CAAC;IAC3B,IAAA,mBAAS,EA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IAAI,CAAC,WAAW,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;;;;;;;;;;CAU1D,CACE,CAAC;IACF,IAAA,uBAAa,EACX,IAAA,gBAAI,EAAC,IAAI,EAAE,uBAAuB,CAAC,EACnC;;;;;WAKO,IAAI,CAAC,SAAS,CAAC,gBAAgB,IAAI,EAAE,CAAC;;;;;;CAMhD,CACE,CAAC;IACF,IAAA,uBAAa,EACX,IAAA,gBAAI,EAAC,IAAI,EAAE,WAAW,CAAC,EACvB,KAAK,IAAI,mVAAmV,IAAI,8GAA8G,CAC/c,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAsElF"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PLUGIN_HELP = void 0;
|
|
4
|
+
exports.pluginCommand = pluginCommand;
|
|
5
|
+
const node_child_process_1 = require("node:child_process");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const node_util_1 = require("node:util");
|
|
8
|
+
const auth_1 = require("../auth");
|
|
9
|
+
const artifact_1 = require("./artifact");
|
|
10
|
+
const build_1 = require("./build");
|
|
11
|
+
const create_1 = require("./create");
|
|
12
|
+
const publish_1 = require("./publish");
|
|
13
|
+
var constants_1 = require("./constants");
|
|
14
|
+
Object.defineProperty(exports, "PLUGIN_HELP", { enumerable: true, get: function () { return constants_1.PLUGIN_HELP; } });
|
|
15
|
+
async function pluginCommand(args, version) {
|
|
16
|
+
const command = args[0];
|
|
17
|
+
const { values, positionals } = (0, node_util_1.parseArgs)({
|
|
18
|
+
args: args.slice(1),
|
|
19
|
+
allowPositionals: true,
|
|
20
|
+
options: {
|
|
21
|
+
input: { type: "string" },
|
|
22
|
+
registry: { type: "string" },
|
|
23
|
+
org: { type: "string" },
|
|
24
|
+
team: { type: "string" },
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
const [target, nodeId] = positionals;
|
|
28
|
+
if (positionals.length > (command === "test" ? 2 : 1))
|
|
29
|
+
throw new Error("Too many plugin command arguments");
|
|
30
|
+
if (command === "build") {
|
|
31
|
+
process.stdout.write(JSON.stringify(await (0, build_1.buildPlugins)(target), null, 2) + "\n");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (!target)
|
|
35
|
+
throw new Error(`plugin ${command ?? "command"} requires a target; run octonodes plugin --help`);
|
|
36
|
+
if (command === "create") {
|
|
37
|
+
process.stdout.write(`Created ${(0, create_1.createPlugin)(target, version)}\nNext: npm install, then npm test in that directory.\n`);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const directory = (0, node_path_1.resolve)(target);
|
|
41
|
+
if (command === "validate") {
|
|
42
|
+
process.stdout.write(JSON.stringify((0, artifact_1.verifyBuild)(directory).manifest, null, 2) + "\n");
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
if (command === "test") {
|
|
46
|
+
const { manifest } = (0, artifact_1.verifyBuild)(directory);
|
|
47
|
+
const selected = nodeId ?? (manifest.nodes.length === 1 ? manifest.nodes[0].id : undefined);
|
|
48
|
+
if (!manifest.nodes.some((node) => node.id === selected))
|
|
49
|
+
throw new Error(`Choose a node: ${manifest.nodes.map((node) => node.id).join(", ")}`);
|
|
50
|
+
const output = (0, node_child_process_1.execFileSync)(process.execPath, ["dist/index.js", selected], {
|
|
51
|
+
cwd: directory,
|
|
52
|
+
encoding: "utf8",
|
|
53
|
+
timeout: 30_000,
|
|
54
|
+
input: JSON.stringify({
|
|
55
|
+
octonode: "1",
|
|
56
|
+
type: "invoke",
|
|
57
|
+
invocationId: "plugin-test",
|
|
58
|
+
inputs: JSON.parse(values.input ?? "{}"),
|
|
59
|
+
}) + "\n",
|
|
60
|
+
});
|
|
61
|
+
process.stdout.write(output);
|
|
62
|
+
if (JSON.parse(output).status !== "ok")
|
|
63
|
+
throw new Error("Plugin test failed");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (command === "publish") {
|
|
67
|
+
const registry = values.registry ?? process.env.OCTONODE_MARKETPLACE_URL;
|
|
68
|
+
if (!registry)
|
|
69
|
+
throw new Error("Set OCTONODE_MARKETPLACE_URL or pass --registry <url>");
|
|
70
|
+
const token = process.env.OCTONODE_MARKETPLACE_TOKEN ?? (await (0, auth_1.accessToken)());
|
|
71
|
+
if (!token)
|
|
72
|
+
throw new Error('Run "octonodes login" or set OCTONODE_TOKEN');
|
|
73
|
+
process.stdout.write(JSON.stringify(await (0, publish_1.publishPlugin)(directory, registry, token, values.org, values.team), null, 2) + "\n");
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
throw new Error(`Unknown plugin command: ${command}`);
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":";;;AAWA,sCAsEC;AAjFD,2DAAkD;AAClD,yCAAoC;AACpC,yCAAsC;AACtC,kCAAsC;AACtC,yCAAyC;AACzC,mCAAuC;AACvC,qCAAwC;AACxC,uCAA0C;AAE1C,yCAA0C;AAAjC,wGAAA,WAAW,OAAA;AAEb,KAAK,UAAU,aAAa,CAAC,IAAc,EAAE,OAAe;IACjE,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACxB,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,qBAAS,EAAC;QACxC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CA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,oBAAoB,CAAC,CAAC;QAC9E,OAAO;IACT,CAAC;IACD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC;QACzE,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;QACxF,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,0BAA0B,IAAI,CAAC,MAAM,IAAA,kBAAW,GAAE,CAAC,CAAC;QAC9E,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;QAC3E,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,IAAI,CAAC,SAAS,CACZ,MAAM,IAAA,uBAAa,EAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,EACxE,IAAI,EACJ,CAAC,CACF,GAAG,IAAI,CACT,CAAC;QACF,OAAO;IACT,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,2BAA2B,OAAO,EAAE,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish.d.ts","sourceRoot":"","sources":["../../src/plugins/publish.ts"],"names":[],"mappings":"AAMA,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,OAAO,CAAC,CAmDlB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.publishPlugin = publishPlugin;
|
|
4
|
+
const node_child_process_1 = require("node:child_process");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_os_1 = require("node:os");
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
|
+
const artifact_1 = require("./artifact");
|
|
9
|
+
async function publishPlugin(directory, registry, token, orgId, teamId) {
|
|
10
|
+
const url = new URL(registry);
|
|
11
|
+
if (url.username ||
|
|
12
|
+
url.password ||
|
|
13
|
+
url.search ||
|
|
14
|
+
url.hash ||
|
|
15
|
+
(url.protocol !== "https:" &&
|
|
16
|
+
!(url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname)))) {
|
|
17
|
+
throw new Error("Registry must use HTTPS (HTTP is allowed only on loopback)");
|
|
18
|
+
}
|
|
19
|
+
const temp = (0, node_fs_1.mkdtempSync)((0, node_path_1.join)((0, node_os_1.tmpdir)(), "octonodes-publish-"));
|
|
20
|
+
try {
|
|
21
|
+
const verified = (0, artifact_1.verifyBuild)(directory);
|
|
22
|
+
const snapshot = (0, node_path_1.join)(temp, "plugin");
|
|
23
|
+
(0, node_fs_1.mkdirSync)(snapshot);
|
|
24
|
+
for (const file of verified.files) {
|
|
25
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)((0, node_path_1.join)(snapshot, file)), { recursive: true });
|
|
26
|
+
(0, node_fs_1.cpSync)((0, node_path_1.join)(directory, file), (0, node_path_1.join)(snapshot, file));
|
|
27
|
+
}
|
|
28
|
+
const { manifest, files } = (0, artifact_1.verifyBuild)(snapshot);
|
|
29
|
+
const bundle = (0, node_path_1.join)(temp, "bundle.tar.gz");
|
|
30
|
+
(0, node_child_process_1.execFileSync)("tar", ["-czf", bundle, "-C", snapshot, "--", ...files]);
|
|
31
|
+
const form = new FormData();
|
|
32
|
+
form.set("manifest", JSON.stringify(manifest));
|
|
33
|
+
form.set("bundle", new Blob([(0, node_fs_1.readFileSync)(bundle)], { type: "application/gzip" }), "bundle.tar.gz");
|
|
34
|
+
if (orgId)
|
|
35
|
+
form.set("orgId", orgId);
|
|
36
|
+
if (teamId)
|
|
37
|
+
form.set("teamId", teamId);
|
|
38
|
+
const response = await fetch(`${registry.replace(/\/$/, "")}/marketplace/plugins/${encodeURIComponent(manifest.id)}/versions`, {
|
|
39
|
+
method: "POST",
|
|
40
|
+
headers: { authorization: `Bearer ${token}` },
|
|
41
|
+
body: form,
|
|
42
|
+
redirect: "error",
|
|
43
|
+
signal: AbortSignal.timeout(120_000),
|
|
44
|
+
});
|
|
45
|
+
if (!response.ok)
|
|
46
|
+
throw new Error(`Plugin publish failed (HTTP ${response.status}): ${(await response.text()).slice(0, 1000)}`);
|
|
47
|
+
return response.json();
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
(0, node_fs_1.rmSync)(temp, { recursive: true, force: true });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=publish.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../../src/plugins/publish.ts"],"names":[],"mappings":";;AAMA,sCAyDC;AA/DD,2DAAkD;AAClD,qCAA+E;AAC/E,qCAAiC;AACjC,yCAA0C;AAC1C,yCAAyC;AAElC,KAAK,UAAU,aAAa,CACjC,SAAiB,EACjB,QAAgB,EAChB,KAAa,EACb,KAAc,EACd,MAAe;IAEf,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,IACE,GAAG,CAAC,QAAQ;QACZ,GAAG,CAAC,QAAQ;QACZ,GAAG,CAAC,MAAM;QACV,GAAG,CAAC,IAAI;QACR,CAAC,GAAG,CAAC,QAAQ,KAAK,QAAQ;YACxB,CAAC,CAAC,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAC5F,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAChF,CAAC;IACD,M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AAE,CAAC,EAC9D,eAAe,CAChB,CAAC;QACF,IAAI,KAAK;YAAE,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACpC,IAAI,MAAM;YAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACvC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,wBAAwB,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC,WAAW,EAChG;YACE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE;YAC7C,IAAI,EAAE,IAAI;YACV,QAAQ,EAAE,OAAO;YACjB,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC;SACrC,CACF,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,EAAE;YACd,MAAM,IAAI,KAAK,CACb,+BAA+B,QAAQ,CAAC,MAAM,MAAM,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAC7F,CAAC;QACJ,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;YAAS,CAAC;QACT,IAAA,gBAAM,EAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PluginManifest } from "@octonodes/sdk/plugins";
|
|
2
|
+
export interface PluginBuild {
|
|
3
|
+
manifest: PluginManifest;
|
|
4
|
+
directory: string;
|
|
5
|
+
}
|
|
6
|
+
export interface PluginBuildRecord {
|
|
7
|
+
format: 1;
|
|
8
|
+
files: Record<string, string>;
|
|
9
|
+
ui?: Array<{
|
|
10
|
+
nodeId: string;
|
|
11
|
+
apiVersion: "1";
|
|
12
|
+
renderer: string;
|
|
13
|
+
target: "node.inspector.inputs";
|
|
14
|
+
path: string;
|
|
15
|
+
size: number;
|
|
16
|
+
sha256: string;
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plugins/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,cAAc,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,CAAC,CAAC;IACV,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,EAAE,CAAC,EAAE,KAAK,CAAC;QACT,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,GAAG,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,uBAAuB,CAAC;QAChC,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/plugins/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octonodes/cli",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Octonode API and plugin development CLI.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"
|
|
7
|
-
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/nivdoron1/octonode-devtools.git",
|
|
9
|
+
"directory": "packages/cli"
|
|
10
|
+
},
|
|
8
11
|
"bin": {
|
|
9
12
|
"octonodes": "dist/index.js"
|
|
10
13
|
},
|
|
11
14
|
"files": [
|
|
12
15
|
"dist"
|
|
13
16
|
],
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
"@supabase/supabase-js": "2.107.0"
|
|
17
|
-
},
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"types": "dist/index.d.ts",
|
|
18
19
|
"scripts": {
|
|
19
20
|
"prepack": "tsc -b"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@octonodes/sdk": "0.1.0",
|
|
24
|
+
"@supabase/supabase-js": "2.107.0",
|
|
25
|
+
"esbuild": "0.28.1",
|
|
26
|
+
"yaml": "^2.4.5"
|
|
20
27
|
}
|
|
21
28
|
}
|