@craftzbay/create-app 1.0.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 ADDED
@@ -0,0 +1,49 @@
1
+ # @craftzbay/create-app
2
+
3
+ Scaffold a new project preconfigured with [`@craftzbay/ui`](https://www.npmjs.com/package/@craftzbay/ui).
4
+
5
+ ```bash
6
+ npm create @craftzbay/app my-app
7
+ # or
8
+ pnpm create @craftzbay/app my-app
9
+ # or
10
+ yarn create @craftzbay/app my-app
11
+ # or
12
+ bun create @craftzbay/app my-app
13
+ ```
14
+
15
+ Then:
16
+
17
+ ```bash
18
+ cd my-app
19
+ pnpm dev
20
+ ```
21
+
22
+ ## Templates
23
+
24
+ | ID | What you get |
25
+ | ----------------- | --------------------------------------------------------------------- |
26
+ | `vite-blank` | Minimal Vite + React + `@craftzbay/ui` starter (Card + Input + Switch) |
27
+ | `vite-dashboard` | `AppShell` + `Dashboard` template, ready to wire data |
28
+
29
+ Pass `--template <id>` to skip the picker:
30
+
31
+ ```bash
32
+ npm create @craftzbay/app my-app -- --template vite-dashboard
33
+ ```
34
+
35
+ ## Options
36
+
37
+ ```
38
+ -t, --template <name> Skip the prompt and use a known template
39
+ -y, --yes Skip "install deps?" prompt and install
40
+ --no-install Skip dependency install entirely
41
+ -h, --help Show this help
42
+ ```
43
+
44
+ ## Docs
45
+
46
+ - Showcase: <https://design.runestonetechnologies.com>
47
+ - Components: <https://design.runestonetechnologies.com/#components>
48
+ - Templates: <https://design.runestonetechnologies.com/#templates>
49
+ - Guides: <https://design.runestonetechnologies.com/#guides>
package/dist/index.js ADDED
@@ -0,0 +1,207 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "fs";
5
+ import path from "path";
6
+ import { fileURLToPath } from "url";
7
+ import { spawnSync } from "child_process";
8
+ import {
9
+ cancel,
10
+ confirm,
11
+ intro,
12
+ isCancel,
13
+ log,
14
+ outro,
15
+ select,
16
+ text
17
+ } from "@clack/prompts";
18
+ import kleur from "kleur";
19
+ var __dirname = path.dirname(fileURLToPath(import.meta.url));
20
+ var TEMPLATES_DIR = path.resolve(__dirname, "../templates");
21
+ var TEMPLATES = [
22
+ { id: "vite-blank", label: "Vite + Blank", hint: "Minimal Vite + React + @craftzbay/ui starter" },
23
+ { id: "vite-dashboard", label: "Vite + Dashboard", hint: "AppShell + Dashboard template, ready to wire data" }
24
+ ];
25
+ function detectPackageManager() {
26
+ const ua = process.env.npm_config_user_agent ?? "";
27
+ if (ua.startsWith("pnpm")) return "pnpm";
28
+ if (ua.startsWith("yarn")) return "yarn";
29
+ if (ua.startsWith("bun")) return "bun";
30
+ return "npm";
31
+ }
32
+ function parseArgs(argv) {
33
+ const args = argv.slice(2);
34
+ let projectName;
35
+ let template;
36
+ let noInstall = false;
37
+ let yes = false;
38
+ for (let i = 0; i < args.length; i++) {
39
+ const a = args[i];
40
+ if (a === "--template" || a === "-t") {
41
+ template = args[++i];
42
+ } else if (a === "--no-install") {
43
+ noInstall = true;
44
+ } else if (a === "--yes" || a === "-y") {
45
+ yes = true;
46
+ } else if (a === "--help" || a === "-h") {
47
+ printHelp();
48
+ process.exit(0);
49
+ } else if (!a.startsWith("-")) {
50
+ projectName = a;
51
+ }
52
+ }
53
+ return { projectName, template, noInstall, yes };
54
+ }
55
+ function printHelp() {
56
+ const lines = [
57
+ "",
58
+ kleur.bold(" @craftzbay/create-app") + kleur.gray(" \u2014 scaffold a new @craftzbay/ui project"),
59
+ "",
60
+ " Usage:",
61
+ " npm create @craftzbay/app [project-name] [options]",
62
+ "",
63
+ " Options:",
64
+ " -t, --template <name> Skip the prompt and use a known template",
65
+ ' -y, --yes Skip "install deps?" prompt and install',
66
+ " --no-install Skip dependency install entirely",
67
+ " -h, --help Show this help",
68
+ "",
69
+ " Templates:",
70
+ ...TEMPLATES.map((t) => ` ${t.id.padEnd(20)} ${kleur.gray(t.hint)}`),
71
+ ""
72
+ ];
73
+ console.log(lines.join("\n"));
74
+ }
75
+ function isValidProjectName(name) {
76
+ if (!name) return "Project name is required";
77
+ if (name === "." || name === "./") return 'Use a directory name, not "."';
78
+ if (!/^[a-z0-9._-]+$/i.test(name)) {
79
+ return "Use letters, numbers, dashes, dots, or underscores";
80
+ }
81
+ return true;
82
+ }
83
+ function copyTemplate(templateId, dest, projectName) {
84
+ const src = path.join(TEMPLATES_DIR, templateId);
85
+ if (!existsSync(src)) {
86
+ throw new Error(`Template "${templateId}" not found at ${src}`);
87
+ }
88
+ mkdirSync(dest, { recursive: true });
89
+ walk(src, dest, projectName);
90
+ }
91
+ function walk(srcDir, destDir, projectName) {
92
+ for (const entry of readdirSync(srcDir)) {
93
+ const srcPath = path.join(srcDir, entry);
94
+ const destName = entry === "_package.json" ? "package.json" : entry === "_gitignore" ? ".gitignore" : entry;
95
+ const destPath = path.join(destDir, destName);
96
+ const stat = statSync(srcPath);
97
+ if (stat.isDirectory()) {
98
+ mkdirSync(destPath, { recursive: true });
99
+ walk(srcPath, destPath, projectName);
100
+ } else {
101
+ const raw = readFileSync(srcPath, "utf8");
102
+ const rendered = raw.replace(/__PROJECT_NAME__/g, projectName);
103
+ writeFileSync(destPath, rendered);
104
+ }
105
+ }
106
+ }
107
+ async function run() {
108
+ intro(kleur.bold(kleur.cyan(" \u2726 @craftzbay/create-app ")));
109
+ const { projectName: cliName, template: cliTemplate, noInstall, yes } = parseArgs(process.argv);
110
+ let projectName = cliName;
111
+ if (!projectName) {
112
+ const answer = await text({
113
+ message: "Project name",
114
+ placeholder: "my-app",
115
+ defaultValue: "my-app",
116
+ validate: (v) => {
117
+ const r = isValidProjectName(v || "my-app");
118
+ return r === true ? void 0 : r;
119
+ }
120
+ });
121
+ if (isCancel(answer)) {
122
+ cancel("Cancelled.");
123
+ process.exit(0);
124
+ }
125
+ projectName = answer || "my-app";
126
+ } else {
127
+ const valid = isValidProjectName(projectName);
128
+ if (valid !== true) {
129
+ log.error(valid);
130
+ process.exit(1);
131
+ }
132
+ }
133
+ const targetDir = path.resolve(process.cwd(), projectName);
134
+ if (existsSync(targetDir) && readdirSync(targetDir).length > 0) {
135
+ const proceed = await confirm({
136
+ message: `Directory "${projectName}" is not empty. Overwrite?`,
137
+ initialValue: false
138
+ });
139
+ if (isCancel(proceed) || !proceed) {
140
+ cancel("Cancelled.");
141
+ process.exit(0);
142
+ }
143
+ }
144
+ let templateId = cliTemplate;
145
+ if (!templateId) {
146
+ const answer = await select({
147
+ message: "Pick a template",
148
+ options: TEMPLATES.map((t) => ({ value: t.id, label: t.label, hint: t.hint }))
149
+ });
150
+ if (isCancel(answer)) {
151
+ cancel("Cancelled.");
152
+ process.exit(0);
153
+ }
154
+ templateId = answer;
155
+ }
156
+ if (!TEMPLATES.some((t) => t.id === templateId)) {
157
+ log.error(`Unknown template "${templateId}". Run with --help to list.`);
158
+ process.exit(1);
159
+ }
160
+ let installNow;
161
+ if (noInstall) {
162
+ installNow = false;
163
+ } else if (yes) {
164
+ installNow = true;
165
+ } else {
166
+ const ans = await confirm({
167
+ message: "Install dependencies now?",
168
+ initialValue: true
169
+ });
170
+ if (isCancel(ans)) {
171
+ cancel("Cancelled.");
172
+ process.exit(0);
173
+ }
174
+ installNow = ans;
175
+ }
176
+ log.step(`Scaffolding into ${kleur.cyan(path.relative(process.cwd(), targetDir) || ".")}`);
177
+ try {
178
+ copyTemplate(templateId, targetDir, projectName);
179
+ } catch (err) {
180
+ log.error(err.message);
181
+ process.exit(1);
182
+ }
183
+ const pm = detectPackageManager();
184
+ if (installNow) {
185
+ log.step(`Installing dependencies with ${kleur.cyan(pm)} (this can take a minute)\u2026`);
186
+ const result = spawnSync(pm, ["install"], { cwd: targetDir, stdio: "inherit" });
187
+ if (result.status !== 0) {
188
+ log.warn("Install failed. You can re-run it manually after fixing the issue.");
189
+ }
190
+ }
191
+ outro(
192
+ [
193
+ kleur.green(" All set."),
194
+ "",
195
+ kleur.gray(" Next steps:"),
196
+ ` ${kleur.cyan(`cd ${projectName}`)}`,
197
+ ...installNow ? [] : [` ${kleur.cyan(`${pm} install`)}`],
198
+ ` ${kleur.cyan(`${pm} run dev`)}`,
199
+ "",
200
+ kleur.gray(" Docs: https://design.runestonetechnologies.com")
201
+ ].join("\n")
202
+ );
203
+ }
204
+ run().catch((err) => {
205
+ log.error(err instanceof Error ? err.message : String(err));
206
+ process.exit(1);
207
+ });
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@craftzbay/create-app",
3
+ "version": "1.0.0",
4
+ "description": "Scaffold a new project preconfigured with @craftzbay/ui. Invoke via `npm create @craftzbay/app my-app`.",
5
+ "license": "MIT",
6
+ "author": "craftzbay",
7
+ "homepage": "https://design.runestonetechnologies.com",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/craftzbay/design-system.git",
11
+ "directory": "packages/create-app"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/craftzbay/design-system/issues"
15
+ },
16
+ "keywords": [
17
+ "create-app",
18
+ "scaffold",
19
+ "craftzbay",
20
+ "design-system",
21
+ "react",
22
+ "tailwind"
23
+ ],
24
+ "type": "module",
25
+ "bin": {
26
+ "create-craftzbay-app": "./dist/index.js"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "templates",
31
+ "README.md"
32
+ ],
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "scripts": {
37
+ "build": "tsup src/index.ts --format esm --target node18 --out-dir dist --clean",
38
+ "dev": "tsup src/index.ts --format esm --target node18 --out-dir dist --watch",
39
+ "test": "pnpm build && node scripts/smoke.mjs",
40
+ "prepublishOnly": "pnpm build"
41
+ },
42
+ "dependencies": {
43
+ "@clack/prompts": "^0.8.2",
44
+ "kleur": "^4.1.5"
45
+ },
46
+ "devDependencies": {
47
+ "@types/node": "^22.10.0",
48
+ "tsup": "^8.3.5",
49
+ "typescript": "^5.7.2"
50
+ },
51
+ "engines": {
52
+ "node": ">=18"
53
+ }
54
+ }
@@ -0,0 +1,7 @@
1
+ node_modules
2
+ dist
3
+ .DS_Store
4
+ *.log
5
+ .env
6
+ .env.local
7
+ .vite
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "__PROJECT_NAME__",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc -b && vite build",
9
+ "preview": "vite preview"
10
+ },
11
+ "dependencies": {
12
+ "@craftzbay/ui": "^0.7.0",
13
+ "react": "^18.3.1",
14
+ "react-dom": "^18.3.1"
15
+ },
16
+ "devDependencies": {
17
+ "@types/react": "^18.3.12",
18
+ "@types/react-dom": "^18.3.1",
19
+ "@vitejs/plugin-react": "^4.3.4",
20
+ "typescript": "^5.7.2",
21
+ "vite": "^6.0.3"
22
+ }
23
+ }
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>__PROJECT_NAME__</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="/src/main.tsx"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,47 @@
1
+ import { useState } from 'react';
2
+ import {
3
+ Button,
4
+ Card,
5
+ CardContent,
6
+ CardDescription,
7
+ CardHeader,
8
+ CardTitle,
9
+ Input,
10
+ Switch,
11
+ } from '@craftzbay/ui';
12
+
13
+ export function App() {
14
+ const [name, setName] = useState('');
15
+ const [notify, setNotify] = useState(true);
16
+
17
+ return (
18
+ <div className="min-h-screen bg-background p-8">
19
+ <div className="mx-auto max-w-md">
20
+ <Card>
21
+ <CardHeader>
22
+ <CardTitle>Hello, __PROJECT_NAME__</CardTitle>
23
+ <CardDescription>
24
+ Your new app is wired up with @craftzbay/ui. Edit{' '}
25
+ <code className="rounded bg-background-muted px-1">src/App.tsx</code> to start
26
+ building.
27
+ </CardDescription>
28
+ </CardHeader>
29
+ <CardContent className="flex flex-col gap-4">
30
+ <Input
31
+ label="Your name"
32
+ value={name}
33
+ onChange={(e) => setName(e.target.value)}
34
+ placeholder="Bay"
35
+ />
36
+ <Switch
37
+ label="Email notifications"
38
+ checked={notify}
39
+ onCheckedChange={setNotify}
40
+ />
41
+ <Button disabled={!name}>{name ? `Hi, ${name}` : 'Enter your name'}</Button>
42
+ </CardContent>
43
+ </Card>
44
+ </div>
45
+ </div>
46
+ );
47
+ }
@@ -0,0 +1,10 @@
1
+ import { StrictMode } from 'react';
2
+ import { createRoot } from 'react-dom/client';
3
+ import '@craftzbay/ui/styles.css';
4
+ import { App } from './App';
5
+
6
+ createRoot(document.getElementById('root')!).render(
7
+ <StrictMode>
8
+ <App />
9
+ </StrictMode>,
10
+ );
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
5
+ "module": "ESNext",
6
+ "moduleResolution": "Bundler",
7
+ "jsx": "react-jsx",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "noEmit": true
12
+ },
13
+ "include": ["src"]
14
+ }
@@ -0,0 +1,6 @@
1
+ import { defineConfig } from 'vite';
2
+ import react from '@vitejs/plugin-react';
3
+
4
+ export default defineConfig({
5
+ plugins: [react()],
6
+ });
@@ -0,0 +1,7 @@
1
+ node_modules
2
+ dist
3
+ .DS_Store
4
+ *.log
5
+ .env
6
+ .env.local
7
+ .vite
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "__PROJECT_NAME__",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc -b && vite build",
9
+ "preview": "vite preview"
10
+ },
11
+ "dependencies": {
12
+ "@craftzbay/ui": "^0.7.0",
13
+ "react": "^18.3.1",
14
+ "react-dom": "^18.3.1"
15
+ },
16
+ "devDependencies": {
17
+ "@types/react": "^18.3.12",
18
+ "@types/react-dom": "^18.3.1",
19
+ "@vitejs/plugin-react": "^4.3.4",
20
+ "typescript": "^5.7.2",
21
+ "vite": "^6.0.3"
22
+ }
23
+ }
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>__PROJECT_NAME__</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="/src/main.tsx"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,26 @@
1
+ import { AppShell, Dashboard, ToastProvider, ToastViewport, TooltipProvider } from '@craftzbay/ui';
2
+
3
+ const Brand = () => (
4
+ <span className="flex items-center gap-2 text-sm font-semibold">
5
+ <span className="inline-flex size-6 items-center justify-center rounded-md bg-accent text-on-accent text-xs">
6
+
7
+ </span>
8
+ __PROJECT_NAME__
9
+ </span>
10
+ );
11
+
12
+ export function App() {
13
+ return (
14
+ <TooltipProvider>
15
+ <ToastProvider>
16
+ <AppShell brand={<Brand />} active="home">
17
+ <Dashboard
18
+ title="Overview"
19
+ subtitle="Replace this with your own data — every section is a prop."
20
+ />
21
+ </AppShell>
22
+ <ToastViewport />
23
+ </ToastProvider>
24
+ </TooltipProvider>
25
+ );
26
+ }
@@ -0,0 +1,10 @@
1
+ import { StrictMode } from 'react';
2
+ import { createRoot } from 'react-dom/client';
3
+ import '@craftzbay/ui/styles.css';
4
+ import { App } from './App';
5
+
6
+ createRoot(document.getElementById('root')!).render(
7
+ <StrictMode>
8
+ <App />
9
+ </StrictMode>,
10
+ );
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
5
+ "module": "ESNext",
6
+ "moduleResolution": "Bundler",
7
+ "jsx": "react-jsx",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "noEmit": true
12
+ },
13
+ "include": ["src"]
14
+ }
@@ -0,0 +1,6 @@
1
+ import { defineConfig } from 'vite';
2
+ import react from '@vitejs/plugin-react';
3
+
4
+ export default defineConfig({
5
+ plugins: [react()],
6
+ });