@trackunit/iris-app-sdk-webpack 0.0.1-alpha-13ecf77e3fd.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.
Files changed (34) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.internal.md +5 -0
  3. package/README.md +26 -0
  4. package/package.json +29 -0
  5. package/src/executors/build/executor.d.ts +16 -0
  6. package/src/executors/build/executor.js +63 -0
  7. package/src/executors/build/executor.js.map +1 -0
  8. package/src/executors/build/webpack.d.ts +9 -0
  9. package/src/executors/build/webpack.js +40 -0
  10. package/src/executors/build/webpack.js.map +1 -0
  11. package/src/executors/serve/executor.d.ts +12 -0
  12. package/src/executors/serve/executor.js +54 -0
  13. package/src/executors/serve/executor.js.map +1 -0
  14. package/src/executors/serve/webpackDevServer.d.ts +12 -0
  15. package/src/executors/serve/webpackDevServer.js +35 -0
  16. package/src/executors/serve/webpackDevServer.js.map +1 -0
  17. package/src/executors/utils/checkPackageVersion.d.ts +30 -0
  18. package/src/executors/utils/checkPackageVersion.js +99 -0
  19. package/src/executors/utils/checkPackageVersion.js.map +1 -0
  20. package/src/executors/utils/defaultWebpackConfig.d.ts +13 -0
  21. package/src/executors/utils/defaultWebpackConfig.js +169 -0
  22. package/src/executors/utils/defaultWebpackConfig.js.map +1 -0
  23. package/src/executors/utils/irisAppServerSettings.d.ts +17 -0
  24. package/src/executors/utils/irisAppServerSettings.js +39 -0
  25. package/src/executors/utils/irisAppServerSettings.js.map +1 -0
  26. package/src/executors/utils/src/index.d.ts +0 -0
  27. package/src/executors/utils/src/index.js +3 -0
  28. package/src/executors/utils/src/index.js.map +1 -0
  29. package/src/executors/utils/version.d.ts +4 -0
  30. package/src/executors/utils/version.js +9 -0
  31. package/src/executors/utils/version.js.map +1 -0
  32. package/src/index.d.ts +0 -0
  33. package/src/index.js +2 -0
  34. package/src/index.js.map +1 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
+
5
+ ## 0.0.1-alpha-13ecf77e3fd.0 (2025-01-03)
@@ -0,0 +1,5 @@
1
+ To build use:
2
+ yarn nx run iris-app-sdk-webpack:build
3
+
4
+ To publish use:
5
+ npm publish ./dist/libs/iris-app-sdk/webpack/ --access public
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # Trackunit Iris App Sdk Webpack Bundler
2
+ The `@trackunit/iris-app-sdk-webpack` package contains a executor for webpack bundler used for IrisAppSDK development.
3
+
4
+ Trackunit Iris App SDK are used by developers to integrate custom functionality into [the Trackunit Manager platform](https://www.trackunit.com/services/manager/).
5
+
6
+ For more info and a full guide on Iris App SDK Development, please visit our [Developer Hub](https://developers.trackunit.com/).
7
+
8
+ ## Getting started
9
+
10
+ Run through the easy getting started guide here: [Getting Started](https://developers.trackunit.com/docs/getting-started)
11
+
12
+ ## Debugging Iris Apps (react-devtools)
13
+ Run a global install of [react-devtools](https://www.npmjs.com/package/react-devtools).
14
+ With volta:
15
+ `volta install react-devtools`
16
+
17
+ Run react-devtools from the terminal to launch the standalone DevTools app:
18
+ `react-devtools`
19
+
20
+ React-devtools will automatically connect to whichever Iris App is running in your browser at the given moment.
21
+
22
+ ## Trackunit
23
+ This package was developed by Trackunit ApS.
24
+ Trackunit is the leading SaaS-based IoT solution for the construction industry, offering an ecosystem of hardware, fleet management software & telematics.
25
+
26
+ ![The Trackunit logo](https://trackunit.com/wp-content/uploads/2022/03/top-logo.svg)
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@trackunit/iris-app-sdk-webpack",
3
+ "version": "0.0.1-alpha-13ecf77e3fd.0",
4
+ "license": "SEE LICENSE IN LICENSE.txt",
5
+ "repository": "https://github.com/Trackunit/manager",
6
+ "executors": "./executors.json",
7
+ "engines": {
8
+ "node": ">=20.x"
9
+ },
10
+ "dependencies": {
11
+ "@trackunit/iris-app-api": "*",
12
+ "@trackunit/iris-app-build-utilities": "*",
13
+ "@trackunit/shared-utils": "*",
14
+ "@trackunit/iris-app-webpack-plugin": "*",
15
+ "webpack": "5.88.1",
16
+ "tslib": "^2.6.2",
17
+ "@nx/devkit": "19.8.3",
18
+ "rxjs": "7.8.1",
19
+ "webpack-dev-server": "5.1.0",
20
+ "win-ca": "^3.5.1",
21
+ "pacote": "17.0.6",
22
+ "semver": "7.5.4",
23
+ "copy-webpack-plugin": "11.0.0",
24
+ "webpack-bundle-analyzer": "^4.8.0"
25
+ },
26
+ "main": "./src/index.js",
27
+ "type": "commonjs",
28
+ "types": "./src/index.d.ts"
29
+ }
@@ -0,0 +1,16 @@
1
+ import { ExecutorContext } from "@nx/devkit";
2
+ import "webpack-dev-server";
3
+ import "win-ca";
4
+ import { BuildExecutorSchema } from "./schema";
5
+ export type NodeBuildEvent = {
6
+ outfile: string;
7
+ success: boolean;
8
+ };
9
+ /**
10
+ * Build executor for building iris apps.
11
+ *
12
+ * @param {BuildExecutorSchema} options build executor options for this nx executor
13
+ * @param {ExecutorContext} context build executor context for this nx executor
14
+ * @yields {NodeBuildEvent} the build event
15
+ */
16
+ export default function (options: BuildExecutorSchema, context: ExecutorContext): AsyncGenerator<any, any, undefined>;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
4
+ const tslib_1 = require("tslib");
5
+ const rxjs_for_await_1 = require("@nx/devkit/src/utils/rxjs-for-await");
6
+ const iris_app_build_utilities_1 = require("@trackunit/iris-app-build-utilities");
7
+ const fs_1 = require("fs");
8
+ const path_1 = require("path");
9
+ const op = tslib_1.__importStar(require("rxjs/operators"));
10
+ require("webpack-dev-server");
11
+ require("win-ca");
12
+ const checkPackageVersion_1 = require("../utils/checkPackageVersion");
13
+ const defaultWebpackConfig_1 = require("../utils/defaultWebpackConfig");
14
+ const webpack_1 = require("./webpack");
15
+ const deleteOutputDir = (root, outputPath) => {
16
+ const resolvedOutputPath = (0, path_1.resolve)(root, outputPath);
17
+ if (resolvedOutputPath === root) {
18
+ throw new Error("Output path MUST not be project root directory!");
19
+ }
20
+ (0, fs_1.rmSync)(resolvedOutputPath, { recursive: true, force: true });
21
+ };
22
+ /**
23
+ * Build executor for building iris apps.
24
+ *
25
+ * @param {BuildExecutorSchema} options build executor options for this nx executor
26
+ * @param {ExecutorContext} context build executor context for this nx executor
27
+ * @yields {NodeBuildEvent} the build event
28
+ */
29
+ async function* default_1(options, context) {
30
+ await (0, checkPackageVersion_1.checkPackageVersion)(false);
31
+ if (!context.projectsConfigurations) {
32
+ throw new Error("context projectsConfigurations is required");
33
+ }
34
+ const projectRoot = context.projectsConfigurations.projects[context.projectName].root;
35
+ const projectRootDir = (0, path_1.join)(context.root, projectRoot);
36
+ const tileManifestPath = (0, path_1.join)(context.root, projectRoot, "iris-app-manifest.ts");
37
+ (0, iris_app_build_utilities_1.enableTsConfigPath)({
38
+ projectRootDir,
39
+ });
40
+ if (!options.webpackConfig) {
41
+ throw new Error("option.webpackConfig is required");
42
+ }
43
+ const IrisAppManifest = (await Promise.resolve(`${tileManifestPath}`).then(s => tslib_1.__importStar(require(s)))).default;
44
+ const defaultConfig = (0, defaultWebpackConfig_1.getDefaultConfig)("production", context.root, projectRootDir, IrisAppManifest);
45
+ const customConfigFile = await Promise.resolve(`${options.webpackConfig}`).then(s => tslib_1.__importStar(require(s)));
46
+ let config = customConfigFile.default(await defaultConfig);
47
+ const isPromise = config instanceof Promise;
48
+ if (isPromise) {
49
+ config = await config;
50
+ }
51
+ deleteOutputDir(context.root, options.outputPath);
52
+ const observable = (0, webpack_1.doRunWebpack)(config).pipe(op.tap(stats => {
53
+ // eslint-disable-next-line no-console
54
+ console.info(stats.toString(config.stats));
55
+ }), op.map(stats => {
56
+ return {
57
+ success: !stats.hasErrors(),
58
+ outfile: (0, path_1.resolve)(context.root, options.outputPath),
59
+ };
60
+ }));
61
+ return yield* (0, rxjs_for_await_1.eachValueFrom)(observable);
62
+ }
63
+ //# sourceMappingURL=executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/webpack/src/executors/build/executor.ts"],"names":[],"mappings":";;AAoCA,4BAsCC;;AAxED,wEAAoE;AACpE,kFAAyE;AACzE,2BAA4B;AAC5B,+BAAqC;AAErC,2DAAqC;AAErC,8BAA4B;AAC5B,kBAAgB;AAChB,sEAAmE;AACnE,wEAAiE;AAEjE,uCAAyC;AAOzC,MAAM,eAAe,GAAG,CAAC,IAAY,EAAE,UAAkB,EAAE,EAAE;IAC3D,MAAM,kBAAkB,GAAG,IAAA,cAAO,EAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IACrD,IAAI,kBAAkB,KAAK,IAAI,EAAE,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IACD,IAAA,WAAM,EAAC,kBAAkB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC/D,CAAC,CAAC;AAEF;;;;;;GAMG;AACY,KAAK,SAAS,CAAC,WAAE,OAA4B,EAAE,OAAwB;IACpF,MAAM,IAAA,yCAAmB,EAAC,KAAK,CAAC,CAAC;IACjC,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IACD,MAAM,WAAW,GAAG,OAAO,CAAC,sBAAsB,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAY,CAAE,CAAC,IAAI,CAAC;IACxF,MAAM,cAAc,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IACvD,MAAM,gBAAgB,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,sBAAsB,CAAC,CAAC;IACjF,IAAA,6CAAkB,EAAC;QACjB,cAAc;KACf,CAAC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-any */\nimport { ExecutorContext } from \"@nx/devkit\";\nimport { eachValueFrom } from \"@nx/devkit/src/utils/rxjs-for-await\";\nimport { enableTsConfigPath } from \"@trackunit/iris-app-build-utilities\";\nimport { rmSync } from \"fs\";\nimport { join, resolve } from \"path\";\nimport { Observable } from \"rxjs\";\nimport * as op from \"rxjs/operators\";\n\nimport \"webpack-dev-server\";\nimport \"win-ca\";\nimport { checkPackageVersion } from \"../utils/checkPackageVersion\";\nimport { getDefaultConfig } from \"../utils/defaultWebpackConfig\";\nimport { BuildExecutorSchema } from \"./schema\";\nimport { doRunWebpack } from \"./webpack\";\n\nexport type NodeBuildEvent = {\n outfile: string;\n success: boolean;\n};\n\nconst deleteOutputDir = (root: string, outputPath: string) => {\n const resolvedOutputPath = resolve(root, outputPath);\n if (resolvedOutputPath === root) {\n throw new Error(\"Output path MUST not be project root directory!\");\n }\n rmSync(resolvedOutputPath, { recursive: true, force: true });\n};\n\n/**\n * Build executor for building iris apps.\n *\n * @param {BuildExecutorSchema} options build executor options for this nx executor\n * @param {ExecutorContext} context build executor context for this nx executor\n * @yields {NodeBuildEvent} the build event\n */\nexport default async function* (options: BuildExecutorSchema, context: ExecutorContext) {\n await checkPackageVersion(false);\n if (!context.projectsConfigurations) {\n throw new Error(\"context projectsConfigurations is required\");\n }\n const projectRoot = context.projectsConfigurations.projects[context.projectName!]!.root;\n const projectRootDir = join(context.root, projectRoot);\n const tileManifestPath = join(context.root, projectRoot, \"iris-app-manifest.ts\");\n enableTsConfigPath({\n projectRootDir,\n });\n if (!options.webpackConfig) {\n throw new Error(\"option.webpackConfig is required\");\n }\n const IrisAppManifest = (await import(tileManifestPath)).default;\n const defaultConfig = getDefaultConfig(\"production\", context.root, projectRootDir, IrisAppManifest);\n\n const customConfigFile = await import(options.webpackConfig);\n\n let config = customConfigFile.default(await defaultConfig);\n const isPromise = config instanceof Promise;\n if (isPromise) {\n config = await config;\n }\n deleteOutputDir(context.root, options.outputPath);\n const observable = doRunWebpack(config).pipe(\n op.tap(stats => {\n // eslint-disable-next-line no-console\n console.info(stats.toString(config.stats));\n }),\n op.map(stats => {\n return {\n success: !stats.hasErrors(),\n outfile: resolve(context.root, options.outputPath),\n } as NodeBuildEvent;\n })\n );\n return yield* eachValueFrom(observable as unknown as Observable<any>);\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { Observable } from "rxjs";
2
+ import webpack = require("webpack");
3
+ /**
4
+ * Run webpack with the given configuration.
5
+ *
6
+ * @param {webpack.Configuration} config the webpack configuration
7
+ * @returns {*} {Observable<any>}
8
+ */
9
+ export declare function doRunWebpack(config: webpack.Configuration): Observable<webpack.Stats>;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.doRunWebpack = doRunWebpack;
4
+ const rxjs_1 = require("rxjs");
5
+ const webpack = require("webpack");
6
+ /**
7
+ * Run webpack with the given configuration.
8
+ *
9
+ * @param {webpack.Configuration} config the webpack configuration
10
+ * @returns {*} {Observable<any>}
11
+ */
12
+ function doRunWebpack(config) {
13
+ return new rxjs_1.Observable(subscriber => {
14
+ const { watch, ...normalizedConfig } = config;
15
+ const webpackCompiler = webpack(normalizedConfig);
16
+ const callback = (err, stats) => {
17
+ if (err) {
18
+ subscriber.error(err);
19
+ }
20
+ subscriber.next(stats);
21
+ };
22
+ if (config.watch) {
23
+ const watchOptions = config.watchOptions || {};
24
+ const watching = webpackCompiler.watch(watchOptions, callback);
25
+ return () => watching.close(() => subscriber.complete());
26
+ }
27
+ else {
28
+ return webpackCompiler.run((err, stats) => {
29
+ callback(err, stats);
30
+ webpackCompiler.close((closeErr) => {
31
+ if (closeErr) {
32
+ subscriber.error(closeErr);
33
+ }
34
+ subscriber.complete();
35
+ });
36
+ });
37
+ }
38
+ });
39
+ }
40
+ //# sourceMappingURL=webpack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webpack.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/webpack/src/executors/build/web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,CAAC","sourcesContent":["import { Observable } from \"rxjs\";\nimport webpack = require(\"webpack\");\n\n/**\n * Run webpack with the given configuration.\n *\n * @param {webpack.Configuration} config the webpack configuration\n * @returns {*} {Observable<any>}\n */\nexport function doRunWebpack(config: webpack.Configuration): Observable<webpack.Stats> {\n return new Observable(subscriber => {\n const { watch, ...normalizedConfig } = config;\n const webpackCompiler = webpack(normalizedConfig);\n\n const callback = (err: Error | null | undefined, stats: webpack.Stats | undefined) => {\n if (err) {\n subscriber.error(err);\n }\n subscriber.next(stats);\n };\n\n if (config.watch) {\n const watchOptions = config.watchOptions || {};\n const watching = webpackCompiler.watch(watchOptions, callback);\n return () => watching.close(() => subscriber.complete());\n } else {\n return webpackCompiler.run((err: Error | null | undefined, stats: webpack.Stats | undefined) => {\n callback(err, stats);\n webpackCompiler.close((closeErr: Error | null | undefined) => {\n if (closeErr) {\n subscriber.error(closeErr);\n }\n subscriber.complete();\n });\n });\n }\n });\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { ExecutorContext } from "@nx/devkit";
2
+ import "webpack-dev-server";
3
+ import "win-ca";
4
+ import { ServeExecutorSchema } from "./schema";
5
+ /**
6
+ * Serve executor for serving iris apps.
7
+ *
8
+ * @param {ServeExecutorSchema} options serve executor options for this nx executor
9
+ * @param {ExecutorContext} context serve executor context for this nx executor
10
+ * @yields {AsyncGenerator<any, void, unknown>} the serve observable
11
+ */
12
+ export default function (options: ServeExecutorSchema, context: ExecutorContext): AsyncGenerator<any, any, undefined>;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
4
+ const tslib_1 = require("tslib");
5
+ const rxjs_for_await_1 = require("@nx/devkit/src/utils/rxjs-for-await");
6
+ const iris_app_build_utilities_1 = require("@trackunit/iris-app-build-utilities");
7
+ const path_1 = require("path");
8
+ const op = tslib_1.__importStar(require("rxjs/operators"));
9
+ require("webpack-dev-server");
10
+ require("win-ca");
11
+ const checkPackageVersion_1 = require("../utils/checkPackageVersion");
12
+ const defaultWebpackConfig_1 = require("../utils/defaultWebpackConfig");
13
+ const webpackDevServer_1 = require("./webpackDevServer");
14
+ /**
15
+ * Serve executor for serving iris apps.
16
+ *
17
+ * @param {ServeExecutorSchema} options serve executor options for this nx executor
18
+ * @param {ExecutorContext} context serve executor context for this nx executor
19
+ * @yields {AsyncGenerator<any, void, unknown>} the serve observable
20
+ */
21
+ async function* default_1(options, context) {
22
+ await (0, checkPackageVersion_1.checkPackageVersion)(false);
23
+ if (!context.workspace) {
24
+ throw new Error("context workspace is required");
25
+ }
26
+ const projectRoot = context.workspace.projects[context.projectName].root;
27
+ const projectRootDir = (0, path_1.join)(context.root, projectRoot);
28
+ const tileManifestPath = (0, path_1.join)(context.root, projectRoot, "iris-app-manifest.ts");
29
+ (0, iris_app_build_utilities_1.enableTsConfigPath)({
30
+ projectRootDir,
31
+ });
32
+ if (!options.webpackConfig) {
33
+ throw new Error("option.webpackConfig is required");
34
+ }
35
+ const IrisAppManifest = (await Promise.resolve(`${tileManifestPath}`).then(s => tslib_1.__importStar(require(s)))).default;
36
+ const defaultConfig = (0, defaultWebpackConfig_1.getDefaultConfig)("development", context.root, projectRootDir, IrisAppManifest);
37
+ const customConfigFile = await Promise.resolve(`${options.webpackConfig}`).then(s => tslib_1.__importStar(require(s)));
38
+ let config = customConfigFile.default(await defaultConfig);
39
+ const isPromise = config instanceof Promise;
40
+ if (isPromise) {
41
+ config = await defaultConfig;
42
+ }
43
+ const observable = (0, webpackDevServer_1.doRunWebpackDevServer)(config).pipe(op.tap(({ stats }) => {
44
+ // eslint-disable-next-line no-console
45
+ console.info(stats.toString(config.stats));
46
+ }), op.map(({ baseUrl, stats }) => {
47
+ return {
48
+ baseUrl,
49
+ success: !stats.hasErrors(),
50
+ };
51
+ }));
52
+ return yield* (0, rxjs_for_await_1.eachValueFrom)(observable);
53
+ }
54
+ //# sourceMappingURL=executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/webpack/src/executors/serve/executor.ts"],"names":[],"mappings":";;AAwBA,4BAsCC;;AA5DD,wEAAoE;AACpE,kFAAyE;AACzE,+BAA4B;AAE5B,2DAAqC;AAErC,8BAA4B;AAC5B,kBAAgB;AAChB,sEAAmE;AACnE,wEAAiE;AAEjE,yDAA2D;AAI3D;;;;;;GAMG;AACY,KAAK,SAAS,CAAC,WAAE,OAA4B,EAAE,OAAwB;IACpF,MAAM,IAAA,yCAAmB,EAAC,KAAK,CAAC,CAAC;IACjC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IACD,MAAM,WAAW,GAAG,OAAO,CAAC,SAAS,CAAC,QAAS,CAAC,OAAO,CAAC,WAAY,CAAE,CAAC,IAAI,CAAC;IAC5E,MAAM,cAAc,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IACvD,MAAM,gBAAgB,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,sBAAsB,CAAC,CAAC;IACjF,IAAA,6CAAkB,EAAC;QACjB,cAAc;KACf,CAAC,CAAC;IACH,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IACD,MAAM,eAAe,GAAG,CAAC,yBAAa,gBAAgB,+CAAC,CAAC,CAAC,OAAO,CAAC;IACjE,MAAM,aAAa,GAAG,IAAA,uCAAgB,EAAC,aAAa,EAAE,OAAO,CAAC,IAAI,EAAE,cAAc,EAAE,eAAe,CAAC,CAAC;IACrG,MAAM,gBAAgB,GAAG,yBAAa,OAAO,CAAC,aAAa,+CAAC,CAAC;IAE7D,IAAI,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,MAAM,aAAa,CAAC,CAAC;IAC3D,MAAM,SAAS,GAAG,MAAM,YAAY,OAAO,CAAC;IAC5C,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,GAAG,MAAM,aAAa,CAAC;IAC/B,CAAC;IAED,MAAM,UAAU,GAAG,IAAA,wCAAqB,EAAC,MAAM,CAAC,CAAC,IAAI,CACnD,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;QACnB,sCAAsC;QACtC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAE,MAAgC,CAAC,KAAK,CAAC,CAAC,CAAC;IACxE,CAAC,CAAC,EACF,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE;QAC5B,OAAO;YACL,OAAO;YACP,OAAO,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE;SAC5B,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,KAAK,CAAC,CAAC,IAAA,8BAAa,EAAC,UAAwC,CAAC,CAAC;AACxE,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { ExecutorContext } from \"@nx/devkit\";\nimport { eachValueFrom } from \"@nx/devkit/src/utils/rxjs-for-await\";\nimport { enableTsConfigPath } from \"@trackunit/iris-app-build-utilities\";\nimport { join } from \"path\";\nimport { Observable } from \"rxjs\";\nimport * as op from \"rxjs/operators\";\n\nimport \"webpack-dev-server\";\nimport \"win-ca\";\nimport { checkPackageVersion } from \"../utils/checkPackageVersion\";\nimport { getDefaultConfig } from \"../utils/defaultWebpackConfig\";\nimport { ServeExecutorSchema } from \"./schema\";\nimport { doRunWebpackDevServer } from \"./webpackDevServer\";\n\nimport type webpack = require(\"webpack\");\n\n/**\n * Serve executor for serving iris apps.\n *\n * @param {ServeExecutorSchema} options serve executor options for this nx executor\n * @param {ExecutorContext} context serve executor context for this nx executor\n * @yields {AsyncGenerator<any, void, unknown>} the serve observable\n */\nexport default async function* (options: ServeExecutorSchema, context: ExecutorContext) {\n await checkPackageVersion(false);\n if (!context.workspace) {\n throw new Error(\"context workspace is required\");\n }\n const projectRoot = context.workspace.projects![context.projectName!]!.root;\n const projectRootDir = join(context.root, projectRoot);\n const tileManifestPath = join(context.root, projectRoot, \"iris-app-manifest.ts\");\n enableTsConfigPath({\n projectRootDir,\n });\n if (!options.webpackConfig) {\n throw new Error(\"option.webpackConfig is required\");\n }\n const IrisAppManifest = (await import(tileManifestPath)).default;\n const defaultConfig = getDefaultConfig(\"development\", context.root, projectRootDir, IrisAppManifest);\n const customConfigFile = await import(options.webpackConfig);\n\n let config = customConfigFile.default(await defaultConfig);\n const isPromise = config instanceof Promise;\n if (isPromise) {\n config = await defaultConfig;\n }\n\n const observable = doRunWebpackDevServer(config).pipe(\n op.tap(({ stats }) => {\n // eslint-disable-next-line no-console\n console.info(stats.toString((config as webpack.Configuration).stats));\n }),\n op.map(({ baseUrl, stats }) => {\n return {\n baseUrl,\n success: !stats.hasErrors(),\n };\n })\n );\n\n return yield* eachValueFrom(observable as unknown as Observable<any>);\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { Observable } from "rxjs";
2
+ import webpack = require("webpack");
3
+ /**
4
+ * Run webpack with the given configuration.
5
+ *
6
+ * @param config the input webpack configuration
7
+ * @returns { Observable<{ stats: webpack.Stats; baseUrl: string }> } the observable of webpack stats and base url
8
+ */
9
+ export declare function doRunWebpackDevServer(config: webpack.Configuration): Observable<{
10
+ stats: webpack.Stats;
11
+ baseUrl: string;
12
+ }>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.doRunWebpackDevServer = doRunWebpackDevServer;
4
+ const rxjs_1 = require("rxjs");
5
+ const WebpackDevServer = require("webpack-dev-server");
6
+ const webpack = require("webpack");
7
+ /**
8
+ * Run webpack with the given configuration.
9
+ *
10
+ * @param config the input webpack configuration
11
+ * @returns { Observable<{ stats: webpack.Stats; baseUrl: string }> } the observable of webpack stats and base url
12
+ */
13
+ function doRunWebpackDevServer(config) {
14
+ return new rxjs_1.Observable(subscriber => {
15
+ const webpackCompiler = webpack.webpack(config);
16
+ let baseUrl;
17
+ webpackCompiler.hooks.done.tap("build-webpack", stats => {
18
+ subscriber.next({ stats, baseUrl });
19
+ });
20
+ const devServerConfig = config.devServer || {};
21
+ const originalOnListen = devServerConfig.onListening;
22
+ devServerConfig.onListening = function (server) {
23
+ var _a;
24
+ if (originalOnListen) {
25
+ originalOnListen(server);
26
+ }
27
+ const devServerOptions = server.options;
28
+ baseUrl = `${server.options.server === "https" ? "https" : "http"}://${server.options.host}:${server.options.port}${(_a = devServerOptions.devMiddleware) === null || _a === void 0 ? void 0 : _a.publicPath}`;
29
+ };
30
+ const webpackServer = new WebpackDevServer(devServerConfig, webpackCompiler);
31
+ webpackServer.start().catch((err) => subscriber.error(err));
32
+ return () => webpackServer.stop();
33
+ });
34
+ }
35
+ //# sourceMappingURL=webpackDevServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webpackDevServer.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/webpack/src/executors/serve/webpackDevServer.ts"],"names":[],"mappings":";;AAUA,sDAiCC;AA3CD,+BAAkC;AAClC,uDAAwD;AACxD,mCAAoC;AAEpC;;;;;GAKG;AACH,SAAgB,qBAAqB,CACnC,MAA6B;IAE7B,OAAO,IAAI,iBAAU,CAAC,UAAU,CAAC,EAAE;QACjC,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAEhD,IAAI,OAAe,CAAC;QAEpB,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,KAAK,CAAC,EAAE;YACtD,UAAU,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;QAEH,MAAM,eAAe,GAAG,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC;QAE/C,MAAM,gBAAgB,GAAG,eAAe,CAAC,WAAW,CAAC;QAErD,eAAe,CAAC,WAAW,GAAG,UAAU,MAAwB;;YAC9D,IAAI,gBAAgB,EAAE,CAAC;gBACrB,gBAAgB,CAAC,MAAM,CAAC,CAAC;YAC3B,CAAC;YAED,MAAM,gBAAgB,GAAmC,MAAM,CAAC,OAAO,CAAC;YAExE,OAAO,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,IACxF,MAAM,CAAC,OAAO,CAAC,IACjB,GAAG,MAAA,gBAAgB,CAAC,aAAa,0CAAE,UAAU,EAAE,CAAC;QAClD,CAAC,CAAC;QAEF,MAAM,aAAa,GAAG,IAAI,gBAAgB,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC;QAE7E,aAAa,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,GAAU,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;QACnE,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { Observable } from \"rxjs\";\nimport WebpackDevServer = require(\"webpack-dev-server\");\nimport webpack = require(\"webpack\");\n\n/**\n * Run webpack with the given configuration.\n *\n * @param config the input webpack configuration\n * @returns { Observable<{ stats: webpack.Stats; baseUrl: string }> } the observable of webpack stats and base url\n */\nexport function doRunWebpackDevServer(\n config: webpack.Configuration\n): Observable<{ stats: webpack.Stats; baseUrl: string }> {\n return new Observable(subscriber => {\n const webpackCompiler = webpack.webpack(config);\n\n let baseUrl: string;\n\n webpackCompiler.hooks.done.tap(\"build-webpack\", stats => {\n subscriber.next({ stats, baseUrl });\n });\n\n const devServerConfig = config.devServer || {};\n\n const originalOnListen = devServerConfig.onListening;\n\n devServerConfig.onListening = function (server: WebpackDevServer) {\n if (originalOnListen) {\n originalOnListen(server);\n }\n\n const devServerOptions: WebpackDevServer.Configuration = server.options;\n\n baseUrl = `${server.options.server === \"https\" ? \"https\" : \"http\"}://${server.options.host}:${\n server.options.port\n }${devServerOptions.devMiddleware?.publicPath}`;\n };\n\n const webpackServer = new WebpackDevServer(devServerConfig, webpackCompiler);\n\n webpackServer.start().catch((err: Error) => subscriber.error(err));\n return () => webpackServer.stop();\n });\n}\n"]}
@@ -0,0 +1,30 @@
1
+ /**
2
+ *
3
+ * @param pkg package to look for.
4
+ * @param localRange local version of the package.
5
+ * @param range range
6
+ * @returns { boolean } true if its a valid version
7
+ */
8
+ export declare const versionCheck: (pkg: string, localRange: string, range: string, throwError?: boolean) => boolean;
9
+ /**
10
+ * Get the latest version of the package from the registry.
11
+ *
12
+ * @param pkg package to look for.
13
+ * @returns { Promise<string> } returns version
14
+ */
15
+ export declare const getLatestRemoteVersion: (pkg: string) => Promise<string>;
16
+ /**
17
+ * Check if the current version of the package is the same as the one in the manager.
18
+ *
19
+ * @param {string} managerNxVersion version of nx in the manager
20
+ * @returns { boolean} true if its a valid version
21
+ */
22
+ export declare function checkNxVersion(managerNxVersion: string, throwError?: boolean): Promise<boolean>;
23
+ /**
24
+ *
25
+ */
26
+ export declare function checkTrackunitPackages(dependencies: Record<string, string>, throwError?: boolean): Promise<boolean>;
27
+ /**
28
+ *
29
+ */
30
+ export declare function checkPackageVersion(throwError?: boolean): Promise<boolean>;
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLatestRemoteVersion = exports.versionCheck = void 0;
4
+ exports.checkNxVersion = checkNxVersion;
5
+ exports.checkTrackunitPackages = checkTrackunitPackages;
6
+ exports.checkPackageVersion = checkPackageVersion;
7
+ const tslib_1 = require("tslib");
8
+ const devkit_1 = require("@nx/devkit");
9
+ const shared_utils_1 = require("@trackunit/shared-utils");
10
+ const child_process_1 = require("child_process");
11
+ const pacote = tslib_1.__importStar(require("pacote"));
12
+ const semver = tslib_1.__importStar(require("semver"));
13
+ /**
14
+ *
15
+ * @param pkg package to look for.
16
+ * @param localRange local version of the package.
17
+ * @param range range
18
+ * @returns { boolean } true if its a valid version
19
+ */
20
+ const versionCheck = (pkg, localRange, range, throwError = true) => {
21
+ var _a, _b;
22
+ const localVersion = (_a = semver.minVersion(localRange)) !== null && _a !== void 0 ? _a : localRange; // ('^1.0.0') => '1.0.0'
23
+ const remoteVersion = (_b = semver.minVersion(range)) !== null && _b !== void 0 ? _b : range; // Assume range is in a format that semver.minVersion can handle
24
+ if (!semver.satisfies(localVersion, range)) {
25
+ const msg = `Package "${pkg}" outdated. Remote Version: ${range} Local version: ${localRange}. 👈\n Update package using command: \n npm i ${pkg}@${range}\n ...or to update all trackunit dependencies: \n npx npm-check-updates "/@trackunit/" -u`;
26
+ if (semver.major(localVersion) < semver.major(remoteVersion) && throwError) {
27
+ throw new Error(msg);
28
+ }
29
+ else {
30
+ // eslint-disable-next-line no-console
31
+ console.warn("⚠️ " + msg + "\n");
32
+ return true;
33
+ }
34
+ }
35
+ return true;
36
+ };
37
+ exports.versionCheck = versionCheck;
38
+ /**
39
+ * Get the latest version of the package from the registry.
40
+ *
41
+ * @param pkg package to look for.
42
+ * @returns { Promise<string> } returns version
43
+ */
44
+ const getLatestRemoteVersion = async (pkg) => {
45
+ try {
46
+ const manifest = await pacote.manifest(pkg);
47
+ return manifest.version;
48
+ }
49
+ catch (error) {
50
+ throw new Error(`Error fetching manifest for package ${pkg}. This package might need to be published, or it has been included as a dependency by mistake.`);
51
+ }
52
+ };
53
+ exports.getLatestRemoteVersion = getLatestRemoteVersion;
54
+ /**
55
+ * Check if the current version of the package is the same as the one in the manager.
56
+ *
57
+ * @param {string} managerNxVersion version of nx in the manager
58
+ * @returns { boolean} true if its a valid version
59
+ */
60
+ async function checkNxVersion(managerNxVersion, throwError = true) {
61
+ const currentNxVersion = (0, child_process_1.execSync)("nx --version")
62
+ .toString("utf-8")
63
+ .replace(/\r?\n|\r/, ""); // regex removes any line breaks
64
+ return (0, exports.versionCheck)("nx", currentNxVersion, managerNxVersion, throwError);
65
+ }
66
+ /**
67
+ *
68
+ */
69
+ async function checkTrackunitPackages(dependencies, throwError = true) {
70
+ for (const key in dependencies) {
71
+ const remoteVersion = await (0, exports.getLatestRemoteVersion)(key);
72
+ if (remoteVersion) {
73
+ const localDependencyVersion = dependencies[key];
74
+ // If @trackunit dependencies are linked/added locally using "file:", skip the version check, used for E2E tests.
75
+ if (localDependencyVersion && !localDependencyVersion.includes("file:")) {
76
+ (0, exports.versionCheck)(key, localDependencyVersion, remoteVersion, throwError);
77
+ }
78
+ }
79
+ }
80
+ return true;
81
+ }
82
+ function getLibraries() {
83
+ const packageJsonLocal = (0, devkit_1.readJsonFile)("package.json");
84
+ const trackunitDependencies = (0, shared_utils_1.objectFromEntries)(Object.entries(packageJsonLocal.dependencies || {}).filter(([key]) => key.startsWith("@trackunit/")));
85
+ const trackunitDevDependencies = (0, shared_utils_1.objectFromEntries)(Object.entries(packageJsonLocal.devDependencies || {}).filter(([key]) => key.startsWith("@trackunit/")));
86
+ return { trackunitDependencies, trackunitDevDependencies };
87
+ }
88
+ /**
89
+ *
90
+ */
91
+ async function checkPackageVersion(throwError = true) {
92
+ const { trackunitDependencies, trackunitDevDependencies } = getLibraries();
93
+ // const managerNxVersion = version.managerNxVersion;
94
+ // await checkNxVersion(managerNxVersion, throwError);
95
+ await checkTrackunitPackages(trackunitDependencies, throwError);
96
+ await checkTrackunitPackages(trackunitDevDependencies, throwError);
97
+ return true;
98
+ }
99
+ //# sourceMappingURL=checkPackageVersion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkPackageVersion.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/webpack/src/executors/utils/checkPackageVersion.ts"],"names":[],"mappings":";;;AAqDA,wCAKC;AAKD,wDAYC;AAgBD,kDAOC;;AAlG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,CAAC,aAAa,CAAC,CAAC,CACrG,CAAC;IACF,MAAM,wBAAwB,GAAG,IAAA,gCAAiB,EAChD,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CACxG,CAAC;IACF,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,CAAC;AAC7D,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,mBAAmB,CAAC,UAAU,GAAG,IAAI;IACzD,MAAM,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,GAAG,YAAY,EAAE,CAAC;IAC3E,qDAAqD;IACrD,sDAAsD;IACtD,MAAM,sBAAsB,CAAC,qBAAqB,EAAE,UAAU,CAAC,CAAC;IAChE,MAAM,sBAAsB,CAAC,wBAAwB,EAAE,UAAU,CAAC,CAAC;IACnE,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import { readJsonFile } from \"@nx/devkit\";\nimport { objectFromEntries } from \"@trackunit/shared-utils\";\nimport { execSync } from \"child_process\";\nimport * as pacote from \"pacote\";\nimport * as semver from \"semver\";\n\n/**\n *\n * @param pkg package to look for.\n * @param localRange local version of the package.\n * @param range range\n * @returns { boolean } true if its a valid version\n */\nexport const versionCheck = (pkg: string, localRange: string, range: string, throwError = true) => {\n const localVersion = semver.minVersion(localRange) ?? localRange; // ('^1.0.0') => '1.0.0'\n const remoteVersion = semver.minVersion(range) ?? range; // Assume range is in a format that semver.minVersion can handle\n\n if (!semver.satisfies(localVersion, range)) {\n const msg = `Package \"${pkg}\" outdated. Remote Version: ${range} Local version: ${localRange}. 👈\\n Update package using command: \\n npm i ${pkg}@${range}\\n ...or to update all trackunit dependencies: \\n npx npm-check-updates \"/@trackunit/\" -u`;\n if (semver.major(localVersion) < semver.major(remoteVersion) && throwError) {\n throw new Error(msg);\n } else {\n // eslint-disable-next-line no-console\n console.warn(\"⚠️ \" + msg + \"\\n\");\n return true;\n }\n }\n return true;\n};\n\n/**\n * Get the latest version of the package from the registry.\n *\n * @param pkg package to look for.\n * @returns { Promise<string> } returns version\n */\nexport const getLatestRemoteVersion = async (pkg: string) => {\n try {\n const manifest = await pacote.manifest(pkg);\n return manifest.version;\n } catch (error) {\n throw new Error(\n `Error fetching manifest for package ${pkg}. This package might need to be published, or it has been included as a dependency by mistake.`\n );\n }\n};\n\n/**\n * Check if the current version of the package is the same as the one in the manager.\n *\n * @param {string} managerNxVersion version of nx in the manager\n * @returns { boolean} true if its a valid version\n */\nexport async function checkNxVersion(managerNxVersion: string, throwError = true) {\n const currentNxVersion = execSync(\"nx --version\")\n .toString(\"utf-8\")\n .replace(/\\r?\\n|\\r/, \"\"); // regex removes any line breaks\n return versionCheck(\"nx\", currentNxVersion, managerNxVersion, throwError);\n}\n\n/**\n *\n */\nexport async function checkTrackunitPackages(dependencies: Record<string, string>, throwError = true) {\n for (const key in dependencies) {\n const remoteVersion: string | undefined = await getLatestRemoteVersion(key);\n if (remoteVersion) {\n const localDependencyVersion: string | undefined = dependencies[key];\n // If @trackunit dependencies are linked/added locally using \"file:\", skip the version check, used for E2E tests.\n if (localDependencyVersion && !localDependencyVersion.includes(\"file:\")) {\n versionCheck(key, localDependencyVersion, remoteVersion, throwError);\n }\n }\n }\n return true;\n}\n\nfunction getLibraries() {\n const packageJsonLocal: Record<string, string | Record<string, string>> = readJsonFile(\"package.json\");\n const trackunitDependencies = objectFromEntries(\n Object.entries(packageJsonLocal.dependencies || {}).filter(([key]) => key.startsWith(\"@trackunit/\"))\n );\n const trackunitDevDependencies = objectFromEntries(\n Object.entries(packageJsonLocal.devDependencies || {}).filter(([key]) => key.startsWith(\"@trackunit/\"))\n );\n return { trackunitDependencies, trackunitDevDependencies };\n}\n\n/**\n *\n */\nexport async function checkPackageVersion(throwError = true) {\n const { trackunitDependencies, trackunitDevDependencies } = getLibraries();\n // const managerNxVersion = version.managerNxVersion;\n // await checkNxVersion(managerNxVersion, throwError);\n await checkTrackunitPackages(trackunitDependencies, throwError);\n await checkTrackunitPackages(trackunitDevDependencies, throwError);\n return true;\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import { IrisAppManifest } from "@trackunit/iris-app-api";
2
+ import * as webpack from "webpack";
3
+ import "webpack-dev-server";
4
+ /**
5
+ * Gets the default webpack config.
6
+ *
7
+ * @param mode mode either "production" or "development"
8
+ * @param nxRootDir the root of the nx workspace
9
+ * @param appDir the app directory
10
+ * @param irisAppManifest the iris app manifest
11
+ * @returns { Promise<webpack.Configuration> } the default webpack config
12
+ */
13
+ export declare const getDefaultConfig: (mode: "production" | "development", nxRootDir: string, appDir: string, irisAppManifest: IrisAppManifest) => Promise<webpack.Configuration>;
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDefaultConfig = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const iris_app_api_1 = require("@trackunit/iris-app-api");
6
+ const iris_app_build_utilities_1 = require("@trackunit/iris-app-build-utilities");
7
+ const iris_app_webpack_plugin_1 = require("@trackunit/iris-app-webpack-plugin");
8
+ const shared_utils_1 = require("@trackunit/shared-utils");
9
+ const path = tslib_1.__importStar(require("path"));
10
+ const webpack = tslib_1.__importStar(require("webpack"));
11
+ require("webpack-dev-server");
12
+ let BundleAnalyzerPlugin = null;
13
+ if (process.env.BUNDLE_ANALYSE === "true") {
14
+ // doing require here to avoid dependency on webpack-bundle-analyzer directly
15
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
16
+ const BundleAnalyzerPluginConstructor = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
17
+ BundleAnalyzerPlugin = new BundleAnalyzerPluginConstructor({ analyzerMode: "static" });
18
+ }
19
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
20
+ const CopyWebpackPlugin = require("copy-webpack-plugin");
21
+ /**
22
+ * Gets the default webpack config.
23
+ *
24
+ * @param mode mode either "production" or "development"
25
+ * @param nxRootDir the root of the nx workspace
26
+ * @param appDir the app directory
27
+ * @param irisAppManifest the iris app manifest
28
+ * @returns { Promise<webpack.Configuration> } the default webpack config
29
+ */
30
+ const getDefaultConfig = async (mode, nxRootDir, appDir, irisAppManifest) => {
31
+ const relativeAppDir = appDir.split(nxRootDir)[1] || "<unknown appdir>";
32
+ const iconPaths = irisAppManifest.extensions
33
+ .map(extension => {
34
+ if (extension.type === "FLEET_EXTENSION" && extension.menuItem.image && (0, iris_app_api_1.isIconByPath)(extension.menuItem.image)) {
35
+ return {
36
+ extensionId: extension.id,
37
+ path: extension.menuItem.image.path,
38
+ sourceRoot: extension.sourceRoot,
39
+ };
40
+ }
41
+ return null;
42
+ })
43
+ .filter(shared_utils_1.truthy);
44
+ return {
45
+ mode: mode,
46
+ output: {
47
+ publicPath: "auto",
48
+ path: path.join(nxRootDir, "dist", relativeAppDir),
49
+ },
50
+ entry: {},
51
+ devtool: false,
52
+ devServer: await (0, iris_app_build_utilities_1.getIrisAppWebpackDevServer)(),
53
+ resolve: {
54
+ extensions: [".tsx", ".ts", ".jsx", ".js", ".json"],
55
+ alias: await (0, iris_app_build_utilities_1.getAliasesFromTsConfig)({ nxRootDir }),
56
+ },
57
+ module: {
58
+ rules: [
59
+ {
60
+ test: /\.svg$/,
61
+ issuer: /\.[jt]sx?$/,
62
+ use: ["@svgr/webpack", "file-loader"],
63
+ },
64
+ {
65
+ test: /\.m?js/,
66
+ type: "javascript/auto",
67
+ resolve: {
68
+ fullySpecified: false,
69
+ },
70
+ },
71
+ {
72
+ test: /\.(png|jpe?g|gif|eot|ttf|ico|woff|woff2)$/,
73
+ exclude: /(node_modules)/,
74
+ type: "asset/resource",
75
+ },
76
+ {
77
+ test: /\.(png|jpe?g|gif|svg|eot|ttf|ico|woff|woff2)$/i,
78
+ include: /(node_modules\/@okta)/,
79
+ type: "asset/resource",
80
+ },
81
+ {
82
+ test: /\.(css|s[ac]ss)$/i,
83
+ use: [
84
+ "style-loader",
85
+ "css-loader",
86
+ {
87
+ loader: "postcss-loader",
88
+ options: {
89
+ postcssOptions: {
90
+ plugins: {
91
+ "postcss-import": {},
92
+ "tailwindcss/nesting": {},
93
+ tailwindcss: {
94
+ config: path.resolve(appDir, "tailwind.config.js"),
95
+ },
96
+ autoprefixer: {},
97
+ },
98
+ },
99
+ },
100
+ },
101
+ ],
102
+ },
103
+ {
104
+ test: /\.json$/,
105
+ loader: "json-loader",
106
+ },
107
+ {
108
+ test: /\.(j|t)sx?$/,
109
+ exclude: /(vendor|node_modules|dist)/,
110
+ use: {
111
+ loader: "esbuild-loader",
112
+ options: {
113
+ jsx: "automatic",
114
+ target: "es6",
115
+ define: {
116
+ "process.env.IRIS_APP_SENTRY_DSN": JSON.stringify(""),
117
+ "process.env.IRIS_APP_VERSION": JSON.stringify(""),
118
+ },
119
+ },
120
+ },
121
+ },
122
+ ],
123
+ },
124
+ plugins: [
125
+ new webpack.container.ModuleFederationPlugin({
126
+ name: irisAppManifest.moduleFederationName,
127
+ filename: "remoteEntry.js",
128
+ library: { type: "global", name: irisAppManifest.moduleFederationName },
129
+ remotes: {},
130
+ exposes: await (0, iris_app_build_utilities_1.getExposedExtensions)({
131
+ nxRootDir,
132
+ manifest: irisAppManifest,
133
+ }),
134
+ shared: await (0, iris_app_build_utilities_1.getSharedDependencies)({ manifest: irisAppManifest }),
135
+ }),
136
+ new iris_app_webpack_plugin_1.TrackunitIrisAppWebpackPlugin({
137
+ nxRootDir: nxRootDir,
138
+ appDir,
139
+ manifest: irisAppManifest,
140
+ }),
141
+ new CopyWebpackPlugin({
142
+ patterns: [
143
+ ...irisAppManifest.extensions
144
+ .filter(extension => extension.type === "LIFECYCLE_EXTENSION")
145
+ .map(extension => ({
146
+ //globs must use / in path to be valid
147
+ from: extension.sourceRoot.replace(/\\/g, "/"),
148
+ to: path.join(nxRootDir, "dist", relativeAppDir, "serverside", extension.id),
149
+ })),
150
+ {
151
+ //globs must use / in path to be valid
152
+ from: path
153
+ .join(path.resolve(relativeAppDir.substring(1), "assets"), "**", "(*.png|*.svg|*.jpg|*.jpeg|*.webp|*.md)")
154
+ .replace(/\\/g, "/"),
155
+ to: path.resolve(nxRootDir, "dist"),
156
+ },
157
+ ...iconPaths.map(iconPath => ({
158
+ //globs must use / in path to be valid
159
+ from: path.join(iconPath.sourceRoot, iconPath.path).replace(/\\/g, "/"),
160
+ to: path.join(nxRootDir, "dist", relativeAppDir, iconPath.extensionId, iconPath.path),
161
+ })),
162
+ ],
163
+ }),
164
+ BundleAnalyzerPlugin,
165
+ ].filter(Boolean),
166
+ };
167
+ };
168
+ exports.getDefaultConfig = getDefaultConfig;
169
+ //# sourceMappingURL=defaultWebpackConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultWebpackConfig.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/webpack/src/executors/utils/defaultWebpackConfig.ts"],"names":[],"mappings":";;;;AAAA,0DAAwE;AACxE,kFAK6C;AAC7C,gFAAmF;AACnF,0DAAiD;AACjD,mDAA6B;AAC7B,yDAAmC;AACnC,8BAA4B;AAE5B,IAAI,oBAAoB,GAAyC,IAAI,CAAC;AACtE,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,KAAK,MAAM,EAAE,CAAC;IAC1C,6EAA6E;IAC7E,8DAA8D;IAC9D,MAAM,+BAA+B,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC,oBAAoB,CAAC;IAChG,oBAAoB,GAAG,IAAI,+BAA+B,CAAC,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC,CAAC;AACzF,CAAC;AAED,8DAA8D;AAC9D,MAAM,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AAEzD;;;;;;;;GAQG;AACI,MAAM,gBAAgB,GAAG,KAAK,EACnC,IAAkC,EAClC,SAAiB,EACjB,MAAc,EACd,eAAgC,EACA,EAAE;IAClC,MAAM,cAAc,GAAG,MAAM,CAAC,KA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wBACvE,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,IAAI,CAAC;qBACtF,CAAC,CAAC;iBACJ;aACF,CAAC;YACF,oBAAoB;SACrB,CAAC,MAAM,CAAC,OAAO,CAAC;KAClB,CAAC;AACJ,CAAC,CAAC;AAnJW,QAAA,gBAAgB,oBAmJ3B","sourcesContent":["import { IrisAppManifest, isIconByPath } from \"@trackunit/iris-app-api\";\nimport {\n getAliasesFromTsConfig,\n getExposedExtensions,\n getIrisAppWebpackDevServer,\n getSharedDependencies,\n} from \"@trackunit/iris-app-build-utilities\";\nimport { TrackunitIrisAppWebpackPlugin } from \"@trackunit/iris-app-webpack-plugin\";\nimport { truthy } from \"@trackunit/shared-utils\";\nimport * as path from \"path\";\nimport * as webpack from \"webpack\";\nimport \"webpack-dev-server\";\n\nlet BundleAnalyzerPlugin: webpack.WebpackPluginInstance | null = null;\nif (process.env.BUNDLE_ANALYSE === \"true\") {\n // doing require here to avoid dependency on webpack-bundle-analyzer directly\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const BundleAnalyzerPluginConstructor = require(\"webpack-bundle-analyzer\").BundleAnalyzerPlugin;\n BundleAnalyzerPlugin = new BundleAnalyzerPluginConstructor({ analyzerMode: \"static\" });\n}\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst CopyWebpackPlugin = require(\"copy-webpack-plugin\");\n\n/**\n * Gets the default webpack config.\n *\n * @param mode mode either \"production\" or \"development\"\n * @param nxRootDir the root of the nx workspace\n * @param appDir the app directory\n * @param irisAppManifest the iris app manifest\n * @returns { Promise<webpack.Configuration> } the default webpack config\n */\nexport const getDefaultConfig = async (\n mode: \"production\" | \"development\",\n nxRootDir: string,\n appDir: string,\n irisAppManifest: IrisAppManifest\n): Promise<webpack.Configuration> => {\n const relativeAppDir = appDir.split(nxRootDir)[1] || \"<unknown appdir>\";\n\n const iconPaths = irisAppManifest.extensions\n .map(extension => {\n if (extension.type === \"FLEET_EXTENSION\" && extension.menuItem.image && isIconByPath(extension.menuItem.image)) {\n return {\n extensionId: extension.id,\n path: extension.menuItem.image.path,\n sourceRoot: extension.sourceRoot,\n };\n }\n return null;\n })\n .filter(truthy);\n\n return {\n mode: mode,\n output: {\n publicPath: \"auto\",\n path: path.join(nxRootDir, \"dist\", relativeAppDir),\n },\n\n entry: {},\n devtool: false,\n devServer: await getIrisAppWebpackDevServer(),\n resolve: {\n extensions: [\".tsx\", \".ts\", \".jsx\", \".js\", \".json\"],\n alias: await getAliasesFromTsConfig({ nxRootDir }),\n },\n module: {\n rules: [\n {\n test: /\\.svg$/,\n issuer: /\\.[jt]sx?$/,\n use: [\"@svgr/webpack\", \"file-loader\"],\n },\n {\n test: /\\.m?js/,\n type: \"javascript/auto\",\n resolve: {\n fullySpecified: false,\n },\n },\n {\n test: /\\.(png|jpe?g|gif|eot|ttf|ico|woff|woff2)$/,\n exclude: /(node_modules)/,\n type: \"asset/resource\",\n },\n {\n test: /\\.(png|jpe?g|gif|svg|eot|ttf|ico|woff|woff2)$/i,\n include: /(node_modules\\/@okta)/,\n type: \"asset/resource\",\n },\n {\n test: /\\.(css|s[ac]ss)$/i,\n use: [\n \"style-loader\",\n \"css-loader\",\n {\n loader: \"postcss-loader\",\n options: {\n postcssOptions: {\n plugins: {\n \"postcss-import\": {},\n \"tailwindcss/nesting\": {},\n tailwindcss: {\n config: path.resolve(appDir, \"tailwind.config.js\"),\n },\n autoprefixer: {},\n },\n },\n },\n },\n ],\n },\n {\n test: /\\.json$/,\n loader: \"json-loader\",\n },\n {\n test: /\\.(j|t)sx?$/,\n exclude: /(vendor|node_modules|dist)/,\n use: {\n loader: \"esbuild-loader\",\n options: {\n jsx: \"automatic\",\n target: \"es6\",\n define: {\n \"process.env.IRIS_APP_SENTRY_DSN\": JSON.stringify(\"\"),\n \"process.env.IRIS_APP_VERSION\": JSON.stringify(\"\"),\n },\n },\n },\n },\n ],\n },\n\n plugins: [\n new webpack.container.ModuleFederationPlugin({\n name: irisAppManifest.moduleFederationName,\n filename: \"remoteEntry.js\",\n library: { type: \"global\", name: irisAppManifest.moduleFederationName },\n remotes: {},\n exposes: await getExposedExtensions({\n nxRootDir,\n manifest: irisAppManifest,\n }),\n shared: await getSharedDependencies({ manifest: irisAppManifest }),\n }),\n\n new TrackunitIrisAppWebpackPlugin({\n nxRootDir: nxRootDir,\n appDir,\n manifest: irisAppManifest,\n }),\n new CopyWebpackPlugin({\n patterns: [\n ...irisAppManifest.extensions\n .filter(extension => extension.type === \"LIFECYCLE_EXTENSION\")\n .map(extension => ({\n //globs must use / in path to be valid\n from: extension.sourceRoot.replace(/\\\\/g, \"/\"),\n to: path.join(nxRootDir, \"dist\", relativeAppDir, \"serverside\", extension.id),\n })),\n {\n //globs must use / in path to be valid\n from: path\n .join(path.resolve(relativeAppDir.substring(1), \"assets\"), \"**\", \"(*.png|*.svg|*.jpg|*.jpeg|*.webp|*.md)\")\n .replace(/\\\\/g, \"/\"),\n to: path.resolve(nxRootDir, \"dist\"),\n },\n ...iconPaths.map(iconPath => ({\n //globs must use / in path to be valid\n from: path.join(iconPath.sourceRoot, iconPath.path).replace(/\\\\/g, \"/\"),\n to: path.join(nxRootDir, \"dist\", relativeAppDir, iconPath.extensionId, iconPath.path),\n })),\n ],\n }),\n BundleAnalyzerPlugin,\n ].filter(Boolean),\n };\n};\n"]}
@@ -0,0 +1,17 @@
1
+ export type Settings = {
2
+ approvalUrl: URL;
3
+ repoUrl: URL;
4
+ env: string;
5
+ devTermsAccept: boolean;
6
+ };
7
+ /**
8
+ * Provides the settings for the Iris App server based on the environment.
9
+ */
10
+ export declare function getSettings(): Settings;
11
+ /**
12
+ * Provides the base URL for the Iris App server based on the environment.
13
+ *
14
+ * @param {string} env The environment to get the base URL for.
15
+ * @returns {URL} The base URL for the Iris App server.
16
+ */
17
+ export declare function getBaseUrl(env: string): URL;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSettings = getSettings;
4
+ exports.getBaseUrl = getBaseUrl;
5
+ /**
6
+ * Provides the settings for the Iris App server based on the environment.
7
+ */
8
+ function getSettings() {
9
+ var _a, _b, _c;
10
+ const env = (_b = (_a = process.env.TU_ENV) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== null && _b !== void 0 ? _b : "PROD";
11
+ const baseUrl = getBaseUrl(env);
12
+ const devTermsAccept = ((_c = process.env.TU_DEV_TERMS_AND_CONDITIONS) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === "accept";
13
+ return {
14
+ approvalUrl: new URL("approve/", baseUrl),
15
+ repoUrl: new URL("repo/", baseUrl),
16
+ env,
17
+ devTermsAccept,
18
+ };
19
+ }
20
+ /**
21
+ * Provides the base URL for the Iris App server based on the environment.
22
+ *
23
+ * @param {string} env The environment to get the base URL for.
24
+ * @returns {URL} The base URL for the Iris App server.
25
+ */
26
+ function getBaseUrl(env) {
27
+ var _a, _b, _c;
28
+ switch (env.toUpperCase()) {
29
+ case "PROD":
30
+ return new URL((_a = process.env.BASE_URL) !== null && _a !== void 0 ? _a : "https://iris.trackunit.app/");
31
+ case "STAGE":
32
+ return new URL((_b = process.env.BASE_URL) !== null && _b !== void 0 ? _b : "https://stage.iris.trackunit.app/");
33
+ case "DEV":
34
+ return new URL((_c = process.env.BASE_URL) !== null && _c !== void 0 ? _c : "https://dev.iris.trackunit.app/");
35
+ default:
36
+ throw new Error(`Unknown environment: ${env}`);
37
+ }
38
+ }
39
+ //# sourceMappingURL=irisAppServerSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"irisAppServerSettings.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/webpack/src/executors/utils/irisAppServerSettings.ts"],"names":[],"mappings":";;AAUA,kCAWC;AAQD,gCAWC;AAjCD;;GAEG;AACH,SAAgB,WAAW;;IACzB,MAAM,GAAG,GAAG,MAAA,MAAA,OAAO,CAAC,GAAG,CAAC,MAAM,0CAAE,WAAW,EAAE,mCAAI,MAAM,CAAC;IACxD,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAChC,MAAM,cAAc,GAAG,CAAA,MAAA,OAAO,CAAC,GAAG,CAAC,2BAA2B,0CAAE,WAAW,EAAE,MAAK,QAAQ,CAAC;IAE3F,OAAO;QACL,WAAW,EAAE,IAAI,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC;QACzC,OAAO,EAAE,IAAI,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC;QAClC,GAAG;QACH,cAAc;KACf,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,UAAU,CAAC,GAAW;;IACpC,QAAQ,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC;QAC1B,KAAK,MAAM;YACT,OAAO,IAAI,GAAG,CAAC,MAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,mCAAI,6BAA6B,CAAC,CAAC;QACxE,KAAK,OAAO;YACV,OAAO,IAAI,GAAG,CAAC,MAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,mCAAI,mCAAmC,CAAC,CAAC;QAC9E,KAAK,KAAK;YACR,OAAO,IAAI,GAAG,CAAC,MAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,mCAAI,iCAAiC,CAAC,CAAC;QAC5E;YACE,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC","sourcesContent":["export type Settings = {\n approvalUrl: URL;\n repoUrl: URL;\n env: string;\n devTermsAccept: boolean;\n};\n\n/**\n * Provides the settings for the Iris App server based on the environment.\n */\nexport function getSettings(): Settings {\n const env = process.env.TU_ENV?.toUpperCase() ?? \"PROD\";\n const baseUrl = getBaseUrl(env);\n const devTermsAccept = process.env.TU_DEV_TERMS_AND_CONDITIONS?.toLowerCase() === \"accept\";\n\n return {\n approvalUrl: new URL(\"approve/\", baseUrl),\n repoUrl: new URL(\"repo/\", baseUrl),\n env,\n devTermsAccept,\n };\n}\n\n/**\n * Provides the base URL for the Iris App server based on the environment.\n *\n * @param {string} env The environment to get the base URL for.\n * @returns {URL} The base URL for the Iris App server.\n */\nexport function getBaseUrl(env: string) {\n switch (env.toUpperCase()) {\n case \"PROD\":\n return new URL(process.env.BASE_URL ?? \"https://iris.trackunit.app/\");\n case \"STAGE\":\n return new URL(process.env.BASE_URL ?? \"https://stage.iris.trackunit.app/\");\n case \"DEV\":\n return new URL(process.env.BASE_URL ?? \"https://dev.iris.trackunit.app/\");\n default:\n throw new Error(`Unknown environment: ${env}`);\n }\n}\n"]}
File without changes
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // Empty ts file for webpack to be happy - we generate module federated js files instead
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../libs/iris-app-sdk/webpack/src/executors/utils/src/index.js"],"names":[],"mappings":";AAAA,wFAAwF","sourcesContent":["// Empty ts file for webpack to be happy - we generate module federated js files instead\n"]}
@@ -0,0 +1,4 @@
1
+ export declare const version: {
2
+ managerNxVersion: string;
3
+ managerNodeVersion: string;
4
+ };
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.version = void 0;
4
+ // The major version of NX and Node specified here will be matched with corresponding versions in the iris app.
5
+ exports.version = {
6
+ managerNxVersion: "^19.8.3",
7
+ managerNodeVersion: "^20.14.0",
8
+ };
9
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/webpack/src/executors/utils/version.ts"],"names":[],"mappings":";;;AAAA,+GAA+G;AAClG,QAAA,OAAO,GAAG;IACrB,gBAAgB,EAAE,SAAS;IAC3B,kBAAkB,EAAE,UAAU;CAC/B,CAAC","sourcesContent":["// The major version of NX and Node specified here will be matched with corresponding versions in the iris app.\nexport const version = {\n managerNxVersion: \"^19.8.3\",\n managerNodeVersion: \"^20.14.0\",\n};\n"]}
package/src/index.d.ts ADDED
File without changes
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/iris-app-sdk/webpack/src/index.ts"],"names":[],"mappings":"","sourcesContent":[""]}