@elliemae/pui-cli 6.13.0-beta.1 → 7.0.0-beta.1

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,20 +1,24 @@
1
1
  const { exit } = require('yargs');
2
+ const path = require('path');
2
3
  const {
3
4
  exec,
4
5
  logInfo,
5
6
  logError,
6
7
  logSuccess,
7
8
  writeAppInfo,
9
+ copyBuildAssetsToVersionedFolder,
8
10
  } = require('./utils');
9
11
  const { esBuild, TARGETS } = require('../transpile/esbuild');
10
12
 
11
- const { name } = require('../../package.json');
12
-
13
13
  async function buildWebApp() {
14
14
  await exec(`rimraf ./build`);
15
15
  await exec(
16
- `cross-env NODE_ENV=production webpack --config node_modules/${name}/lib/webpack/webpack.prod.babel.js --color`,
16
+ `cross-env NODE_ENV=production webpack --config ${path.resolve(
17
+ __dirname,
18
+ '../webpack/webpack.prod.babel.js',
19
+ )} --color`,
17
20
  );
21
+ await copyBuildAssetsToVersionedFolder();
18
22
  await writeAppInfo();
19
23
  }
20
24
 
@@ -1,17 +1,22 @@
1
+ const path = require('path');
1
2
  const { exit } = require('yargs');
2
3
  const { exec, logError, logSuccess } = require('./utils');
3
4
 
4
- const { name } = require('../../package.json');
5
-
6
5
  async function startProdServer() {
7
6
  await exec(
8
- `cross-env NODE_ENV=production ts-node node_modules/${name}/lib/server --color always`,
7
+ `cross-env NODE_ENV=production ts-node ${path.resolve(
8
+ __dirname,
9
+ '../server',
10
+ )} --color always`,
9
11
  );
10
12
  }
11
13
 
12
14
  async function startDevServer() {
13
15
  await exec(
14
- `cross-env NODE_ENV=development ts-node node_modules/${name}/lib/server --color always`,
16
+ `cross-env NODE_ENV=development webpack serve --config ${path.resolve(
17
+ __dirname,
18
+ '../webpack/webpack.dev.babel.js',
19
+ )}`,
15
20
  );
16
21
  }
17
22
 
@@ -1,9 +1,21 @@
1
+ /* eslint-disable max-lines */
1
2
  /* eslint-disable no-console */
2
3
  const execa = require('execa');
3
4
  const chalk = require('chalk');
4
5
  const path = require('path');
5
- const { readFile, writeFile } = require('fs/promises');
6
- const { getPaths } = require('../webpack/helpers');
6
+ const {
7
+ readFile,
8
+ writeFile,
9
+ mkdir,
10
+ readdir,
11
+ copyFile,
12
+ } = require('fs/promises');
13
+ const {
14
+ getPaths,
15
+ isAppLoaderEnabled,
16
+ getAppVersion,
17
+ LATEST_VERSION,
18
+ } = require('../webpack/helpers');
7
19
 
8
20
  const browsersMapping = {
9
21
  and_chr: 'Chrome for Android',
@@ -87,3 +99,29 @@ exports.writeAppInfo = async () => {
87
99
  path.join(process.cwd(), 'build', 'public', 'info.json'),
88
100
  ].forEach(async (infoPath) => writeFile(infoPath, infoJSON));
89
101
  };
102
+
103
+ const copyDir = async (src, dest) => {
104
+ const entries = await readdir(src, {
105
+ withFileTypes: true,
106
+ });
107
+ await mkdir(dest);
108
+ return Promise.all(
109
+ entries.map((entry) => {
110
+ const srcPath = path.join(src, entry.name);
111
+ const destPath = path.join(dest, entry.name);
112
+ if (entry.isDirectory()) {
113
+ return copyDir(srcPath, destPath);
114
+ }
115
+ return copyFile(srcPath, destPath);
116
+ }),
117
+ );
118
+ };
119
+
120
+ exports.copyBuildAssetsToVersionedFolder = async () => {
121
+ const appVersion = getAppVersion();
122
+ const isVersionedApp = isAppLoaderEnabled() && appVersion !== LATEST_VERSION;
123
+ if (!isVersionedApp) return;
124
+ const src = path.resolve(process.cwd(), 'build/public/latest');
125
+ const dest = path.resolve(process.cwd(), `build/public/${appVersion}`);
126
+ copyDir(src, dest);
127
+ };
@@ -150,7 +150,6 @@ const getENCWLoaderFileName = () => {
150
150
  )[0];
151
151
  };
152
152
 
153
- // base path for index page
154
153
  const getAssetPath = () => (process.env.ASSET_PATH || '/').replace(/\/?$/, '/');
155
154
 
156
155
  const getAppVersion = () => {
@@ -161,19 +160,19 @@ const getAppVersion = () => {
161
160
 
162
161
  const getPaths = (latestVersion = true) => {
163
162
  const version = latestVersion ? LATEST_VERSION : getAppVersion();
164
- const publicPath = `${getAssetPath()}${version}/`;
163
+ const publicPath = `${version}/`;
165
164
  const timeStampQuery =
166
165
  process.env.PUI_PIPELINE !== 'true' ? `?timeStamp=${Date.now()}` : '';
167
166
  return {
168
167
  appVersion: version,
169
- buildPath: path.resolve(process.cwd(), `build/public/${version}`),
168
+ buildPath: path.resolve(process.cwd(), `build/public/`),
170
169
  // base path for all assets
171
170
  publicPath,
172
- userMonScriptPath: `${publicPath}js/${getUserMonitoringFileName()}`,
173
- appLoaderScriptPath: `${publicPath}js/${getAppLoaderFileName()}`,
174
- diagnosticsScriptPath: `${publicPath}js/${getDiagnosticsFileName()}`,
175
- globalScriptPath: `${publicPath}js/global.js${timeStampQuery}`,
176
- encwLoaderScriptPath: `${publicPath}js/${getENCWLoaderFileName()}`,
171
+ userMonScriptPath: `latest/js/${getUserMonitoringFileName()}`,
172
+ appLoaderScriptPath: `latest/js/${getAppLoaderFileName()}`,
173
+ diagnosticsScriptPath: `latest/js/${getDiagnosticsFileName()}`,
174
+ globalScriptPath: `latest/js/global.js${timeStampQuery}`,
175
+ encwLoaderScriptPath: `latest/js/${getENCWLoaderFileName()}`,
177
176
  };
178
177
  };
179
178
 
@@ -227,6 +226,7 @@ const filterByFilePresence = (patterns) =>
227
226
  !noErrorOnMissing || fs.existsSync(path.resolve(process.cwd(), from)),
228
227
  );
229
228
 
229
+ exports.LATEST_VERSION = LATEST_VERSION;
230
230
  exports.excludeNodeModulesExcept = excludeNodeModulesExcept;
231
231
  exports.getLibraryName = getLibraryName;
232
232
  exports.getAppConfig = getAppConfig;
@@ -48,46 +48,47 @@ const plugins = [
48
48
  patterns: filterByFilePresence([
49
49
  {
50
50
  from: 'app/app.config.json',
51
- to: 'app.config.json',
51
+ to: './latest/app.config.json',
52
52
  },
53
53
  {
54
54
  from: 'app/robots.txt',
55
- to: '../robots.txt',
55
+ to: 'robots.txt',
56
56
  noErrorOnMissing: true,
57
57
  },
58
58
  {
59
59
  from: 'app/global*.js',
60
- to: 'js/[name][ext]',
60
+ to: './latest/js/[name][ext]',
61
61
  },
62
62
  {
63
63
  from: 'node_modules/@elliemae/pui-user-monitoring/dist/public/js',
64
- to: 'js',
64
+ to: './latest/js',
65
65
  toType: 'dir',
66
66
  info: { minimized: true },
67
67
  },
68
68
  {
69
69
  from: 'node_modules/@elliemae/pui-app-loader/dist/public/js',
70
- to: 'js',
70
+ to: './latest/js',
71
71
  toType: 'dir',
72
72
  noErrorOnMissing: true,
73
73
  info: { minimized: true },
74
74
  },
75
75
  {
76
76
  from: 'node_modules/@elliemae/encw-loader/dist/public/js',
77
- to: 'js',
77
+ to: './latest/js',
78
78
  toType: 'dir',
79
79
  noErrorOnMissing: true,
80
80
  info: { minimized: true },
81
81
  },
82
82
  {
83
83
  from: 'node_modules/@elliemae/pui-diagnostics/dist/public/js',
84
- to: 'js',
84
+ to: './latest/js',
85
85
  toType: 'dir',
86
86
  noErrorOnMissing: true,
87
87
  info: { minimized: true },
88
88
  },
89
89
  {
90
90
  from: 'public',
91
+ to: './latest',
91
92
  noErrorOnMissing: true,
92
93
  globOptions: {
93
94
  ignore: ['readme.md'],
@@ -95,7 +96,6 @@ const plugins = [
95
96
  },
96
97
  {
97
98
  from: 'webroot',
98
- to: '../',
99
99
  noErrorOnMissing: true,
100
100
  globOptions: {
101
101
  ignore: ['readme.md'],
@@ -105,8 +105,16 @@ const plugins = [
105
105
  }),
106
106
  new DuplicatePackageCheckerPlugin(),
107
107
  new MomentLocalesPlugin({ localesToKeep: ['es-us'] }),
108
- new WebpackManifestPlugin(),
108
+ new WebpackManifestPlugin({
109
+ fileName: './latest/manifest.json',
110
+ publicPath: '',
111
+ map: (file) => {
112
+ file.name = file.name.replace(/^latest\//, '');
113
+ return file;
114
+ },
115
+ }),
109
116
  new FaviconsWebpackPlugin({
117
+ outputPath: './latest/assets',
110
118
  logo: './app/view/images/favicon.png',
111
119
  favicons: {
112
120
  developerName: 'ICE MT',
@@ -1,5 +1,4 @@
1
1
  const path = require('path');
2
- const { HotModuleReplacementPlugin } = require('webpack');
3
2
  const HtmlWebpackPlugin = require('html-webpack-plugin');
4
3
  const CircularDependencyPlugin = require('circular-dependency-plugin');
5
4
  const MiniCssExtractPlugin = require('mini-css-extract-plugin');
@@ -74,7 +73,6 @@ const devConfig = {
74
73
  // Add development plugins
75
74
  plugins: [
76
75
  new HtmlWebpackPlugin({
77
- scriptLoading: 'module',
78
76
  inject: !isAppLoaderEnabled(), // Inject all files that are generated by webpack, e.g. bundle.js
79
77
  template: !isAppLoaderEnabled()
80
78
  ? 'app/index.html'
@@ -104,11 +102,12 @@ const devConfig = {
104
102
  performance: {
105
103
  hints: false,
106
104
  },
105
+
106
+ devServer: {},
107
107
  };
108
108
 
109
109
  const config = smp.wrap(baseConfigFactory(devConfig));
110
110
  config.plugins = config.plugins.concat([
111
- new HotModuleReplacementPlugin(),
112
111
  new ReactRefreshWebpackPlugin({
113
112
  overlay: {
114
113
  sockIntegration: 'whm',
@@ -11,9 +11,7 @@ const browserslistToEsbuild = require('browserslist-to-esbuild');
11
11
  const baseConfigFactory = require('./webpack.base.babel');
12
12
  const {
13
13
  isAppLoaderEnabled,
14
- LATEST_VERSION,
15
14
  getPaths,
16
- getAppVersion,
17
15
  isGoogleTagManagerEnabled,
18
16
  getCompressionPlugins,
19
17
  } = require('./helpers');
@@ -32,9 +30,9 @@ const getProdConfig = ({ latestVersion = true } = {}) => {
32
30
  output: {
33
31
  path: buildPath,
34
32
  publicPath: 'auto',
35
- filename: 'js/[name].[contenthash].js',
36
- chunkFilename: 'js/[name].[contenthash].chunk.js',
37
- assetModuleFilename: 'assets/[name].[hash][ext][query]',
33
+ filename: 'latest/js/[name].[contenthash].js',
34
+ chunkFilename: 'latest/js/[name].[contenthash].chunk.js',
35
+ assetModuleFilename: 'latest/assets/[name].[hash][ext][query]',
38
36
  },
39
37
 
40
38
  optimization: {
@@ -63,11 +61,6 @@ const getProdConfig = ({ latestVersion = true } = {}) => {
63
61
  },
64
62
 
65
63
  plugins: [
66
- // new MiniCssExtractPlugin({
67
- // filename: 'css/[name].[contenthash].css',
68
- // chunkFilename: 'css/[name].[contenthash].chunk.css',
69
- // }),
70
-
71
64
  ...getCompressionPlugins(),
72
65
 
73
66
  new BundleAnalyzerPlugin({
@@ -77,7 +70,7 @@ const getProdConfig = ({ latestVersion = true } = {}) => {
77
70
  }),
78
71
 
79
72
  new GenerateSW({
80
- swDest: '../sw.js',
73
+ swDest: 'sw.js',
81
74
  clientsClaim: true,
82
75
  skipWaiting: true,
83
76
  }),
@@ -100,8 +93,6 @@ const {
100
93
  encwLoaderScriptPath,
101
94
  } = getPaths();
102
95
  const htmlWebpackPlugin = new HtmlWebpackPlugin({
103
- scriptLoading: 'module',
104
- filename: '../index.html',
105
96
  inject: !isAppLoaderEnabled(),
106
97
  template: !isAppLoaderEnabled()
107
98
  ? 'app/index.html'
@@ -129,33 +120,21 @@ const htmlWebpackPlugin = new HtmlWebpackPlugin({
129
120
  },
130
121
  });
131
122
 
132
- // user want to version the web app to support backward compatible releases
133
- const isVersionedApp =
134
- isAppLoaderEnabled() && getAppVersion() !== LATEST_VERSION;
135
-
136
- const latestVersionConfig = baseConfigFactory(getProdConfig());
137
- latestVersionConfig.plugins.push(htmlWebpackPlugin);
123
+ const config = baseConfigFactory(getProdConfig());
124
+ config.plugins.push(htmlWebpackPlugin);
138
125
 
139
- const appVersionConfig = baseConfigFactory(
140
- getProdConfig({ latestVersion: false }),
141
- );
142
-
143
- const addSMPPlugin = (config) => {
126
+ const addSMPPlugin = (webpackConfig) => {
144
127
  const smpConfig = new SpeedMeasurePlugin({
145
128
  disable: !process.env.MEASURE,
146
- }).wrap(config);
129
+ }).wrap(webpackConfig);
147
130
  // mini css extract plugin is not working fine with smp
148
131
  smpConfig.plugins.push(
149
132
  new MiniCssExtractPlugin({
150
- filename: 'css/[name].[contenthash].css',
151
- chunkFilename: 'css/[name].[contenthash].chunk.css',
133
+ filename: 'latest/css/[name].[contenthash].css',
134
+ chunkFilename: 'latest/css/[name].[contenthash].chunk.css',
152
135
  }),
153
136
  );
154
137
  return smpConfig;
155
138
  };
156
139
 
157
- const config = isVersionedApp
158
- ? [latestVersionConfig, appVersionConfig].map(addSMPPlugin)
159
- : addSMPPlugin(latestVersionConfig);
160
-
161
- module.exports = config;
140
+ module.exports = addSMPPlugin(config);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elliemae/pui-cli",
3
- "version": "6.13.0-beta.1",
3
+ "version": "7.0.0-beta.1",
4
4
  "private": false,
5
5
  "description": "ICE MT UI Platform CLI",
6
6
  "sideEffects": false,
@@ -67,9 +67,9 @@
67
67
  "@commitlint/config-conventional": "~16.2.1",
68
68
  "@elliemae/browserslist-config-elliemae-latest-browsers": "~1.3.0",
69
69
  "@faker-js/faker": "6.0.0",
70
- "@nrwl/cli": "13.9.1",
71
- "@nrwl/tao": "13.9.1",
72
- "@nrwl/workspace": "13.9.1",
70
+ "@nrwl/cli": "13.9.3",
71
+ "@nrwl/tao": "13.9.3",
72
+ "@nrwl/workspace": "13.9.3",
73
73
  "@pmmmwh/react-refresh-webpack-plugin": "~0.5.4",
74
74
  "@semantic-release/changelog": "~6.0.1",
75
75
  "@semantic-release/exec": "~6.0.3",
@@ -87,7 +87,7 @@
87
87
  "@stylelint/postcss-css-in-js": "~0.37.2",
88
88
  "@svgr/webpack": "~6.2.1",
89
89
  "@swc/cli": "~0.1.55",
90
- "@swc/core": "~1.2.156",
90
+ "@swc/core": "~1.2.158",
91
91
  "@swc/jest": "~0.2.20",
92
92
  "@testing-library/jest-dom": "~5.16.2",
93
93
  "@testing-library/react": "~12.1.4",
@@ -137,7 +137,7 @@
137
137
  "eslint": "~8.11.0",
138
138
  "eslint-config-airbnb": "~19.0.4",
139
139
  "eslint-config-airbnb-base": "~15.0.0",
140
- "eslint-config-airbnb-typescript": "~16.1.2",
140
+ "eslint-config-airbnb-typescript": "~16.1.3",
141
141
  "eslint-config-prettier": "~8.5.0",
142
142
  "eslint-config-react-app": "~7.0.0",
143
143
  "eslint-import-resolver-babel-module": "~5.3.1",
@@ -180,7 +180,7 @@
180
180
  "jscodeshift": "~0.13.1",
181
181
  "jsdoc": "~3.6.10",
182
182
  "lerna": "~4.0.0",
183
- "lint-staged": "~12.3.6",
183
+ "lint-staged": "~12.3.7",
184
184
  "mini-css-extract-plugin": "~2.6.0",
185
185
  "minimist": "~1.2.5",
186
186
  "moment": "~2.29.1",
@@ -190,10 +190,10 @@
190
190
  "node-plop": "~0.30.0",
191
191
  "nodemon": "~2.0.15",
192
192
  "normalize-path": "~3.0.0",
193
- "npm-check-updates": "12.5.3",
193
+ "npm-check-updates": "12.5.4",
194
194
  "null-loader": "~4.0.1",
195
- "pino": "~7.8.1",
196
- "pino-pretty": "~7.5.3",
195
+ "pino": "~7.9.1",
196
+ "pino-pretty": "~7.5.4",
197
197
  "pinst": "~3.0.0",
198
198
  "plop": "~3.0.5",
199
199
  "postcss": "~8.4.12",
@@ -218,7 +218,7 @@
218
218
  "slackify-markdown": "~4.3.1",
219
219
  "speed-measure-webpack-plugin": "~1.5.0",
220
220
  "storybook-addon-turbo-build": "~1.1.0",
221
- "storybook-builder-vite": "~0.1.20",
221
+ "storybook-builder-vite": "~0.1.21",
222
222
  "storybook-react-router": "~1.0.8",
223
223
  "style-loader": "~3.3.1",
224
224
  "stylelint": "~14.6.0",
@@ -233,11 +233,12 @@
233
233
  "url-loader": "~4.1.1",
234
234
  "uuid": "~8.3.2",
235
235
  "vite": "~2.8.6",
236
- "vitest": "~0.6.3",
237
- "webpack": "~5.65.0",
236
+ "vitest": "~0.7.4",
237
+ "webpack": "~5.70.0",
238
238
  "webpack-bundle-analyzer": "~4.5.0",
239
239
  "webpack-cli": "~4.9.2",
240
240
  "webpack-dev-middleware": "~5.3.1",
241
+ "webpack-dev-server": "~4.7.4",
241
242
  "webpack-hot-middleware": "~2.25.1",
242
243
  "webpack-manifest-plugin": "~5.0.0",
243
244
  "webpack-merge": "~5.8.0",