@vertesia/create-plugin 0.59.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/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2024 Composable Prompts
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # @vertesia/create-agent
2
+
3
+ This package is scaffolding a vertesia agent project.
4
+ Vertesia agents are used to deploy custom workflows to Vertesia cloud.
5
+
6
+ Visit https://vertesiahq.com for more information about Vertesia.
7
+
8
+ ## Requirements:
9
+ 1. docker (with buildx support) installed locally.
10
+ 2. vertesia CLI application. The CLI will be automatically installed when initializing the agent project if you didn't installed it previously.
11
+
12
+ ## Initialize a Vertesia agent project
13
+
14
+ Run the command line command:
15
+
16
+ ```
17
+ npm init @vertesia/agent
18
+ ```
19
+
20
+ Follow the instructions on screen. You need to define an organization and a name for your agent. The organization must be unique inside Vertesia and is usually the name of your Vertesia organization account. The agent name is identifying the project in your organization.
21
+
22
+ The generated project is a typescript project and is using [Temporal](https://temporal.io/) as the workflow system.
23
+
24
+ You can implement your own workflows and activities anywhere in the src/ directory or even in a dependency project. The only requirement is that you need to export the workflows and the activities from the `src/workflow.ts` and `src/activities.ts` files.
25
+ These generated files are containing a "Hello world!" workflow and activity as an example that you should remove and export your own definitions.
26
+
27
+
28
+ ## Developing your agent workflows / activities.
29
+
30
+ Export your temporal wrofklows `from src/workflows.ts` and your activities from `src/activities.ts`
31
+
32
+ ## Test locally the workflows.
33
+
34
+ There are two ways to test the agent worker:
35
+
36
+ 1. Using `npm start`. This will start the worker in your terminal.
37
+ 2. Using `vertesia agent run` from your project root. This will run the agent worker in side the docker image you previously built. See the [Build](build-the-agent-docker-image) section.
38
+
39
+ **Important Note:** All `vertesia agent` commands must be executed in the agent project root.
40
+
41
+ ## Debugging locally the workflows.
42
+
43
+ You can debug the workflows by replaying them locally using the temporal replayer that you can found in `src/debug-replayer.ts`.
44
+
45
+ See https://docs.temporal.io/develop/typescript/debugging for more information
46
+
47
+ ## Packaging and publishing your Vertesia agent
48
+
49
+ When the workflows are working you will want to publish the agent to Vertesia.
50
+ The agent should be packaged as a docker imageand then published to the Vertesia cloud.
51
+
52
+ ### Build the agent docker image
53
+
54
+ When you are ready to test the agent image you can built it using `vertesia agent build` from you project root.
55
+
56
+ This will build a docker image tagged as `your-organization/your-agent-name:latest`.
57
+ This image is only useable to test locally. You cannot push it to Vertesia.
58
+
59
+ ### Releasing the agent docker image
60
+
61
+ When you aready to push your agent to Vertesia you must first create a version using the following command:
62
+
63
+ ```
64
+ vertesia agent release <version>
65
+ ```
66
+
67
+ The version must be in the `major.minor.patch[-modifier]` format. \
68
+ Examples: `1.0.0`, `1.0.0-rc1`.
69
+
70
+ This command is creating a new docker tag `your-organization/your-agent-name:version` from the `latest` image tag.
71
+
72
+ ### Publishing the agent docker image to Vertesia
73
+
74
+ Versionned images (using the `release` command) can be published to Vertesia. This can be done using the following command:
75
+
76
+ ```
77
+ vertesia agent publish <version>
78
+ ```
79
+
80
+ where the version is the version of the image tag you want to publish.
81
+
82
+ You can also only push the image to vertesia without deploying the agent by using the `--push-only` flag:
83
+
84
+ ```
85
+ vertesia agent publish <version> --push-only
86
+ ```
87
+
88
+ The you can deploy an agent that you previously uploaded to Vertesia by using the command:
89
+
90
+ ```
91
+ vertesia agent publish <version> --deploy-only
92
+ ```
93
+
94
+ ## Manaing agent versions
95
+
96
+ You can see the docker image versions you created using the following command:
97
+
98
+ ```
99
+ vertesia agent versions
100
+ ```
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import "../lib/main.js"
@@ -0,0 +1,43 @@
1
+ interface PackageJson {
2
+ name: string;
3
+ version: string;
4
+ description: string;
5
+ type: string;
6
+ types: string;
7
+ main: string;
8
+ files?: string[];
9
+ module?: string;
10
+ license?: string;
11
+ dependencies?: Record<string, string>;
12
+ devDependencies?: Record<string, string>;
13
+ peerDependencies?: Record<string, string>;
14
+ optionalDependencies?: Record<string, string>;
15
+ scripts?: Record<string, string>;
16
+ bin?: Record<string, string>;
17
+ plugin?: {
18
+ title?: string;
19
+ icon?: string;
20
+ publisher?: string;
21
+ external?: boolean;
22
+ status?: "beta" | "stable" | "deprecated" | "hidden";
23
+ };
24
+ }
25
+ export declare class Package {
26
+ data: PackageJson;
27
+ file?: string | undefined;
28
+ constructor(data: PackageJson, file?: string | undefined);
29
+ static fromFile(file: string): Package;
30
+ get name(): string;
31
+ set name(name: string);
32
+ get version(): string;
33
+ set version(version: string);
34
+ get description(): string;
35
+ set description(description: string);
36
+ get scripts(): Record<string, string>;
37
+ set scripts(scripts: Record<string, string>);
38
+ save(): void;
39
+ saveTo(file: string): void;
40
+ toJson(): PackageJson;
41
+ }
42
+ export {};
43
+ //# sourceMappingURL=Package.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Package.d.ts","sourceRoot":"","sources":["../src/Package.ts"],"names":[],"mappings":"AAEA,UAAU,WAAW;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe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AAI,WAAW;CAGxB"}
package/lib/Package.js ADDED
@@ -0,0 +1,52 @@
1
+ import fs from "fs";
2
+ export class Package {
3
+ data;
4
+ file;
5
+ constructor(data, file) {
6
+ this.data = data;
7
+ this.file = file;
8
+ }
9
+ static fromFile(file) {
10
+ const content = fs.readFileSync(file, "utf8");
11
+ return new Package(JSON.parse(content), file);
12
+ }
13
+ get name() {
14
+ return this.data.name;
15
+ }
16
+ set name(name) {
17
+ this.data.name = name;
18
+ }
19
+ get version() {
20
+ return this.data.version;
21
+ }
22
+ set version(version) {
23
+ this.data.version = version;
24
+ }
25
+ get description() {
26
+ return this.data.description;
27
+ }
28
+ set description(description) {
29
+ this.data.description = description;
30
+ }
31
+ get scripts() {
32
+ if (!this.data.scripts)
33
+ this.data.scripts = {};
34
+ return this.data.scripts;
35
+ }
36
+ set scripts(scripts) {
37
+ this.data.scripts = scripts;
38
+ }
39
+ save() {
40
+ if (!this.file)
41
+ throw new Error("File not specified, Use saveTo");
42
+ fs.writeFileSync(this.file, JSON.stringify(this.data, undefined, 2), "utf8");
43
+ }
44
+ saveTo(file) {
45
+ this.file = file;
46
+ this.save();
47
+ }
48
+ toJson() {
49
+ return { ...this.data };
50
+ }
51
+ }
52
+ //# sourceMappingURL=Package.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Package.js","sourceRoot":"","sources":["../src/Package.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AA4BpB,MAAM,OAAO,OAAO;IACG;IAA0B;IAA7C,YAAmB,IAAiB,EAAS,IAAa;QAAvC,SAAI,GAAJ,IAAI,CAAa;QAAS,SAAI,GAAJ,IAAI,CAAS;IAC1D,CAAC;IACD,MAAM,CAAC,QAAQ,CAAC,IAAY;QACxB,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC9C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EA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AG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,CAAC;CACJ"}
package/lib/copy.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Recursively copies the contents of a source directory to a target directory using the most optimized method.
3
+ *
4
+ * @param sourceDir - The path to the source directory.
5
+ * @param targetDir - The path to the target directory.
6
+ * @param templateSuffix - Optional suffix to remvoe from file name after copying. Ex: .template, .tmpl
7
+ */
8
+ export declare function copyTree(sourceDir: string, targetDir: string, template?: {
9
+ suffix?: string;
10
+ context: Record<string, any>;
11
+ }): Promise<void>;
12
+ //# sourceMappingURL=copy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy.d.ts","sourceRoot":"","sources":["../src/copy.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE;IAC5E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC/B,GAAG,OAAO,CAAC,IAAI,CAAC,CAkChB"}
package/lib/copy.js ADDED
@@ -0,0 +1,41 @@
1
+ import { promises as fs } from "fs";
2
+ import { join } from "path";
3
+ import { processVarsInFile } from "./template.js";
4
+ /**
5
+ * Recursively copies the contents of a source directory to a target directory using the most optimized method.
6
+ *
7
+ * @param sourceDir - The path to the source directory.
8
+ * @param targetDir - The path to the target directory.
9
+ * @param templateSuffix - Optional suffix to remvoe from file name after copying. Ex: .template, .tmpl
10
+ */
11
+ export async function copyTree(sourceDir, targetDir, template) {
12
+ // Optimize by using a queue to avoid deep recursion and potential stack overflows
13
+ const queue = [{ source: sourceDir, target: targetDir }];
14
+ while (queue.length > 0) {
15
+ const { source, target } = queue.pop();
16
+ // Ensure the target directory exists
17
+ await fs.mkdir(target, { recursive: true });
18
+ // Read all items in the source directory
19
+ const items = await fs.readdir(source, { withFileTypes: true });
20
+ for (const item of items) {
21
+ const isTemplate = template?.suffix ? item.name.endsWith(template.suffix) : false;
22
+ const targetName = isTemplate ? item.name.slice(0, -template.suffix.length) : item.name;
23
+ const sourcePath = join(source, item.name);
24
+ const targetPath = join(target, targetName);
25
+ console.log('Generating', targetPath);
26
+ if (item.isDirectory()) {
27
+ // Queue subdirectory for processing
28
+ queue.push({ source: sourcePath, target: targetPath });
29
+ }
30
+ else if (item.isFile() || item.isSymbolicLink()) {
31
+ // Copy file or symbolic link
32
+ await fs.copyFile(sourcePath, targetPath);
33
+ if (isTemplate) {
34
+ // Process template if applicable
35
+ processVarsInFile(targetPath, template.context);
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
41
+ //# sourceMappingURL=copy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"copy.js","sourceRoot":"","sources":["../src/copy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,SAAiB,EAAE,SAAiB,EAAE,QAGpE;IACG,kFAAkF;IAClF,MAAM,KAAK,GAAyC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IAE/F,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,GAAG,EAAG,CAAC;QAExC,qCAAqC;QACrC,MAAM,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAE5C,yCAAyC;QACzC,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,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MappingURL=deps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deps.d.ts","sourceRoot":"","sources":["../src/deps.ts"],"names":[],"mappings":"AA+CA,wBAAgB,WAAW,CAAC,EAAE,EAAE,KAAK,GAAG,MAAM,QAI7C"}
package/lib/deps.js ADDED
@@ -0,0 +1,49 @@
1
+ import { runCommand } from "./utils.js";
2
+ const DEV_DEPS = [
3
+ "@vertesia/plugin-builder",
4
+ "@vertesia/ui",
5
+ "@eslint/js",
6
+ "@tailwindcss/vite",
7
+ "@types/node",
8
+ "@types/react",
9
+ "@types/react-dom",
10
+ "@vitejs/plugin-react",
11
+ "eslint",
12
+ "eslint-plugin-react-hooks",
13
+ "eslint-plugin-react-refresh",
14
+ "globals",
15
+ "react",
16
+ "react-dom",
17
+ "tailwindcss",
18
+ "typescript",
19
+ "typescript-eslint",
20
+ "vite",
21
+ "vite-plugin-dts",
22
+ ];
23
+ const RUNTIME_DEPS = [
24
+ "@vertesia/ui",
25
+ ];
26
+ function addDevDependencies(pm, deps) {
27
+ _addDependencies(pm, deps, "dev");
28
+ }
29
+ function addRuntimeDependencies(pm, deps) {
30
+ _addDependencies(pm, deps, "runtime");
31
+ }
32
+ function _addDependencies(pm, deps, type = "runtime") {
33
+ const args = [
34
+ pm === "pnpm" ? "add" : "install"
35
+ ];
36
+ if (type === "dev") {
37
+ args.push('-D');
38
+ }
39
+ for (const dep of deps) {
40
+ args.push(dep);
41
+ }
42
+ runCommand(pm, args);
43
+ }
44
+ export function installDeps(pm) {
45
+ console.log("Installing dependencies");
46
+ addDevDependencies(pm, DEV_DEPS);
47
+ addRuntimeDependencies(pm, RUNTIME_DEPS);
48
+ }
49
+ //# sourceMappingURL=deps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deps.js","sourceRoot":"","sources":["../src/deps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,QAAQ,GAAa;IACvB,0BAA0B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 //# sourceMappingURL=hasBin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasBin.d.ts","sourceRoot":"","sources":["../src/hasBin.ts"],"names":[],"mappings":"AAEA,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAUrD"}
package/lib/hasBin.js ADDED
@@ -0,0 +1,14 @@
1
+ import hasbin from "hasbin";
2
+ export function hasBin(name) {
3
+ return new Promise((resolve, reject) => {
4
+ try {
5
+ hasbin(name, (result) => {
6
+ resolve(result);
7
+ });
8
+ }
9
+ catch (err) {
10
+ reject(err);
11
+ }
12
+ });
13
+ }
14
+ //# sourceMappingURL=hasBin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasBin.js","sourceRoot":"","sources":["../src/hasBin.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,UAAU,MAAM,CAAC,IAAY;IAC/B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,IAAI,CAAC;YACD,MAAM,CAAC,IAAI,EAAE,CAAC,MAAe,EAAE,EAAE;gBAC7B,OAAO,CAAC,MAAM,CAAC,CAAC;YACpB,CAAC,CAAC,CAAC;QACP,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAChB,MAAM,CAAC,GAAG,CAAC,CAAA;QACf,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
package/lib/init.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare function init(dirName?: string | undefined): Promise<void>;
2
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAYA,wBAAsB,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,iBA2HtD"}
package/lib/init.js ADDED
@@ -0,0 +1,161 @@
1
+ import enquirer from "enquirer";
2
+ import { mkdirSync } from "node:fs";
3
+ import { join, resolve } from "node:path";
4
+ import { chdir } from "node:process";
5
+ import { fileURLToPath } from "node:url";
6
+ import { copyTree } from "./copy.js";
7
+ import { installDeps } from "./deps.js";
8
+ import { hasBin } from "./hasBin.js";
9
+ import { Package } from "./Package.js";
10
+ const { prompt } = enquirer;
11
+ export async function init(dirName) {
12
+ let initialPm = "npm";
13
+ const currentPmPath = process.env.npm_execpath;
14
+ if (!currentPmPath) {
15
+ initialPm = await hasBin("pnpm") ? "pnpm" : "npm";
16
+ }
17
+ else if (currentPmPath.endsWith("pnpm")) {
18
+ initialPm = "pnpm";
19
+ }
20
+ else if (currentPmPath.endsWith("yarn")) {
21
+ initialPm = "yarn";
22
+ }
23
+ const pms = ["npm", "pnpm"];
24
+ const answer = await prompt([{
25
+ name: 'pm',
26
+ type: 'select',
27
+ message: "Which package manager to use?",
28
+ initial: pms.indexOf(initialPm),
29
+ choices: pms,
30
+ }, {
31
+ name: 'plugin_name',
32
+ type: 'input',
33
+ message: "Plugin name (use kebab case, e.g. my-plugin)",
34
+ required: true,
35
+ validate: (input) => /[a-zA-Z_](-[a-zA-Z_0-9]+)*/g.test(input),
36
+ }, {
37
+ name: 'plugin_version',
38
+ type: 'input',
39
+ message: "PLugin version",
40
+ initial: '1.0.0',
41
+ required: true,
42
+ validate: (input) => /[\d]\.[\d].[\d](-[a-zA-Z0-9_]+)?/g.test(input),
43
+ }, {
44
+ name: 'plugin_description',
45
+ type: 'input',
46
+ required: false,
47
+ message: "Package description",
48
+ initial: '',
49
+ },
50
+ //TODO
51
+ // {
52
+ // name: 'template',
53
+ // type: 'select',
54
+ // message: "Template to use",
55
+ // initial: 0,
56
+ // choices: [
57
+ // { message: 'Web plugin', name: 'web' },
58
+ // { message: 'Agent tool', name: 'tool' },
59
+ // { message: 'Workflow Acitity', name: 'activity' },
60
+ // ]
61
+ // },
62
+ ]);
63
+ //TODO remove this
64
+ answer.template = 'web';
65
+ const cmd = answer.pm;
66
+ const pluginName = new PluginName(answer.plugin_name);
67
+ let dir;
68
+ if (!dirName) {
69
+ dirName = answer.plugin_name;
70
+ dir = join(process.cwd(), dirName);
71
+ }
72
+ else {
73
+ dir = resolve(dirName);
74
+ }
75
+ mkdirSync(dir, { recursive: true });
76
+ chdir(dir);
77
+ const PluginComponent = pluginName.pascalCase + "Plugin";
78
+ const templateProps = {
79
+ suffix: '.tmpl',
80
+ context: {
81
+ plugin_title: pluginName.title,
82
+ PluginComponent,
83
+ }
84
+ };
85
+ // copy template to current directory and process template files
86
+ const templsDir = resolve(fileURLToPath(import.meta.url), '../../templates');
87
+ if (answer.template === 'web') {
88
+ await copyTree(join(templsDir, "web"), dir, templateProps);
89
+ }
90
+ else if (answer.template === 'tool') {
91
+ }
92
+ else if (answer.template === 'activity') {
93
+ }
94
+ else {
95
+ throw new Error("Invalid template type");
96
+ }
97
+ console.log("Generating package.json");
98
+ const pkg = new Package({
99
+ name: answer.plugin_name,
100
+ version: answer.plugion_version || '1.0.0',
101
+ description: answer.description || '',
102
+ type: 'module',
103
+ main: `dist/${answer.plugin_name}.js`,
104
+ module: `dist/${answer.plugin_name}.js`,
105
+ types: "dist/index.d.ts",
106
+ files: [
107
+ "dist"
108
+ ],
109
+ scripts: {
110
+ "dev": "vite",
111
+ "build": "vite build",
112
+ "lint": "eslint .",
113
+ "preview": "vite preview"
114
+ },
115
+ peerDependencies: {
116
+ "react": "^19.0.0",
117
+ "react-dom": "^19.0.0"
118
+ },
119
+ plugin: {
120
+ title: pluginName.title,
121
+ publisher: pluginName.scope || "vertesia",
122
+ external: false,
123
+ status: "beta",
124
+ }
125
+ });
126
+ pkg.saveTo(`${dir}/package.json`);
127
+ installDeps(cmd);
128
+ }
129
+ class PluginName {
130
+ value;
131
+ scope;
132
+ name;
133
+ _title;
134
+ constructor(value) {
135
+ this.value = value;
136
+ if (value.startsWith('@')) {
137
+ const index = value.indexOf('/');
138
+ if (index > -1) {
139
+ this.name = value.substring(index + 1);
140
+ this.scope = value.substring(1, index);
141
+ }
142
+ else {
143
+ throw new Error("Invalid plugin name");
144
+ }
145
+ }
146
+ else {
147
+ this.name = value;
148
+ this.scope = undefined;
149
+ }
150
+ }
151
+ get title() {
152
+ if (!this._title) {
153
+ this._title = this.name.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' ');
154
+ }
155
+ return this._title;
156
+ }
157
+ get pascalCase() {
158
+ return this.name.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join('');
159
+ }
160
+ }
161
+ //# sourceMappingURL=init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC;AAE5B,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,OAA4B;IAEnD,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;IAC/C,IAAI,CAAC,aAAa,EAAE,CAAC;QACjB,SAAS,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;IACtD,CAAC;SAAM,IAAI,aAAa,CA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,CAAC,CAAC;gBACvC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;YAC3C,CAAC;iBAAM,CAAC;gBACJ,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;YAC3C,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;YAClB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAA;QAC1B,CAAC;IACL,CAAC;IACD,IAAI,KAAK;QACL,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACf,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC3G,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IACD,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACnG,CAAC;CACJ"}
package/lib/main.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=main.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":""}
package/lib/main.js ADDED
@@ -0,0 +1,8 @@
1
+ import { init } from "./init.js";
2
+ async function main(argv) {
3
+ await init(argv[2]);
4
+ }
5
+ main(process.argv).catch(err => {
6
+ console.error("Error: ", err);
7
+ });
8
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,KAAK,UAAU,IAAI,CAAC,IAAc;IAC9B,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;AACvB,CAAC;AAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;IAC3B,OAAO,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;AAClC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare function expandVars(content: string, vars: Record<string, string>): string;
2
+ export declare function processVarsInFile(file: string, vars: Record<string, string>): void;
3
+ export declare function processAndRenameTemplateFile(file: string, vars: Record<string, string>): void;
4
+ //# sourceMappingURL=template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../src/template.ts"],"names":[],"mappings":"AAKA,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,UAEvE;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAG3E;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAKtF"}
@@ -0,0 +1,16 @@
1
+ import { readFileSync, renameSync, writeFileSync } from "fs";
2
+ const VAR_RX = /\$\{\s*([a-zA-Z_$][a-zA-Z_$0-9]*)\s*\}/g;
3
+ export function expandVars(content, vars) {
4
+ return content.replaceAll(VAR_RX, (m, p) => p in vars ? vars[p] : m);
5
+ }
6
+ export function processVarsInFile(file, vars) {
7
+ const content = readFileSync(file, "utf8");
8
+ writeFileSync(file, expandVars(content, vars), "utf8");
9
+ }
10
+ export function processAndRenameTemplateFile(file, vars) {
11
+ processVarsInFile(file, vars);
12
+ if (file.endsWith(".template")) {
13
+ renameSync(file, file.slice(0, -".template".length));
14
+ }
15
+ }
16
+ //# sourceMappingURL=template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.js","sourceRoot":"","sources":["../src/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAE7D,MAAM,MAAM,GAAG,yCAAyC,CAAC;AAGzD,MAAM,UAAU,UAAU,CAAC,OAAe,EAAE,IAA4B;IACpE,OAAO,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACzF,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,IAA4B;IACxE,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC3C,aAAa,CAAC,IAAI,EAAE,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,4BAA4B,CAAC,IAAY,EAAE,IAA4B;IACnF,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC9B,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QAC7B,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAA;IACxD,CAAC;AACL,CAAC"}
package/lib/utils.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare function runCommand(cmd: string, args: string[]): void;
2
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAIrD"}
package/lib/utils.js ADDED
@@ -0,0 +1,7 @@
1
+ import { spawnSync } from "node:child_process";
2
+ export function runCommand(cmd, args) {
3
+ spawnSync(cmd, args, {
4
+ stdio: 'inherit'
5
+ });
6
+ }
7
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,IAAc;IAClD,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE;QACjB,KAAK,EAAE,SAAS;KACnB,CAAC,CAAC;AACP,CAAC"}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@vertesia/create-plugin",
3
+ "version": "0.59.0",
4
+ "description": "Initialize a Vertesia plugin package",
5
+ "type": "module",
6
+ "bin": {
7
+ "create-plugin": "./bin/create-plugin.mjs"
8
+ },
9
+ "main": "./lib/main.js",
10
+ "types": "./lib/main.d.ts",
11
+ "files": [
12
+ "lib",
13
+ "template",
14
+ "bin"
15
+ ],
16
+ "license": "Apache-2.0",
17
+ "homepage": "https://docs.vertesiahq.com/",
18
+ "keywords": [
19
+ "vertesia",
20
+ "ui",
21
+ "plugin"
22
+ ],
23
+ "dependencies": {
24
+ "enquirer": "^2.4.1",
25
+ "hasbin": "^1.2.3"
26
+ },
27
+ "devDependencies": {
28
+ "@types/hasbin": "^1.2.2",
29
+ "@types/node": "^22.5.0",
30
+ "typescript": "^5.7.2"
31
+ },
32
+ "scripts": {
33
+ "eslint": "eslint './src/**/*.{jsx,js,tsx,ts}'",
34
+ "build": "rm -rf ./lib ./tsconfig.tsbuildinfo && tsc --build",
35
+ "clean": "rimraf ./node_modules ./lib ./tsconfig.tsbuildinfo"
36
+ }
37
+ }