@cerema/cadriciel 1.4.5 → 1.4.8
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/global/install.js +1 -2
- package/cli.js +52 -5
- package/package.json +1 -1
package/cli/global/install.js
CHANGED
|
@@ -89,8 +89,7 @@ module.exports = (args) => {
|
|
|
89
89
|
return {
|
|
90
90
|
info: {
|
|
91
91
|
title: 'install',
|
|
92
|
-
description:
|
|
93
|
-
'Installation des dépendances (La première fois uniquement).)',
|
|
92
|
+
description: 'Installation des dépendances (La première fois uniquement)',
|
|
94
93
|
},
|
|
95
94
|
start: () => {
|
|
96
95
|
addMapping();
|
package/cli.js
CHANGED
|
@@ -145,10 +145,44 @@ const display = (commands) => {
|
|
|
145
145
|
}
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
+
const displaySub = (commands) => {
|
|
149
|
+
const maxWidth = 30;
|
|
150
|
+
const maxDescriptionLength = 50;
|
|
151
|
+
|
|
152
|
+
for (let el in commands) {
|
|
153
|
+
let title = el;
|
|
154
|
+
|
|
155
|
+
if (commands[el].info) {
|
|
156
|
+
let description = commands[el].info.description;
|
|
157
|
+
console.log(' ' + chalk.bold(commands[el].info.title));
|
|
158
|
+
console.log(' ' + chalk.cyan(description));
|
|
159
|
+
console.log(' ');
|
|
160
|
+
|
|
161
|
+
for (let i = 0; i < commands[el].info.sub.length; i++) {
|
|
162
|
+
let sub = commands[el].info.sub[i];
|
|
163
|
+
const formattedDesc = formatDescription(
|
|
164
|
+
sub.description,
|
|
165
|
+
maxDescriptionLength
|
|
166
|
+
);
|
|
167
|
+
const dots = '.'.repeat(maxWidth - sub.title.length);
|
|
168
|
+
console.log(
|
|
169
|
+
' ' +
|
|
170
|
+
chalk.cyanBright(sub.title) +
|
|
171
|
+
' ' +
|
|
172
|
+
chalk.grey(dots) +
|
|
173
|
+
' ' +
|
|
174
|
+
label(sub.label) +
|
|
175
|
+
' ' +
|
|
176
|
+
chalk.white(formattedDesc)
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
148
183
|
const displayBanner = () => {
|
|
149
184
|
figlet('Cadriciel', function (err, data) {
|
|
150
185
|
if (err) {
|
|
151
|
-
console.log(err);
|
|
152
186
|
log.error('Something went wrong...');
|
|
153
187
|
return;
|
|
154
188
|
}
|
|
@@ -188,7 +222,7 @@ const displayBanner = () => {
|
|
|
188
222
|
display(CADRICIEL_COMMANDS);
|
|
189
223
|
console.log(' ');
|
|
190
224
|
}
|
|
191
|
-
console.log();
|
|
225
|
+
console.log(' ');
|
|
192
226
|
});
|
|
193
227
|
};
|
|
194
228
|
|
|
@@ -205,6 +239,9 @@ const processCommands = (args) => {
|
|
|
205
239
|
console.log(' ');
|
|
206
240
|
const cmd = `node`;
|
|
207
241
|
const fullArgs = [`${CADRICIEL_PATH}/${command}`, ...args.splice(1)];
|
|
242
|
+
const unit = require(`${CADRICIEL_PATH}/../cli/${args[0]}`)();
|
|
243
|
+
|
|
244
|
+
if (unit.info.sub) return displaySub({ unit });
|
|
208
245
|
|
|
209
246
|
const child = spawn(cmd, fullArgs, {
|
|
210
247
|
stdio: 'inherit',
|
|
@@ -241,12 +278,22 @@ checkVersion()
|
|
|
241
278
|
|
|
242
279
|
console.log(framedMessage);
|
|
243
280
|
loadGlobalCommands();
|
|
244
|
-
|
|
245
|
-
|
|
281
|
+
process.argv.shift();
|
|
282
|
+
process.argv.shift();
|
|
283
|
+
if (process.argv.length <= 0) return displayBanner();
|
|
284
|
+
processCommands(process.argv);
|
|
285
|
+
} else {
|
|
286
|
+
loadGlobalCommands();
|
|
287
|
+
process.argv.shift();
|
|
288
|
+
process.argv.shift();
|
|
289
|
+
if (process.argv.length <= 0) return displayBanner();
|
|
290
|
+
processCommands(process.argv);
|
|
246
291
|
}
|
|
247
292
|
})
|
|
248
293
|
.catch((error) => {
|
|
249
294
|
loadGlobalCommands();
|
|
250
|
-
|
|
295
|
+
process.argv.shift();
|
|
296
|
+
process.argv.shift();
|
|
251
297
|
if (process.argv.length <= 2) return displayBanner();
|
|
298
|
+
processCommands(process.argv.splice(2));
|
|
252
299
|
});
|