@kunver/new 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.MD +33 -0
- package/dist/index.js +16 -5
- package/package.json +34 -37
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Burak Unver
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.MD
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Opiniated Project Starter
|
|
2
|
+
|
|
3
|
+
Cli tool for creating new projects with pre-configured settings.
|
|
4
|
+
|
|
5
|
+
## Using
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpx | npx | bun @kunver/new
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Starters
|
|
12
|
+
|
|
13
|
+
### Ready to use
|
|
14
|
+
|
|
15
|
+
✅
|
|
16
|
+
|
|
17
|
+
### Work in progress
|
|
18
|
+
|
|
19
|
+
🟡 React + TypeScript + Tailwind + Prettierconfig
|
|
20
|
+
|
|
21
|
+
### Will be added
|
|
22
|
+
|
|
23
|
+
🟡 Next.js + TypeScript + Tailwind + Prettierconfig
|
|
24
|
+
|
|
25
|
+
🟡 Wxt + React + TypeScript + Tailwind + Prettierconfig
|
|
26
|
+
|
|
27
|
+
🟡 Wxt + Svelte + TypeScript + Tailwind + Prettierconfig
|
|
28
|
+
|
|
29
|
+
🟡 Astro + TypeScript + Tailwind + Prettierconfig
|
|
30
|
+
|
|
31
|
+
🟡 Cpp + Cmake + bash Scripts
|
|
32
|
+
|
|
33
|
+
🟡 Golang
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{input as
|
|
2
|
+
import{input as _,select as I}from"@inquirer/prompts";import{spawn as B}from"child_process";import l from"chalk";import H from"ora";async function u(e,s){return new Promise(t=>{let r;switch(e){case"pnpm":r=`cd ${s} && pnpm install`;break;case"npm":r=`cd ${s} && npm install`;break;case"bun":r=`cd ${s} && bun install`;break;default:r=`cd ${s} && pnpm install`}let i=B(r,{shell:!0,cwd:process.cwd()}),a=H("Installing dependencies with "+l.blue(e)).start();a.color="white",i.stderr.pipe(process.stderr),i.on("close",n=>{n==0?(a.succeed("Installed dependencies for "+l.blue(s)),t(!0)):(a.fail("Failed to install dependencies for "+l.blue(s)),t(!1))})})}import{readFileSync as G,writeFileSync as g}from"fs";import{spawn as O}from"child_process";import p from"ora";import z from"chalk";function Q(e){let s=`${e}/vite.config.ts`,t=p("Editing vite.config.ts...").start();t.color="blue";try{let r=G(s,"utf-8");r.includes('import tailwindcss from "@tailwindcss/vite"')?t.info("Tailwind import already exists in vite.config.ts"):(r=`import tailwindcss from "@tailwindcss/vite"
|
|
3
|
+
`+r,r=r.replace(/plugins:\s*\[.*?\]/,"plugins: [react(), tailwindcss()]"),g(s,r,"utf-8"),t.succeed("Updated vite.config.ts with Tailwind import"))}catch(r){t.fail(`Failed to edit vite.config.ts: ${r}`),console.error(r)}}function U(e){let s=`${e}/src/index.css`,t='@import "tailwindcss";',r=p("Adding Tailwind directive to index.css...").start();g(s,t,"utf-8"),r.succeed("Added Tailwind directive to index.css")}async function w(e,s){return new Promise(t=>{let r="cd "+s+" && "+e+" install tailwindcss @tailwindcss/vite",i=O(r,{shell:!0,cwd:process.cwd()}),a=p("Installing Tailwind with "+z.blue(e)).start();a.color="blue",a.start(),i.on("close",n=>{n===0?(a.succeed("Installed tailwind"),Q(s),U(s),t(!0)):(a.fail("Failed to install tailwind"),t(!1))})})}var h=`
|
|
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
|
-
`,
|
|
15
|
+
`,b=`
|
|
15
16
|
#!/bin/bash
|
|
16
17
|
|
|
17
18
|
# Exit immediately if a command fails
|
|
@@ -41,6 +42,16 @@ 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{
|
|
45
|
-
`),
|
|
46
|
-
`),
|
|
45
|
+
`;import{writeFile as x}from"fs/promises";import{join as d}from"path";import{execSync as W}from"child_process";import L from"chalk";import V from"ora";async function y(e){let s=d(process.cwd(),e),t=d(s,"push.sh"),r=V("Copying config files to "+L.blue(e)).start();r.color="blue";try{await Promise.all([x(d(s,".prettierrc.json"),h),x(t,b)]),W(`chmod +x "${t}"`),r.succeed("Config files copied and push.sh is executable")}catch(i){r.fail("Failed to copy config files or set permissions"),console.error(i)}}import{spawn as q}from"child_process";import J from"ora";import m from"chalk";function k(e,s){let t;switch(e){case"pnpm":t=`pnpm create vite ${s} --template react-swc-ts`;break;case"npm":t=`npm create vite@latest ${s} -- --template react-swc-ts`;break;case"bun":t=`bun create vite ${s} --template react-swc-ts`;break;default:t=`pnpm create vite ${s} --template react-swc-ts`}return new Promise(r=>{let i=q(t,{shell:!0,cwd:process.cwd()}),a=J("Creating React project "+m.blue(s)).start();a.color="blue",i.on("close",n=>{n===0?(a.succeed("Created React project at "+m.blue(s)),r(!0)):(a.fail("Failed to create React project at "+m.blue(s)),r(!1))})})}import{spawn as K}from"child_process";import X from"ora";async function v(e){return new Promise((s,t)=>{let r="cd "+e+" && pnpm approve-builds",i=K(r,{shell:!0,cwd:process.cwd()}),a=X("Approving builds").start();i.stdout.pipe(process.stdout),i.stderr.pipe(process.stderr),setTimeout(()=>{i.stdin.write(`a
|
|
46
|
+
`),setTimeout(()=>{i.stdin.write(`y
|
|
47
|
+
`),i.stdin.end()},500)},500),i.on("close",n=>{n===0?(a.succeed("Builds approved."),s(!0)):(a.fail("Failed to approve builds."),t(new Error(`Process exited with code ${n}`)))}),i.on("error",n=>{a.fail(`Failed to start process. Error: ${n.message}`),t(n)})})}import{writeFile as $,unlink as F,rm as Y}from"fs/promises";import c from"ora";import{spawn as Z}from"child_process";async function j(e){let s=`${e}/README.md`,t=c("Editing README.md...").start();t.color="white";try{let r=`# ${e}`;await $(s,r,"utf-8"),t.succeed("Updated README.md")}catch(r){t.fail(`Failed to edit README.md: ${r}`),console.error(r)}}async function P(e){let s=`${e}/src/assets`,t=c("Deleting assets...").start();t.color="white";try{await Y(s,{recursive:!0,force:!0}),t.succeed("Deleted assets")}catch(r){t.fail(`Failed to delete assets: ${r}`),console.error(r)}}async function C(e){let s=`${e}/src/app.css`,t=c("Deleting app.css...").start();t.color="white";try{await F(s),t.succeed("Deleted app.css")}catch(r){t.fail(`Failed to delete app.css: ${r}`),console.error(r)}}async function R(e){let s=`${e}/src/app.tsx`,t=c("Clearing app.tsx...").start();t.color="white";let r=`
|
|
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 $(s,r,"utf-8"),t.succeed("Cleared app.tsx")}catch(i){t.fail(`Failed to clear app.tsx: ${i}`),console.error(i)}}async function M(e){let s=`${e}/eslint.config.js`,t=c("Deleting eslint.config.js...").start();t.color="white";try{await F(s),t.succeed("Deleted eslint.config.js")}catch(r){t.fail(`Failed to delete eslint.config.js: ${r}`),console.error(r)}}async function T(e,s){let t="cd "+e+" && "+s+" remove @eslint/js eslint eslint-plugin-react-hooks eslint-plugin-react-refresh globals typescript-eslint";return new Promise(r=>{let i=Z(t,{shell:!0,cwd:process.cwd()}),a=c("Removing packages...").start();a.color="white",a.start(),i.on("close",n=>{n===0?(a.succeed("Removed packages"),r(!0)):(a.fail("Failed to remove packages"),r(!1))})})}async function A(e,s){await Promise.all([C(e),P(e),M(e),R(e),j(e),T(e,s)])}async function E(e){let{name:s,packageManager:t}=e;await k(t,s)&&(await u(t,s),await y(s),await w(t,s),t==="pnpm"&&await v(s),await A(s,t))}var D=["react-ts-tw","next-ts","wxt-react","wxt-svelte"],S=["pnpm","npm","bun"];function f(e){switch(e.projectType){case"react-ts-tw":E({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 o from"chalk";import N from"fs";import ee from"path";var te=await _({message:o.bold.blue("Enter a project name"),default:o.gray("my-project"),validate:e=>!e||e.trim().length<2?o.red("Project name must be at least 2 characters"):/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e)?N.existsSync(ee.resolve(process.cwd(),e))?o.red("A folder with that name already exists"):!0:o.red("Only lowercase letters, numbers, and single hyphens allowed. No spaces or special characters.")}),se=await I({message:o.bold.green("Select a package manager"),choices:S,default:"pnpm"}),re=await I({message:o.bold.yellow("Select a project type"),default:"react-ts-tw",choices:D}),ie={projectType:re,packageManager:se,name:te};f(ie);
|
package/package.json
CHANGED
|
@@ -1,37 +1,34 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@kunver/new",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Opiniated project starter",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"kunver": "dist/index.js"
|
|
8
|
-
},
|
|
9
|
-
"main": "dist/index.js",
|
|
10
|
-
"files": [
|
|
11
|
-
"dist"
|
|
12
|
-
],
|
|
13
|
-
"publishConfig": {
|
|
14
|
-
"access": "public"
|
|
15
|
-
},
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"ora": "^8.2.0"
|
|
36
|
-
}
|
|
37
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@kunver/new",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "Opiniated project starter",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"kunver": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [],
|
|
17
|
+
"author": "Burak Unver <burakhanunver@gmail.com> (https://kunver.dev)",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/node": "^24.0.13",
|
|
21
|
+
"tsup": "^8.2.2",
|
|
22
|
+
"typescript": "^5.5.4"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@inquirer/prompts": "^7.6.0",
|
|
26
|
+
"chalk": "^5.4.1",
|
|
27
|
+
"ora": "^8.2.0"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsup",
|
|
31
|
+
"start": "pnpm run build && node dist/index.js",
|
|
32
|
+
"local": "pnpm link --global"
|
|
33
|
+
}
|
|
34
|
+
}
|