diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index b66932cc..4915ddb8 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -13,6 +13,7 @@ jobs: env: CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + # TODO: Template API credentials steps: - uses: actions/checkout@v4 - name: Use Node.js @@ -22,3 +23,4 @@ jobs: - run: npm ci - run: npm run check:ci - run: npm run deploy + - run: npm run upload diff --git a/cli/README.md b/cli/README.md new file mode 100644 index 00000000..dde133c3 --- /dev/null +++ b/cli/README.md @@ -0,0 +1,3 @@ +# Templates CLI + +TODO diff --git a/cli/build.mjs b/cli/build.mjs new file mode 100644 index 00000000..861b176e --- /dev/null +++ b/cli/build.mjs @@ -0,0 +1,15 @@ +import PACKAGE from "./package.json" assert { type: "json" }; +import * as esbuild from "esbuild"; +import fs from "node:fs"; + +const outfile = PACKAGE["bin"]; + +await esbuild.build({ + entryPoints: ["src/index.ts"], + bundle: true, + sourcemap: true, + platform: "node", + outfile, +}); + +fs.writeFileSync(outfile, "#!/usr/bin/env node\n" + fs.readFileSync(outfile)); diff --git a/cli/package.json b/cli/package.json new file mode 100644 index 00000000..2b8f3ddf --- /dev/null +++ b/cli/package.json @@ -0,0 +1,17 @@ +{ + "name": "cli", + "description": "A handy CLI for developing templates.", + "bin": "out/cli.js", + "dependencies": { + "commander": "12.1.0" + }, + "devDependencies": { + "@types/node": "22.9.1", + "esbuild": "0.24.0", + "typescript": "5.6.3" + }, + "scripts": { + "build": "node build.mjs", + "check": "tsc" + } +} diff --git a/cli/src/index.ts b/cli/src/index.ts new file mode 100644 index 00000000..d4215b80 --- /dev/null +++ b/cli/src/index.ts @@ -0,0 +1,19 @@ +import { Command } from "commander"; +import { upload } from "./upload"; + +const program = new Command(); + +program.name("cli").description("A handy CLI for developing templates."); + +program + .command("upload") + .argument( + "[path-to-templates]", + "path to directory containing templates", + ".", + ) + .action((templateDirectory) => + upload({ templateDirectory, apiBaseUrl: "TODO" }), + ); + +program.parse(); diff --git a/cli/src/upload.ts b/cli/src/upload.ts new file mode 100644 index 00000000..3f8b7d17 --- /dev/null +++ b/cli/src/upload.ts @@ -0,0 +1,72 @@ +import fs from "node:fs"; +import path from "node:path"; +import subprocess from "node:child_process"; + +const TEMPLATE_DIRECTORY_SUFFIX = "-template"; + +export type UploadConfig = { + templateDirectory: string; + apiBaseUrl: string; +}; + +export async function upload(config: UploadConfig) { + const templatePaths = fs + .readdirSync(config.templateDirectory) + .filter( + (file) => + file.endsWith(TEMPLATE_DIRECTORY_SUFFIX) && + fs.statSync(file).isDirectory(), + ) + .map((template) => path.join(config.templateDirectory, template)); + const results = await Promise.allSettled( + templatePaths.map((templatePath) => uploadTemplate(templatePath, config)), + ); + results.forEach((result, i) => { + if (result.status === "rejected") { + console.error(`Upload ${templatePaths[i]} failed: ${result.reason}`); + } + }); +} + +export async function uploadTemplate( + templatePath: string, + config: UploadConfig, +) { + const files = collectTemplateFiles(templatePath); + console.info(`Uploading ${templatePath}:`); + const body = new FormData(); + files.forEach((file) => { + console.info(` ${file.name}`); + body.set(file.name, file); + }); + const url = `${config.apiBaseUrl}/upload/path`; + const response = await fetch(url, { method: "POST", body }); + if (!response.ok) { + throw new Error( + `Error response from ${url} (${response.status}): ${await response.text()}`, + ); + } +} + +function collectTemplateFiles(templatePath: string): File[] { + return fs + .readdirSync(templatePath, { recursive: true }) + .map((file) => ({ + name: file.toString(), + filePath: path.join(templatePath, file.toString()), + })) + .filter( + ({ filePath }) => + !fs.statSync(filePath).isDirectory() && !gitIgnored(filePath), + ) + .map(({ name, filePath }) => new File([fs.readFileSync(filePath)], name)); +} + +function gitIgnored(filePath: string): boolean { + try { + subprocess.execSync(`git check-ignore ${filePath}`); + return true; + } catch { + return false; + } +} diff --git a/cli/tsconfig.json b/cli/tsconfig.json new file mode 100644 index 00000000..da2b35c3 --- /dev/null +++ b/cli/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "target": "esnext", + "lib": ["esnext"], + "module": "nodenext", + "types": ["@types/node"], + "noEmit": true, + "isolatedModules": true, + "forceConsistentCasingInFileNames": true, + "skipLibCheck": true, + "strict": true + }, + "include": ["src"] +} diff --git a/package-lock.json b/package-lock.json index f59d6708..0f25dbfc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,33 +6,439 @@ "": { "name": "templates", "workspaces": [ - "./*-template" + "./*-template", + "./cli" ], "devDependencies": { - "prettier": "^3.3.3", - "syncpack": "^13.0.0", - "turbo": "^2.3.0" + "cli": "workspace:*", + "prettier": "3.3.3", + "syncpack": "13.0.0", + "turbo": "2.3.0" + } + }, + "cli": { + "dependencies": { + "commander": "^12.1.0" + }, + "bin": { + "cli": "out/cli.js" + }, + "devDependencies": { + "@types/node": "^22.9.1", + "esbuild": "0.24.0", + "typescript": "5.6.3" + } + }, + "cli/node_modules/@esbuild/android-arm": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.24.0.tgz", + "integrity": "sha512-arAtTPo76fJ/ICkXWetLCc9EwEHKaeya4vMrReVlEIUCAUncH7M4bhMQ+M9Vf+FFOZJdTNMXNBrWwW+OXWpSew==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/@esbuild/android-arm64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.24.0.tgz", + "integrity": "sha512-Vsm497xFM7tTIPYK9bNTYJyF/lsP590Qc1WxJdlB6ljCbdZKU9SY8i7+Iin4kyhV/KV5J2rOKsBQbB77Ab7L/w==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/@esbuild/android-x64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.24.0.tgz", + "integrity": "sha512-t8GrvnFkiIY7pa7mMgJd7p8p8qqYIz1NYiAoKc75Zyv73L3DZW++oYMSHPRarcotTKuSs6m3hTOa5CKHaS02TQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/@esbuild/darwin-arm64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.24.0.tgz", + "integrity": "sha512-CKyDpRbK1hXwv79soeTJNHb5EiG6ct3efd/FTPdzOWdbZZfGhpbcqIpiD0+vwmpu0wTIL97ZRPZu8vUt46nBSw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/@esbuild/darwin-x64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.24.0.tgz", + "integrity": "sha512-rgtz6flkVkh58od4PwTRqxbKH9cOjaXCMZgWD905JOzjFKW+7EiUObfd/Kav+A6Gyud6WZk9w+xu6QLytdi2OA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/@esbuild/freebsd-arm64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.24.0.tgz", + "integrity": "sha512-6Mtdq5nHggwfDNLAHkPlyLBpE5L6hwsuXZX8XNmHno9JuL2+bg2BX5tRkwjyfn6sKbxZTq68suOjgWqCicvPXA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/@esbuild/freebsd-x64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.24.0.tgz", + "integrity": "sha512-D3H+xh3/zphoX8ck4S2RxKR6gHlHDXXzOf6f/9dbFt/NRBDIE33+cVa49Kil4WUjxMGW0ZIYBYtaGCa2+OsQwQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/@esbuild/linux-arm": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.24.0.tgz", + "integrity": "sha512-gJKIi2IjRo5G6Glxb8d3DzYXlxdEj2NlkixPsqePSZMhLudqPhtZ4BUrpIuTjJYXxvF9njql+vRjB2oaC9XpBw==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/@esbuild/linux-arm64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.24.0.tgz", + "integrity": "sha512-TDijPXTOeE3eaMkRYpcy3LarIg13dS9wWHRdwYRnzlwlA370rNdZqbcp0WTyyV/k2zSxfko52+C7jU5F9Tfj1g==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/@esbuild/linux-ia32": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.24.0.tgz", + "integrity": "sha512-K40ip1LAcA0byL05TbCQ4yJ4swvnbzHscRmUilrmP9Am7//0UjPreh4lpYzvThT2Quw66MhjG//20mrufm40mA==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/@esbuild/linux-loong64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.24.0.tgz", + "integrity": "sha512-0mswrYP/9ai+CU0BzBfPMZ8RVm3RGAN/lmOMgW4aFUSOQBjA31UP8Mr6DDhWSuMwj7jaWOT0p0WoZ6jeHhrD7g==", + "cpu": [ + "loong64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/@esbuild/linux-mips64el": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.24.0.tgz", + "integrity": "sha512-hIKvXm0/3w/5+RDtCJeXqMZGkI2s4oMUGj3/jM0QzhgIASWrGO5/RlzAzm5nNh/awHE0A19h/CvHQe6FaBNrRA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/@esbuild/linux-ppc64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.24.0.tgz", + "integrity": "sha512-HcZh5BNq0aC52UoocJxaKORfFODWXZxtBaaZNuN3PUX3MoDsChsZqopzi5UupRhPHSEHotoiptqikjN/B77mYQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/@esbuild/linux-riscv64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.24.0.tgz", + "integrity": "sha512-bEh7dMn/h3QxeR2KTy1DUszQjUrIHPZKyO6aN1X4BCnhfYhuQqedHaa5MxSQA/06j3GpiIlFGSsy1c7Gf9padw==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/@esbuild/linux-s390x": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.24.0.tgz", + "integrity": "sha512-ZcQ6+qRkw1UcZGPyrCiHHkmBaj9SiCD8Oqd556HldP+QlpUIe2Wgn3ehQGVoPOvZvtHm8HPx+bH20c9pvbkX3g==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/@esbuild/linux-x64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.24.0.tgz", + "integrity": "sha512-vbutsFqQ+foy3wSSbmjBXXIJ6PL3scghJoM8zCL142cGaZKAdCZHyf+Bpu/MmX9zT9Q0zFBVKb36Ma5Fzfa8xA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/@esbuild/netbsd-x64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.24.0.tgz", + "integrity": "sha512-hjQ0R/ulkO8fCYFsG0FZoH+pWgTTDreqpqY7UnQntnaKv95uP5iW3+dChxnx7C3trQQU40S+OgWhUVwCjVFLvg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/@esbuild/openbsd-x64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.24.0.tgz", + "integrity": "sha512-4ir0aY1NGUhIC1hdoCzr1+5b43mw99uNwVzhIq1OY3QcEwPDO3B7WNXBzaKY5Nsf1+N11i1eOfFcq+D/gOS15Q==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/@esbuild/sunos-x64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.24.0.tgz", + "integrity": "sha512-jVzdzsbM5xrotH+W5f1s+JtUy1UWgjU0Cf4wMvffTB8m6wP5/kx0KiaLHlbJO+dMgtxKV8RQ/JvtlFcdZ1zCPA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/@esbuild/win32-arm64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.24.0.tgz", + "integrity": "sha512-iKc8GAslzRpBytO2/aN3d2yb2z8XTVfNV0PjGlCxKo5SgWmNXx82I/Q3aG1tFfS+A2igVCY97TJ8tnYwpUWLCA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/@esbuild/win32-ia32": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.24.0.tgz", + "integrity": "sha512-vQW36KZolfIudCcTnaTpmLQ24Ha1RjygBo39/aLkM2kmjkWmZGEJ5Gn9l5/7tzXA42QGIoWbICfg6KLLkIw6yw==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/@esbuild/win32-x64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.24.0.tgz", + "integrity": "sha512-7IAFPrjSQIJrGsK6flwg7NFmwBoSTyF3rl7If0hNUFQU4ilTsEPL6GuMuU9BfIWVVGuRnuIidkSMC+c0Otu8IA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "cli/node_modules/esbuild": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.24.0.tgz", + "integrity": "sha512-FuLPevChGDshgSicjisSooU0cemp/sGXR841D5LHMB7mTVOmsEHcAxaH3irL53+8YDIeVNQEySh4DaYU/iuPqQ==", + "dev": true, + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.24.0", + "@esbuild/android-arm": "0.24.0", + "@esbuild/android-arm64": "0.24.0", + "@esbuild/android-x64": "0.24.0", + "@esbuild/darwin-arm64": "0.24.0", + "@esbuild/darwin-x64": "0.24.0", + "@esbuild/freebsd-arm64": "0.24.0", + "@esbuild/freebsd-x64": "0.24.0", + "@esbuild/linux-arm": "0.24.0", + "@esbuild/linux-arm64": "0.24.0", + "@esbuild/linux-ia32": "0.24.0", + "@esbuild/linux-loong64": "0.24.0", + "@esbuild/linux-mips64el": "0.24.0", + "@esbuild/linux-ppc64": "0.24.0", + "@esbuild/linux-riscv64": "0.24.0", + "@esbuild/linux-s390x": "0.24.0", + "@esbuild/linux-x64": "0.24.0", + "@esbuild/netbsd-x64": "0.24.0", + "@esbuild/openbsd-arm64": "0.24.0", + "@esbuild/openbsd-x64": "0.24.0", + "@esbuild/sunos-x64": "0.24.0", + "@esbuild/win32-arm64": "0.24.0", + "@esbuild/win32-ia32": "0.24.0", + "@esbuild/win32-x64": "0.24.0" } }, "d1-template": { "devDependencies": { - "@cloudflare/workers-types": "^4.20241112.0", - "typescript": "^5.6.3", - "wrangler": "^3.87.0" + "@cloudflare/workers-types": "4.20241112.0", + "typescript": "5.6.3", + "wrangler": "3.87.0" } }, "image-classification-template": { "devDependencies": { - "@cloudflare/workers-types": "^4.20241112.0", - "typescript": "^5.6.3", - "wrangler": "^3.87.0" + "@cloudflare/workers-types": "4.20241112.0", + "typescript": "5.6.3", + "wrangler": "3.87.0" } }, "llm-template": { "devDependencies": { - "@cloudflare/workers-types": "^4.20241112.0", - "typescript": "^5.6.3", - "wrangler": "^3.87.0" + "@cloudflare/workers-types": "4.20241112.0", + "typescript": "5.6.3", + "wrangler": "3.87.0" } }, "node_modules/@babel/code-frame": { @@ -215,6 +621,22 @@ "esbuild": "*" } }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.24.0.tgz", + "integrity": "sha512-WtKdFM7ls47zkKHFVzMz8opM7LkcsIp9amDUBIAWirg70RM71WRSjdILPsY5Uv1D42ZpUfaPILDlfactHgsRkw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, "node_modules/@esbuild/android-arm": { "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.19.tgz", @@ -487,6 +909,22 @@ "node": ">=12" } }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.24.0", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.24.0.tgz", + "integrity": "sha512-MD9uzzkPQbYehwcN583yx3Tu5M8EIoTD+tUgKF982WYL9Pf5rKy9ltgD0eUgs8pvKnmizxjXZyLt0z6DC3rRXg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, "node_modules/@esbuild/openbsd-x64": { "version": "0.17.19", "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.19.tgz", @@ -649,9 +1087,9 @@ } }, "node_modules/@types/node": { - "version": "22.9.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.9.0.tgz", - "integrity": "sha512-vuyHg81vvWA1Z1ELfvLko2c8f34gyA0zaic0+Rllc5lbCnbSyuvb2Oxpm6TAUAC/2xZN3QGqxBNggD1nNR2AfQ==", + "version": "22.9.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.9.1.tgz", + "integrity": "sha512-p8Yy/8sw1caA8CdRIQBG5tiLHmxtQKObCijiAa9Ez+d4+PRffM4054xbju0msf+cvhJpnFEeNjxmVT/0ipktrg==", "dev": true, "dependencies": { "undici-types": "~6.19.8" @@ -817,6 +1255,10 @@ "url": "https://paulmillr.com/funding/" } }, + "node_modules/cli": { + "resolved": "cli", + "link": true + }, "node_modules/cli-cursor": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-4.0.0.tgz", @@ -848,7 +1290,6 @@ "version": "12.1.0", "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz", "integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==", - "dev": true, "engines": { "node": ">=18" } @@ -2466,37 +2907,37 @@ }, "speech-to-text-template": { "devDependencies": { - "@cloudflare/workers-types": "^4.20241112.0", - "typescript": "^5.6.3", - "wrangler": "^3.87.0" + "@cloudflare/workers-types": "4.20241112.0", + "typescript": "5.6.3", + "wrangler": "3.87.0" } }, "text-classification-template": { "devDependencies": { - "@cloudflare/workers-types": "^4.20241112.0", - "typescript": "^5.6.3", - "wrangler": "^3.87.0" + "@cloudflare/workers-types": "4.20241112.0", + "typescript": "5.6.3", + "wrangler": "3.87.0" } }, "text-to-image-template": { "devDependencies": { - "@cloudflare/workers-types": "^4.20241112.0", - "typescript": "^5.6.3", - "wrangler": "^3.87.0" + "@cloudflare/workers-types": "4.20241112.0", + "typescript": "5.6.3", + "wrangler": "3.87.0" } }, "translation-template": { "devDependencies": { - "@cloudflare/workers-types": "^4.20241112.0", - "typescript": "^5.6.3", - "wrangler": "^3.87.0" + "@cloudflare/workers-types": "4.20241112.0", + "typescript": "5.6.3", + "wrangler": "3.87.0" } }, "vector-embedding-template": { "devDependencies": { - "@cloudflare/workers-types": "^4.20241112.0", - "typescript": "^5.6.3", - "wrangler": "^3.87.0" + "@cloudflare/workers-types": "4.20241112.0", + "typescript": "5.6.3", + "wrangler": "3.87.0" } } } diff --git a/package.json b/package.json index 941dd25a..6cf07e73 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,21 @@ { "name": "templates", "devDependencies": { + "cli": "workspace:*", "prettier": "3.3.3", "syncpack": "13.0.0", "turbo": "2.3.0" }, "packageManager": "npm@10.2.0", "scripts": { - "check:ci": "prettier . --check && syncpack lint && turbo run check types && git diff --exit-code", + "check:ci": "prettier . --check && syncpack lint && turbo run build check types && git diff --exit-code", "deploy": "turbo run deploy", - "fix:ci": "prettier . --write && syncpack format && syncpack fix-mismatches && turbo run types" + "fix:ci": "prettier . --write && syncpack format && syncpack fix-mismatches && turbo run types", + "preupload": "turbo run build --filter=cli", + "upload": "cli upload ." }, "workspaces": [ - "./*-template" + "./*-template", + "./cli" ] } diff --git a/turbo.json b/turbo.json index 3f467418..be7009f4 100644 --- a/turbo.json +++ b/turbo.json @@ -2,6 +2,7 @@ "$schema": "https://turbo.build/schema.json", "globalEnv": ["CLOUDFLARE_ACCOUNT_ID", "CLOUDFLARE_API_TOKEN"], "tasks": { + "build": {}, "check": {}, "types": {}, "deploy": {}