create-ipro-microfront 1.0.0 → 1.0.2
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/bin/generate-app.js +21 -9
- package/package.json +3 -6
package/bin/generate-app.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// Импорт необходимых зависимостей
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import { join } from "path";
|
|
5
|
+
import { mkdirSync, rmSync } from "fs";
|
|
6
|
+
import { execSync } from "child_process";
|
|
7
7
|
|
|
8
8
|
if (process.argv.length < 3) {
|
|
9
9
|
console.log("Необходимо ввести имя приложения.");
|
|
@@ -14,12 +14,14 @@ if (process.argv.length < 3) {
|
|
|
14
14
|
|
|
15
15
|
const projectName = process.argv[2]; // Название проекта - ipro-catalog
|
|
16
16
|
const currentPath = process.cwd(); // Текущая директория - Desktop/Projects
|
|
17
|
-
const projectPath =
|
|
17
|
+
const projectPath = join(currentPath, projectName); // Абсолютный путь - Desktop/Projects/ipro-catalog
|
|
18
|
+
const binPath = path.join(projectPath, "bin"); // Путь к папке bin
|
|
19
|
+
const gitFolderPath = path.join(projectPath, ".git"); // Путь к папке .git
|
|
18
20
|
const git_repo = "https://github.com/maxsvst/test-repo.git";
|
|
19
21
|
|
|
20
22
|
// Валидация имени проекта
|
|
21
23
|
try {
|
|
22
|
-
|
|
24
|
+
mkdirSync(projectPath); // Попытка создать директорию
|
|
23
25
|
} catch (err) {
|
|
24
26
|
if (err.code === "EEXIST") {
|
|
25
27
|
console.log(
|
|
@@ -42,14 +44,24 @@ async function main() {
|
|
|
42
44
|
execSync("npm install");
|
|
43
45
|
|
|
44
46
|
console.log("Удаление папки .git...");
|
|
45
|
-
|
|
47
|
+
if (fs.existsSync(gitFolderPath)) {
|
|
48
|
+
fs.rmSync(gitFolderPath, { recursive: true, force: true });
|
|
49
|
+
console.log("Папка .git удалена.");
|
|
50
|
+
}
|
|
46
51
|
|
|
47
|
-
|
|
48
|
-
fs.
|
|
52
|
+
console.log("Удаление папки bin...");
|
|
53
|
+
if (fs.existsSync(binPath)) {
|
|
54
|
+
fs.rmSync(binPath, { recursive: true, force: true });
|
|
55
|
+
console.log("Папка bin удалена.");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
console.log("Инициализация нового репозитория Git...");
|
|
59
|
+
execSync("git init");
|
|
49
60
|
|
|
50
61
|
console.log("Загрузка завершена!");
|
|
51
62
|
} catch (err) {
|
|
52
|
-
console.
|
|
63
|
+
console.error("Произошла ошибка во время инициализации:", err.message);
|
|
64
|
+
process.exit(1);
|
|
53
65
|
}
|
|
54
66
|
}
|
|
55
67
|
main();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-ipro-microfront",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"start": "parcel index.html",
|
|
@@ -14,9 +14,6 @@
|
|
|
14
14
|
"parcel-bundler": "^1.12.5"
|
|
15
15
|
},
|
|
16
16
|
"bin": {
|
|
17
|
-
"create-ipro-microfront": "./generate-app.js"
|
|
18
|
-
},
|
|
19
|
-
"dependencies": {
|
|
20
|
-
"rimraf": "^6.1.2"
|
|
17
|
+
"create-ipro-microfront": "./bin/generate-app.js"
|
|
21
18
|
}
|
|
22
|
-
}
|
|
19
|
+
}
|