create-web-kit 25.728.953 → 25.728.1414

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 CHANGED
@@ -1,4 +1,4 @@
1
- # Web Kit
1
+ # Create Web Kit
2
2
 
3
3
  一个强大的前端项目脚手架工具,基于官方脚手架命令整合开发者常用配置。
4
4
 
@@ -32,15 +32,10 @@ export const FRAMEWORKS = [
32
32
  workingDir: "target",
33
33
  },
34
34
  {
35
- command: "pnpm add date-fns",
35
+ command: "pnpm add date-fns next-themes motion",
36
36
  description: "Installing date-fns for date utilities",
37
37
  workingDir: "target",
38
38
  },
39
- {
40
- command: "pnpm add next-themes",
41
- description: "Installing next-themes for theme support",
42
- workingDir: "target",
43
- },
44
39
  {
45
40
  command: "pnpm dlx shadcn@latest add --all",
46
41
  description: "Installing all shadcnui components",
@@ -64,7 +59,7 @@ export const FRAMEWORKS = [
64
59
  workingDir: "target",
65
60
  },
66
61
  {
67
- command: "pnpm add @tanstack/react-query next-auth prisma",
62
+ command: "pnpm add @tanstack/react-query next-auth prisma motion",
68
63
  description: "Installing SSR dependencies",
69
64
  workingDir: "target",
70
65
  },
@@ -1 +1,8 @@
1
- const i=b;(function(c,d){const h=b,e=c();while(!![]){try{const f=parseInt(h(0xd2))/0x1*(-parseInt(h(0xcf))/0x2)+parseInt(h(0xd7))/0x3+parseInt(h(0xd3))/0x4+parseInt(h(0xd0))/0x5+-parseInt(h(0xce))/0x6+-parseInt(h(0xd4))/0x7+-parseInt(h(0xd1))/0x8*(-parseInt(h(0xd6))/0x9);if(f===d)break;else e['push'](e['shift']());}catch(g){e['push'](e['shift']());}}}(a,0xc5445));import{copyTemplateFiles}from'../utils/template.js';function a(){const j=['1160032iNemcv','4463823TTzNfH','electron-vue','89982GMhkGz','1771710qukpEg','.eslintrc.js','8696274yQUBfz','2654564TbmdKm','2861655pATCeU','2216ITQEBI','1zsdYDm'];a=function(){return j;};return a();}const TEMPLATE_NAME=i(0xd5),TEMPLATE_FILES=[{'source':'eslint.config.js','destination':i(0xcd)}];function b(c,d){const e=a();return b=function(f,g){f=f-0xcd;let h=e[f];return h;},b(c,d);}export function createElectronVueFiles(c){copyTemplateFiles(TEMPLATE_NAME,TEMPLATE_FILES,c);}
1
+ import { copyTemplateFiles } from "../utils/template.js";
2
+ const TEMPLATE_NAME = "electron-vue";
3
+ const TEMPLATE_FILES = [
4
+ { source: "eslint.config.js", destination: ".eslintrc.js" },
5
+ ];
6
+ export function createElectronVueFiles(root) {
7
+ copyTemplateFiles(TEMPLATE_NAME, TEMPLATE_FILES, root);
8
+ }
@@ -5,34 +5,38 @@ const TEMPLATE_NAME = "nextjs-csr";
5
5
  const TEMPLATE_FILES = [
6
6
  // Config files
7
7
  { source: "prettier.config.json", destination: ".prettierrc", isJson: true },
8
- { source: "eslint.config.js", destination: ".eslintrc.js" },
9
- { source: "next.config.js", destination: "next.config.js" },
10
- // Environment files
11
- { source: ".env", destination: ".env.development" },
12
- { source: ".env", destination: ".env.production" },
13
- { source: ".env", destination: ".env.test" },
8
+ { source: "eslint.config.mjs", destination: "eslint.config.mjs" },
9
+ { source: "next.config.ts", destination: "next.config.ts" },
14
10
  // DevContainer
15
11
  {
16
- source: "devcontainer.json",
12
+ source: ".devcontainer/devcontainer.json",
17
13
  destination: ".devcontainer/devcontainer.json",
18
14
  isJson: true,
19
15
  },
20
16
  // App files
21
- { source: "layout.tsx", destination: "src/app/layout.tsx" },
22
- { source: "not-found.tsx", destination: "src/app/not-found.tsx" },
17
+ { source: "src/app/layout.tsx", destination: "src/app/layout.tsx" },
18
+ { source: "src/app/not-found.tsx", destination: "src/app/not-found.tsx" },
19
+ { source: "src/app/error.tsx", destination: "src/app/error.tsx" },
23
20
  // Components
24
- { source: "show.tsx", destination: "src/components/show.tsx" },
25
- { source: "build-info.tsx", destination: "src/components/build-info.tsx" },
21
+ { source: "src/components/show.tsx", destination: "src/components/show.tsx" },
26
22
  {
27
- source: "theme-provider.tsx",
28
- destination: "src/components/providers/theme-provider.tsx",
23
+ source: "src/components/build-info.tsx",
24
+ destination: "src/components/build-info.tsx",
29
25
  },
30
26
  {
31
- source: "query-provider.tsx",
32
- destination: "src/components/providers/query-provider.tsx",
27
+ source: "src/components/providers/theme.tsx",
28
+ destination: "src/components/providers/theme.tsx",
29
+ },
30
+ {
31
+ source: "src/components/providers/query.tsx",
32
+ destination: "src/components/providers/query.tsx",
33
+ },
34
+ {
35
+ source: "src/components/providers/index.tsx",
36
+ destination: "src/components/providers/index.tsx",
33
37
  },
34
38
  // Utils
35
- { source: "request.ts", destination: "src/utils/request.ts" },
39
+ { source: "src/lib/request.ts", destination: "src/lib/request.ts" },
36
40
  ];
37
41
  export function createNextjsCSRFiles(root) {
38
42
  // Copy all template files
@@ -1 +1,9 @@
1
- function a(){const j=['.env.local','5274azzNiZ','81ZhUTxK','nextjs-ssr','649883dkQZcg','32106DHrRJt','20888rWdiFH','7131625dhbKsg','9WlnZhD','11skdGuy','11244770VeACVy','406kcgQNs','15882XUKNYu','876GOAxpv','5972baDZEz'];a=function(){return j;};return a();}const i=b;(function(c,d){const h=b,e=c();while(!![]){try{const f=-parseInt(h(0x112))/0x1*(-parseInt(h(0x116))/0x2)+-parseInt(h(0x11b))/0x3*(parseInt(h(0x118))/0x4)+parseInt(h(0x111))/0x5+-parseInt(h(0x11e))/0x6*(-parseInt(h(0x115))/0x7)+-parseInt(h(0x110))/0x8*(-parseInt(h(0x11a))/0x9)+-parseInt(h(0x114))/0xa*(-parseInt(h(0x113))/0xb)+parseInt(h(0x117))/0xc*(-parseInt(h(0x11d))/0xd);if(f===d)break;else e['push'](e['shift']());}catch(g){e['push'](e['shift']());}}}(a,0xbcb9d));import{copyTemplateFiles}from'../utils/template.js';const TEMPLATE_NAME=i(0x11c),TEMPLATE_FILES=[{'source':i(0x119),'destination':'.env.local'},{'source':'.env.local','destination':'.env.example'}];function b(c,d){const e=a();return b=function(f,g){f=f-0x110;let h=e[f];return h;},b(c,d);}export function createNextjsSSRFiles(c){copyTemplateFiles(TEMPLATE_NAME,TEMPLATE_FILES,c);}
1
+ import { copyTemplateFiles } from "../utils/template.js";
2
+ const TEMPLATE_NAME = "nextjs-ssr";
3
+ const TEMPLATE_FILES = [
4
+ { source: ".env.local", destination: ".env.local" },
5
+ { source: ".env.local", destination: ".env.example" },
6
+ ];
7
+ export function createNextjsSSRFiles(root) {
8
+ copyTemplateFiles(TEMPLATE_NAME, TEMPLATE_FILES, root);
9
+ }
@@ -1 +1,44 @@
1
- function a(){const u=['11368189ViVSWX','\x0a\x20\x20yarn\x20dev','log','step','2BKqNgo','stringify','Done.\x20Now\x20run:\x0a','url','4RlJODg','10075680kibMYl','2570109fUBFgK','package.json','1467IdmUVK','6809742grAJOm','7424425UVggIb','42190UkSewT','\x20install','1515118NcBGhM'];a=function(){return u;};return a();}(function(f,g){const s=b,h=f();while(!![]){try{const i=-parseInt(s(0x136))/0x1+-parseInt(s(0x13b))/0x2*(parseInt(s(0x141))/0x3)+parseInt(s(0x13f))/0x4*(-parseInt(s(0x133))/0x5)+parseInt(s(0x144))/0x6+parseInt(s(0x137))/0x7+parseInt(s(0x140))/0x8+parseInt(s(0x143))/0x9*(parseInt(s(0x134))/0xa);if(i===g)break;else h['push'](h['shift']());}catch(j){h['push'](h['shift']());}}}(a,0xcf61b));import c from'node:fs';function b(c,d){const e=a();return b=function(f,g){f=f-0x133;let h=e[f];return h;},b(c,d);}import d from'node:path';import{fileURLToPath}from'node:url';import*as e from'@clack/prompts';import{copy}from'../utils/file.js';import{renameFiles}from'../config/frameworks.js';export function generateTemplateProject(f,g,h,i,cwd){const t=b;c['mkdirSync'](g,{'recursive':!![]}),e[t(0x139)][t(0x13a)]('Scaffolding\x20project\x20in\x20'+g+'...');const j=d['resolve'](fileURLToPath(import.meta[t(0x13e)]),'../../..','template-'+f),k=(p,q)=>{const r=d['join'](g,renameFiles[p]??p);q?c['writeFileSync'](r,q):copy(d['join'](j,p),r);},l=c['readdirSync'](j);for(const p of l['filter'](q=>q!=='package.json')){k(p);}const m=JSON['parse'](c['readFileSync'](d['join'](j,'package.json'),'utf-8'));m['name']=h,k(t(0x142),JSON[t(0x13c)](m,null,0x2)+'\x0a');let n='';const o=d['relative'](cwd,g);n+=t(0x13d);g!==cwd&&(n+='\x0a\x20\x20cd\x20'+(o['includes']('\x20')?'\x22'+o+'\x22':o));switch(i){case'yarn':n+='\x0a\x20\x20yarn',n+=t(0x138);break;default:n+='\x0a\x20\x20'+i+t(0x135),n+='\x0a\x20\x20'+i+'\x20run\x20dev';break;}e['outro'](n);}
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import * as prompts from "@clack/prompts";
5
+ import { copy } from "../utils/file.js";
6
+ import { renameFiles } from "../config/frameworks.js";
7
+ export function generateTemplateProject(template, root, packageName, pkgManager, cwd) {
8
+ fs.mkdirSync(root, { recursive: true });
9
+ prompts.log.step(`Scaffolding project in ${root}...`);
10
+ const templateDir = path.resolve(fileURLToPath(import.meta.url), "../../..", `template-${template}`);
11
+ const write = (file, content) => {
12
+ const targetPath = path.join(root, renameFiles[file] ?? file);
13
+ if (content) {
14
+ fs.writeFileSync(targetPath, content);
15
+ }
16
+ else {
17
+ copy(path.join(templateDir, file), targetPath);
18
+ }
19
+ };
20
+ const files = fs.readdirSync(templateDir);
21
+ for (const file of files.filter((f) => f !== "package.json")) {
22
+ write(file);
23
+ }
24
+ const pkg = JSON.parse(fs.readFileSync(path.join(templateDir, `package.json`), "utf-8"));
25
+ pkg.name = packageName;
26
+ write("package.json", JSON.stringify(pkg, null, 2) + "\n");
27
+ let doneMessage = "";
28
+ const cdProjectName = path.relative(cwd, root);
29
+ doneMessage += `Done. Now run:\n`;
30
+ if (root !== cwd) {
31
+ doneMessage += `\n cd ${cdProjectName.includes(" ") ? `"${cdProjectName}"` : cdProjectName}`;
32
+ }
33
+ switch (pkgManager) {
34
+ case "yarn":
35
+ doneMessage += "\n yarn";
36
+ doneMessage += "\n yarn dev";
37
+ break;
38
+ default:
39
+ doneMessage += `\n ${pkgManager} install`;
40
+ doneMessage += `\n ${pkgManager} run dev`;
41
+ break;
42
+ }
43
+ prompts.outro(doneMessage);
44
+ }
@@ -1 +1,8 @@
1
- function a(){const i=['2098716gJUJkN','331436lmOnTi','708076gFotBV','25NFKeis','5957344THVsGo','262452PEdNyk','1013388NIajiV','6070323DAjFoo'];a=function(){return i;};return a();}function b(c,d){const e=a();return b=function(f,g){f=f-0x1d2;let h=e[f];return h;},b(c,d);}(function(c,d){const h=b,e=c();while(!![]){try{const f=-parseInt(h(0x1d5))/0x1+-parseInt(h(0x1d4))/0x2+parseInt(h(0x1d8))/0x3+parseInt(h(0x1d3))/0x4+parseInt(h(0x1d6))/0x5*(-parseInt(h(0x1d9))/0x6)+parseInt(h(0x1d2))/0x7+parseInt(h(0x1d7))/0x8;if(f===d)break;else e['push'](e['shift']());}catch(g){e['push'](e['shift']());}}}(a,0x7b788));import{copyTemplateFiles}from'../utils/template.js';const TEMPLATE_NAME='vue3',TEMPLATE_FILES=[{'source':'vite.config.ts','destination':'vite.config.ts'}];export function createVue3Files(c){copyTemplateFiles(TEMPLATE_NAME,TEMPLATE_FILES,c);}
1
+ import { copyTemplateFiles } from "../utils/template.js";
2
+ const TEMPLATE_NAME = "vue3";
3
+ const TEMPLATE_FILES = [
4
+ { source: "vite.config.ts", destination: "vite.config.ts" },
5
+ ];
6
+ export function createVue3Files(root) {
7
+ copyTemplateFiles(TEMPLATE_NAME, TEMPLATE_FILES, root);
8
+ }
package/dist/index.js CHANGED
@@ -1,2 +1,175 @@
1
1
  #!/usr/bin/env node
2
- const J=b;function a(){const M=['text','28464pDzSBf','11ANHDdl','\x22\x20isn\x27t\x20a\x20valid\x20template.\x20Please\x20choose\x20from\x20below:\x20','black','name','Current\x20directory','1460105ByoqdE','\x20commands','75928ugdNOe','93317sZoODw','Cancel\x20operation','580302PzuzBz','Project\x20name:','cancel','multiStepCommands','12vSyJBU','overwrite','1894660JBJSlr','6170664vJwYIT','Select\x20a\x20variant:','map','select','intro','3nvfyva','8IGJzap','slice','Ignore\x20files\x20and\x20continue','15lMpwPi','TARGET_DIR','replace','yes','help','template','includes','Target\x20directory\x20\x22'];a=function(){return M;};return a();}(function(i,j){const I=b,k=i();while(!![]){try{const l=parseInt(I(0x126))/0x1*(parseInt(I(0x12f))/0x2)+parseInt(I(0x122))/0x3*(parseInt(I(0x137))/0x4)+-parseInt(I(0x135))/0x5+-parseInt(I(0x13e))/0x6*(parseInt(I(0x138))/0x7)+parseInt(I(0x123))/0x8*(-parseInt(I(0x13a))/0x9)+-parseInt(I(0x140))/0xa*(parseInt(I(0x130))/0xb)+parseInt(I(0x11d))/0xc;if(l===j)break;else k['push'](k['shift']());}catch(m){k['push'](k['shift']());}}}(a,0x2a7e9));import c from'node:fs';import d from'node:path';import e from'cross-spawn';import f from'mri';import*as g from'@clack/prompts';import h from'picocolors';import{helpMessage}from'./config/help.js';import{FRAMEWORKS,TEMPLATES,defaultTargetDir}from'./config/frameworks.js';import{formatTargetDir,isValidPackageName,toValidPackageName,isEmpty,emptyDir,pkgFromUserAgent}from'./utils/file.js';import{getFullCustomCommand}from'./utils/package-manager.js';import{executeMultiStepCommands,createProjectFiles,generateSuccessMessage}from'./generators/project.js';import{generateTemplateProject}from'./generators/template.js';const argv=f(process['argv'][J(0x124)](0x2),{'alias':{'h':'help','t':J(0x12b)},'boolean':[J(0x12a),J(0x13f)],'string':[J(0x12b)]}),cwd=process['cwd']();function b(c,d){const e=a();return b=function(f,g){f=f-0x11d;let h=e[f];return h;},b(c,d);}async function init(){const K=J,i=argv['_'][0x0]?formatTargetDir(String(argv['_'][0x0])):undefined,j=argv['template'],k=argv['overwrite'],l=argv['help'];if(l){console['log'](helpMessage);return;}const m=pkgFromUserAgent(process['env']['npm_config_user_agent']),n=()=>g[K(0x13c)]('Operation\x20cancelled');g[K(0x121)](h['bgCyan'](h[K(0x132)]('\x20create-web\x20')));let o=i;if(!o){const w=await g[K(0x12e)]({'message':K(0x13b),'defaultValue':defaultTargetDir,'placeholder':defaultTargetDir,'validate':x=>{return x['length']===0x0||formatTargetDir(x)['length']>0x0?undefined:'Invalid\x20project\x20name';}});if(g['isCancel'](w))return n();o=formatTargetDir(w);}if(c['existsSync'](o)&&!isEmpty(o)){const x=k?'yes':await g['select']({'message':(o==='.'?K(0x134):K(0x12d)+o+'\x22')+'\x20is\x20not\x20empty.\x20Please\x20choose\x20how\x20to\x20proceed:','options':[{'label':K(0x139),'value':'no'},{'label':'Remove\x20existing\x20files\x20and\x20continue','value':K(0x129)},{'label':K(0x125),'value':'ignore'}]});if(g['isCancel'](x))return n();switch(x){case'yes':emptyDir(o);break;case'no':n();return;}}let p=d['basename'](d['resolve'](o));if(!isValidPackageName(p)){const y=await g['text']({'message':'Package\x20name:','defaultValue':toValidPackageName(p),'placeholder':toValidPackageName(p),'validate'(z){if(!isValidPackageName(z))return'Invalid\x20package.json\x20name';}});if(g['isCancel'](y))return n();p=y;}let q=j,r=![];j&&!TEMPLATES[K(0x12c)](j)&&(q=undefined,r=!![]);if(!q){const z=await g[K(0x120)]({'message':r?'\x22'+j+K(0x131):'Select\x20a\x20framework:','options':FRAMEWORKS['map'](B=>{const C=B['color'];return{'label':C(B['display']||B['name']),'value':B};})});if(g['isCancel'](z))return n();const A=await g['select']({'message':K(0x11e),'options':z['variants'][K(0x11f)](B=>{const L=K,C=B['color'],D=B['customCommand']?getFullCustomCommand(B['customCommand'],m)[L(0x128)](/ TARGET_DIR$/,''):B['multiStepCommands']?'Multi-step\x20setup:\x20'+B[L(0x13d)]['length']+L(0x136):undefined;return{'label':C(B['display']||B['name']),'value':B['name'],'hint':D};})});if(g['isCancel'](A))return n();q=A;}const s=d['join'](cwd,o),t=m?m[K(0x133)]:'npm',u=FRAMEWORKS['flatMap'](B=>B['variants'])['find'](B=>B[K(0x133)]===q);if(u?.['multiStepCommands']){await executeMultiStepCommands(u,o,s,cwd,m),createProjectFiles(q,s);const B=generateSuccessMessage(o,t);g['outro'](B);return;}const {customCommand:v}=u??{};if(v){const C=getFullCustomCommand(v,m),[D,...E]=C['split']('\x20'),F=E[K(0x11f)](H=>H[K(0x128)](K(0x127),()=>o)),{status:G}=e['sync'](D,F,{'stdio':'inherit'});process['exit'](G??0x0);}generateTemplateProject(q,s,p,t,cwd);}init()['catch'](i=>{console['error'](i);});
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import spawn from "cross-spawn";
5
+ import mri from "mri";
6
+ import * as prompts from "@clack/prompts";
7
+ import colors from "picocolors";
8
+ // Import configurations
9
+ import { helpMessage } from "./config/help.js";
10
+ import { FRAMEWORKS, TEMPLATES, defaultTargetDir, } from "./config/frameworks.js";
11
+ // Import utilities
12
+ import { formatTargetDir, isValidPackageName, toValidPackageName, isEmpty, emptyDir, pkgFromUserAgent, } from "./utils/file.js";
13
+ import { getFullCustomCommand } from "./utils/package-manager.js";
14
+ // Import generators
15
+ import { executeMultiStepCommands, createProjectFiles, generateSuccessMessage, } from "./generators/project.js";
16
+ import { generateTemplateProject } from "./generators/template.js";
17
+ const argv = mri(process.argv.slice(2), {
18
+ alias: { h: "help", t: "template" },
19
+ boolean: ["help", "overwrite"],
20
+ string: ["template"],
21
+ });
22
+ const cwd = process.cwd();
23
+ async function init() {
24
+ const argTargetDir = argv._[0]
25
+ ? formatTargetDir(String(argv._[0]))
26
+ : undefined;
27
+ const argTemplate = argv.template;
28
+ const argOverwrite = argv.overwrite;
29
+ const help = argv.help;
30
+ if (help) {
31
+ console.log(helpMessage);
32
+ return;
33
+ }
34
+ const pkgInfo = pkgFromUserAgent(process.env.npm_config_user_agent);
35
+ const cancel = () => prompts.cancel("Operation cancelled");
36
+ prompts.intro(colors.bgCyan(colors.black(" create-web ")));
37
+ // 1. Get project name and target dir
38
+ let targetDir = argTargetDir;
39
+ if (!targetDir) {
40
+ const projectName = await prompts.text({
41
+ message: "Project name:",
42
+ defaultValue: defaultTargetDir,
43
+ placeholder: defaultTargetDir,
44
+ validate: (value) => {
45
+ return value.length === 0 || formatTargetDir(value).length > 0
46
+ ? undefined
47
+ : "Invalid project name";
48
+ },
49
+ });
50
+ if (prompts.isCancel(projectName))
51
+ return cancel();
52
+ targetDir = formatTargetDir(projectName);
53
+ }
54
+ // 2. Handle directory if exist and not empty
55
+ if (fs.existsSync(targetDir) && !isEmpty(targetDir)) {
56
+ const overwrite = argOverwrite
57
+ ? "yes"
58
+ : await prompts.select({
59
+ message: (targetDir === "."
60
+ ? "Current directory"
61
+ : `Target directory "${targetDir}"`) +
62
+ ` is not empty. Please choose how to proceed:`,
63
+ options: [
64
+ {
65
+ label: "Cancel operation",
66
+ value: "no",
67
+ },
68
+ {
69
+ label: "Remove existing files and continue",
70
+ value: "yes",
71
+ },
72
+ {
73
+ label: "Ignore files and continue",
74
+ value: "ignore",
75
+ },
76
+ ],
77
+ });
78
+ if (prompts.isCancel(overwrite))
79
+ return cancel();
80
+ switch (overwrite) {
81
+ case "yes":
82
+ emptyDir(targetDir);
83
+ break;
84
+ case "no":
85
+ cancel();
86
+ return;
87
+ }
88
+ }
89
+ // 3. Get package name
90
+ let packageName = path.basename(path.resolve(targetDir));
91
+ if (!isValidPackageName(packageName)) {
92
+ const packageNameResult = await prompts.text({
93
+ message: "Package name:",
94
+ defaultValue: toValidPackageName(packageName),
95
+ placeholder: toValidPackageName(packageName),
96
+ validate(dir) {
97
+ if (!isValidPackageName(dir)) {
98
+ return "Invalid package.json name";
99
+ }
100
+ },
101
+ });
102
+ if (prompts.isCancel(packageNameResult))
103
+ return cancel();
104
+ packageName = packageNameResult;
105
+ }
106
+ // 4. Choose a framework and variant
107
+ let template = argTemplate;
108
+ let hasInvalidArgTemplate = false;
109
+ if (argTemplate && !TEMPLATES.includes(argTemplate)) {
110
+ template = undefined;
111
+ hasInvalidArgTemplate = true;
112
+ }
113
+ if (!template) {
114
+ const framework = (await prompts.select({
115
+ message: hasInvalidArgTemplate
116
+ ? `"${argTemplate}" isn't a valid template. Please choose from below: `
117
+ : "Select a framework:",
118
+ options: FRAMEWORKS.map((framework) => {
119
+ const frameworkColor = framework.color;
120
+ return {
121
+ label: frameworkColor(framework.display || framework.name),
122
+ value: framework,
123
+ };
124
+ }),
125
+ }));
126
+ if (prompts.isCancel(framework))
127
+ return cancel();
128
+ const variant = (await prompts.select({
129
+ message: "Select a variant:",
130
+ options: framework.variants.map((variant) => {
131
+ const variantColor = variant.color;
132
+ const command = variant.customCommand
133
+ ? getFullCustomCommand(variant.customCommand, pkgInfo).replace(/ TARGET_DIR$/, "")
134
+ : variant.multiStepCommands
135
+ ? `Multi-step setup: ${variant.multiStepCommands.length} commands`
136
+ : undefined;
137
+ return {
138
+ label: variantColor(variant.display || variant.name),
139
+ value: variant.name,
140
+ hint: command,
141
+ };
142
+ }),
143
+ }));
144
+ if (prompts.isCancel(variant))
145
+ return cancel();
146
+ template = variant;
147
+ }
148
+ const root = path.join(cwd, targetDir);
149
+ const pkgManager = pkgInfo ? pkgInfo.name : "npm";
150
+ const selectedVariant = FRAMEWORKS.flatMap((f) => f.variants).find((v) => v.name === template);
151
+ // Handle multi-step commands
152
+ if (selectedVariant?.multiStepCommands) {
153
+ await executeMultiStepCommands(selectedVariant, targetDir, root, cwd, pkgInfo);
154
+ createProjectFiles(template, root);
155
+ const successMessage = generateSuccessMessage(targetDir, pkgManager);
156
+ prompts.outro(successMessage);
157
+ return;
158
+ }
159
+ // Handle custom commands
160
+ const { customCommand } = selectedVariant ?? {};
161
+ if (customCommand) {
162
+ const fullCustomCommand = getFullCustomCommand(customCommand, pkgInfo);
163
+ const [command, ...args] = fullCustomCommand.split(" ");
164
+ const replacedArgs = args.map((arg) => arg.replace("TARGET_DIR", () => targetDir));
165
+ const { status } = spawn.sync(command, replacedArgs, {
166
+ stdio: "inherit",
167
+ });
168
+ process.exit(status ?? 0);
169
+ }
170
+ // Handle template-based projects
171
+ generateTemplateProject(template, root, packageName, pkgManager, cwd);
172
+ }
173
+ init().catch((e) => {
174
+ console.error(e);
175
+ });
@@ -1 +1 @@
1
- export{};
1
+ export {};
@@ -1 +1,62 @@
1
- (function(e,f){const j=b,g=e();while(!![]){try{const h=-parseInt(j(0x1d3))/0x1+parseInt(j(0x1da))/0x2+-parseInt(j(0x1d1))/0x3*(parseInt(j(0x1cd))/0x4)+-parseInt(j(0x1db))/0x5+-parseInt(j(0x1dd))/0x6+parseInt(j(0x1cf))/0x7+parseInt(j(0x1d0))/0x8*(parseInt(j(0x1d6))/0x9);if(h===f)break;else g['push'](g['shift']());}catch(i){g['push'](g['shift']());}}}(a,0xa59ab));import c from'node:fs';import d from'node:path';export function formatTargetDir(e){return e['trim']()['replace'](/\/+$/g,'');}function a(){const r=['split','2797479kKBKHB','trim','.git','statSync','513894kwJXSj','1622185ftXcFL','writeFileSync','6938274WJWrPo','replace','12LUPhIh','length','1620479qUuClI','56lPAgBB','462945ZpiWjM','mkdirSync','42185ojECuO','resolve'];a=function(){return r;};return a();}export function isValidPackageName(e){return/^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/['test'](e);}export function toValidPackageName(e){const k=b;return e[k(0x1d7)]()['toLowerCase']()['replace'](/\s+/g,'-')[k(0x1de)](/^[._]/,'')['replace'](/[^a-z\d\-~]+/g,'-');}export function isEmpty(e){const l=b,f=c['readdirSync'](e);return f['length']===0x0||f[l(0x1ce)]===0x1&&f[0x0]===l(0x1d8);}export function emptyDir(e){const m=b;if(!c['existsSync'](e))return;for(const f of c['readdirSync'](e)){if(f==='.git')continue;c['rmSync'](d[m(0x1d4)](e,f),{'recursive':!![],'force':!![]});}}export function pkgFromUserAgent(e){const n=b;if(!e)return undefined;const f=e['split']('\x20')[0x0],g=f[n(0x1d5)]('/');return{'name':g[0x0],'version':g[0x1]};}export function editFile(e,f){const o=b,g=c['readFileSync'](e,'utf-8');c[o(0x1dc)](e,f(g),'utf-8');}function b(c,d){const e=a();return b=function(f,g){f=f-0x1cd;let h=e[f];return h;},b(c,d);}export function copy(e,f){const p=b,g=c[p(0x1d9)](e);g['isDirectory']()?copyDir(e,f):c['copyFileSync'](e,f);}export function copyDir(e,f){const q=b;c[q(0x1d2)](f,{'recursive':!![]});for(const g of c['readdirSync'](e)){const h=d[q(0x1d4)](e,g),i=d['resolve'](f,g);copy(h,i);}}
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ export function formatTargetDir(targetDir) {
4
+ return targetDir.trim().replace(/\/+$/g, "");
5
+ }
6
+ export function isValidPackageName(projectName) {
7
+ return /^(?:@[a-z\d\-*~][a-z\d\-*._~]*\/)?[a-z\d\-~][a-z\d\-._~]*$/.test(projectName);
8
+ }
9
+ export function toValidPackageName(projectName) {
10
+ return projectName
11
+ .trim()
12
+ .toLowerCase()
13
+ .replace(/\s+/g, "-")
14
+ .replace(/^[._]/, "")
15
+ .replace(/[^a-z\d\-~]+/g, "-");
16
+ }
17
+ export function isEmpty(dirPath) {
18
+ const files = fs.readdirSync(dirPath);
19
+ return files.length === 0 || (files.length === 1 && files[0] === ".git");
20
+ }
21
+ export function emptyDir(dir) {
22
+ if (!fs.existsSync(dir)) {
23
+ return;
24
+ }
25
+ for (const file of fs.readdirSync(dir)) {
26
+ if (file === ".git") {
27
+ continue;
28
+ }
29
+ fs.rmSync(path.resolve(dir, file), { recursive: true, force: true });
30
+ }
31
+ }
32
+ export function pkgFromUserAgent(userAgent) {
33
+ if (!userAgent)
34
+ return undefined;
35
+ const pkgSpec = userAgent.split(" ")[0];
36
+ const pkgSpecArr = pkgSpec.split("/");
37
+ return {
38
+ name: pkgSpecArr[0],
39
+ version: pkgSpecArr[1],
40
+ };
41
+ }
42
+ export function editFile(file, callback) {
43
+ const content = fs.readFileSync(file, "utf-8");
44
+ fs.writeFileSync(file, callback(content), "utf-8");
45
+ }
46
+ export function copy(src, dest) {
47
+ const stat = fs.statSync(src);
48
+ if (stat.isDirectory()) {
49
+ copyDir(src, dest);
50
+ }
51
+ else {
52
+ fs.copyFileSync(src, dest);
53
+ }
54
+ }
55
+ export function copyDir(srcDir, destDir) {
56
+ fs.mkdirSync(destDir, { recursive: true });
57
+ for (const file of fs.readdirSync(srcDir)) {
58
+ const srcFile = path.resolve(srcDir, file);
59
+ const destFile = path.resolve(destDir, file);
60
+ copy(srcFile, destFile);
61
+ }
62
+ }
@@ -1 +1,94 @@
1
- (function(c,d){const h=b,e=c();while(!![]){try{const f=-parseInt(h(0xdd))/0x1+parseInt(h(0xcf))/0x2+parseInt(h(0xdb))/0x3+parseInt(h(0xdf))/0x4*(parseInt(h(0xd4))/0x5)+parseInt(h(0xd3))/0x6+-parseInt(h(0xcd))/0x7+-parseInt(h(0xce))/0x8*(parseInt(h(0xcc))/0x9);if(f===d)break;else e['push'](e['shift']());}catch(g){e['push'](e['shift']());}}}(a,0xd42ac));export function getFullCustomCommand(c,d){const i=b,e=d?d[i(0xdc)]:i(0xe1),f=e==='yarn'&&d?.['version']['startsWith']('1.');return c[i(0xd7)](/^npm create (?:-- )?/,()=>{const j=i;if(e===j(0xd9))return'bun\x20x\x20create-';if(e==='pnpm')return j(0xda);return c[j(0xd1)]('npm\x20create\x20--\x20')?e+'\x20create\x20--\x20':e+'\x20create\x20';})[i(0xd7)]('@latest',()=>f?'':'@latest')[i(0xd7)](/^npm exec/,()=>{const k=i;if(e==='pnpm')return'pnpm\x20dlx';if(e==='yarn'&&!f)return k(0xd2);if(e==='bun')return'bun\x20x';return'npm\x20exec';});}export function replacePackageManagerInCommand(c,d){const l=b,e=d?d['name']:'npm',f=e==='yarn'&&d?.['version']['startsWith']('1.');return c[l(0xd7)](/^pnpx\s/,()=>{const m=l;if(e===m(0xe0))return f?'npx\x20':'yarn\x20dlx\x20';if(e==='bun')return'bunx\x20';if(e==='npm')return'npx\x20';return'pnpx\x20';})['replace'](/^pnpm dlx\s/,()=>{const n=l;if(e===n(0xe0))return f?n(0xde):n(0xd5);if(e==='bun')return n(0xd8);if(e==='npm')return'npx\x20';return'pnpm\x20dlx\x20';})['replace'](/^pnpm add\s/,()=>{const o=l;if(e===o(0xe0))return'yarn\x20add\x20';if(e==='bun')return'bun\x20add\x20';if(e===o(0xe1))return o(0xd6);return o(0xd0);})['replace'](/^pnpm create\s/,()=>{const p=l;if(e===p(0xe0))return'yarn\x20create\x20';if(e==='bun')return'bun\x20create\x20';if(e==='npm')return'npm\x20create\x20';return'pnpm\x20create\x20';});}function b(c,d){const e=a();return b=function(f,g){f=f-0xcc;let h=e[f];return h;},b(c,d);}function a(){const q=['bun','pnpm\x20create\x20','3159156RptVHB','name','1301822FElyXp','npx\x20','892PxGhqS','yarn','npm','347211gLVqqB','6736240tGEoNf','264mnaPxy','2532770VqVCkO','pnpm\x20add\x20','startsWith','yarn\x20dlx','3795990tmdlVS','32605vkvWHO','yarn\x20dlx\x20','npm\x20install\x20','replace','bunx\x20'];a=function(){return q;};return a();}
1
+ export function getFullCustomCommand(customCommand, pkgInfo) {
2
+ const pkgManager = pkgInfo ? pkgInfo.name : "npm";
3
+ const isYarn1 = pkgManager === "yarn" && pkgInfo?.version.startsWith("1.");
4
+ return (customCommand
5
+ .replace(/^npm create (?:-- )?/, () => {
6
+ // `bun create` uses it's own set of templates,
7
+ // the closest alternative is using `bun x` directly on the package
8
+ if (pkgManager === "bun") {
9
+ return "bun x create-";
10
+ }
11
+ // pnpm doesn't support the -- syntax
12
+ if (pkgManager === "pnpm") {
13
+ return "pnpm create ";
14
+ }
15
+ // For other package managers, preserve the original format
16
+ return customCommand.startsWith("npm create -- ")
17
+ ? `${pkgManager} create -- `
18
+ : `${pkgManager} create `;
19
+ })
20
+ // Only Yarn 1.x doesn't support `@version` in the `create` command
21
+ .replace("@latest", () => (isYarn1 ? "" : "@latest"))
22
+ .replace(/^npm exec/, () => {
23
+ // Prefer `pnpm dlx`, `yarn dlx`, or `bun x`
24
+ if (pkgManager === "pnpm") {
25
+ return "pnpm dlx";
26
+ }
27
+ if (pkgManager === "yarn" && !isYarn1) {
28
+ return "yarn dlx";
29
+ }
30
+ if (pkgManager === "bun") {
31
+ return "bun x";
32
+ }
33
+ // Use `npm exec` in all other cases,
34
+ // including Yarn 1.x and other custom npm clients.
35
+ return "npm exec";
36
+ }));
37
+ }
38
+ export function replacePackageManagerInCommand(command, pkgInfo) {
39
+ const pkgManager = pkgInfo ? pkgInfo.name : "npm";
40
+ const isYarn1 = pkgManager === "yarn" && pkgInfo?.version.startsWith("1.");
41
+ return (command
42
+ // Replace pnpx/npx with appropriate package manager
43
+ .replace(/^pnpx\s/, () => {
44
+ if (pkgManager === "yarn") {
45
+ return isYarn1 ? "npx " : "yarn dlx ";
46
+ }
47
+ if (pkgManager === "bun") {
48
+ return "bunx ";
49
+ }
50
+ if (pkgManager === "npm") {
51
+ return "npx ";
52
+ }
53
+ return "pnpx ";
54
+ })
55
+ // Replace pnpm dlx with appropriate package manager
56
+ .replace(/^pnpm dlx\s/, () => {
57
+ if (pkgManager === "yarn") {
58
+ return isYarn1 ? "npx " : "yarn dlx ";
59
+ }
60
+ if (pkgManager === "bun") {
61
+ return "bunx ";
62
+ }
63
+ if (pkgManager === "npm") {
64
+ return "npx ";
65
+ }
66
+ return "pnpm dlx ";
67
+ })
68
+ // Replace pnpm add with appropriate package manager
69
+ .replace(/^pnpm add\s/, () => {
70
+ if (pkgManager === "yarn") {
71
+ return "yarn add ";
72
+ }
73
+ if (pkgManager === "bun") {
74
+ return "bun add ";
75
+ }
76
+ if (pkgManager === "npm") {
77
+ return "npm install ";
78
+ }
79
+ return "pnpm add ";
80
+ })
81
+ // Replace pnpm create with appropriate package manager
82
+ .replace(/^pnpm create\s/, () => {
83
+ if (pkgManager === "yarn") {
84
+ return "yarn create ";
85
+ }
86
+ if (pkgManager === "bun") {
87
+ return "bun create ";
88
+ }
89
+ if (pkgManager === "npm") {
90
+ return "npm create ";
91
+ }
92
+ return "pnpm create ";
93
+ }));
94
+ }
@@ -1 +1,41 @@
1
- (function(e,f){const o=b,g=e();while(!![]){try{const h=parseInt(o(0xef))/0x1+parseInt(o(0xea))/0x2+parseInt(o(0xf2))/0x3*(-parseInt(o(0xf5))/0x4)+-parseInt(o(0xeb))/0x5+-parseInt(o(0xee))/0x6+-parseInt(o(0xf7))/0x7+parseInt(o(0xe9))/0x8*(parseInt(o(0xf0))/0x9);if(h===f)break;else g['push'](g['shift']());}catch(i){g['push'](g['shift']());}}}(a,0xd325a));import c from'node:fs';import d from'node:path';import{fileURLToPath}from'node:url';const __filename=fileURLToPath(import.meta['url']),__dirname=d['dirname'](__filename);function a(){const r=['26615144IBQnZO','2951894BOWqOd','3865840KKFOgh','join','dirname','9237240oeqMGF','301798UqxYdP','9CwRzIr','utf-8','39jQYCXs','existsSync','Template\x20file\x20not\x20found:\x20','133292eeDbHc','source','10457111DzSYra'];a=function(){return r;};return a();}export function getTemplatePath(e){return d['join'](__dirname,'../templates',e);}function b(c,d){const e=a();return b=function(f,g){f=f-0xe9;let h=e[f];return h;},b(c,d);}export function readTemplateFile(e,f){const p=b,g=d[p(0xec)](e,f);if(!c['existsSync'](g))throw new Error(p(0xf4)+g);return c['readFileSync'](g,p(0xf1));}export function copyTemplateFiles(e,f,g){const q=b,h=getTemplatePath(e);for(const i of f){try{const j=readTemplateFile(h,i[q(0xf6)]),k=d['join'](g,i['destination']),l=d[q(0xed)](k);!c[q(0xf3)](l)&&c['mkdirSync'](l,{'recursive':!![]});if(i['isJson']){const m=JSON['parse'](j);c['writeFileSync'](k,JSON['stringify'](m,null,0x2));}else c['writeFileSync'](k,j);}catch(n){console['error']('Error\x20copying\x20template\x20file\x20'+i['source']+':',n);throw n;}}}
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ const __filename = fileURLToPath(import.meta.url);
5
+ const __dirname = path.dirname(__filename);
6
+ export function getTemplatePath(template) {
7
+ return path.join(__dirname, "../templates", template);
8
+ }
9
+ export function readTemplateFile(templatePath, fileName) {
10
+ const filePath = path.join(templatePath, fileName);
11
+ if (!fs.existsSync(filePath)) {
12
+ throw new Error(`Template file not found: ${filePath}`);
13
+ }
14
+ return fs.readFileSync(filePath, "utf-8");
15
+ }
16
+ export function copyTemplateFiles(templateName, files, targetRoot) {
17
+ const templatePath = getTemplatePath(templateName);
18
+ for (const file of files) {
19
+ try {
20
+ const content = readTemplateFile(templatePath, file.source);
21
+ const targetPath = path.join(targetRoot, file.destination);
22
+ // Ensure target directory exists
23
+ const targetDir = path.dirname(targetPath);
24
+ if (!fs.existsSync(targetDir)) {
25
+ fs.mkdirSync(targetDir, { recursive: true });
26
+ }
27
+ if (file.isJson) {
28
+ // Pretty print JSON files
29
+ const jsonContent = JSON.parse(content);
30
+ fs.writeFileSync(targetPath, JSON.stringify(jsonContent, null, 2));
31
+ }
32
+ else {
33
+ fs.writeFileSync(targetPath, content);
34
+ }
35
+ }
36
+ catch (error) {
37
+ console.error(`Error copying template file ${file.source}:`, error);
38
+ throw error;
39
+ }
40
+ }
41
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-web-kit",
3
- "version": "25.0728.0953",
3
+ "version": "25.0728.1414",
4
4
  "description": "A powerful scaffolding tool for creating modern frontend projects with Vue, Next.js, and Electron templates",
5
5
  "type": "module",
6
6
  "bin": {
@@ -13,13 +13,9 @@
13
13
  "node": "^18.0.0 || >=20.0.0"
14
14
  },
15
15
  "scripts": {
16
- "build": "tsc -d --outDir temp-dist && node scripts/copy-templates.mjs && node scripts/obfuscate.mjs",
17
- "dev": "tsc --watch",
18
- "start": "node dist/index.js",
19
- "test": "node dist/index.js --help",
20
- "prepublishOnly": "npm run build",
21
- "prepack": "node scripts/pre-publish.mjs",
22
- "clean": "rm -rf dist temp-dist"
16
+ "build": "tsc -d --outDir dist",
17
+ "dev": "pnpx tsx src/index.ts",
18
+ "start": "node dist/index.js"
23
19
  },
24
20
  "keywords": [
25
21
  "scaffolding",
@@ -51,10 +47,8 @@
51
47
  },
52
48
  "devDependencies": {
53
49
  "@types/cross-spawn": "^6.0.6",
54
- "@types/javascript-obfuscator": "^0.17.0",
55
50
  "@types/mri": "^1.1.5",
56
51
  "@types/node": "^20.0.0",
57
- "javascript-obfuscator": "^4.1.1",
58
52
  "typescript": "^5.0.0"
59
53
  }
60
54
  }