@cerema/cadriciel 1.4.2 → 1.4.4

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.
@@ -13,6 +13,7 @@ module.exports = (args) => {
13
13
  const log = require('log-beautify');
14
14
  const isBinary = require('isbinaryfile').isBinaryFile;
15
15
  const userHomeDir = os.homedir();
16
+ var sep = path.sep;
16
17
  const {
17
18
  capitalizeFirstLetter,
18
19
  getAccount,
@@ -34,17 +35,21 @@ module.exports = (args) => {
34
35
  };
35
36
 
36
37
  const download = async (name, cb) => {
37
- const CadricielAPI = require('../../lib/cadriciel');
38
+ const CadricielAPI = require(path.join('..', '..', 'lib', 'cadriciel'));
38
39
  const cadriciel = new CadricielAPI();
39
40
  await cadriciel.downloadFile(
40
41
  '/template?key=' + name + '.zip',
41
- `${os.tmpdir()}/${name}.zip`
42
+ `${os.tmpdir()}${sep}${name}.zip`
42
43
  );
43
44
 
44
- unzipFile(`${os.tmpdir()}/${name}.zip`, `${os.tmpdir()}/${UID}`, () => {
45
- DEFAULT_TEMPLATE = name;
46
- fs.unlink(`${os.tmpdir()}/${name}.zip`, cb);
47
- });
45
+ unzipFile(
46
+ `${os.tmpdir()}${sep}${name}.zip`,
47
+ `${os.tmpdir()}${sep}${UID}`,
48
+ () => {
49
+ DEFAULT_TEMPLATE = name;
50
+ fs.unlink(`${os.tmpdir()}${sep}${name}.zip`, cb);
51
+ }
52
+ );
48
53
  };
49
54
 
50
55
  const changefs = (o, files, ndx, cb) => {
@@ -68,8 +73,8 @@ module.exports = (args) => {
68
73
  text = text.replace(/§§pgadmin_password§§/g, o.pgadmin_password);
69
74
  var output =
70
75
  OUTPUT_DIRECTORY +
71
- '/' +
72
- input.split(UID + '/')[1].replace(/§§project§§/g, o.project);
76
+ sep +
77
+ input.split(UID + sep)[1].replace(/§§project§§/g, o.project);
73
78
  var dir = require('path').dirname(output);
74
79
  fs.mkdirSync(dir, { recursive: true });
75
80
  fs.writeFileSync(output, text);
@@ -79,8 +84,8 @@ module.exports = (args) => {
79
84
  return changefs(o, files, ndx + 1, cb);
80
85
  var output =
81
86
  OUTPUT_DIRECTORY +
82
- '/' +
83
- input.split(UID + '/')[1].replace(/§§project§§/g, o.project);
87
+ sep +
88
+ input.split(UID + sep)[1].replace(/§§project§§/g, o.project);
84
89
  var dir = require('path').dirname(output);
85
90
  fs.mkdirSync(dir, { recursive: true });
86
91
  fs.copyFileSync(input, output);
@@ -144,8 +149,9 @@ module.exports = (args) => {
144
149
  spinner.succeed(
145
150
  '🚀 Votre projet a été correctement installé.\n'
146
151
  );
147
- console.log(
148
- `\n──────────────────────────────────────────────────────────────
152
+ console.log(' ');
153
+ console.log(`
154
+ ──────────────────────────────────────────────────────────────
149
155
 
150
156
  Pour lancer l'environnement local de développement :
151
157
 
@@ -153,17 +159,17 @@ module.exports = (args) => {
153
159
 
154
160
  cd ${chalk.green(name)}
155
161
  ${chalk.cyan('cad start')} .............. 🚀 ${chalk.bold(
156
- "démarre l'environnement local de développement"
157
- )}
162
+ "démarre l'environnement de développement"
163
+ )}
158
164
 
159
165
  ${chalk.cyan('cad stop')} ............... 🚦 ${chalk.bold(
160
- "arrête l'environnement."
161
- )}
166
+ "arrête l'environnement."
167
+ )}
162
168
 
163
- 👉 https://cadriciel.k8-dev.cerema.fr/api 👈
169
+ 👉 https://cadriciel.k8-dev.cerema.fr/api 👈);
164
170
 
165
- ──────────────────────────────────────────────────────────────\n`
166
- );
171
+ ──────────────────────────────────────────────────────────────`);
172
+ console.log(' ');
167
173
  }
168
174
  );
169
175
  });
@@ -187,8 +193,10 @@ module.exports = (args) => {
187
193
  }
188
194
 
189
195
  spinner.succeed('🚀 Votre projet a été correctement installé.\n');
196
+ console.log(' ');
190
197
  console.log(
191
- `\n──────────────────────────────────────────────────────────────
198
+ `
199
+ ──────────────────────────────────────────────────────────────
192
200
 
193
201
  Pour lancer l'environnement local de développement :
194
202
 
@@ -200,7 +208,7 @@ module.exports = (args) => {
200
208
  ${chalk.cyan(
201
209
  'cad start'
202
210
  )} .............. 🚀 ${chalk.bold(
203
- "démarre l'environnement local de développement"
211
+ "démarre l'environnement de développement"
204
212
  )}
205
213
 
206
214
  ${chalk.cyan(
@@ -53,6 +53,7 @@ module.exports = (args) => {
53
53
  const response = await prompts({
54
54
  type: 'confirm',
55
55
  name: 'code',
56
+ initial: true,
56
57
  message: 'Ouvrir le navigateur et se connecter à ORION',
57
58
  });
58
59
 
@@ -148,17 +149,14 @@ module.exports = (args) => {
148
149
  });
149
150
 
150
151
  // Ouvrez le navigateur vers l'URL d'authentification
151
- switch (process.platform) {
152
- case 'darwin':
153
- exec(`open "${authUrl}"`);
154
- break;
155
- case 'win32':
156
- exec(`start "${authUrl}"`);
157
- break;
158
- default:
159
- exec(`xdg-open "${authUrl}"`);
160
- break;
161
- }
152
+ var start =
153
+ process.platform == 'darwin'
154
+ ? 'open'
155
+ : process.platform == 'win32'
156
+ ? 'start "" '
157
+ : 'xdg-open';
158
+
159
+ require('child_process').exec(start + ' "' + authUrl + '"');
162
160
  });
163
161
  };
164
162
  axios
package/cli.js CHANGED
@@ -129,9 +129,19 @@ const displayBanner = () => {
129
129
  log.error('Something went wrong...');
130
130
  return;
131
131
  }
132
+ try {
133
+ let info = require(CADRICIEL_PATH + '/version.json');
134
+ version_cadriciel =
135
+ ` - ${chalk.green('Cadriciel v')} ` +
136
+ chalk.green.bold(info.version) +
137
+ chalk.green(' (' + info.name + ')');
138
+ } catch (e) {
139
+ version_cadriciel = '';
140
+ }
132
141
  console.log(
133
142
  chalk.cyan(data) +
134
- chalk.bold('\n CLI v' + require('./package.json').version)
143
+ chalk.bold('\n CLI v ' + require('./package.json').version) +
144
+ version_cadriciel
135
145
  );
136
146
  console.log(' ');
137
147
  console.log(
@@ -144,6 +154,7 @@ const displayBanner = () => {
144
154
  console.log(' ');
145
155
  display(CADRICIEL_GLOBAL_COMMANDS);
146
156
  console.log(' ');
157
+
147
158
  console.log(chalk.bold(' Commandes du projet :'));
148
159
  if (!CADRICIEL_PATH) {
149
160
  console.log(`\n Vous n'êtes pas à l'intérieur d'un projet. `);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cerema/cadriciel",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "npm": ">=8.0.0",