create-proyect-cli 1.1.0 → 1.2.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/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/proyecto-cli.iml +9 -0
- package/.idea/vcs.xml +6 -0
- package/.idea/workspace.xml +42 -0
- package/index.js +53 -15
- package/package.json +1 -1
package/.idea/misc.xml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/proyecto-cli.iml" filepath="$PROJECT_DIR$/.idea/proyecto-cli.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="JAVA_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
+
<exclude-output />
|
|
5
|
+
<content url="file://$MODULE_DIR$" />
|
|
6
|
+
<orderEntry type="inheritedJdk" />
|
|
7
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
+
</component>
|
|
9
|
+
</module>
|
package/.idea/vcs.xml
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ChangeListManager">
|
|
4
|
+
<list default="true" id="93d8c761-14c3-4e66-a6c8-d6d7dd32ccbc" name="Changes" comment="" />
|
|
5
|
+
<option name="SHOW_DIALOG" value="false" />
|
|
6
|
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
|
7
|
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
|
8
|
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
|
9
|
+
</component>
|
|
10
|
+
<component name="Git.Settings">
|
|
11
|
+
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
|
12
|
+
</component>
|
|
13
|
+
<component name="MarkdownSettingsMigration">
|
|
14
|
+
<option name="stateVersion" value="1" />
|
|
15
|
+
</component>
|
|
16
|
+
<component name="ProjectColorInfo"><![CDATA[{
|
|
17
|
+
"associatedIndex": 2
|
|
18
|
+
}]]></component>
|
|
19
|
+
<component name="ProjectId" id="2YjKv1QmTTAAV7hcUdNJSCVbWTh" />
|
|
20
|
+
<component name="ProjectViewState">
|
|
21
|
+
<option name="hideEmptyMiddlePackages" value="true" />
|
|
22
|
+
<option name="showLibraryContents" value="true" />
|
|
23
|
+
</component>
|
|
24
|
+
<component name="PropertiesComponent"><![CDATA[{
|
|
25
|
+
"keyToString": {
|
|
26
|
+
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
|
27
|
+
"RunOnceActivity.ShowReadmeOnStart": "true",
|
|
28
|
+
"git-widget-placeholder": "Dev"
|
|
29
|
+
}
|
|
30
|
+
}]]></component>
|
|
31
|
+
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
|
32
|
+
<component name="TaskManager">
|
|
33
|
+
<task active="true" id="Default" summary="Default task">
|
|
34
|
+
<changelist id="93d8c761-14c3-4e66-a6c8-d6d7dd32ccbc" name="Changes" comment="" />
|
|
35
|
+
<created>1701033776269</created>
|
|
36
|
+
<option name="number" value="Default" />
|
|
37
|
+
<option name="presentableId" value="Default" />
|
|
38
|
+
<updated>1701033776269</updated>
|
|
39
|
+
</task>
|
|
40
|
+
<servers />
|
|
41
|
+
</component>
|
|
42
|
+
</project>
|
package/index.js
CHANGED
|
@@ -4,6 +4,8 @@ import { exec } from 'child_process';
|
|
|
4
4
|
import inquirer from 'inquirer';
|
|
5
5
|
import ora from 'ora';
|
|
6
6
|
import figlet from 'figlet';
|
|
7
|
+
import fs from 'fs'
|
|
8
|
+
import path from 'path';
|
|
7
9
|
|
|
8
10
|
// Función para clonar un repositorio
|
|
9
11
|
function cloneRepository(repoUrl, cloneLocation) {
|
|
@@ -23,10 +25,10 @@ function cloneRepository(repoUrl, cloneLocation) {
|
|
|
23
25
|
function installdependencias(location) {
|
|
24
26
|
const install = 'npm install';
|
|
25
27
|
const installSpinner = ora('Instalando Dependencias..').start();
|
|
26
|
-
exec(`cd ${location}`, (error, stdout, stderr)=>{
|
|
27
|
-
if(error){
|
|
28
|
+
exec(`cd ${location}`, (error, stdout, stderr) => {
|
|
29
|
+
if (error) {
|
|
28
30
|
installSpinner.fail(`Error al ingresar a la carpeta: ${stderr}`)
|
|
29
|
-
}else {
|
|
31
|
+
} else {
|
|
30
32
|
exec(install, (error, stdout, stderr) => {
|
|
31
33
|
if (error) {
|
|
32
34
|
installSpinner.fail(`Error al Instalar las dependecias: ${stderr}`);
|
|
@@ -40,16 +42,34 @@ function installdependencias(location) {
|
|
|
40
42
|
|
|
41
43
|
//Funcion para eliminar repo local
|
|
42
44
|
function deleterepo(location) {
|
|
43
|
-
const deleteRepo = `rm -rf ${location}`;
|
|
44
45
|
const deleteSpinner = ora('Eliminando Repositorio Local..').start();
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
|
|
47
|
+
if (fs.existsSync(location)) {
|
|
48
|
+
fs.readdirSync(location).forEach((archivo) => {
|
|
49
|
+
const archivoPath = path.join(location, archivo);
|
|
50
|
+
|
|
51
|
+
if (fs.lstatSync(archivoPath).isDirectory()) {
|
|
52
|
+
// Llamamos recursivamente a la función para eliminar el subdirectorio
|
|
53
|
+
deleterepo(archivoPath);
|
|
54
|
+
} else {
|
|
55
|
+
// Si es un archivo, lo eliminamos
|
|
56
|
+
fs.unlinkSync(archivoPath);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Finalmente, eliminamos el directorio
|
|
61
|
+
fs.rmdir(location, (error) => {
|
|
62
|
+
if (error) {
|
|
63
|
+
deleteSpinner.fail(`Error al Eliminar el repositorio: ${error}`);
|
|
64
|
+
} else {
|
|
65
|
+
deleteSpinner.succeed('Directorio eliminado correctamente.');
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
deleteSpinner.fail('El directorio no existe.');
|
|
70
|
+
}
|
|
52
71
|
}
|
|
72
|
+
|
|
53
73
|
// Función para crear un proyecto en Angular, React o Ionic
|
|
54
74
|
function createProject(projectType, projectName) {
|
|
55
75
|
let createCommand = '';
|
|
@@ -68,6 +88,10 @@ function createProject(projectType, projectName) {
|
|
|
68
88
|
createCommand = `npx ionic start ${projectName} blank`;
|
|
69
89
|
createSpinnerText = 'Creando proyecto Ionic...';
|
|
70
90
|
break;
|
|
91
|
+
case 'api-express':
|
|
92
|
+
createCommand = `git clone https://github.com/CARLOSMARES/api-express.git ${projectName}`;
|
|
93
|
+
createSpinnerText = 'Clonando API Express...';
|
|
94
|
+
break;
|
|
71
95
|
default:
|
|
72
96
|
console.error('Tipo de proyecto no reconocido.');
|
|
73
97
|
return;
|
|
@@ -84,6 +108,11 @@ function createProject(projectType, projectName) {
|
|
|
84
108
|
});
|
|
85
109
|
}
|
|
86
110
|
|
|
111
|
+
function createAPIExpress(proyectoname) {
|
|
112
|
+
projectType = "api-express";
|
|
113
|
+
createProject(projectType, proyectoname);
|
|
114
|
+
}
|
|
115
|
+
|
|
87
116
|
// Presentación del texto con Figlet
|
|
88
117
|
figlet('Create Project CLI', (err, data) => {
|
|
89
118
|
if (err) {
|
|
@@ -99,6 +128,12 @@ figlet('Create Project CLI', (err, data) => {
|
|
|
99
128
|
message: '¿Qué acción desea realizar?',
|
|
100
129
|
choices: ['Clonar repositorio', 'Crear proyecto', 'Instalar Dependencias', 'Eliminar Repositorio Local'],
|
|
101
130
|
},
|
|
131
|
+
{
|
|
132
|
+
type: 'input',
|
|
133
|
+
name: 'proyectoname',
|
|
134
|
+
message: 'Ingrese el nombre del proyecto:',
|
|
135
|
+
when: (answers) => answers.action === 'api-rest',
|
|
136
|
+
},
|
|
102
137
|
{
|
|
103
138
|
type: 'input',
|
|
104
139
|
name: 'repoUrl',
|
|
@@ -110,6 +145,7 @@ figlet('Create Project CLI', (err, data) => {
|
|
|
110
145
|
name: 'location',
|
|
111
146
|
message: 'Ingrese la URL del repositorio local:',
|
|
112
147
|
when: (answers) => answers.action === 'Eliminar Repositorio Local',
|
|
148
|
+
default: './',
|
|
113
149
|
},
|
|
114
150
|
{
|
|
115
151
|
type: 'input',
|
|
@@ -129,7 +165,7 @@ figlet('Create Project CLI', (err, data) => {
|
|
|
129
165
|
type: 'list',
|
|
130
166
|
name: 'projectType',
|
|
131
167
|
message: 'Seleccione el tipo de proyecto:',
|
|
132
|
-
choices: ['Angular', 'React', 'Ionic'],
|
|
168
|
+
choices: ['Angular', 'React', 'Ionic', `api-express`],
|
|
133
169
|
when: (answers) => answers.action === 'Crear proyecto',
|
|
134
170
|
},
|
|
135
171
|
{
|
|
@@ -145,10 +181,12 @@ figlet('Create Project CLI', (err, data) => {
|
|
|
145
181
|
cloneRepository(answers.repoUrl, answers.cloneLocation);
|
|
146
182
|
} else if (answers.action === 'Crear proyecto') {
|
|
147
183
|
createProject(answers.projectType, answers.projectName);
|
|
148
|
-
}else if (answers.action === 'Instalar Dependencias'){
|
|
184
|
+
} else if (answers.action === 'Instalar Dependencias') {
|
|
149
185
|
installdependencias(answers.location);
|
|
150
|
-
} else if(answers.action === 'Eliminar Repositorio Local'){
|
|
151
|
-
|
|
186
|
+
} else if (answers.action === 'Eliminar Repositorio Local') {
|
|
187
|
+
deleterepo(answers.location);
|
|
188
|
+
} else if (answers.action === 'api-express') {
|
|
189
|
+
createAPIExpress(answers.proyectoname);
|
|
152
190
|
}
|
|
153
191
|
});
|
|
154
192
|
});
|