@cerema/cadriciel 1.5.2 → 1.5.4
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 +5 -0
- package/cli/global/upgrade.js +79 -18
- package/package.json +2 -2
package/cli/global/init.js
CHANGED
|
@@ -104,10 +104,15 @@ Host cadriciel
|
|
|
104
104
|
bar1.start(100, 0);
|
|
105
105
|
progress(bar1, response, async () => {
|
|
106
106
|
console.log(' ');
|
|
107
|
+
console.log(response);
|
|
107
108
|
const step1 = ora('📥 Téléchargement du projet en cours...').start();
|
|
108
109
|
try {
|
|
110
|
+
console.log('o');
|
|
109
111
|
await updatePK();
|
|
112
|
+
console.log('o');
|
|
110
113
|
try {
|
|
114
|
+
console.log('git clone ' + response.prj.uri);
|
|
115
|
+
console.log('git clone ' + response.prj.uri);
|
|
111
116
|
const git = await execPromise('git clone ' + response.prj.uri, {
|
|
112
117
|
cwd: process.cwd(),
|
|
113
118
|
});
|
package/cli/global/upgrade.js
CHANGED
|
@@ -8,23 +8,75 @@ module.exports = (args) => {
|
|
|
8
8
|
const log = require('log-beautify');
|
|
9
9
|
const sep = path.sep;
|
|
10
10
|
const { nanoid } = require('nanoid');
|
|
11
|
-
const
|
|
11
|
+
const yauzl = require('yauzl');
|
|
12
12
|
const UID = nanoid();
|
|
13
13
|
const fse = require('fs-extra');
|
|
14
14
|
const chalk = require('chalk-v2');
|
|
15
15
|
|
|
16
16
|
var DEFAULT_TEMPLATE = '';
|
|
17
17
|
const unzipFile = (zipFilePath, outputPath, callback) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
);
|
|
27
|
-
|
|
18
|
+
yauzl.open(zipFilePath, { lazyEntries: true }, (err, zipfile) => {
|
|
19
|
+
if (err) {
|
|
20
|
+
return console.error(
|
|
21
|
+
"Une erreur s'est produite lors de l'ouverture du fichier ZIP :",
|
|
22
|
+
err
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
zipfile.readEntry();
|
|
27
|
+
|
|
28
|
+
zipfile.on('entry', (entry) => {
|
|
29
|
+
const entryPath = path.join(outputPath, entry.fileName);
|
|
30
|
+
|
|
31
|
+
if (/\/$/.test(entry.fileName)) {
|
|
32
|
+
// Directory file names end with '/'.
|
|
33
|
+
mkdirp(entryPath, (err) => {
|
|
34
|
+
if (err) {
|
|
35
|
+
return console.error(
|
|
36
|
+
"Une erreur s'est produite lors de la création du répertoire :",
|
|
37
|
+
err
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
zipfile.readEntry();
|
|
41
|
+
});
|
|
42
|
+
} else {
|
|
43
|
+
// Ensure the parent directory exists.
|
|
44
|
+
mkdirp(path.dirname(entryPath), (err) => {
|
|
45
|
+
if (err) {
|
|
46
|
+
return console.error(
|
|
47
|
+
"Une erreur s'est produite lors de la création du répertoire parent :",
|
|
48
|
+
err
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
zipfile.openReadStream(entry, (err, readStream) => {
|
|
53
|
+
if (err) {
|
|
54
|
+
return console.error(
|
|
55
|
+
"Une erreur s'est produite lors de la lecture de l'entrée ZIP :",
|
|
56
|
+
err
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const writeStream = fs.createWriteStream(entryPath);
|
|
61
|
+
|
|
62
|
+
readStream.on('end', () => {
|
|
63
|
+
zipfile.readEntry();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
readStream.pipe(writeStream);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
zipfile.on('end', () => {
|
|
73
|
+
callback();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
zipfile.on('error', (err) => {
|
|
77
|
+
console.error("Une erreur s'est produite lors de l'extraction :", err);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
28
80
|
};
|
|
29
81
|
const download = async (name, cb) => {
|
|
30
82
|
const CadricielAPI = require(path.join('..', '..', 'lib', 'cadriciel'));
|
|
@@ -80,15 +132,24 @@ module.exports = (args) => {
|
|
|
80
132
|
console.log(' ');
|
|
81
133
|
var spinner = ora('📥 Téléchargement du patch...').start();
|
|
82
134
|
try {
|
|
83
|
-
var info = require(path.join(
|
|
135
|
+
var info = require(path.join(
|
|
136
|
+
process.cwd(),
|
|
137
|
+
'.cadriciel',
|
|
138
|
+
'version.json'
|
|
139
|
+
));
|
|
84
140
|
} catch (e) {
|
|
85
141
|
try {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
142
|
+
var info = require(path.join(
|
|
143
|
+
process.cwd(),
|
|
144
|
+
'.cadriciel',
|
|
145
|
+
'bin',
|
|
146
|
+
'version.json'
|
|
147
|
+
));
|
|
148
|
+
} catch (e) {
|
|
149
|
+
spinner.fail('upgrade doit être lancé à partir de votre projet.');
|
|
150
|
+
console.log(' ');
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
92
153
|
}
|
|
93
154
|
const title = 'cadriciel-' + info.name;
|
|
94
155
|
download(title, async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cerema/cadriciel",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.4",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"npm": ">=8.0.0",
|
|
@@ -32,6 +32,6 @@
|
|
|
32
32
|
"semver": "^7.5.4",
|
|
33
33
|
"terminal-link": "2.1.1",
|
|
34
34
|
"unzipper": "^0.10.11",
|
|
35
|
-
"yauzl": "^
|
|
35
|
+
"yauzl": "^3.1.3"
|
|
36
36
|
}
|
|
37
37
|
}
|