create-stephansama-example
Advanced tools
+2
-11
| #!/usr/bin/env node | ||
| import { main } from "./dist/index.js"; | ||
| main().then( | ||
| () => { | ||
| process.exit(0); | ||
| }, | ||
| (error) => { | ||
| if (error) console.error(error); | ||
| process.exit(1); | ||
| }, | ||
| ); | ||
| const cli = await import("./dist/index.cjs"); | ||
| await cli.main(); |
+40
-44
@@ -1,2 +0,3 @@ | ||
| //#region rolldown:runtime | ||
| Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); | ||
| //#region \0rolldown/runtime.js | ||
| var __create = Object.create; | ||
@@ -22,14 +23,10 @@ var __defProp = Object.defineProperty; | ||
| }) : target, mod)); | ||
| //#endregion | ||
| let __bluwy_giget_core = require("@bluwy/giget-core"); | ||
| __bluwy_giget_core = __toESM(__bluwy_giget_core); | ||
| let __clack_prompts = require("@clack/prompts"); | ||
| __clack_prompts = __toESM(__clack_prompts); | ||
| let _bluwy_giget_core = require("@bluwy/giget-core"); | ||
| let _clack_prompts = require("@clack/prompts"); | ||
| _clack_prompts = __toESM(_clack_prompts, 1); | ||
| let node_path = require("node:path"); | ||
| node_path = __toESM(node_path); | ||
| node_path = __toESM(node_path, 1); | ||
| //#region ../../package.json | ||
| var homepage = "https://packages.stephansama.info"; | ||
| //#endregion | ||
@@ -42,3 +39,3 @@ //#region ../../scripts/dist/examples.js | ||
| "relativeDir": "examples/astro-iconify-svgmap", | ||
| "version": "1.0.6" | ||
| "version": "1.0.7" | ||
| }, | ||
@@ -48,3 +45,3 @@ { | ||
| "relativeDir": "examples/catppuccin-xsl/astro", | ||
| "version": "0.0.2" | ||
| "version": "0.0.3" | ||
| }, | ||
@@ -54,3 +51,3 @@ { | ||
| "relativeDir": "examples/catppuccin-xsl/vanilla", | ||
| "version": "1.0.1" | ||
| "version": "1.0.2" | ||
| }, | ||
@@ -61,3 +58,3 @@ { | ||
| "relativeDir": "examples/remark-asciinema", | ||
| "version": "0.0.7" | ||
| "version": "0.0.8" | ||
| }, | ||
@@ -67,3 +64,3 @@ { | ||
| "relativeDir": "examples/svelte-social-share-links/astro", | ||
| "version": "0.1.3" | ||
| "version": "0.1.4" | ||
| }, | ||
@@ -73,3 +70,3 @@ { | ||
| "relativeDir": "examples/svelte-social-share-links/svelte-kit", | ||
| "version": "0.1.2" | ||
| "version": "0.1.3" | ||
| }, | ||
@@ -79,3 +76,3 @@ { | ||
| "relativeDir": "examples/typed-events/react", | ||
| "version": "0.1.2" | ||
| "version": "0.1.3" | ||
| }, | ||
@@ -85,6 +82,5 @@ { | ||
| "relativeDir": "examples/typed-events/vanilla", | ||
| "version": "1.2.2" | ||
| "version": "1.2.3" | ||
| } | ||
| ]; | ||
| //#endregion | ||
@@ -95,4 +91,6 @@ //#region src/index.ts | ||
| try { | ||
| const examples = (await (await fetch(url)).json()).filter(({ name }) => name.startsWith("@example")); | ||
| if (!examples.length) throw new Error("no examples found from remote"); | ||
| const examples = (await (await fetch(url)).json()).filter(({ name }) => { | ||
| return name.startsWith("@example"); | ||
| }); | ||
| if (examples.length === 0) throw new Error("no examples found from remote"); | ||
| return examples; | ||
@@ -105,40 +103,38 @@ } catch { | ||
| async function main() { | ||
| __clack_prompts.intro("create @stephansama example projects"); | ||
| _clack_prompts.intro("create @stephansama example projects"); | ||
| const examples = await fetchExamples(); | ||
| const example = await __clack_prompts.select({ | ||
| const example = await _clack_prompts.select({ | ||
| message: "Select an example:", | ||
| options: examples.map((example$1) => ({ | ||
| description: example$1.description, | ||
| label: `${example$1.name.replace("@example/", "")} (v${example$1.version})`, | ||
| value: example$1.name | ||
| options: examples.map((example) => ({ | ||
| description: example.description, | ||
| label: `${example.name.replace("@example/", "")} (v${example.version})`, | ||
| value: example.name | ||
| })) | ||
| }); | ||
| if (__clack_prompts.isCancel(example)) return cancel(); | ||
| const exampleData = examples.find((e) => e.name === example); | ||
| if (_clack_prompts.isCancel(example)) return cancel(); | ||
| const exampleData = examples.find((current) => current.name === example); | ||
| if (!exampleData) throw new Error("unable to find example data"); | ||
| const [, ...relativeDir] = exampleData.relativeDir.split("/"); | ||
| const defaultDir = "./" + relativeDir.join("-"); | ||
| const dir = await __clack_prompts.text({ | ||
| defaultValue: defaultDir, | ||
| const [, ...relativeDirectory] = exampleData.relativeDir.split("/"); | ||
| const defaultDirectory = "./" + relativeDirectory.join("-"); | ||
| const directory = await _clack_prompts.text({ | ||
| defaultValue: defaultDirectory, | ||
| message: "Input the directory to clone to:", | ||
| placeholder: defaultDir | ||
| placeholder: defaultDirectory | ||
| }); | ||
| if (__clack_prompts.isCancel(dir)) return cancel(); | ||
| const spinner = __clack_prompts.spinner(); | ||
| if (_clack_prompts.isCancel(directory)) return cancel(); | ||
| const spinner = _clack_prompts.spinner(); | ||
| spinner.start("Downloading template"); | ||
| await (0, __bluwy_giget_core.downloadTemplate)(`github:stephansama/packages/${exampleData.relativeDir}`, { | ||
| cwd: node_path.resolve(), | ||
| dir, | ||
| await (0, _bluwy_giget_core.downloadTemplate)(`github:stephansama/packages/${exampleData.relativeDir}`, { | ||
| cwd: node_path.default.resolve(), | ||
| dir: directory, | ||
| force: true | ||
| }).catch((e) => console.error(e)); | ||
| }).catch((error) => console.error(error)); | ||
| spinner.stop("Downloaded example"); | ||
| __clack_prompts.outro(`successfully downloaded example template to ${dir}`); | ||
| _clack_prompts.outro(`successfully downloaded example template to ${directory}`); | ||
| } | ||
| function cancel() { | ||
| __clack_prompts.cancel("Operation canceled"); | ||
| process.exit(0); | ||
| _clack_prompts.cancel("Operation canceled"); | ||
| } | ||
| //#endregion | ||
| exports.fetchExamples = fetchExamples; | ||
| exports.main = main; | ||
| exports.main = main; |
+11
-7
| { | ||
| "name": "create-stephansama-example", | ||
| "version": "1.4.3", | ||
| "version": "1.4.5", | ||
| "description": "Download an example from the @stephansama/packages examples", | ||
@@ -20,2 +20,3 @@ "keywords": [ | ||
| }, | ||
| "sideEffects": true, | ||
| "type": "module", | ||
@@ -30,13 +31,15 @@ "exports": { | ||
| "files": [ | ||
| "./dist", | ||
| "./cli.mjs" | ||
| "./dist" | ||
| ], | ||
| "dependencies": { | ||
| "@bluwy/giget-core": "^0.1.6", | ||
| "@clack/prompts": "^0.11.0" | ||
| "@bluwy/giget-core": "0.1.6", | ||
| "@clack/prompts": "1.3.0" | ||
| }, | ||
| "devDependencies": { | ||
| "tsdown": "0.15.12", | ||
| "tsdown": "0.21.10", | ||
| "undici": "7.22.0" | ||
| }, | ||
| "engines": { | ||
| "node": ">=24" | ||
| }, | ||
| "publishConfig": { | ||
@@ -51,6 +54,7 @@ "access": "public", | ||
| "dev": "tsdown --watch", | ||
| "generate": "pnpm --workspace-root run scripts:generate-examples", | ||
| "generate": "pnpm --filter=scripts run generate-examples", | ||
| "lint": "eslint ./ --pass-on-no-patterns --no-error-on-unmatched-pattern", | ||
| "lint:fix": "eslint ./ --pass-on-no-patterns --no-error-on-unmatched-pattern --fix", | ||
| "typedoc": "pnpm run generate" | ||
| } | ||
| } |
8658
1.45%132
-4.35%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated