create-vorzelajs 0.0.1

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.
Files changed (3) hide show
  1. package/README.md +22 -0
  2. package/dist/index.js +139 -0
  3. package/package.json +28 -0
package/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # create-vorzelajs
2
+
3
+ Scaffold a new [VorzelaJs](https://github.com/vorzela/VorzelaJS) project.
4
+
5
+ ## Usage
6
+
7
+ ```bash
8
+ npm create vorzelajs@latest my-app
9
+ ```
10
+
11
+ You will be prompted for:
12
+ - **Template**: `modern` (multi-page) or `bare` (single page)
13
+ - **Styling**: `tailwindcss`, `css-modules`, or `css`
14
+
15
+ ## Quick Start
16
+
17
+ ```bash
18
+ npm create vorzelajs@latest my-app
19
+ cd my-app
20
+ npm install
21
+ npm run dev
22
+ ```
package/dist/index.js ADDED
@@ -0,0 +1,139 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import url from 'node:url';
5
+ import prompts from 'prompts';
6
+ const __filename = url.fileURLToPath(import.meta.url);
7
+ const __dirname = path.dirname(__filename);
8
+ // Templates ship inside the vorzelajs package
9
+ function resolveTemplatesDir() {
10
+ try {
11
+ const vorzelaRoot = path.dirname(require.resolve('vorzelajs/package.json'));
12
+ return path.join(vorzelaRoot, 'templates');
13
+ }
14
+ catch {
15
+ // Fallback: assume templates are sibling to create-vorzelajs
16
+ return path.resolve(__dirname, '..', '..', 'templates');
17
+ }
18
+ }
19
+ async function copyDir(src, dest) {
20
+ await fs.mkdir(dest, { recursive: true });
21
+ for (const entry of await fs.readdir(src, { withFileTypes: true })) {
22
+ const srcPath = path.join(src, entry.name);
23
+ const destPath = path.join(dest, entry.name === 'gitignore' ? '.gitignore' : entry.name);
24
+ if (entry.isDirectory()) {
25
+ await copyDir(srcPath, destPath);
26
+ }
27
+ else {
28
+ await fs.copyFile(srcPath, destPath);
29
+ }
30
+ }
31
+ }
32
+ async function pathExists(p) {
33
+ try {
34
+ await fs.access(p);
35
+ return true;
36
+ }
37
+ catch {
38
+ return false;
39
+ }
40
+ }
41
+ function generatePackageJson(config) {
42
+ const pkg = {
43
+ name: config.name,
44
+ private: true,
45
+ type: 'module',
46
+ scripts: {
47
+ dev: 'vorzelajs dev',
48
+ build: 'vorzelajs build',
49
+ serve: 'NODE_ENV=production vorzelajs serve',
50
+ check: 'tsc --noEmit',
51
+ },
52
+ dependencies: {
53
+ vorzelajs: '^0.0.1',
54
+ 'solid-js': '^1.9',
55
+ },
56
+ devDependencies: {
57
+ typescript: '^6',
58
+ },
59
+ };
60
+ if (config.styling === 'tailwindcss') {
61
+ pkg.dependencies.tailwindcss = '^4.2';
62
+ pkg.dependencies['@tailwindcss/vite'] = '^4.2';
63
+ }
64
+ return JSON.stringify(pkg, null, 2) + '\n';
65
+ }
66
+ async function main() {
67
+ const argProjectName = process.argv[2];
68
+ const response = await prompts([
69
+ {
70
+ type: argProjectName ? null : 'text',
71
+ name: 'name',
72
+ message: 'Project name:',
73
+ initial: 'my-app',
74
+ },
75
+ {
76
+ type: 'select',
77
+ name: 'template',
78
+ message: 'Template:',
79
+ choices: [
80
+ { title: 'Modern', description: 'Multi-page starter with nav, features, and about page', value: 'modern' },
81
+ { title: 'Bare', description: 'Single landing page with counter', value: 'bare' },
82
+ ],
83
+ initial: 0,
84
+ },
85
+ {
86
+ type: 'select',
87
+ name: 'styling',
88
+ message: 'Styling:',
89
+ choices: [
90
+ { title: 'Tailwind CSS', description: 'Tailwind CSS v4 with utility classes', value: 'tailwindcss' },
91
+ { title: 'CSS Modules', description: 'Scoped CSS modules', value: 'css-modules' },
92
+ { title: 'Plain CSS', description: 'Global CSS with custom properties', value: 'css' },
93
+ ],
94
+ initial: 0,
95
+ },
96
+ ], {
97
+ onCancel() {
98
+ console.info('\nCancelled.');
99
+ process.exit(0);
100
+ },
101
+ });
102
+ const config = {
103
+ name: argProjectName ?? response.name ?? 'my-app',
104
+ template: response.template ?? 'modern',
105
+ styling: response.styling ?? 'tailwindcss',
106
+ };
107
+ const targetDir = path.resolve(process.cwd(), config.name);
108
+ if (await pathExists(targetDir)) {
109
+ const existing = await fs.readdir(targetDir);
110
+ if (existing.length > 0) {
111
+ console.error(`\nError: Directory "${config.name}" is not empty.`);
112
+ process.exit(1);
113
+ }
114
+ }
115
+ const templatesDir = resolveTemplatesDir();
116
+ console.info(`\nScaffolding ${config.name}...`);
117
+ // 1. Copy base template
118
+ await copyDir(path.join(templatesDir, 'base'), targetDir);
119
+ // 2. Copy chosen template
120
+ await copyDir(path.join(templatesDir, config.template), targetDir);
121
+ // 3. Apply styling variant
122
+ const stylingDir = config.styling === 'tailwindcss' ? 'tailwind'
123
+ : config.styling === 'css-modules' ? 'css-modules'
124
+ : 'css';
125
+ const stylesSource = path.join(templatesDir, 'styling', stylingDir, 'styles.css');
126
+ const stylesDest = path.join(targetDir, 'src', 'styles.css');
127
+ await fs.mkdir(path.dirname(stylesDest), { recursive: true });
128
+ await fs.copyFile(stylesSource, stylesDest);
129
+ // 4. Generate package.json
130
+ await fs.writeFile(path.join(targetDir, 'package.json'), generatePackageJson(config));
131
+ console.info(`\nDone! Next steps:\n`);
132
+ console.info(` cd ${config.name}`);
133
+ console.info(` npm install`);
134
+ console.info(` npm run dev\n`);
135
+ }
136
+ main().catch((error) => {
137
+ console.error(error);
138
+ process.exitCode = 1;
139
+ });
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "create-vorzelajs",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "description": "Create a new VorzelaJs project",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/vorzela/VorzelaJS.git",
10
+ "directory": "create-vorzelajs"
11
+ },
12
+ "bin": {
13
+ "create-vorzelajs": "./dist/index.js"
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsc -p tsconfig.json"
20
+ },
21
+ "dependencies": {
22
+ "prompts": "^2.4.2"
23
+ },
24
+ "devDependencies": {
25
+ "@types/prompts": "^2.4.9",
26
+ "typescript": "^6.0.2"
27
+ }
28
+ }