@cerema/cadriciel 0.5.3 → 0.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/cmd/init.js +23 -64
- package/package.json +2 -5
- package/cmd/info.js +0 -33
package/cmd/init.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
module.exports = function (program) {
|
|
2
|
+
var UID = require('shortid').generate();
|
|
2
3
|
const inquirer = require('inquirer');
|
|
3
4
|
const ora = require('ora');
|
|
4
5
|
const os = require('os');
|
|
@@ -14,14 +15,13 @@ module.exports = function (program) {
|
|
|
14
15
|
getTemplates,
|
|
15
16
|
} = require('../lib/util');
|
|
16
17
|
const { S3 } = require('../lib/s3');
|
|
17
|
-
var DEFAULT_TEMPLATE;
|
|
18
18
|
|
|
19
19
|
const download = async (name, cb) => {
|
|
20
20
|
var client = await S3();
|
|
21
21
|
client.get('templates', `${name}.zip`, function () {
|
|
22
22
|
fs.createReadStream(`${os.tmpdir()}/${name}.zip`).pipe(
|
|
23
23
|
unzipper
|
|
24
|
-
.Extract({ path: os.tmpdir() + '/' +
|
|
24
|
+
.Extract({ path: os.tmpdir() + '/' + UID })
|
|
25
25
|
.on('close', function () {
|
|
26
26
|
DEFAULT_TEMPLATE = name;
|
|
27
27
|
fs.unlink(`${os.tmpdir()}/${name}.zip`, cb);
|
|
@@ -29,6 +29,7 @@ module.exports = function (program) {
|
|
|
29
29
|
);
|
|
30
30
|
});
|
|
31
31
|
};
|
|
32
|
+
|
|
32
33
|
const changefs = (o, files, ndx, cb) => {
|
|
33
34
|
if (!files[ndx]) return cb();
|
|
34
35
|
|
|
@@ -50,9 +51,7 @@ module.exports = function (program) {
|
|
|
50
51
|
var output =
|
|
51
52
|
OUTPUT_DIRECTORY +
|
|
52
53
|
'/' +
|
|
53
|
-
input
|
|
54
|
-
.split(DEFAULT_TEMPLATE + '/')[1]
|
|
55
|
-
.replace(/§§project§§/g, o.project);
|
|
54
|
+
input.split(UID + '/')[1].replace(/§§project§§/g, o.project);
|
|
56
55
|
var dir = require('path').dirname(output);
|
|
57
56
|
fs.mkdirSync(dir, { recursive: true });
|
|
58
57
|
fs.writeFileSync(output, text);
|
|
@@ -63,9 +62,7 @@ module.exports = function (program) {
|
|
|
63
62
|
var output =
|
|
64
63
|
OUTPUT_DIRECTORY +
|
|
65
64
|
'/' +
|
|
66
|
-
input
|
|
67
|
-
.split(DEFAULT_TEMPLATE + '/')[1]
|
|
68
|
-
.replace(/§§project§§/g, o.project);
|
|
65
|
+
input.split(UID + '/')[1].replace(/§§project§§/g, o.project);
|
|
69
66
|
var dir = require('path').dirname(output);
|
|
70
67
|
fs.mkdirSync(dir, { recursive: true });
|
|
71
68
|
fs.copyFileSync(input, output);
|
|
@@ -73,33 +70,31 @@ module.exports = function (program) {
|
|
|
73
70
|
}
|
|
74
71
|
});
|
|
75
72
|
};
|
|
73
|
+
|
|
76
74
|
const createProject = async (o) => {
|
|
77
75
|
const account = await getAccount();
|
|
78
76
|
var spinner = ora('Téléchargement du cadriciel').start();
|
|
79
|
-
return download(o.template.
|
|
77
|
+
return download(o.template.dir, function () {
|
|
80
78
|
spinner.succeed();
|
|
81
79
|
spinner = ora('Création du projet ' + o.project).start();
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
fs.rmSync(os.tmpdir() + '/' + o.project, {
|
|
89
|
-
recursive: true,
|
|
90
|
-
force: true,
|
|
91
|
-
});
|
|
92
|
-
fs.writeFileSync(
|
|
93
|
-
process.cwd() + '/' + o.project + '/.project',
|
|
94
|
-
JSON.stringify(o)
|
|
95
|
-
);
|
|
96
|
-
spinner.succeed(`projet ${o.project} crée avec succès.`);
|
|
97
|
-
console.log('\n🚀 Happy coding !\n');
|
|
80
|
+
recursive(`${os.tmpdir()}/${UID}`, async function (err, files) {
|
|
81
|
+
spinner.succeed();
|
|
82
|
+
changefs(o, files, 0, function () {
|
|
83
|
+
fs.rmSync(os.tmpdir() + '/' + UID, {
|
|
84
|
+
recursive: true,
|
|
85
|
+
force: true,
|
|
98
86
|
});
|
|
99
|
-
|
|
100
|
-
|
|
87
|
+
fs.writeFileSync(
|
|
88
|
+
process.cwd() + '/' + o.project + '/.project',
|
|
89
|
+
JSON.stringify(o)
|
|
90
|
+
);
|
|
91
|
+
spinner.succeed(`projet ${o.project} crée avec succès.`);
|
|
92
|
+
console.log('\n🚀 Happy coding !\n');
|
|
93
|
+
});
|
|
94
|
+
});
|
|
101
95
|
});
|
|
102
96
|
};
|
|
97
|
+
|
|
103
98
|
const init = async (str, options) => {
|
|
104
99
|
const templates = await getTemplates();
|
|
105
100
|
var tpl = [];
|
|
@@ -119,43 +114,7 @@ module.exports = function (program) {
|
|
|
119
114
|
name: 'template',
|
|
120
115
|
message: 'Choisissez le modèle de cadriciel',
|
|
121
116
|
choices: tpl,
|
|
122
|
-
} /*,
|
|
123
|
-
{
|
|
124
|
-
type: 'number',
|
|
125
|
-
name: 'pgport',
|
|
126
|
-
initial: 5433,
|
|
127
|
-
message: 'Spécifiez le port de PostGres',
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
type: 'number',
|
|
131
|
-
name: 'pgadmin',
|
|
132
|
-
initial: 8888,
|
|
133
|
-
message: 'Spécifiez le port de PgAdmin',
|
|
134
117
|
},
|
|
135
|
-
{
|
|
136
|
-
type: 'number',
|
|
137
|
-
name: 'inbucket_port',
|
|
138
|
-
initial: 8889,
|
|
139
|
-
message: 'Spécifiez le port de FakeSMTP',
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
type: 'number',
|
|
143
|
-
name: 'keycloak_port',
|
|
144
|
-
initial: 8890,
|
|
145
|
-
message: 'Spécifiez le port de Keycloak',
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
type: 'input',
|
|
149
|
-
name: 'pgadmin_email',
|
|
150
|
-
initial: 'admin@cerema.fr',
|
|
151
|
-
message: 'Login',
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
type: 'password',
|
|
155
|
-
name: 'pgadmin_password',
|
|
156
|
-
initial: 'CeremaRulez!',
|
|
157
|
-
message: 'Mot de passe',
|
|
158
|
-
},*/,
|
|
159
118
|
];
|
|
160
119
|
inquirer
|
|
161
120
|
.prompt(questions)
|
|
@@ -168,7 +127,7 @@ module.exports = function (program) {
|
|
|
168
127
|
return log.error('Ce projet existe déjà !');
|
|
169
128
|
} catch (e) {}
|
|
170
129
|
|
|
171
|
-
OUTPUT_DIRECTORY = process.cwd()
|
|
130
|
+
OUTPUT_DIRECTORY = `${process.cwd()}`;
|
|
172
131
|
createProject(response);
|
|
173
132
|
})
|
|
174
133
|
.catch((error) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cerema/cadriciel",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"npm": ">=8.0.0",
|
|
@@ -9,19 +9,16 @@
|
|
|
9
9
|
"cadriciel": "./cli.js"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"axios": "^1.2.3",
|
|
13
12
|
"chalk-v2": "^1.0.2",
|
|
14
13
|
"commander": "^10.0.0",
|
|
15
14
|
"figlet": "^1.5.2",
|
|
16
|
-
"handlebars": "^4.7.7",
|
|
17
15
|
"inquirer": "8.2.5",
|
|
18
16
|
"isbinaryfile": "^5.0.0",
|
|
19
17
|
"log-beautify": "^1.2.0",
|
|
20
18
|
"minio": "^7.0.32",
|
|
21
19
|
"ora": "^5.4.1",
|
|
22
|
-
"prompts": "^2.4.2",
|
|
23
20
|
"recursive-readdir": "^2.2.3",
|
|
24
|
-
"
|
|
21
|
+
"shortid": "^2.2.16",
|
|
25
22
|
"terminal-link": "2.1.1",
|
|
26
23
|
"unzipper": "^0.10.11"
|
|
27
24
|
}
|
package/cmd/info.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
module.exports = function (program) {
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
function info() {
|
|
4
|
-
var text = fs.readFileSync(process.cwd() + '/.project', 'utf-8');
|
|
5
|
-
var p = JSON.parse(text);
|
|
6
|
-
//console.log(p);
|
|
7
|
-
console.log('---');
|
|
8
|
-
console.log('Serveur PGAdmin');
|
|
9
|
-
var link = terminalLink(
|
|
10
|
-
'http://127.0.0.1:' + p.pgadmin_port,
|
|
11
|
-
'http://127.0.0.1:' + p.pgadmin_port
|
|
12
|
-
);
|
|
13
|
-
console.log(link);
|
|
14
|
-
console.log('\nServeur FakeSMTP');
|
|
15
|
-
link = terminalLink(
|
|
16
|
-
'http://127.0.0.1:' + p.inbucket_port,
|
|
17
|
-
'http://127.0.0.1:' + p.inbucket_port
|
|
18
|
-
);
|
|
19
|
-
console.log(link);
|
|
20
|
-
console.log('\nServeur KeyCloak (ORION)');
|
|
21
|
-
link = terminalLink(
|
|
22
|
-
'http://127.0.0.1:' + p.keycloak_port,
|
|
23
|
-
'http://127.0.0.1:' + p.keycloak_port
|
|
24
|
-
);
|
|
25
|
-
console.log(link);
|
|
26
|
-
}
|
|
27
|
-
program
|
|
28
|
-
.command('info')
|
|
29
|
-
.description('Affichage des informations des services')
|
|
30
|
-
.action((str, options) => {
|
|
31
|
-
info();
|
|
32
|
-
});
|
|
33
|
-
};
|