beever-create 0.1.0 → 0.1.1
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 +20 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/templates/package.json +2 -2
- package/templates/web/main.tsx +1 -1
- package/templates/web/vite.config.ts +8 -0
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import fs from "fs";
|
|
5
5
|
import path from "path";
|
|
6
|
+
import { spawnSync } from "child_process";
|
|
6
7
|
import { fileURLToPath } from "url";
|
|
7
8
|
var projectName = process.argv[2];
|
|
8
9
|
if (!projectName) {
|
|
@@ -54,10 +55,10 @@ try {
|
|
|
54
55
|
recursive: true
|
|
55
56
|
});
|
|
56
57
|
replaceProjectName(projectPath);
|
|
57
|
-
console.log("
|
|
58
|
+
console.log("\nBeever project created successfully!");
|
|
58
59
|
console.log(`Project location: ${projectPath}`);
|
|
59
60
|
} catch (error) {
|
|
60
|
-
console.error("
|
|
61
|
+
console.error("\nFailed to create Beever project.");
|
|
61
62
|
if (fs.existsSync(projectPath)) {
|
|
62
63
|
fs.rmSync(projectPath, {
|
|
63
64
|
recursive: true,
|
|
@@ -67,4 +68,21 @@ try {
|
|
|
67
68
|
console.error(error);
|
|
68
69
|
process.exit(1);
|
|
69
70
|
}
|
|
71
|
+
console.log("\nInstalling project dependencies...\n");
|
|
72
|
+
var installResult = spawnSync("npm", ["install"], {
|
|
73
|
+
cwd: projectPath,
|
|
74
|
+
stdio: "inherit",
|
|
75
|
+
shell: process.platform === "win32"
|
|
76
|
+
});
|
|
77
|
+
if (installResult.error || installResult.status !== 0) {
|
|
78
|
+
console.error("\nDependency installation failed.");
|
|
79
|
+
console.error(`Your project was created at: ${projectPath}`);
|
|
80
|
+
console.error("You can retry by running 'npm install' inside the project.");
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
console.log("\nDependencies installed successfully!");
|
|
84
|
+
console.log("\nYour Beever project is ready!");
|
|
85
|
+
console.log("\nNext steps:");
|
|
86
|
+
console.log(` cd ${projectName}`);
|
|
87
|
+
console.log(" npm run web");
|
|
70
88
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import fs from \"node:fs\";\r\nimport path from \"node:path\";\r\nimport { fileURLToPath } from \"node:url\";\r\n\r\nconst projectName = process.argv[2];\r\n\r\nif (!projectName) {\r\n console.log(\"Please provide a project name.\");\r\n console.log(\"Usage: npx beever-create <project-name>\");\r\n process.exit(1);\r\n}\r\n\r\nconst validProjectName = /^[a-zA-Z0-9_-]+$/.test(projectName);\r\n\r\nif (!validProjectName) {\r\n console.error(\r\n \"Invalid project name. Use only letters, numbers, hyphens, and underscores.\",\r\n );\r\n process.exit(1);\r\n}\r\n\r\nconst projectPath = path.resolve(process.cwd(), projectName);\r\n\r\nif (fs.existsSync(projectPath)) {\r\n console.error(`A folder named \"${projectName}\" already exists.`);\r\n process.exit(1);\r\n}\r\n\r\nconst currentDirectory = path.dirname(fileURLToPath(import.meta.url));\r\nconst templatesPath = path.resolve(currentDirectory, \"../templates\");\r\n\r\nconst packageName = projectName.toLowerCase().replace(/_/g, \"-\");\r\n\r\nfunction replaceProjectName(directory: string) {\r\n const entries = fs.readdirSync(directory, {\r\n withFileTypes: true,\r\n });\r\n\r\n for (const entry of entries) {\r\n const entryPath = path.join(directory, entry.name);\r\n\r\n if (entry.isDirectory()) {\r\n replaceProjectName(entryPath);\r\n continue;\r\n }\r\n\r\n const content = fs.readFileSync(entryPath, \"utf8\");\r\n\r\n if (content.includes(\"{{projectName}}\")) {\r\n fs.writeFileSync(\r\n entryPath,\r\n content.split(\"{{projectName}}\").join(packageName),\r\n \"utf8\",\r\n );\r\n }\r\n }\r\n}\r\n\r\ntry {\r\n if (!fs.existsSync(templatesPath)) {\r\n throw new Error(\"Project templates directory not found.\");\r\n }\r\n\r\n fs.mkdirSync(projectPath);\r\n\r\n fs.cpSync(templatesPath, projectPath, {\r\n recursive: true,\r\n });\r\n\r\n replaceProjectName(projectPath);\r\n\r\n console.log(\"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import fs from \"node:fs\";\r\nimport path from \"node:path\";\r\nimport { spawnSync } from \"node:child_process\";\r\nimport { fileURLToPath } from \"node:url\";\r\n\r\nconst projectName = process.argv[2];\r\n\r\nif (!projectName) {\r\n console.log(\"Please provide a project name.\");\r\n console.log(\"Usage: npx beever-create <project-name>\");\r\n process.exit(1);\r\n}\r\n\r\nconst validProjectName = /^[a-zA-Z0-9_-]+$/.test(projectName);\r\n\r\nif (!validProjectName) {\r\n console.error(\r\n \"Invalid project name. Use only letters, numbers, hyphens, and underscores.\",\r\n );\r\n process.exit(1);\r\n}\r\n\r\nconst projectPath = path.resolve(process.cwd(), projectName);\r\n\r\nif (fs.existsSync(projectPath)) {\r\n console.error(`A folder named \"${projectName}\" already exists.`);\r\n process.exit(1);\r\n}\r\n\r\nconst currentDirectory = path.dirname(fileURLToPath(import.meta.url));\r\nconst templatesPath = path.resolve(currentDirectory, \"../templates\");\r\n\r\nconst packageName = projectName.toLowerCase().replace(/_/g, \"-\");\r\n\r\nfunction replaceProjectName(directory: string) {\r\n const entries = fs.readdirSync(directory, {\r\n withFileTypes: true,\r\n });\r\n\r\n for (const entry of entries) {\r\n const entryPath = path.join(directory, entry.name);\r\n\r\n if (entry.isDirectory()) {\r\n replaceProjectName(entryPath);\r\n continue;\r\n }\r\n\r\n const content = fs.readFileSync(entryPath, \"utf8\");\r\n\r\n if (content.includes(\"{{projectName}}\")) {\r\n fs.writeFileSync(\r\n entryPath,\r\n content.split(\"{{projectName}}\").join(packageName),\r\n \"utf8\",\r\n );\r\n }\r\n }\r\n}\r\n\r\ntry {\r\n if (!fs.existsSync(templatesPath)) {\r\n throw new Error(\"Project templates directory not found.\");\r\n }\r\n\r\n fs.mkdirSync(projectPath);\r\n\r\n fs.cpSync(templatesPath, projectPath, {\r\n recursive: true,\r\n });\r\n\r\n replaceProjectName(projectPath);\r\n\r\n console.log(\"\\nBeever project created successfully!\");\r\n console.log(`Project location: ${projectPath}`);\r\n} catch (error) {\r\n console.error(\"\\nFailed to create Beever project.\");\r\n\r\n if (fs.existsSync(projectPath)) {\r\n fs.rmSync(projectPath, {\r\n recursive: true,\r\n force: true,\r\n });\r\n }\r\n\r\n console.error(error);\r\n process.exit(1);\r\n}\r\n\r\n// Automatically install project dependencies.\r\nconsole.log(\"\\nInstalling project dependencies...\\n\");\r\n\r\nconst installResult = spawnSync(\"npm\", [\"install\"], {\r\n cwd: projectPath,\r\n stdio: \"inherit\",\r\n shell: process.platform === \"win32\",\r\n});\r\n\r\nif (installResult.error || installResult.status !== 0) {\r\n console.error(\"\\nDependency installation failed.\");\r\n console.error(`Your project was created at: ${projectPath}`);\r\n console.error(\"You can retry by running 'npm install' inside the project.\");\r\n process.exit(1);\r\n}\r\n\r\nconsole.log(\"\\nDependencies installed successfully!\");\r\nconsole.log(\"\\nYour Beever project is ready!\");\r\n\r\nconsole.log(\"\\nNext steps:\");\r\nconsole.log(` cd ${projectName}`);\r\nconsole.log(\" npm run web\");\r\n"],"mappings":";;;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAE9B,IAAM,cAAc,QAAQ,KAAK,CAAC;AAElC,IAAI,CAAC,aAAa;AAChB,UAAQ,IAAI,gCAAgC;AAC5C,UAAQ,IAAI,yCAAyC;AACrD,UAAQ,KAAK,CAAC;AAChB;AAEA,IAAM,mBAAmB,mBAAmB,KAAK,WAAW;AAE5D,IAAI,CAAC,kBAAkB;AACrB,UAAQ;AAAA,IACN;AAAA,EACF;AACA,UAAQ,KAAK,CAAC;AAChB;AAEA,IAAM,cAAc,KAAK,QAAQ,QAAQ,IAAI,GAAG,WAAW;AAE3D,IAA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I,wCAAwC;AAEpD,IAAM,gBAAgB,UAAU,OAAO,CAAC,SAAS,GAAG;AAAA,EAClD,KAAK;AAAA,EACL,OAAO;AAAA,EACP,OAAO,QAAQ,aAAa;AAC9B,CAAC;AAED,IAAI,cAAc,SAAS,cAAc,WAAW,GAAG;AACrD,UAAQ,MAAM,mCAAmC;AACjD,UAAQ,MAAM,gCAAgC,WAAW,EAAE;AAC3D,UAAQ,MAAM,4DAA4D;AAC1E,UAAQ,KAAK,CAAC;AAChB;AAEA,QAAQ,IAAI,wCAAwC;AACpD,QAAQ,IAAI,iCAAiC;AAE7C,QAAQ,IAAI,eAAe;AAC3B,QAAQ,IAAI,QAAQ,WAAW,EAAE;AACjC,QAAQ,IAAI,eAAe;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "beever-create",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "CLI tool for creating Beever projects.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
|
-
"beever-create": "
|
|
8
|
+
"beever-create": "dist/index.js"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|
package/templates/package.json
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"main": "mobile/index.ts",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"web": "vite --
|
|
8
|
-
"build:web": "vite build --
|
|
7
|
+
"web": "vite web --config web/vite.config.ts",
|
|
8
|
+
"build:web": "vite build web --config web/vite.config.ts",
|
|
9
9
|
"mobile": "expo start --config mobile/app.json"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
package/templates/web/main.tsx
CHANGED