@cerema/cadriciel 1.2.7 → 1.2.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.
Files changed (2) hide show
  1. package/cli/global/init.js +85 -28
  2. package/package.json +1 -1
@@ -5,6 +5,7 @@ module.exports = (args) => {
5
5
  const path = require('path');
6
6
  const AdmZip = require('adm-zip');
7
7
  const ora = require('ora');
8
+ const { exec } = require('child_process');
8
9
  const os = require('os');
9
10
  const recursive = require('recursive-readdir');
10
11
  const fs = require('fs');
@@ -83,6 +84,89 @@ module.exports = (args) => {
83
84
  });
84
85
  };
85
86
 
87
+ const install_dependencies = (name) => {
88
+ console.log(' ');
89
+ const spinner = ora('Installation des dépendances ☕').start();
90
+ const projectPath = `${process.cwd()}/${name}`;
91
+
92
+ // Check if directory exists
93
+ if (!fs.existsSync(projectPath)) {
94
+ spinner.fail(`Le répertoire ${projectPath} n'existe pas !`);
95
+ return;
96
+ }
97
+
98
+ // Change to the directory
99
+ process.chdir(projectPath);
100
+
101
+ // Check if git and pnpm are installed
102
+ exec('git --version', (errorGit) => {
103
+ if (errorGit) {
104
+ spinner.fail(`git n'est pas installé sur votre système !`);
105
+ return;
106
+ }
107
+
108
+ exec('pnpm -v', (errorPnpm) => {
109
+ if (errorPnpm) {
110
+ spinner.fail(
111
+ `pnpm n'est pas installé sur votre système ! (https://pnpm.js.org/installation)`
112
+ );
113
+ return;
114
+ }
115
+
116
+ // If git and pnpm are installed, proceed with the operations
117
+ exec('pnpm i', (errorInstall) => {
118
+ if (errorInstall) {
119
+ spinner.fail(
120
+ `Problème pendant l'installation des dépendances :\n`,
121
+ errorInstall
122
+ );
123
+ return;
124
+ }
125
+
126
+ exec(
127
+ 'git init && git add --all && git commit -m "first commit"',
128
+ (errorGit) => {
129
+ if (errorGit) {
130
+ spinner.fail('Error occurred during git operations:', errorGit);
131
+ return;
132
+ }
133
+
134
+ spinner.succeed('🚀 Votre projet a été correctement installé.\n');
135
+ console.log(
136
+ '\n______________________________________________________________'
137
+ );
138
+ console.log(chalk.bold('Prochaines étapes :'));
139
+ console.log(' ');
140
+ console.log('cd ' + name);
141
+ console.log(
142
+ chalk.bold(
143
+ "Pour lancer l'environnement local de développement :"
144
+ )
145
+ );
146
+ console.log(
147
+ chalk.green('✳️ nécessite docker et docker-compose\n')
148
+ );
149
+ console.log('cad start');
150
+ console.log('---\n');
151
+ console.log(
152
+ chalk.bold(
153
+ "Pour arrêter l'environnement local de développement :\n"
154
+ )
155
+ );
156
+ console.log('cad stop');
157
+ console.log('---\n');
158
+ console.log(chalk.bold('Pour lancer le projet :\n'));
159
+ console.log('cad dev\n');
160
+ console.log(
161
+ '______________________________________________________________'
162
+ );
163
+ }
164
+ );
165
+ });
166
+ });
167
+ });
168
+ };
169
+
86
170
  const createProject = async (o) => {
87
171
  const account = await getAccount();
88
172
  var spinner = ora('Téléchargement du cadriciel').start();
@@ -101,34 +185,7 @@ module.exports = (args) => {
101
185
  JSON.stringify(o)
102
186
  );
103
187
  spinner.succeed(`projet ${o.project} crée avec succès.`);
104
- console.log(' ');
105
- console.log(
106
- '______________________________________________________________'
107
- );
108
- console.log(chalk.bold('Prochaines étapes :'));
109
- console.log(' ');
110
- console.log('cd ' + o.project);
111
- console.log('npm i ' + '(ou yarn)');
112
- console.log(' ');
113
- console.log(
114
- chalk.bold("Pour lancer l'environnement local de développement :")
115
- );
116
- console.log(chalk.green('✳️ nécessite docker et docker-compose\n'));
117
- console.log('npm run start (ou yarn start)');
118
- console.log('---\n');
119
- console.log(
120
- chalk.bold(
121
- "Pour arrêter l'environnement local de développement :\n"
122
- )
123
- );
124
- console.log('npm run stop (ou yarn stop)');
125
- console.log('---\n');
126
- console.log(chalk.bold('Pour lancer le projet :\n'));
127
- console.log('npm run dev (or yarn dev)\n');
128
- console.log(
129
- '______________________________________________________________'
130
- );
131
- console.log('\n🚀 Happy coding !\n');
188
+ install_dependencies(o.project);
132
189
  });
133
190
  });
134
191
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cerema/cadriciel",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "npm": ">=8.0.0",