@cerema/cadriciel 1.4.17 → 1.4.19

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
 
@@ -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/cli.js CHANGED
@@ -22,7 +22,31 @@ try {
22
22
  fs.unlinkSync(`${userHomeDir}/.cadriciel/account.json`);
23
23
  } catch (e) {}
24
24
 
25
+ const VERSION_CHECK_FILE = path.join(userHomeDir, '.cadriciel_last_check.json');
26
+
27
+ const shouldCheckVersion = async () => {
28
+ try {
29
+ const data = fs.readFileSync(VERSION_CHECK_FILE, 'utf8');
30
+ const lastCheck = JSON.parse(data);
31
+ const lastCheckDate = new Date(lastCheck.date);
32
+ const diff = Date.now() - lastCheckDate.getTime();
33
+ const twelveHours = 12 * 60 * 60 * 1000;
34
+
35
+ return diff > twelveHours;
36
+ } catch (e) {
37
+ return true;
38
+ }
39
+ };
40
+
41
+ const updateLastCheckDate = () => {
42
+ const data = JSON.stringify({ date: new Date() });
43
+ fs.writeFileSync(VERSION_CHECK_FILE, data, 'utf8');
44
+ };
45
+
25
46
  const checkVersion = async () => {
47
+ if (!(await shouldCheckVersion())) {
48
+ return Promise.resolve(null); // Aucune version à vérifier, renvoie null
49
+ }
26
50
  return new Promise((resolve, reject) => {
27
51
  const packageName = '@cerema/cadriciel';
28
52
  const child = spawn('npm', ['view', packageName, 'version'], {
@@ -35,12 +59,27 @@ const checkVersion = async () => {
35
59
  version += data.toString();
36
60
  });
37
61
 
62
+ child.stderr.on('data', (data) => {
63
+ console.error(`err: ${data}`);
64
+ });
65
+
66
+ child.on('error', (error) => {
67
+ console.error(`Erreur lors de l'exécution de npm view: ${error.message}`);
68
+ reject(error);
69
+ });
70
+
38
71
  child.on('close', (code) => {
39
72
  if (code !== 0) {
40
- return;
73
+ console.error(
74
+ `Le processus npm view s'est terminé avec le code ${code}`
75
+ );
76
+ return reject(
77
+ new Error('Erreur lors de la récupération de la version')
78
+ );
41
79
  }
42
80
 
43
81
  version = version.trim();
82
+ updateLastCheckDate();
44
83
  resolve(version);
45
84
  });
46
85
  });
@@ -258,13 +297,15 @@ const processCommands = (args) => {
258
297
  checkVersion()
259
298
  .then((version) => {
260
299
  const current_version = require(__dirname + '/package.json').version;
261
-
300
+ if (version === null) {
301
+ version = current_version;
302
+ }
262
303
  if (current_version != version) {
263
304
  const message =
264
305
  'Une nouvelle version (' +
265
306
  version +
266
307
  ') a été détectée. Veuillez mettre à jour.\n' +
267
- chalk.white.bold('npm i -g @cerema/cadriciel');
308
+ chalk.white.bold('npm i -g @cerema/cadriciel@' + version);
268
309
 
269
310
  // Options pour le cadre
270
311
  const boxenOptions = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cerema/cadriciel",
3
- "version": "1.4.17",
3
+ "version": "1.4.19",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "npm": ">=8.0.0",