create-crust 0.0.15 → 0.0.17

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 CHANGED
@@ -8,7 +8,14 @@ Scaffold a new [Crust](https://crustjs.com) CLI project in seconds.
8
8
  bun create crust my-cli
9
9
  ```
10
10
 
11
- This will prompt for your project directory, install dependencies, and optionally initialize a git repository. The package name is inferred from the directory name. The generated project includes:
11
+ This will prompt for your project directory, template style, whether to install dependencies, and optionally initialize a git repository. The package name is inferred from the directory name.
12
+
13
+ `create-crust` includes two templates:
14
+
15
+ - `Minimal` — single-file starter (`src/cli.ts`)
16
+ - `Modular` — file-splitting pattern with `.sub()` and `.command(builder)`
17
+
18
+ Every generated project includes:
12
19
 
13
20
  - `src/cli.ts` — entry point with a sample command
14
21
  - `package.json` — configured with `crust build` and `bun run` dev scripts
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import{existsSync as O}from"fs";import{basename as Z,resolve as Q}from"path";import{defineCommand as $,runMain as b}from"@crustjs/core";import{detectPackageManager as E,isInGitRepo as H,runSteps as T,scaffold as L}from"@crustjs/create";import{confirm as F,input as V,spinner as x}from"@crustjs/prompts";var y=/[<>:"|?*\\]/;function G(z){if(!z)return"Project name cannot be empty";if(y.test(z))return`Project name contains invalid characters: ${z}`;return!0}var R=$({meta:{name:"create-crust",description:"Scaffold a new Crust CLI project"},args:[{name:"directory",type:"string",description:"Project directory to scaffold into"}],async run({args:z}){let w=z.directory??await V({message:"Project directory",default:"my-cli",validate:G}),q=Q(process.cwd(),w),J=Z(q);if(w!=="."&&O(q)){if(!await F({message:`Directory "${J}" already exists. Overwrite?`,default:!1})){console.log("Aborted.");return}}let U=await F({message:"Install dependencies?",default:!0}),W=O(q)?q:Q(q,".."),X=H(W)?!1:await F({message:"Initialize a git repository?",default:!0}),K=J;if(await L({template:"templates/base",dest:q,context:{name:K},conflict:"overwrite"}),U){let B=E(q),Y=B==="npm"?"npm install":`${B} install`;await T([{type:"command",cmd:Y}],q)}if(X)await x({message:"Initializing git repository...",task:()=>T([{type:"git-init",commit:"chore: initial commit"}],q)});if(console.log(`
3
+ import{existsSync as O}from"fs";import{basename as $,resolve as Q}from"path";import{Crust as b}from"@crustjs/core";import{detectPackageManager as E,isInGitRepo as H,runSteps as T,scaffold as L}from"@crustjs/create";import{confirm as F,input as V,select as x,spinner as y}from"@crustjs/prompts";var G=/[<>:"|?*\\]/;function M(z){if(!z)return"Project name cannot be empty";if(G.test(z))return`Project name contains invalid characters: ${z}`;return!0}var R=new b("create-crust").meta({description:"Scaffold a new Crust CLI project"}).args([{name:"directory",type:"string",description:"Project directory to scaffold into"}]).run(async({args:z})=>{let w=z.directory??await V({message:"Project directory",default:"my-cli",validate:M}),q=Q(process.cwd(),w),J=$(q);if(w!=="."&&O(q)){if(!await F({message:`Directory "${J}" already exists. Overwrite?`,default:!1})){console.log("Aborted.");return}}let U=await F({message:"Install dependencies?",default:!0}),W=await x({message:"Template style",choices:[{label:"Minimal",value:"minimal",hint:"single-file starter"},{label:"Modular",value:"modular",hint:"file split with .sub()"}],default:"minimal"})==="minimal"?"templates/base":"templates/modular",X=O(q)?q:Q(q,".."),Y=H(X)?!1:await F({message:"Initialize a git repository?",default:!0}),K=J;if(await L({template:W,dest:q,context:{name:K},conflict:"overwrite"}),U){let B=E(q),Z=B==="npm"?"npm install":`${B} install`;await T([{type:"command",cmd:Z}],q)}if(Y)await y({message:"Initializing git repository...",task:()=>T([{type:"git-init",commit:"chore: initial commit"}],q)});if(console.log(`
4
4
  Created ${K}!
5
- `),console.log("Next steps:"),w!=="."){let B=w.startsWith("/")?w:`./${w}`;console.log(` cd ${B}`)}console.log(" bun run dev"),console.log(" bun run build")}});b(R);
5
+ `),console.log("Next steps:"),w!=="."){let B=w.startsWith("/")?w:`./${w}`;console.log(` cd ${B}`)}console.log(" bun run dev"),console.log(" bun run build")});await R.execute();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-crust",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "Scaffold a new Crust CLI project.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,9 +40,9 @@
40
40
  "test": "bun test"
41
41
  },
42
42
  "dependencies": {
43
- "@crustjs/core": "0.0.9",
43
+ "@crustjs/core": "0.0.10",
44
44
  "@crustjs/create": "0.0.4",
45
- "@crustjs/prompts": "0.0.6"
45
+ "@crustjs/prompts": "0.0.7"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@crustjs/config": "0.0.0",
@@ -1,33 +1,29 @@
1
- import { defineCommand, runMain } from "@crustjs/core";
1
+ import { Crust } from "@crustjs/core";
2
2
  import { helpPlugin, versionPlugin } from "@crustjs/plugins";
3
3
  import pkg from "../package.json";
4
4
 
5
- const main = defineCommand({
6
- meta: {
7
- name: "{{name}}",
8
- description: "A CLI built with Crust",
9
- },
10
- args: [
5
+ const cli = new Crust("{{name}}")
6
+ .meta({ description: "A CLI built with Crust" })
7
+ .use(versionPlugin(pkg.version))
8
+ .use(helpPlugin())
9
+ .args([
11
10
  {
12
11
  name: "name",
13
12
  type: "string",
14
13
  description: "Your name",
15
14
  default: "world",
16
15
  },
17
- ],
18
- flags: {
16
+ ])
17
+ .flags({
19
18
  greet: {
20
19
  type: "string",
21
20
  description: "Greeting to use",
22
21
  default: "Hello",
23
- alias: "g",
22
+ short: "g",
24
23
  },
25
- },
26
- run({ args, flags }) {
24
+ })
25
+ .run(({ args, flags }) => {
27
26
  console.log(`${flags.greet}, ${args.name}!`);
28
- },
29
- });
27
+ });
30
28
 
31
- runMain(main, {
32
- plugins: [versionPlugin(pkg.version), helpPlugin()],
33
- });
29
+ await cli.execute();
@@ -0,0 +1,29 @@
1
+ # {{name}}
2
+
3
+ A modular CLI built with [Crust](https://crustjs.com).
4
+
5
+ This template demonstrates the file-splitting pattern with `.sub()` and `.command(builder)`.
6
+
7
+ ## Development
8
+
9
+ ```sh
10
+ # Run in dev mode
11
+ bun run dev
12
+
13
+ # Type-check
14
+ bun run check:types
15
+
16
+ # Build standalone executable
17
+ bun run build
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ```sh
23
+ # Run the greet subcommand
24
+ {{name}} greet world
25
+ {{name}} greet --greet Hey world
26
+
27
+ # Show help
28
+ {{name}} --help
29
+ ```
@@ -0,0 +1,34 @@
1
+ # dependencies (bun install)
2
+ node_modules
3
+
4
+ # output
5
+ out
6
+ dist
7
+ *.tgz
8
+
9
+ # code coverage
10
+ coverage
11
+ *.lcov
12
+
13
+ # logs
14
+ logs
15
+ *.log
16
+ report.*.*.*.*.json
17
+
18
+ # dotenv environment variable files
19
+ .env
20
+ .env.development.local
21
+ .env.test.local
22
+ .env.production.local
23
+ .env.local
24
+
25
+ # caches
26
+ .eslintcache
27
+ .cache
28
+ *.tsbuildinfo
29
+
30
+ # IntelliJ based IDEs
31
+ .idea
32
+
33
+ # Finder (MacOS) folder config
34
+ .DS_Store
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "{{name}}",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "description": "A CLI built with Crust",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "bin": {
10
+ "{{name}}": "dist/cli"
11
+ },
12
+ "scripts": {
13
+ "dev": "bun run src/cli.ts",
14
+ "build": "crust build",
15
+ "start": "./dist/cli",
16
+ "check:types": "tsc --noEmit"
17
+ },
18
+ "dependencies": {
19
+ "@crustjs/core": "latest",
20
+ "@crustjs/plugins": "latest"
21
+ },
22
+ "devDependencies": {
23
+ "@crustjs/crust": "latest",
24
+ "@types/bun": "latest",
25
+ "typescript": "^5"
26
+ }
27
+ }
@@ -0,0 +1,13 @@
1
+ import { Crust } from "@crustjs/core";
2
+
3
+ export const app = new Crust("{{name}}")
4
+ .meta({ description: "A CLI built with Crust" })
5
+ .flags({
6
+ greet: {
7
+ type: "string",
8
+ description: "Greeting to use",
9
+ default: "Hello",
10
+ short: "g",
11
+ inherit: true,
12
+ },
13
+ });
@@ -0,0 +1,10 @@
1
+ import { helpPlugin, versionPlugin } from "@crustjs/plugins";
2
+ import pkg from "../package.json";
3
+ import { app } from "./app.ts";
4
+ import { greetCmd } from "./commands/greet.ts";
5
+
6
+ await app
7
+ .use(versionPlugin(pkg.version))
8
+ .use(helpPlugin())
9
+ .command(greetCmd)
10
+ .execute();
@@ -0,0 +1,16 @@
1
+ import { app } from "../app.ts";
2
+
3
+ export const greetCmd = app
4
+ .sub("greet")
5
+ .meta({ description: "Greet someone" })
6
+ .args([
7
+ {
8
+ name: "name",
9
+ type: "string",
10
+ description: "Your name",
11
+ default: "world",
12
+ },
13
+ ])
14
+ .run(({ args, flags }) => {
15
+ console.log(`${flags.greet}, ${args.name}!`);
16
+ });
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "lib": ["ESNext"],
4
+ "target": "ESNext",
5
+ "module": "Preserve",
6
+ "moduleDetection": "force",
7
+ "moduleResolution": "bundler",
8
+ "allowImportingTsExtensions": true,
9
+ "verbatimModuleSyntax": true,
10
+ "noEmit": true,
11
+ "strict": true,
12
+ "skipLibCheck": true,
13
+ "noFallthroughCasesInSwitch": true,
14
+ "noUncheckedIndexedAccess": true
15
+ },
16
+ "include": ["src"]
17
+ }