@elliemae/pui-cli 8.62.0 → 8.62.2

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.
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var versionPathMiddleware_exports = {};
20
+ __export(versionPathMiddleware_exports, {
21
+ versionedPathRewriteMiddleware: () => versionedPathRewriteMiddleware
22
+ });
23
+ module.exports = __toCommonJS(versionPathMiddleware_exports);
24
+ var import_helpers = require("../webpack/helpers.js");
25
+ const versionedPathRewriteMiddleware = (basePath) => {
26
+ const appVersion = (0, import_helpers.getAppVersion)();
27
+ if (appVersion === import_helpers.LATEST_VERSION) {
28
+ return (_req, _res, next) => next();
29
+ }
30
+ const normalizedBase = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath;
31
+ const versionPrefix = `${normalizedBase}/${appVersion}`;
32
+ const latestPrefix = `${normalizedBase}/latest`;
33
+ return (req, _res, next) => {
34
+ const url = req.url ?? "";
35
+ const queryIndex = url.indexOf("?");
36
+ const pathname = queryIndex === -1 ? url : url.slice(0, queryIndex);
37
+ const search = queryIndex === -1 ? "" : url.slice(queryIndex);
38
+ if (pathname === versionPrefix || pathname.startsWith(`${versionPrefix}/`)) {
39
+ const rewritten = pathname.replace(versionPrefix, latestPrefix);
40
+ req.url = rewritten + search;
41
+ }
42
+ next();
43
+ };
44
+ };
@@ -80,7 +80,11 @@ const jestConfig = {
80
80
  },
81
81
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
82
82
  setupFilesAfterEnv: [path.resolve(__dirname, './setup-tests.js')],
83
- setupFiles: ['raf/polyfill', 'whatwg-fetch'],
83
+ setupFiles: [
84
+ path.resolve(__dirname, './setup-env.js'),
85
+ 'raf/polyfill',
86
+ 'whatwg-fetch',
87
+ ],
84
88
  testRegex: '(app|lib).*/tests/.*\\.test\\.[jt]sx?$',
85
89
  snapshotSerializers: [],
86
90
  testResultsProcessor: 'jest-sonar-reporter',
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ const { TextDecoder, TextEncoder } = require("util");
3
+ if (global.TextEncoder === void 0) {
4
+ global.TextEncoder = TextEncoder;
5
+ }
6
+ if (global.TextDecoder === void 0) {
7
+ global.TextDecoder = TextDecoder;
8
+ }
@@ -42,6 +42,7 @@ __export(helpers_exports, {
42
42
  htmlFilesToExclude: () => htmlFilesToExclude,
43
43
  isAppLoaderEnabled: () => isAppLoaderEnabled,
44
44
  isGoogleTagManagerEnabled: () => isGoogleTagManagerEnabled,
45
+ isVersionedDevEnabled: () => isVersionedDevEnabled,
45
46
  mainFields: () => mainFields,
46
47
  mapToFolder: () => mapToFolder,
47
48
  modulesToTranspile: () => modulesToTranspile,
@@ -195,9 +196,12 @@ const getENCWLoaderFileName = () => {
195
196
  };
196
197
  const getAppVersion = () => {
197
198
  if (!process.env.APP_VERSION) return LATEST_VERSION;
198
- const match = process.env.APP_VERSION.match(/^v?(\d+\.\d+)\..*$/);
199
- return match && match[1] || LATEST_VERSION;
199
+ const semverMatch = process.env.APP_VERSION.match(/^v?(\d+\.\d+)\..*$/);
200
+ if (semverMatch?.[1]) return semverMatch[1];
201
+ const shortMatch = process.env.APP_VERSION.match(/^v?(\d+\.\d+)$/);
202
+ return shortMatch && shortMatch[1] || LATEST_VERSION;
200
203
  };
204
+ const isVersionedDevEnabled = () => getAppVersion() !== LATEST_VERSION;
201
205
  const getPaths = (latestVersion = true) => {
202
206
  const version = latestVersion ? LATEST_VERSION : getAppVersion();
203
207
  const publicPath = `${version}/`;
@@ -39,8 +39,10 @@ var import_circular_dependency_plugin = __toESM(require("circular-dependency-plu
39
39
  var import_mini_css_extract_plugin = __toESM(require("mini-css-extract-plugin"), 1);
40
40
  var import_react_refresh_webpack_plugin = __toESM(require("@pmmmwh/react-refresh-webpack-plugin"), 1);
41
41
  var import_express_static_gzip = __toESM(require("express-static-gzip"), 1);
42
+ var import_copy_webpack_plugin = __toESM(require("copy-webpack-plugin"), 1);
42
43
  var import_interceptor_middleware = require("./interceptor-middleware.js");
43
44
  var import_middlewares = require("../server/middlewares.js");
45
+ var import_versionPathMiddleware = require("../server/versionPathMiddleware.js");
44
46
  var import_appRoutes = require("../server/appRoutes.js");
45
47
  var import_helpers = require("./helpers.js");
46
48
  var import_webpack_base_babel = require("./webpack.base.babel.js");
@@ -60,7 +62,7 @@ const {
60
62
  diagnosticsScriptPath,
61
63
  encwLoaderScriptPath,
62
64
  logRocketScriptPath
63
- } = (0, import_helpers.getPaths)();
65
+ } = (0, import_helpers.getPaths)(!(0, import_helpers.isVersionedDevEnabled)());
64
66
  const serverOptions = {
65
67
  type: "https",
66
68
  options: (0, import_cert.getCertOptions)()
@@ -171,6 +173,14 @@ const devConfig = {
171
173
  server: (0, import_utils2.isHttps)() ? serverOptions : {},
172
174
  setupMiddlewares: (middlewares, devServer) => {
173
175
  (0, import_interceptor_middleware.addCSPNonceMiddleware)(middlewares);
176
+ if ((0, import_helpers.isVersionedDevEnabled)()) {
177
+ middlewares.unshift({
178
+ name: "versioned-path-rewrite",
179
+ middleware: (0, import_versionPathMiddleware.versionedPathRewriteMiddleware)(
180
+ basePath
181
+ )
182
+ });
183
+ }
174
184
  if (devServer.app) {
175
185
  (0, import_middlewares.setupDefaultMiddlewares)(devServer.app);
176
186
  (0, import_appRoutes.loadRoutes)(devServer.app).then(() => {
@@ -200,4 +210,16 @@ const devConfig = {
200
210
  };
201
211
  const config = (0, import_webpack_base_babel.baseConfig)(devConfig);
202
212
  config.plugins = config.plugins ? config.plugins.concat([new import_react_refresh_webpack_plugin.default({})]) : [];
213
+ if ((0, import_helpers.isVersionedDevEnabled)()) {
214
+ config.plugins = config.plugins.concat([
215
+ new import_copy_webpack_plugin.default({
216
+ patterns: (0, import_helpers.filterByFilePresence)([
217
+ {
218
+ from: "app/app.config.json",
219
+ to: `./${appVersion}/app.config.json`
220
+ }
221
+ ])
222
+ })
223
+ ]);
224
+ }
203
225
  var webpack_dev_babel_default = config;
@@ -0,0 +1,24 @@
1
+ import { getAppVersion, LATEST_VERSION } from "../webpack/helpers.js";
2
+ const versionedPathRewriteMiddleware = (basePath) => {
3
+ const appVersion = getAppVersion();
4
+ if (appVersion === LATEST_VERSION) {
5
+ return (_req, _res, next) => next();
6
+ }
7
+ const normalizedBase = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath;
8
+ const versionPrefix = `${normalizedBase}/${appVersion}`;
9
+ const latestPrefix = `${normalizedBase}/latest`;
10
+ return (req, _res, next) => {
11
+ const url = req.url ?? "";
12
+ const queryIndex = url.indexOf("?");
13
+ const pathname = queryIndex === -1 ? url : url.slice(0, queryIndex);
14
+ const search = queryIndex === -1 ? "" : url.slice(queryIndex);
15
+ if (pathname === versionPrefix || pathname.startsWith(`${versionPrefix}/`)) {
16
+ const rewritten = pathname.replace(versionPrefix, latestPrefix);
17
+ req.url = rewritten + search;
18
+ }
19
+ next();
20
+ };
21
+ };
22
+ export {
23
+ versionedPathRewriteMiddleware
24
+ };
@@ -80,7 +80,11 @@ const jestConfig = {
80
80
  },
81
81
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
82
82
  setupFilesAfterEnv: [path.resolve(__dirname, './setup-tests.js')],
83
- setupFiles: ['raf/polyfill', 'whatwg-fetch'],
83
+ setupFiles: [
84
+ path.resolve(__dirname, './setup-env.js'),
85
+ 'raf/polyfill',
86
+ 'whatwg-fetch',
87
+ ],
84
88
  testRegex: '(app|lib).*/tests/.*\\.test\\.[jt]sx?$',
85
89
  snapshotSerializers: [],
86
90
  testResultsProcessor: 'jest-sonar-reporter',
@@ -0,0 +1,7 @@
1
+ const { TextDecoder, TextEncoder } = require("util");
2
+ if (global.TextEncoder === void 0) {
3
+ global.TextEncoder = TextEncoder;
4
+ }
5
+ if (global.TextDecoder === void 0) {
6
+ global.TextDecoder = TextDecoder;
7
+ }
@@ -145,9 +145,12 @@ const getENCWLoaderFileName = () => {
145
145
  };
146
146
  const getAppVersion = () => {
147
147
  if (!process.env.APP_VERSION) return LATEST_VERSION;
148
- const match = process.env.APP_VERSION.match(/^v?(\d+\.\d+)\..*$/);
149
- return match && match[1] || LATEST_VERSION;
148
+ const semverMatch = process.env.APP_VERSION.match(/^v?(\d+\.\d+)\..*$/);
149
+ if (semverMatch?.[1]) return semverMatch[1];
150
+ const shortMatch = process.env.APP_VERSION.match(/^v?(\d+\.\d+)$/);
151
+ return shortMatch && shortMatch[1] || LATEST_VERSION;
150
152
  };
153
+ const isVersionedDevEnabled = () => getAppVersion() !== LATEST_VERSION;
151
154
  const getPaths = (latestVersion = true) => {
152
155
  const version = latestVersion ? LATEST_VERSION : getAppVersion();
153
156
  const publicPath = `${version}/`;
@@ -234,6 +237,7 @@ export {
234
237
  htmlFilesToExclude,
235
238
  isAppLoaderEnabled,
236
239
  isGoogleTagManagerEnabled,
240
+ isVersionedDevEnabled,
237
241
  mainFields,
238
242
  mapToFolder,
239
243
  modulesToTranspile,
@@ -6,13 +6,17 @@ import CircularDependencyPlugin from "circular-dependency-plugin";
6
6
  import MiniCssExtractPlugin from "mini-css-extract-plugin";
7
7
  import ReactRefreshWebpackPlugin from "@pmmmwh/react-refresh-webpack-plugin";
8
8
  import expressStaticGzip from "express-static-gzip";
9
+ import CopyWebpackPlugin from "copy-webpack-plugin";
9
10
  import { addCSPNonceMiddleware } from "./interceptor-middleware.js";
10
11
  import { setupDefaultMiddlewares } from "../server/middlewares.js";
12
+ import { versionedPathRewriteMiddleware } from "../server/versionPathMiddleware.js";
11
13
  import { loadRoutes } from "../server/appRoutes.js";
12
14
  import {
13
15
  isAppLoaderEnabled,
14
16
  getPaths,
15
- isGoogleTagManagerEnabled
17
+ isGoogleTagManagerEnabled,
18
+ isVersionedDevEnabled,
19
+ filterByFilePresence
16
20
  } from "./helpers.js";
17
21
  import { baseConfig } from "./webpack.base.babel.js";
18
22
  import { wsPort } from "../server/utils.js";
@@ -30,7 +34,7 @@ const {
30
34
  diagnosticsScriptPath,
31
35
  encwLoaderScriptPath,
32
36
  logRocketScriptPath
33
- } = getPaths();
37
+ } = getPaths(!isVersionedDevEnabled());
34
38
  const serverOptions = {
35
39
  type: "https",
36
40
  options: getCertOptions()
@@ -141,6 +145,14 @@ const devConfig = {
141
145
  server: isHttps() ? serverOptions : {},
142
146
  setupMiddlewares: (middlewares, devServer) => {
143
147
  addCSPNonceMiddleware(middlewares);
148
+ if (isVersionedDevEnabled()) {
149
+ middlewares.unshift({
150
+ name: "versioned-path-rewrite",
151
+ middleware: versionedPathRewriteMiddleware(
152
+ basePath
153
+ )
154
+ });
155
+ }
144
156
  if (devServer.app) {
145
157
  setupDefaultMiddlewares(devServer.app);
146
158
  loadRoutes(devServer.app).then(() => {
@@ -170,6 +182,18 @@ const devConfig = {
170
182
  };
171
183
  const config = baseConfig(devConfig);
172
184
  config.plugins = config.plugins ? config.plugins.concat([new ReactRefreshWebpackPlugin({})]) : [];
185
+ if (isVersionedDevEnabled()) {
186
+ config.plugins = config.plugins.concat([
187
+ new CopyWebpackPlugin({
188
+ patterns: filterByFilePresence([
189
+ {
190
+ from: "app/app.config.json",
191
+ to: `./${appVersion}/app.config.json`
192
+ }
193
+ ])
194
+ })
195
+ ]);
196
+ }
173
197
  var webpack_dev_babel_default = config;
174
198
  export {
175
199
  webpack_dev_babel_default as default
@@ -0,0 +1,8 @@
1
+ import type { NextFunction, Request, Response } from 'express';
2
+ /**
3
+ * Rewrites versioned asset URLs (e.g. /prospects/26.2/app.config.json) to the
4
+ * latest build output (/prospects/latest/...) during local dev when APP_VERSION is set.
5
+ * @param {string} basePath - The app base path prefix (e.g. /prospects).
6
+ * @returns {import('express').RequestHandler} Express middleware that rewrites versioned URLs.
7
+ */
8
+ export declare const versionedPathRewriteMiddleware: (basePath: string) => (_req: Request, _res: Response, next: NextFunction) => void;
@@ -0,0 +1 @@
1
+ export {};
@@ -23,6 +23,11 @@ export declare const getLibraryAlias: (name: string, alias: string) => {
23
23
  };
24
24
  export declare const modulesToTranspile: string[];
25
25
  export declare const getAppVersion: () => string;
26
+ /**
27
+ * Use versioned public paths in dev when APP_VERSION resolves to major.minor.
28
+ * @returns {boolean} True when versioned dev paths should be enabled.
29
+ */
30
+ export declare const isVersionedDevEnabled: () => boolean;
26
31
  export declare const getPaths: (latestVersion?: boolean) => {
27
32
  appVersion: string;
28
33
  buildPath: string;