@kunver/new 1.4.1 → 1.5.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 CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import{input as _,select as u}from"@inquirer/prompts";import{execa as v}from"execa";import d from"chalk";import T from"ora";async function i(e,t,a){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 o=T("Installing dependencies with "+d.blue(e)).start();try{return await v(r,{shell:!0,cwd:a}),o.succeed("Installed dependencies for "+d.blue(t)),!0}catch{return o.fail("Failed to install dependencies for "+d.blue(t)),!1}}import F from"fs-extra";import A from"ora";async function g(e,t){let a=A("Copying template folder...").start();try{return await F.copy(e,t),a.succeed("Copied template folder"),!0}catch{return a.fail("Failed to copy template folder"),!1}}import w from"ora";import s from"chalk";import{execa as I}from"execa";import{spawn as E}from"child_process";async function p(e,t){let a=w("Approving builds for "+s.blue(e)).start();try{return new Promise(r=>{let o=E("pnpm",["approve-builds"],{cwd:`${t}/${e}`,stdio:["pipe","inherit","inherit"],shell:!0});setTimeout(()=>{o.stdin?.write(`a
2
+ import G from"fs";import H from"path";import{input as K,select as y}from"@inquirer/prompts";import c from"chalk";import{join as x}from"path";import{fileURLToPath as B}from"url";import C from"path";import{execa as I}from"execa";import g from"chalk";import $ from"ora";async function i(e,t,a){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 o=$("Installing dependencies with "+g.blue(e)).start();try{return await I(r,{shell:!0,cwd:a}),o.succeed("Installed dependencies for "+g.blue(t)),!0}catch{return o.fail("Failed to install dependencies for "+g.blue(t)),!1}}import E from"fs-extra";import S from"ora";async function p(e,t){let a=S("Copying template folder...").start();try{return await E.copy(e,t),a.succeed("Copied template folder"),!0}catch{return a.fail("Failed to copy template folder"),!1}}import{spawn as O}from"child_process";import k from"ora";import s from"chalk";import{execa as _}from"execa";async function l(e,t){let a=k("Approving builds for "+s.blue(e)).start();try{return new Promise(r=>{let o=O("pnpm",["approve-builds"],{cwd:`${t}/${e}`,stdio:["pipe","inherit","inherit"],shell:!0});setTimeout(()=>{o.stdin?.write(`a
3
3
  `),setTimeout(()=>{o.stdin?.write(`y
4
- `),o.stdin?.end()},1e3)},2e3),o.on("close",n=>{n===0?(a.succeed("Approved builds for "+s.blue(e)),r(!0)):(a.fail("Failed to approve builds for "+s.blue(e)),r(!1))}),o.on("error",n=>{a.fail("Failed to approve builds for "+s.blue(e)),console.error(n),r(!1)})})}catch(r){return a.fail("Failed to approve builds for "+s.blue(e)),console.error(r),!1}}async function l(e,t){let a=`cd ${e} && bun pm trust --all`,r=w("Approving builds for "+s.blue(e)).start();try{return await I(a,{shell:!0,cwd:t}),r.succeed("Approved builds for "+s.blue(e)),!0}catch{return r.fail("Failed to approve builds for "+s.blue(e)),!1}}import{join as b}from"path";import{fileURLToPath as $}from"url";import P from"path";var O=$(import.meta.url),B=P.dirname(O);async function y(e){let{name:t,packageManager:a,cwd:r=process.cwd()}=e,o=b(B,"templates","react-ts-tw");try{if(!await g(o,b(r,t)))throw new Error("Failed to copy template folder");if(!await i(a,t,r))throw new Error("Failed to install dependencies");return a==="pnpm"?await p(t,r):a==="bun"&&await l(t,r),!0}catch(n){throw console.error("Error creating React project:",n),n}}import{select as C}from"@inquirer/prompts";import D from"chalk";import{join as S}from"path";var W=["react - !not ready","vue - !not ready","svelte","vanilla - !not ready","solid - !not ready"];async function h(e){let{name:t,packageManager:a,cwd:r=process.cwd(),selectedFramework:o}=e;try{let n=o||await C({message:D.bold.magenta("Select a framework for WXT"),choices:W,default:"svelte"});if(!1){let J=S(r,t);await i(a,t,r),a==="pnpm"?await p(t,r):a==="bun"&&await l(t,r)}}catch(n){console.error(n)}}import{execa as R}from"execa";import m from"chalk";async function k(e,t,a){console.log(m.white("Opening "+m.blue(e)+" in "+m.green(a)));try{return await R(`${a} ${e}`,{shell:!0,cwd:t}),!0}catch(r){return console.error(m.red("Failed to open project in editor:"),r),!1}}var x=["react-ts-tw","next-ts - !not ready","wxt","cpp-cmake - !not ready"],j=["bun","pnpm","npm"];async function f(e){switch(e.projectType){case"react-ts-tw":await y({name:e.name,packageManager:e.packageManager});break;case"next-ts - !not ready":console.log("next-ts",e.packageManager,e.name);break;case"wxt":await h({name:e.name,packageManager:e.packageManager});break;case"cpp-cmake - !not ready":console.log("cpp-cmake",e.packageManager,e.name);break;default:console.log("Invalid project type",e.projectType);break}e.openInEditor!=="no"&&await k(e.name,process.cwd(),e.openInEditor)}import c from"chalk";import z from"fs";import L from"path";var U=await _({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)?z.existsSync(L.resolve(process.cwd(),e))?c.red("A folder with that name already exists"):!0:c.red("Only lowercase letters, numbers, and single hyphens allowed. No spaces or special characters.")}),X=await u({message:c.bold.green("Select a package manager"),choices:j,default:"bun"}),q=await u({message:c.bold.yellow("Select a project type"),default:"react-ts-tw",choices:x}),G=await u({message:c.bold.cyan("Open in editor?"),choices:["no","windsurf","cursor","code"],default:"no"}),H={projectType:q,packageManager:X,name:U,openInEditor:G};await f(H);
4
+ `),o.stdin?.end()},1e3)},2e3),o.on("close",n=>{n===0?(a.succeed("Approved builds for "+s.blue(e)),r(!0)):(a.fail("Failed to approve builds for "+s.blue(e)),r(!1))}),o.on("error",n=>{a.fail("Failed to approve builds for "+s.blue(e)),console.error(n),r(!1)})})}catch(r){return a.fail("Failed to approve builds for "+s.blue(e)),console.error(r),!1}}async function m(e,t){let a=`cd ${e} && bun pm trust --all`,r=k("Approving builds for "+s.blue(e)).start();try{return await _(a,{shell:!0,cwd:t}),r.succeed("Approved builds for "+s.blue(e)),!0}catch{return r.fail("Failed to approve builds for "+s.blue(e)),!1}}var D=B(import.meta.url),R=C.dirname(D);async function j(e){let{name:t,packageManager:a,cwd:r=process.cwd()}=e,o=x(R,"templates","react-ts-tw");try{if(!await p(o,x(r,t)))throw new Error("Failed to copy template folder");if(!await i(a,t,r))throw new Error("Failed to install dependencies");return a==="pnpm"?await l(t,r):a==="bun"&&await m(t,r),!0}catch(n){throw console.error("Error creating React project:",n),n}}import{join as d}from"path";import{fileURLToPath as W}from"url";import J from"path";import z from"chalk";import{select as L}from"@inquirer/prompts";import v from"fs";var U=["react - !not ready","vue - !not ready","svelte","vanilla - !not ready","solid - !not ready"],X=W(import.meta.url),M=J.dirname(X);async function T(e){let{name:t,packageManager:a,cwd:r=process.cwd(),selectedFramework:o}=e;try{let n=o||await L({message:z.bold.magenta("Select a framework for WXT"),choices:U,default:"svelte"}),u=d(M,"templates","wxt-svelte");if(n==="svelte"&&(u=d(M,"templates","wxt-svelte")),await p(u,d(r,t))){let b=d(r,t,"package.json"),h=JSON.parse(v.readFileSync(b,"utf-8"));h.scripts.manager=`node manager.cjs ${a}`,v.writeFileSync(b,JSON.stringify(h,null,2)),await i(a,t,r),a==="pnpm"?await l(t,r):a==="bun"&&await m(t,r)}}catch(n){console.error(n)}}import{execa as q}from"execa";import f from"chalk";async function F(e,t,a){console.log(f.white("Opening "+f.blue(e)+" in "+f.green(a)));try{return await q(`${a} ${e}`,{shell:!0,cwd:t}),!0}catch(r){return console.error(f.red("Failed to open project in editor:"),r),!1}}var P=["react-ts-tw","next-ts - !not ready","wxt","cpp-cmake - !not ready"],A=["bun","pnpm","npm"];async function w(e){switch(e.projectType){case"react-ts-tw":await j({name:e.name,packageManager:e.packageManager});break;case"next-ts - !not ready":console.log("next-ts",e.packageManager,e.name);break;case"wxt":await T({name:e.name,packageManager:e.packageManager});break;case"cpp-cmake - !not ready":console.log("cpp-cmake",e.packageManager,e.name);break;default:console.log("Invalid project type",e.projectType);break}e.openInEditor!=="no"&&await F(e.name,process.cwd(),e.openInEditor)}var Q=await K({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)?G.existsSync(H.resolve(process.cwd(),e))?c.red("A folder with that name already exists"):!0:c.red("Only lowercase letters, numbers, and single hyphens allowed. No spaces or special characters.")}),V=await y({message:c.bold.green("Select a package manager"),choices:A,default:"bun"}),Y=await y({message:c.bold.yellow("Select a project type"),default:"react-ts-tw",choices:P}),Z=await y({message:c.bold.cyan("Open in editor?"),choices:["no","windsurf","cursor","code"],default:"no"}),N={projectType:Y,packageManager:V,name:Q,openInEditor:Z};await w(N);
@@ -18,7 +18,7 @@ function runCommand(command) {
18
18
  })
19
19
  }
20
20
 
21
- async function publishAndPushOperations(command) {
21
+ async function publishAndPushOperations(packageManager, command) {
22
22
  console.log("Switching to main branch...")
23
23
  if (!await runCommand("git checkout main")) {
24
24
  process.exit(1)
@@ -39,9 +39,9 @@ async function publishAndPushOperations(command) {
39
39
  console.log("✅ Successfully merged 'dev' into 'main' and pushed to GitHub!")
40
40
 
41
41
  if (command === "publish") {
42
- console.log("Publishing package (pnpm publish)...")
43
- if (!await runCommand("pnpm publish")) {
44
- console.log("❌ pnpm publish command failed.")
42
+ console.log(`Publishing package (${packageManager} publish)...`)
43
+ if (!await runCommand(`${packageManager} publish`)) {
44
+ console.log(`❌ ${packageManager} publish command failed.`)
45
45
  process.exit(1)
46
46
  }
47
47
  }
@@ -55,10 +55,15 @@ async function publishAndPushOperations(command) {
55
55
  console.log("✅ All operations completed.")
56
56
  }
57
57
 
58
- const commandArg = process.argv[2]
58
+ const packageManagerArg = process.argv[2]
59
+ const commandArg = process.argv[3]
59
60
 
60
- if (commandArg === "push" || commandArg === "publish") {
61
- publishAndPushOperations(commandArg)
62
- } else {
63
- console.log(`Invalid or missing command: '${commandArg || ""}'. Usage: node manager.js [push|publish]`)
61
+ const validManagers = ["pnpm", "npm", "yarn", "bun"]
62
+ const validCommands = ["push", "publish"]
63
+
64
+ if (!validManagers.includes(packageManagerArg) || !validCommands.includes(commandArg)) {
65
+ console.log(`Invalid or missing arguments. Usage: node manager.cjs <package-manager> <push|publish>\nValid package managers: ${validManagers.join(", ")}`)
66
+ process.exit(1)
64
67
  }
68
+
69
+ publishAndPushOperations(packageManagerArg, commandArg)
@@ -0,0 +1,11 @@
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
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "recommendations": ["svelte.svelte-vscode"]
3
+ }
@@ -0,0 +1,3 @@
1
+ # Wxt + Svelte + Tailwind + Typescript
2
+
3
+ Web extension starter
@@ -0,0 +1,69 @@
1
+ const { exec } = require("child_process")
2
+
3
+ function runCommand(command) {
4
+ return new Promise((resolve, reject) => {
5
+ exec(command, { shell: true }, (error, stdout, stderr) => {
6
+ if (error) {
7
+ console.log(`❌ Error occurred: ${error.message}`)
8
+ if (stderr) {
9
+ console.log(`Standard Error: ${stderr.trim()}`)
10
+ }
11
+ return resolve(false)
12
+ }
13
+ if (stdout) {
14
+ console.log(stdout.trim())
15
+ }
16
+ resolve(true)
17
+ })
18
+ })
19
+ }
20
+
21
+ async function publishAndPushOperations(packageManager, command) {
22
+ console.log("Switching to main branch...")
23
+ if (!await runCommand("git checkout main")) {
24
+ process.exit(1)
25
+ }
26
+
27
+ console.log("Merging dev branch into main...")
28
+ if (!await runCommand("git merge dev")) {
29
+ console.log("❌ Merge conflict occurred. Please resolve it manually.")
30
+ process.exit(1)
31
+ }
32
+
33
+ console.log("Pushing changes to GitHub...")
34
+ if (!await runCommand("git push origin main")) {
35
+ console.log("❌ Failed to push changes to GitHub. Please check your network connection and permissions.")
36
+ process.exit(1)
37
+ }
38
+
39
+ console.log("✅ Successfully merged 'dev' into 'main' and pushed to GitHub!")
40
+
41
+ if (command === "publish") {
42
+ console.log(`Publishing package (${packageManager} publish)...`)
43
+ if (!await runCommand(`${packageManager} publish`)) {
44
+ console.log(`❌ ${packageManager} publish command failed.`)
45
+ process.exit(1)
46
+ }
47
+ }
48
+
49
+ console.log("Switching back to dev branch...")
50
+ if (!await runCommand("git checkout dev")) {
51
+ console.log("❌ Failed to switch back to the 'dev' branch.")
52
+ process.exit(1)
53
+ }
54
+
55
+ console.log("✅ All operations completed.")
56
+ }
57
+
58
+ const packageManagerArg = process.argv[2]
59
+ const commandArg = process.argv[3]
60
+
61
+ const validManagers = ["pnpm", "npm", "yarn", "bun"]
62
+ const validCommands = ["push", "publish"]
63
+
64
+ if (!validManagers.includes(packageManagerArg) || !validCommands.includes(commandArg)) {
65
+ console.log(`Invalid or missing arguments. Usage: node manager.cjs <package-manager> <push|publish>\nValid package managers: ${validManagers.join(", ")}`)
66
+ process.exit(1)
67
+ }
68
+
69
+ publishAndPushOperations(packageManagerArg, commandArg)
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "wxt-svelte-starter",
3
+ "description": "manifest.json description",
4
+ "private": true,
5
+ "version": "0.0.0",
6
+ "type": "module",
7
+ "scripts": {
8
+ "dev": "wxt",
9
+ "dev:firefox": "wxt -b firefox",
10
+ "build": "wxt build",
11
+ "build:firefox": "wxt build -b firefox",
12
+ "zip": "wxt zip",
13
+ "zip:firefox": "wxt zip -b firefox",
14
+ "check": "svelte-check --tsconfig ./tsconfig.json",
15
+ "postinstall": "wxt prepare"
16
+ },
17
+ "devDependencies": {
18
+ "@tailwindcss/vite": "^4.1.11",
19
+ "@tsconfig/svelte": "^5.0.4",
20
+ "@wxt-dev/module-svelte": "^2.0.3",
21
+ "svelte": "^5.28.2",
22
+ "svelte-check": "^4.1.6",
23
+ "tailwindcss": "^4.1.11",
24
+ "tslib": "^2.8.1",
25
+ "typescript": "^5.8.3",
26
+ "wxt": "^0.20.6"
27
+ },
28
+ "trustedDependencies": [
29
+ "@tailwindcss/oxide",
30
+ "esbuild",
31
+ "spawn-sync"
32
+ ]
33
+ }
@@ -0,0 +1 @@
1
+ @import "tailwindcss";
@@ -0,0 +1,3 @@
1
+ export default defineBackground(() => {
2
+ console.log("Hello background!", { id: browser.runtime.id })
3
+ })
@@ -0,0 +1,7 @@
1
+ <script lang="ts">
2
+ let msg = "Hello"
3
+ </script>
4
+
5
+ <main class="p-4 z-50 top-10 left-10 fixed">
6
+ <h1 class="text-3xl font-bold underline">{msg}</h1>
7
+ </main>
@@ -0,0 +1,25 @@
1
+ import { mount, unmount } from "svelte"
2
+ import App from "./App.svelte"
3
+ import "~/assets/tailwind.css"
4
+
5
+ export default defineContentScript({
6
+ matches: ["<all_urls>"],
7
+
8
+ cssInjectionMode: "ui",
9
+
10
+ async main(ctx) {
11
+ const ui = await createShadowRootUi(ctx, {
12
+ name: "ext-ui",
13
+ position: "inline",
14
+ anchor: "body",
15
+ onMount: container => {
16
+ return mount(App, { target: container })
17
+ },
18
+ onRemove: app => {
19
+ unmount(app as any)
20
+ },
21
+ })
22
+
23
+ ui.mount()
24
+ },
25
+ })
@@ -0,0 +1,7 @@
1
+ <script lang="ts">
2
+ let msg = "Hello"
3
+ </script>
4
+
5
+ <main>
6
+ <h1 class="text-3xl font-bold underline">{msg}</h1>
7
+ </main>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Popup</title>
7
+ <meta name="manifest.type" content="browser_action" />
8
+ </head>
9
+ <body>
10
+ <div id="app"></div>
11
+ <script type="module" src="./main.ts"></script>
12
+ </body>
13
+ </html>
@@ -0,0 +1,9 @@
1
+ import { mount } from "svelte"
2
+ import App from "./App.svelte"
3
+ import "~/assets/tailwind.css"
4
+
5
+ const app = mount(App, {
6
+ target: document.getElementById("app")!,
7
+ })
8
+
9
+ export default app
@@ -0,0 +1,6 @@
1
+ {
2
+ "extends": "./.wxt/tsconfig.json",
3
+ "compilerOptions": {
4
+ "useDefineForClassFields": true
5
+ }
6
+ }
@@ -0,0 +1 @@
1
+ /// <reference types="svelte" />
@@ -0,0 +1,14 @@
1
+ import { defineConfig } from "wxt"
2
+ import tailwindcss from "@tailwindcss/vite"
3
+
4
+ // See https://wxt.dev/api/config.html
5
+ export default defineConfig({
6
+ srcDir: "src",
7
+ modules: ["@wxt-dev/module-svelte"],
8
+ vite: () => ({
9
+ plugins: [tailwindcss()],
10
+ }),
11
+ webExt: {
12
+ disabled: true,
13
+ },
14
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kunver/new",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "Opiniated project starter",
5
5
  "type": "module",
6
6
  "bin": {
@@ -16,12 +16,6 @@
16
16
  "keywords": [],
17
17
  "author": "Burak Unver <burakhanunver@gmail.com> (https://kunver.dev)",
18
18
  "license": "MIT",
19
- "devDependencies": {
20
- "@types/node": "^24.0.13",
21
- "tsup": "^8.2.2",
22
- "typescript": "^5.5.4",
23
- "vitest": "^3.2.4"
24
- },
25
19
  "dependencies": {
26
20
  "@inquirer/prompts": "^7.6.0",
27
21
  "@types/fs-extra": "^11.0.4",
@@ -30,11 +24,17 @@
30
24
  "fs-extra": "^11.3.0",
31
25
  "ora": "^8.2.0"
32
26
  },
27
+ "devDependencies": {
28
+ "@types/node": "^24.0.13",
29
+ "tsup": "^8.2.2",
30
+ "typescript": "^5.5.4",
31
+ "vitest": "^3.2.4"
32
+ },
33
33
  "scripts": {
34
34
  "build": "tsup",
35
35
  "start": "pnpm run build && node dist/index.js",
36
36
  "local": "pnpm link --global",
37
- "manager": "node manager.cjs",
37
+ "manager": "node manager.cjs pnpm",
38
38
  "test": "vitest run"
39
39
  }
40
40
  }