@cerema/cadriciel 1.4.18 β†’ 1.4.20

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.
@@ -5,7 +5,7 @@
5
5
  <meta charset="UTF-8">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
7
  <title>Cadriciel</title>
8
- <link rel="stylesheet" type="text/css" href="http://127.0.0.1:4200/index.css">
8
+ <link rel="stylesheet" type="text/css" href="/index.css">
9
9
  </link>
10
10
  </head>
11
11
 
@@ -16,13 +16,13 @@
16
16
 
17
17
 
18
18
  <div style="position:absolute;bottom:0px;right:0px;">
19
- <img src="http://127.0.0.1:4200/nono.png" width="300px" height="300px">
19
+ <img src="/nono.png" width="300px" height="300px">
20
20
  </div>
21
21
  <div
22
- style="position:absolute;top:30px;left:0px;background-image:url(http://127.0.0.1:4200/cerema.jpeg);background-position:center;background-repeat:no-repeat;background-size:contain;width:100%;height:150px">
22
+ style="position:absolute;top:30px;left:0px;background-image:url(/cerema.jpeg);background-position:center;background-repeat:no-repeat;background-size:contain;width:100%;height:150px">
23
23
  </div>
24
24
  <div
25
- style="position:absolute;top:150px;left:30px;background-image:url(http://127.0.0.1:4200/logo.png);background-position:center;background-repeat:no-repeat;background-size:contain;width:100%;height:100px">
25
+ style="position:absolute;top:150px;left:30px;background-image:url(/logo.png);background-position:center;background-repeat:no-repeat;background-size:contain;width:100%;height:100px">
26
26
  </div>
27
27
  </body>
28
28
 
@@ -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,
@@ -136,7 +137,7 @@ module.exports = (args) => {
136
137
  }
137
138
 
138
139
  exec(
139
- 'git init && git add --all && git commit -m "first commit" && git checkout -b dev',
140
+ 'git init && git add --all && git commit -m "first commit [ci skip]" && git checkout -b dev',
140
141
  (errorGit) => {
141
142
  if (errorGit) {
142
143
  spinner.fail(
@@ -166,7 +167,7 @@ module.exports = (args) => {
166
167
  "arrΓͺte l'environnement."
167
168
  )}
168
169
 
169
- πŸ‘‰ https://cadriciel.k8-dev.cerema.fr/api πŸ‘ˆ);
170
+ πŸ‘‰ https://studio.k8-dev.cerema.fr πŸ‘ˆ);
170
171
 
171
172
  ──────────────────────────────────────────────────────────────`);
172
173
  console.log(' ');
@@ -185,7 +186,7 @@ module.exports = (args) => {
185
186
  }
186
187
 
187
188
  exec(
188
- 'git init && git add --all && git commit -m "first commit" && git checkout -b dev',
189
+ 'git init && git add --all && git commit -m "first commit [ci skip]" && git checkout -b dev',
189
190
  (errorGit) => {
190
191
  if (errorGit) {
191
192
  spinner.fail('Error occurred during git operations:', errorGit);
@@ -217,7 +218,7 @@ module.exports = (args) => {
217
218
  "arrΓͺte l'environnement."
218
219
  )}
219
220
 
220
- πŸ‘‰ https://cadriciel.k8-dev.cerema.fr/api πŸ‘ˆ
221
+ πŸ‘‰ https://studio.k8-dev.cerema.fr πŸ‘ˆ
221
222
 
222
223
  ──────────────────────────────────────────────────────────────\n`
223
224
  );
@@ -229,8 +230,8 @@ module.exports = (args) => {
229
230
  };
230
231
 
231
232
  const createProject = async (o) => {
232
- const account = await getAccount();
233
233
  var spinner = ora('TΓ©lΓ©chargement du cadriciel').start();
234
+ const account = await getAccount();
234
235
 
235
236
  return download(o.template.dir, function () {
236
237
  spinner.succeed();
@@ -253,19 +254,48 @@ module.exports = (args) => {
253
254
  });
254
255
  };
255
256
 
257
+ const toCamelCase = (str) => {
258
+ return (
259
+ str
260
+ // Remplacez tout caractère non-alphanumérique par un espace
261
+ .replace(/[^a-zA-Z0-9]+/g, ' ')
262
+ // Supprimez les espaces ou autres caractères non alphanumériques au début ou à la fin
263
+ .trim()
264
+ // Convertissez la première lettre de chaque mot en majuscule, sauf pour le premier mot
265
+ .replace(/(?:^\w|[A-Z]|\b\w)/g, (word, index) =>
266
+ index === 0 ? word.toLowerCase() : word.toUpperCase()
267
+ )
268
+ // Supprimez les espaces
269
+ .replace(/\s+/g, '')
270
+ );
271
+ };
272
+
273
+ const launch = (response) => {
274
+ response.project = toCamelCase(response.project);
275
+ var index = templates.findIndex((p) => p.title == response.template);
276
+ response.template = templates[index];
277
+
278
+ try {
279
+ var stat = fs.statSync(process.cwd() + '/' + response.project);
280
+ return log.error('Ce projet existe dΓ©jΓ  !');
281
+ } catch (e) {}
282
+
283
+ OUTPUT_DIRECTORY = `${process.cwd()}`;
284
+ createProject(response);
285
+ };
286
+
256
287
  return {
257
288
  info: {
258
289
  title: 'completion',
259
290
  description: `DΓ©marrage d'un projet Cadriciel`,
260
291
  },
261
292
  start: async () => {
262
- const templates = await getTemplates();
293
+ const spinner = ora('Veuillez patienter un instant...').start();
294
+ templates = await getTemplates();
295
+ spinner.stop();
263
296
  var tpl = [];
264
297
  if (!templates) return process.exit(1);
265
298
  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
299
 
270
300
  const questions = [
271
301
  {
@@ -284,20 +314,18 @@ module.exports = (args) => {
284
314
  choices: tpl,
285
315
  },
286
316
  ];
317
+
318
+ if (tpl.length == 1) questions.splice(1, 1);
319
+ if (process.argv[1]) {
320
+ if (questions.length == 1)
321
+ return launch({ project: process.argv[1], template: tpl[0] });
322
+ }
323
+ console.log(
324
+ '\nπŸ˜ƒ ' + chalk.bold('Tout grand projet commence par un nom !\n')
325
+ );
287
326
  inquirer
288
327
  .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
- })
328
+ .then(launch)
301
329
  .catch((error) => {
302
330
  log.error(error);
303
331
  });
@@ -4,24 +4,6 @@ module.exports = (args) => {
4
4
  const os = require('os');
5
5
  const fs = require('fs');
6
6
  const { spawn } = require('child_process');
7
- const HOSTS_PATH = '/etc/hosts';
8
- const MAPPING_ENTRY = '127.0.0.1 keycloak';
9
-
10
- function addMapping() {
11
- try {
12
- const hostsContent = fs.readFileSync(HOSTS_PATH, 'utf8');
13
- if (!hostsContent.includes(MAPPING_ENTRY)) {
14
- fs.appendFileSync(HOSTS_PATH, os.EOL + MAPPING_ENTRY);
15
- }
16
- } catch (e) {
17
- console.error(
18
- chalk.red.bold(
19
- "\nVous devez lancer la commande en tant qu'administrateur.\n"
20
- )
21
- );
22
- return process.exit(0);
23
- }
24
- }
25
7
 
26
8
  const checkIfCommandExists = (command, callback) => {
27
9
  const proc = spawn('which', [command], { shell: true });
@@ -94,7 +76,6 @@ module.exports = (args) => {
94
76
  description: 'Installation des images Docker',
95
77
  },
96
78
  start: () => {
97
- addMapping();
98
79
  const dockerImagesToInstall = [
99
80
  'postgis/postgis',
100
81
  'dpage/pgadmin4',
@@ -20,9 +20,6 @@ module.exports = (args) => {
20
20
  const PORT = 14211;
21
21
  const CLIENT_ID = 'cadriciel_login';
22
22
 
23
- //const KEYCLOAK_SERVER = 'https://orion-recette.cerema.fr';
24
- //const PORT = 4200;
25
- //const CLIENT_ID = 'marep_dev';
26
23
  const REDIRECT_URI = 'http://localhost:' + PORT + '/login';
27
24
 
28
25
  const INDEX_HTML = fs.readFileSync(
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.18",
3
+ "version": "1.4.20",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "npm": ">=8.0.0",