@cerema/cadriciel 1.2.1 → 1.2.3
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.
- package/cli/cadriciel/project.js +1 -1
- package/cli/global/install.js +20 -0
- package/cli.js +13 -16
- package/package.json +1 -1
package/cli/cadriciel/project.js
CHANGED
package/cli/global/install.js
CHANGED
|
@@ -1,7 +1,26 @@
|
|
|
1
1
|
module.exports = (args) => {
|
|
2
2
|
const chalk = require('chalk-v2');
|
|
3
3
|
const ora = require('ora');
|
|
4
|
+
const fs = require('fs');
|
|
4
5
|
const { spawn } = require('child_process');
|
|
6
|
+
const HOSTS_PATH = '/etc/hosts';
|
|
7
|
+
const MAPPING_ENTRY = '127.0.0.1 keycloak';
|
|
8
|
+
|
|
9
|
+
function addMapping() {
|
|
10
|
+
const hostsContent = fs.readFileSync(HOSTS_PATH, 'utf8');
|
|
11
|
+
if (!hostsContent.includes(MAPPING_ENTRY)) {
|
|
12
|
+
try {
|
|
13
|
+
fs.appendFileSync(HOSTS_PATH, os.EOL + MAPPING_ENTRY);
|
|
14
|
+
} catch (e) {
|
|
15
|
+
console.error(
|
|
16
|
+
chalk.red.bold(
|
|
17
|
+
"\nVous devez lancer la commande en tant qu'administrateur.\n"
|
|
18
|
+
)
|
|
19
|
+
);
|
|
20
|
+
return process.exit(0);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
5
24
|
|
|
6
25
|
const checkIfCommandExists = (command, callback) => {
|
|
7
26
|
const proc = spawn('which', [command]);
|
|
@@ -72,6 +91,7 @@ module.exports = (args) => {
|
|
|
72
91
|
description: 'Installation des dépendances',
|
|
73
92
|
},
|
|
74
93
|
start: () => {
|
|
94
|
+
addMapping();
|
|
75
95
|
const dockerImagesToInstall = [
|
|
76
96
|
'postgres:15',
|
|
77
97
|
'cerema/cadriciel:1.0.0',
|
package/cli.js
CHANGED
|
@@ -4,7 +4,7 @@ const chalk = require('chalk-v2');
|
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
const log = require('log-beautify');
|
|
6
6
|
const path = require('path');
|
|
7
|
-
const {
|
|
7
|
+
const { spawn } = require('child_process');
|
|
8
8
|
|
|
9
9
|
const CADRICIEL_PATH = findCadricielDir(process.cwd());
|
|
10
10
|
const CADRICIEL_COMMAND =
|
|
@@ -86,10 +86,10 @@ const display = (commands) => {
|
|
|
86
86
|
for (let i = 0; i < commands[el].info.sub.length; i++) {
|
|
87
87
|
sc.push(commands[el].info.sub[i].title);
|
|
88
88
|
}
|
|
89
|
-
description +=
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
description += chalk.white(' ');
|
|
90
|
+
description += chalk.grey(' (subcommands: ');
|
|
91
|
+
description += chalk.cyan(sc.join(', '));
|
|
92
|
+
description += chalk.grey(')');
|
|
93
93
|
}
|
|
94
94
|
const dots = '.'.repeat(maxWidth - title.length);
|
|
95
95
|
|
|
@@ -156,18 +156,15 @@ const processCommands = (args) => {
|
|
|
156
156
|
}
|
|
157
157
|
CADRICIEL_GLOBAL_COMMANDS[command].start(args);
|
|
158
158
|
} else {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (stderr) {
|
|
166
|
-
console.error(`Erreur: ${stderr}`);
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
console.log(stdout);
|
|
159
|
+
console.log(' ');
|
|
160
|
+
const cmd = `node`;
|
|
161
|
+
const fullArgs = [`${CADRICIEL_PATH}/${command}`, ...args.splice(1)];
|
|
162
|
+
|
|
163
|
+
const child = spawn(cmd, fullArgs, {
|
|
164
|
+
stdio: 'inherit',
|
|
170
165
|
});
|
|
166
|
+
|
|
167
|
+
child.on('close', (code) => {});
|
|
171
168
|
}
|
|
172
169
|
};
|
|
173
170
|
|