@cerema/cadriciel 1.4.19 β†’ 1.4.21

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.
@@ -14,6 +14,7 @@ module.exports = (args) => {
14
14
  const isBinary = require('isbinaryfile').isBinaryFile;
15
15
  const userHomeDir = os.homedir();
16
16
  var sep = path.sep;
17
+ var templates = [];
17
18
  const {
18
19
  capitalizeFirstLetter,
19
20
  getAccount,
@@ -34,6 +35,19 @@ module.exports = (args) => {
34
35
  }
35
36
  };
36
37
 
38
+ const link = (url, name) => {
39
+ if (!name) name = url;
40
+ if (url.includes('localhost')) url = 'http://' + url + '/';
41
+ else url = 'https://' + url + '/';
42
+ return (
43
+ '\u001b[36m\u001b]8;;' +
44
+ url +
45
+ '\u0007' +
46
+ name +
47
+ '\u001b]8;;\u0007\u001b[0m\n'
48
+ );
49
+ };
50
+
37
51
  const download = async (name, cb) => {
38
52
  const CadricielAPI = require(path.join('..', '..', 'lib', 'cadriciel'));
39
53
  const cadriciel = new CadricielAPI();
@@ -136,7 +150,7 @@ module.exports = (args) => {
136
150
  }
137
151
 
138
152
  exec(
139
- 'git init && git add --all && git commit -m "first commit" && git checkout -b dev',
153
+ 'git init && git add --all && git commit -m "first commit [ci skip]" && git checkout -b dev',
140
154
  (errorGit) => {
141
155
  if (errorGit) {
142
156
  spinner.fail(
@@ -166,7 +180,10 @@ module.exports = (args) => {
166
180
  "arrΓͺte l'environnement."
167
181
  )}
168
182
 
169
- πŸ‘‰ https://cadriciel.k8-dev.cerema.fr/api πŸ‘ˆ);
183
+ πŸ‘‰ ${link(
184
+ 'https://studio.k8-dev.cerema.fr',
185
+ 'studio.k8-dev.cerema.fr'
186
+ )}
170
187
 
171
188
  ──────────────────────────────────────────────────────────────`);
172
189
  console.log(' ');
@@ -185,7 +202,7 @@ module.exports = (args) => {
185
202
  }
186
203
 
187
204
  exec(
188
- 'git init && git add --all && git commit -m "first commit" && git checkout -b dev',
205
+ 'git init && git add --all && git commit -m "first commit [ci skip]" && git checkout -b dev',
189
206
  (errorGit) => {
190
207
  if (errorGit) {
191
208
  spinner.fail('Error occurred during git operations:', errorGit);
@@ -217,7 +234,10 @@ module.exports = (args) => {
217
234
  "arrΓͺte l'environnement."
218
235
  )}
219
236
 
220
- πŸ‘‰ https://cadriciel.k8-dev.cerema.fr/api πŸ‘ˆ
237
+ πŸ‘‰ ${link(
238
+ 'studio.k8-dev.cerema.fr',
239
+ 'studio.k8-dev.cerema.fr'
240
+ )}
221
241
 
222
242
  ──────────────────────────────────────────────────────────────\n`
223
243
  );
@@ -229,8 +249,8 @@ module.exports = (args) => {
229
249
  };
230
250
 
231
251
  const createProject = async (o) => {
232
- const account = await getAccount();
233
252
  var spinner = ora('TΓ©lΓ©chargement du cadriciel').start();
253
+ const account = await getAccount();
234
254
 
235
255
  return download(o.template.dir, function () {
236
256
  spinner.succeed();
@@ -253,19 +273,48 @@ module.exports = (args) => {
253
273
  });
254
274
  };
255
275
 
276
+ const toCamelCase = (str) => {
277
+ return (
278
+ str
279
+ // Remplacez tout caractère non-alphanumérique par un espace
280
+ .replace(/[^a-zA-Z0-9]+/g, ' ')
281
+ // Supprimez les espaces ou autres caractères non alphanumériques au début ou à la fin
282
+ .trim()
283
+ // Convertissez la première lettre de chaque mot en majuscule, sauf pour le premier mot
284
+ .replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) =>
285
+ index === 0 ? word.toLowerCase() : word.toUpperCase()
286
+ )
287
+ // Supprimez les espaces
288
+ .replace(/\s+/g, '')
289
+ );
290
+ };
291
+
292
+ const launch = (response) => {
293
+ response.project = toCamelCase(response.project);
294
+ var index = templates.findIndex((p) => p.title == response.template);
295
+ response.template = templates[index];
296
+
297
+ try {
298
+ var stat = fs.statSync(process.cwd() + '/' + response.project);
299
+ return log.error('Ce projet existe dΓ©jΓ  !');
300
+ } catch (e) {}
301
+
302
+ OUTPUT_DIRECTORY = `${process.cwd()}`;
303
+ createProject(response);
304
+ };
305
+
256
306
  return {
257
307
  info: {
258
308
  title: 'completion',
259
309
  description: `DΓ©marrage d'un projet Cadriciel`,
260
310
  },
261
311
  start: async () => {
262
- const templates = await getTemplates();
312
+ const spinner = ora('Veuillez patienter un instant...').start();
313
+ templates = await getTemplates();
314
+ spinner.stop();
263
315
  var tpl = [];
264
316
  if (!templates) return process.exit(1);
265
317
  for (let i = 0; i < templates.length; i++) tpl.push(templates[i].title);
266
- console.log(
267
- '\nπŸ˜ƒ ' + chalk.bold('Tout grand projet commence par un nom !\n')
268
- );
269
318
 
270
319
  const questions = [
271
320
  {
@@ -284,20 +333,18 @@ module.exports = (args) => {
284
333
  choices: tpl,
285
334
  },
286
335
  ];
336
+
337
+ if (tpl.length == 1) questions.splice(1, 1);
338
+ if (process.argv[1]) {
339
+ if (questions.length == 1)
340
+ return launch({ project: process.argv[1], template: tpl[0] });
341
+ }
342
+ console.log(
343
+ '\nπŸ˜ƒ ' + chalk.bold('Tout grand projet commence par un nom !\n')
344
+ );
287
345
  inquirer
288
346
  .prompt(questions)
289
- .then((response) => {
290
- response.project = response.project.replace(/[^a-zA-Z0-9]/g, '');
291
- var index = templates.findIndex((p) => p.title == response.template);
292
- response.template = templates[index];
293
- try {
294
- var stat = fs.statSync(process.cwd() + '/' + response.project);
295
- return log.error('Ce projet existe dΓ©jΓ  !');
296
- } catch (e) {}
297
-
298
- OUTPUT_DIRECTORY = `${process.cwd()}`;
299
- createProject(response);
300
- })
347
+ .then(launch)
301
348
  .catch((error) => {
302
349
  log.error(error);
303
350
  });
@@ -77,7 +77,7 @@ module.exports = (args) => {
77
77
  },
78
78
  start: () => {
79
79
  const dockerImagesToInstall = [
80
- 'postgis/postgis',
80
+ 'cerema/postgres',
81
81
  'dpage/pgadmin4',
82
82
  'inbucket/inbucket:latest',
83
83
  'quay.io/keycloak/keycloak:legacy',
package/lib/util.js CHANGED
@@ -37,7 +37,6 @@ const getTemplates = async () => {
37
37
  const o = await cadriciel.get('/update');
38
38
  return o;
39
39
  } catch (e) {
40
- console.log(e);
41
40
  log.error("Vous n'Γͺtes pas authentifiΓ©.");
42
41
  }
43
42
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cerema/cadriciel",
3
- "version": "1.4.19",
3
+ "version": "1.4.21",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "npm": ">=8.0.0",