create-ipro-microfront 1.0.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/bin/generate-app.js +55 -0
- package/index.html +8 -0
- package/index.js +0 -0
- package/package.json +22 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// Импорт необходимых зависимостей
|
|
4
|
+
const { execSync } = require("child_process");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
|
|
8
|
+
if (process.argv.length < 3) {
|
|
9
|
+
console.log("Необходимо ввести имя приложения.");
|
|
10
|
+
console.log("Например :");
|
|
11
|
+
console.log(" npx create-ipro-microfront ipro-catalog");
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const projectName = process.argv[2]; // Название проекта - ipro-catalog
|
|
16
|
+
const currentPath = process.cwd(); // Текущая директория - Desktop/Projects
|
|
17
|
+
const projectPath = path.join(currentPath, projectName); // Абсолютный путь - Desktop/Projects/ipro-catalog
|
|
18
|
+
const git_repo = "https://github.com/maxsvst/test-repo.git";
|
|
19
|
+
|
|
20
|
+
// Валидация имени проекта
|
|
21
|
+
try {
|
|
22
|
+
fs.mkdirSync(projectPath); // Попытка создать директорию
|
|
23
|
+
} catch (err) {
|
|
24
|
+
if (err.code === "EEXIST") {
|
|
25
|
+
console.log(
|
|
26
|
+
`Папка ${projectName} уже существует в текущей директории, придумайте другое название.`,
|
|
27
|
+
);
|
|
28
|
+
} else {
|
|
29
|
+
console.log(err);
|
|
30
|
+
}
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function main() {
|
|
35
|
+
try {
|
|
36
|
+
console.log("Скачивание проекта...");
|
|
37
|
+
execSync(`git clone --depth 1 ${git_repo} ${projectPath}`);
|
|
38
|
+
|
|
39
|
+
process.chdir(projectPath);
|
|
40
|
+
|
|
41
|
+
console.log("Установка зависимостей...");
|
|
42
|
+
execSync("npm install");
|
|
43
|
+
|
|
44
|
+
console.log("Удаление папки .git...");
|
|
45
|
+
execSync("npx rimraf ./.git");
|
|
46
|
+
|
|
47
|
+
// Нужно ли удалять папку bin для конечного пользователя?
|
|
48
|
+
fs.rmdirSync(path.join(projectPath, "bin"), { recursive: true });
|
|
49
|
+
|
|
50
|
+
console.log("Загрузка завершена!");
|
|
51
|
+
} catch (err) {
|
|
52
|
+
console.log(err);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
main();
|
package/index.html
ADDED
package/index.js
ADDED
|
File without changes
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-ipro-microfront",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"start": "parcel index.html",
|
|
7
|
+
"build": "parcel build index.js",
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"description": "",
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"parcel-bundler": "^1.12.5"
|
|
15
|
+
},
|
|
16
|
+
"bin": {
|
|
17
|
+
"create-ipro-microfront": "./generate-app.js"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"rimraf": "^6.1.2"
|
|
21
|
+
}
|
|
22
|
+
}
|