create-rspack 0.5.7 → 0.5.8-canary-2e1be96-20240321104547
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/index.js +35 -24
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -12,21 +12,29 @@ yargs(hideBin(process.argv))
|
|
|
12
12
|
const { help } = argv.argv;
|
|
13
13
|
if (help) return;
|
|
14
14
|
|
|
15
|
+
const onCancel = () => {
|
|
16
|
+
console.log("Operation cancelled.");
|
|
17
|
+
process.exit(0);
|
|
18
|
+
};
|
|
19
|
+
|
|
15
20
|
const defaultProjectName = "rspack-project";
|
|
16
21
|
let template = "react";
|
|
17
22
|
let targetDir = defaultProjectName;
|
|
18
23
|
const promptProjectDir = async () =>
|
|
19
|
-
await prompts(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
await prompts(
|
|
25
|
+
[
|
|
26
|
+
{
|
|
27
|
+
type: "text",
|
|
28
|
+
name: "projectDir",
|
|
29
|
+
initial: defaultProjectName,
|
|
30
|
+
message: "Project folder",
|
|
31
|
+
onState: state => {
|
|
32
|
+
targetDir = formatTargetDir(state.value) || defaultProjectName;
|
|
33
|
+
}
|
|
27
34
|
}
|
|
28
|
-
|
|
29
|
-
|
|
35
|
+
],
|
|
36
|
+
{ onCancel }
|
|
37
|
+
);
|
|
30
38
|
|
|
31
39
|
await promptProjectDir();
|
|
32
40
|
let root = path.resolve(process.cwd(), targetDir);
|
|
@@ -39,21 +47,24 @@ yargs(hideBin(process.argv))
|
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
// choose template
|
|
42
|
-
await prompts(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
await prompts(
|
|
51
|
+
[
|
|
52
|
+
{
|
|
53
|
+
type: "select",
|
|
54
|
+
name: "template",
|
|
55
|
+
message: "Project template",
|
|
56
|
+
choices: [
|
|
57
|
+
{ title: "react", value: "react" },
|
|
58
|
+
{ title: "react-ts", value: "react-ts" },
|
|
59
|
+
{ title: "vue", value: "vue" }
|
|
60
|
+
],
|
|
61
|
+
onState: state => {
|
|
62
|
+
template = state.value;
|
|
63
|
+
}
|
|
54
64
|
}
|
|
55
|
-
|
|
56
|
-
|
|
65
|
+
],
|
|
66
|
+
{ onCancel }
|
|
67
|
+
);
|
|
57
68
|
|
|
58
69
|
fs.mkdirSync(root, { recursive: true });
|
|
59
70
|
const srcFolder = path.resolve(__dirname, `template-${template}`);
|