@cerema/cadriciel 1.4.30 → 1.4.32
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/init.js +1 -1
- package/cli/global/load.js +1 -1
- package/cli/global/upgrade.js +89 -0
- package/cli.js +40 -36
- package/package.json +2 -1
package/cli/global/init.js
CHANGED
|
@@ -128,7 +128,7 @@ Host cadriciel
|
|
|
128
128
|
|
|
129
129
|
try {
|
|
130
130
|
await execPromise(
|
|
131
|
-
`git config --local user.email "${response.prj.owner.email}" && git config --local user.name "${response.prj.owner.name}" && git add --all && git checkout -b ${response.prj.owner.trigram}`,
|
|
131
|
+
`git config --local user.email "${response.prj.owner.email}" && git config --local user.name "${response.prj.owner.name}" && git add --all && git checkout -b ${response.prj.owner.trigram} && git config pull.rebase true`,
|
|
132
132
|
{
|
|
133
133
|
cwd: process.cwd() + '/' + response.prj.title,
|
|
134
134
|
}
|
package/cli/global/load.js
CHANGED
|
@@ -91,7 +91,7 @@ Host cadriciel
|
|
|
91
91
|
.replace('.git', '');
|
|
92
92
|
try {
|
|
93
93
|
await execPromise(
|
|
94
|
-
`git config --local user.email "${user.info.email}" && git config --local user.name "${user.info.name}" && git add --all && git checkout -b ${user.trigram}`,
|
|
94
|
+
`git config --local user.email "${user.info.email}" && git config --local user.name "${user.info.name}" && git add --all && git checkout -b ${user.trigram} && git config pull.rebase true`,
|
|
95
95
|
{
|
|
96
96
|
cwd: process.cwd() + '/' + title,
|
|
97
97
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
const ora = require('ora');
|
|
2
|
+
|
|
3
|
+
module.exports = (args) => {
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const userHomeDir = os.homedir();
|
|
8
|
+
const log = require('log-beautify');
|
|
9
|
+
const sep = path.sep;
|
|
10
|
+
const { nanoid } = require('nanoid');
|
|
11
|
+
const AdmZip = require('adm-zip');
|
|
12
|
+
const UID = nanoid();
|
|
13
|
+
const fse = require('fs-extra');
|
|
14
|
+
const chalk = require('chalk-v2');
|
|
15
|
+
|
|
16
|
+
var DEFAULT_TEMPLATE = '';
|
|
17
|
+
const unzipFile = (zipFilePath, outputPath, callback) => {
|
|
18
|
+
const zip = new AdmZip(zipFilePath);
|
|
19
|
+
try {
|
|
20
|
+
zip.extractAllTo(outputPath, true);
|
|
21
|
+
callback();
|
|
22
|
+
} catch (err) {
|
|
23
|
+
console.error(
|
|
24
|
+
"Une erreur s'est produite lors de la décompression :",
|
|
25
|
+
err
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const download = async (name, cb) => {
|
|
30
|
+
const CadricielAPI = require(path.join('..', '..', 'lib', 'cadriciel'));
|
|
31
|
+
const cadriciel = new CadricielAPI();
|
|
32
|
+
await cadriciel.downloadFile(
|
|
33
|
+
'/template?key=' + name + '.zip',
|
|
34
|
+
`${os.tmpdir()}${sep}${name}.zip`
|
|
35
|
+
);
|
|
36
|
+
unzipFile(
|
|
37
|
+
`${os.tmpdir()}${sep}${name}.zip`,
|
|
38
|
+
`${os.tmpdir()}${sep}${UID}`,
|
|
39
|
+
() => {
|
|
40
|
+
DEFAULT_TEMPLATE = name;
|
|
41
|
+
fs.unlink(`${os.tmpdir()}${sep}${name}.zip`, cb);
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
async function updateCadriciel(srcDir, destDir) {
|
|
46
|
+
try {
|
|
47
|
+
const storeDir = path.join(destDir, '.store');
|
|
48
|
+
|
|
49
|
+
// Sauvegarde de .store
|
|
50
|
+
const backupDir = path.join(os.tmpdir(), 'backup_store');
|
|
51
|
+
await fse.copy(storeDir, backupDir);
|
|
52
|
+
|
|
53
|
+
// Suppression de xxx/.cadriciel
|
|
54
|
+
await fse.remove(path.join(destDir));
|
|
55
|
+
|
|
56
|
+
// Copie de yyy/.cadriciel vers xxx/.cadriciel
|
|
57
|
+
await fse.copy(srcDir, path.join(destDir));
|
|
58
|
+
|
|
59
|
+
// Restauration de .store
|
|
60
|
+
await fse.copy(backupDir, storeDir);
|
|
61
|
+
|
|
62
|
+
// Suppression du dossier de sauvegarde
|
|
63
|
+
await fse.remove(backupDir);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.error('Erreur lors de la mise à jour de .cadriciel:', error);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
info: {
|
|
71
|
+
title: '---',
|
|
72
|
+
description: 'upgrade cadriciel framework',
|
|
73
|
+
},
|
|
74
|
+
start: () => {
|
|
75
|
+
var spinner = ora('📥 Téléchargement du patch...').start();
|
|
76
|
+
const info = require(`${process.cwd()}/.cadriciel/version.json`);
|
|
77
|
+
const title = 'cadriciel-' + info.name;
|
|
78
|
+
download(title, async () => {
|
|
79
|
+
spinner.succeed(chalk.bold('Téléchargement OK.'));
|
|
80
|
+
spinner = ora('📥 Application du patch...').start();
|
|
81
|
+
const dir1 = `${os.tmpdir()}${sep}${UID}/§§project§§/.cadriciel`;
|
|
82
|
+
const dir2 = `${process.cwd()}/.cadriciel`;
|
|
83
|
+
await updateCadriciel(dir1, dir2);
|
|
84
|
+
spinner.succeed(chalk.bold('Application du patch OK.'));
|
|
85
|
+
console.log(' ');
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
};
|
package/cli.js
CHANGED
|
@@ -211,37 +211,38 @@ const display = (commands) => {
|
|
|
211
211
|
|
|
212
212
|
for (let el in commands) {
|
|
213
213
|
let title = el;
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
214
|
+
if (commands[el].info.title != '---') {
|
|
215
|
+
if (commands[el].info) {
|
|
216
|
+
let description = commands[el].info.description;
|
|
217
|
+
if (commands[el].info.sub) {
|
|
218
|
+
title += ' <subcommand>';
|
|
219
|
+
const sc = [];
|
|
220
|
+
for (let i = 0; i < commands[el].info.sub.length; i++) {
|
|
221
|
+
sc.push(commands[el].info.sub[i].title);
|
|
222
|
+
}
|
|
223
|
+
description += chalk.white(' ');
|
|
224
|
+
description += chalk.grey(' (subcommands: ');
|
|
225
|
+
description += chalk.cyan(sc.join(', '));
|
|
226
|
+
description += chalk.grey(')');
|
|
222
227
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
228
|
+
const dots = '.'.repeat(maxWidth - title.length);
|
|
229
|
+
|
|
230
|
+
const formattedDesc = formatDescription(
|
|
231
|
+
description,
|
|
232
|
+
maxDescriptionLength
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
console.log(
|
|
236
|
+
' ' +
|
|
237
|
+
chalk.cyanBright(title) +
|
|
238
|
+
' ' +
|
|
239
|
+
chalk.grey(dots) +
|
|
240
|
+
' ' +
|
|
241
|
+
label(commands[el].info.label) +
|
|
242
|
+
' ' +
|
|
243
|
+
chalk.white(formattedDesc)
|
|
244
|
+
);
|
|
227
245
|
}
|
|
228
|
-
const dots = '.'.repeat(maxWidth - title.length);
|
|
229
|
-
|
|
230
|
-
const formattedDesc = formatDescription(
|
|
231
|
-
description,
|
|
232
|
-
maxDescriptionLength
|
|
233
|
-
);
|
|
234
|
-
|
|
235
|
-
console.log(
|
|
236
|
-
' ' +
|
|
237
|
-
chalk.cyanBright(title) +
|
|
238
|
-
' ' +
|
|
239
|
-
chalk.grey(dots) +
|
|
240
|
-
' ' +
|
|
241
|
-
label(commands[el].info.label) +
|
|
242
|
-
' ' +
|
|
243
|
-
chalk.white(formattedDesc)
|
|
244
|
-
);
|
|
245
246
|
}
|
|
246
247
|
}
|
|
247
248
|
};
|
|
@@ -299,17 +300,20 @@ const processCommands = (args) => {
|
|
|
299
300
|
const command = args[0];
|
|
300
301
|
const maxWidth = 30;
|
|
301
302
|
const maxDescriptionLength = 50;
|
|
303
|
+
|
|
302
304
|
loadCadricielCommands(CADRICIEL_PATH + '/../');
|
|
303
|
-
|
|
304
|
-
|
|
305
|
+
|
|
306
|
+
if (CADRICIEL_GLOBAL_COMMANDS[command]) {
|
|
307
|
+
CADRICIEL_GLOBAL_COMMANDS[command].start(args);
|
|
308
|
+
} else {
|
|
309
|
+
if (CADRICIEL_COMMANDS[command]) {
|
|
310
|
+
console.log(' ');
|
|
311
|
+
const dir = args.join('/');
|
|
312
|
+
return parseCommand(args);
|
|
313
|
+
} else {
|
|
305
314
|
log.error('Commande inconnue : ' + command);
|
|
306
315
|
return displayBanner();
|
|
307
316
|
}
|
|
308
|
-
CADRICIEL_GLOBAL_COMMANDS[command].start(args);
|
|
309
|
-
} else {
|
|
310
|
-
console.log(' ');
|
|
311
|
-
const dir = args.join('/');
|
|
312
|
-
return parseCommand(args);
|
|
313
317
|
}
|
|
314
318
|
};
|
|
315
319
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cerema/cadriciel",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.32",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"npm": ">=8.0.0",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"dotenv": "^16.3.1",
|
|
20
20
|
"express": "^4.18.2",
|
|
21
21
|
"figlet": "^1.5.2",
|
|
22
|
+
"fs-extra": "^11.2.0",
|
|
22
23
|
"inquirer": "8.2.5",
|
|
23
24
|
"isbinaryfile": "^5.0.0",
|
|
24
25
|
"jsonwebtoken": "^9.0.2",
|