@kunver/new 3.4.1 → 3.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,21 +1,27 @@
|
|
|
1
|
-
import
|
|
1
|
+
import G,{readFileSync,existsSync,promises}from'fs';import K,{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 X from'ora';import {fileURLToPath}from'url';async function b(e){let{name:n,cwd:t=process.cwd()}=e,o=join(t,n),r=join(o,"main.ipynb");await mkdir(o,{recursive:true}),await execa("uv",["init","--python","3.12"],{cwd:o,stdout:"inherit",stderr:"inherit"}),await execa("uv",["add","numpy"],{cwd:o,stdout:"inherit",stderr:"inherit"}),await writeFile(r,oe(n),"utf8");}function oe(e){return `${JSON.stringify({cells:[{cell_type:"markdown",metadata:{language:"markdown"},source:[`# ${e}
|
|
2
2
|
`,`
|
|
3
3
|
`,`Starter notebook with NumPy ready to use.
|
|
4
4
|
`]},{cell_type:"code",execution_count:null,metadata:{language:"python"},outputs:[],source:[`import numpy as np
|
|
5
|
-
|
|
6
|
-
`
|
|
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
|
|
5
|
+
`,"np.arange(5)"]}],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)}
|
|
6
|
+
`}var $=["react-ts-tw","next-ts-prisma","wxt","uv-notebook","cmake-cpp"],L=["bun","pnpm","npm"],R=["antigravity","windsurf","no","cursor","code"],k=["svelte","vanilla","solid"];async function d(e,n,t){switch(e){case "pnpm":return await se(n,t);case "bun":return await ie(n,t);default:return false}}async function se(e,n){let t=X("Approving builds for "+i.blue(e)).start(),o=join(n,e);try{return new Promise(r=>{let a=spawn("pnpm",["approve-builds"],{cwd:o,stdio:["pipe","inherit","inherit"],shell:!0});setTimeout(()=>{a.stdin?.write(`a
|
|
8
7
|
`),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)),
|
|
10
|
-
`);try{return await execa(e,["install"],{cwd:
|
|
11
|
-
`),!0}catch(t){return console.error("Error updating project name:",t),false}}async function
|
|
8
|
+
`),a.stdin?.end();},1e3);},2e3),a.on("close",s=>{s===0?(t.succeed("Approved builds for "+i.blue(e)),r(!0)):(t.fail("Failed to approve builds for "+i.blue(e)),r(!1));}),a.on("error",s=>{t.fail("Failed to approve builds for "+i.blue(e)),console.error(s),r(!1);});})}catch(r){return t.fail("Failed to approve builds for "+i.blue(e)),console.error(r),false}}async function ie(e,n){let t=X("Approving builds for "+i.blue(e)).start(),o=join(n,e);try{return await execa("bun",["pm","trust","--all"],{cwd:o}),t.succeed("Approved builds for "+i.blue(e)),!0}catch{return t.fail("Failed to approve builds for "+i.blue(e)),false}}async function T(e,n,t){let o=join(t,n);console.log("Installing dependencies with "+i.cyan(e)+`
|
|
9
|
+
`);try{return await execa(e,["install"],{cwd:o,stdout:"inherit",stderr:"inherit"}),!0}catch{return false}}async function q(e){let n=await promises.readdir(e,{withFileTypes:true});for(let t of n){let o=K.join(e,t.name),r=o;t.name.startsWith("_")&&t.name.length>1&&(r=K.join(e,`.${t.name.slice(1)}`),await promises.rename(o,r)),t.isDirectory()&&await q(r);}}async function P(e,n){let t=X("Copying template folder...").start();try{return await promises.cp(e,n,{recursive:!0}),await q(n),t.succeed("Copied template folder"),!0}catch{return t.fail("Failed to copy template folder"),false}}async function v(e,n,t){let o=join(t,n,"package.json"),r=await G.promises.readFile(o,"utf-8"),a=JSON.parse(r);e==="bun"?a.scripts.manager=`bun manager.cjs ${e}`:a.scripts.manager=`node manager.cjs ${e}`,await G.promises.writeFile(o,JSON.stringify(a,null,2));}async function C(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(o){return console.error(i.red("Failed to open project in editor:"),o),false}}function ye(){return typeof __dirname<"u"?__dirname:typeof import.meta<"u"&&import.meta.url?dirname(fileURLToPath(import.meta.url)):process.cwd()}var Q=ye();async function l(e,n){if(await n()===false)throw new Error(`Failed to ${e}`)}function he(e){let n=join(Q,"../public/templates",e),t=join(Q,"templates",e);return existsSync(n)?n:t}async function m(e){let{templateName:n,name:t,packageManager:o,cwd:r=process.cwd(),addManager:a=true,changeName:s=true,approveBuild:f=true,installDependency:h=true,onBeforeInstall:W}=e,x=join(r,t),ee=he(n);try{return await l("copy template folder",()=>P(ee,x)),W&&await l("run pre-install hook",()=>W(x)),h&&await l("install dependencies",()=>T(o,t,r)),a&&await l("add manager script",()=>v(o,t,r)),f&&await l("approve builds",()=>d(o,t,r)),s&&await l("change project name",()=>I(x,t)),!0}catch(B){throw console.error("Error creating project:",B),B}}async function I(e,n){try{let t=join(e,"package.json"),o=await readFile(t,"utf-8"),r=JSON.parse(o);return r.name=n.toLowerCase().replace(/\s+/g,"-"),await writeFile(t,JSON.stringify(r,null,2)+`
|
|
10
|
+
`),!0}catch(t){return console.error("Error updating project name:",t),false}}async function M(e,n){try{let t=join(e,"CMakeLists.txt"),o=await readFile(t,"utf-8"),r=o.replace(/project\s*\(\s*(?:"[^"]+"|[^\s\)]+)([\s\S]*?)\)/i,`project("${n}"$1)`);return r===o?!1:(await writeFile(t,r),!0)}catch(t){return console.error("Error updating CMake project name:",t),false}}async function O(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&&k.includes(e)?e:await select({message:i.bold.magenta("Select a framework for WXT"),choices:k.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}),o=e==="svelte"||e==="solid"?await confirm({message:i.bold.cyan("Do you want to use content UI?"),default:false}):false,r=await confirm({message:i.bold.cyan("Do you want to use wxt-storage?"),default:false});return {useI18n:n,useContentUI:o,useWxtStorage:r}}async function Ee(e){let n=join(e,"entrypoints","content"),t=join(e,"entrypoints","content.ts"),o=`export default defineContentScript({
|
|
12
11
|
matches: ["*://*.google.com/*"],
|
|
13
12
|
main() {
|
|
14
13
|
console.log("Hello content.");
|
|
15
14
|
},
|
|
16
15
|
});
|
|
17
|
-
`;await rm(n,{recursive:true,force:true}),await writeFile(t,
|
|
16
|
+
`;await rm(n,{recursive:true,force:true}),await writeFile(t,o,"utf-8");}async function Fe(e){let n=join(e,"package.json"),t=await readFile(n,"utf-8"),o=JSON.parse(t);o.devDependencies=o.devDependencies||{},o.devDependencies["@wxt-dev/i18n"]="0.2.5",await writeFile(n,JSON.stringify(o,null,2),"utf-8");let r=join(e,"wxt.config.ts"),a=await readFile(r,"utf-8");a=a.replace("manifest: {",`manifest: {
|
|
18
17
|
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(
|
|
20
|
-
`,"utf-8");}function Ne(e
|
|
21
|
-
|
|
18
|
+
modules: ["@wxt-dev/i18n/module"],`),await writeFile(r,a,"utf-8");let s=join(e,"locales");await mkdir(s,{recursive:true}),await writeFile(join(s,"en.yml"),`hello: Hello!
|
|
19
|
+
`,"utf-8");}async function Ne(e){let n=join(e,"wxt.config.ts"),t=join(e,"utils"),o=join(t,"storage.ts"),r=await readFile(n,"utf-8");if(!r.includes('permissions: ["storage"]')){let a=r.replace(/(manifest:\s*{[\s\S]*?)(\n\s*},)/,(s,f,h)=>f.includes('permissions: ["storage"]')?s:`${f}
|
|
20
|
+
permissions: ["storage"],${h}`);if(a===r)throw new Error("Could not add storage permission to wxt.config.ts");r=a,await writeFile(n,r,"utf-8");}await mkdir(t,{recursive:true}),await writeFile(o,`// Example WXT Storage usage:
|
|
21
|
+
// import { storage } from "#imports"
|
|
22
|
+
//
|
|
23
|
+
// const showChangelogOnUpdate = storage.defineItem<boolean>("local:showChangelogOnUpdate", {
|
|
24
|
+
// fallback: true,
|
|
25
|
+
// })
|
|
26
|
+
`,"utf-8");}function _e(e,n){return async t=>{(e==="svelte"||e==="solid")&&!n.useContentUI&&await Ee(t),n.useI18n&&await Fe(t),n.useWxtStorage&&await Ne(t);}}async function N(e){let{name:n,packageManager:t,selectedFramework:o}=e;try{let r=await Me(o),a=await Oe(r);await m({templateName:Ie[r],name:n,packageManager:t,onBeforeInstall:_e(r,a)});}catch(r){throw console.error(r),r}}function Y(e,n){return async t=>{await m({templateName:e,name:t.name,packageManager:t.packageManager,...n});}}var Ue={"react-ts-tw":Y("react-ts-tw"),"next-ts-prisma":Y("next-prisma"),wxt:async e=>{await N({name:e.name,packageManager:e.packageManager});},"uv-notebook":async e=>{await b({name:e.name});},"cmake-cpp":async e=>{await m({templateName:"cmake-cpp",name:e.name,packageManager:"bun",addManager:false,approveBuild:false,installDependency:false,changeName:false,onBeforeInstall:async n=>{await M(n,e.name),await O(n);}});}};async function _(e){let n=Ue[e.projectType];if(!n){console.log(i.red("Project Type Not Implemented"),e.projectType);return}await n(e),e.openInEditor!=="no"&&await C(e.name,process.cwd(),e.openInEditor);}var ze=fileURLToPath(import.meta.url),He=dirname(ze),Xe=join(He,"../package.json"),Ke=JSON.parse(readFileSync(Xe,"utf8")),qe=Ke.version;console.log(i.green("Kunver v"+i.bold(qe)+`
|
|
27
|
+
`));var Ge=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)?G.existsSync(K.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.")}),D=await select({message:i.bold.yellow("Select a project type"),default:"react-ts-tw",choices:$}),Z="bun";D!=="uv-notebook"&&D!=="cmake-cpp"&&(Z=await select({message:i.bold.green("Select a package manager"),choices:L,default:"bun"}));var Qe=await select({message:i.bold.cyan("Open in editor?"),choices:R,default:"no"}),Ve={projectType:D,packageManager:Z,name:Ge,openInEditor:Qe};await _(Ve);
|
|
@@ -1,18 +1,17 @@
|
|
|
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
|
-
manifest: {
|
|
7
|
-
name: "wxt-solid-starter",
|
|
8
|
-
description: "manifest.json description",
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
})
|
|
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
|
+
manifest: {
|
|
7
|
+
name: "wxt-solid-starter",
|
|
8
|
+
description: "manifest.json description",
|
|
9
|
+
},
|
|
10
|
+
modules: ["@wxt-dev/module-solid"],
|
|
11
|
+
vite: () => ({
|
|
12
|
+
plugins: [tailwindcss()],
|
|
13
|
+
}),
|
|
14
|
+
webExt: {
|
|
15
|
+
disabled: true,
|
|
16
|
+
},
|
|
17
|
+
})
|
|
@@ -1,18 +1,17 @@
|
|
|
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
|
-
manifest: {
|
|
7
|
-
name: "wxt-svelte-starter",
|
|
8
|
-
description: "manifest.json description",
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
})
|
|
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
|
+
manifest: {
|
|
7
|
+
name: "wxt-svelte-starter",
|
|
8
|
+
description: "manifest.json description",
|
|
9
|
+
},
|
|
10
|
+
modules: ["@wxt-dev/module-svelte"],
|
|
11
|
+
vite: () => ({
|
|
12
|
+
plugins: [tailwindcss()],
|
|
13
|
+
}),
|
|
14
|
+
webExt: {
|
|
15
|
+
disabled: true,
|
|
16
|
+
},
|
|
17
|
+
})
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { defineConfig } from "wxt"
|
|
2
|
-
|
|
3
|
-
// See https://wxt.dev/api/config.html
|
|
4
|
-
export default defineConfig({
|
|
5
|
-
manifest: {
|
|
6
|
-
name: "wxt-vanilla-starter",
|
|
7
|
-
description: "manifest.json description",
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
})
|
|
1
|
+
import { defineConfig } from "wxt"
|
|
2
|
+
|
|
3
|
+
// See https://wxt.dev/api/config.html
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
manifest: {
|
|
6
|
+
name: "wxt-vanilla-starter",
|
|
7
|
+
description: "manifest.json description",
|
|
8
|
+
},
|
|
9
|
+
webExt: {
|
|
10
|
+
disabled: true,
|
|
11
|
+
},
|
|
12
|
+
})
|