create-what 0.5.1 → 0.5.3

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 (2) hide show
  1. package/index.js +42 -41
  2. package/package.json +7 -3
package/index.js CHANGED
@@ -4,17 +4,14 @@
4
4
  // Canonical scaffold for What Framework projects.
5
5
  // Usage:
6
6
  // npx create-what my-app
7
- // npx create-what my-app --vanilla
8
7
 
9
8
  import { mkdirSync, writeFileSync, existsSync } from 'node:fs';
10
9
  import { join } from 'node:path';
11
10
 
12
11
  const args = process.argv.slice(2);
13
- const flags = args.filter(a => a.startsWith('-'));
14
12
  const positional = args.filter(a => !a.startsWith('-'));
15
13
 
16
14
  const projectName = positional[0] || 'my-what-app';
17
- const useJSX = !flags.includes('--no-jsx') && !flags.includes('--vanilla');
18
15
 
19
16
  const root = join(process.cwd(), projectName);
20
17
 
@@ -26,9 +23,6 @@ if (existsSync(root)) {
26
23
  mkdirSync(join(root, 'src'), { recursive: true });
27
24
  mkdirSync(join(root, 'public'), { recursive: true });
28
25
 
29
- const ext = useJSX ? 'jsx' : 'js';
30
- const entry = `src/main.${ext}`;
31
-
32
26
  writeFileSync(join(root, '.gitignore'), `node_modules\ndist\n.DS_Store\n`);
33
27
 
34
28
  writeFileSync(join(root, 'package.json'), JSON.stringify({
@@ -42,11 +36,11 @@ writeFileSync(join(root, 'package.json'), JSON.stringify({
42
36
  preview: 'vite preview',
43
37
  },
44
38
  dependencies: {
45
- 'what-framework': '^0.5.1',
39
+ 'what-framework': '^0.5.2',
46
40
  },
47
41
  devDependencies: {
48
42
  vite: '^5.4.0',
49
- ...(useJSX ? { 'what-compiler': '^0.5.1' } : {}),
43
+ 'what-compiler': '^0.5.2',
50
44
  },
51
45
  }, null, 2) + '\n');
52
46
 
@@ -61,7 +55,7 @@ writeFileSync(join(root, 'index.html'), `<!doctype html>
61
55
  </head>
62
56
  <body>
63
57
  <div id="app"></div>
64
- <script type="module" src="/${entry}"></script>
58
+ <script type="module" src="/src/main.jsx"></script>
65
59
  </body>
66
60
  </html>
67
61
  `);
@@ -78,8 +72,7 @@ writeFileSync(join(root, 'public', 'favicon.svg'), `<svg xmlns="http://www.w3.or
78
72
  </svg>
79
73
  `);
80
74
 
81
- if (useJSX) {
82
- writeFileSync(join(root, 'vite.config.js'), `import { defineConfig } from 'vite';
75
+ writeFileSync(join(root, 'vite.config.js'), `import { defineConfig } from 'vite';
83
76
  import what from 'what-compiler/vite';
84
77
 
85
78
  export default defineConfig({
@@ -87,7 +80,40 @@ export default defineConfig({
87
80
  });
88
81
  `);
89
82
 
90
- writeFileSync(join(root, 'src', 'main.jsx'), `import { mount, useSignal } from 'what-framework';
83
+ // TypeScript configuration (works for both .jsx and .tsx projects)
84
+ writeFileSync(join(root, 'tsconfig.json'), JSON.stringify({
85
+ compilerOptions: {
86
+ target: 'ES2022',
87
+ module: 'ESNext',
88
+ moduleResolution: 'bundler',
89
+ jsx: 'preserve',
90
+ jsxImportSource: 'what-core',
91
+ strict: true,
92
+ noEmit: true,
93
+ skipLibCheck: true,
94
+ esModuleInterop: true,
95
+ resolveJsonModule: true,
96
+ isolatedModules: true,
97
+ types: ['vite/client'],
98
+ },
99
+ include: ['src'],
100
+ }, null, 2) + '\n');
101
+
102
+ // VS Code workspace settings
103
+ mkdirSync(join(root, '.vscode'), { recursive: true });
104
+
105
+ writeFileSync(join(root, '.vscode', 'settings.json'), JSON.stringify({
106
+ 'typescript.tsdk': 'node_modules/typescript/lib',
107
+ 'editor.formatOnSave': true,
108
+ }, null, 2) + '\n');
109
+
110
+ writeFileSync(join(root, '.vscode', 'extensions.json'), JSON.stringify({
111
+ recommendations: [
112
+ 'zvndev.thenjs',
113
+ ],
114
+ }, null, 2) + '\n');
115
+
116
+ writeFileSync(join(root, 'src', 'main.jsx'), `import { mount, useSignal } from 'what-framework';
91
117
 
92
118
  function App() {
93
119
  const count = useSignal(0);
@@ -108,31 +134,6 @@ function App() {
108
134
 
109
135
  mount(<App />, '#app');
110
136
  `);
111
- } else {
112
- writeFileSync(join(root, 'vite.config.js'), `import { defineConfig } from 'vite';
113
-
114
- export default defineConfig({});
115
- `);
116
-
117
- writeFileSync(join(root, 'src', 'main.js'), `import { h, mount, signal } from 'what-framework';
118
-
119
- function App() {
120
- const count = signal(0);
121
-
122
- return h('main', { class: 'app-shell' },
123
- h('h1', null, 'What Framework'),
124
- h('p', null, 'Runtime h() path (advanced).'),
125
- h('section', { class: 'counter' },
126
- h('button', { onClick: () => count.set(c => c - 1) }, '-'),
127
- h('output', null, () => count()),
128
- h('button', { onClick: () => count.set(c => c + 1) }, '+'),
129
- ),
130
- );
131
- }
132
-
133
- mount(h(App), '#app');
134
- `);
135
- }
136
137
 
137
138
  writeFileSync(join(root, 'src', 'styles.css'), `:root {
138
139
  color-scheme: light;
@@ -203,13 +204,13 @@ Open [http://localhost:5173](http://localhost:5173).
203
204
  ## Notes
204
205
 
205
206
  - Canonical package name is \`what-framework\`.
206
- - JSX path is compiler-first and recommended.
207
- - Runtime \`h()\` path is available with \`--vanilla\`.
208
- - Vite is preconfigured under the hood; use \`npm run dev/build/preview\`.
207
+ - Uses the What compiler for JSX transforms and automatic reactivity.
208
+ - Vite is preconfigured; use \`npm run dev/build/preview\`.
209
209
  - Event handlers accept both \`onClick\` and \`onclick\`; docs and templates use \`onClick\`.
210
+ - Bun is also supported: \`bun create what@latest\`, \`bun run dev\`.
210
211
  `);
211
212
 
212
- console.log(`\nCreated ${projectName} (${useJSX ? 'jsx' : 'vanilla'} mode).`);
213
+ console.log(`\nCreated ${projectName}.`);
213
214
  console.log('Next steps:');
214
215
  console.log(` cd ${projectName}`);
215
216
  console.log(' npm install');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-what",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Scaffold a new What Framework project",
5
5
  "type": "module",
6
6
  "bin": {
@@ -21,6 +21,10 @@
21
21
  "license": "MIT",
22
22
  "repository": {
23
23
  "type": "git",
24
- "url": "git+https://github.com/aspect/what-fw.git"
25
- }
24
+ "url": "https://github.com/zvndev/what-fw"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/zvndev/what-fw/issues"
28
+ },
29
+ "homepage": "https://whatframework.dev"
26
30
  }