create-rsbuild 1.0.0-alpha.6 → 1.0.0-alpha.8
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 +14 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1140,8 +1140,12 @@ function checkCancel(value) {
|
|
|
1140
1140
|
}
|
|
1141
1141
|
return value;
|
|
1142
1142
|
}
|
|
1143
|
-
function
|
|
1144
|
-
|
|
1143
|
+
function formatProjectName(input) {
|
|
1144
|
+
const formatted = input.trim().replace(/\/+$/g, "");
|
|
1145
|
+
return {
|
|
1146
|
+
packageName: formatted.startsWith("@") ? formatted : path2.basename(formatted),
|
|
1147
|
+
targetDir: formatted
|
|
1148
|
+
};
|
|
1145
1149
|
}
|
|
1146
1150
|
function pkgFromUserAgent(userAgent) {
|
|
1147
1151
|
if (!userAgent)
|
|
@@ -1166,19 +1170,20 @@ async function main() {
|
|
|
1166
1170
|
const packageRoot = path2.resolve(__dirname, "..");
|
|
1167
1171
|
const packageJsonPath = path2.join(packageRoot, "package.json");
|
|
1168
1172
|
const { version } = __require(packageJsonPath);
|
|
1169
|
-
|
|
1173
|
+
const projectName = checkCancel(
|
|
1170
1174
|
await te({
|
|
1171
|
-
message: "
|
|
1172
|
-
placeholder: "
|
|
1175
|
+
message: "Project name or path",
|
|
1176
|
+
placeholder: "rsbuild-project",
|
|
1177
|
+
defaultValue: "rsbuild-project",
|
|
1173
1178
|
validate(value) {
|
|
1174
1179
|
if (value.length === 0) {
|
|
1175
|
-
return "
|
|
1180
|
+
return "Project name is required";
|
|
1176
1181
|
}
|
|
1177
1182
|
}
|
|
1178
1183
|
})
|
|
1179
1184
|
);
|
|
1180
|
-
targetDir =
|
|
1181
|
-
const distFolder = path2.join(cwd, targetDir);
|
|
1185
|
+
const { targetDir, packageName } = formatProjectName(projectName);
|
|
1186
|
+
const distFolder = path2.isAbsolute(targetDir) ? targetDir : path2.join(cwd, targetDir);
|
|
1182
1187
|
if (fs.existsSync(distFolder) && !isEmptyDir(distFolder)) {
|
|
1183
1188
|
const option = checkCancel(
|
|
1184
1189
|
await ie({
|
|
@@ -1231,7 +1236,7 @@ async function main() {
|
|
|
1231
1236
|
const srcFolder = path2.join(packageRoot, `template-${framework}-${language}`);
|
|
1232
1237
|
const commonFolder = path2.join(packageRoot, "template-common");
|
|
1233
1238
|
copyFolder(commonFolder, distFolder, version);
|
|
1234
|
-
copyFolder(srcFolder, distFolder, version,
|
|
1239
|
+
copyFolder(srcFolder, distFolder, version, packageName);
|
|
1235
1240
|
for (const tool of tools) {
|
|
1236
1241
|
const toolFolder = path2.join(packageRoot, `template-${tool}`);
|
|
1237
1242
|
if (tool === "eslint") {
|