create-what 0.5.0 → 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.
- package/index.js +55 -41
- 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.
|
|
39
|
+
'what-framework': '^0.5.2',
|
|
46
40
|
},
|
|
47
41
|
devDependencies: {
|
|
48
42
|
vite: '^5.4.0',
|
|
49
|
-
|
|
43
|
+
'what-compiler': '^0.5.2',
|
|
50
44
|
},
|
|
51
45
|
}, null, 2) + '\n');
|
|
52
46
|
|
|
@@ -56,17 +50,29 @@ writeFileSync(join(root, 'index.html'), `<!doctype html>
|
|
|
56
50
|
<meta charset="UTF-8" />
|
|
57
51
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
58
52
|
<title>${projectName}</title>
|
|
53
|
+
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
59
54
|
<link rel="stylesheet" href="/src/styles.css" />
|
|
60
55
|
</head>
|
|
61
56
|
<body>
|
|
62
57
|
<div id="app"></div>
|
|
63
|
-
<script type="module" src="
|
|
58
|
+
<script type="module" src="/src/main.jsx"></script>
|
|
64
59
|
</body>
|
|
65
60
|
</html>
|
|
66
61
|
`);
|
|
67
62
|
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
writeFileSync(join(root, 'public', 'favicon.svg'), `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
|
64
|
+
<defs>
|
|
65
|
+
<linearGradient id="g" x1="0" x2="1" y1="0" y2="1">
|
|
66
|
+
<stop offset="0%" stop-color="#2563eb" />
|
|
67
|
+
<stop offset="100%" stop-color="#1d4ed8" />
|
|
68
|
+
</linearGradient>
|
|
69
|
+
</defs>
|
|
70
|
+
<rect width="64" height="64" rx="14" fill="url(#g)" />
|
|
71
|
+
<path d="M17 20h10l5 20 5-20h10L36 49h-8z" fill="#fff" />
|
|
72
|
+
</svg>
|
|
73
|
+
`);
|
|
74
|
+
|
|
75
|
+
writeFileSync(join(root, 'vite.config.js'), `import { defineConfig } from 'vite';
|
|
70
76
|
import what from 'what-compiler/vite';
|
|
71
77
|
|
|
72
78
|
export default defineConfig({
|
|
@@ -74,7 +80,40 @@ export default defineConfig({
|
|
|
74
80
|
});
|
|
75
81
|
`);
|
|
76
82
|
|
|
77
|
-
|
|
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';
|
|
78
117
|
|
|
79
118
|
function App() {
|
|
80
119
|
const count = useSignal(0);
|
|
@@ -95,31 +134,6 @@ function App() {
|
|
|
95
134
|
|
|
96
135
|
mount(<App />, '#app');
|
|
97
136
|
`);
|
|
98
|
-
} else {
|
|
99
|
-
writeFileSync(join(root, 'vite.config.js'), `import { defineConfig } from 'vite';
|
|
100
|
-
|
|
101
|
-
export default defineConfig({});
|
|
102
|
-
`);
|
|
103
|
-
|
|
104
|
-
writeFileSync(join(root, 'src', 'main.js'), `import { h, mount, signal } from 'what-framework';
|
|
105
|
-
|
|
106
|
-
function App() {
|
|
107
|
-
const count = signal(0);
|
|
108
|
-
|
|
109
|
-
return h('main', { class: 'app-shell' },
|
|
110
|
-
h('h1', null, 'What Framework'),
|
|
111
|
-
h('p', null, 'Runtime h() path (advanced).'),
|
|
112
|
-
h('section', { class: 'counter' },
|
|
113
|
-
h('button', { onClick: () => count.set(c => c - 1) }, '-'),
|
|
114
|
-
h('output', null, () => count()),
|
|
115
|
-
h('button', { onClick: () => count.set(c => c + 1) }, '+'),
|
|
116
|
-
),
|
|
117
|
-
);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
mount(h(App), '#app');
|
|
121
|
-
`);
|
|
122
|
-
}
|
|
123
137
|
|
|
124
138
|
writeFileSync(join(root, 'src', 'styles.css'), `:root {
|
|
125
139
|
color-scheme: light;
|
|
@@ -190,13 +204,13 @@ Open [http://localhost:5173](http://localhost:5173).
|
|
|
190
204
|
## Notes
|
|
191
205
|
|
|
192
206
|
- Canonical package name is \`what-framework\`.
|
|
193
|
-
-
|
|
194
|
-
-
|
|
195
|
-
- 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\`.
|
|
196
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\`.
|
|
197
211
|
`);
|
|
198
212
|
|
|
199
|
-
console.log(`\nCreated ${projectName}
|
|
213
|
+
console.log(`\nCreated ${projectName}.`);
|
|
200
214
|
console.log('Next steps:');
|
|
201
215
|
console.log(` cd ${projectName}`);
|
|
202
216
|
console.log(' npm install');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-what",
|
|
3
|
-
"version": "0.5.
|
|
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": "
|
|
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
|
}
|