@kunver/new 1.1.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/dist/index.js +46 -0
- package/package.json +37 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
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=`
|
|
3
|
+
{
|
|
4
|
+
"semi": false,
|
|
5
|
+
"trailingComma": "all",
|
|
6
|
+
"singleQuote": false,
|
|
7
|
+
"printWidth": 120,
|
|
8
|
+
"tabWidth": 2,
|
|
9
|
+
"useTabs": false,
|
|
10
|
+
"jsxSingleQuote": false,
|
|
11
|
+
"jsxBracketSameLine": false,
|
|
12
|
+
"arrowParens": "avoid"
|
|
13
|
+
}
|
|
14
|
+
`,h=`
|
|
15
|
+
#!/bin/bash
|
|
16
|
+
|
|
17
|
+
# Exit immediately if a command fails
|
|
18
|
+
set -e
|
|
19
|
+
|
|
20
|
+
# Switch to the main branch
|
|
21
|
+
git checkout main
|
|
22
|
+
|
|
23
|
+
# Merge the dev branch into main
|
|
24
|
+
git merge dev
|
|
25
|
+
if [ $? -ne 0 ]; then
|
|
26
|
+
echo "\u274C Merge conflict occurred. Please resolve it manually."
|
|
27
|
+
exit 1
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
# Push changes to GitHub
|
|
31
|
+
git push origin main
|
|
32
|
+
if [ $? -ne 0 ]; then
|
|
33
|
+
echo "\u274C Failed to push changes to GitHub. Please check your network connection and permissions."
|
|
34
|
+
exit 1
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
echo "\u2705 Successfully merged 'dev' into 'main' and pushed to GitHub!"
|
|
38
|
+
|
|
39
|
+
git checkout dev
|
|
40
|
+
if [ $? -ne 0 ]; then
|
|
41
|
+
echo "\u274C Failed to switch back to the 'dev' branch."
|
|
42
|
+
exit 1
|
|
43
|
+
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);
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kunver/new",
|
|
3
|
+
"version": "1.1.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
|
+
"scripts": {
|
|
17
|
+
"build": "tsup",
|
|
18
|
+
"start": "pnpm run build && node dist/index.js",
|
|
19
|
+
"prepublishOnly": "pnpm run build",
|
|
20
|
+
"publish": "pnpm run build && npm publish",
|
|
21
|
+
"local": "pnpm link --global"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [],
|
|
24
|
+
"author": "Burak Unver <burakhanunver@gmail.com> (https://kunver.dev)",
|
|
25
|
+
"license": "ISC",
|
|
26
|
+
"packageManager": "pnpm@10.13.1",
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^24.0.13",
|
|
29
|
+
"tsup": "^8.2.2",
|
|
30
|
+
"typescript": "^5.5.4"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@inquirer/prompts": "^7.6.0",
|
|
34
|
+
"chalk": "^5.4.1",
|
|
35
|
+
"ora": "^8.2.0"
|
|
36
|
+
}
|
|
37
|
+
}
|