@editframe/create 0.26.2-beta.0 → 0.26.4-beta.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
|
@@ -2,10 +2,39 @@
|
|
|
2
2
|
import { access, cp, readdir } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { parseArgs } from "node:util";
|
|
5
6
|
import chalk from "chalk";
|
|
6
7
|
import prompts from "prompts";
|
|
7
8
|
|
|
8
9
|
//#region src/index.ts
|
|
10
|
+
function showHelp(templates) {
|
|
11
|
+
const usage = `
|
|
12
|
+
${chalk.bold("Usage:")}
|
|
13
|
+
npm create @editframe/elements -- [template] [options]
|
|
14
|
+
|
|
15
|
+
${chalk.bold("Options:")}
|
|
16
|
+
-d, --directory <name> Project directory name (default: prompts for input)
|
|
17
|
+
-h, --help Show this help message
|
|
18
|
+
|
|
19
|
+
${chalk.bold("Available Templates:")}
|
|
20
|
+
${templates.map((t) => ` - ${t}`).join("\n")}
|
|
21
|
+
|
|
22
|
+
${chalk.bold("Examples:")}
|
|
23
|
+
${chalk.dim("# Interactive mode (prompts for all inputs)")}
|
|
24
|
+
npm create @editframe/elements
|
|
25
|
+
|
|
26
|
+
${chalk.dim("# Specify template, prompt for directory")}
|
|
27
|
+
npm create @editframe/elements -- react-demo
|
|
28
|
+
|
|
29
|
+
${chalk.dim("# Specify both template and directory")}
|
|
30
|
+
npm create @editframe/elements -- react-demo --directory my-app
|
|
31
|
+
npm create @editframe/elements -- react-demo -d my-app
|
|
32
|
+
|
|
33
|
+
${chalk.dim("# Show help")}
|
|
34
|
+
npm create @editframe/elements -- --help
|
|
35
|
+
`;
|
|
36
|
+
process.stdout.write(usage);
|
|
37
|
+
}
|
|
9
38
|
async function checkDirectoryExists(path$1) {
|
|
10
39
|
try {
|
|
11
40
|
await access(path$1);
|
|
@@ -16,22 +45,56 @@ async function checkDirectoryExists(path$1) {
|
|
|
16
45
|
}
|
|
17
46
|
async function main() {
|
|
18
47
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
19
|
-
const
|
|
48
|
+
const templates = await readdir(path.join(__dirname, "templates"));
|
|
49
|
+
const { values, positionals } = parseArgs({
|
|
50
|
+
args: process.argv.slice(2),
|
|
51
|
+
options: {
|
|
52
|
+
help: {
|
|
53
|
+
type: "boolean",
|
|
54
|
+
short: "h",
|
|
55
|
+
default: false
|
|
56
|
+
},
|
|
57
|
+
directory: {
|
|
58
|
+
type: "string",
|
|
59
|
+
short: "d"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
allowPositionals: true
|
|
63
|
+
});
|
|
64
|
+
if (values.help) {
|
|
65
|
+
showHelp(templates);
|
|
66
|
+
process.exit(0);
|
|
67
|
+
}
|
|
68
|
+
const cliTemplate = positionals[0];
|
|
69
|
+
const cliDirectory = values.directory;
|
|
70
|
+
if (cliTemplate && !templates.includes(cliTemplate)) {
|
|
71
|
+
process.stderr.write(chalk.red(`Error: Template "${cliTemplate}" does not exist.\n\n`));
|
|
72
|
+
process.stderr.write(chalk.bold("Available templates:\n"));
|
|
73
|
+
for (const t of templates) process.stderr.write(` - ${t}\n`);
|
|
74
|
+
process.stderr.write(chalk.dim("\nRun with --help for more information.\n"));
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
const promptQuestions = [];
|
|
78
|
+
if (!cliDirectory) promptQuestions.push({
|
|
20
79
|
type: "text",
|
|
21
80
|
name: "directoryName",
|
|
22
81
|
message: "Enter the name of the directory to generate into:",
|
|
23
82
|
initial: "my-project"
|
|
24
|
-
}
|
|
83
|
+
});
|
|
84
|
+
if (!cliTemplate) promptQuestions.push({
|
|
25
85
|
type: "select",
|
|
26
86
|
name: "templateName",
|
|
27
87
|
message: "Choose a starter template:",
|
|
28
|
-
choices:
|
|
88
|
+
choices: templates.map((template) => ({
|
|
29
89
|
title: template,
|
|
30
90
|
value: template
|
|
31
91
|
}))
|
|
32
|
-
}
|
|
33
|
-
const
|
|
34
|
-
const
|
|
92
|
+
});
|
|
93
|
+
const answers = promptQuestions.length > 0 ? await prompts(promptQuestions) : {};
|
|
94
|
+
const directoryName = cliDirectory || answers.directoryName;
|
|
95
|
+
const templateName = cliTemplate || answers.templateName;
|
|
96
|
+
const targetDir = path.join(process.cwd(), directoryName);
|
|
97
|
+
const templateDir = path.join(__dirname, "templates", templateName);
|
|
35
98
|
if (await checkDirectoryExists(targetDir)) {
|
|
36
99
|
process.stderr.write(chalk.yellow(`Directory ${targetDir} already exists.\n`));
|
|
37
100
|
const { overwrite } = await prompts({
|
|
@@ -46,13 +109,13 @@ async function main() {
|
|
|
46
109
|
}
|
|
47
110
|
}
|
|
48
111
|
process.stderr.write(`Creating project in directory: ${targetDir}\n`);
|
|
49
|
-
process.stderr.write(`Using template: ${
|
|
112
|
+
process.stderr.write(`Using template: ${templateName}\n`);
|
|
50
113
|
await cp(templateDir, targetDir, { recursive: true });
|
|
51
|
-
process.stderr.write("
|
|
114
|
+
process.stderr.write(chalk.green("\nProject created successfully.\n\n"));
|
|
52
115
|
process.stderr.write(chalk.green("Next steps:\n"));
|
|
53
|
-
process.stderr.write(`cd ${
|
|
54
|
-
process.stderr.write("npm install\n");
|
|
55
|
-
process.stderr.write("npm start\n\n");
|
|
116
|
+
process.stderr.write(` cd ${directoryName}\n`);
|
|
117
|
+
process.stderr.write(" npm install\n");
|
|
118
|
+
process.stderr.write(" npm start\n\n");
|
|
56
119
|
process.stderr.write("Happy hacking!\n");
|
|
57
120
|
}
|
|
58
121
|
main();
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["path"],"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { access, cp, readdir } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport chalk from \"chalk\";\nimport prompts from \"prompts\";\n\nasync function checkDirectoryExists(path: string) {\n try {\n await access(path);\n return true;\n } catch (_error) {\n return false;\n }\n}\n\nasync function main() {\n const __dirname = path.dirname(fileURLToPath(import.meta.url));\n\n // List of available starter templates\n const templates = await readdir(path.join(__dirname, \"templates\"));\n\n //
|
|
1
|
+
{"version":3,"file":"index.js","names":["path","promptQuestions: prompts.PromptObject[]"],"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { access, cp, readdir } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { parseArgs } from \"node:util\";\nimport chalk from \"chalk\";\nimport prompts from \"prompts\";\n\nfunction showHelp(templates: string[]) {\n const usage = `\n${chalk.bold(\"Usage:\")}\n npm create @editframe/elements -- [template] [options]\n\n${chalk.bold(\"Options:\")}\n -d, --directory <name> Project directory name (default: prompts for input)\n -h, --help Show this help message\n\n${chalk.bold(\"Available Templates:\")}\n${templates.map((t) => ` - ${t}`).join(\"\\n\")}\n\n${chalk.bold(\"Examples:\")}\n ${chalk.dim(\"# Interactive mode (prompts for all inputs)\")}\n npm create @editframe/elements\n\n ${chalk.dim(\"# Specify template, prompt for directory\")}\n npm create @editframe/elements -- react-demo\n\n ${chalk.dim(\"# Specify both template and directory\")}\n npm create @editframe/elements -- react-demo --directory my-app\n npm create @editframe/elements -- react-demo -d my-app\n\n ${chalk.dim(\"# Show help\")}\n npm create @editframe/elements -- --help\n`;\n\n process.stdout.write(usage);\n}\n\nasync function checkDirectoryExists(path: string) {\n try {\n await access(path);\n return true;\n } catch (_error) {\n return false;\n }\n}\n\nasync function main() {\n const __dirname = path.dirname(fileURLToPath(import.meta.url));\n\n // List of available starter templates\n const templates = await readdir(path.join(__dirname, \"templates\"));\n\n // Parse command line arguments\n const { values, positionals } = parseArgs({\n args: process.argv.slice(2),\n options: {\n help: {\n type: \"boolean\",\n short: \"h\",\n default: false,\n },\n directory: {\n type: \"string\",\n short: \"d\",\n },\n },\n allowPositionals: true,\n });\n\n // Show help if requested\n if (values.help) {\n showHelp(templates);\n process.exit(0);\n }\n\n // Extract CLI arguments\n const cliTemplate = positionals[0];\n const cliDirectory = values.directory;\n\n // Validate template if provided\n if (cliTemplate && !templates.includes(cliTemplate)) {\n process.stderr.write(\n chalk.red(`Error: Template \"${cliTemplate}\" does not exist.\\n\\n`),\n );\n process.stderr.write(chalk.bold(\"Available templates:\\n\"));\n for (const t of templates) {\n process.stderr.write(` - ${t}\\n`);\n }\n process.stderr.write(\n chalk.dim(\"\\nRun with --help for more information.\\n\"),\n );\n process.exit(1);\n }\n\n // Build prompts array based on what CLI args were provided\n const promptQuestions: prompts.PromptObject[] = [];\n\n if (!cliDirectory) {\n promptQuestions.push({\n type: \"text\",\n name: \"directoryName\",\n message: \"Enter the name of the directory to generate into:\",\n initial: \"my-project\",\n });\n }\n\n if (!cliTemplate) {\n promptQuestions.push({\n type: \"select\",\n name: \"templateName\",\n message: \"Choose a starter template:\",\n choices: templates.map((template) => ({\n title: template,\n value: template,\n })),\n });\n }\n\n // Prompt for missing information\n const answers =\n promptQuestions.length > 0 ? await prompts(promptQuestions) : {};\n\n // Use CLI args or prompted values\n const directoryName = cliDirectory || answers.directoryName;\n const templateName = cliTemplate || answers.templateName;\n\n const targetDir = path.join(process.cwd(), directoryName);\n const templateDir = path.join(__dirname, \"templates\", templateName);\n\n const exists = await checkDirectoryExists(targetDir);\n\n if (exists) {\n process.stderr.write(\n chalk.yellow(`Directory ${targetDir} already exists.\\n`),\n );\n const { overwrite } = await prompts({\n type: \"confirm\",\n name: \"overwrite\",\n message: \"Directory already exists. Do you want to overwrite it?\",\n initial: false,\n });\n\n if (!overwrite) {\n process.stderr.write(chalk.red(\"Aborting...\\n\"));\n process.exit(1);\n }\n }\n\n process.stderr.write(`Creating project in directory: ${targetDir}\\n`);\n process.stderr.write(`Using template: ${templateName}\\n`);\n\n // Copy the selected template to the target directory\n await cp(templateDir, targetDir, { recursive: true });\n\n process.stderr.write(chalk.green(\"\\nProject created successfully.\\n\\n\"));\n\n process.stderr.write(chalk.green(\"Next steps:\\n\"));\n\n process.stderr.write(` cd ${directoryName}\\n`);\n process.stderr.write(\" npm install\\n\");\n process.stderr.write(\" npm start\\n\\n\");\n\n process.stderr.write(\"Happy hacking!\\n\");\n}\n\nmain();\n"],"mappings":";;;;;;;;;AASA,SAAS,SAAS,WAAqB;CACrC,MAAM,QAAQ;EACd,MAAM,KAAK,SAAS,CAAC;;;EAGrB,MAAM,KAAK,WAAW,CAAC;;;;EAIvB,MAAM,KAAK,uBAAuB,CAAC;EACnC,UAAU,KAAK,MAAM,OAAO,IAAI,CAAC,KAAK,KAAK,CAAC;;EAE5C,MAAM,KAAK,YAAY,CAAC;IACtB,MAAM,IAAI,8CAA8C,CAAC;;;IAGzD,MAAM,IAAI,2CAA2C,CAAC;;;IAGtD,MAAM,IAAI,wCAAwC,CAAC;;;;IAInD,MAAM,IAAI,cAAc,CAAC;;;AAI3B,SAAQ,OAAO,MAAM,MAAM;;AAG7B,eAAe,qBAAqB,QAAc;AAChD,KAAI;AACF,QAAM,OAAOA,OAAK;AAClB,SAAO;UACA,QAAQ;AACf,SAAO;;;AAIX,eAAe,OAAO;CACpB,MAAM,YAAY,KAAK,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;CAG9D,MAAM,YAAY,MAAM,QAAQ,KAAK,KAAK,WAAW,YAAY,CAAC;CAGlE,MAAM,EAAE,QAAQ,gBAAgB,UAAU;EACxC,MAAM,QAAQ,KAAK,MAAM,EAAE;EAC3B,SAAS;GACP,MAAM;IACJ,MAAM;IACN,OAAO;IACP,SAAS;IACV;GACD,WAAW;IACT,MAAM;IACN,OAAO;IACR;GACF;EACD,kBAAkB;EACnB,CAAC;AAGF,KAAI,OAAO,MAAM;AACf,WAAS,UAAU;AACnB,UAAQ,KAAK,EAAE;;CAIjB,MAAM,cAAc,YAAY;CAChC,MAAM,eAAe,OAAO;AAG5B,KAAI,eAAe,CAAC,UAAU,SAAS,YAAY,EAAE;AACnD,UA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,MAAM,MAAM,sCAAsC,CAAC;AAExE,SAAQ,OAAO,MAAM,MAAM,MAAM,gBAAgB,CAAC;AAElD,SAAQ,OAAO,MAAM,QAAQ,cAAc,IAAI;AAC/C,SAAQ,OAAO,MAAM,kBAAkB;AACvC,SAAQ,OAAO,MAAM,kBAAkB;AAEvC,SAAQ,OAAO,MAAM,mBAAmB;;AAG1C,MAAM"}
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"author": "",
|
|
12
12
|
"license": "ISC",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@editframe/cli": "0.26.
|
|
15
|
-
"@editframe/elements": "0.26.
|
|
16
|
-
"@editframe/vite-plugin": "0.26.
|
|
14
|
+
"@editframe/cli": "0.26.4-beta.0",
|
|
15
|
+
"@editframe/elements": "0.26.4-beta.0",
|
|
16
|
+
"@editframe/vite-plugin": "0.26.4-beta.0",
|
|
17
17
|
"animejs": "^4.2.2",
|
|
18
18
|
"prismjs": "^1.30.0",
|
|
19
19
|
"tailwindcss": "^3.4.3",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"author": "",
|
|
12
12
|
"license": "ISC",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@editframe/cli": "0.26.
|
|
15
|
-
"@editframe/elements": "0.26.
|
|
16
|
-
"@editframe/vite-plugin": "0.26.
|
|
14
|
+
"@editframe/cli": "0.26.4-beta.0",
|
|
15
|
+
"@editframe/elements": "0.26.4-beta.0",
|
|
16
|
+
"@editframe/vite-plugin": "0.26.4-beta.0",
|
|
17
17
|
"tailwindcss": "^3.4.3",
|
|
18
18
|
"vite": "^6.3.5",
|
|
19
19
|
"vite-plugin-singlefile": "^2.0.1"
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"author": "",
|
|
12
12
|
"license": "ISC",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@editframe/cli": "0.26.
|
|
15
|
-
"@editframe/react": "0.26.
|
|
16
|
-
"@editframe/vite-plugin": "0.26.
|
|
14
|
+
"@editframe/cli": "0.26.4-beta.0",
|
|
15
|
+
"@editframe/react": "0.26.4-beta.0",
|
|
16
|
+
"@editframe/vite-plugin": "0.26.4-beta.0",
|
|
17
17
|
"@vitejs/plugin-react": "^4.3.1",
|
|
18
18
|
"tailwindcss": "^3.4.3",
|
|
19
19
|
"vite": "^6.3.5",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"author": "",
|
|
12
12
|
"license": "ISC",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@editframe/cli": "0.26.
|
|
15
|
-
"@editframe/elements": "0.26.
|
|
16
|
-
"@editframe/vite-plugin": "0.26.
|
|
14
|
+
"@editframe/cli": "0.26.4-beta.0",
|
|
15
|
+
"@editframe/elements": "0.26.4-beta.0",
|
|
16
|
+
"@editframe/vite-plugin": "0.26.4-beta.0",
|
|
17
17
|
"tailwindcss": "^3.4.3",
|
|
18
18
|
"vite": "^6.3.5",
|
|
19
19
|
"vite-plugin-singlefile": "^2.0.1"
|