@trackunit/iris-app 0.0.180 → 0.0.183
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.
- package/CHANGELOG.md +17 -0
- package/package.json +59 -5
- package/src/executors/build/executor.d.ts +7 -1
- package/src/executors/build/executor.js +9 -4
- package/src/executors/build/executor.js.map +1 -1
- package/src/executors/build/webpack.d.ts +7 -1
- package/src/executors/build/webpack.js +6 -1
- package/src/executors/build/webpack.js.map +1 -1
- package/src/executors/publish/executor.d.ts +6 -0
- package/src/executors/publish/executor.js +6 -0
- package/src/executors/publish/executor.js.map +1 -1
- package/src/executors/serve/executor.d.ts +7 -0
- package/src/executors/serve/executor.js +7 -0
- package/src/executors/serve/executor.js.map +1 -1
- package/src/executors/serve/webpackDevServer.d.ts +6 -0
- package/src/executors/serve/webpackDevServer.js +6 -0
- package/src/executors/serve/webpackDevServer.js.map +1 -1
- package/src/executors/utils/checkPackageVersion.d.ts +33 -2
- package/src/executors/utils/checkPackageVersion.js +40 -15
- package/src/executors/utils/checkPackageVersion.js.map +1 -1
- package/src/executors/utils/defaultWebpackConfig.d.ts +9 -0
- package/src/executors/utils/defaultWebpackConfig.js +9 -0
- package/src/executors/utils/defaultWebpackConfig.js.map +1 -1
- package/src/generators/create/files/tailwind.config.js__template__ +3 -8
- package/src/generators/create/generator.d.ts +8 -0
- package/src/generators/create/generator.js +8 -0
- package/src/generators/create/generator.js.map +1 -1
- package/src/generators/extend/generator.d.ts +8 -1
- package/src/generators/extend/generator.js +15 -8
- package/src/generators/extend/generator.js.map +1 -1
- package/src/utils/addDevDependency.d.ts +16 -2
- package/src/utils/addDevDependency.js +36 -24
- package/src/utils/addDevDependency.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.0.183](https://github.com/Trackunit/manager/compare/iris-app/0.0.182...iris-app/0.0.183) (2023-03-29)
|
|
6
|
+
|
|
7
|
+
### Dependency Updates
|
|
8
|
+
|
|
9
|
+
* `iris-app-build-utilities` updated to version `0.0.92`
|
|
10
|
+
## [0.0.182](https://github.com/Trackunit/manager/compare/iris-app/0.0.181...iris-app/0.0.182) (2023-03-28)
|
|
11
|
+
|
|
12
|
+
### Dependency Updates
|
|
13
|
+
|
|
14
|
+
* `iris-app-build-utilities` updated to version `0.0.91`
|
|
15
|
+
## [0.0.181](https://github.com/Trackunit/manager/compare/iris-app/0.0.180...iris-app/0.0.181) (2023-03-27)
|
|
16
|
+
|
|
17
|
+
### Dependency Updates
|
|
18
|
+
|
|
19
|
+
* `iris-app-build-utilities` updated to version `0.0.90`
|
|
20
|
+
* `iris-app-api` updated to version `0.0.80`
|
|
21
|
+
* `iris-app-webpack-plugin` updated to version `0.0.90`
|
|
5
22
|
## [0.0.180](https://github.com/Trackunit/manager/compare/iris-app/0.0.179...iris-app/0.0.180) (2023-03-24)
|
|
6
23
|
|
|
7
24
|
### Dependency Updates
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/iris-app",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.183",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"generators": "./generators.json",
|
|
@@ -12,9 +12,64 @@
|
|
|
12
12
|
"react-dom": "18.2.0",
|
|
13
13
|
"echarts": "^5.4.0",
|
|
14
14
|
"penpal": "^6.2.2",
|
|
15
|
-
"@trackunit/iris-app-build-utilities": "0.0.
|
|
15
|
+
"@trackunit/iris-app-build-utilities": "0.0.92",
|
|
16
16
|
"tsconfig-paths": "3.14.1",
|
|
17
|
-
"@trackunit/iris-app-api": "0.0.
|
|
17
|
+
"@trackunit/iris-app-api": "0.0.80",
|
|
18
|
+
"@trackunit/css-components": "0.0.296",
|
|
19
|
+
"@trackunit/react-components": "0.1.65",
|
|
20
|
+
"@trackunit/css-core": "0.0.74",
|
|
21
|
+
"@trackunit/ui-design-tokens": "0.0.60",
|
|
22
|
+
"@trackunit/tailwind-styled-components": "0.0.54",
|
|
23
|
+
"react-use": "17.4.0",
|
|
24
|
+
"date-fns": "2.29.3",
|
|
25
|
+
"react-day-picker": "8.3.7",
|
|
26
|
+
"@floating-ui/react": "0.15.1",
|
|
27
|
+
"@trackunit/ui-icons": "0.0.60",
|
|
28
|
+
"@heroicons/react": "2.0.16",
|
|
29
|
+
"@babel/core": "7.18.9",
|
|
30
|
+
"@babel/template": "7.18.10",
|
|
31
|
+
"camelcase": "5.3.1",
|
|
32
|
+
"capitalize": "2.0.4",
|
|
33
|
+
"glob": "7.2.3",
|
|
34
|
+
"react-browser-hooks": "2.2.4",
|
|
35
|
+
"react-useportal": "1.0.17",
|
|
36
|
+
"libphonenumber-js": "1.10.24",
|
|
37
|
+
"react-router-dom": "6.4.5",
|
|
38
|
+
"react-helmet-async": "1.3.0",
|
|
39
|
+
"react-select": "5.7.0",
|
|
40
|
+
"jest-canvas-mock": "2.4.0",
|
|
41
|
+
"@react-google-maps/api": "2.17.1",
|
|
42
|
+
"react-virtualized-auto-sizer": "1.0.7",
|
|
43
|
+
"@react-spring/web": "9.6.0",
|
|
44
|
+
"moment-timezone": "0.5.39",
|
|
45
|
+
"react-i18next": "12.1.1",
|
|
46
|
+
"@sentry/browser": "7.24.2",
|
|
47
|
+
"@trackunit/react-core-hooks": "0.2.32",
|
|
48
|
+
"@trackunit/react-core-contexts-api": "0.2.19",
|
|
49
|
+
"@trackunit/iris-app-runtime-core": "0.3.22",
|
|
50
|
+
"@trackunit/iris-app-runtime-core-api": "0.3.20",
|
|
51
|
+
"@sentry/react": "7.27.0",
|
|
52
|
+
"crossfilter2": "1.5.4",
|
|
53
|
+
"moment": "2.29.4",
|
|
54
|
+
"amplitude-js": "7.4.4",
|
|
55
|
+
"@apollo/client": "3.7.10",
|
|
56
|
+
"graphql": "15.8.0",
|
|
57
|
+
"mobx-react": "7.6.0",
|
|
58
|
+
"@trackunit/react-core-contexts-test": "0.1.34",
|
|
59
|
+
"@sentry/tracing": "7.24.2",
|
|
60
|
+
"mobx-state-tree": "5.1.7",
|
|
61
|
+
"styled-media-query": "2.1.2",
|
|
62
|
+
"styled-components": "5.3.6",
|
|
63
|
+
"@trackunit/react-core-contexts": "0.4.91",
|
|
64
|
+
"apollo-upload-client": "17.0.0",
|
|
65
|
+
"@trackunit/i18n-library-translation": "0.0.31",
|
|
66
|
+
"i18next": "21.10.0",
|
|
67
|
+
"i18next-browser-languagedetector": "6.1.8",
|
|
68
|
+
"i18next-resources-to-backend": "1.1.0",
|
|
69
|
+
"@trackunit/css-tailwind": "0.0.42",
|
|
70
|
+
"@trackunit/css-component-tokens": "0.0.20",
|
|
71
|
+
"csstype": "3.1.1",
|
|
72
|
+
"@trackunit/css-tailwind-custom-properties-plugin": "0.0.12",
|
|
18
73
|
"get-port": "5.1.1",
|
|
19
74
|
"node-fetch": "2.6.8",
|
|
20
75
|
"rxjs": "7.6.0",
|
|
@@ -22,8 +77,7 @@
|
|
|
22
77
|
"open": "8.4.0",
|
|
23
78
|
"pacote": "13.6.2",
|
|
24
79
|
"semver": "7.3.8",
|
|
25
|
-
"@trackunit/iris-app-webpack-plugin": "0.0.
|
|
26
|
-
"camelcase": "5.3.1",
|
|
80
|
+
"@trackunit/iris-app-webpack-plugin": "0.0.90",
|
|
27
81
|
"enquirer": "2.3.6",
|
|
28
82
|
"tslib": "2.4.1"
|
|
29
83
|
},
|
|
@@ -5,5 +5,11 @@ export type NodeBuildEvent = {
|
|
|
5
5
|
outfile: string;
|
|
6
6
|
success: boolean;
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Build executor for building iris apps.
|
|
10
|
+
*
|
|
11
|
+
* @param {BuildExecutorSchema} options build executor options for this nx executor
|
|
12
|
+
* @param {ExecutorContext} context build executor context for this nx executor
|
|
13
|
+
* @yields {NodeBuildEvent} the build event
|
|
14
|
+
*/
|
|
9
15
|
export default function (options: BuildExecutorSchema, context: ExecutorContext): AsyncGenerator<any, any, undefined>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _a, _b;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.deleteOutputDir = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
6
5
|
const rxjs_for_await_1 = require("@nrwl/devkit/src/utils/rxjs-for-await");
|
|
7
6
|
const iris_app_build_utilities_1 = require("@trackunit/iris-app-build-utilities");
|
|
@@ -12,14 +11,20 @@ require("webpack-dev-server");
|
|
|
12
11
|
const checkPackageVersion_1 = require("../utils/checkPackageVersion");
|
|
13
12
|
const defaultWebpackConfig_1 = require("../utils/defaultWebpackConfig");
|
|
14
13
|
const webpack_1 = require("./webpack");
|
|
15
|
-
|
|
14
|
+
const deleteOutputDir = (root, outputPath) => {
|
|
16
15
|
const resolvedOutputPath = (0, path_1.resolve)(root, outputPath);
|
|
17
16
|
if (resolvedOutputPath === root) {
|
|
18
17
|
throw new Error("Output path MUST not be project root directory!");
|
|
19
18
|
}
|
|
20
19
|
(0, fs_1.rmSync)(resolvedOutputPath, { recursive: true, force: true });
|
|
21
|
-
}
|
|
22
|
-
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Build executor for building iris apps.
|
|
23
|
+
*
|
|
24
|
+
* @param {BuildExecutorSchema} options build executor options for this nx executor
|
|
25
|
+
* @param {ExecutorContext} context build executor context for this nx executor
|
|
26
|
+
* @yields {NodeBuildEvent} the build event
|
|
27
|
+
*/
|
|
23
28
|
async function* default_1(options, context) {
|
|
24
29
|
await (0, checkPackageVersion_1.checkPackageVersion)();
|
|
25
30
|
if (!context.workspace) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/executors/build/executor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/executors/build/executor.ts"],"names":[],"mappings":";;;;AAEA,0EAAsE;AACtE,kFAAyE;AACzE,2BAA4B;AAC5B,+BAAqC;AAErC,2DAAqC;AAErC,8BAA4B;AAC5B,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;QAC/B,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;KACpE;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,GAAE,CAAC;IAC5B,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;KAClD;IACD,MAAM,cAAc,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,QAAS,CAAC,OAAO,CAAC,WAAY,CAAC,CAAC,IAAI,CAAC,CAAC;IAClG,MAAM,gBAAgB,GAAG,IAAA,WAAI,EAC3B,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAY,CAAC,CAAC,IAAI,EACrD,sBAAsB,CACvB,CAAC;IACF,IAAA,6CAAkB,EAAC;QACjB,cAAc;KACf,CAAC,CAAC;IACH,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;KACrD;IACD,MAAM,eAAe,GAAG,CAAC,YAAa,gBAAgB,kEAAC,CAAC,CAAC,OAAO,CAAC;IACjE,MAAM,aAAa,GAAG,IAAA,uCAAgB,EAAC,YAAY,EAAE,OAAO,CAAC,IAAI,EAAE,cAAc,EAAE,eAAe,CAAC,CAAC;IACpG,MAAM,gBAAgB,GAAG,YAAa,OAAO,CAAC,aAAa,kEAAC,CAAC;IAE7D,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAC7D,eAAe,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,IAAA,sBAAY,EAAC,MAAM,CAAC,CAAC,IAAI,CAC1C,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QACb,sCAAsC;QACtC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,EACF,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QACb,OAAO;YACL,OAAO,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE;YAC3B,OAAO,EAAE,IAAA,cAAO,EAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC;SACjC,CAAC;IACtB,CAAC,CAAC,CACH,CAAC;IACF,OAAO,KAAK,CAAC,CAAC,IAAA,8BAAa,EAAC,UAAwC,CAAC,CAAC;AACxE,CAAC;AApCD,4BAoCC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { ExecutorContext } from \"@nrwl/devkit\";\nimport { eachValueFrom } from \"@nrwl/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 { 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();\n if (!context.workspace) {\n throw new Error(\"context workspace is required\");\n }\n const projectRootDir = join(context.root, context.workspace.projects![context.projectName!].root);\n const tileManifestPath = join(\n context.root,\n context.workspace.projects[context.projectName!].root,\n \"iris-app-manifest.ts\"\n );\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 const customConfigFile = await import(options.webpackConfig);\n\n const config = await customConfigFile.default(defaultConfig);\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"]}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { Observable } from "rxjs";
|
|
2
2
|
import webpack = require("webpack");
|
|
3
|
-
|
|
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>;
|
|
@@ -3,7 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.doRunWebpack = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const webpack = require("webpack");
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Run webpack with the given configuration.
|
|
8
|
+
*
|
|
9
|
+
* @param {webpack.Configuration} config the webpack configuration
|
|
10
|
+
* @returns {*} {Observable<any>}
|
|
11
|
+
*/
|
|
7
12
|
function doRunWebpack(config) {
|
|
8
13
|
return new rxjs_1.Observable(subscriber => {
|
|
9
14
|
const { watch, ...normalizedConfig } = config;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/executors/build/webpack.ts"],"names":[],"mappings":";;;AAAA,+BAAkC;AAClC,mCAAoC;AAEpC
|
|
1
|
+
{"version":3,"file":"webpack.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/executors/build/webpack.ts"],"names":[],"mappings":";;;AAAA,+BAAkC;AAClC,mCAAoC;AAEpC;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,MAA6B;IACxD,OAAO,IAAI,iBAAU,CAAC,UAAU,CAAC,EAAE;QACjC,MAAM,EAAE,KAAK,EAAE,GAAG,gBAAgB,EAAE,GAAG,MAAM,CAAC;QAC9C,MAAM,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAElD,MAAM,QAAQ,GAAG,CAAC,GAA6B,EAAE,KAAgC,EAAE,EAAE;YACnF,IAAI,GAAG,EAAE;gBACP,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aACvB;YACD,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC,CAAC;QAEF,IAAI,MAAM,CAAC,KAAK,EAAE;YAChB,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC;YAC/C,MAAM,QAAQ,GAAG,eAAe,CAAC,KAAK,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;YAC/D,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;SAC1D;aAAM;YACL,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC,GAA6B,EAAE,KAAgC,EAAE,EAAE;gBAC7F,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBACrB,eAAe,CAAC,KAAK,CAAC,CAAC,QAAkC,EAAE,EAAE;oBAC3D,IAAI,QAAQ,EAAE;wBACZ,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;qBAC5B;oBACD,UAAU,CAAC,QAAQ,EAAE,CAAC;gBACxB,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AA5BD,oCA4BC","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"]}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { PublishExecutorSchema } from "./schema";
|
|
2
|
+
/**
|
|
3
|
+
* Publish the package to the npm registry.
|
|
4
|
+
*
|
|
5
|
+
* @param {PublishExecutorSchema} options The options provided to the executor.
|
|
6
|
+
* @returns {Promise<{ success: boolean }>} The result of the publish.
|
|
7
|
+
*/
|
|
2
8
|
export default function runExecutor(options: PublishExecutorSchema): Promise<{
|
|
3
9
|
success: boolean;
|
|
4
10
|
}>;
|
|
@@ -49,6 +49,12 @@ function getSettings() {
|
|
|
49
49
|
throw new Error(`Unknown environment: ${env}`);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Publish the package to the npm registry.
|
|
54
|
+
*
|
|
55
|
+
* @param {PublishExecutorSchema} options The options provided to the executor.
|
|
56
|
+
* @returns {Promise<{ success: boolean }>} The result of the publish.
|
|
57
|
+
*/
|
|
52
58
|
async function runExecutor(options) {
|
|
53
59
|
await (0, checkPackageVersion_1.checkPackageVersion)();
|
|
54
60
|
const settings = getSettings();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/executors/publish/executor.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,8DAAwC;AACxC,iEAA4C;AAC5C,mDAA6B;AAC7B,uDAAiC;AACjC,6BAA2C;AAC3C,sEAAmE;AA2DnE,MAAM,gBAAiB,SAAQ,KAAK;CAAG;AAEvC,MAAM,eAAgB,SAAQ,KAAK;CAAG;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,YAAY,CAAC,KAAa,EAAE,QAAqB,EAAE,QAAkB;IAClF,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,KAAK,MAAM,EAAE;QACrC,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;QACxC,MAAM,aAAa,GAAG,MAAM,IAAA,oBAAK,EAAC,IAAI,SAAG,CAAC,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE;YACvG,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,KAAK,EAAE;aACjC;SACF,CAAC,CAAC;QAEH,IAAI,aAAa,CAAC,EAAE,EAAE;YACpB,OAAO,CAAC,GAAG,CAAC,sBAAsB,QAAQ,CAAC,OAAO,OAAO,QAAQ,CAAC,IAAI,GAAG,CAAC,CAAC;YAC3E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;SAC1B;aAAM;YACL,MAAM,IAAI,YAAY,CACpB,GAAG,aAAa,CAAC,UAAU,KAAK,MAAM,aAAa,CAAC,IAAI,EAAE,eAAe,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CACjH,CAAC;SACH;KACF;SAAM;QACL,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;KAC1B;AACH,CAAC","sourcesContent":["/* eslint-disable no-console */\nimport * as libpub from \"libnpmpublish\";\nimport fetch, { Headers } from \"node-fetch\";\nimport * as open from \"open\";\nimport * as pacote from \"pacote\";\nimport { URL, URLSearchParams } from \"url\";\nimport { checkPackageVersion } from \"../utils/checkPackageVersion\";\nimport { PublishExecutorSchema } from \"./schema\";\n\ninterface PackageJson {\n name: string;\n version: string;\n scripts?: Record<string, string>;\n type?: \"module\" | \"commonjs\";\n main?: string;\n types?: string;\n module?: string;\n exports?: Record<\n string,\n {\n types?: string;\n require?: string;\n import?: string;\n }\n >;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n}\n\ninterface OktaError {\n error: string;\n error_description: string;\n}\n\ninterface AuthorizeDataSuccess {\n device_code: string;\n user_code: string;\n verification_uri: string;\n verification_uri_complete: string;\n expires_in: number;\n interval: number;\n}\n\ntype AuthorizeData = AuthorizeDataSuccess | OktaError;\n\ninterface TokenDataSuccess {\n token_type: string;\n expires_in: number;\n access_token: string;\n scope: string;\n id_token: string;\n}\n\ntype TokenData = TokenDataSuccess | OktaError;\n\ntype PublishError = Error & { code?: string; headers?: { [key: string]: string } };\n\ninterface Settings {\n approvalUrl: URL;\n repoUrl: URL;\n clientId: string;\n authorizationServerBaseUrl: string;\n}\n\nclass NpmConflictError extends Error {}\n\nclass NpmGeneralError extends Error {}\n\nclass ApproveError extends Error {}\n\nfunction sleep(time: number) {\n return new Promise(resolve => setTimeout(resolve, time));\n}\n\nfunction getSettings(): Settings {\n const env = process.env.TU_ENV?.toLowerCase() ?? \"dev\";\n let baseUrl: URL;\n switch (env) {\n case \"prod\":\n baseUrl = new URL(process.env.BASE_URL ?? \"https://apps.iris.trackunit.com/\");\n return {\n approvalUrl: new URL(\"approve/\", baseUrl),\n repoUrl: new URL(\"repo/\", baseUrl),\n clientId: \"0oamfeklvodROR2ul357\",\n authorizationServerBaseUrl: \"https://trackunit-portal.okta.com/oauth2/aus2u3jix1dWU7fwt356\",\n };\n case \"stage\":\n baseUrl = new URL(process.env.BASE_URL ?? \"https://apps.stage.iris.trackunit.com/\");\n return {\n approvalUrl: new URL(\"approve/\", baseUrl),\n repoUrl: new URL(\"repo/\", baseUrl),\n clientId: \"0oa1q2vmx21NcFLOs0h8\",\n authorizationServerBaseUrl: \"https://trackunit-portal-stage.okta.com/oauth2/aus1owd7wny5YVsU00h8\",\n };\n case \"dev\":\n baseUrl = new URL(process.env.BASE_URL ?? \"https://apps.dev.iris.trackunit.com/\");\n return {\n approvalUrl: new URL(\"approve/\", baseUrl),\n repoUrl: new URL(\"repo/\", baseUrl),\n clientId: \"0oamebigau4RkaqZ6357\",\n authorizationServerBaseUrl: \"https://trackunit-portal-dev.okta.com/oauth2/ausj7eh9zeiFhLk4m357\",\n };\n default:\n throw new Error(`Unknown environment: ${env}`);\n }\n}\n\nexport default async function runExecutor(options: PublishExecutorSchema) {\n await checkPackageVersion();\n const settings = getSettings();\n\n const env = process.env.TU_ENV?.toUpperCase() ?? \"DEV\";\n const clientId = process.env[`TU_CLIENT_ID_${env}`];\n const clientSecret = process.env[`TU_CLIENT_SECRET_${env}`];\n\n let useAccessToken = false;\n let tokenData: TokenData | null = null;\n if (process.env.TU_TOKEN) {\n tokenData = {\n token_type: \"Bearer\",\n id_token: process.env.TU_TOKEN,\n access_token: process.env.TU_TOKEN,\n expires_in: 0,\n scope: \"unknown\",\n };\n } else if (clientId !== undefined) {\n if (clientId === undefined || clientId.trim() === \"\") {\n console.error(`❌ Missing environment value: TU_CLIENT_ID_${env}`);\n return { success: false };\n }\n if (clientSecret === undefined || clientSecret.trim() === \"\") {\n console.error(`❌ Missing environment value: TU_CLIENT_SECRET_${env}`);\n return { success: false };\n }\n const tokenParams = new URLSearchParams();\n tokenParams.append(\"client_id\", clientId);\n tokenParams.append(\"client_secret\", clientSecret);\n tokenParams.append(\"grant_type\", \"client_credentials\");\n tokenParams.append(\"scope\", \"iris_app_sdk.publish_for_all_accounts iris_app_sdk.approve\");\n const tokenResponse = await fetch(`${settings.authorizationServerBaseUrl}/v1/token`, {\n method: \"POST\",\n body: tokenParams,\n });\n tokenData = (await tokenResponse.json()) as TokenData;\n useAccessToken = true;\n } else {\n const authorizeParams = new URLSearchParams();\n authorizeParams.append(\"client_id\", settings.clientId);\n authorizeParams.append(\"scope\", \"openid profile fms\");\n const authorizeResponse = await fetch(`${settings.authorizationServerBaseUrl}/v1/device/authorize`, {\n method: \"POST\",\n body: authorizeParams,\n });\n const authorizeData = (await authorizeResponse.json()) as AuthorizeData;\n\n if (\"error\" in authorizeData) {\n console.error(`❌ Error occurred: ${authorizeData.error} ${authorizeData.error_description}`);\n return { success: false };\n } else if (!authorizeData.verification_uri_complete) {\n console.error(`❌ Missing verification URI: ${JSON.stringify(authorizeData)}`);\n return { success: false };\n }\n\n console.log(\n `🔐 Attempting to automatically open the Trackunit authentication page in your default browser...\\n If the browser does not open or you wish to use a different device to authorize this request, open the following URL:\\n\\n ${authorizeData.verification_uri_complete}`\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n await ((open as any).default ? (open as any).default : open)(authorizeData.verification_uri_complete);\n\n console.log(\"\\n⏳ Waiting for authentication in the browser...\");\n do {\n await sleep(authorizeData.interval * 1000);\n if (tokenData && \"error\" in tokenData && tokenData.error === \"slow_down\") {\n await sleep(10000);\n }\n const tokenParams = new URLSearchParams();\n tokenParams.append(\"client_id\", settings.clientId);\n tokenParams.append(\"grant_type\", \"urn:ietf:params:oauth:grant-type:device_code\");\n tokenParams.append(\"device_code\", authorizeData.device_code);\n const tokenResponse = await fetch(`${settings.authorizationServerBaseUrl}/v1/token`, {\n method: \"POST\",\n body: tokenParams,\n });\n tokenData = (await tokenResponse.json()) as TokenData;\n } while (\n !(\"id_token\" in tokenData) &&\n !(\"error\" in tokenData && tokenData.error !== \"authorization_pending\" && tokenData.error !== \"slow_down\")\n );\n }\n\n if (\"access_token\" in tokenData) {\n console.log(\"🥳 Successfully authenticated.\");\n\n const manifest = (await pacote.manifest(options.inputPath)) as PackageJson;\n const tarData = await pacote.tarball(options.inputPath);\n\n return await doUploadAppWithRetry(tokenData, useAccessToken, manifest, tarData, settings, 3);\n } else if (\"error\" in tokenData) {\n if (tokenData.error === \"expired_token\") {\n console.error(\"⌛️ Authentication attempt expired\");\n return { success: false };\n } else {\n console.error(`❌ Error occurred: ${tokenData.error} ${tokenData.error_description}`);\n return { success: false };\n }\n } else {\n console.error(\"❌ Unknown error occurred\");\n return { success: false };\n }\n}\n\nasync function doUploadAppWithRetry(\n tokenData: TokenDataSuccess,\n useAccessToken: boolean,\n manifest: PackageJson,\n tarData: Buffer & pacote.FetchResult,\n settings: Settings,\n retryCount: number\n): Promise<{ success: boolean }> {\n try {\n return await doUploadApp(tokenData, useAccessToken, manifest, tarData, settings);\n } catch (e) {\n if (e instanceof NpmConflictError) {\n console.error(\"❌ Unable to ship app package. Cannot publish over existing version.\");\n return { success: false };\n } else {\n if (retryCount > 1) {\n console.error(\"⚠️ Unable to ship app package. Got error from Iris App SDK repository. Retrying publish...\", e);\n await sleep(5000);\n return await doUploadAppWithRetry(tokenData, useAccessToken, manifest, tarData, settings, retryCount - 1);\n } else {\n console.error(\"❌ Unable to ship app package. Got error from Iris App SDK repository.\", e);\n return { success: false };\n }\n }\n }\n}\n\nasync function doUploadApp(\n tokenData: TokenDataSuccess,\n useAccessToken: boolean,\n manifest: PackageJson,\n tarData: Buffer & pacote.FetchResult,\n settings: Settings\n): Promise<{ success: boolean }> {\n const npmFetchOptions: { registry?: string } = {};\n npmFetchOptions.registry = settings.repoUrl.toString();\n const repoHostAndPort = settings.repoUrl.hostname + (settings.repoUrl.port ? \":\" + settings.repoUrl.port : \"\");\n npmFetchOptions[`//${repoHostAndPort}${settings.repoUrl.pathname}:_authToken`] = useAccessToken\n ? tokenData.access_token\n : tokenData.id_token;\n npmFetchOptions[`//${repoHostAndPort}${settings.repoUrl.pathname}/repo/:always-auth`] = true;\n\n console.log(\"🚢 Shipping the app package...\");\n const publishResult = await libpub.publish(manifest, tarData, npmFetchOptions).catch((err: PublishError) => {\n if (err.code === \"EPUBLISHCONFLICT\") {\n return {\n ok: false,\n publishConflict: true,\n };\n } else {\n return {\n ok: false,\n headers: new Headers(err.headers),\n statusText: `Error`,\n text: () => Promise.resolve(`${err.name} ${err.message}`),\n };\n }\n });\n\n const warningsText = publishResult.headers?.get(\"TU-TILE-WARNINGS\");\n if (warningsText) {\n console.log(\"⚠️ \" + decodeURI(warningsText));\n }\n\n if (publishResult.ok) {\n console.log(`🚀 Uploaded the app package version ${manifest.version}`);\n\n return await doApproveAppWithRetry(\n useAccessToken ? tokenData.access_token : tokenData.id_token,\n manifest,\n settings,\n 3\n );\n } else if (\"publishConflict\" in publishResult) {\n if (process.env.SKIP_EXISTING === \"true\") {\n console.log(`⏩ Skipped publishing ${manifest.version} because the version is already published`);\n return await doApproveAppWithRetry(\n useAccessToken ? tokenData.access_token : tokenData.id_token,\n manifest,\n settings,\n 3\n );\n } else {\n throw new NpmConflictError();\n }\n } else {\n throw new NpmGeneralError(\n publishResult.statusText +\n \" \" +\n (await publishResult.text()) +\n \". Trace ID: \" +\n publishResult.headers.get(\"trace-id\")\n );\n }\n}\n\nasync function doApproveAppWithRetry(\n token: string,\n manifest: PackageJson,\n settings: Settings,\n retryCount: number\n): Promise<{ success: boolean }> {\n try {\n return await doApproveApp(token, manifest, settings);\n } catch (e) {\n if (e instanceof ApproveError) {\n if (retryCount > 1) {\n console.error(\n \"⚠️ Unable to approve app package. Got approve error from Iris App SDK repository. Retrying approve...\",\n e\n );\n await sleep(5000);\n return await doApproveAppWithRetry(token, manifest, settings, retryCount - 1);\n } else {\n console.error(\"❌ Unable to approve app package. Got approve error from Iris App SDK repository.\", e);\n return { success: false };\n }\n } else {\n console.error(\"❌ Unable to approve app package. Got error from Iris App SDK repository.\", e);\n return { success: false };\n }\n }\n}\n\nasync function doApproveApp(token: string, manifest: PackageJson, settings: Settings) {\n if (process.env.TU_APPROVE === \"true\") {\n console.log(`🖋️ Approving the app...`);\n const approveResult = await fetch(new URL(`${manifest.name}@${manifest.version}`, settings.approvalUrl), {\n method: \"PUT\",\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (approveResult.ok) {\n console.log(`✅ Approved version ${manifest.version} of ${manifest.name}.`);\n return { success: true };\n } else {\n throw new ApproveError(\n `${approveResult.statusText}, ${await approveResult.text()}, Trace ID: ${approveResult.headers.get(\"trace-id\")}`\n );\n }\n } else {\n return { success: true };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/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,EAAE,CAAC,CAAC,CAAC;gBACrG,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;aAC3B;SACF;aAAM;YACL,OAAO,CAAC,KAAK,CAAC,0EAA0E,EAAE,CAAC,CAAC,CAAC;YAC7F,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;SAC3B;KACF;AACH,CAAC;AAED,KAAK,UAAU,YAAY,CAAC,KAAa,EAAE,QAAqB,EAAE,QAAkB;IAClF,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,KAAK,MAAM,EAAE;QACrC,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;QACxC,MAAM,aAAa,GAAG,MAAM,IAAA,oBAAK,EAAC,IAAI,SAAG,CAAC,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE;YACvG,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACP,aAAa,EAAE,UAAU,KAAK,EAAE;aACjC;SACF,CAAC,CAAC;QAEH,IAAI,aAAa,CAAC,EAAE,EAAE;YACpB,OAAO,CAAC,GAAG,CAAC,sBAAsB,QAAQ,CAAC,OAAO,OAAO,QAAQ,CAAC,IAAI,GAAG,CAAC,CAAC;YAC3E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;SAC1B;aAAM;YACL,MAAM,IAAI,YAAY,CACpB,GAAG,aAAa,CAAC,UAAU,KAAK,MAAM,aAAa,CAAC,IAAI,EAAE,eAAe,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CACjH,CAAC;SACH;KACF;SAAM;QACL,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;KAC1B;AACH,CAAC","sourcesContent":["/* eslint-disable no-console */\nimport * as libpub from \"libnpmpublish\";\nimport fetch, { Headers } from \"node-fetch\";\nimport * as open from \"open\";\nimport * as pacote from \"pacote\";\nimport { URL, URLSearchParams } from \"url\";\nimport { checkPackageVersion } from \"../utils/checkPackageVersion\";\nimport { PublishExecutorSchema } from \"./schema\";\n\ninterface PackageJson {\n name: string;\n version: string;\n scripts?: Record<string, string>;\n type?: \"module\" | \"commonjs\";\n main?: string;\n types?: string;\n module?: string;\n exports?: Record<\n string,\n {\n types?: string;\n require?: string;\n import?: string;\n }\n >;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n}\n\ninterface OktaError {\n error: string;\n error_description: string;\n}\n\ninterface AuthorizeDataSuccess {\n device_code: string;\n user_code: string;\n verification_uri: string;\n verification_uri_complete: string;\n expires_in: number;\n interval: number;\n}\n\ntype AuthorizeData = AuthorizeDataSuccess | OktaError;\n\ninterface TokenDataSuccess {\n token_type: string;\n expires_in: number;\n access_token: string;\n scope: string;\n id_token: string;\n}\n\ntype TokenData = TokenDataSuccess | OktaError;\n\ntype PublishError = Error & { code?: string; headers?: { [key: string]: string } };\n\ninterface Settings {\n approvalUrl: URL;\n repoUrl: URL;\n clientId: string;\n authorizationServerBaseUrl: string;\n}\n\nclass NpmConflictError extends Error {}\n\nclass NpmGeneralError extends Error {}\n\nclass ApproveError extends Error {}\n\nfunction sleep(time: number) {\n return new Promise(resolve => setTimeout(resolve, time));\n}\n\nfunction getSettings(): Settings {\n const env = process.env.TU_ENV?.toLowerCase() ?? \"dev\";\n let baseUrl: URL;\n switch (env) {\n case \"prod\":\n baseUrl = new URL(process.env.BASE_URL ?? \"https://apps.iris.trackunit.com/\");\n return {\n approvalUrl: new URL(\"approve/\", baseUrl),\n repoUrl: new URL(\"repo/\", baseUrl),\n clientId: \"0oamfeklvodROR2ul357\",\n authorizationServerBaseUrl: \"https://trackunit-portal.okta.com/oauth2/aus2u3jix1dWU7fwt356\",\n };\n case \"stage\":\n baseUrl = new URL(process.env.BASE_URL ?? \"https://apps.stage.iris.trackunit.com/\");\n return {\n approvalUrl: new URL(\"approve/\", baseUrl),\n repoUrl: new URL(\"repo/\", baseUrl),\n clientId: \"0oa1q2vmx21NcFLOs0h8\",\n authorizationServerBaseUrl: \"https://trackunit-portal-stage.okta.com/oauth2/aus1owd7wny5YVsU00h8\",\n };\n case \"dev\":\n baseUrl = new URL(process.env.BASE_URL ?? \"https://apps.dev.iris.trackunit.com/\");\n return {\n approvalUrl: new URL(\"approve/\", baseUrl),\n repoUrl: new URL(\"repo/\", baseUrl),\n clientId: \"0oamebigau4RkaqZ6357\",\n authorizationServerBaseUrl: \"https://trackunit-portal-dev.okta.com/oauth2/ausj7eh9zeiFhLk4m357\",\n };\n default:\n throw new Error(`Unknown environment: ${env}`);\n }\n}\n\n/**\n * Publish the package to the npm registry.\n *\n * @param {PublishExecutorSchema} options The options provided to the executor.\n * @returns {Promise<{ success: boolean }>} The result of the publish.\n */\nexport default async function runExecutor(options: PublishExecutorSchema) {\n await checkPackageVersion();\n const settings = getSettings();\n\n const env = process.env.TU_ENV?.toUpperCase() ?? \"DEV\";\n const clientId = process.env[`TU_CLIENT_ID_${env}`];\n const clientSecret = process.env[`TU_CLIENT_SECRET_${env}`];\n\n let useAccessToken = false;\n let tokenData: TokenData | null = null;\n if (process.env.TU_TOKEN) {\n tokenData = {\n token_type: \"Bearer\",\n id_token: process.env.TU_TOKEN,\n access_token: process.env.TU_TOKEN,\n expires_in: 0,\n scope: \"unknown\",\n };\n } else if (clientId !== undefined) {\n if (clientId === undefined || clientId.trim() === \"\") {\n console.error(`❌ Missing environment value: TU_CLIENT_ID_${env}`);\n return { success: false };\n }\n if (clientSecret === undefined || clientSecret.trim() === \"\") {\n console.error(`❌ Missing environment value: TU_CLIENT_SECRET_${env}`);\n return { success: false };\n }\n const tokenParams = new URLSearchParams();\n tokenParams.append(\"client_id\", clientId);\n tokenParams.append(\"client_secret\", clientSecret);\n tokenParams.append(\"grant_type\", \"client_credentials\");\n tokenParams.append(\"scope\", \"iris_app_sdk.publish_for_all_accounts iris_app_sdk.approve\");\n const tokenResponse = await fetch(`${settings.authorizationServerBaseUrl}/v1/token`, {\n method: \"POST\",\n body: tokenParams,\n });\n tokenData = (await tokenResponse.json()) as TokenData;\n useAccessToken = true;\n } else {\n const authorizeParams = new URLSearchParams();\n authorizeParams.append(\"client_id\", settings.clientId);\n authorizeParams.append(\"scope\", \"openid profile fms\");\n const authorizeResponse = await fetch(`${settings.authorizationServerBaseUrl}/v1/device/authorize`, {\n method: \"POST\",\n body: authorizeParams,\n });\n const authorizeData = (await authorizeResponse.json()) as AuthorizeData;\n\n if (\"error\" in authorizeData) {\n console.error(`❌ Error occurred: ${authorizeData.error} ${authorizeData.error_description}`);\n return { success: false };\n } else if (!authorizeData.verification_uri_complete) {\n console.error(`❌ Missing verification URI: ${JSON.stringify(authorizeData)}`);\n return { success: false };\n }\n\n console.log(\n `🔐 Attempting to automatically open the Trackunit authentication page in your default browser...\\n If the browser does not open or you wish to use a different device to authorize this request, open the following URL:\\n\\n ${authorizeData.verification_uri_complete}`\n );\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n await ((open as any).default ? (open as any).default : open)(authorizeData.verification_uri_complete);\n\n console.log(\"\\n⏳ Waiting for authentication in the browser...\");\n do {\n await sleep(authorizeData.interval * 1000);\n if (tokenData && \"error\" in tokenData && tokenData.error === \"slow_down\") {\n await sleep(10000);\n }\n const tokenParams = new URLSearchParams();\n tokenParams.append(\"client_id\", settings.clientId);\n tokenParams.append(\"grant_type\", \"urn:ietf:params:oauth:grant-type:device_code\");\n tokenParams.append(\"device_code\", authorizeData.device_code);\n const tokenResponse = await fetch(`${settings.authorizationServerBaseUrl}/v1/token`, {\n method: \"POST\",\n body: tokenParams,\n });\n tokenData = (await tokenResponse.json()) as TokenData;\n } while (\n !(\"id_token\" in tokenData) &&\n !(\"error\" in tokenData && tokenData.error !== \"authorization_pending\" && tokenData.error !== \"slow_down\")\n );\n }\n\n if (\"access_token\" in tokenData) {\n console.log(\"🥳 Successfully authenticated.\");\n\n const manifest = (await pacote.manifest(options.inputPath)) as PackageJson;\n const tarData = await pacote.tarball(options.inputPath);\n\n return await doUploadAppWithRetry(tokenData, useAccessToken, manifest, tarData, settings, 3);\n } else if (\"error\" in tokenData) {\n if (tokenData.error === \"expired_token\") {\n console.error(\"⌛️ Authentication attempt expired\");\n return { success: false };\n } else {\n console.error(`❌ Error occurred: ${tokenData.error} ${tokenData.error_description}`);\n return { success: false };\n }\n } else {\n console.error(\"❌ Unknown error occurred\");\n return { success: false };\n }\n}\n\nasync function doUploadAppWithRetry(\n tokenData: TokenDataSuccess,\n useAccessToken: boolean,\n manifest: PackageJson,\n tarData: Buffer & pacote.FetchResult,\n settings: Settings,\n retryCount: number\n): Promise<{ success: boolean }> {\n try {\n return await doUploadApp(tokenData, useAccessToken, manifest, tarData, settings);\n } catch (e) {\n if (e instanceof NpmConflictError) {\n console.error(\"❌ Unable to ship app package. Cannot publish over existing version.\");\n return { success: false };\n } else {\n if (retryCount > 1) {\n console.error(\"⚠️ Unable to ship app package. Got error from Iris App SDK repository. Retrying publish...\", e);\n await sleep(5000);\n return await doUploadAppWithRetry(tokenData, useAccessToken, manifest, tarData, settings, retryCount - 1);\n } else {\n console.error(\"❌ Unable to ship app package. Got error from Iris App SDK repository.\", e);\n return { success: false };\n }\n }\n }\n}\n\nasync function doUploadApp(\n tokenData: TokenDataSuccess,\n useAccessToken: boolean,\n manifest: PackageJson,\n tarData: Buffer & pacote.FetchResult,\n settings: Settings\n): Promise<{ success: boolean }> {\n const npmFetchOptions: { registry?: string } = {};\n npmFetchOptions.registry = settings.repoUrl.toString();\n const repoHostAndPort = settings.repoUrl.hostname + (settings.repoUrl.port ? \":\" + settings.repoUrl.port : \"\");\n npmFetchOptions[`//${repoHostAndPort}${settings.repoUrl.pathname}:_authToken`] = useAccessToken\n ? tokenData.access_token\n : tokenData.id_token;\n npmFetchOptions[`//${repoHostAndPort}${settings.repoUrl.pathname}/repo/:always-auth`] = true;\n\n console.log(\"🚢 Shipping the app package...\");\n const publishResult = await libpub.publish(manifest, tarData, npmFetchOptions).catch((err: PublishError) => {\n if (err.code === \"EPUBLISHCONFLICT\") {\n return {\n ok: false,\n publishConflict: true,\n };\n } else {\n return {\n ok: false,\n headers: new Headers(err.headers),\n statusText: `Error`,\n text: () => Promise.resolve(`${err.name} ${err.message}`),\n };\n }\n });\n\n const warningsText = publishResult.headers?.get(\"TU-TILE-WARNINGS\");\n if (warningsText) {\n console.log(\"⚠️ \" + decodeURI(warningsText));\n }\n\n if (publishResult.ok) {\n console.log(`🚀 Uploaded the app package version ${manifest.version}`);\n\n return await doApproveAppWithRetry(\n useAccessToken ? tokenData.access_token : tokenData.id_token,\n manifest,\n settings,\n 3\n );\n } else if (\"publishConflict\" in publishResult) {\n if (process.env.SKIP_EXISTING === \"true\") {\n console.log(`⏩ Skipped publishing ${manifest.version} because the version is already published`);\n return await doApproveAppWithRetry(\n useAccessToken ? tokenData.access_token : tokenData.id_token,\n manifest,\n settings,\n 3\n );\n } else {\n throw new NpmConflictError();\n }\n } else {\n throw new NpmGeneralError(\n publishResult.statusText +\n \" \" +\n (await publishResult.text()) +\n \". Trace ID: \" +\n publishResult.headers.get(\"trace-id\")\n );\n }\n}\n\nasync function doApproveAppWithRetry(\n token: string,\n manifest: PackageJson,\n settings: Settings,\n retryCount: number\n): Promise<{ success: boolean }> {\n try {\n return await doApproveApp(token, manifest, settings);\n } catch (e) {\n if (e instanceof ApproveError) {\n if (retryCount > 1) {\n console.error(\n \"⚠️ Unable to approve app package. Got approve error from Iris App SDK repository. Retrying approve...\",\n e\n );\n await sleep(5000);\n return await doApproveAppWithRetry(token, manifest, settings, retryCount - 1);\n } else {\n console.error(\"❌ Unable to approve app package. Got approve error from Iris App SDK repository.\", e);\n return { success: false };\n }\n } else {\n console.error(\"❌ Unable to approve app package. Got error from Iris App SDK repository.\", e);\n return { success: false };\n }\n }\n}\n\nasync function doApproveApp(token: string, manifest: PackageJson, settings: Settings) {\n if (process.env.TU_APPROVE === \"true\") {\n console.log(`🖋️ Approving the app...`);\n const approveResult = await fetch(new URL(`${manifest.name}@${manifest.version}`, settings.approvalUrl), {\n method: \"PUT\",\n headers: {\n Authorization: `Bearer ${token}`,\n },\n });\n\n if (approveResult.ok) {\n console.log(`✅ Approved version ${manifest.version} of ${manifest.name}.`);\n return { success: true };\n } else {\n throw new ApproveError(\n `${approveResult.statusText}, ${await approveResult.text()}, Trace ID: ${approveResult.headers.get(\"trace-id\")}`\n );\n }\n } else {\n return { success: true };\n }\n}\n"]}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { ExecutorContext } from "@nrwl/devkit";
|
|
2
2
|
import "webpack-dev-server";
|
|
3
3
|
import { ServeExecutorSchema } from "./schema";
|
|
4
|
+
/**
|
|
5
|
+
* Serve executor for serving iris apps.
|
|
6
|
+
*
|
|
7
|
+
* @param {ServeExecutorSchema} options serve executor options for this nx executor
|
|
8
|
+
* @param {ExecutorContext} context serve executor context for this nx executor
|
|
9
|
+
* @yields {AsyncGenerator<any, void, unknown>} the serve observable
|
|
10
|
+
*/
|
|
4
11
|
export default function (options: ServeExecutorSchema, context: ExecutorContext): AsyncGenerator<any, any, undefined>;
|
|
@@ -11,6 +11,13 @@ require("webpack-dev-server");
|
|
|
11
11
|
const checkPackageVersion_1 = require("../utils/checkPackageVersion");
|
|
12
12
|
const defaultWebpackConfig_1 = require("../utils/defaultWebpackConfig");
|
|
13
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
|
+
*/
|
|
14
21
|
async function* default_1(options, context) {
|
|
15
22
|
await (0, checkPackageVersion_1.checkPackageVersion)();
|
|
16
23
|
if (!context.workspace) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/executors/serve/executor.ts"],"names":[],"mappings":";;;;AAEA,0EAAsE;AACtE,iGAA4F;AAC5F,kFAAyE;AACzE,+BAA4B;AAE5B,2DAAqC;AAErC,8BAA4B;AAC5B,sEAAmE;AACnE,wEAAiE;AAEjE,yDAA2D;
|
|
1
|
+
{"version":3,"file":"executor.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/executors/serve/executor.ts"],"names":[],"mappings":";;;;AAEA,0EAAsE;AACtE,iGAA4F;AAC5F,kFAAyE;AACzE,+BAA4B;AAE5B,2DAAqC;AAErC,8BAA4B;AAC5B,sEAAmE;AACnE,wEAAiE;AAEjE,yDAA2D;AAI3D;;;;;;GAMG;AACY,KAAK,SAAS,CAAC,WAAE,OAA4B,EAAE,OAAwB;IACpF,MAAM,IAAA,yCAAmB,GAAE,CAAC;IAC5B,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;QACtB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;KAClD;IACD,MAAM,cAAc,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAY,CAAC,CAAC,IAAI,CAAC,CAAC;IACjG,MAAM,gBAAgB,GAAG,IAAA,WAAI,EAC3B,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAY,CAAC,CAAC,IAAI,EACrD,sBAAsB,CACvB,CAAC;IACF,IAAA,6CAAkB,EAAC;QACjB,cAAc;KACf,CAAC,CAAC;IACH,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;KACrD;IACD,MAAM,eAAe,GAAG,CAAC,YAAa,gBAAgB,kEAAC,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,YAAa,OAAO,CAAC,aAAa,kEAAC,CAAC;IAE7D,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAE7D,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,YAAY,EAAE,IAAA,mCAAe,EAAC,KAAK,CAAC;YACpC,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;AAtCD,4BAsCC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { ExecutorContext } from \"@nrwl/devkit\";\nimport { eachValueFrom } from \"@nrwl/devkit/src/utils/rxjs-for-await\";\nimport { getEmittedFiles } from \"@nrwl/webpack/src/executors/webpack/lib/get-emitted-files\";\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 { 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();\n if (!context.workspace) {\n throw new Error(\"context workspace is required\");\n }\n const projectRootDir = join(context.root, context.workspace.projects[context.projectName!].root);\n const tileManifestPath = join(\n context.root,\n context.workspace.projects[context.projectName!].root,\n \"iris-app-manifest.ts\"\n );\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 const config = await customConfigFile.default(defaultConfig);\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 emittedFiles: getEmittedFiles(stats),\n success: !stats.hasErrors(),\n };\n })\n );\n\n return yield* eachValueFrom(observable as unknown as Observable<any>);\n}\n"]}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { Observable } from "rxjs";
|
|
2
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
|
+
*/
|
|
3
9
|
export declare function doRunWebpackDevServer(config: webpack.Configuration): Observable<{
|
|
4
10
|
stats: webpack.Stats;
|
|
5
11
|
baseUrl: string;
|
|
@@ -4,6 +4,12 @@ exports.doRunWebpackDevServer = void 0;
|
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const webpack = require("webpack");
|
|
6
6
|
const WebpackDevServer = require("webpack-dev-server");
|
|
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
|
+
*/
|
|
7
13
|
function doRunWebpackDevServer(config) {
|
|
8
14
|
return new rxjs_1.Observable(subscriber => {
|
|
9
15
|
const webpackCompiler = webpack.webpack(config);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpackDevServer.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/executors/serve/webpackDevServer.ts"],"names":[],"mappings":";;;AAAA,+BAAkC;AAClC,mCAAoC;AACpC,uDAAwD;AAExD,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,GAAI,MAAgC,CAAC,SAAS,IAAI,EAAE,CAAC;QAE1E,MAAM,gBAAgB,GAAG,eAAe,CAAC,WAAW,CAAC;QAErD,eAAe,CAAC,WAAW,GAAG,UAAU,MAAwB;YAC9D,IAAI,gBAAgB,EAAE;gBACpB,gBAAgB,CAAC,MAAM,CAAC,CAAC;aAC1B;YAED,MAAM,gBAAgB,GAAmC,MAAM,CAAC,OAAO,CAAC;YAExE,OAAO,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,GAClG,gBAAgB,EAAE,aAAa,EAAE,UACnC,EAAE,CAAC;QACL,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;AAjCD,sDAiCC","sourcesContent":["import { Observable } from \"rxjs\";\nimport webpack = require(\"webpack\");\nimport WebpackDevServer = require(\"webpack-dev-server\");\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 as webpack.Configuration).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.https ? \"https\" : \"http\"}://${server.options.host}:${server.options.port}${\n devServerOptions?.devMiddleware?.publicPath\n }`;\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"]}
|
|
1
|
+
{"version":3,"file":"webpackDevServer.js","source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AO,GAAG,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;AACL,CAAC;AAjCD,sDAiCC","sourcesContent":["import { Observable } from \"rxjs\";\nimport webpack = require(\"webpack\");\nimport WebpackDevServer = require(\"webpack-dev-server\");\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 as webpack.Configuration).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.https ? \"https\" : \"http\"}://${server.options.host}:${server.options.port}${\n devServerOptions?.devMiddleware?.publicPath\n }`;\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"]}
|
|
@@ -1,6 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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) => 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 versio
|
|
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} managerNodeVersion version of node in the manager
|
|
20
|
+
* @returns { boolean } true if its a valid version
|
|
21
|
+
*/
|
|
3
22
|
export declare function checkNodeVersion(managerNodeVersion: string): Promise<boolean>;
|
|
23
|
+
/**
|
|
24
|
+
* Check if the current version of the package is the same as the one in the manager.
|
|
25
|
+
*
|
|
26
|
+
* @param {string} managerNxVersion version of nx in the manager
|
|
27
|
+
* @returns { boolean} true if its a valid version
|
|
28
|
+
*/
|
|
4
29
|
export declare function checkNxVersion(managerNxVersion: string): Promise<boolean>;
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
5
33
|
export declare function checkTrackunitPackages(packageJson: any): Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
6
37
|
export declare function checkPackageVersion(): Promise<boolean>;
|
|
@@ -7,51 +7,73 @@ const child_process_1 = require("child_process");
|
|
|
7
7
|
const pacote = tslib_1.__importStar(require("pacote"));
|
|
8
8
|
const semver = tslib_1.__importStar(require("semver"));
|
|
9
9
|
const version_1 = require("./version");
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param pkg package to look for.
|
|
13
|
+
* @param localRange local version of the package.
|
|
14
|
+
* @param range range
|
|
15
|
+
* @returns { boolean } true if its a valid version
|
|
16
|
+
*/
|
|
17
|
+
const versionCheck = (pkg, localRange, range) => {
|
|
11
18
|
const localVersion = semver.minVersion(localRange) ?? localRange; // ('^1.0.0') => '1.0.0'
|
|
12
19
|
if (!semver.satisfies(localVersion, range)) {
|
|
13
20
|
throw new Error(`Package "${pkg}" outdated. Remote Version: ${range} Local version: ${localRange}. \n Update package using command: 'npm i ${pkg}@${range}'`);
|
|
14
21
|
}
|
|
15
22
|
return true;
|
|
16
|
-
}
|
|
23
|
+
};
|
|
17
24
|
exports.versionCheck = versionCheck;
|
|
18
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Get the latest version of the package from the registry.
|
|
27
|
+
*
|
|
28
|
+
* @param pkg package to look for.
|
|
29
|
+
* @returns { Promise<string> } returns versio
|
|
30
|
+
*/
|
|
31
|
+
const getLatestRemoteVersion = async (pkg) => {
|
|
19
32
|
try {
|
|
20
33
|
const manifest = await pacote.manifest(pkg);
|
|
21
34
|
return manifest.version;
|
|
22
35
|
}
|
|
23
36
|
catch (error) {
|
|
24
|
-
|
|
25
|
-
if (pkg === "@trackunit/i18n-library-translation") {
|
|
26
|
-
return undefined;
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
throw new Error(`Error fetching manifest for package ${pkg}`);
|
|
30
|
-
}
|
|
37
|
+
throw new Error(`Error fetching manifest for package ${pkg}`);
|
|
31
38
|
}
|
|
32
|
-
}
|
|
39
|
+
};
|
|
33
40
|
exports.getLatestRemoteVersion = getLatestRemoteVersion;
|
|
41
|
+
/**
|
|
42
|
+
* Check if the current version of the package is the same as the one in the manager.
|
|
43
|
+
*
|
|
44
|
+
* @param {string} managerNodeVersion version of node in the manager
|
|
45
|
+
* @returns { boolean } true if its a valid version
|
|
46
|
+
*/
|
|
34
47
|
async function checkNodeVersion(managerNodeVersion) {
|
|
35
48
|
const currentNodeVersion = await process.version.replace(/\r?\n|\r/, ""); // regex removes any linebreaks
|
|
36
|
-
return versionCheck("node", currentNodeVersion, managerNodeVersion);
|
|
49
|
+
return (0, exports.versionCheck)("node", currentNodeVersion, managerNodeVersion);
|
|
37
50
|
}
|
|
38
51
|
exports.checkNodeVersion = checkNodeVersion;
|
|
52
|
+
/**
|
|
53
|
+
* Check if the current version of the package is the same as the one in the manager.
|
|
54
|
+
*
|
|
55
|
+
* @param {string} managerNxVersion version of nx in the manager
|
|
56
|
+
* @returns { boolean} true if its a valid version
|
|
57
|
+
*/
|
|
39
58
|
async function checkNxVersion(managerNxVersion) {
|
|
40
59
|
const currentNxVersion = (0, child_process_1.execSync)("nx --version")
|
|
41
60
|
.toString("utf-8")
|
|
42
61
|
.replace(/\r?\n|\r/, ""); // regex removes any linebreaks
|
|
43
|
-
return versionCheck("nx", currentNxVersion, managerNxVersion);
|
|
62
|
+
return (0, exports.versionCheck)("nx", currentNxVersion, managerNxVersion);
|
|
44
63
|
}
|
|
45
64
|
exports.checkNxVersion = checkNxVersion;
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
*/
|
|
46
68
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
69
|
async function checkTrackunitPackages(packageJson) {
|
|
48
70
|
for (const key in packageJson) {
|
|
49
|
-
const remoteVersion = await getLatestRemoteVersion(key);
|
|
71
|
+
const remoteVersion = await (0, exports.getLatestRemoteVersion)(key);
|
|
50
72
|
if (remoteVersion) {
|
|
51
73
|
const localDependencyVersion = packageJson[key];
|
|
52
74
|
// If @trackunit dependencies are linked/added locally using "file://", skip the version check.
|
|
53
75
|
if (!localDependencyVersion.includes("file://")) {
|
|
54
|
-
versionCheck(key, localDependencyVersion, remoteVersion);
|
|
76
|
+
(0, exports.versionCheck)(key, localDependencyVersion, remoteVersion);
|
|
55
77
|
}
|
|
56
78
|
}
|
|
57
79
|
}
|
|
@@ -64,6 +86,9 @@ function getLibraries() {
|
|
|
64
86
|
const trackunitDevDependencies = Object.fromEntries(Object.entries(packageJsonLocal.devDependencies).filter(([key]) => key.startsWith("@trackunit/")));
|
|
65
87
|
return { trackunitDependencies, trackunitDevDependencies };
|
|
66
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
*
|
|
91
|
+
*/
|
|
67
92
|
async function checkPackageVersion() {
|
|
68
93
|
const { trackunitDependencies, trackunitDevDependencies } = getLibraries();
|
|
69
94
|
const managerNodeVersion = version_1.version.managerNodeVersion;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkPackageVersion.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/executors/utils/checkPackageVersion.ts"],"names":[],"mappings":";;;;AAAA,yCAA4C;AAC5C,iDAAyC;AACzC,uDAAiC;AACjC,uDAAiC;AACjC,uCAAoC;AAEpC,
|
|
1
|
+
{"version":3,"file":"checkPackageVersion.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/executors/utils/checkPackageVersion.ts"],"names":[],"mappings":";;;;AAAA,yCAA4C;AAC5C,iDAAyC;AACzC,uDAAiC;AACjC,uDAAiC;AACjC,uCAAoC;AAEpC;;;;;;GAMG;AACI,MAAM,YAAY,GAAG,CAAC,GAAW,EAAE,UAAkB,EAAE,KAAa,EAAE,EAAE;IAC7E,MAAM,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,CAAC,wBAAwB;IAC1F,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,YAAY,EAAE,KAAK,CAAC,EAAE;QAC1C,MAAM,IAAI,KAAK,CACb,YAAY,GAAG,+BAA+B,KAAK,mBAAmB,UAAU,6CAA6C,GAAG,IAAI,KAAK,GAAG,CAC7I,CAAC;KACH;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AARW,QAAA,YAAY,gBAQvB;AAEF;;;;;GAKG;AACI,MAAM,sBAAsB,GAAG,KAAK,EAAE,GAAW,EAAE,EAAE;IAC1D,IAAI;QACF,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC5C,OAAO,QAAQ,CAAC,OAAO,CAAC;KACzB;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,IAAI,KAAK,CAAC,uCAAuC,GAAG,EAAE,CAAC,CAAC;KAC/D;AACH,CAAC,CAAC;AAPW,QAAA,sBAAsB,0BAOjC;AAEF;;;;;GAKG;AACI,KAAK,UAAU,gBAAgB,CAAC,kBAA0B;IAC/D,MAAM,kBAAkB,GAAG,MAAM,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,CAAC,aAAa,CAAC,CAAC,CAC/F,CAAC;IACF,MAAM,wBAAwB,GAAG,MAAM,CAAC,WAAW,CACjD,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAClG,CAAC;IACF,OAAO,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,CAAC;AAC7D,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,mBAAmB;IACvC,MAAM,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,GAAG,YAAY,EAAE,CAAC;IAC3E,MAAM,kBAAkB,GAAG,iBAAO,CAAC,kBAAkB,CAAC;IACtD,MAAM,gBAAgB,GAAG,iBAAO,CAAC,gBAAgB,CAAC;IAClD,MAAM,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;IAC3C,MAAM,cAAc,CAAC,gBAAgB,CAAC,CAAC;IACvC,MAAM,sBAAsB,CAAC,qBAAqB,CAAC,CAAC;IACpD,MAAM,sBAAsB,CAAC,wBAAwB,CAAC,CAAC;IACvD,OAAO,IAAI,CAAC;AACd,CAAC;AATD,kDASC","sourcesContent":["import { readJsonFile } from \"@nrwl/devkit\";\nimport { execSync } from \"child_process\";\nimport * as pacote from \"pacote\";\nimport * as semver from \"semver\";\nimport { version } from \"./version\";\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) => {\n const localVersion = semver.minVersion(localRange) ?? localRange; // ('^1.0.0') => '1.0.0'\n if (!semver.satisfies(localVersion, range)) {\n throw new Error(\n `Package \"${pkg}\" outdated. Remote Version: ${range} Local version: ${localRange}. \\n Update package using command: 'npm i ${pkg}@${range}'`\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 versio\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(`Error fetching manifest for package ${pkg}`);\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} managerNodeVersion version of node in the manager\n * @returns { boolean } true if its a valid version\n */\nexport async function checkNodeVersion(managerNodeVersion: string) {\n const currentNodeVersion = await process.version.replace(/\\r?\\n|\\r/, \"\"); // regex removes any linebreaks\n return versionCheck(\"node\", currentNodeVersion, managerNodeVersion);\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) {\n const currentNxVersion = execSync(\"nx --version\")\n .toString(\"utf-8\")\n .replace(/\\r?\\n|\\r/, \"\"); // regex removes any linebreaks\n return versionCheck(\"nx\", currentNxVersion, managerNxVersion);\n}\n\n/**\n *\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function checkTrackunitPackages(packageJson: any) {\n for (const key in packageJson) {\n const remoteVersion: string | undefined = await getLatestRemoteVersion(key);\n if (remoteVersion) {\n const localDependencyVersion: string = packageJson[key];\n // If @trackunit dependencies are linked/added locally using \"file://\", skip the version check.\n if (!localDependencyVersion.includes(\"file://\")) {\n versionCheck(key, localDependencyVersion, remoteVersion);\n }\n }\n }\n return true;\n}\n\nfunction getLibraries() {\n const packageJsonLocal = readJsonFile(\"package.json\");\n const trackunitDependencies = Object.fromEntries(\n Object.entries(packageJsonLocal.dependencies).filter(([key]) => key.startsWith(\"@trackunit/\"))\n );\n const trackunitDevDependencies = Object.fromEntries(\n Object.entries(packageJsonLocal.devDependencies).filter(([key]) => key.startsWith(\"@trackunit/\"))\n );\n return { trackunitDependencies, trackunitDevDependencies };\n}\n\n/**\n *\n */\nexport async function checkPackageVersion() {\n const { trackunitDependencies, trackunitDevDependencies } = getLibraries();\n const managerNodeVersion = version.managerNodeVersion;\n const managerNxVersion = version.managerNxVersion;\n await checkNodeVersion(managerNodeVersion);\n await checkNxVersion(managerNxVersion);\n await checkTrackunitPackages(trackunitDependencies);\n await checkTrackunitPackages(trackunitDevDependencies);\n return true;\n}\n"]}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { IrisAppManifest } from "@trackunit/iris-app-api";
|
|
2
2
|
import * as webpack from "webpack";
|
|
3
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
|
+
*/
|
|
4
13
|
export declare const getDefaultConfig: (mode: "production" | "development", nxRootDir: string, appDir: string, irisAppManifest: IrisAppManifest) => Promise<webpack.Configuration>;
|
|
@@ -9,6 +9,15 @@ const webpack = tslib_1.__importStar(require("webpack"));
|
|
|
9
9
|
require("webpack-dev-server");
|
|
10
10
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
11
11
|
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
|
12
|
+
/**
|
|
13
|
+
* Gets the default webpack config.
|
|
14
|
+
*
|
|
15
|
+
* @param mode mode either "production" or "development"
|
|
16
|
+
* @param nxRootDir the root of the nx workspace
|
|
17
|
+
* @param appDir the app directory
|
|
18
|
+
* @param irisAppManifest the iris app manifest
|
|
19
|
+
* @returns { Promise<webpack.Configuration> } the default webpack config
|
|
20
|
+
*/
|
|
12
21
|
const getDefaultConfig = async (mode, nxRootDir, appDir, irisAppManifest) => {
|
|
13
22
|
const relativeAppDir = appDir.split(nxRootDir)[1];
|
|
14
23
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultWebpackConfig.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/executors/utils/defaultWebpackConfig.ts"],"names":[],"mappings":";;;;AACA,kFAK6C;AAC7C,gFAAmF;AACnF,mDAA6B;AAC7B,yDAAmC;AACnC,8BAA4B;AAC5B,8DAA8D;AAC9D,MAAM,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"defaultWebpackConfig.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/executors/utils/defaultWebpackConfig.ts"],"names":[],"mappings":";;;;AACA,kFAK6C;AAC7C,gFAAmF;AACnF,mDAA6B;AAC7B,yDAAmC;AACnC,8BAA4B;AAC5B,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,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAClD,OAAO;QACL,IAAI,EAAE,IAAI;QACV,MAAM,EAAE;YACN,UAAU,EAAE,MAAM;YAClB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,cAAc,CAAC;SACnD;QAED,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,GAAG,WAAW;QACnD,OAAO,EAAE,KAAK;QACd,SAAS,EAAE,MAAM,IAAA,kDAAuB,GAAE;QAC1C,OAAO,EAAE;YACP,UAAU,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC;YACnD,KAAK,EAAE,MAAM,IAAA,iDAAsB,EAAC,EAAE,SAAS,EAAE,CAAC;SACnD;QACD,MAAM,EAAE;YACN,KAAK,EAA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AQ,EAAE,IAAI,EAAE,eAAe,CAAC,oBAAoB,EAAE;gBACvE,OAAO,EAAE,EAAE;gBACX,OAAO,EAAE,MAAM,IAAA,+CAAoB,EAAC;oBAClC,SAAS;oBACT,QAAQ,EAAE,eAAe;iBAC1B,CAAC;gBACF,MAAM,EAAE,MAAM,IAAA,gDAAqB,EAAC,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC;aACnE,CAAC;YACF,IAAI,uDAA6B,CAAC;gBAChC,SAAS,EAAE,SAAS;gBACpB,MAAM;gBACN,QAAQ,EAAE,eAAe;aAC1B,CAAC;YACF,IAAI,iBAAiB,CAAC;gBACpB,QAAQ,EAAE;oBACR;wBACE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,4CAA4C;wBACrG,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC;qBACjC;iBACF;aACF,CAAC;SACH,CAAC,MAAM,CAAC,OAAO,CAAC;KAClB,CAAC;AACJ,CAAC,CAAC;AAhHW,QAAA,gBAAgB,oBAgH3B","sourcesContent":["import { IrisAppManifest } from \"@trackunit/iris-app-api\";\nimport {\n getAliasesFromTsConfig,\n getExposedExtensions,\n getSharedDependencies,\n getTileWebpackDevServer,\n} from \"@trackunit/iris-app-build-utilities\";\nimport { TrackunitIrisAppWebpackPlugin } from \"@trackunit/iris-app-webpack-plugin\";\nimport * as path from \"path\";\nimport * as webpack from \"webpack\";\nimport \"webpack-dev-server\";\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];\n return {\n mode: mode,\n output: {\n publicPath: \"auto\",\n path: path.join(nxRootDir, \"dist\", relativeAppDir),\n },\n\n entry: path.resolve(__dirname, \"src\") + \"/index.js\",\n devtool: false,\n devServer: await getTileWebpackDevServer(),\n resolve: {\n extensions: [\".tsx\", \".ts\", \".jsx\", \".js\", \".json\"],\n alias: await getAliasesFromTsConfig({ nxRootDir }),\n },\n module: {\n rules: [\n {\n test: /\\.m?js/,\n type: \"javascript/auto\",\n resolve: {\n fullySpecified: false,\n },\n },\n {\n test: /\\.svg$/,\n use: [\"@svgr/webpack\", \"url-loader\"],\n },\n {\n test: /\\.(png|jpg|gif|woff|ico)$/,\n exclude: /(node_modules)/,\n type: \"asset/resource\",\n },\n {\n test: /\\.(png|jpe?g|gif|svg|eot|ttf|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 loader: \"tsx\",\n jsx: \"automatic\",\n target: \"es6\",\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 new TrackunitIrisAppWebpackPlugin({\n nxRootDir: nxRootDir,\n appDir,\n manifest: irisAppManifest,\n }),\n new CopyWebpackPlugin({\n patterns: [\n {\n from: path.join(relativeAppDir.substring(1), \"assets\") + \"/**/(*.png|*.svg|*.jpg|*.jpeg|*.webp|*.md)\",\n to: path.join(nxRootDir, \"dist\"),\n },\n ],\n }),\n ].filter(Boolean),\n };\n};\n"]}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
const {
|
|
2
|
-
const path = require("path");
|
|
1
|
+
const { getTrackunitTailwindConfig } = require('@trackunit/iris-app-build-utilities');
|
|
3
2
|
|
|
4
3
|
module.exports = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
nxRootDir: path.resolve(__dirname, "<%= toNxRoot %>"),
|
|
8
|
-
app: "<%= projectName %>",
|
|
9
|
-
}),
|
|
10
|
-
plugins: [require("@trackunit/css-components")],
|
|
4
|
+
...getTrackunitTailwindConfig({ appDir: __dirname }),
|
|
5
|
+
// your custom stuff here
|
|
11
6
|
};
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { Tree } from "@nrwl/devkit";
|
|
2
2
|
import { IrisAppGeneratorSchema } from "./schema";
|
|
3
|
+
/**
|
|
4
|
+
* Iris App Generator.
|
|
5
|
+
* This generator will create a new iris app, you can call this from your own generator.
|
|
6
|
+
*
|
|
7
|
+
* @param tree the nx tree
|
|
8
|
+
* @param options the generator options
|
|
9
|
+
* @returns { Promise<void> } void
|
|
10
|
+
*/
|
|
3
11
|
export declare const IrisAppGenerator: (tree: Tree, options: IrisAppGeneratorSchema) => Promise<() => void>;
|
|
4
12
|
export default IrisAppGenerator;
|
|
@@ -30,6 +30,14 @@ function addFiles(tree, options) {
|
|
|
30
30
|
};
|
|
31
31
|
(0, devkit_1.generateFiles)(tree, path.join(__dirname, "files"), options.projectRoot, templateOptions);
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Iris App Generator.
|
|
35
|
+
* This generator will create a new iris app, you can call this from your own generator.
|
|
36
|
+
*
|
|
37
|
+
* @param tree the nx tree
|
|
38
|
+
* @param options the generator options
|
|
39
|
+
* @returns { Promise<void> } void
|
|
40
|
+
*/
|
|
33
41
|
const IrisAppGenerator = async function (tree, options) {
|
|
34
42
|
const normalizedOptions = normalizeOptions(tree, options);
|
|
35
43
|
const packageJsonFromNpm = await pacote.manifest("@trackunit/iris-app");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/generators/create/generator.ts"],"names":[],"mappings":";;;;AAAA,yCAWsB;AACtB,uDAAiC;AACjC,mDAA6B;AAW7B,SAAS,gBAAgB,CAAC,IAAU,EAAE,OAA+B;IACnE,MAAM,IAAI,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IAC1C,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvF,MAAM,QAAQ,GAAG,SAAS,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAC9E,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAC5D,MAAM,QAAQ,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IACnD,MAAM,WAAW,GAAG,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC,OAAO,IAAI,gBAAgB,EAAE,CAAC;IAC9E,OAAO;QACL,GAAG,OAAO;QACV,WAAW;QACX,WAAW;QACX,gBAAgB;QAChB,QAAQ;QACR,QAAQ;KACT,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,IAAU,EAAE,OAAyB;IACrD,MAAM,eAAe,GAAG;QACtB,GAAG,OAAO;QACV,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC;QACtB,cAAc,EAAE,IAAA,uBAAc,EAAC,OAAO,CAAC,WAAW,CAAC;QACnD,QAAQ,EAAE,EAAE;KACb,CAAC;IACF,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;AAC3F,CAAC;
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/generators/create/generator.ts"],"names":[],"mappings":";;;;AAAA,yCAWsB;AACtB,uDAAiC;AACjC,mDAA6B;AAW7B,SAAS,gBAAgB,CAAC,IAAU,EAAE,OAA+B;IACnE,MAAM,IAAI,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IAC1C,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvF,MAAM,QAAQ,GAAG,SAAS,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAC9E,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IAC5D,MAAM,QAAQ,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC,QAAQ,CAAC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EAAE,IAAI,CAAC,CAAC;IAClC,CAAC,CAAC;AACJ,CAAC,CAAC;AAjGW,QAAA,gBAAgB,oBAiG3B;AAEF,kBAAe,wBAAgB,CAAC","sourcesContent":["import {\n addDependenciesToPackageJson,\n addProjectConfiguration,\n formatFiles,\n generateFiles,\n getWorkspaceLayout,\n installPackagesTask,\n names,\n offsetFromRoot,\n readJsonFile,\n Tree,\n} from \"@nrwl/devkit\";\nimport * as pacote from \"pacote\";\nimport * as path from \"path\";\nimport { IrisAppGeneratorSchema } from \"./schema\";\n\ninterface NormalizedSchema extends IrisAppGeneratorSchema {\n projectName: string;\n projectRoot: string;\n projectDirectory: string;\n toNxRoot: string;\n npmScope: string;\n}\n\nfunction normalizeOptions(tree: Tree, options: IrisAppGeneratorSchema): NormalizedSchema {\n const name = names(options.name).fileName;\n const projectDirectory = options.directory ? path.join(options.directory, name) : name;\n const toNxRoot = `../../${projectDirectory.indexOf(\"/\") !== -1 ? \"../\" : \"\"}`;\n const projectName = name.replace(new RegExp(\"/\", \"g\"), \"_\");\n const npmScope = getWorkspaceLayout(tree).npmScope;\n const projectRoot = `${getWorkspaceLayout(tree).appsDir}/${projectDirectory}`;\n return {\n ...options,\n projectName,\n projectRoot,\n projectDirectory,\n toNxRoot,\n npmScope,\n };\n}\n\nfunction addFiles(tree: Tree, options: NormalizedSchema) {\n const templateOptions = {\n ...options,\n ...names(options.name),\n offsetFromRoot: offsetFromRoot(options.projectRoot),\n template: \"\",\n };\n generateFiles(tree, path.join(__dirname, \"files\"), options.projectRoot, templateOptions);\n}\n\n/**\n * Iris App Generator.\n * This generator will create a new iris app, you can call this from your own generator.\n *\n * @param tree the nx tree\n * @param options the generator options\n * @returns { Promise<void> } void\n */\nexport const IrisAppGenerator = async function (tree: Tree, options: IrisAppGeneratorSchema) {\n const normalizedOptions = normalizeOptions(tree, options);\n const packageJsonFromNpm = await pacote.manifest(\"@trackunit/iris-app\");\n\n const packageJsonLocally = readJsonFile(path.join(__dirname, \"..\", \"..\", \"..\", \"package.json\"));\n\n if (options.updatePackageJson) {\n if (packageJsonFromNpm.version !== packageJsonLocally.version) {\n throw new Error(\n `This version of the iris-app package does not match the version of the iris-app package from NPM JS. Please update using: npm i @trackunit/iris-app@${packageJsonFromNpm.version}`\n );\n }\n\n const reactComponentsPackageJsonFromNpm = pacote.manifest(\"@trackunit/react-components\");\n const reactCoreContextsPackageJsonFromNpm = pacote.manifest(\"@trackunit/react-core-contexts\");\n const cssComponentsPackageJsonFromNpm = pacote.manifest(\"@trackunit/css-components\");\n const cssTailwindPackageJsonFromNpm = pacote.manifest(\"@trackunit/css-tailwind\");\n const irisAppApiPackageJsonFromNpm = pacote.manifest(\"@trackunit/iris-app-api\");\n const irisAppBuildUtilitiesPackageJsonFromNpm = pacote.manifest(\"@trackunit/iris-app-build-utilities\");\n const irisAppWebpackPluginPackageJsonFromNpm = pacote.manifest(\"@trackunit/iris-app-webpack-plugin\");\n\n addDependenciesToPackageJson(\n tree,\n {\n tslib: \"^2.3.1\",\n \"@trackunit/react-components\": (await reactComponentsPackageJsonFromNpm).version,\n \"@trackunit/react-core-contexts\": (await reactCoreContextsPackageJsonFromNpm).version,\n \"@trackunit/css-components\": (await cssComponentsPackageJsonFromNpm).version,\n \"@trackunit/css-tailwind\": (await cssTailwindPackageJsonFromNpm).version,\n },\n {\n \"@trackunit/iris-app-api\": (await irisAppApiPackageJsonFromNpm).version,\n \"@trackunit/iris-app-build-utilities\": (await irisAppBuildUtilitiesPackageJsonFromNpm).version,\n \"@trackunit/iris-app-webpack-plugin\": (await irisAppWebpackPluginPackageJsonFromNpm).version,\n \"@nrwl/react\": \"^14.5.6\",\n \"@nrwl/workspace\": \"^14.5.6\",\n \"@nrwl/devkit\": \"^14.5.6\",\n eslint: \"^8.0.0\",\n \"ts-morph\": \"^13.0.2\",\n \"esbuild-loader\": \"^2.20.0\",\n \"postcss-js\": \"^4.0.0\",\n \"postcss-loader\": \"^6.2.1\",\n \"postcss-nested\": \"^5.0.6\",\n postcss: \"^8.4.7\",\n \"style-loader\": \"^3.3.1\",\n \"json-loader\": \"^0.5.7\",\n autoprefixer: \"^10.4.2\",\n \"css-loader\": \"^6.6.0\",\n webpack: \"^5.65.0\",\n tailwindcss: \"^3.0.23\",\n \"ts-node\": \"^10.4.0\",\n \"webpack-dev-server\": \"4.7.3\",\n \"webpack-cli\": \"^4.9.1\",\n }\n );\n }\n addProjectConfiguration(tree, normalizedOptions.projectName, {\n root: normalizedOptions.projectRoot,\n projectType: \"application\",\n sourceRoot: `${normalizedOptions.projectRoot}/src`,\n targets: {\n build: {\n executor: \"@trackunit/iris-app:build\",\n options: {\n webpackConfig: `${normalizedOptions.projectRoot}/webpack.config.ts`,\n outputPath: `dist/${normalizedOptions.projectRoot}`,\n },\n outputs: [\"{options.outputPath}\"],\n },\n serve: {\n executor: \"@trackunit/iris-app:serve\",\n options: {\n webpackConfig: `${normalizedOptions.projectRoot}/webpack.config.ts`,\n },\n outputs: [\"{options.outputPath}\"],\n },\n publishApp: {\n executor: \"@trackunit/iris-app:publish\",\n options: {\n inputPath: `dist/${normalizedOptions.projectRoot}`,\n },\n dependsOn: [\n {\n target: \"build\",\n projects: \"self\",\n },\n ],\n outputs: [\"dist/\" + normalizedOptions.projectRoot],\n },\n },\n });\n addFiles(tree, normalizedOptions);\n\n await formatFiles(tree);\n return () => {\n installPackagesTask(tree, true);\n };\n};\n\nexport default IrisAppGenerator;\n"]}
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { Tree } from "@nrwl/devkit";
|
|
2
2
|
import { IrisAppExtensionGeneratorSchema } from "./schema";
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Iris App Extension Generator.
|
|
5
|
+
*
|
|
6
|
+
* @param tree the nx tree
|
|
7
|
+
* @param options the generator options
|
|
8
|
+
* @returns { Promise<void> } void
|
|
9
|
+
*/
|
|
10
|
+
export declare const IrisAppExtensionGenerator: (tree: Tree, options: IrisAppExtensionGeneratorSchema) => Promise<() => void>;
|
|
4
11
|
export default IrisAppExtensionGenerator;
|
|
@@ -31,16 +31,23 @@ function normalizeOptions(tree, options) {
|
|
|
31
31
|
sourceRoot,
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Iris App Extension Generator.
|
|
36
|
+
*
|
|
37
|
+
* @param tree the nx tree
|
|
38
|
+
* @param options the generator options
|
|
39
|
+
* @returns { Promise<void> } void
|
|
40
|
+
*/
|
|
41
|
+
const IrisAppExtensionGenerator = async function (tree, options) {
|
|
42
|
+
const adjustedOptions = await updateAppName(tree, options);
|
|
43
|
+
const normalizedOptions = normalizeOptions(tree, adjustedOptions);
|
|
37
44
|
const templateOptions = {
|
|
38
45
|
...normalizedOptions,
|
|
39
|
-
...(0, devkit_1.names)(
|
|
46
|
+
...(0, devkit_1.names)(normalizedOptions.name),
|
|
40
47
|
offsetFromRoot: (0, devkit_1.offsetFromRoot)(normalizedOptions.projectRoot),
|
|
41
48
|
template: "",
|
|
42
49
|
};
|
|
43
|
-
const irisAppExtensionType =
|
|
50
|
+
const irisAppExtensionType = normalizedOptions.type;
|
|
44
51
|
if (!fs.existsSync(`${(0, devkit_1.getWorkspaceLayout)(tree).appsDir}/${normalizedOptions.app}`)) {
|
|
45
52
|
throw new Error(`The app does not exist: ${(0, devkit_1.getWorkspaceLayout)(tree).appsDir}/${normalizedOptions.app} make sure you enter the right app name`);
|
|
46
53
|
}
|
|
@@ -49,13 +56,13 @@ const IrisAppExtensionGenerator = async function (tree, schemaOptions) {
|
|
|
49
56
|
throw new Error(`The app does not have an iris-app-manifest.ts: ${manifestPath} make sure you enter the right app name, which has an iris-app-manifest.ts`);
|
|
50
57
|
}
|
|
51
58
|
(0, devkit_1.generateFiles)(tree, path.join(__dirname, "files", irisAppExtensionType), normalizedOptions.projectRoot, templateOptions);
|
|
52
|
-
if (
|
|
59
|
+
if (normalizedOptions.updatePackageJson) {
|
|
53
60
|
(0, devkit_1.addDependenciesToPackageJson)(tree, {}, {
|
|
54
61
|
...singleSpaDependencies_1.spaDependencies,
|
|
55
62
|
});
|
|
56
63
|
}
|
|
57
64
|
const schema = {
|
|
58
|
-
name:
|
|
65
|
+
name: normalizedOptions.name,
|
|
59
66
|
style: "none",
|
|
60
67
|
skipFormat: false,
|
|
61
68
|
strict: true,
|
|
@@ -63,7 +70,7 @@ const IrisAppExtensionGenerator = async function (tree, schemaOptions) {
|
|
|
63
70
|
linter: linter_1.Linter.EsLint,
|
|
64
71
|
routing: false,
|
|
65
72
|
pascalCaseFiles: true,
|
|
66
|
-
directory:
|
|
73
|
+
directory: normalizedOptions.directory,
|
|
67
74
|
skipTsConfig: false,
|
|
68
75
|
skipPackageJson: true,
|
|
69
76
|
standaloneConfig: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/generators/extend/generator.ts"],"names":[],"mappings":";;;;AAAA,yCAWsB;AACtB,yCAAsC;AACtC,uCAA+C;AAE/C,yEAAqF;AACrF,kEAAkC;AAClC,uCAAkC;AAClC,+CAAyB;AACzB,mDAA6B;AAC7B,uCAAqD;AAErD,mEAA0D;AAW1D,SAAS,gBAAgB,CAAC,IAAU,EAAE,OAAwC;IAC5E,MAAM,IAAI,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IAC1C,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACnG,MAAM,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IACxE,MAAM,gBAAgB,GAAG,IAAA,mBAAS,E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C,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,MAAc,EAAE,EAAE;gBACjD,2DAA2D;gBAC3D,OAAO,CAAC,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;YAC9B,CAAC,CAAC,CAAC;SACJ;KACF;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,kBAAe,iCAAyB,CAAC","sourcesContent":["import {\n addDependenciesToPackageJson,\n formatFiles,\n generateFiles,\n getWorkspaceLayout,\n installPackagesTask,\n joinPathFragments,\n names,\n offsetFromRoot,\n Tree,\n updateJson,\n} from \"@nrwl/devkit\";\nimport { Linter } from \"@nrwl/linter\";\nimport { libraryGenerator } from \"@nrwl/react\";\nimport { Schema } from \"@nrwl/react/src/generators/library/schema\";\nimport { getRootTsConfigPathInTree } from \"@nrwl/workspace/src/utilities/typescript\";\nimport camelCase from \"camelcase\";\nimport { prompt } from \"enquirer\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport { Node, Project, SyntaxKind } from \"ts-morph\";\nimport { IrisAppExtensionGeneratorSchema } from \"./schema\";\nimport { spaDependencies } from \"./singleSpaDependencies\";\n\ninterface NormalizedSchema extends IrisAppExtensionGeneratorSchema {\n projectName: string;\n projectRoot: string;\n projectDirectory: string;\n projectCamelcase: string;\n importPath: string;\n sourceRoot: string;\n}\n\nfunction normalizeOptions(tree: Tree, options: IrisAppExtensionGeneratorSchema): NormalizedSchema {\n const name = names(options.name).fileName;\n const projectDirectory = options.directory ? `${names(options.directory).fileName}/${name}` : name;\n const projectName = projectDirectory.replace(new RegExp(\"/\", \"g\"), \"-\");\n const projectCamelcase = camelCase(name);\n const wsLayout = getWorkspaceLayout(tree);\n const projectRoot = `${wsLayout.libsDir}/${projectDirectory}`;\n const sourceRoot = `${wsLayout.libsDir}/${projectDirectory}/src`;\n const importPath = `@${wsLayout.npmScope}/${projectDirectory}`;\n\n return {\n ...options,\n projectName,\n projectRoot,\n projectDirectory,\n projectCamelcase,\n importPath,\n sourceRoot,\n };\n}\n\nexport const IrisAppExtensionGenerator = async function(tree: Tree, schemaOptions: IrisAppExtensionGeneratorSchema) {\n const options = await updateAppName(tree, schemaOptions);\n\n const normalizedOptions = normalizeOptions(tree, options);\n\n const templateOptions = {\n ...normalizedOptions,\n ...names(options.name),\n offsetFromRoot: offsetFromRoot(normalizedOptions.projectRoot),\n template: \"\",\n };\n const irisAppExtensionType = options.type;\n\n if (!fs.existsSync(`${getWorkspaceLayout(tree).appsDir}/${normalizedOptions.app}`)) {\n throw new Error(\n `The app does not exist: ${getWorkspaceLayout(tree).appsDir}/${normalizedOptions.app\n } make sure you enter the right app name`\n );\n }\n\n const manifestPath = `${getWorkspaceLayout(tree).appsDir}/${normalizedOptions.app}/iris-app-manifest.ts`;\n if (!fs.existsSync(manifestPath)) {\n throw new Error(`The app does not have an iris-app-manifest.ts: ${manifestPath} make sure you enter the right app name, which has an iris-app-manifest.ts`);\n }\n generateFiles(\n tree,\n path.join(__dirname, \"files\", irisAppExtensionType),\n normalizedOptions.projectRoot,\n templateOptions\n );\n\n if (options.updatePackageJson) {\n addDependenciesToPackageJson(\n tree,\n {},\n {\n ...spaDependencies,\n }\n );\n }\n\n const schema: Schema = {\n name: options.name,\n style: \"none\",\n skipFormat: false,\n strict: true,\n unitTestRunner: \"jest\",\n linter: Linter.EsLint,\n routing: false,\n pascalCaseFiles: true,\n directory: options.directory,\n skipTsConfig: false,\n skipPackageJson: true,\n standaloneConfig: true,\n };\n await libraryGenerator(tree, schema);\n\n if (irisAppExtensionType !== \"REPORT_EXTENSION\") {\n generateFiles(tree, path.join(__dirname, \"files\", \"react-app\"), normalizedOptions.projectRoot, templateOptions);\n }\n\n const rootTsConfigPath = getRootTsConfigPathInTree(tree);\n if (!rootTsConfigPath) {\n throw new Error(\"Could not find root tsconfig.json\");\n }\n updateJson(tree, rootTsConfigPath, tsConfigBase => {\n tsConfigBase.compilerOptions.paths[normalizedOptions.importPath] = [\n path.join(normalizedOptions.projectRoot, \"extension-manifest.ts\"),\n ];\n return tsConfigBase;\n });\n\n const project = new Project({\n tsConfigFilePath: `${getWorkspaceLayout(tree).appsDir}/${normalizedOptions.app}/tsconfig.app.json`,\n });\n\n const manifest = project.getSourceFileOrThrow(manifestPath);\n\n manifest.addImportDeclaration({\n moduleSpecifier: normalizedOptions.importPath,\n defaultImport: normalizedOptions.projectCamelcase,\n });\n\n manifest.forEachDescendant(node => {\n if (Node.isPropertyAssignment(node)) {\n if (node.getText().indexOf(\"extensions\") !== -1) {\n const array = node.getFirstChildByKindOrThrow(SyntaxKind.ArrayLiteralExpression);\n array.addElement(`${normalizedOptions.projectCamelcase}`);\n }\n }\n });\n await manifest.save();\n\n tree.delete(joinPathFragments(normalizedOptions.projectRoot, \"src\", \"index.ts\"));\n\n updateJson(tree, joinPathFragments(normalizedOptions.projectRoot, \"tsconfig.lib.json\"), tsConfigLib => {\n tsConfigLib.include = [...tsConfigLib.include, \"extension-manifest.ts\"];\n return tsConfigLib;\n });\n\n await formatFiles(tree);\n return () => {\n installPackagesTask(tree, true);\n };\n};\nconst updateAppName = async (tree: Tree, options: IrisAppExtensionGeneratorSchema) => {\n if (!options.app) {\n const folders = fs\n .readdirSync(getWorkspaceLayout(tree).appsDir, { withFileTypes: true })\n .filter(item => item.isDirectory());\n\n const tileApps: string[] = [];\n\n folders.forEach(folder => {\n const irisAppManifest = fs\n .readdirSync(`${getWorkspaceLayout(tree).appsDir}/${folder.name}`, { withFileTypes: true })\n .find(item => item.name === \"iris-app-manifest.ts\");\n\n if (irisAppManifest) {\n tileApps.push(folder.name);\n } else {\n const subFolders = fs\n .readdirSync(path.join(getWorkspaceLayout(tree).appsDir, folder.name), { withFileTypes: true })\n .filter(item => item.isDirectory());\n subFolders.forEach(subFolder => {\n const subDirIrisAppManifest = fs\n .readdirSync(`${getWorkspaceLayout(tree).appsDir}/${folder.name}/${subFolder.name}`, {\n withFileTypes: true,\n })\n .find(item => item.name === \"iris-app-manifest.ts\");\n\n if (subDirIrisAppManifest) {\n tileApps.push(path.join(folder.name, subFolder.name));\n }\n });\n }\n });\n\n if (tileApps.length === 1) {\n options.app = tileApps[0];\n } else if (tileApps.length === 0) {\n throw new Error(\"Please add an iris-app using: nx g @trackunit/iris-app:create \");\n } else {\n const promptObject = {\n name: \"app\",\n message: \"Select iris-app for this extension:\",\n type: \"select\",\n choices: tileApps.map(item => item),\n };\n await prompt(promptObject).then((values: object) => {\n // eslint-disable-next-line @typescript-eslint/dot-notation\n options.app = values[\"app\"];\n });\n }\n }\n return options;\n};\n\nexport default IrisAppExtensionGenerator;\n"]}
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../libs/iris-app-sdk/iris-app/src/generators/extend/generator.ts"],"names":[],"mappings":";;;;AAAA,yCAWsB;AACtB,yCAAsC;AACtC,uCAA+C;AAE/C,yEAAqF;AACrF,kEAAkC;AAClC,uCAAkC;AAClC,+CAAyB;AACzB,mDAA6B;AAC7B,uCAAqD;AAErD,mEAA0D;AAW1D,SAAS,gBAAgB,CAAC,IAAU,EAAE,OAAwC;IAC5E,MAAM,IAAI,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC;IAC1C,MAAM,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,SAAS,CAAC,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACnG,MAAM,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;IACxE,MAAM,gBAAgB,GAAG,IAAA,mBAAS,EAAC,IAAI,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,IAAA,2BAAkB,EAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,WAAW,GAAG,GAAG,QAAQ,CAAC,OAAO,IAAI,gBAAgB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C,CAAC;YAC9B,CAAC,CAAC,CAAC;SACJ;KACF;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,kBAAe,iCAAyB,CAAC","sourcesContent":["import {\n addDependenciesToPackageJson,\n formatFiles,\n generateFiles,\n getWorkspaceLayout,\n installPackagesTask,\n joinPathFragments,\n names,\n offsetFromRoot,\n Tree,\n updateJson,\n} from \"@nrwl/devkit\";\nimport { Linter } from \"@nrwl/linter\";\nimport { libraryGenerator } from \"@nrwl/react\";\nimport { Schema } from \"@nrwl/react/src/generators/library/schema\";\nimport { getRootTsConfigPathInTree } from \"@nrwl/workspace/src/utilities/typescript\";\nimport camelCase from \"camelcase\";\nimport { prompt } from \"enquirer\";\nimport * as fs from \"fs\";\nimport * as path from \"path\";\nimport { Node, Project, SyntaxKind } from \"ts-morph\";\nimport { IrisAppExtensionGeneratorSchema } from \"./schema\";\nimport { spaDependencies } from \"./singleSpaDependencies\";\n\ninterface NormalizedSchema extends IrisAppExtensionGeneratorSchema {\n projectName: string;\n projectRoot: string;\n projectDirectory: string;\n projectCamelcase: string;\n importPath: string;\n sourceRoot: string;\n}\n\nfunction normalizeOptions(tree: Tree, options: IrisAppExtensionGeneratorSchema): NormalizedSchema {\n const name = names(options.name).fileName;\n const projectDirectory = options.directory ? `${names(options.directory).fileName}/${name}` : name;\n const projectName = projectDirectory.replace(new RegExp(\"/\", \"g\"), \"-\");\n const projectCamelcase = camelCase(name);\n const wsLayout = getWorkspaceLayout(tree);\n const projectRoot = `${wsLayout.libsDir}/${projectDirectory}`;\n const sourceRoot = `${wsLayout.libsDir}/${projectDirectory}/src`;\n const importPath = `@${wsLayout.npmScope}/${projectDirectory}`;\n\n return {\n ...options,\n projectName,\n projectRoot,\n projectDirectory,\n projectCamelcase,\n importPath,\n sourceRoot,\n };\n}\n\n/**\n * Iris App Extension Generator.\n *\n * @param tree the nx tree\n * @param options the generator options\n * @returns { Promise<void> } void\n */\nexport const IrisAppExtensionGenerator = async function (tree: Tree, options: IrisAppExtensionGeneratorSchema) {\n const adjustedOptions = await updateAppName(tree, options);\n\n const normalizedOptions = normalizeOptions(tree, adjustedOptions);\n\n const templateOptions = {\n ...normalizedOptions,\n ...names(normalizedOptions.name),\n offsetFromRoot: offsetFromRoot(normalizedOptions.projectRoot),\n template: \"\",\n };\n const irisAppExtensionType = normalizedOptions.type;\n\n if (!fs.existsSync(`${getWorkspaceLayout(tree).appsDir}/${normalizedOptions.app}`)) {\n throw new Error(\n `The app does not exist: ${getWorkspaceLayout(tree).appsDir}/${\n normalizedOptions.app\n } make sure you enter the right app name`\n );\n }\n\n const manifestPath = `${getWorkspaceLayout(tree).appsDir}/${normalizedOptions.app}/iris-app-manifest.ts`;\n if (!fs.existsSync(manifestPath)) {\n throw new Error(\n `The app does not have an iris-app-manifest.ts: ${manifestPath} make sure you enter the right app name, which has an iris-app-manifest.ts`\n );\n }\n generateFiles(\n tree,\n path.join(__dirname, \"files\", irisAppExtensionType),\n normalizedOptions.projectRoot,\n templateOptions\n );\n\n if (normalizedOptions.updatePackageJson) {\n addDependenciesToPackageJson(\n tree,\n {},\n {\n ...spaDependencies,\n }\n );\n }\n\n const schema: Schema = {\n name: normalizedOptions.name,\n style: \"none\",\n skipFormat: false,\n strict: true,\n unitTestRunner: \"jest\",\n linter: Linter.EsLint,\n routing: false,\n pascalCaseFiles: true,\n directory: normalizedOptions.directory,\n skipTsConfig: false,\n skipPackageJson: true,\n standaloneConfig: true,\n };\n await libraryGenerator(tree, schema);\n\n if (irisAppExtensionType !== \"REPORT_EXTENSION\") {\n generateFiles(tree, path.join(__dirname, \"files\", \"react-app\"), normalizedOptions.projectRoot, templateOptions);\n }\n\n const rootTsConfigPath = getRootTsConfigPathInTree(tree);\n if (!rootTsConfigPath) {\n throw new Error(\"Could not find root tsconfig.json\");\n }\n updateJson(tree, rootTsConfigPath, tsConfigBase => {\n tsConfigBase.compilerOptions.paths[normalizedOptions.importPath] = [\n path.join(normalizedOptions.projectRoot, \"extension-manifest.ts\"),\n ];\n return tsConfigBase;\n });\n\n const project = new Project({\n tsConfigFilePath: `${getWorkspaceLayout(tree).appsDir}/${normalizedOptions.app}/tsconfig.app.json`,\n });\n\n const manifest = project.getSourceFileOrThrow(manifestPath);\n\n manifest.addImportDeclaration({\n moduleSpecifier: normalizedOptions.importPath,\n defaultImport: normalizedOptions.projectCamelcase,\n });\n\n manifest.forEachDescendant(node => {\n if (Node.isPropertyAssignment(node)) {\n if (node.getText().indexOf(\"extensions\") !== -1) {\n const array = node.getFirstChildByKindOrThrow(SyntaxKind.ArrayLiteralExpression);\n array.addElement(`${normalizedOptions.projectCamelcase}`);\n }\n }\n });\n await manifest.save();\n\n tree.delete(joinPathFragments(normalizedOptions.projectRoot, \"src\", \"index.ts\"));\n\n updateJson(tree, joinPathFragments(normalizedOptions.projectRoot, \"tsconfig.lib.json\"), tsConfigLib => {\n tsConfigLib.include = [...tsConfigLib.include, \"extension-manifest.ts\"];\n return tsConfigLib;\n });\n\n await formatFiles(tree);\n return () => {\n installPackagesTask(tree, true);\n };\n};\nconst updateAppName = async (tree: Tree, options: IrisAppExtensionGeneratorSchema) => {\n if (!options.app) {\n const folders = fs\n .readdirSync(getWorkspaceLayout(tree).appsDir, { withFileTypes: true })\n .filter(item => item.isDirectory());\n\n const tileApps: string[] = [];\n\n folders.forEach(folder => {\n const irisAppManifest = fs\n .readdirSync(`${getWorkspaceLayout(tree).appsDir}/${folder.name}`, { withFileTypes: true })\n .find(item => item.name === \"iris-app-manifest.ts\");\n\n if (irisAppManifest) {\n tileApps.push(folder.name);\n } else {\n const subFolders = fs\n .readdirSync(path.join(getWorkspaceLayout(tree).appsDir, folder.name), { withFileTypes: true })\n .filter(item => item.isDirectory());\n subFolders.forEach(subFolder => {\n const subDirIrisAppManifest = fs\n .readdirSync(`${getWorkspaceLayout(tree).appsDir}/${folder.name}/${subFolder.name}`, {\n withFileTypes: true,\n })\n .find(item => item.name === \"iris-app-manifest.ts\");\n\n if (subDirIrisAppManifest) {\n tileApps.push(path.join(folder.name, subFolder.name));\n }\n });\n }\n });\n\n if (tileApps.length === 1) {\n options.app = tileApps[0];\n } else if (tileApps.length === 0) {\n throw new Error(\"Please add an iris-app using: nx g @trackunit/iris-app:create \");\n } else {\n const promptObject = {\n name: \"app\",\n message: \"Select iris-app for this extension:\",\n type: \"select\",\n choices: tileApps.map(item => item),\n };\n await prompt(promptObject).then((values: object) => {\n // eslint-disable-next-line @typescript-eslint/dot-notation\n options.app = values[\"app\"];\n });\n }\n }\n return options;\n};\n\nexport default IrisAppExtensionGenerator;\n"]}
|
|
@@ -1,3 +1,17 @@
|
|
|
1
1
|
import { Tree } from "@nrwl/devkit";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Add a dev dependency to the package.json
|
|
4
|
+
*
|
|
5
|
+
* @param { Tree } host the nx tree
|
|
6
|
+
* @param { string } packageName the package name
|
|
7
|
+
* @param { string } version the package version
|
|
8
|
+
*/
|
|
9
|
+
export declare const addDevDependency: (host: Tree, packageName: string, version?: string) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Add a dependency to the package.json
|
|
12
|
+
*
|
|
13
|
+
* @param { Tree } host the nx tree
|
|
14
|
+
* @param { string } packageName the package name
|
|
15
|
+
* @param { string } version the package version
|
|
16
|
+
*/
|
|
17
|
+
export declare const addDependency: (host: Tree, packageName: string, version?: string) => void;
|
|
@@ -2,38 +2,50 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.addDependency = exports.addDevDependency = void 0;
|
|
4
4
|
const devkit_1 = require("@nrwl/devkit");
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Add a dev dependency to the package.json
|
|
7
|
+
*
|
|
8
|
+
* @param { Tree } host the nx tree
|
|
9
|
+
* @param { string } packageName the package name
|
|
10
|
+
* @param { string } version the package version
|
|
11
|
+
*/
|
|
12
|
+
const addDevDependency = (host, packageName, version = "*") => {
|
|
6
13
|
const packageJsonPath = "package.json";
|
|
7
14
|
const currentPackageJson = (0, devkit_1.readJson)(host, packageJsonPath);
|
|
8
15
|
const isPackageInstalled = currentPackageJson.devDependencies?.[packageName] !== undefined;
|
|
9
|
-
if (isPackageInstalled) {
|
|
10
|
-
|
|
16
|
+
if (!isPackageInstalled) {
|
|
17
|
+
const modifiedPackageJson = {
|
|
18
|
+
...currentPackageJson,
|
|
19
|
+
devDependencies: {
|
|
20
|
+
...currentPackageJson.devDependencies,
|
|
21
|
+
[packageName]: version,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
host.write(packageJsonPath, JSON.stringify(modifiedPackageJson, null, 2));
|
|
11
25
|
}
|
|
12
|
-
|
|
13
|
-
...currentPackageJson,
|
|
14
|
-
devDependencies: {
|
|
15
|
-
...currentPackageJson.devDependencies,
|
|
16
|
-
[packageName]: version,
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
host.write(packageJsonPath, JSON.stringify(modifiedPackageJson, null, 2));
|
|
20
|
-
}
|
|
26
|
+
};
|
|
21
27
|
exports.addDevDependency = addDevDependency;
|
|
22
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Add a dependency to the package.json
|
|
30
|
+
*
|
|
31
|
+
* @param { Tree } host the nx tree
|
|
32
|
+
* @param { string } packageName the package name
|
|
33
|
+
* @param { string } version the package version
|
|
34
|
+
*/
|
|
35
|
+
const addDependency = (host, packageName, version = "*") => {
|
|
23
36
|
const packageJsonPath = "package.json";
|
|
24
37
|
const currentPackageJson = (0, devkit_1.readJson)(host, packageJsonPath);
|
|
25
38
|
const isPackageInstalled = currentPackageJson.dependencies?.[packageName] !== undefined;
|
|
26
|
-
if (isPackageInstalled) {
|
|
27
|
-
|
|
39
|
+
if (!isPackageInstalled) {
|
|
40
|
+
const modifiedPackageJson = {
|
|
41
|
+
...currentPackageJson,
|
|
42
|
+
dependencies: {
|
|
43
|
+
...currentPackageJson.dependencies,
|
|
44
|
+
[packageName]: version,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
host.write(packageJsonPath, JSON.stringify(modifiedPackageJson, null, 2));
|
|
28
48
|
}
|
|
29
|
-
|
|
30
|
-
...currentPackageJson,
|
|
31
|
-
dependencies: {
|
|
32
|
-
...currentPackageJson.dependencies,
|
|
33
|
-
[packageName]: version,
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
host.write(packageJsonPath, JSON.stringify(modifiedPackageJson, null, 2));
|
|
37
|
-
}
|
|
49
|
+
};
|
|
38
50
|
exports.addDependency = addDependency;
|
|
39
51
|
//# sourceMappingURL=addDevDependency.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addDevDependency.js","sourceRoot":"","sources":["../../../../../../libs/iris-app-sdk/iris-app/src/utils/addDevDependency.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"addDevDependency.js","sourceRoot":"","sources":["../../../../../../libs/iris-app-sdk/iris-app/src/utils/addDevDependency.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAE9C;;;;;;GAMG;AACI,MAAM,gBAAgB,GAAG,CAAC,IAAU,EAAE,WAAmB,EAAE,OAAO,GAAG,GAAG,EAAE,EAAE;IACjF,MAAM,eAAe,GAAG,cAAc,CAAC;IACvC,MAAM,kBAAkB,GAAG,IAAA,iBAAQ,EAAC,IAAI,EAAE,eAAe,CAAC,CAAC;IAC3D,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,eAAe,EAAE,CAAC,WAAW,CAAC,KAAK,SAAS,CAAC;IAE3F,IAAI,CAAC,kBAAkB,EAAE;QACvB,MAAM,mBAAmB,GAAG;YAC1B,GAAG,kBAAkB;YACrB,eAAe,EAAE;gBACf,GAAG,kBAAkB,CAAC,eAAe;gBACrC,CAAC,WAAW,CAAC,EAAE,OAAO;aACvB;SACF,CAAC;QAEF,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;KAC3E;AACH,CAAC,CAAC;AAhBW,QAAA,gBAAgB,oBAgB3B;AAEF;;;;;;GAMG;AACI,MAAM,aAAa,GAAG,CAAC,IAAU,EAAE,WAAmB,EAAE,OAAO,GAAG,GAAG,EAAE,EAAE;IAC9E,MAAM,eAAe,GAAG,cAAc,CAAC;IACvC,MAAM,kBAAkB,GAAG,IAAA,iBAAQ,EAAC,IAAI,EAAE,eAAe,CAAC,CAAC;IAC3D,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,YAAY,EAAE,CAAC,WAAW,CAAC,KAAK,SAAS,CAAC;IAExF,IAAI,CAAC,kBAAkB,EAAE;QACvB,MAAM,mBAAmB,GAAG;YAC1B,GAAG,kBAAkB;YACrB,YAAY,EAAE;gBACZ,GAAG,kBAAkB,CAAC,YAAY;gBAClC,CAAC,WAAW,CAAC,EAAE,OAAO;aACvB;SACF,CAAC;QAEF,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;KAC3E;AACH,CAAC,CAAC;AAhBW,QAAA,aAAa,iBAgBxB","sourcesContent":["import { readJson, Tree } from \"@nrwl/devkit\";\n\n/**\n * Add a dev dependency to the package.json\n *\n * @param { Tree } host the nx tree\n * @param { string } packageName the package name\n * @param { string } version the package version\n */\nexport const addDevDependency = (host: Tree, packageName: string, version = \"*\") => {\n const packageJsonPath = \"package.json\";\n const currentPackageJson = readJson(host, packageJsonPath);\n const isPackageInstalled = currentPackageJson.devDependencies?.[packageName] !== undefined;\n\n if (!isPackageInstalled) {\n const modifiedPackageJson = {\n ...currentPackageJson,\n devDependencies: {\n ...currentPackageJson.devDependencies,\n [packageName]: version,\n },\n };\n\n host.write(packageJsonPath, JSON.stringify(modifiedPackageJson, null, 2));\n }\n};\n\n/**\n * Add a dependency to the package.json\n *\n * @param { Tree } host the nx tree\n * @param { string } packageName the package name\n * @param { string } version the package version\n */\nexport const addDependency = (host: Tree, packageName: string, version = \"*\") => {\n const packageJsonPath = \"package.json\";\n const currentPackageJson = readJson(host, packageJsonPath);\n const isPackageInstalled = currentPackageJson.dependencies?.[packageName] !== undefined;\n\n if (!isPackageInstalled) {\n const modifiedPackageJson = {\n ...currentPackageJson,\n dependencies: {\n ...currentPackageJson.dependencies,\n [packageName]: version,\n },\n };\n\n host.write(packageJsonPath, JSON.stringify(modifiedPackageJson, null, 2));\n }\n};\n"]}
|