create-react-on-rails-app 16.4.0-rc.8 → 16.4.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/lib/create-app.js +8 -4
- package/package.json +2 -2
package/lib/create-app.js
CHANGED
|
@@ -72,20 +72,24 @@ function printSuccessMessage(appName, route) {
|
|
|
72
72
|
console.log('');
|
|
73
73
|
}
|
|
74
74
|
function validateAppName(name) {
|
|
75
|
-
if (!name
|
|
75
|
+
if (!name) {
|
|
76
76
|
return { success: false, error: 'App name is required.' };
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
const trimmedName = name.trim();
|
|
79
|
+
if (!trimmedName) {
|
|
80
|
+
return { success: false, error: 'App name is required.' };
|
|
81
|
+
}
|
|
82
|
+
if (!/^[a-zA-Z][a-zA-Z0-9]*([_-][a-zA-Z0-9]+)*$/.test(trimmedName)) {
|
|
79
83
|
return {
|
|
80
84
|
success: false,
|
|
81
85
|
error: 'App name must start with a letter, end with a letter or number, and may contain hyphens or underscores only between alphanumeric characters.',
|
|
82
86
|
};
|
|
83
87
|
}
|
|
84
|
-
const appPath = path_1.default.resolve(process.cwd(),
|
|
88
|
+
const appPath = path_1.default.resolve(process.cwd(), trimmedName);
|
|
85
89
|
if (fs_1.default.existsSync(appPath)) {
|
|
86
90
|
return {
|
|
87
91
|
success: false,
|
|
88
|
-
error: `Directory "${
|
|
92
|
+
error: `Directory "${trimmedName}" already exists. Please choose a different name or remove it.`,
|
|
89
93
|
};
|
|
90
94
|
}
|
|
91
95
|
return { success: true };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-react-on-rails-app",
|
|
3
|
-
"version": "16.4.0
|
|
3
|
+
"version": "16.4.0",
|
|
4
4
|
"description": "Create React on Rails applications with a single command",
|
|
5
5
|
"bin": {
|
|
6
6
|
"create-react-on-rails-app": "./bin/create-react-on-rails-app.js"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"scripts": {
|
|
45
45
|
"build": "pnpm run clean && tsc",
|
|
46
46
|
"build-watch": "pnpm run clean && tsc --watch",
|
|
47
|
-
"clean": "node -e \"require('fs').rmSync('./lib',{recursive:true,force:true})\"",
|
|
47
|
+
"clean": "node -e \"require('fs').rmSync('./lib', { recursive: true, force: true })\"",
|
|
48
48
|
"test": "jest tests",
|
|
49
49
|
"type-check": "tsc --noEmit --noErrorTruncation"
|
|
50
50
|
}
|