@cerema/cadriciel 0.6.1 → 1.0.0

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 CHANGED
@@ -1,9 +1,10 @@
1
1
  module.exports = function (program) {
2
2
  var UID = require('shortid').generate();
3
3
  const inquirer = require('inquirer');
4
+ const path = require('path');
5
+ const AdmZip = require('adm-zip');
4
6
  const ora = require('ora');
5
7
  const os = require('os');
6
- const unzipper = require('unzipper');
7
8
  const recursive = require('recursive-readdir');
8
9
  const fs = require('fs');
9
10
  const log = require('log-beautify');
@@ -16,17 +17,27 @@ module.exports = function (program) {
16
17
  } = require('../lib/util');
17
18
  const { S3 } = require('../lib/s3');
18
19
 
20
+ const unzipFile = (zipFilePath, outputPath, callback) => {
21
+ const zip = new AdmZip(zipFilePath);
22
+
23
+ try {
24
+ zip.extractAllTo(outputPath, true);
25
+ callback();
26
+ } catch (err) {
27
+ console.error(
28
+ "Une erreur s'est produite lors de la décompression :",
29
+ err
30
+ );
31
+ }
32
+ };
33
+
19
34
  const download = async (name, cb) => {
20
35
  var client = await S3();
21
36
  client.get('templates', `${name}.zip`, function () {
22
- fs.createReadStream(`${os.tmpdir()}/${name}.zip`).pipe(
23
- unzipper
24
- .Extract({ path: os.tmpdir() + '/' + UID })
25
- .on('close', function () {
26
- DEFAULT_TEMPLATE = name;
27
- fs.unlink(`${os.tmpdir()}/${name}.zip`, cb);
28
- })
29
- );
37
+ unzipFile(`${os.tmpdir()}/${name}.zip`, `${os.tmpdir()}/${UID}`, () => {
38
+ DEFAULT_TEMPLATE = name;
39
+ fs.unlink(`${os.tmpdir()}/${name}.zip`, cb);
40
+ });
30
41
  });
31
42
  };
32
43
 
@@ -41,7 +52,6 @@ module.exports = function (program) {
41
52
  var text = fs.readFileSync(input, 'utf-8');
42
53
  text = text.replace(/§§project§§/g, o.project);
43
54
  text = text.replace(/§§projectUpper§§/g, o.project.toUpperCase());
44
- text = text.replace(/§§projectNS§§/g, capitalizeFirstLetter(o.project));
45
55
  text = text.replace(/§§projectID§§/g, capitalizeFirstLetter(o.project));
46
56
  text = text.replace(/§§pg_port§§/g, o.pg_port);
47
57
  text = text.replace(/§§inbucket_port§§/g, o.inbucket_port);
@@ -89,73 +99,7 @@ module.exports = function (program) {
89
99
  process.cwd() + '/' + o.project + '/.project',
90
100
  JSON.stringify(o)
91
101
  );
92
- var gitignore = `
93
- ##########################
94
- # Application specfic
95
- ##########################
96
- # config/config.js
97
-
98
- ##########################
99
- # General
100
- ##########################
101
-
102
- #####
103
- # OS X temporary files
104
- #
105
- # c.f. http://www.westwind.com/reference/os-x/invisibles.html
106
- .DS_Store
107
- __MACOSX
108
-
109
- # c.f. http://www.westwind.com/reference/os-x/invisibles.html
110
- .Trashes
111
-
112
- # c.f. http://www.westwind.com/reference/os-x/invisibles.html
113
- *.swp
114
-
115
- #####
116
- # Node stuff
117
- #
118
- # Logs
119
- logs
120
- *.log
121
- npm-debug.log*
122
-
123
- # Runtime data
124
- pids
125
- *.pid
126
- *.seed
127
-
128
- # Coverage directory used by tools like istanbul
129
- coverage
130
-
131
- # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
132
- .grunt
133
-
134
- # node-waf configuration
135
- .lock-wscript
136
-
137
- # Compiled binary addons (http://nodejs.org/api/addons.html)
138
- build/Release
139
-
140
- # Dependency directory
141
- # https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
142
- node_modules
143
- `;
144
- fs.writeFileSync(
145
- process.cwd() + '/' + o.project + '/.gitignore',
146
- gitignore
147
- );
148
102
  spinner.succeed(`projet ${o.project} crée avec succès.`);
149
- console.log('\n');
150
- console.log('Prochaines étapes');
151
- console.log('-----------------');
152
- console.log('cd ' + o.project);
153
- console.log('git init');
154
- console.log('git add --all');
155
- console.log('git commit -m "first commit"');
156
- console.log('npm i');
157
- console.log('Lancer le backend avec votre IDE préféré ;-)');
158
- console.log('\n');
159
103
  console.log('\n🚀 Happy coding !\n');
160
104
  });
161
105
  });
package/lib/s3.js CHANGED
@@ -1,7 +1,6 @@
1
1
  const os = require('os');
2
2
  const fs = require('fs');
3
3
  const util = require('util');
4
- const userHomeDir = os.homedir();
5
4
  const S3_URI = 's3.siipro.fr';
6
5
  const Minio = require('minio');
7
6
 
@@ -15,7 +14,7 @@ const S3 = async function (current_login) {
15
14
  current_login.useSSL = true;
16
15
  return new Minio.Client(current_login);
17
16
  }
18
- const r = await readFile(`${userHomeDir}/.cadriciel/account.json`, 'utf-8');
17
+ const r = await readFile(`${os.homedir}/.cadriciel/account.json`, 'utf-8');
19
18
  if (r) return new Minio.Client(JSON.parse(r));
20
19
  };
21
20
  var client = await login(current_login);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cerema/cadriciel",
3
- "version": "0.6.1",
3
+ "version": "1.0.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "npm": ">=8.0.0",
@@ -9,17 +9,19 @@
9
9
  "cadriciel": "./cli.js"
10
10
  },
11
11
  "dependencies": {
12
+ "adm-zip": "^0.5.10",
12
13
  "chalk-v2": "^1.0.2",
13
14
  "commander": "^10.0.0",
14
15
  "figlet": "^1.5.2",
15
16
  "inquirer": "8.2.5",
16
17
  "isbinaryfile": "^5.0.0",
17
18
  "log-beautify": "^1.2.0",
18
- "minio": "",
19
+ "minio": "^7.0.32",
19
20
  "ora": "^5.4.1",
20
21
  "recursive-readdir": "^2.2.3",
21
22
  "shortid": "^2.2.16",
22
23
  "terminal-link": "2.1.1",
23
- "unzipper": "^0.10.11"
24
+ "unzipper": "^0.10.11",
25
+ "yauzl": "^2.10.0"
24
26
  }
25
27
  }
package/gitignore DELETED
@@ -1,50 +0,0 @@
1
- ##########################
2
- # Application specfic
3
- ##########################
4
- # config/config.js
5
-
6
- ##########################
7
- # General
8
- ##########################
9
-
10
- #####
11
- # OS X temporary files
12
- #
13
- # c.f. http://www.westwind.com/reference/os-x/invisibles.html
14
- .DS_Store
15
- __MACOSX
16
-
17
- # c.f. http://www.westwind.com/reference/os-x/invisibles.html
18
- .Trashes
19
-
20
- # c.f. http://www.westwind.com/reference/os-x/invisibles.html
21
- *.swp
22
-
23
- #####
24
- # Node stuff
25
- #
26
- # Logs
27
- logs
28
- *.log
29
- npm-debug.log*
30
-
31
- # Runtime data
32
- pids
33
- *.pid
34
- *.seed
35
-
36
- # Coverage directory used by tools like istanbul
37
- coverage
38
-
39
- # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
40
- .grunt
41
-
42
- # node-waf configuration
43
- .lock-wscript
44
-
45
- # Compiled binary addons (http://nodejs.org/api/addons.html)
46
- build/Release
47
-
48
- # Dependency directory
49
- # https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
50
- node_modules