@kunver/new 3.1.1 → 3.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.
Files changed (112) hide show
  1. package/README.MD +26 -18
  2. package/dist/index.js +16 -10
  3. package/dist/templates/cmake-cpp/.clang-format +1 -0
  4. package/dist/templates/cmake-cpp/CMakeLists.txt +14 -0
  5. package/dist/templates/cmake-cpp/README.md +32 -0
  6. package/dist/templates/cmake-cpp/_clang-format +1 -0
  7. package/dist/templates/cmake-cpp/_gitignore +9 -0
  8. package/dist/templates/cmake-cpp/agents.md +8 -0
  9. package/dist/templates/{make-cpp → cmake-cpp}/include/example.hpp +1 -1
  10. package/dist/templates/cmake-cpp/manager.ts +276 -0
  11. package/dist/templates/{make-cpp → cmake-cpp}/src/main.cpp +1 -1
  12. package/dist/templates/electron-svelte/.vscode/launch.json +39 -39
  13. package/dist/templates/electron-svelte/.vscode/settings.json +15 -15
  14. package/dist/templates/next-prisma/README.md +11 -11
  15. package/dist/templates/next-prisma/_prettierrc.json +12 -0
  16. package/dist/templates/next-prisma/app/globals.css +1 -1
  17. package/dist/templates/next-prisma/app/layout.tsx +21 -21
  18. package/dist/templates/next-prisma/app/page.tsx +7 -7
  19. package/dist/templates/next-prisma/lib/prisma.ts +11 -11
  20. package/dist/templates/next-prisma/manager.cjs +71 -69
  21. package/dist/templates/next-prisma/next.config.ts +7 -7
  22. package/dist/templates/next-prisma/package.json +33 -33
  23. package/dist/templates/next-prisma/postcss.config.mjs +5 -5
  24. package/dist/templates/next-prisma/tsconfig.json +27 -27
  25. package/dist/templates/react-ts-tw/README.md +1 -1
  26. package/dist/templates/react-ts-tw/_prettierrc.json +12 -0
  27. package/dist/templates/react-ts-tw/index.html +13 -13
  28. package/dist/templates/react-ts-tw/manager.cjs +71 -69
  29. package/dist/templates/react-ts-tw/package.json +30 -30
  30. package/dist/templates/react-ts-tw/src/App.tsx +9 -9
  31. package/dist/templates/react-ts-tw/src/index.css +1 -1
  32. package/dist/templates/react-ts-tw/src/main.tsx +10 -10
  33. package/dist/templates/react-ts-tw/src/vite-env.d.ts +1 -1
  34. package/dist/templates/react-ts-tw/tsconfig.app.json +27 -27
  35. package/dist/templates/react-ts-tw/tsconfig.json +4 -7
  36. package/dist/templates/react-ts-tw/tsconfig.node.json +25 -25
  37. package/dist/templates/react-ts-tw/vite.config.ts +8 -8
  38. package/dist/templates/wxt-solid/README.md +3 -3
  39. package/dist/templates/wxt-solid/_prettierrc.json +11 -0
  40. package/dist/templates/wxt-solid/agents.md +76 -76
  41. package/dist/templates/wxt-solid/assets/tailwind.css +1 -1
  42. package/dist/templates/wxt-solid/entrypoints/background.ts +3 -3
  43. package/dist/templates/wxt-solid/entrypoints/content/Content.tsx +7 -7
  44. package/dist/templates/wxt-solid/entrypoints/content/main.tsx +31 -31
  45. package/dist/templates/wxt-solid/entrypoints/options/{App.tsx → Options.tsx} +0 -1
  46. package/dist/templates/wxt-solid/entrypoints/options/index.html +13 -13
  47. package/dist/templates/wxt-solid/entrypoints/options/main.tsx +2 -2
  48. package/dist/templates/wxt-solid/entrypoints/popup/index.html +13 -13
  49. package/dist/templates/wxt-solid/entrypoints/popup/main.tsx +2 -2
  50. package/dist/templates/wxt-solid/manager.cjs +71 -69
  51. package/dist/templates/wxt-solid/package.json +33 -33
  52. package/dist/templates/wxt-solid/tsconfig.json +7 -7
  53. package/dist/templates/wxt-solid/wxt.config.ts +18 -18
  54. package/dist/templates/wxt-svelte/.vscode/extensions.json +3 -3
  55. package/dist/templates/wxt-svelte/README.md +3 -3
  56. package/dist/templates/wxt-svelte/_prettierrc.json +11 -0
  57. package/dist/templates/wxt-svelte/agents.md +77 -77
  58. package/dist/templates/wxt-svelte/assets/tailwind.css +1 -1
  59. package/dist/templates/wxt-svelte/entrypoints/background.ts +3 -3
  60. package/dist/templates/wxt-svelte/entrypoints/content/index.ts +4 -4
  61. package/dist/templates/wxt-svelte/entrypoints/options/index.html +13 -13
  62. package/dist/templates/wxt-svelte/entrypoints/options/main.ts +2 -2
  63. package/dist/templates/wxt-svelte/entrypoints/popup/index.html +13 -13
  64. package/dist/templates/wxt-svelte/entrypoints/popup/main.ts +2 -2
  65. package/dist/templates/wxt-svelte/manager.cjs +71 -69
  66. package/dist/templates/wxt-svelte/package.json +36 -36
  67. package/dist/templates/wxt-svelte/tsconfig.json +6 -6
  68. package/dist/templates/wxt-svelte/wxt-env.d.ts +1 -1
  69. package/dist/templates/wxt-svelte/wxt.config.ts +18 -18
  70. package/dist/templates/wxt-vanilla/README.md +3 -3
  71. package/dist/templates/wxt-vanilla/_prettierrc.json +11 -0
  72. package/dist/templates/wxt-vanilla/agents.md +73 -73
  73. package/dist/templates/wxt-vanilla/entrypoints/background.ts +3 -3
  74. package/dist/templates/wxt-vanilla/entrypoints/content.ts +6 -6
  75. package/dist/templates/wxt-vanilla/entrypoints/popup/index.html +13 -13
  76. package/dist/templates/wxt-vanilla/entrypoints/popup/main.ts +1 -1
  77. package/dist/templates/wxt-vanilla/manager.cjs +71 -69
  78. package/dist/templates/wxt-vanilla/package.json +25 -25
  79. package/dist/templates/wxt-vanilla/tsconfig.json +3 -3
  80. package/dist/templates/wxt-vanilla/wxt.config.ts +13 -13
  81. package/package.json +18 -5
  82. package/dist/templates/electron-svelte/README.md +0 -3
  83. package/dist/templates/electron-svelte/_gitignore +0 -6
  84. package/dist/templates/electron-svelte/build/entitlements.mac.plist +0 -12
  85. package/dist/templates/electron-svelte/build/icon.icns +0 -0
  86. package/dist/templates/electron-svelte/build/icon.ico +0 -0
  87. package/dist/templates/electron-svelte/build/icon.png +0 -0
  88. package/dist/templates/electron-svelte/bun.lock +0 -1154
  89. package/dist/templates/electron-svelte/electron-builder.yml +0 -44
  90. package/dist/templates/electron-svelte/electron.vite.config.ts +0 -15
  91. package/dist/templates/electron-svelte/manager.cjs +0 -69
  92. package/dist/templates/electron-svelte/package.json +0 -44
  93. package/dist/templates/electron-svelte/resources/icon.png +0 -0
  94. package/dist/templates/electron-svelte/src/main/index.ts +0 -62
  95. package/dist/templates/electron-svelte/src/preload/index.d.ts +0 -8
  96. package/dist/templates/electron-svelte/src/preload/index.ts +0 -22
  97. package/dist/templates/electron-svelte/src/renderer/index.html +0 -16
  98. package/dist/templates/electron-svelte/src/renderer/src/App.svelte +0 -8
  99. package/dist/templates/electron-svelte/src/renderer/src/assets/main.css +0 -1
  100. package/dist/templates/electron-svelte/src/renderer/src/env.d.ts +0 -2
  101. package/dist/templates/electron-svelte/src/renderer/src/main.ts +0 -11
  102. package/dist/templates/electron-svelte/svelte.config.mjs +0 -7
  103. package/dist/templates/electron-svelte/tsconfig.json +0 -4
  104. package/dist/templates/electron-svelte/tsconfig.node.json +0 -11
  105. package/dist/templates/electron-svelte/tsconfig.web.json +0 -17
  106. package/dist/templates/make-cpp/Makefile +0 -44
  107. package/dist/templates/make-cpp/README.md +0 -15
  108. /package/dist/templates/{make-cpp → cmake-cpp}/src/example.cpp +0 -0
  109. /package/dist/templates/wxt-solid/entrypoints/popup/{App.tsx → Popup.tsx} +0 -0
  110. /package/dist/templates/wxt-svelte/entrypoints/content/{App.svelte → Content.svelte} +0 -0
  111. /package/dist/templates/wxt-svelte/entrypoints/options/{App.svelte → Options.svelte} +0 -0
  112. /package/dist/templates/wxt-svelte/entrypoints/popup/{App.svelte → Popup.svelte} +0 -0
package/README.MD CHANGED
@@ -1,35 +1,43 @@
1
1
  # Opiniated Project Starter
2
2
 
3
- Cli tool for creating new projects with pre-configured settings.
3
+ CLI tool for creating new projects with pre-configured settings.
4
4
 
5
- [![npm v](https://img.shields.io/npm/v/@kunver/new)](https://www.npmjs.com/package/@kunver/new)
6
- [![npm downloads](https://img.shields.io/npm/dm/@kunver/new)](https://www.npmjs.com/package/@kunver/new)
7
-
8
- ## Using
5
+ ## Usage
9
6
 
10
7
  ```bash
11
8
  pnpx | npx | bunx @kunver/new
12
9
  ```
13
10
 
14
- ## Starters
11
+ The CLI asks for a project name, starter type, package manager when needed, and whether the project should be opened in your editor.
12
+
13
+ ## Current starters
14
+
15
+ - React + TypeScript + Tailwind
16
+ - Next.js + Prisma
17
+ - WXT
18
+ - Svelte
19
+ - Vanilla
20
+ - Solid
21
+ - UV Notebook
22
+ - C++ + CMake
15
23
 
16
- ### Ready to use
24
+ ## Notes
17
25
 
18
- React
26
+ - C++ + CMake projects include a `manager.ts` bridge for commands like `bun manager.ts dev` and `bun manager.ts build`.
27
+ - The C++ + CMake starter automatically updates the CMake project name to the folder name you enter.
19
28
 
20
- Wxt + Svelte
29
+ ## Package managers
21
30
 
22
- Wxt + Vanilla
31
+ - Bun
32
+ - pnpm
33
+ - npm
23
34
 
24
- Next.js + Prisma
35
+ Some starters intentionally skip package manager selection because they do not need JS dependencies.
25
36
 
26
- Python Jupyter Notebook
37
+ ## Output
27
38
 
28
- ### Work in progress
39
+ Generated templates live under [src/public/templates](src/public/templates) in this repository.
29
40
 
30
- ### Will be added
41
+ ## Status
31
42
 
32
- 🟡 Wxt Solid
33
- 🟡 C++ CMake
34
- 🟡 Rust
35
- 🟡 Rust Tauri
43
+ This project is intentionally opinionated and focused on a small set of starters.
package/dist/index.js CHANGED
@@ -1,15 +1,21 @@
1
- import K,{readFileSync,existsSync,constants,promises}from'fs';import H,{dirname,join}from'path';import {input,select,confirm}from'@inquirer/prompts';import c from'chalk';import {access,mkdir,writeFile,rm,readFile}from'fs/promises';import {spawn}from'child_process';import L from'ora';import {execa}from'execa';import {fileURLToPath}from'url';async function j(e){let{name:o,cwd:t=process.cwd()}=e,a=join(t,o);try{await access(a,constants.F_OK);}catch{await mkdir(a,{recursive:true});}let r=join(a,"main.ipynb");await writeFile(r,"");}var _=["react-ts-tw","next-ts-prisma","wxt","electron-svelte","python-notebook","cpp-makefile"],$=["bun","pnpm","npm"],A=["antigravity","windsurf","no","cursor","code"],U=["svelte","vanilla","solid"];async function h(e,o,t){switch(e){case "pnpm":return await ne(o,t);case "bun":return await se(o,t);default:return false}}async function ne(e,o){let t=L("Approving builds for "+c.blue(e)).start();try{return new Promise(a=>{let r=spawn("pnpm",["approve-builds"],{cwd:`${o}/${e}`,stdio:["pipe","inherit","inherit"],shell:!0});setTimeout(()=>{r.stdin?.write(`a
2
- `),setTimeout(()=>{r.stdin?.write(`y
3
- `),r.stdin?.end();},1e3);},2e3),r.on("close",s=>{s===0?(t.succeed("Approved builds for "+c.blue(e)),a(!0)):(t.fail("Failed to approve builds for "+c.blue(e)),a(!1));}),r.on("error",s=>{t.fail("Failed to approve builds for "+c.blue(e)),console.error(s),a(!1);});})}catch(a){return t.fail("Failed to approve builds for "+c.blue(e)),console.error(a),false}}async function se(e,o){let t=`cd ${e} && bun pm trust --all`,a=L("Approving builds for "+c.blue(e)).start();try{return await execa(t,{shell:!0,cwd:o}),a.succeed("Approved builds for "+c.blue(e)),!0}catch{return a.fail("Failed to approve builds for "+c.blue(e)),false}}async function P(e,o,t){let a=`cd ${o} && ${e} install`;console.log("Installing dependencies with "+c.cyan(e)+`
4
- `);try{return await execa(a,{shell:!0,cwd:t,stdout:"inherit",stderr:"inherit"}),!0}catch{return false}}async function M(e,o){let t=L("Copying template folder...").start();try{await promises.cp(e,o,{recursive:!0});let a=H.join(o,"_gitignore"),r=H.join(o,".gitignore");try{await promises.rename(a,r);}catch{}return t.succeed("Copied template folder"),!0}catch{return t.fail("Failed to copy template folder"),false}}async function F(e,o,t){let a=join(t,o,"package.json"),r=await K.promises.readFile(a,"utf-8"),s=JSON.parse(r);e==="bun"?s.scripts.manager=`bun manager.cjs ${e}`:s.scripts.manager=`node manager.cjs ${e}`,await K.promises.writeFile(a,JSON.stringify(s,null,2));}async function I(e,o,t){console.log(c.white("Opening "+c.blue(e)+" in "+c.green(t)));try{return await execa(`${t} ${e}`,{shell:!0,cwd:o}),!0}catch(a){return console.error(c.red("Failed to open project in editor:"),a),false}}function ge(){return typeof __dirname<"u"?__dirname:typeof import.meta<"u"&&import.meta.url?dirname(fileURLToPath(import.meta.url)):process.cwd()}var R=ge();async function i(e){let{templateName:o,name:t,packageManager:a,cwd:r=process.cwd(),addManager:s=true,changeName:p=true,approveBuild:x=true,installDependency:w=true,onBeforeInstall:f}=e,n=join(R,"../public/templates",o),y=join(R,"templates",o),T=existsSync(n)?n:y;try{if(!await M(T,join(r,t)))throw new Error("Failed to copy template folder");if(f&&await f(join(r,t)),w&&!await P(a,t,r))throw new Error("Failed to install dependencies");return s&&await F(a,t,r),x&&await h(a,t,r),p&&await O(join(r,t),t),!0}catch(l){throw console.error("Error creating project:",l),l}}async function O(e,o){try{let t=join(e,"package.json"),a=await readFile(t,"utf-8"),r=JSON.parse(a);return r.name=o.toLowerCase().replace(/\s+/g,"-"),await writeFile(t,JSON.stringify(r,null,2)+`
5
- `),!0}catch(t){return console.error("Error updating project name:",t),false}}async function S(e){let{name:o,packageManager:t,selectedFramework:a}=e;try{let r=U,s=r.includes("svelte")?"svelte":r[0],p;a&&r.includes(a)?p=a:p=await select({message:c.bold.magenta("Select a framework for WXT"),choices:r.map(n=>({name:n.charAt(0).toUpperCase()+n.slice(1),value:n})),default:s});let x=await confirm({message:c.bold.cyan("Use i18n? (@wxt-dev/i18n)"),default:!1}),w=!1;(p==="svelte"||p==="solid")&&(w=await confirm({message:c.bold.cyan("Do you want to use content UI?"),default:!1}));let f=async n=>{if((p==="svelte"||p==="solid")&&!w){let V=join(n,"entrypoints","content");await rm(V,{recursive:!0,force:!0});let Y=join(n,"entrypoints","content.ts");await writeFile(Y,`export default defineContentScript({
1
+ import H,{readFileSync,existsSync,promises}from'fs';import R,{dirname,join}from'path';import {input,select,confirm}from'@inquirer/prompts';import i from'chalk';import {mkdir,writeFile,readFile,rm}from'fs/promises';import {execa}from'execa';import {spawn}from'child_process';import L from'ora';import {fileURLToPath}from'url';async function y(e){let{name:n,cwd:t=process.cwd()}=e,r=join(t,n),o=join(r,"main.ipynb");await mkdir(r,{recursive:true}),await execa("uv",["init","--python","3.12"],{cwd:r,stdout:"inherit",stderr:"inherit"}),await execa("uv",["add","numpy"],{cwd:r,stdout:"inherit",stderr:"inherit"}),await writeFile(o,ne(n),"utf8");}function ne(e){return `${JSON.stringify({cells:[{cell_type:"markdown",metadata:{language:"markdown"},source:[`# ${e}
2
+ `,`
3
+ `,`Starter notebook with NumPy ready to use.
4
+ `]},{cell_type:"code",execution_count:null,metadata:{language:"python"},outputs:[],source:[`import numpy as np
5
+ `,`np.arange(5)
6
+ `]}],metadata:{kernelspec:{display_name:"Python 3.12",language:"python",name:"python3"},language_info:{name:"python",version:"3.12"}},nbformat:4,nbformat_minor:5},null,2)}
7
+ `}var J=["react-ts-tw","next-ts-prisma","wxt","uv-notebook","cmake-cpp"],U=["bun","pnpm","npm"],A=["antigravity","windsurf","no","cursor","code"],h=["svelte","vanilla","solid"];async function u(e,n,t){switch(e){case "pnpm":return await ae(n,t);case "bun":return await ie(n,t);default:return false}}async function ae(e,n){let t=L("Approving builds for "+i.blue(e)).start(),r=join(n,e);try{return new Promise(o=>{let a=spawn("pnpm",["approve-builds"],{cwd:r,stdio:["pipe","inherit","inherit"],shell:!0});setTimeout(()=>{a.stdin?.write(`a
8
+ `),setTimeout(()=>{a.stdin?.write(`y
9
+ `),a.stdin?.end();},1e3);},2e3),a.on("close",s=>{s===0?(t.succeed("Approved builds for "+i.blue(e)),o(!0)):(t.fail("Failed to approve builds for "+i.blue(e)),o(!1));}),a.on("error",s=>{t.fail("Failed to approve builds for "+i.blue(e)),console.error(s),o(!1);});})}catch(o){return t.fail("Failed to approve builds for "+i.blue(e)),console.error(o),false}}async function ie(e,n){let t=L("Approving builds for "+i.blue(e)).start(),r=join(n,e);try{return await execa("bun",["pm","trust","--all"],{cwd:r}),t.succeed("Approved builds for "+i.blue(e)),!0}catch{return t.fail("Failed to approve builds for "+i.blue(e)),false}}async function k(e,n,t){let r=join(t,n);console.log("Installing dependencies with "+i.cyan(e)+`
10
+ `);try{return await execa(e,["install"],{cwd:r,stdout:"inherit",stderr:"inherit"}),!0}catch{return false}}async function z(e){let n=await promises.readdir(e,{withFileTypes:true});for(let t of n){let r=R.join(e,t.name),o=r;t.name.startsWith("_")&&t.name.length>1&&(o=R.join(e,`.${t.name.slice(1)}`),await promises.rename(r,o)),t.isDirectory()&&await z(o);}}async function b(e,n){let t=L("Copying template folder...").start();try{return await promises.cp(e,n,{recursive:!0}),await z(n),t.succeed("Copied template folder"),!0}catch{return t.fail("Failed to copy template folder"),false}}async function j(e,n,t){let r=join(t,n,"package.json"),o=await H.promises.readFile(r,"utf-8"),a=JSON.parse(o);e==="bun"?a.scripts.manager=`bun manager.cjs ${e}`:a.scripts.manager=`node manager.cjs ${e}`,await H.promises.writeFile(r,JSON.stringify(a,null,2));}async function x(e,n,t){console.log(i.white("Opening "+i.blue(e)+" in "+i.green(t)));try{return await execa(t,[e],{cwd:n}),!0}catch(r){return console.error(i.red("Failed to open project in editor:"),r),false}}function we(){return typeof __dirname<"u"?__dirname:typeof import.meta<"u"&&import.meta.url?dirname(fileURLToPath(import.meta.url)):process.cwd()}var X=we();async function p(e,n){if(await n()===false)throw new Error(`Failed to ${e}`)}function ye(e){let n=join(X,"../public/templates",e),t=join(X,"templates",e);return existsSync(n)?n:t}async function l(e){let{templateName:n,name:t,packageManager:r,cwd:o=process.cwd(),addManager:a=true,changeName:s=true,approveBuild:V=true,installDependency:Y=true,onBeforeInstall:N}=e,w=join(o,t),Z=ye(n);try{return await p("copy template folder",()=>b(Z,w)),N&&await p("run pre-install hook",()=>N(w)),Y&&await p("install dependencies",()=>k(r,t,o)),a&&await p("add manager script",()=>j(r,t,o)),V&&await p("approve builds",()=>u(r,t,o)),s&&await p("change project name",()=>v(w,t)),!0}catch(_){throw console.error("Error creating project:",_),_}}async function v(e,n){try{let t=join(e,"package.json"),r=await readFile(t,"utf-8"),o=JSON.parse(r);return o.name=n.toLowerCase().replace(/\s+/g,"-"),await writeFile(t,JSON.stringify(o,null,2)+`
11
+ `),!0}catch(t){return console.error("Error updating project name:",t),false}}async function C(e,n){try{let t=join(e,"CMakeLists.txt"),r=await readFile(t,"utf-8"),o=r.replace(/project\s*\(\s*(?:"[^"]+"|[^\s\)]+)([\s\S]*?)\)/i,`project("${n}"$1)`);return o===r?!1:(await writeFile(t,o),!0)}catch(t){return console.error("Error updating CMake project name:",t),false}}async function S(e){console.log(i.white("Configuring CMake project in "+i.blue(e)));try{return await execa("cmake",["-S",".","-B","build"],{cwd:e,stdout:"inherit",stderr:"inherit"}),console.log(i.green("CMake project configured successfully")),!0}catch{return console.log(i.yellow("Automatic CMake configure skipped. Run `cmake -S . -B build` manually if needed.")),false}}var Ie={svelte:"wxt-svelte",solid:"wxt-solid",vanilla:"wxt-vanilla"};async function Me(e){return e&&h.includes(e)?e:await select({message:i.bold.magenta("Select a framework for WXT"),choices:h.map(n=>({name:n.charAt(0).toUpperCase()+n.slice(1),value:n})),default:"svelte"})}async function Oe(e){let n=await confirm({message:i.bold.cyan("Use i18n? (@wxt-dev/i18n)"),default:false}),r=e==="svelte"||e==="solid"?await confirm({message:i.bold.cyan("Do you want to use content UI?"),default:false}):false;return {useI18n:n,useContentUI:r}}async function Fe(e){let n=join(e,"entrypoints","content"),t=join(e,"entrypoints","content.ts"),r=`export default defineContentScript({
6
12
  matches: ["*://*.google.com/*"],
7
13
  main() {
8
14
  console.log("Hello content.");
9
15
  },
10
16
  });
11
- `,"utf-8");}if(!x)return;let y=join(n,"package.json"),T=await readFile(y,"utf-8"),l=JSON.parse(T);l.devDependencies=l.devDependencies||{},l.devDependencies["@wxt-dev/i18n"]="0.2.5",await writeFile(y,JSON.stringify(l,null,2),"utf-8");let v=join(n,"wxt.config.ts"),m=await readFile(v,"utf-8");m=m.replace("manifest: {",`manifest: {
12
- default_locale: "en",`),m.includes("modules: [")?m=m.replace("modules: [",'modules: ["@wxt-dev/i18n/module", '):m=m.replace("export default defineConfig({",`export default defineConfig({
13
- modules: ["@wxt-dev/i18n/module"],`),await writeFile(v,m,"utf-8");let J=join(n,"locales");await mkdir(J,{recursive:!0}),await writeFile(join(J,"en.yml"),`hello: Hello!
14
- `,"utf-8");};switch(p){case "svelte":await i({templateName:"wxt-svelte",name:o,packageManager:t,onBeforeInstall:f});break;case "solid":await i({templateName:"wxt-solid",name:o,packageManager:t,onBeforeInstall:f});break;case "vanilla":await i({templateName:"wxt-vanilla",name:o,packageManager:t,onBeforeInstall:f});break;default:break}}catch(r){console.error(r);}}async function N(e){switch(e.projectType){case "react-ts-tw":await i({templateName:"react-ts-tw",name:e.name,packageManager:e.packageManager});break;case "next-ts-prisma":await i({templateName:"next-prisma",name:e.name,packageManager:e.packageManager});break;case "wxt":await S({name:e.name,packageManager:e.packageManager});break;case "electron-svelte":await i({templateName:"electron-svelte",name:e.name,packageManager:e.packageManager,installDependency:false,approveBuild:false}),console.log(c.yellow("Dependencies not installed. Please install dependencies manually"));break;case "python-notebook":await j({name:e.name});break;case "cpp-makefile":await i({templateName:"make-cpp",name:e.name,packageManager:"bun",addManager:false,approveBuild:false,installDependency:false});break;default:console.log(c.red("Project Type Not Implemented"),e.projectType);break}e.openInEditor!=="no"&&await I(e.name,process.cwd(),e.openInEditor);}var Oe=fileURLToPath(import.meta.url),Ee=dirname(Oe),Se=join(Ee,"../package.json"),Ne=JSON.parse(readFileSync(Se,"utf8")),De=Ne.version;console.log(c.green("Kunver v"+c.bold(De)+`
15
- `));var Ce=await input({message:c.bold.blue("Enter a project name"),default:c.gray("my-project"),validate:e=>!e||e.trim().length<2?c.red("Project name must be at least 2 characters"):/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e)?K.existsSync(H.resolve(process.cwd(),e))?c.red("A folder with that name already exists"):true:c.red("Only lowercase letters, numbers, and single hyphens allowed. No spaces or special characters.")}),D=await select({message:c.bold.yellow("Select a project type"),default:"react-ts-tw",choices:_}),Q="bun";D!=="python-notebook"&&D!=="cpp-makefile"&&(Q=await select({message:c.bold.green("Select a package manager"),choices:$,default:"bun"}));var Je=await select({message:c.bold.cyan("Open in editor?"),choices:A,default:"no"}),Be={projectType:D,packageManager:Q,name:Ce,openInEditor:Je};await N(Be);
17
+ `;await rm(n,{recursive:true,force:true}),await writeFile(t,r,"utf-8");}async function Ee(e){let n=join(e,"package.json"),t=await readFile(n,"utf-8"),r=JSON.parse(t);r.devDependencies=r.devDependencies||{},r.devDependencies["@wxt-dev/i18n"]="0.2.5",await writeFile(n,JSON.stringify(r,null,2),"utf-8");let o=join(e,"wxt.config.ts"),a=await readFile(o,"utf-8");a=a.replace("manifest: {",`manifest: {
18
+ default_locale: "en",`),a.includes("modules: [")?a=a.replace("modules: [",'modules: ["@wxt-dev/i18n/module", '):a=a.replace("export default defineConfig({",`export default defineConfig({
19
+ modules: ["@wxt-dev/i18n/module"],`),await writeFile(o,a,"utf-8");let s=join(e,"locales");await mkdir(s,{recursive:true}),await writeFile(join(s,"en.yml"),`hello: Hello!
20
+ `,"utf-8");}function Ne(e,n){return async t=>{(e==="svelte"||e==="solid")&&!n.useContentUI&&await Fe(t),n.useI18n&&await Ee(t);}}async function M(e){let{name:n,packageManager:t,selectedFramework:r}=e;try{let o=await Me(r),a=await Oe(o);await l({templateName:Ie[o],name:n,packageManager:t,onBeforeInstall:Ne(o,a)});}catch(o){throw console.error(o),o}}function G(e,n){return async t=>{await l({templateName:e,name:t.name,packageManager:t.packageManager,...n});}}var Be={"react-ts-tw":G("react-ts-tw"),"next-ts-prisma":G("next-prisma"),wxt:async e=>{await M({name:e.name,packageManager:e.packageManager});},"uv-notebook":async e=>{await y({name:e.name});},"cmake-cpp":async e=>{await l({templateName:"cmake-cpp",name:e.name,packageManager:"bun",addManager:false,approveBuild:false,installDependency:false,changeName:false,onBeforeInstall:async n=>{await C(n,e.name),await S(n);}});}};async function O(e){let n=Be[e.projectType];if(!n){console.log(i.red("Project Type Not Implemented"),e.projectType);return}await n(e),e.openInEditor!=="no"&&await x(e.name,process.cwd(),e.openInEditor);}var Re=fileURLToPath(import.meta.url),ze=dirname(Re),He=join(ze,"../package.json"),Xe=JSON.parse(readFileSync(He,"utf8")),Ke=Xe.version;console.log(i.green("Kunver v"+i.bold(Ke)+`
21
+ `));var qe=await input({message:i.bold.blue("Enter a project name"),default:i.gray("my-project"),validate:e=>!e||e.trim().length<2?i.red("Project name must be at least 2 characters"):/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e)?H.existsSync(R.resolve(process.cwd(),e))?i.red("A folder with that name already exists"):true:i.red("Only lowercase letters, numbers, and single hyphens allowed. No spaces or special characters.")}),F=await select({message:i.bold.yellow("Select a project type"),default:"react-ts-tw",choices:J}),Q="bun";F!=="uv-notebook"&&F!=="cmake-cpp"&&(Q=await select({message:i.bold.green("Select a package manager"),choices:U,default:"bun"}));var Ge=await select({message:i.bold.cyan("Open in editor?"),choices:A,default:"no"}),Qe={projectType:F,packageManager:Q,name:qe,openInEditor:Ge};await O(Qe);
@@ -0,0 +1 @@
1
+ BasedOnStyle: Google
@@ -0,0 +1,14 @@
1
+ cmake_minimum_required(VERSION 3.20)
2
+
3
+ project(cmake_cpp_template LANGUAGES CXX)
4
+
5
+ set(CMAKE_CXX_STANDARD 20)
6
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
7
+ set(CMAKE_CXX_EXTENSIONS OFF)
8
+
9
+ add_executable(${PROJECT_NAME}
10
+ src/main.cpp
11
+ src/example.cpp
12
+ )
13
+
14
+ target_include_directories(${PROJECT_NAME} PRIVATE include)
@@ -0,0 +1,32 @@
1
+ # Cpp + CMake template
2
+
3
+ Opinionated C++ project starter with CMake build system.
4
+
5
+ ## Requirements
6
+
7
+ - CMake 3.20+
8
+ - Bun
9
+ - GCC, Clang, or MSVC
10
+ - VS Code C/C++ or CMake Tools extension
11
+
12
+ ## CLI behavior
13
+
14
+ - `kunver-new` runs `cmake -S . -B build` automatically after creating the project when CMake is available.
15
+ - If that step fails, the project is still created and you can run the command manually.
16
+
17
+ ## Manager bridge
18
+
19
+ - `bun manager.ts dev` configures, builds, and runs the app.
20
+ - `bun manager.ts build` configures if needed, then builds.
21
+ - `bun manager.ts run` runs the latest built executable.
22
+ - `bun manager.ts rebuild` deletes `build/`, then configures and builds again.
23
+ - `bun manager.ts clean` deletes `build/`.
24
+ - `bun manager.ts doctor` checks required files.
25
+
26
+ ## Raw CMake usage
27
+
28
+ - Configure: `cmake -S . -B build`
29
+ - Build: `cmake --build build`
30
+ - Run: use the executable generated inside `build/` by your chosen CMake generator.
31
+
32
+ Note: `kunver` rewrites the CMake project name to the folder name you enter during creation, and `manager.ts` reads that same name from `CMakeLists.txt`.
@@ -0,0 +1 @@
1
+ BasedOnStyle: Google
@@ -0,0 +1,9 @@
1
+ # Build artifacts
2
+ build/
3
+
4
+ # CMake cache and generated files
5
+ CMakeCache.txt
6
+ CMakeFiles/
7
+ cmake_install.cmake
8
+ compile_commands.json
9
+ Makefile
@@ -0,0 +1,8 @@
1
+ # About Project
2
+
3
+ - This is a minimal C++ project template that uses CMake as its build system.
4
+ - Source files live in `src/`, headers live in `include/`, and build output is generated in `build/`.
5
+ - The project targets C++20 and expects CMake 3.20 or newer.
6
+ - Prefer using `bun manager.ts dev` for configure + build + run during development.
7
+ - Other common commands are `bun manager.ts build`, `bun manager.ts run`, and `bun manager.ts clean`.
8
+ - If you change project structure, keep `CMakeLists.txt` in sync.
@@ -2,4 +2,4 @@
2
2
 
3
3
  #include <iostream>
4
4
 
5
- void printHello();
5
+ void printHello();
@@ -0,0 +1,276 @@
1
+ import { existsSync, readdirSync, readFileSync, rmSync } from "node:fs"
2
+ import { join } from "node:path"
3
+ import { platform } from "node:os"
4
+ import { spawn } from "node:child_process"
5
+
6
+ type CommandName = "help" | "doctor" | "configure" | "build" | "run" | "dev" | "rebuild" | "clean"
7
+
8
+ type ManagerOptions = {
9
+ config?: string
10
+ }
11
+
12
+ const ROOT_DIR = process.cwd()
13
+ const BUILD_DIR = join(ROOT_DIR, "build")
14
+ const IS_WINDOWS = platform() === "win32"
15
+
16
+ function print(message: string) {
17
+ process.stdout.write(`${message}\n`)
18
+ }
19
+
20
+ function printError(message: string) {
21
+ process.stderr.write(`${message}\n`)
22
+ }
23
+
24
+ function getProjectName() {
25
+ const cmakeListsPath = join(ROOT_DIR, "CMakeLists.txt")
26
+
27
+ if (!existsSync(cmakeListsPath)) {
28
+ return null
29
+ }
30
+
31
+ const cmakeListsContent = readFileSync(cmakeListsPath, "utf-8")
32
+ const match = cmakeListsContent.match(/project\s*\(\s*(?:"([^"]+)"|([^\s\)]+))/i)
33
+
34
+ return match?.[1] ?? match?.[2] ?? null
35
+ }
36
+
37
+ function parseArgs(argv: string[]) {
38
+ const [commandArg, ...rest] = argv
39
+ const command = (commandArg ?? "help") as CommandName
40
+ const options: ManagerOptions = {}
41
+
42
+ for (let index = 0; index < rest.length; index += 1) {
43
+ const arg = rest[index]
44
+
45
+ if ((arg === "--config" || arg === "-c") && rest[index + 1]) {
46
+ options.config = rest[index + 1]
47
+ index += 1
48
+ }
49
+ }
50
+
51
+ return { command, options }
52
+ }
53
+
54
+ function runCommand(command: string, args: string[], cwd = ROOT_DIR) {
55
+ return new Promise<boolean>(resolve => {
56
+ const child = spawn(command, args, {
57
+ cwd,
58
+ stdio: "inherit",
59
+ shell: false,
60
+ })
61
+
62
+ child.on("close", code => {
63
+ resolve(code === 0)
64
+ })
65
+
66
+ child.on("error", () => {
67
+ resolve(false)
68
+ })
69
+ })
70
+ }
71
+
72
+ async function ensureCmakeAvailable() {
73
+ const ok = await runCommand("cmake", ["--version"])
74
+ if (!ok) {
75
+ printError("CMake not found. Install CMake and ensure it is available in PATH.")
76
+ }
77
+ return ok
78
+ }
79
+
80
+ async function configure() {
81
+ print("Configuring project with CMake...")
82
+ return runCommand("cmake", ["-S", ".", "-B", "build"])
83
+ }
84
+
85
+ async function build(config?: string) {
86
+ print("Building project...")
87
+ const args = ["--build", "build"]
88
+
89
+ if (config) {
90
+ args.push("--config", config)
91
+ }
92
+
93
+ return runCommand("cmake", args)
94
+ }
95
+
96
+ function getCandidateExecutablePaths(config?: string) {
97
+ const projectName = getProjectName()
98
+ if (!projectName) {
99
+ return []
100
+ }
101
+
102
+ const executableName = IS_WINDOWS ? `${projectName}.exe` : projectName
103
+ const requestedConfig = config ? [config] : []
104
+ const commonConfigs = ["Debug", "Release", "RelWithDebInfo", "MinSizeRel"]
105
+ const configDirs = [...requestedConfig, ...commonConfigs]
106
+ const uniqueConfigDirs = [...new Set(configDirs)]
107
+
108
+ return [join(BUILD_DIR, executableName), ...uniqueConfigDirs.map(dir => join(BUILD_DIR, dir, executableName))]
109
+ }
110
+
111
+ function findBuiltExecutable(config?: string) {
112
+ const projectName = getProjectName()
113
+ if (!projectName) {
114
+ return null
115
+ }
116
+
117
+ for (const candidate of getCandidateExecutablePaths(config)) {
118
+ if (existsSync(candidate)) {
119
+ return candidate
120
+ }
121
+ }
122
+
123
+ if (!existsSync(BUILD_DIR)) {
124
+ return null
125
+ }
126
+
127
+ const topLevelEntries = readdirSync(BUILD_DIR, { withFileTypes: true })
128
+ for (const entry of topLevelEntries) {
129
+ if (!entry.isDirectory()) {
130
+ continue
131
+ }
132
+
133
+ const executableName = IS_WINDOWS ? `${projectName}.exe` : projectName
134
+ const candidate = join(BUILD_DIR, entry.name, executableName)
135
+ if (existsSync(candidate)) {
136
+ return candidate
137
+ }
138
+ }
139
+
140
+ return null
141
+ }
142
+
143
+ async function runBuiltApp(config?: string) {
144
+ const executablePath = findBuiltExecutable(config)
145
+
146
+ if (!executablePath) {
147
+ printError("Built executable not found. Run `bun manager.ts build` first.")
148
+ return false
149
+ }
150
+
151
+ print(`Running ${executablePath} ...`)
152
+ return runCommand(executablePath, [], ROOT_DIR)
153
+ }
154
+
155
+ function clean() {
156
+ if (!existsSync(BUILD_DIR)) {
157
+ print("Build directory does not exist. Nothing to clean.")
158
+ return true
159
+ }
160
+
161
+ rmSync(BUILD_DIR, { recursive: true, force: true })
162
+ print("Removed build directory.")
163
+ return true
164
+ }
165
+
166
+ function doctor() {
167
+ print("Checking project structure...")
168
+
169
+ const requiredPaths = ["CMakeLists.txt", "src/main.cpp", "src/example.cpp", "include/example.hpp"]
170
+ let ok = true
171
+
172
+ for (const requiredPath of requiredPaths) {
173
+ if (!existsSync(join(ROOT_DIR, requiredPath))) {
174
+ printError(`Missing required file: ${requiredPath}`)
175
+ ok = false
176
+ }
177
+ }
178
+
179
+ if (!getProjectName()) {
180
+ printError("Could not determine the project name from CMakeLists.txt")
181
+ ok = false
182
+ }
183
+
184
+ return ok
185
+ }
186
+
187
+ function printHelp() {
188
+ print("CMake C++ manager")
189
+ print("")
190
+ print("Usage:")
191
+ print(" bun manager.ts <command> [--config Debug]")
192
+ print("")
193
+ print("Commands:")
194
+ print(" help Show this help message")
195
+ print(" doctor Check whether required files exist")
196
+ print(" configure Run `cmake -S . -B build`")
197
+ print(" build Configure if needed, then build the project")
198
+ print(" run Run the built executable")
199
+ print(" dev Configure, build, and run the project")
200
+ print(" rebuild Remove build directory, then configure and build again")
201
+ print(" clean Remove the build directory")
202
+ }
203
+
204
+ async function main() {
205
+ const { command, options } = parseArgs(process.argv.slice(2))
206
+ const validCommands: CommandName[] = ["help", "doctor", "configure", "build", "run", "dev", "rebuild", "clean"]
207
+
208
+ if (!validCommands.includes(command)) {
209
+ printError(`Unknown command: ${command}`)
210
+ printHelp()
211
+ process.exit(1)
212
+ }
213
+
214
+ if (command === "help") {
215
+ printHelp()
216
+ return
217
+ }
218
+
219
+ if (command === "doctor") {
220
+ const ok = doctor()
221
+ process.exit(ok ? 0 : 1)
222
+ }
223
+
224
+ if (command === "clean") {
225
+ const ok = clean()
226
+ process.exit(ok ? 0 : 1)
227
+ }
228
+
229
+ if (!doctor()) {
230
+ process.exit(1)
231
+ }
232
+
233
+ if (!(await ensureCmakeAvailable())) {
234
+ process.exit(1)
235
+ }
236
+
237
+ if (command === "configure") {
238
+ process.exit((await configure()) ? 0 : 1)
239
+ }
240
+
241
+ if (command === "build") {
242
+ if (!existsSync(BUILD_DIR) && !(await configure())) {
243
+ process.exit(1)
244
+ }
245
+
246
+ process.exit((await build(options.config)) ? 0 : 1)
247
+ }
248
+
249
+ if (command === "run") {
250
+ process.exit((await runBuiltApp(options.config)) ? 0 : 1)
251
+ }
252
+
253
+ if (command === "dev") {
254
+ if (!(await configure())) {
255
+ process.exit(1)
256
+ }
257
+
258
+ if (!(await build(options.config))) {
259
+ process.exit(1)
260
+ }
261
+
262
+ process.exit((await runBuiltApp(options.config)) ? 0 : 1)
263
+ }
264
+
265
+ if (command === "rebuild") {
266
+ clean()
267
+
268
+ if (!(await configure())) {
269
+ process.exit(1)
270
+ }
271
+
272
+ process.exit((await build(options.config)) ? 0 : 1)
273
+ }
274
+ }
275
+
276
+ await main()
@@ -3,4 +3,4 @@
3
3
  int main() {
4
4
  printHello();
5
5
  return 0;
6
- }
6
+ }
@@ -1,39 +1,39 @@
1
- {
2
- "version": "0.2.0",
3
- "configurations": [
4
- {
5
- "name": "Debug Main Process",
6
- "type": "node",
7
- "request": "launch",
8
- "cwd": "${workspaceRoot}",
9
- "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-vite",
10
- "windows": {
11
- "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-vite.cmd"
12
- },
13
- "runtimeArgs": ["--sourcemap"],
14
- "env": {
15
- "REMOTE_DEBUGGING_PORT": "9222"
16
- }
17
- },
18
- {
19
- "name": "Debug Renderer Process",
20
- "port": 9222,
21
- "request": "attach",
22
- "type": "chrome",
23
- "webRoot": "${workspaceFolder}/src/renderer",
24
- "timeout": 60000,
25
- "presentation": {
26
- "hidden": true
27
- }
28
- }
29
- ],
30
- "compounds": [
31
- {
32
- "name": "Debug All",
33
- "configurations": ["Debug Main Process", "Debug Renderer Process"],
34
- "presentation": {
35
- "order": 1
36
- }
37
- }
38
- ]
39
- }
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "name": "Debug Main Process",
6
+ "type": "node",
7
+ "request": "launch",
8
+ "cwd": "${workspaceRoot}",
9
+ "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-vite",
10
+ "windows": {
11
+ "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron-vite.cmd"
12
+ },
13
+ "runtimeArgs": ["--sourcemap"],
14
+ "env": {
15
+ "REMOTE_DEBUGGING_PORT": "9222"
16
+ }
17
+ },
18
+ {
19
+ "name": "Debug Renderer Process",
20
+ "port": 9222,
21
+ "request": "attach",
22
+ "type": "chrome",
23
+ "webRoot": "${workspaceFolder}/src/renderer",
24
+ "timeout": 60000,
25
+ "presentation": {
26
+ "hidden": true
27
+ }
28
+ }
29
+ ],
30
+ "compounds": [
31
+ {
32
+ "name": "Debug All",
33
+ "configurations": ["Debug Main Process", "Debug Renderer Process"],
34
+ "presentation": {
35
+ "order": 1
36
+ }
37
+ }
38
+ ]
39
+ }
@@ -1,15 +1,15 @@
1
- {
2
- "[typescript]": {
3
- "editor.defaultFormatter": "esbenp.prettier-vscode"
4
- },
5
- "[javascript]": {
6
- "editor.defaultFormatter": "esbenp.prettier-vscode"
7
- },
8
- "[json]": {
9
- "editor.defaultFormatter": "esbenp.prettier-vscode"
10
- },
11
- "[svelte]": {
12
- "editor.defaultFormatter": "svelte.svelte-vscode"
13
- },
14
- "svelte.enable-ts-plugin": true
15
- }
1
+ {
2
+ "[typescript]": {
3
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
4
+ },
5
+ "[javascript]": {
6
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
7
+ },
8
+ "[json]": {
9
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
10
+ },
11
+ "[svelte]": {
12
+ "editor.defaultFormatter": "svelte.svelte-vscode"
13
+ },
14
+ "svelte.enable-ts-plugin": true
15
+ }
@@ -1,11 +1,11 @@
1
- # Getting Started
2
-
3
- ```bash
4
- npm run dev
5
- # or
6
- yarn dev
7
- # or
8
- pnpm dev
9
- # or
10
- bun dev
11
- ```
1
+ # Getting Started
2
+
3
+ ```bash
4
+ npm run dev
5
+ # or
6
+ yarn dev
7
+ # or
8
+ pnpm dev
9
+ # or
10
+ bun dev
11
+ ```
@@ -0,0 +1,12 @@
1
+ {
2
+ "semi": false,
3
+ "trailingComma": "all",
4
+ "singleQuote": false,
5
+ "printWidth": 120,
6
+ "tabWidth": 2,
7
+ "useTabs": false,
8
+ "jsxSingleQuote": false,
9
+ "jsxBracketSameLine": false,
10
+ "arrowParens": "avoid",
11
+ "plugins": ["prettier-plugin-tailwindcss"]
12
+ }
@@ -1 +1 @@
1
- @import "tailwindcss";
1
+ @import "tailwindcss";