create-rspack 0.4.5 → 0.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/index.js
CHANGED
|
@@ -5,6 +5,7 @@ const fs = require("fs");
|
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const prompts = require("prompts");
|
|
7
7
|
const { formatTargetDir } = require("./utils");
|
|
8
|
+
const { version } = require("./package.json");
|
|
8
9
|
|
|
9
10
|
yargs(hideBin(process.argv))
|
|
10
11
|
.command("$0", "init rspack project", async argv => {
|
|
@@ -73,6 +74,9 @@ function copyFolder(src, dst) {
|
|
|
73
74
|
|
|
74
75
|
fs.mkdirSync(dst, { recursive: true });
|
|
75
76
|
for (const file of fs.readdirSync(src)) {
|
|
77
|
+
if (file === "node_modules") {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
76
80
|
const srcFile = path.resolve(src, file);
|
|
77
81
|
const dstFile = renameFiles[file]
|
|
78
82
|
? path.resolve(dst, renameFiles[file])
|
|
@@ -81,7 +85,27 @@ function copyFolder(src, dst) {
|
|
|
81
85
|
if (stat.isDirectory()) {
|
|
82
86
|
copyFolder(srcFile, dstFile);
|
|
83
87
|
} else {
|
|
84
|
-
|
|
88
|
+
// use create-rspack version as @rspack/xxx version in template
|
|
89
|
+
if (file === "package.json") {
|
|
90
|
+
const pkg = require(srcFile);
|
|
91
|
+
if (pkg.dependencies) {
|
|
92
|
+
for (const key of Object.keys(pkg.dependencies)) {
|
|
93
|
+
if (key.startsWith("@rspack/")) {
|
|
94
|
+
pkg.dependencies[key] = version;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (pkg.devDependencies) {
|
|
99
|
+
for (const key of Object.keys(pkg.devDependencies)) {
|
|
100
|
+
if (key.startsWith("@rspack/")) {
|
|
101
|
+
pkg.devDependencies[key] = version;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
fs.writeFileSync(dstFile, JSON.stringify(pkg, null, 2), "utf-8");
|
|
106
|
+
} else {
|
|
107
|
+
fs.copyFileSync(srcFile, dstFile);
|
|
108
|
+
}
|
|
85
109
|
}
|
|
86
110
|
}
|
|
87
111
|
}
|
package/package.json
CHANGED