@kunver/new 1.1.1 → 1.3.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/README.MD CHANGED
@@ -5,7 +5,7 @@ Cli tool for creating new projects with pre-configured settings.
5
5
  ## Using
6
6
 
7
7
  ```bash
8
- pnpx | npx | bun @kunver/new
8
+ pnpx | npx | bunx @kunver/new
9
9
  ```
10
10
 
11
11
  ## Starters
@@ -14,13 +14,15 @@ pnpx | npx | bun @kunver/new
14
14
 
15
15
  ✅ React + TypeScript + Tailwind + Prettierconfig
16
16
 
17
- ### Will be added
17
+ Wxt + Svelte + TypeScript + Tailwind + Prettierconfig
18
18
 
19
- 🟡 Next.js + TypeScript + Tailwind + Prettierconfig
19
+ ### Work in progress
20
20
 
21
21
  🟡 Wxt + React + TypeScript + Tailwind + Prettierconfig
22
22
 
23
- 🟡 Wxt + Svelte + TypeScript + Tailwind + Prettierconfig
23
+ ### Will be added
24
+
25
+ 🟡 Next.js + TypeScript + Tailwind + Prettierconfig
24
26
 
25
27
  🟡 Astro + TypeScript + Tailwind + Prettierconfig
26
28
 
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import{input as R,select as $}from"@inquirer/prompts";import{spawn as C}from"child_process";import T from"ora";import c from"chalk";import{spawn as M}from"child_process";import n from"chalk";import S from"ora";function f(e,t){return new Promise(o=>{let r;switch(e){case"pnpm":r=`cd ${t} && pnpm install`;break;case"npm":r=`cd ${t} && npm install`;break;case"bun":r=`cd ${t} && bun install`;break;default:r=`cd ${t} && pnpm install`}let i=M(r,{shell:!0,cwd:process.cwd()}),a=S("Installing dependencies with "+n.bold.blue(e)+" ...");a.color="white",a.start(),i.stderr.pipe(process.stderr),i.on("close",p=>{a.stop(),p==0?(console.log(n.green("\u2705 Installed dependencies for "+n.bold.blue(t))),o(!0)):(console.error(n.red("\u274C Failed to install dependencies for "+n.bold.blue(t))),o(!1))})})}var u=`
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=`
3
4
  {
4
5
  "semi": false,
5
6
  "trailingComma": "all",
@@ -11,7 +12,7 @@ import{input as R,select as $}from"@inquirer/prompts";import{spawn as C}from"chi
11
12
  "jsxBracketSameLine": false,
12
13
  "arrowParens": "avoid"
13
14
  }
14
- `,h=`
15
+ `,O=`
15
16
  #!/bin/bash
16
17
 
17
18
  # Exit immediately if a command fails
@@ -41,6 +42,52 @@ if [ $? -ne 0 ]; then
41
42
  echo "\u274C Failed to switch back to the 'dev' branch."
42
43
  exit 1
43
44
  fi
44
- `;import{writeFileSync as b}from"fs";import{join as m}from"path";import{execSync as F}from"child_process";import l from"chalk";function w(e){let t=m(process.cwd(),e),o=m(t,"push.sh");console.log(l.green("Copying config files to "+l.bold.blue(e))),b(m(t,".prettierrc.json"),u),b(o,h);try{F(`chmod +x "${o}"`),console.log(l.green("\u2705 Set execute permissions for push.sh"))}catch(r){console.warn(l.yellow(`Warning: Could not set execute permissions for push.sh: ${r}`))}}import{spawn as P}from"child_process";import k from"chalk";function y(){let e=P("pnpm approve-builds",{shell:!0});e.stdout.pipe(process.stdout),e.stderr.pipe(process.stderr),e.stdin.write(`a
45
- `),e.stdin.write(`y
46
- `),e.on("close",t=>{t===0?console.log(k.green("\u2705 Builds approved.")):console.error(k.red("\u274C Failed to approve builds."))})}async function x(e){let{name:t,packageManager:o}=e,r;switch(o){case"pnpm":r=`pnpm create vite ${t} --template react-swc-ts`;break;case"npm":r=`npm create vite@latest ${t} -- --template react-swc-ts`;break;case"bun":r=`bun create vite ${t} --template react-swc-ts`;break;default:r=`pnpm create vite ${t} --template react-swc-ts`}let i=C(r,{shell:!0}),a=T("Creating React project...");a.color="blue",a.start(),i.on("close",async p=>{if(a.stop(),p==0){console.log(c.green("Created React Project At "+c.bold.blue(t)));let g=await f(o,t);g||(console.log(c.red("\u274C Failed to install dependencies for "+c.bold.blue(t))),console.log(c.red("Please install dependencies manually, tool will continue"))),g&&o=="pnpm"&&y(),w(t)}else console.error(`Failed to create React project at ${t}`)})}var j=["react-ts-tw","next-ts","wxt-react","wxt-svelte"],v=["pnpm","npm","bun"];function d(e){switch(e.projectType){case"react-ts-tw":x({name:e.name,packageManager:e.packageManager});break;case"next-ts":console.log("next-ts",e.packageManager,e.name);break;case"wxt-react":console.log("wxt-react",e.packageManager,e.name);break;case"wxt-svelte":console.log("wxt-svelte",e.packageManager,e.name);break;default:console.log("Invalid project type",e.projectType);break}}import s from"chalk";import B from"fs";import I from"path";var G=await R({message:s.bold.blue("Enter a project name"),default:s.gray("my-project"),validate:e=>!e||e.trim().length<2?s.red("Project name must be at least 2 characters"):/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e)?B.existsSync(I.resolve(process.cwd(),e))?s.red("A folder with that name already exists"):!0:s.red("Only lowercase letters, numbers, and single hyphens allowed. No spaces or special characters.")}),H=await $({message:s.bold.green("Select a package manager"),choices:v,default:"pnpm"}),O=await $({message:s.bold.yellow("Select a project type"),default:"react-ts-tw",choices:j}),W={projectType:O,packageManager:H,name:G};d(W);
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
+ function App() {
49
+ return (
50
+ <>
51
+ <h1 className="text-3xl font-bold underline">Hello</h1>
52
+ </>
53
+ )
54
+ }
55
+
56
+ export default App
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","vue","svelte","vanilla","solid"];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","wxt","cpp-cmake"],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":console.log("next-ts",s.packageManager,s.name);break;case"wxt":await N({name:s.name,packageManager:s.packageManager});break;case"cpp-cmake":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.1.1",
3
+ "version": "1.3.0",
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
  }