@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.
- package/README.MD +26 -18
- package/dist/index.js +16 -10
- package/dist/templates/cmake-cpp/.clang-format +1 -0
- package/dist/templates/cmake-cpp/CMakeLists.txt +14 -0
- package/dist/templates/cmake-cpp/README.md +32 -0
- package/dist/templates/cmake-cpp/_clang-format +1 -0
- package/dist/templates/cmake-cpp/_gitignore +9 -0
- package/dist/templates/cmake-cpp/agents.md +8 -0
- package/dist/templates/{make-cpp → cmake-cpp}/include/example.hpp +1 -1
- package/dist/templates/cmake-cpp/manager.ts +276 -0
- package/dist/templates/{make-cpp → cmake-cpp}/src/main.cpp +1 -1
- package/dist/templates/electron-svelte/.vscode/launch.json +39 -39
- package/dist/templates/electron-svelte/.vscode/settings.json +15 -15
- package/dist/templates/next-prisma/README.md +11 -11
- package/dist/templates/next-prisma/_prettierrc.json +12 -0
- package/dist/templates/next-prisma/app/globals.css +1 -1
- package/dist/templates/next-prisma/app/layout.tsx +21 -21
- package/dist/templates/next-prisma/app/page.tsx +7 -7
- package/dist/templates/next-prisma/lib/prisma.ts +11 -11
- package/dist/templates/next-prisma/manager.cjs +71 -69
- package/dist/templates/next-prisma/next.config.ts +7 -7
- package/dist/templates/next-prisma/package.json +33 -33
- package/dist/templates/next-prisma/postcss.config.mjs +5 -5
- package/dist/templates/next-prisma/tsconfig.json +27 -27
- package/dist/templates/react-ts-tw/README.md +1 -1
- package/dist/templates/react-ts-tw/_prettierrc.json +12 -0
- package/dist/templates/react-ts-tw/index.html +13 -13
- package/dist/templates/react-ts-tw/manager.cjs +71 -69
- package/dist/templates/react-ts-tw/package.json +30 -30
- package/dist/templates/react-ts-tw/src/App.tsx +9 -9
- package/dist/templates/react-ts-tw/src/index.css +1 -1
- package/dist/templates/react-ts-tw/src/main.tsx +10 -10
- package/dist/templates/react-ts-tw/src/vite-env.d.ts +1 -1
- package/dist/templates/react-ts-tw/tsconfig.app.json +27 -27
- package/dist/templates/react-ts-tw/tsconfig.json +4 -7
- package/dist/templates/react-ts-tw/tsconfig.node.json +25 -25
- package/dist/templates/react-ts-tw/vite.config.ts +8 -8
- package/dist/templates/wxt-solid/README.md +3 -3
- package/dist/templates/wxt-solid/_prettierrc.json +11 -0
- package/dist/templates/wxt-solid/agents.md +76 -76
- package/dist/templates/wxt-solid/assets/tailwind.css +1 -1
- package/dist/templates/wxt-solid/entrypoints/background.ts +3 -3
- package/dist/templates/wxt-solid/entrypoints/content/Content.tsx +7 -7
- package/dist/templates/wxt-solid/entrypoints/content/main.tsx +31 -31
- package/dist/templates/wxt-solid/entrypoints/options/{App.tsx → Options.tsx} +0 -1
- package/dist/templates/wxt-solid/entrypoints/options/index.html +13 -13
- package/dist/templates/wxt-solid/entrypoints/options/main.tsx +2 -2
- package/dist/templates/wxt-solid/entrypoints/popup/index.html +13 -13
- package/dist/templates/wxt-solid/entrypoints/popup/main.tsx +2 -2
- package/dist/templates/wxt-solid/manager.cjs +71 -69
- package/dist/templates/wxt-solid/package.json +33 -33
- package/dist/templates/wxt-solid/tsconfig.json +7 -7
- package/dist/templates/wxt-solid/wxt.config.ts +18 -18
- package/dist/templates/wxt-svelte/.vscode/extensions.json +3 -3
- package/dist/templates/wxt-svelte/README.md +3 -3
- package/dist/templates/wxt-svelte/_prettierrc.json +11 -0
- package/dist/templates/wxt-svelte/agents.md +77 -77
- package/dist/templates/wxt-svelte/assets/tailwind.css +1 -1
- package/dist/templates/wxt-svelte/entrypoints/background.ts +3 -3
- package/dist/templates/wxt-svelte/entrypoints/content/index.ts +4 -4
- package/dist/templates/wxt-svelte/entrypoints/options/index.html +13 -13
- package/dist/templates/wxt-svelte/entrypoints/options/main.ts +2 -2
- package/dist/templates/wxt-svelte/entrypoints/popup/index.html +13 -13
- package/dist/templates/wxt-svelte/entrypoints/popup/main.ts +2 -2
- package/dist/templates/wxt-svelte/manager.cjs +71 -69
- package/dist/templates/wxt-svelte/package.json +36 -36
- package/dist/templates/wxt-svelte/tsconfig.json +6 -6
- package/dist/templates/wxt-svelte/wxt-env.d.ts +1 -1
- package/dist/templates/wxt-svelte/wxt.config.ts +18 -18
- package/dist/templates/wxt-vanilla/README.md +3 -3
- package/dist/templates/wxt-vanilla/_prettierrc.json +11 -0
- package/dist/templates/wxt-vanilla/agents.md +73 -73
- package/dist/templates/wxt-vanilla/entrypoints/background.ts +3 -3
- package/dist/templates/wxt-vanilla/entrypoints/content.ts +6 -6
- package/dist/templates/wxt-vanilla/entrypoints/popup/index.html +13 -13
- package/dist/templates/wxt-vanilla/entrypoints/popup/main.ts +1 -1
- package/dist/templates/wxt-vanilla/manager.cjs +71 -69
- package/dist/templates/wxt-vanilla/package.json +25 -25
- package/dist/templates/wxt-vanilla/tsconfig.json +3 -3
- package/dist/templates/wxt-vanilla/wxt.config.ts +13 -13
- package/package.json +18 -5
- package/dist/templates/electron-svelte/README.md +0 -3
- package/dist/templates/electron-svelte/_gitignore +0 -6
- package/dist/templates/electron-svelte/build/entitlements.mac.plist +0 -12
- package/dist/templates/electron-svelte/build/icon.icns +0 -0
- package/dist/templates/electron-svelte/build/icon.ico +0 -0
- package/dist/templates/electron-svelte/build/icon.png +0 -0
- package/dist/templates/electron-svelte/bun.lock +0 -1154
- package/dist/templates/electron-svelte/electron-builder.yml +0 -44
- package/dist/templates/electron-svelte/electron.vite.config.ts +0 -15
- package/dist/templates/electron-svelte/manager.cjs +0 -69
- package/dist/templates/electron-svelte/package.json +0 -44
- package/dist/templates/electron-svelte/resources/icon.png +0 -0
- package/dist/templates/electron-svelte/src/main/index.ts +0 -62
- package/dist/templates/electron-svelte/src/preload/index.d.ts +0 -8
- package/dist/templates/electron-svelte/src/preload/index.ts +0 -22
- package/dist/templates/electron-svelte/src/renderer/index.html +0 -16
- package/dist/templates/electron-svelte/src/renderer/src/App.svelte +0 -8
- package/dist/templates/electron-svelte/src/renderer/src/assets/main.css +0 -1
- package/dist/templates/electron-svelte/src/renderer/src/env.d.ts +0 -2
- package/dist/templates/electron-svelte/src/renderer/src/main.ts +0 -11
- package/dist/templates/electron-svelte/svelte.config.mjs +0 -7
- package/dist/templates/electron-svelte/tsconfig.json +0 -4
- package/dist/templates/electron-svelte/tsconfig.node.json +0 -11
- package/dist/templates/electron-svelte/tsconfig.web.json +0 -17
- package/dist/templates/make-cpp/Makefile +0 -44
- package/dist/templates/make-cpp/README.md +0 -15
- /package/dist/templates/{make-cpp → cmake-cpp}/src/example.cpp +0 -0
- /package/dist/templates/wxt-solid/entrypoints/popup/{App.tsx → Popup.tsx} +0 -0
- /package/dist/templates/wxt-svelte/entrypoints/content/{App.svelte → Content.svelte} +0 -0
- /package/dist/templates/wxt-svelte/entrypoints/options/{App.svelte → Options.svelte} +0 -0
- /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
|
-
|
|
3
|
+
CLI tool for creating new projects with pre-configured settings.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
[](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
|
-
|
|
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
|
-
|
|
24
|
+
## Notes
|
|
17
25
|
|
|
18
|
-
|
|
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
|
-
|
|
29
|
+
## Package managers
|
|
21
30
|
|
|
22
|
-
|
|
31
|
+
- Bun
|
|
32
|
+
- pnpm
|
|
33
|
+
- npm
|
|
23
34
|
|
|
24
|
-
|
|
35
|
+
Some starters intentionally skip package manager selection because they do not need JS dependencies.
|
|
25
36
|
|
|
26
|
-
|
|
37
|
+
## Output
|
|
27
38
|
|
|
28
|
-
|
|
39
|
+
Generated templates live under [src/public/templates](src/public/templates) in this repository.
|
|
29
40
|
|
|
30
|
-
|
|
41
|
+
## Status
|
|
31
42
|
|
|
32
|
-
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
`
|
|
5
|
-
|
|
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
|
-
|
|
12
|
-
default_locale: "en",`),
|
|
13
|
-
modules: ["@wxt-dev/i18n/module"],`),await writeFile(
|
|
14
|
-
`,"utf-8");}
|
|
15
|
-
`));var
|
|
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,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.
|
|
@@ -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()
|
|
@@ -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";
|