@eui/tools 6.20.22 → 6.20.23

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 +1 @@
1
- 6.20.22
1
+ 6.20.23
package/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 6.20.23 (2024-09-05)
2
+
3
+ ##### Chores
4
+
5
+ * **other:**
6
+ * improve names MWP-11061 [MWP-11061](https://webgate.ec.europa.eu/CITnet/jira/browse/MWP-11061) ([bd68b63d](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/bd68b63de9a4208d6aa667d1c5f0b88c26661ae2))
7
+ * support esbuild build + bundle files in order to load elements as js modules MWP-11061 [MWP-11061](https://webgate.ec.europa.eu/CITnet/jira/browse/MWP-11061) ([967657f5](https://webgate.ec.europa.eu/CITnet/stash/scm/csdr/eui-tools.git/commits/967657f5708153ae24360407a62f015fdbf03633))
8
+
9
+ * * *
10
+ * * *
1
11
  ## 6.20.22 (2024-09-03)
2
12
 
3
13
  ##### Chores
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eui/tools",
3
- "version": "6.20.22",
3
+ "version": "6.20.23",
4
4
  "tag": "latest",
5
5
  "license": "EUPL-1.1",
6
6
  "description": "eUI common tools and scripts",
@@ -87,8 +87,8 @@ module.exports.build = (pkg, isMaster) => {
87
87
  return tools.runNodeScriptProcessOutput(args, pkg.paths.root);
88
88
 
89
89
  } else {
90
- return execa('node', args, { cwd: pkg.paths.root, stdio: 'inherit' });
91
- }
90
+ return execa('node', args, { cwd: pkg.paths.root, stdio: 'inherit' });
91
+ }
92
92
  }
93
93
  })
94
94
 
@@ -96,8 +96,7 @@ module.exports.build = (pkg, isMaster) => {
96
96
  .catch((e) => {
97
97
  throw e;
98
98
  });
99
- }
100
-
99
+ };
101
100
 
102
101
 
103
102
  module.exports.postBuild = (pkg, version) => {
@@ -110,44 +109,62 @@ module.exports.postBuild = (pkg, version) => {
110
109
 
111
110
  if (dryRun) {
112
111
  tools.logInfo('DRY-RUN...skipping');
113
- return;
114
-
115
112
  } else {
116
113
  return Promise.resolve()
117
- .then(() => {
118
- tools.logTitle('ELEMENT POST build');
119
- tools.logInfo('Copying dist to bundles folder');
120
- tools.mkdir(path.join(pkg.paths.dist, 'bundles'));
121
- if (euiVersionNumber >= 18) {
122
- tools.copydirFiles(path.join(pkg.paths.dist, 'browser'), path.join(pkg.paths.dist));
123
- tools.remove(path.join(pkg.paths.dist, 'browser'));
124
- }
125
- tools.copydir(path.join(pkg.paths.dist), path.join(pkg.paths.dist, 'bundles'));
126
- })
114
+ .then(() => {
115
+ tools.logTitle('ELEMENT POST build');
116
+ tools.logInfo('Copying dist to bundles folder');
117
+ tools.mkdir(path.join(pkg.paths.dist, 'bundles'));
127
118
 
128
- .then(() => {
129
- return remotesUtils.concatFiles(pkg, path.join(pkg.paths.dist, 'bundles'), euiVersionNumber);
130
- })
119
+ // remove browser folder for esbuild builds
120
+ const isEsbuild = pkg?.build?.esbuild !== undefined ?? false;
131
121
 
132
- .then(() => {
133
- return remotesUtils.copyPackageJson(pkg.paths.root, pkg.paths.dist, remoteEuiVersion);
134
- })
122
+ if (isEsbuild) {
123
+ tools.copydirFiles(path.join(pkg.paths.dist, 'browser'), path.join(pkg.paths.dist));
124
+ tools.remove(path.join(pkg.paths.dist, 'browser'));
125
+ }
126
+ tools.copydir(path.join(pkg.paths.dist), path.join(pkg.paths.dist, 'bundles'));
127
+ })
135
128
 
136
- .then(() => {
137
- tools.logInfo(`Renaming main.js file to current version : ${version}`);
138
- return tools.move(path.join(pkg.paths.dist, 'bundles', 'main.js'), path.join(pkg.paths.dist, 'bundles', 'main-' + version + '.js'));
139
- })
129
+ .then(() => {
130
+ // Note: it's limited to 18, but it could be applied to 15 / 16 / 17 / 18
131
+ const loadedAsJsModule = euiVersionNumber >= 18;
140
132
 
141
- .then(() => {
142
- return remotesUtils.emptyIndexHtml(pkg, path.join(pkg.paths.dist, 'bundles'));
143
- })
133
+ if (loadedAsJsModule) {
134
+ return remotesUtils.createEntryJsFile(pkg, path.join(pkg.paths.dist, 'bundles'), euiVersionNumber);
135
+ } else {
136
+ return remotesUtils.concatFiles(pkg, path.join(pkg.paths.dist, 'bundles'), euiVersionNumber);
137
+ }
138
+ })
144
139
 
145
- .then(() => {
146
- return remotesUtils.cleanupUnusedAssets(path.join(pkg.paths.dist, 'bundles', 'assets'), euiVersionNumber);
147
- })
140
+ .then(() => {
141
+ // Note: it's limited to 18, but it could be applied to 15 / 16 / 17 / 18
142
+ const loadedAsJsModule = euiVersionNumber >= 18;
148
143
 
149
- .catch((e) => {
150
- throw e;
151
- })
144
+ const name = loadedAsJsModule ? 'entry' : undefined;
145
+ return remotesUtils.copyPackageJson(pkg, pkg.paths.root, pkg.paths.dist, remoteEuiVersion, name);
146
+ })
147
+
148
+ .then(() => {
149
+ tools.logInfo(`Renaming main.js or entry.js file to current version : ${version}`);
150
+
151
+ // Note: it's limited to 18, but it could be applied to 15 / 16 / 17 / 18
152
+ const loadedAsJsModule = euiVersionNumber >= 18;
153
+
154
+ const name = loadedAsJsModule ? 'entry' : 'main';
155
+ return tools.move(path.join(pkg.paths.dist, 'bundles', `${name}.js`), path.join(pkg.paths.dist, 'bundles', `${name}-` + version + '.js'));
156
+ })
157
+
158
+ .then(() => {
159
+ return remotesUtils.emptyIndexHtml(pkg, path.join(pkg.paths.dist, 'bundles'));
160
+ })
161
+
162
+ .then(() => {
163
+ return remotesUtils.cleanupUnusedAssets(path.join(pkg.paths.dist, 'bundles', 'assets'), euiVersionNumber);
164
+ })
165
+
166
+ .catch((e) => {
167
+ throw e;
168
+ });
152
169
  }
153
- }
170
+ };
@@ -7,119 +7,149 @@ const concat = require('concat');
7
7
  // LOCAL
8
8
  const tools = require('../tools');
9
9
 
10
-
11
10
  module.exports.concatFiles = (pkg, workingPath, euiVersionNumber = 10) => {
12
- return Promise.resolve()
13
- .then(() => {
14
- tools.logInfo('Concatenating JS files into main.js');
15
-
16
- tools.move(path.join(workingPath, 'main.js'), path.join(workingPath, 'main-old.js'));
11
+ return Promise.resolve()
12
+ .then(() => {
17
13
 
18
- const files = [
19
- // covers both webpack and esbuild
20
- ...(tools.isFileExists(path.join(workingPath, 'runtime.js')) ? ['runtime.js'] : []),
21
- ...(tools.isFileExists(path.join(workingPath, 'polyfills.js')) ? ['polyfills.js'] : []),
22
- ...(tools.isFileExists(path.join(workingPath, 'scripts.js')) ? ['scripts.js'] : []),
23
- ...(tools.isFileExists(path.join(workingPath, 'vendor.js')) ? ['vendor.js'] : []),
24
- 'main-old.js',
25
- ].map(f => path.join(workingPath, f));
14
+ tools.logInfo('Concatenating JS files into main.js');
26
15
 
27
- const outFilePath = path.join(workingPath, 'main.js');
16
+ tools.move(path.join(workingPath, 'main.js'), path.join(workingPath, 'main-old.js'));
28
17
 
29
- console.log(files);
18
+ const files = [
19
+ // covers both webpack and esbuild
20
+ ...(tools.isFileExists(path.join(workingPath, 'runtime.js')) ? ['runtime.js'] : []),
21
+ ...(tools.isFileExists(path.join(workingPath, 'polyfills.js')) ? ['polyfills.js'] : []),
22
+ ...(tools.isFileExists(path.join(workingPath, 'scripts.js')) ? ['scripts.js'] : []),
23
+ ...(tools.isFileExists(path.join(workingPath, 'vendor.js')) ? ['vendor.js'] : []),
24
+ 'main-old.js',
25
+ ].map(f => path.join(workingPath, f));
30
26
 
31
- return concat(files, outFilePath);
32
- })
27
+ const outFilePath = path.join(workingPath, 'main.js');
33
28
 
34
- .catch((e) => {
35
- throw e;
36
- })
37
- }
29
+ console.log(files);
38
30
 
31
+ return concat(files, outFilePath);
32
+ })
39
33
 
40
- module.exports.copyPackageJson = (srcPath, destPath, euiVersion) => {
41
- return Promise.resolve()
42
- .then(() => {
43
- tools.logInfo('Copying package.json to dist');
34
+ .catch((e) => {
35
+ throw e;
36
+ });
37
+ };
44
38
 
45
- tools.copy(path.join(srcPath, 'package.json'), path.join(destPath, 'package.json'));
39
+ module.exports.createEntryJsFile = (pkg, workingPath, euiVersionNumber = 15) => {
40
+ return Promise.resolve()
41
+ .then(() => {
46
42
 
47
- if (euiVersion) {
48
- const packageJsonFile = path.join(destPath, 'package.json');
49
- const packageJson = require(packageJsonFile);
43
+ tools.logInfo('Importing files into entry.js');
50
44
 
51
- packageJson.euiVersion = euiVersion;
45
+ const files = [
46
+ // covers both webpack and esbuild
47
+ ...(tools.isFileExists(path.join(workingPath, 'runtime.js')) ? ['runtime.js'] : []),
48
+ ...(tools.isFileExists(path.join(workingPath, 'polyfills.js')) ? ['polyfills.js'] : []),
49
+ ...(tools.isFileExists(path.join(workingPath, 'scripts.js')) ? ['scripts.js'] : []),
50
+ ...(tools.isFileExists(path.join(workingPath, 'vendor.js')) ? ['vendor.js'] : []),
51
+ ...(tools.isFileExists(path.join(workingPath, 'main.js')) ? ['main.js'] : []),
52
+ ];
52
53
 
53
- tools.writeJsonFileSync(packageJsonFile, packageJson);
54
- }
55
- })
54
+ const outFilePath = path.join(workingPath, 'entry.js');
56
55
 
57
- .catch((e) => {
58
- throw e;
59
- })
60
- }
56
+ console.log(files);
61
57
 
58
+ let content = ``;
59
+ files.forEach(f => content = `${content}\nimport \'./${f}\';`.trim());
62
60
 
63
- module.exports.emptyIndexHtml = (pkg, destPath) => {
64
- return Promise.resolve()
65
- .then(() => {
66
- try {
67
- if (pkg.build.injectPiwikScript) {
68
- tools.logInfo('Inject index.html with piwik script embedded');
61
+ return tools.writeFileContent(outFilePath, content);
62
+ })
69
63
 
70
- const emptyIndexHtmlFile = path.join(__dirname, 'skeletons', 'elements', 'index-piwik.html');
71
- const outputIndexHmtlFile = path.join(destPath, 'index.html');
72
- return tools.copy(emptyIndexHtmlFile, outputIndexHmtlFile);
64
+ .catch((e) => {
65
+ throw e;
66
+ });
67
+ };
73
68
 
74
- } else {
75
- tools.logInfo('Set empty index.html');
69
+ module.exports.copyPackageJson = (pkg, srcPath, destPath, euiVersion, entryName) => {
70
+ return Promise.resolve()
71
+ .then(() => {
72
+ tools.logInfo('Copying package.json to dist');
76
73
 
77
- const emptyIndexHtmlFile = path.join(__dirname, 'skeletons', 'elements', 'index.html');
78
- const outputIndexHmtlFile = path.join(destPath, 'index.html');
79
- return tools.copy(emptyIndexHtmlFile, outputIndexHmtlFile);
80
- }
74
+ tools.copy(path.join(srcPath, 'package.json'), path.join(destPath, 'package.json'));
81
75
 
82
- } catch(e) {
83
- console.log(e);
84
- }
85
- })
76
+ if (euiVersion || entryName) {
77
+ const packageJsonFile = path.join(destPath, 'package.json');
78
+ const packageJson = require(packageJsonFile);
86
79
 
87
- .catch((e) => {
88
- throw e;
89
- })
90
- }
80
+ packageJson.euiVersion = euiVersion;
81
+ packageJson.entryName = entryName;
91
82
 
83
+ tools.writeJsonFileSync(packageJsonFile, packageJson);
84
+ }
85
+ })
92
86
 
93
- module.exports.cleanupUnusedAssets = (assetsPath, euiVersionNumber = 10) => {
94
- tools.logInfo(`Cleanup unused assets for version : ${euiVersionNumber} in ${assetsPath}`);
87
+ .catch((e) => {
88
+ throw e;
89
+ });
90
+ };
95
91
 
96
- if (euiVersionNumber > 10) {
97
92
 
93
+ module.exports.emptyIndexHtml = (pkg, destPath) => {
98
94
  return Promise.resolve()
99
- .then(() => {
100
- return tools.rimraf(path.join(assetsPath, 'ecl'));
101
- })
102
- .then(() => {
103
- return tools.rimraf(path.join(assetsPath, 'icons', 'ionicons'));
104
- })
105
- .then(() => {
106
- return tools.rimraf(path.join(assetsPath, 'icons', 'svg'));
107
- })
108
- .then(() => {
109
- return tools.rimraf(path.join(assetsPath, 'icons', 'svg-src'));
110
- })
111
- .then(() => {
112
- return tools.rimraf(path.join(assetsPath, 'icons', 'flags'));
113
- })
114
- .then(() => {
115
- return tools.rimraf(path.join(assetsPath, 'fonts'));
116
- })
117
- .then(() => {
118
- return tools.rimraf(path.join(assetsPath, 'i18n-eui'));
119
- })
120
-
121
- .catch((e) => {
122
- throw e;
123
- })
124
- }
125
- }
95
+ .then(() => {
96
+ try {
97
+ if (pkg.build.injectPiwikScript) {
98
+ tools.logInfo('Inject index.html with piwik script embedded');
99
+
100
+ const emptyIndexHtmlFile = path.join(__dirname, 'skeletons', 'elements', 'index-piwik.html');
101
+ const outputIndexHmtlFile = path.join(destPath, 'index.html');
102
+ return tools.copy(emptyIndexHtmlFile, outputIndexHmtlFile);
103
+
104
+ } else {
105
+ tools.logInfo('Set empty index.html');
106
+
107
+ const emptyIndexHtmlFile = path.join(__dirname, 'skeletons', 'elements', 'index.html');
108
+ const outputIndexHmtlFile = path.join(destPath, 'index.html');
109
+ return tools.copy(emptyIndexHtmlFile, outputIndexHmtlFile);
110
+ }
111
+
112
+ } catch (e) {
113
+ console.log(e);
114
+ }
115
+ })
116
+
117
+ .catch((e) => {
118
+ throw e;
119
+ });
120
+ };
121
+
122
+
123
+ module.exports.cleanupUnusedAssets = (assetsPath, euiVersionNumber = 10) => {
124
+ tools.logInfo(`Cleanup unused assets for version : ${euiVersionNumber} in ${assetsPath}`);
125
+
126
+ if (euiVersionNumber > 10) {
127
+
128
+ return Promise.resolve()
129
+ .then(() => {
130
+ return tools.rimraf(path.join(assetsPath, 'ecl'));
131
+ })
132
+ .then(() => {
133
+ return tools.rimraf(path.join(assetsPath, 'icons', 'ionicons'));
134
+ })
135
+ .then(() => {
136
+ return tools.rimraf(path.join(assetsPath, 'icons', 'svg'));
137
+ })
138
+ .then(() => {
139
+ return tools.rimraf(path.join(assetsPath, 'icons', 'svg-src'));
140
+ })
141
+ .then(() => {
142
+ return tools.rimraf(path.join(assetsPath, 'icons', 'flags'));
143
+ })
144
+ .then(() => {
145
+ return tools.rimraf(path.join(assetsPath, 'fonts'));
146
+ })
147
+ .then(() => {
148
+ return tools.rimraf(path.join(assetsPath, 'i18n-eui'));
149
+ })
150
+
151
+ .catch((e) => {
152
+ throw e;
153
+ });
154
+ }
155
+ };
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  const path = require('path');
4
- const execa = require('execa');
5
4
 
6
5
  const tools = require('../tools');
7
6
  const remotesUtils = require('../remotes/remotes-utils');
@@ -98,11 +97,35 @@ module.exports.serve = (remote = false) => {
98
97
  })
99
98
 
100
99
  .then(() => {
101
- return remotesUtils.concatFiles(pkg, destPath, euiVersionNumber);
100
+ // remove browser folder for esbuild builds
101
+ const isEsbuild = pkg?.build?.esbuild !== undefined ?? false;
102
+
103
+ if (isEsbuild) {
104
+ tools.copydirFiles(path.join(destPath, 'browser'), path.join(destPath));
105
+ tools.remove(path.join(destPath, 'browser'));
106
+ return Promise.resolve();
107
+ } else {
108
+ Promise.resolve();
109
+ }
110
+ })
111
+
112
+ .then(() => {
113
+ // Note: it's limited to 18, but it could be applied to 15 / 16 / 17 / 18
114
+ const loadedAsJsModule = euiVersionNumber >= 18;
115
+
116
+ if (loadedAsJsModule) {
117
+ return remotesUtils.createEntryJsFile(pkg, destPath, euiVersionNumber);
118
+ } else {
119
+ return remotesUtils.concatFiles(pkg, destPath, euiVersionNumber);
120
+ }
102
121
  })
103
122
 
104
123
  .then(() => {
105
- return remotesUtils.copyPackageJson(pkg.paths.root, rootDestPath, remoteEuiVersion);
124
+ // Note: it's limited to 18, but it could be applied to 15 / 16 / 17 / 18
125
+ const loadedAsJsModule = euiVersionNumber >= 18;
126
+
127
+ const name = loadedAsJsModule ? 'entry' : undefined;
128
+ return remotesUtils.copyPackageJson(pkg, pkg.paths.root, rootDestPath, remoteEuiVersion, name);
106
129
  })
107
130
 
108
131
  .then(() => {
@@ -112,4 +135,4 @@ module.exports.serve = (remote = false) => {
112
135
  .catch((e) => {
113
136
  throw e;
114
137
  });
115
- }
138
+ };