@kunver/new 1.2.0 → 1.3.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.
- package/README.MD +5 -7
- package/dist/index.js +43 -7
- package/package.json +5 -3
package/README.MD
CHANGED
|
@@ -5,27 +5,25 @@ Cli tool for creating new projects with pre-configured settings.
|
|
|
5
5
|
## Using
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
pnpx | npx |
|
|
8
|
+
pnpx | npx | bunx @kunver/new
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Starters
|
|
12
12
|
|
|
13
13
|
### Ready to use
|
|
14
14
|
|
|
15
|
-
✅
|
|
15
|
+
✅ React + TypeScript + Tailwind + Prettierconfig
|
|
16
|
+
|
|
17
|
+
✅ Wxt + Svelte + TypeScript + Tailwind + Prettierconfig
|
|
16
18
|
|
|
17
19
|
### Work in progress
|
|
18
20
|
|
|
19
|
-
🟡 React + TypeScript + Tailwind + Prettierconfig
|
|
21
|
+
🟡 Wxt + React + TypeScript + Tailwind + Prettierconfig
|
|
20
22
|
|
|
21
23
|
### Will be added
|
|
22
24
|
|
|
23
25
|
🟡 Next.js + TypeScript + Tailwind + Prettierconfig
|
|
24
26
|
|
|
25
|
-
🟡 Wxt + React + TypeScript + Tailwind + Prettierconfig
|
|
26
|
-
|
|
27
|
-
🟡 Wxt + Svelte + TypeScript + Tailwind + Prettierconfig
|
|
28
|
-
|
|
29
27
|
🟡 Astro + TypeScript + Tailwind + Prettierconfig
|
|
30
28
|
|
|
31
29
|
🟡 Cpp + Cmake + bash Scripts
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{input as
|
|
3
|
-
`+
|
|
2
|
+
import{input as It,select as T}from"@inquirer/prompts";import{spawn as ct}from"child_process";import y from"chalk";import lt from"ora";async function f(s,t,i){return new Promise(e=>{let n;switch(s){case"pnpm":n=`cd ${t} && pnpm install`;break;case"npm":n=`cd ${t} && npm install`;break;case"bun":n=`cd ${t} && bun install`;break;default:n=`cd ${t} && pnpm install`}let r=ct(n,{shell:!0,cwd:i}),o=lt("Installing dependencies with "+y.blue(s)).start();o.color="white",r.on("close",a=>{a==0?(o.succeed("Installed dependencies for "+y.blue(t)),e(!0)):(o.fail("Failed to install dependencies for "+y.blue(t)),e(!1))})})}import{readFileSync as pt,writeFileSync as R}from"fs";import{spawn as dt}from"child_process";import v from"ora";import mt from"chalk";function ut(s,t){let i=`${t}/${s}/vite.config.ts`,e=v("Editing vite.config.ts...").start();e.color="blue";try{let n=pt(i,"utf-8");n.includes('import tailwindcss from "@tailwindcss/vite"')?e.info("Tailwind import already exists in vite.config.ts"):(n=`import tailwindcss from "@tailwindcss/vite"
|
|
3
|
+
`+n,n=n.replace(/plugins:\s*\[.*?\]/,"plugins: [react(), tailwindcss()]"),R(i,n,"utf-8"),e.succeed("Updated vite.config.ts with Tailwind import"))}catch(n){e.fail(`Failed to edit vite.config.ts: ${n}`),console.error(n)}}function ft(s,t){let i=`${t}/${s}/src/index.css`,e='@import "tailwindcss";',n=v("Adding Tailwind directive to index.css...").start();R(i,e,"utf-8"),n.succeed("Added Tailwind directive to index.css")}async function W(s,t,i){return new Promise(e=>{let n="cd "+t+" && "+s+" install tailwindcss @tailwindcss/vite",r=dt(n,{shell:!0,cwd:i}),o=v("Installing Tailwind with "+mt.blue(s)).start();o.color="blue",o.start(),r.on("close",a=>{a===0?(o.succeed("Installed tailwind"),ut(t,i),ft(t,i),e(!0)):(o.fail("Failed to install tailwind"),e(!1))})})}var I=`
|
|
4
4
|
{
|
|
5
5
|
"semi": false,
|
|
6
6
|
"trailingComma": "all",
|
|
@@ -12,7 +12,7 @@ import{input as _,select as I}from"@inquirer/prompts";import{spawn as B}from"chi
|
|
|
12
12
|
"jsxBracketSameLine": false,
|
|
13
13
|
"arrowParens": "avoid"
|
|
14
14
|
}
|
|
15
|
-
`,
|
|
15
|
+
`,O=`
|
|
16
16
|
#!/bin/bash
|
|
17
17
|
|
|
18
18
|
# Exit immediately if a command fails
|
|
@@ -42,9 +42,9 @@ if [ $? -ne 0 ]; then
|
|
|
42
42
|
echo "\u274C Failed to switch back to the 'dev' branch."
|
|
43
43
|
exit 1
|
|
44
44
|
fi
|
|
45
|
-
`;import{writeFile as
|
|
46
|
-
`),setTimeout(()=>{
|
|
47
|
-
`),
|
|
45
|
+
`;import{writeFile as B}from"fs/promises";import{join as k}from"path";import{execSync as gt}from"child_process";import D from"chalk";import wt from"ora";async function g(s,t){let i=k(t,s),e=k(i,"push.sh"),n=wt("Copying config files to "+D.blue(s)).start();n.color="blue";try{await Promise.all([B(k(i,".prettierrc.json"),I),B(e,O)]);try{gt(`chmod +x "${e}"`)}catch{console.error(D.red("Failed to make push.sh executable"))}n.succeed("Config files copied and push.sh is executable")}catch(r){n.fail("Failed to copy config files or set permissions"),console.error(r)}}import{spawn as ht}from"child_process";import bt from"ora";import $ from"chalk";function H(s,t,i){let e;switch(s){case"pnpm":e=`pnpm create vite ${t} --template react-swc-ts`;break;case"npm":e=`npm create vite@latest ${t} -- --template react-swc-ts`;break;case"bun":e=`bun create vite ${t} --template react-swc-ts`;break;default:e=`pnpm create vite ${t} --template react-swc-ts`}return new Promise(n=>{let r=ht(e,{shell:!0,cwd:i}),o=bt("Creating React project "+$.blue(t)).start();o.color="blue",r.on("close",a=>{a===0?(o.succeed("Created React project at "+$.blue(t)),n(!0)):(o.fail("Failed to create React project at "+$.blue(t)),n(!1))})})}import{spawn as xt}from"child_process";import yt from"ora";async function w(s,t){return new Promise((i,e)=>{let n="cd "+s+" && pnpm approve-builds",r=xt(n,{shell:!0,cwd:t}),o=yt("Approving builds").start();r.stdout.pipe(process.stdout),r.stderr.pipe(process.stderr),setTimeout(()=>{r.stdin.write(`a
|
|
46
|
+
`),setTimeout(()=>{r.stdin.write(`y
|
|
47
|
+
`),r.stdin.end()},500)},500),r.on("close",a=>{a===0?(o.succeed("Builds approved."),i(!0)):(o.fail("Failed to approve builds."),e(new Error(`Process exited with code ${a}`)))}),r.on("error",a=>{o.fail(`Failed to start process. Error: ${a.message}`),e(a)})})}import{spawn as vt}from"child_process";import kt from"ora";import C from"chalk";async function h(s,t){return new Promise(i=>{let e=`cd ${s} && bun pm trust --all`,n=vt(e,{shell:!0,cwd:t}),r=kt("Approving builds for "+C.blue(s)).start();r.color="blue",n.on("close",o=>{o===0?(r.succeed("Approved builds for "+C.blue(s)),i(!0)):(r.fail("Failed to approve builds for "+C.blue(s)),i(!1))})})}import{writeFile as X,unlink as U,rm as $t}from"fs/promises";import d from"ora";import{spawn as Ct}from"child_process";async function z(s,t){let i=`${t}/${s}/README.md`,e=d("Editing README.md...").start();e.color="white";try{let n=`# ${s}`;await X(i,n,"utf-8"),e.succeed("Updated README.md")}catch(n){e.fail(`Failed to edit README.md: ${n}`),console.error(n)}}async function J(s,t){let i=`${t}/${s}/src/assets`,e=d("Deleting assets...").start();e.color="white";try{await $t(i,{recursive:!0,force:!0}),e.succeed("Deleted assets")}catch(n){e.fail(`Failed to delete assets: ${n}`),console.error(n)}}async function G(s,t){let i=`${t}/${s}/src/app.css`,e=d("Deleting app.css...").start();e.color="white";try{await U(i),e.succeed("Deleted app.css")}catch(n){e.fail(`Failed to delete app.css: ${n}`),console.error(n)}}async function Q(s,t){let i=`${t}/${s}/src/app.tsx`,e=d("Clearing app.tsx...").start();e.color="white";let n=`
|
|
48
48
|
function App() {
|
|
49
49
|
return (
|
|
50
50
|
<>
|
|
@@ -54,4 +54,40 @@ fi
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export default App
|
|
57
|
-
`;try{await
|
|
57
|
+
`;try{await X(i,n,"utf-8"),e.succeed("Cleared app.tsx")}catch(r){e.fail(`Failed to clear app.tsx: ${r}`),console.error(r)}}async function L(s,t){let i=`${t}/${s}/eslint.config.js`,e=d("Deleting eslint.config.js...").start();e.color="white";try{await U(i),e.succeed("Deleted eslint.config.js")}catch(n){e.fail(`Failed to delete eslint.config.js: ${n}`),console.error(n)}}async function V(s,t,i){let e="cd "+s+" && "+t+" remove @eslint/js eslint eslint-plugin-react-hooks eslint-plugin-react-refresh globals typescript-eslint";return new Promise(n=>{let r=Ct(e,{shell:!0,cwd:i}),o=d("Removing packages...").start();o.color="white",o.start(),r.on("close",a=>{a===0?(o.succeed("Removed packages"),n(!0)):(o.fail("Failed to remove packages"),n(!1))})})}async function _(s,t,i){await Promise.all([G(s,i),J(s,i),L(s,i),Q(s,i),z(s,i),V(s,t,i)])}async function q(s){let{name:t,packageManager:i,cwd:e=process.cwd()}=s;try{await H(i,t,e)&&(await f(i,t,e),await g(t,e),await W(i,t,e),i==="pnpm"?await w(t,e):i==="bun"&&await h(t,e),await _(t,i,e))}catch(n){console.error(n)}}import{spawn as Ft}from"child_process";import Pt from"ora";import F from"chalk";async function K(s,t,i,e){let n;switch(t){case"pnpm":n=`pnpm dlx wxt@latest init ${i} -t ${s} --pm ${t}`;break;case"npm":n=`npx wxt@latest init ${i} -t ${s} --pm ${t}`;break;case"bun":n=`bunx wxt@latest init ${i} -t ${s} --pm ${t}`;break;default:n=`bun wxt@latest init ${i} -t ${s} --pm ${t}`}return new Promise(r=>{let o=Ft(n,{shell:!0,cwd:e}),a=Pt("Creating WXT project "+F.blue(i)).start();a.color="blue",o.on("close",u=>{u===0?(a.succeed("Created WXT project at "+F.blue(i)),r(!0)):(a.fail("Failed to create WXT project at "+F.blue(i)),r(!1))})})}import{select as Et}from"@inquirer/prompts";import jt from"chalk";import{rm as b,mkdir as St,writeFile as p,readFile as P}from"fs/promises";import{join as c}from"path";import{spawn as At}from"child_process";import Tt from"ora";import Y from"chalk";async function Z(s,t,i){let e=Tt("Finalizing WXT Svelte project setup...").start();try{e.text="Cleaning up default files...",await b(c(t,"src","assets","svelte.svg")),await b(c(t,"src","entrypoints","popup","app.css")),await b(c(t,"src","entrypoints","content.ts")),await b(c(t,"src","lib","Counter.svelte")),e.text="Creating content script files...";let n=c(t,"src","entrypoints","content");await St(n),await p(c(n,"App.svelte"),`<script lang="ts">
|
|
58
|
+
let message = "Hello World"
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<h1 class="text-3xl fixed top-20 left-20 z-50">{message}</h1>`),await p(c(n,"index.ts"),`import App from "./App.svelte"
|
|
62
|
+
import { mount, unmount } from "svelte"
|
|
63
|
+
|
|
64
|
+
export default defineContentScript({
|
|
65
|
+
matches: ["<all_urls>"],
|
|
66
|
+
cssInjectionMode: "ui",
|
|
67
|
+
|
|
68
|
+
async main(ctx) {
|
|
69
|
+
const ui = await createShadowRootUi(ctx, {
|
|
70
|
+
name: "extension-ui",
|
|
71
|
+
position: "inline",
|
|
72
|
+
anchor: "body",
|
|
73
|
+
onMount: container => {
|
|
74
|
+
return mount(App, { target: container })
|
|
75
|
+
},
|
|
76
|
+
onRemove: app => {
|
|
77
|
+
unmount(app)
|
|
78
|
+
},
|
|
79
|
+
})
|
|
80
|
+
ui.mount()
|
|
81
|
+
},
|
|
82
|
+
})`),e.text="Installing Tailwind CSS...",await new Promise((it,rt)=>{let ot=`${i} install tailwindcss @tailwindcss/vite`;At(ot,{shell:!0,cwd:t}).on("close",at=>{at===0?it():rt(new Error("Failed to install Tailwind CSS"))})}),e.text="Configuring Tailwind CSS...",await p(c(t,"src","assets","tailwind.css"),'@import "tailwindcss";');let u=c(t,"wxt.config.ts"),m=await P(u,"utf-8");m=`import tailwindcss from '@tailwindcss/vite'
|
|
83
|
+
`+m,m=m.replace("defineConfig({",`defineConfig({
|
|
84
|
+
vite: () => ({
|
|
85
|
+
plugins: [tailwindcss()]
|
|
86
|
+
}),
|
|
87
|
+
webExt: {
|
|
88
|
+
disabled: true
|
|
89
|
+
},`),await p(u,m),e.text="Updating popup files...";let E=c(t,"src","entrypoints","popup","main.ts"),x=await P(E,"utf-8");x=x.replace("import './app.css'",'import "~/assets/tailwind.css"'),await p(E,x);let nt=c(t,"src","entrypoints","popup","App.svelte");await p(nt,`<script lang="ts">
|
|
90
|
+
let message = "Hello World"
|
|
91
|
+
</script>
|
|
92
|
+
|
|
93
|
+
<h1 class="text-3xl">{message}</h1>`),e.text="Updating package.json...";let j=c(t,"package.json"),M=JSON.parse(await P(j,"utf-8"));return M.name=s,await p(j,JSON.stringify(M,null,2)),e.succeed(Y.green("WXT Svelte project setup finished successfully!")),!0}catch(n){return e.fail(Y.red(`Error during post-installation setup: ${n.message}`)),!1}}import{join as Mt}from"path";var Rt=["react - !not ready","vue - !not ready","svelte","vanilla - !not ready","solid - !not ready"];async function N(s){let{name:t,packageManager:i,cwd:e=process.cwd()}=s;try{let n=await Et({message:jt.bold.magenta("Select a framework for WXT"),choices:Rt,default:"svelte"});if(await K(n,i,t,e)){let o=Mt(e,t);await f(i,t,e),await g(t,e),n==="svelte"&&await Z(t,o,i),i==="pnpm"?await w(t,e):i==="bun"&&await h(t,e)}}catch(n){console.error(n)}}import{spawn as Wt}from"child_process";import S from"chalk";async function tt(s,t,i){return console.log(S.white("Opening "+S.blue(s)+" in "+S.green(i))),new Promise(e=>{Wt(`${i} ${s}`,{shell:!0,cwd:t}).on("close",()=>e(!0))})}var et=["react-ts-tw","next-ts - !not ready","wxt","cpp-cmake - !not ready"],st=["bun","pnpm","npm"];async function A(s){switch(s.projectType){case"react-ts-tw":await q({name:s.name,packageManager:s.packageManager});break;case"next-ts - !not ready":console.log("next-ts",s.packageManager,s.name);break;case"wxt":await N({name:s.name,packageManager:s.packageManager});break;case"cpp-cmake - !not ready":console.log("cpp-cmake",s.packageManager,s.name);break;default:console.log("Invalid project type",s.projectType);break}s.openInEditor!=="no"&&await tt(s.name,process.cwd(),s.openInEditor)}import l from"chalk";import Ot from"fs";import Bt from"path";var Dt=await It({message:l.bold.blue("Enter a project name"),default:l.gray("my-project"),validate:s=>!s||s.trim().length<2?l.red("Project name must be at least 2 characters"):/^[a-z0-9]+(-[a-z0-9]+)*$/.test(s)?Ot.existsSync(Bt.resolve(process.cwd(),s))?l.red("A folder with that name already exists"):!0:l.red("Only lowercase letters, numbers, and single hyphens allowed. No spaces or special characters.")}),Ht=await T({message:l.bold.green("Select a package manager"),choices:st,default:"bun"}),Xt=await T({message:l.bold.yellow("Select a project type"),default:"react-ts-tw",choices:et}),Ut=await T({message:l.bold.cyan("Open in editor?"),choices:["no","windsurf","cursor","code"],default:"no"}),zt={projectType:Xt,packageManager:Ht,name:Dt,openInEditor:Ut};await A(zt);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kunver/new",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Opiniated project starter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/node": "^24.0.13",
|
|
21
21
|
"tsup": "^8.2.2",
|
|
22
|
-
"typescript": "^5.5.4"
|
|
22
|
+
"typescript": "^5.5.4",
|
|
23
|
+
"vitest": "^3.2.4"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
26
|
"@inquirer/prompts": "^7.6.0",
|
|
@@ -29,6 +30,7 @@
|
|
|
29
30
|
"scripts": {
|
|
30
31
|
"build": "tsup",
|
|
31
32
|
"start": "pnpm run build && node dist/index.js",
|
|
32
|
-
"local": "pnpm link --global"
|
|
33
|
+
"local": "pnpm link --global",
|
|
34
|
+
"test": "vitest run"
|
|
33
35
|
}
|
|
34
36
|
}
|