@bouygues-telecom/staticjs 0.1.7 → 0.1.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.
@@ -1,62 +1,51 @@
1
+ #!/usr/bin/env node
1
2
  import fs from 'fs';
2
3
  import path from 'path';
3
-
4
4
  const sourceDir = './dist';
5
-
6
5
  const htmlFiles = ['page1.html', 'page2.html'];
7
-
8
6
  const outputDir = 'test';
9
7
  const outputFile = 'test-multi-app.html';
10
-
11
8
  const readFile = (filePath) => {
12
9
  return new Promise((resolve, reject) => {
13
10
  fs.readFile(filePath, 'utf8', (err, data) => {
14
11
  if (err) {
15
12
  reject(err);
16
- } else {
13
+ }
14
+ else {
17
15
  resolve(data);
18
16
  }
19
17
  });
20
18
  });
21
19
  };
22
-
23
20
  const writeOutputFile = (filePath, content) => {
24
21
  return new Promise((resolve, reject) => {
25
22
  fs.writeFile(filePath, content, 'utf8', (err) => {
26
23
  if (err) {
27
24
  reject(err);
28
- } else {
25
+ }
26
+ else {
29
27
  resolve();
30
28
  }
31
29
  });
32
30
  });
33
31
  };
34
-
35
32
  const createDir = (dirPath) => {
36
33
  if (!fs.existsSync(dirPath)) {
37
34
  fs.mkdirSync(dirPath, { recursive: true });
38
35
  }
39
36
  };
40
-
41
37
  const generateHtmlFile = async () => {
42
38
  try {
43
39
  createDir(outputDir);
44
-
45
- const htmlContents = await Promise.all(
46
- htmlFiles.map(file => readFile(path.join(sourceDir, file)))
47
- );
48
-
40
+ const htmlContents = await Promise.all(htmlFiles.map(file => readFile(path.join(sourceDir, file))));
49
41
  let combinedContent = htmlContents.join("\n<!-- Page Separator -->\n");
50
-
51
42
  combinedContent = combinedContent.replace(/src="page1.js"/g, 'src="../dist/page1.js"');
52
43
  combinedContent = combinedContent.replace(/src="page2.js"/g, 'src="../dist/page2.js"');
53
-
54
44
  await writeOutputFile(path.join(outputDir, outputFile), combinedContent);
55
-
56
- console.log(`Le fichier ${outputFile} a été créé avec succès dans le dossier ${outputDir}.`);
57
- } catch (error) {
58
- console.error(`Une erreur est survenue: ${error.message}`);
45
+ console.log(`File ${outputFile} was created with success in folder ${outputDir}.`);
46
+ }
47
+ catch (error) {
48
+ console.error(`Error exception: ${error.message}`);
59
49
  }
60
50
  };
61
-
62
51
  generateHtmlFile();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bouygues-telecom/staticjs",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -10,7 +10,7 @@
10
10
  "bin": {
11
11
  "create-staticjs-app": "./dist/scripts/create-static-app.js",
12
12
  "bt-staticjs": "./dist/scripts/cli.js",
13
- "generate-test-multiapps": "./scripts/generate-test-multiapps.js"
13
+ "generate-test-multiapps": "./dist/scripts/generate-test-multiapps.js"
14
14
  },
15
15
  "scripts": {
16
16
  "prebuild": "tsc -p ./tsconfig.json",