create-vite-extra 4.2.0 → 5.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/LICENSE +12 -6
- package/README.md +51 -66
- package/dist/index.js +585 -0
- package/package.json +20 -10
- package/template-deno-lit/README.md +3 -3
- package/template-deno-lit/deno.json +3 -3
- package/template-deno-lit/index.html +2 -2
- package/template-deno-lit/public/favicon.svg +1 -0
- package/template-deno-lit/public/icons.svg +24 -0
- package/template-deno-lit/src/assets/hero.png +0 -0
- package/template-deno-lit/src/index.css +14 -20
- package/template-deno-lit/src/my-element.js +372 -67
- package/template-deno-lit/vite.config.js +1 -1
- package/template-deno-lit-ts/README.md +2 -2
- package/template-deno-lit-ts/deno.json +3 -3
- package/template-deno-lit-ts/index.html +3 -3
- package/template-deno-lit-ts/public/favicon.svg +1 -0
- package/template-deno-lit-ts/public/icons.svg +24 -0
- package/template-deno-lit-ts/src/assets/hero.png +0 -0
- package/template-deno-lit-ts/src/index.css +13 -28
- package/template-deno-lit-ts/src/my-element.ts +373 -68
- package/template-deno-lit-ts/tsconfig.json +20 -2
- package/template-deno-lit-ts/vite.config.ts +1 -1
- package/template-deno-preact/README.md +2 -2
- package/template-deno-preact/deno.json +5 -5
- package/template-deno-preact/index.html +1 -1
- package/template-deno-preact/public/favicon.svg +1 -0
- package/template-deno-preact/public/icons.svg +24 -0
- package/template-deno-preact/src/app.css +185 -16
- package/template-deno-preact/src/app.jsx +88 -21
- package/template-deno-preact/src/assets/hero.png +0 -0
- package/template-deno-preact/src/index.css +88 -46
- package/template-deno-preact/src/main.jsx +1 -1
- package/template-deno-preact-ts/README.md +2 -2
- package/template-deno-preact-ts/deno.json +5 -5
- package/template-deno-preact-ts/index.html +1 -1
- package/template-deno-preact-ts/public/favicon.svg +1 -0
- package/template-deno-preact-ts/public/icons.svg +24 -0
- package/template-deno-preact-ts/src/app.css +185 -16
- package/template-deno-preact-ts/src/app.tsx +88 -21
- package/template-deno-preact-ts/src/assets/hero.png +0 -0
- package/template-deno-preact-ts/src/index.css +88 -46
- package/template-deno-preact-ts/src/main.tsx +2 -2
- package/template-deno-react/README.md +2 -2
- package/template-deno-react/deno.json +5 -5
- package/template-deno-react/index.html +1 -1
- package/template-deno-react/public/favicon.svg +1 -0
- package/template-deno-react/public/icons.svg +24 -0
- package/template-deno-react/src/App.css +169 -28
- package/template-deno-react/src/App.jsx +107 -21
- package/template-deno-react/src/assets/hero.png +0 -0
- package/template-deno-react/src/index.css +88 -46
- package/template-deno-react/src/main.jsx +1 -1
- package/template-deno-react-ts/README.md +2 -2
- package/template-deno-react-ts/deno.json +5 -5
- package/template-deno-react-ts/index.html +1 -1
- package/template-deno-react-ts/public/favicon.svg +1 -0
- package/template-deno-react-ts/public/icons.svg +24 -0
- package/template-deno-react-ts/src/App.css +169 -28
- package/template-deno-react-ts/src/App.tsx +107 -21
- package/template-deno-react-ts/src/assets/hero.png +0 -0
- package/template-deno-react-ts/src/index.css +88 -46
- package/template-deno-react-ts/src/main.tsx +2 -2
- package/template-deno-solid/README.md +2 -2
- package/template-deno-solid/deno.json +5 -5
- package/template-deno-solid/index.html +2 -2
- package/template-deno-solid/public/favicon.svg +1 -0
- package/template-deno-solid/public/icons.svg +24 -0
- package/template-deno-solid/src/App.css +175 -19
- package/template-deno-solid/src/App.jsx +90 -23
- package/template-deno-solid/src/assets/hero.png +0 -0
- package/template-deno-solid/src/index.css +88 -46
- package/template-deno-solid/src/index.jsx +8 -0
- package/template-deno-solid-ts/README.md +2 -2
- package/template-deno-solid-ts/deno.json +5 -5
- package/template-deno-solid-ts/index.html +2 -2
- package/template-deno-solid-ts/public/favicon.svg +1 -0
- package/template-deno-solid-ts/public/icons.svg +24 -0
- package/template-deno-solid-ts/src/App.css +175 -19
- package/template-deno-solid-ts/src/App.tsx +90 -23
- package/template-deno-solid-ts/src/assets/hero.png +0 -0
- package/template-deno-solid-ts/src/index.css +88 -46
- package/template-deno-solid-ts/src/index.tsx +8 -0
- package/template-deno-svelte/README.md +2 -2
- package/template-deno-svelte/deno.json +5 -5
- package/template-deno-svelte/index.html +1 -1
- package/template-deno-svelte/public/favicon.svg +1 -0
- package/template-deno-svelte/public/icons.svg +24 -0
- package/template-deno-svelte/src/App.svelte +79 -38
- package/template-deno-svelte/src/app.css +263 -47
- package/template-deno-svelte/src/assets/hero.png +0 -0
- package/template-deno-svelte/src/lib/Counter.svelte +1 -6
- package/template-deno-svelte/src/main.js +1 -1
- package/template-deno-svelte-ts/README.md +2 -2
- package/template-deno-svelte-ts/deno.json +5 -5
- package/template-deno-svelte-ts/index.html +1 -1
- package/template-deno-svelte-ts/public/favicon.svg +1 -0
- package/template-deno-svelte-ts/public/icons.svg +24 -0
- package/template-deno-svelte-ts/src/App.svelte +80 -39
- package/template-deno-svelte-ts/src/app.css +263 -47
- package/template-deno-svelte-ts/src/assets/hero.png +0 -0
- package/template-deno-svelte-ts/src/lib/Counter.svelte +2 -2
- package/template-deno-svelte-ts/src/main.ts +1 -1
- package/template-deno-vanilla/deno.json +3 -3
- package/template-deno-vanilla/index.html +2 -2
- package/template-deno-vanilla/public/favicon.svg +1 -0
- package/template-deno-vanilla/public/icons.svg +24 -0
- package/template-deno-vanilla/src/assets/hero.png +0 -0
- package/template-deno-vanilla/src/assets/javascript.svg +1 -0
- package/template-deno-vanilla/src/counter.js +2 -2
- package/template-deno-vanilla/src/main.js +51 -17
- package/template-deno-vanilla/src/style.css +260 -61
- package/template-deno-vanilla-ts/deno.json +3 -3
- package/template-deno-vanilla-ts/index.html +1 -1
- package/template-deno-vanilla-ts/public/favicon.svg +1 -0
- package/template-deno-vanilla-ts/public/icons.svg +24 -0
- package/template-deno-vanilla-ts/src/assets/hero.png +0 -0
- package/template-deno-vanilla-ts/src/assets/typescript.svg +1 -0
- package/template-deno-vanilla-ts/src/counter.ts +1 -1
- package/template-deno-vanilla-ts/src/main.ts +52 -16
- package/template-deno-vanilla-ts/src/style.css +260 -61
- package/template-deno-vue/README.md +2 -2
- package/template-deno-vue/deno.json +5 -5
- package/template-deno-vue/index.html +1 -1
- package/template-deno-vue/public/favicon.svg +1 -0
- package/template-deno-vue/public/icons.svg +24 -0
- package/template-deno-vue/src/App.vue +1 -28
- package/template-deno-vue/src/assets/hero.png +0 -0
- package/template-deno-vue/src/components/HelloWorld.vue +83 -30
- package/template-deno-vue/src/main.js +1 -1
- package/template-deno-vue/src/style.css +263 -46
- package/template-deno-vue-ts/README.md +2 -2
- package/template-deno-vue-ts/deno.json +5 -5
- package/template-deno-vue-ts/index.html +1 -1
- package/template-deno-vue-ts/public/favicon.svg +1 -0
- package/template-deno-vue-ts/public/icons.svg +24 -0
- package/template-deno-vue-ts/src/App.vue +1 -28
- package/template-deno-vue-ts/src/assets/hero.png +0 -0
- package/template-deno-vue-ts/src/components/HelloWorld.vue +83 -28
- package/template-deno-vue-ts/src/main.ts +1 -1
- package/template-deno-vue-ts/src/style.css +263 -46
- package/template-library/index.d.ts +1 -1
- package/template-library/index.html +3 -3
- package/template-library/package.json +5 -9
- package/template-library/public/favicon.svg +1 -0
- package/template-library/public/icons.svg +24 -0
- package/template-library/src/assets/hero.png +0 -0
- package/template-library/src/assets/javascript.svg +1 -0
- package/template-library/src/main.js +60 -0
- package/template-library/src/style.css +296 -0
- package/template-library/vite.config.js +1 -1
- package/template-library-ts/index.d.ts +1 -1
- package/template-library-ts/index.html +2 -2
- package/template-library-ts/package.json +6 -10
- package/template-library-ts/public/favicon.svg +1 -0
- package/template-library-ts/public/icons.svg +24 -0
- package/template-library-ts/src/assets/hero.png +0 -0
- package/template-library-ts/src/assets/typescript.svg +1 -0
- package/template-library-ts/src/main.ts +51 -14
- package/template-library-ts/src/style.css +260 -61
- package/template-library-ts/tsconfig.json +6 -7
- package/template-library-ts/vite.config.ts +1 -1
- package/template-ssr-preact/index.html +1 -1
- package/template-ssr-preact/package.json +4 -4
- package/template-ssr-preact/public/favicon.svg +1 -0
- package/template-ssr-preact/public/icons.svg +24 -0
- package/template-ssr-preact/src/app.css +185 -17
- package/template-ssr-preact/src/app.jsx +88 -20
- package/template-ssr-preact/src/assets/hero.png +0 -0
- package/template-ssr-preact/src/index.css +88 -46
- package/template-ssr-preact-ts/index.html +1 -1
- package/template-ssr-preact-ts/package.json +7 -7
- package/template-ssr-preact-ts/public/favicon.svg +1 -0
- package/template-ssr-preact-ts/public/icons.svg +24 -0
- package/template-ssr-preact-ts/src/app.css +185 -17
- package/template-ssr-preact-ts/src/app.tsx +88 -20
- package/template-ssr-preact-ts/src/assets/hero.png +0 -0
- package/template-ssr-preact-ts/src/index.css +88 -46
- package/template-ssr-preact-ts/tsconfig.app.json +30 -0
- package/template-ssr-preact-ts/tsconfig.json +5 -29
- package/template-ssr-preact-ts/tsconfig.node.json +5 -5
- package/template-ssr-react/README.md +16 -0
- package/template-ssr-react/index.html +1 -1
- package/template-ssr-react/package.json +3 -3
- package/template-ssr-react/public/favicon.svg +1 -0
- package/template-ssr-react/public/icons.svg +24 -0
- package/template-ssr-react/src/App.css +169 -28
- package/template-ssr-react/src/App.jsx +107 -20
- package/template-ssr-react/src/assets/hero.png +0 -0
- package/template-ssr-react/src/index.css +88 -46
- package/template-ssr-react-streaming/index.html +1 -1
- package/template-ssr-react-streaming/package.json +2 -2
- package/template-ssr-react-streaming/public/favicon.svg +1 -0
- package/template-ssr-react-streaming/public/icons.svg +24 -0
- package/template-ssr-react-streaming/src/App.css +169 -28
- package/template-ssr-react-streaming/src/App.jsx +107 -20
- package/template-ssr-react-streaming/src/assets/hero.png +0 -0
- package/template-ssr-react-streaming/src/index.css +88 -46
- package/template-ssr-react-streaming-ts/index.html +1 -1
- package/template-ssr-react-streaming-ts/package.json +6 -6
- package/template-ssr-react-streaming-ts/public/favicon.svg +1 -0
- package/template-ssr-react-streaming-ts/public/icons.svg +24 -0
- package/template-ssr-react-streaming-ts/src/App.css +169 -28
- package/template-ssr-react-streaming-ts/src/App.tsx +107 -20
- package/template-ssr-react-streaming-ts/src/assets/hero.png +0 -0
- package/template-ssr-react-streaming-ts/src/index.css +88 -46
- package/template-ssr-react-streaming-ts/tsconfig.app.json +25 -0
- package/template-ssr-react-streaming-ts/tsconfig.json +5 -24
- package/template-ssr-react-streaming-ts/tsconfig.node.json +5 -5
- package/template-ssr-react-ts/README.md +73 -0
- package/template-ssr-react-ts/index.html +1 -1
- package/template-ssr-react-ts/package.json +6 -6
- package/template-ssr-react-ts/public/favicon.svg +1 -0
- package/template-ssr-react-ts/public/icons.svg +24 -0
- package/template-ssr-react-ts/src/App.css +169 -28
- package/template-ssr-react-ts/src/App.tsx +107 -20
- package/template-ssr-react-ts/src/assets/hero.png +0 -0
- package/template-ssr-react-ts/src/index.css +88 -46
- package/template-ssr-react-ts/tsconfig.app.json +25 -0
- package/template-ssr-react-ts/tsconfig.json +5 -24
- package/template-ssr-react-ts/tsconfig.node.json +5 -5
- package/template-ssr-solid/README.md +28 -0
- package/template-ssr-solid/index.html +1 -1
- package/template-ssr-solid/package.json +3 -3
- package/template-ssr-solid/public/favicon.svg +1 -0
- package/template-ssr-solid/public/icons.svg +24 -0
- package/template-ssr-solid/src/App.css +175 -19
- package/template-ssr-solid/src/App.jsx +90 -22
- package/template-ssr-solid/src/assets/hero.png +0 -0
- package/template-ssr-solid/src/index.css +88 -46
- package/template-ssr-solid-ts/README.md +28 -0
- package/template-ssr-solid-ts/index.html +1 -1
- package/template-ssr-solid-ts/package.json +5 -5
- package/template-ssr-solid-ts/public/favicon.svg +1 -0
- package/template-ssr-solid-ts/public/icons.svg +24 -0
- package/template-ssr-solid-ts/src/App.css +175 -19
- package/template-ssr-solid-ts/src/App.tsx +90 -22
- package/template-ssr-solid-ts/src/assets/hero.png +0 -0
- package/template-ssr-solid-ts/src/index.css +88 -46
- package/template-ssr-solid-ts/tsconfig.app.json +26 -0
- package/template-ssr-solid-ts/tsconfig.json +5 -25
- package/template-ssr-solid-ts/tsconfig.node.json +5 -5
- package/template-ssr-svelte/README.md +0 -4
- package/template-ssr-svelte/index.html +1 -1
- package/template-ssr-svelte/package.json +3 -3
- package/template-ssr-svelte/public/favicon.svg +1 -0
- package/template-ssr-svelte/public/icons.svg +24 -0
- package/template-ssr-svelte/src/App.svelte +79 -37
- package/template-ssr-svelte/src/app.css +263 -47
- package/template-ssr-svelte/src/assets/hero.png +0 -0
- package/template-ssr-svelte/src/lib/Counter.svelte +1 -6
- package/template-ssr-svelte-ts/README.md +1 -1
- package/template-ssr-svelte-ts/index.html +1 -1
- package/template-ssr-svelte-ts/package.json +9 -9
- package/template-ssr-svelte-ts/public/favicon.svg +1 -0
- package/template-ssr-svelte-ts/public/icons.svg +24 -0
- package/template-ssr-svelte-ts/src/App.svelte +80 -38
- package/template-ssr-svelte-ts/src/app.css +263 -47
- package/template-ssr-svelte-ts/src/assets/hero.png +0 -0
- package/template-ssr-svelte-ts/src/lib/Counter.svelte +2 -2
- package/template-ssr-svelte-ts/tsconfig.app.json +20 -0
- package/template-ssr-svelte-ts/tsconfig.json +5 -19
- package/template-ssr-svelte-ts/tsconfig.node.json +16 -4
- package/template-ssr-transform/package.json +1 -1
- package/template-ssr-vanilla/index.html +2 -2
- package/template-ssr-vanilla/package.json +1 -1
- package/template-ssr-vanilla/public/favicon.svg +1 -0
- package/template-ssr-vanilla/public/icons.svg +24 -0
- package/template-ssr-vanilla/src/assets/hero.png +0 -0
- package/template-ssr-vanilla/src/assets/javascript.svg +1 -0
- package/template-ssr-vanilla/src/counter.js +1 -1
- package/template-ssr-vanilla/src/entry-client.js +0 -1
- package/template-ssr-vanilla/src/entry-server.js +52 -15
- package/template-ssr-vanilla/src/style.css +260 -61
- package/template-ssr-vanilla-ts/index.html +1 -1
- package/template-ssr-vanilla-ts/package.json +4 -4
- package/template-ssr-vanilla-ts/public/favicon.svg +1 -0
- package/template-ssr-vanilla-ts/public/icons.svg +24 -0
- package/template-ssr-vanilla-ts/src/assets/hero.png +0 -0
- package/template-ssr-vanilla-ts/src/assets/typescript.svg +1 -0
- package/template-ssr-vanilla-ts/src/counter.ts +1 -1
- package/template-ssr-vanilla-ts/src/entry-client.ts +0 -1
- package/template-ssr-vanilla-ts/src/entry-server.ts +52 -15
- package/template-ssr-vanilla-ts/src/style.css +260 -61
- package/template-ssr-vanilla-ts/tsconfig.json +6 -7
- package/template-ssr-vue/README.md +1 -3
- package/template-ssr-vue/index.html +1 -1
- package/template-ssr-vue/package.json +3 -3
- package/template-ssr-vue/public/favicon.svg +1 -0
- package/template-ssr-vue/public/icons.svg +24 -0
- package/template-ssr-vue/src/App.vue +1 -27
- package/template-ssr-vue/src/assets/hero.png +0 -0
- package/template-ssr-vue/src/components/HelloWorld.vue +83 -30
- package/template-ssr-vue/src/style.css +263 -46
- package/template-ssr-vue-streaming/index.html +1 -1
- package/template-ssr-vue-streaming/package.json +3 -3
- package/template-ssr-vue-streaming/public/favicon.svg +1 -0
- package/template-ssr-vue-streaming/public/icons.svg +24 -0
- package/template-ssr-vue-streaming/src/App.vue +1 -27
- package/template-ssr-vue-streaming/src/assets/hero.png +0 -0
- package/template-ssr-vue-streaming/src/components/HelloWorld.vue +83 -30
- package/template-ssr-vue-streaming/src/style.css +263 -46
- package/template-ssr-vue-streaming-ts/index.html +1 -1
- package/template-ssr-vue-streaming-ts/package.json +8 -7
- package/template-ssr-vue-streaming-ts/public/favicon.svg +1 -0
- package/template-ssr-vue-streaming-ts/public/icons.svg +24 -0
- package/template-ssr-vue-streaming-ts/src/App.vue +1 -27
- package/template-ssr-vue-streaming-ts/src/assets/hero.png +0 -0
- package/template-ssr-vue-streaming-ts/src/components/HelloWorld.vue +83 -28
- package/template-ssr-vue-streaming-ts/src/style.css +263 -46
- package/template-ssr-vue-streaming-ts/tsconfig.app.json +14 -0
- package/template-ssr-vue-streaming-ts/tsconfig.json +5 -24
- package/template-ssr-vue-streaming-ts/tsconfig.node.json +5 -5
- package/template-ssr-vue-ts/README.md +1 -12
- package/template-ssr-vue-ts/index.html +1 -1
- package/template-ssr-vue-ts/package.json +9 -9
- package/template-ssr-vue-ts/public/favicon.svg +1 -0
- package/template-ssr-vue-ts/public/icons.svg +24 -0
- package/template-ssr-vue-ts/src/App.vue +1 -27
- package/template-ssr-vue-ts/src/assets/hero.png +0 -0
- package/template-ssr-vue-ts/src/components/HelloWorld.vue +83 -28
- package/template-ssr-vue-ts/src/style.css +263 -46
- package/template-ssr-vue-ts/tsconfig.app.json +14 -0
- package/template-ssr-vue-ts/tsconfig.json +5 -24
- package/template-ssr-vue-ts/tsconfig.node.json +5 -5
- package/index.js +0 -708
- package/template-deno-lit-ts/src/vite-env.d.ts +0 -1
- package/template-deno-preact-ts/src/vite-env.d.ts +0 -1
- package/template-deno-react-ts/src/vite-env.d.ts +0 -1
- package/template-deno-svelte/src/vite-env.d.ts +0 -2
- package/template-deno-svelte-ts/src/vite-env.d.ts +0 -2
- package/template-deno-vanilla-ts/src/vite-env.d.ts +0 -1
- package/template-deno-vue-ts/src/vite-env.d.ts +0 -7
- package/template-library/main.js +0 -23
- package/template-library/style.css +0 -97
- package/template-library-ts/src/vite-env.d.ts +0 -1
- package/template-ssr-preact-ts/src/vite-env.d.ts +0 -1
- package/template-ssr-react-streaming-ts/src/vite-env.d.ts +0 -1
- package/template-ssr-react-ts/src/vite-env.d.ts +0 -1
- package/template-ssr-solid-ts/src/vite-env.d.ts +0 -1
- package/template-ssr-svelte/src/vite-env.d.ts +0 -2
- package/template-ssr-svelte-ts/src/vite-env.d.ts +0 -2
- package/template-ssr-vanilla-ts/src/vite-env.d.ts +0 -1
- package/template-ssr-vue-streaming-ts/src/vite-env.d.ts +0 -7
- package/template-ssr-vue-ts/src/vite-env.d.ts +0 -7
- /package/template-deno-lit/{public → src/assets}/vite.svg +0 -0
- /package/template-deno-lit-ts/{public → src/assets}/vite.svg +0 -0
- /package/template-deno-preact/{public → src/assets}/vite.svg +0 -0
- /package/template-deno-preact-ts/{public → src/assets}/vite.svg +0 -0
- /package/template-deno-react/{public → src/assets}/vite.svg +0 -0
- /package/template-deno-react-ts/{public → src/assets}/vite.svg +0 -0
- /package/template-deno-solid/{public → src/assets}/vite.svg +0 -0
- /package/template-deno-solid-ts/{public → src/assets}/vite.svg +0 -0
- /package/template-deno-svelte/{public → src/assets}/vite.svg +0 -0
- /package/template-deno-svelte-ts/{public → src/assets}/vite.svg +0 -0
- /package/template-deno-vanilla/{public → src/assets}/vite.svg +0 -0
- /package/template-deno-vanilla-ts/{public → src/assets}/vite.svg +0 -0
- /package/template-deno-vue/{public → src/assets}/vite.svg +0 -0
- /package/template-deno-vue-ts/{public → src/assets}/vite.svg +0 -0
- /package/template-library/{public → src/assets}/vite.svg +0 -0
- /package/template-library/{javascript.svg → src/javascript.svg} +0 -0
- /package/template-library-ts/{public → src/assets}/vite.svg +0 -0
- /package/template-ssr-preact/{public → src/assets}/vite.svg +0 -0
- /package/template-ssr-preact-ts/{public → src/assets}/vite.svg +0 -0
- /package/template-ssr-react/{public → src/assets}/vite.svg +0 -0
- /package/template-ssr-react-streaming/{public → src/assets}/vite.svg +0 -0
- /package/template-ssr-react-streaming-ts/{public → src/assets}/vite.svg +0 -0
- /package/template-ssr-react-ts/{public → src/assets}/vite.svg +0 -0
- /package/template-ssr-solid/{public → src/assets}/vite.svg +0 -0
- /package/template-ssr-solid-ts/{public → src/assets}/vite.svg +0 -0
- /package/template-ssr-svelte/{public → src/assets}/vite.svg +0 -0
- /package/template-ssr-svelte-ts/{public → src/assets}/vite.svg +0 -0
- /package/template-ssr-vanilla/{public → src/assets}/vite.svg +0 -0
- /package/template-ssr-vanilla-ts/{public → src/assets}/vite.svg +0 -0
- /package/template-ssr-vue/{public → src/assets}/vite.svg +0 -0
- /package/template-ssr-vue-streaming/{public → src/assets}/vite.svg +0 -0
- /package/template-ssr-vue-streaming-ts/{public → src/assets}/vite.svg +0 -0
- /package/template-ssr-vue-ts/{public → src/assets}/vite.svg +0 -0
package/index.js
DELETED
|
@@ -1,708 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
// @ts-check
|
|
4
|
-
import fs from 'node:fs'
|
|
5
|
-
import path from 'node:path'
|
|
6
|
-
import { fileURLToPath } from 'node:url'
|
|
7
|
-
import minimist from 'minimist'
|
|
8
|
-
import prompts from 'prompts'
|
|
9
|
-
import colors from 'picocolors'
|
|
10
|
-
|
|
11
|
-
const {
|
|
12
|
-
blue,
|
|
13
|
-
cyan,
|
|
14
|
-
green,
|
|
15
|
-
redBright,
|
|
16
|
-
blueBright,
|
|
17
|
-
magenta,
|
|
18
|
-
red,
|
|
19
|
-
reset,
|
|
20
|
-
yellow,
|
|
21
|
-
magentaBright,
|
|
22
|
-
} = colors
|
|
23
|
-
|
|
24
|
-
// Avoids autoconversion to number of the project name by defining that the args
|
|
25
|
-
// non associated with an option ( _ ) needs to be parsed as a string. See #4606
|
|
26
|
-
const argv = minimist(process.argv.slice(2), {
|
|
27
|
-
string: ['_'],
|
|
28
|
-
boolean: ['overwrite'],
|
|
29
|
-
})
|
|
30
|
-
const cwd = process.cwd()
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @typedef {Object} Framework
|
|
34
|
-
* @property {string} name
|
|
35
|
-
* @property {string} [display]
|
|
36
|
-
* @property {(typeof colors.blue)} color
|
|
37
|
-
* @property {Framework[]} [variants]
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
/** @type {Framework[]} */
|
|
41
|
-
const FRAMEWORKS = [
|
|
42
|
-
{
|
|
43
|
-
name: 'ssr-vanilla',
|
|
44
|
-
color: yellow,
|
|
45
|
-
variants: [
|
|
46
|
-
{
|
|
47
|
-
name: 'ssr-vanilla',
|
|
48
|
-
display: 'JavaScript',
|
|
49
|
-
color: yellow,
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
name: 'ssr-vanilla-ts',
|
|
53
|
-
display: 'TypeScript',
|
|
54
|
-
color: blue,
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
name: 'ssr-vue',
|
|
60
|
-
color: green,
|
|
61
|
-
variants: [
|
|
62
|
-
{
|
|
63
|
-
name: 'ssr-vue-streaming',
|
|
64
|
-
display: 'Streaming',
|
|
65
|
-
color: green,
|
|
66
|
-
variants: [
|
|
67
|
-
{
|
|
68
|
-
name: 'ssr-vue-streaming',
|
|
69
|
-
display: 'JavaScript',
|
|
70
|
-
color: yellow,
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
name: 'ssr-vue-streaming-ts',
|
|
74
|
-
display: 'TypeScript',
|
|
75
|
-
color: blue,
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
name: 'ssr-vue',
|
|
81
|
-
display: 'Non-streaming',
|
|
82
|
-
color: green,
|
|
83
|
-
variants: [
|
|
84
|
-
{
|
|
85
|
-
name: 'ssr-vue',
|
|
86
|
-
display: 'JavaScript',
|
|
87
|
-
color: yellow,
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
name: 'ssr-vue-ts',
|
|
91
|
-
display: 'TypeScript',
|
|
92
|
-
color: blue,
|
|
93
|
-
},
|
|
94
|
-
],
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
name: 'ssr-react',
|
|
100
|
-
color: cyan,
|
|
101
|
-
variants: [
|
|
102
|
-
{
|
|
103
|
-
name: 'ssr-react-streaming',
|
|
104
|
-
display: 'Streaming',
|
|
105
|
-
color: cyan,
|
|
106
|
-
variants: [
|
|
107
|
-
{
|
|
108
|
-
name: 'ssr-react-streaming',
|
|
109
|
-
display: 'JavaScript',
|
|
110
|
-
color: yellow,
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
name: 'ssr-react-streaming-ts',
|
|
114
|
-
display: 'TypeScript',
|
|
115
|
-
color: blue,
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
name: 'ssr-react-swc-streaming',
|
|
119
|
-
display: 'JavaScript + SWC',
|
|
120
|
-
color: yellow,
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
name: 'ssr-react-swc-streaming-ts',
|
|
124
|
-
display: 'TypeScript + SWC',
|
|
125
|
-
color: blue,
|
|
126
|
-
},
|
|
127
|
-
],
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
name: 'ssr-react',
|
|
131
|
-
display: 'Non-streaming',
|
|
132
|
-
color: cyan,
|
|
133
|
-
variants: [
|
|
134
|
-
{
|
|
135
|
-
name: 'ssr-react',
|
|
136
|
-
display: 'JavaScript',
|
|
137
|
-
color: yellow,
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
name: 'ssr-react-ts',
|
|
141
|
-
display: 'TypeScript',
|
|
142
|
-
color: blue,
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
name: 'ssr-react-swc',
|
|
146
|
-
display: 'JavaScript + SWC',
|
|
147
|
-
color: yellow,
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
name: 'ssr-react-swc-ts',
|
|
151
|
-
display: 'TypeScript + SWC',
|
|
152
|
-
color: blue,
|
|
153
|
-
},
|
|
154
|
-
],
|
|
155
|
-
},
|
|
156
|
-
],
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
name: 'ssr-preact',
|
|
160
|
-
color: magenta,
|
|
161
|
-
variants: [
|
|
162
|
-
{
|
|
163
|
-
name: 'ssr-preact',
|
|
164
|
-
display: 'JavaScript',
|
|
165
|
-
color: yellow,
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
name: 'ssr-preact-ts',
|
|
169
|
-
display: 'TypeScript',
|
|
170
|
-
color: blue,
|
|
171
|
-
},
|
|
172
|
-
],
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
name: 'ssr-svelte',
|
|
176
|
-
color: red,
|
|
177
|
-
variants: [
|
|
178
|
-
{
|
|
179
|
-
name: 'ssr-svelte',
|
|
180
|
-
display: 'JavaScript',
|
|
181
|
-
color: yellow,
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
name: 'ssr-svelte-ts',
|
|
185
|
-
display: 'TypeScript',
|
|
186
|
-
color: blue,
|
|
187
|
-
},
|
|
188
|
-
],
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
name: 'ssr-solid',
|
|
192
|
-
color: blueBright,
|
|
193
|
-
variants: [
|
|
194
|
-
{
|
|
195
|
-
name: 'ssr-solid',
|
|
196
|
-
display: 'JavaScript',
|
|
197
|
-
color: yellow,
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
name: 'ssr-solid-ts',
|
|
201
|
-
display: 'TypeScript',
|
|
202
|
-
color: blue,
|
|
203
|
-
},
|
|
204
|
-
],
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
name: 'deno-vanilla',
|
|
208
|
-
color: yellow,
|
|
209
|
-
variants: [
|
|
210
|
-
{
|
|
211
|
-
name: 'deno-vanilla',
|
|
212
|
-
display: 'JavaScript',
|
|
213
|
-
color: yellow,
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
name: 'deno-vanilla-ts',
|
|
217
|
-
display: 'TypeScript',
|
|
218
|
-
color: blue,
|
|
219
|
-
},
|
|
220
|
-
],
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
name: 'deno-vue',
|
|
224
|
-
color: green,
|
|
225
|
-
variants: [
|
|
226
|
-
{
|
|
227
|
-
name: 'deno-vue',
|
|
228
|
-
display: 'JavaScript',
|
|
229
|
-
color: yellow,
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
name: 'deno-vue-ts',
|
|
233
|
-
display: 'TypeScript',
|
|
234
|
-
color: blue,
|
|
235
|
-
},
|
|
236
|
-
],
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
name: 'deno-react',
|
|
240
|
-
color: cyan,
|
|
241
|
-
variants: [
|
|
242
|
-
{
|
|
243
|
-
name: 'deno-react',
|
|
244
|
-
display: 'JavaScript',
|
|
245
|
-
color: yellow,
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
name: 'deno-react-ts',
|
|
249
|
-
display: 'TypeScript',
|
|
250
|
-
color: blue,
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
name: 'deno-react-swc',
|
|
254
|
-
display: 'JavaScript + SWC',
|
|
255
|
-
color: yellow,
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
name: 'deno-react-swc-ts',
|
|
259
|
-
display: 'TypeScript + SWC',
|
|
260
|
-
color: blue,
|
|
261
|
-
},
|
|
262
|
-
],
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
name: 'deno-preact',
|
|
266
|
-
color: magenta,
|
|
267
|
-
variants: [
|
|
268
|
-
{
|
|
269
|
-
name: 'deno-preact',
|
|
270
|
-
display: 'JavaScript',
|
|
271
|
-
color: yellow,
|
|
272
|
-
},
|
|
273
|
-
{
|
|
274
|
-
name: 'deno-preact-ts',
|
|
275
|
-
display: 'TypeScript',
|
|
276
|
-
color: blue,
|
|
277
|
-
},
|
|
278
|
-
],
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
name: 'deno-lit',
|
|
282
|
-
color: redBright,
|
|
283
|
-
variants: [
|
|
284
|
-
{
|
|
285
|
-
name: 'deno-lit',
|
|
286
|
-
display: 'JavaScript',
|
|
287
|
-
color: yellow,
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
name: 'deno-lit-ts',
|
|
291
|
-
display: 'TypeScript',
|
|
292
|
-
color: blue,
|
|
293
|
-
},
|
|
294
|
-
],
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
name: 'deno-svelte',
|
|
298
|
-
color: red,
|
|
299
|
-
variants: [
|
|
300
|
-
{
|
|
301
|
-
name: 'deno-svelte',
|
|
302
|
-
display: 'JavaScript',
|
|
303
|
-
color: yellow,
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
name: 'deno-svelte-ts',
|
|
307
|
-
display: 'TypeScript',
|
|
308
|
-
color: blue,
|
|
309
|
-
},
|
|
310
|
-
],
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
name: 'deno-solid',
|
|
314
|
-
color: blueBright,
|
|
315
|
-
variants: [
|
|
316
|
-
{
|
|
317
|
-
name: 'deno-solid',
|
|
318
|
-
display: 'JavaScript',
|
|
319
|
-
color: yellow,
|
|
320
|
-
},
|
|
321
|
-
{
|
|
322
|
-
name: 'deno-solid-ts',
|
|
323
|
-
display: 'TypeScript',
|
|
324
|
-
color: blue,
|
|
325
|
-
},
|
|
326
|
-
],
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
name: 'library',
|
|
330
|
-
color: magentaBright,
|
|
331
|
-
variants: [
|
|
332
|
-
{
|
|
333
|
-
name: 'library',
|
|
334
|
-
display: 'JavaScript',
|
|
335
|
-
color: yellow,
|
|
336
|
-
},
|
|
337
|
-
{
|
|
338
|
-
name: 'library-ts',
|
|
339
|
-
display: 'TypeScript',
|
|
340
|
-
color: blue,
|
|
341
|
-
},
|
|
342
|
-
],
|
|
343
|
-
},
|
|
344
|
-
{
|
|
345
|
-
name: 'ssr-transform',
|
|
346
|
-
color: redBright,
|
|
347
|
-
},
|
|
348
|
-
]
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* @param {Framework} framework
|
|
352
|
-
* @return {string[]}
|
|
353
|
-
*/
|
|
354
|
-
function flattenVariants(framework) {
|
|
355
|
-
if (framework.variants) {
|
|
356
|
-
return framework.variants.flatMap((variant) => flattenVariants(variant))
|
|
357
|
-
}
|
|
358
|
-
return [framework.name]
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
const TEMPLATES = FRAMEWORKS.flatMap(flattenVariants)
|
|
362
|
-
|
|
363
|
-
/** @type {Record<string, string>} */
|
|
364
|
-
const renameFiles = {
|
|
365
|
-
_gitignore: '.gitignore',
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
async function init() {
|
|
369
|
-
let targetDir = /** @type {string} */ (formatTargetDir(argv._[0]))
|
|
370
|
-
const argTemplate = argv.template || argv.t
|
|
371
|
-
|
|
372
|
-
const defaultTargetDir = 'vite-project'
|
|
373
|
-
const getProjectName = () => path.basename(path.resolve(targetDir))
|
|
374
|
-
|
|
375
|
-
/** @type {Record<string, any>} */
|
|
376
|
-
let result = {}
|
|
377
|
-
|
|
378
|
-
try {
|
|
379
|
-
result = await prompts(
|
|
380
|
-
[
|
|
381
|
-
{
|
|
382
|
-
type: targetDir ? null : 'text',
|
|
383
|
-
name: 'projectName',
|
|
384
|
-
message: reset('Project name:'),
|
|
385
|
-
initial: defaultTargetDir,
|
|
386
|
-
onState: (state) => {
|
|
387
|
-
targetDir = formatTargetDir(state.value) || defaultTargetDir
|
|
388
|
-
},
|
|
389
|
-
},
|
|
390
|
-
{
|
|
391
|
-
type: () =>
|
|
392
|
-
argv.overwrite
|
|
393
|
-
? null
|
|
394
|
-
: !fs.existsSync(targetDir) || isEmpty(targetDir)
|
|
395
|
-
? null
|
|
396
|
-
: 'confirm',
|
|
397
|
-
name: 'overwrite',
|
|
398
|
-
initial: argv.overwrite ? true : false,
|
|
399
|
-
message: () =>
|
|
400
|
-
(targetDir === '.'
|
|
401
|
-
? 'Current directory'
|
|
402
|
-
: `Target directory "${targetDir}"`) +
|
|
403
|
-
` is not empty. Remove existing files and continue?`,
|
|
404
|
-
},
|
|
405
|
-
{
|
|
406
|
-
// @ts-expect-error
|
|
407
|
-
type: (_, { overwrite } = {}) => {
|
|
408
|
-
if (overwrite === false) {
|
|
409
|
-
throw new Error(red('✖') + ' Operation cancelled')
|
|
410
|
-
}
|
|
411
|
-
return null
|
|
412
|
-
},
|
|
413
|
-
name: 'overwriteChecker',
|
|
414
|
-
},
|
|
415
|
-
{
|
|
416
|
-
type: () => (isValidPackageName(getProjectName()) ? null : 'text'),
|
|
417
|
-
name: 'packageName',
|
|
418
|
-
message: reset('Package name:'),
|
|
419
|
-
initial: () => toValidPackageName(getProjectName()),
|
|
420
|
-
validate: (dir) =>
|
|
421
|
-
isValidPackageName(dir) || 'Invalid package.json name',
|
|
422
|
-
},
|
|
423
|
-
{
|
|
424
|
-
type:
|
|
425
|
-
argTemplate && TEMPLATES.includes(argTemplate) ? null : 'select',
|
|
426
|
-
name: 'framework',
|
|
427
|
-
message:
|
|
428
|
-
typeof argTemplate === 'string' && !TEMPLATES.includes(argTemplate)
|
|
429
|
-
? reset(
|
|
430
|
-
`"${argTemplate}" isn't a valid template. Please choose from below: `,
|
|
431
|
-
)
|
|
432
|
-
: reset('Select a template:'),
|
|
433
|
-
initial: 0,
|
|
434
|
-
choices: FRAMEWORKS.map((framework) => {
|
|
435
|
-
const frameworkColor = framework.color
|
|
436
|
-
return {
|
|
437
|
-
title: frameworkColor(framework.display || framework.name),
|
|
438
|
-
value: framework,
|
|
439
|
-
}
|
|
440
|
-
}),
|
|
441
|
-
},
|
|
442
|
-
// Variant 1
|
|
443
|
-
{
|
|
444
|
-
/** @param {Framework} framework */
|
|
445
|
-
type: (framework) =>
|
|
446
|
-
framework && framework.variants ? 'select' : null,
|
|
447
|
-
name: 'variant',
|
|
448
|
-
message: reset('Select a variant:'),
|
|
449
|
-
/** @param {Framework} framework */
|
|
450
|
-
choices: (framework) =>
|
|
451
|
-
framework.variants?.map((variant) => {
|
|
452
|
-
const variantColor = variant.color
|
|
453
|
-
return {
|
|
454
|
-
title: variantColor(variant.display || variant.name),
|
|
455
|
-
value: variant.variants ? variant : variant.name,
|
|
456
|
-
}
|
|
457
|
-
}),
|
|
458
|
-
},
|
|
459
|
-
// Variant 2
|
|
460
|
-
{
|
|
461
|
-
/** @param {Framework} framework */
|
|
462
|
-
type: (framework) =>
|
|
463
|
-
framework && framework.variants ? 'select' : null,
|
|
464
|
-
name: 'variant',
|
|
465
|
-
message: reset('Select a variant:'),
|
|
466
|
-
/** @param {Framework} framework */
|
|
467
|
-
choices: (framework) =>
|
|
468
|
-
framework.variants?.map((variant) => {
|
|
469
|
-
const variantColor = variant.color
|
|
470
|
-
return {
|
|
471
|
-
title: variantColor(variant.display || variant.name),
|
|
472
|
-
value: variant.name,
|
|
473
|
-
}
|
|
474
|
-
}),
|
|
475
|
-
},
|
|
476
|
-
],
|
|
477
|
-
{
|
|
478
|
-
onCancel: () => {
|
|
479
|
-
throw new Error(red('✖') + ' Operation cancelled')
|
|
480
|
-
},
|
|
481
|
-
},
|
|
482
|
-
)
|
|
483
|
-
} catch (/** @type {any} */ cancelled) {
|
|
484
|
-
console.log(cancelled.message)
|
|
485
|
-
return
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
// user choice associated with prompts
|
|
489
|
-
const { framework, overwrite, packageName, variant } = result
|
|
490
|
-
|
|
491
|
-
const root = path.join(cwd, targetDir)
|
|
492
|
-
|
|
493
|
-
if (overwrite) {
|
|
494
|
-
emptyDir(root)
|
|
495
|
-
} else if (!fs.existsSync(root)) {
|
|
496
|
-
fs.mkdirSync(root, { recursive: true })
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
// determine template
|
|
500
|
-
let template = variant || framework?.name || argTemplate
|
|
501
|
-
let isReactSwc = false
|
|
502
|
-
if (template.includes('-swc')) {
|
|
503
|
-
isReactSwc = true
|
|
504
|
-
template = template.replace('-swc', '')
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
console.log(`\nScaffolding project in ${root}...`)
|
|
508
|
-
|
|
509
|
-
const templateDir = path.resolve(
|
|
510
|
-
fileURLToPath(import.meta.url),
|
|
511
|
-
'..',
|
|
512
|
-
`template-${template}`,
|
|
513
|
-
)
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* @param {string} file
|
|
517
|
-
* @param {string} [content]
|
|
518
|
-
*/
|
|
519
|
-
const write = (file, content) => {
|
|
520
|
-
const targetPath = renameFiles[file]
|
|
521
|
-
? path.join(root, renameFiles[file])
|
|
522
|
-
: path.join(root, file)
|
|
523
|
-
if (content) {
|
|
524
|
-
fs.writeFileSync(targetPath, content)
|
|
525
|
-
} else {
|
|
526
|
-
copy(path.join(templateDir, file), targetPath)
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
const files = fs.readdirSync(templateDir)
|
|
531
|
-
for (const file of files.filter((f) => f !== 'package.json')) {
|
|
532
|
-
write(file)
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
const isDeno = template.startsWith('deno-')
|
|
536
|
-
if (isDeno) {
|
|
537
|
-
if (isReactSwc) {
|
|
538
|
-
setupReactSwc(root, { isTs: template.endsWith('-ts'), isDeno: true })
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
console.log(`\nDone. Now run:\n`)
|
|
542
|
-
if (root !== cwd) {
|
|
543
|
-
console.log(` cd ${path.relative(cwd, root)}`)
|
|
544
|
-
}
|
|
545
|
-
console.log(' deno task dev')
|
|
546
|
-
console.log()
|
|
547
|
-
} else {
|
|
548
|
-
const pkg = JSON.parse(
|
|
549
|
-
fs.readFileSync(path.join(templateDir, `package.json`), 'utf-8'),
|
|
550
|
-
)
|
|
551
|
-
|
|
552
|
-
pkg.name = packageName || getProjectName()
|
|
553
|
-
|
|
554
|
-
write('package.json', JSON.stringify(pkg, null, 2))
|
|
555
|
-
|
|
556
|
-
if (isReactSwc) {
|
|
557
|
-
setupReactSwc(root, { isTs: template.endsWith('-ts'), isDeno: false })
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
const pkgInfo = pkgFromUserAgent(process.env.npm_config_user_agent)
|
|
561
|
-
const pkgManager = pkgInfo ? pkgInfo.name : 'npm'
|
|
562
|
-
|
|
563
|
-
console.log(`\nDone. Now run:\n`)
|
|
564
|
-
if (root !== cwd) {
|
|
565
|
-
console.log(` cd ${path.relative(cwd, root)}`)
|
|
566
|
-
}
|
|
567
|
-
switch (pkgManager) {
|
|
568
|
-
case 'yarn':
|
|
569
|
-
console.log(' yarn')
|
|
570
|
-
console.log(' yarn dev')
|
|
571
|
-
break
|
|
572
|
-
default:
|
|
573
|
-
console.log(` ${pkgManager} install`)
|
|
574
|
-
console.log(` ${pkgManager} run dev`)
|
|
575
|
-
break
|
|
576
|
-
}
|
|
577
|
-
console.log()
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
/**
|
|
582
|
-
* @param {string | undefined} targetDir
|
|
583
|
-
*/
|
|
584
|
-
function formatTargetDir(targetDir) {
|
|
585
|
-
return targetDir?.trim().replace(/\/+$/g, '')
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
/**
|
|
589
|
-
* @param {string} src
|
|
590
|
-
* @param {string} dest
|
|
591
|
-
*/
|
|
592
|
-
function copy(src, dest) {
|
|
593
|
-
const stat = fs.statSync(src)
|
|
594
|
-
if (stat.isDirectory()) {
|
|
595
|
-
copyDir(src, dest)
|
|
596
|
-
} else {
|
|
597
|
-
fs.copyFileSync(src, dest)
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
* @param {string} projectName
|
|
603
|
-
*/
|
|
604
|
-
function isValidPackageName(projectName) {
|
|
605
|
-
return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(
|
|
606
|
-
projectName,
|
|
607
|
-
)
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
/**
|
|
611
|
-
* @param {string} projectName
|
|
612
|
-
*/
|
|
613
|
-
function toValidPackageName(projectName) {
|
|
614
|
-
return projectName
|
|
615
|
-
.trim()
|
|
616
|
-
.toLowerCase()
|
|
617
|
-
.replace(/\s+/g, '-')
|
|
618
|
-
.replace(/^[._]/, '')
|
|
619
|
-
.replace(/[^a-z0-9-~]+/g, '-')
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
/**
|
|
623
|
-
* @param {string} srcDir
|
|
624
|
-
* @param {string} destDir
|
|
625
|
-
*/
|
|
626
|
-
function copyDir(srcDir, destDir) {
|
|
627
|
-
fs.mkdirSync(destDir, { recursive: true })
|
|
628
|
-
for (const file of fs.readdirSync(srcDir)) {
|
|
629
|
-
const srcFile = path.resolve(srcDir, file)
|
|
630
|
-
const destFile = path.resolve(destDir, file)
|
|
631
|
-
copy(srcFile, destFile)
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
/**
|
|
636
|
-
* @param {string} path
|
|
637
|
-
*/
|
|
638
|
-
function isEmpty(path) {
|
|
639
|
-
const files = fs.readdirSync(path)
|
|
640
|
-
return files.length === 0 || (files.length === 1 && files[0] === '.git')
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
/**
|
|
644
|
-
* @param {string} dir
|
|
645
|
-
*/
|
|
646
|
-
function emptyDir(dir) {
|
|
647
|
-
if (!fs.existsSync(dir)) {
|
|
648
|
-
return
|
|
649
|
-
}
|
|
650
|
-
for (const file of fs.readdirSync(dir)) {
|
|
651
|
-
fs.rmSync(path.resolve(dir, file), { recursive: true, force: true })
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
* @param {string | undefined} userAgent process.env.npm_config_user_agent
|
|
657
|
-
* @returns object | undefined
|
|
658
|
-
*/
|
|
659
|
-
function pkgFromUserAgent(userAgent) {
|
|
660
|
-
if (!userAgent) return undefined
|
|
661
|
-
const pkgSpec = userAgent.split(' ')[0]
|
|
662
|
-
const pkgSpecArr = pkgSpec.split('/')
|
|
663
|
-
return {
|
|
664
|
-
name: pkgSpecArr[0],
|
|
665
|
-
version: pkgSpecArr[1],
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
/**
|
|
670
|
-
* @param {string} root
|
|
671
|
-
* @param {{ isTs: boolean, isDeno: boolean }} options
|
|
672
|
-
*/
|
|
673
|
-
function setupReactSwc(root, { isTs, isDeno }) {
|
|
674
|
-
if (isDeno) {
|
|
675
|
-
editFile(path.resolve(root, 'deno.json'), (content) => {
|
|
676
|
-
return content.replace(
|
|
677
|
-
/"@vitejs\/plugin-react": ".+?"/,
|
|
678
|
-
`"@vitejs/plugin-react-swc": "npm:@vitejs/plugin-react-swc@^4.2.2"`,
|
|
679
|
-
)
|
|
680
|
-
})
|
|
681
|
-
} else {
|
|
682
|
-
editFile(path.resolve(root, 'package.json'), (content) => {
|
|
683
|
-
return content.replace(
|
|
684
|
-
/"@vitejs\/plugin-react": ".+?"/,
|
|
685
|
-
`"@vitejs/plugin-react-swc": "^4.2.2"`,
|
|
686
|
-
)
|
|
687
|
-
})
|
|
688
|
-
}
|
|
689
|
-
editFile(
|
|
690
|
-
path.resolve(root, `vite.config.${isTs ? 'ts' : 'js'}`),
|
|
691
|
-
(content) => {
|
|
692
|
-
return content.replace('@vitejs/plugin-react', '@vitejs/plugin-react-swc')
|
|
693
|
-
},
|
|
694
|
-
)
|
|
695
|
-
}
|
|
696
|
-
|
|
697
|
-
/**
|
|
698
|
-
* @param {string} file
|
|
699
|
-
* @param {(content: string) => string} callback
|
|
700
|
-
*/
|
|
701
|
-
function editFile(file, callback) {
|
|
702
|
-
const content = fs.readFileSync(file, 'utf-8')
|
|
703
|
-
fs.writeFileSync(file, callback(content), 'utf-8')
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
init().catch((e) => {
|
|
707
|
-
console.error(e)
|
|
708
|
-
})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|