@trackunit/iris-app-sdk-vite 1.4.12 → 1.4.13
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 +8 -0
- package/package.json +4 -4
- package/src/executors/build/executor.js +10 -0
- package/src/executors/serve/executor.js +9 -0
- package/src/executors/utils/defaultViteConfig.js +6 -2
- package/src/executors/utils/getTrackunitIrisAppVitePlugins.js +13 -2
- package/src/executors/utils/resolveSdkVersion.js +130 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/iris-app-sdk-vite",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.13",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"repository": "https://github.com/Trackunit/manager",
|
|
6
6
|
"executors": "./executors.json",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"rxjs": "7.8.1",
|
|
12
12
|
"win-ca": "^3.5.1",
|
|
13
|
-
"@trackunit/iris-app-build-utilities": "2.4.
|
|
14
|
-
"@trackunit/iris-app-api": "2.4.
|
|
13
|
+
"@trackunit/iris-app-build-utilities": "2.4.13",
|
|
14
|
+
"@trackunit/iris-app-api": "2.4.9",
|
|
15
15
|
"tslib": "^2.6.2",
|
|
16
16
|
"vite": "8.1.5",
|
|
17
17
|
"@module-federation/vite": "1.18.1",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@tailwindcss/postcss": "^4.1.18",
|
|
23
23
|
"@vitejs/plugin-react-swc": "^4.3.2",
|
|
24
24
|
"@nx/devkit": "23.1.0",
|
|
25
|
-
"@trackunit/iris-app": "2.5.
|
|
25
|
+
"@trackunit/iris-app": "2.5.13",
|
|
26
26
|
"cross-keychain": "^1.1.0",
|
|
27
27
|
"jwt-decode": "^3.1.2"
|
|
28
28
|
},
|
|
@@ -11,6 +11,7 @@ const op = tslib_1.__importStar(require("rxjs/operators"));
|
|
|
11
11
|
require("win-ca");
|
|
12
12
|
const defaultViteConfig_1 = require("../utils/defaultViteConfig");
|
|
13
13
|
const manifestLoader_1 = require("../utils/manifestLoader");
|
|
14
|
+
const resolveSdkVersion_1 = require("../utils/resolveSdkVersion");
|
|
14
15
|
const deleteOutputDir = (root, outputPath) => {
|
|
15
16
|
const resolvedOutputPath = (0, path_1.resolve)(root, outputPath);
|
|
16
17
|
if (resolvedOutputPath === root) {
|
|
@@ -41,6 +42,15 @@ async function* buildExecutor(options, context) {
|
|
|
41
42
|
// by the spec - the import threw before the spec's beforeEach `vi.mock(...)`
|
|
42
43
|
// had any chance to intercept it.
|
|
43
44
|
const IrisAppManifest = await (0, manifestLoader_1.loadManifest)(context.root, projectRootDir);
|
|
45
|
+
// Stamp the *installed* `@trackunit/iris-app` version (not the declared
|
|
46
|
+
// range) so the host can decide content-inset behaviour from the published
|
|
47
|
+
// manifest. Fail-soft: absent version keeps the legacy-inset default.
|
|
48
|
+
const sdkVersion = (0, resolveSdkVersion_1.resolveSdkVersion)(projectRootDir);
|
|
49
|
+
if (sdkVersion !== undefined) {
|
|
50
|
+
IrisAppManifest.sdkVersion = sdkVersion;
|
|
51
|
+
}
|
|
52
|
+
// Advisory: warn when past the content-inset cutoff without `p-content-space`.
|
|
53
|
+
(0, iris_app_build_utilities_1.checkContentInsetAdoption)(sdkVersion, projectRootDir);
|
|
44
54
|
const defaultConfig = await (0, defaultViteConfig_1.getDefaultViteConfig)("production", context.root, projectRootDir, IrisAppManifest, context, {
|
|
45
55
|
skipTypeChecking,
|
|
46
56
|
});
|
|
@@ -13,6 +13,7 @@ require("win-ca");
|
|
|
13
13
|
const checkCustomFields_1 = require("../utils/checkCustomFields");
|
|
14
14
|
const defaultViteConfig_1 = require("../utils/defaultViteConfig");
|
|
15
15
|
const manifestLoader_1 = require("../utils/manifestLoader");
|
|
16
|
+
const resolveSdkVersion_1 = require("../utils/resolveSdkVersion");
|
|
16
17
|
/**
|
|
17
18
|
* Serve executor for serving Iris Apps with Vite.
|
|
18
19
|
*
|
|
@@ -37,6 +38,14 @@ async function* serveExecutor(options, context) {
|
|
|
37
38
|
// by the spec - the import threw before the spec's beforeEach `vi.mock(...)`
|
|
38
39
|
// had any chance to intercept it.
|
|
39
40
|
const irisAppManifest = await (0, manifestLoader_1.loadManifest)(context.root, projectRootDir);
|
|
41
|
+
// Stamp the installed SDK version so serve's published /manifest.json matches
|
|
42
|
+
// production builds (plugin also refreshes on emit after disk reloads).
|
|
43
|
+
const sdkVersion = (0, resolveSdkVersion_1.resolveSdkVersion)(projectRootDir);
|
|
44
|
+
if (sdkVersion !== undefined) {
|
|
45
|
+
irisAppManifest.sdkVersion = sdkVersion;
|
|
46
|
+
}
|
|
47
|
+
// Advisory: warn when past the content-inset cutoff without `p-content-space`.
|
|
48
|
+
(0, iris_app_build_utilities_1.checkContentInsetAdoption)(sdkVersion, projectRootDir);
|
|
40
49
|
const checkCustomFieldsResult = await (0, checkCustomFields_1.checkCustomFields)(irisAppManifest, settings);
|
|
41
50
|
if (checkCustomFieldsResult === "out-of-sync") {
|
|
42
51
|
throw new Error("Custom fields are out of sync with the latest approved manifest, which can cause the app to behave in unexpected ways. Please submit and get this version approved before you continue developing the app.");
|
|
@@ -33,15 +33,19 @@ const virtualEntryPlugin = {
|
|
|
33
33
|
* @param mode - "production" or "development"
|
|
34
34
|
* @param nxRootDir - the root of the nx workspace
|
|
35
35
|
* @param appDir - the app directory
|
|
36
|
-
* @param
|
|
36
|
+
* @param irisAppManifest - the iris app manifest (may already carry a stamped `sdkVersion`)
|
|
37
37
|
* @param context - NX executor context
|
|
38
38
|
* @returns {Promise<UserConfig>} the default Vite config
|
|
39
39
|
*/
|
|
40
|
-
const getDefaultViteConfig = async (mode, nxRootDir, appDir,
|
|
40
|
+
const getDefaultViteConfig = async (mode, nxRootDir, appDir, irisAppManifest, context, options = {}) => {
|
|
41
41
|
// Dynamic import - safe after enableTsConfigPath() is called
|
|
42
42
|
const irisAppPlugins = await (0, getTrackunitIrisAppVitePlugins_1.getTrackunitIrisAppVitePlugins)({
|
|
43
43
|
appDir,
|
|
44
44
|
workspaceRoot: nxRootDir,
|
|
45
|
+
// Pass the executor-loaded (and possibly sdkVersion-stamped) manifest through so
|
|
46
|
+
// federation config and the first emit seed share one object — the plugin still
|
|
47
|
+
// refreshes `sdkVersion` on every generateManifestJson after disk reloads.
|
|
48
|
+
manifest: irisAppManifest,
|
|
45
49
|
config: { mode },
|
|
46
50
|
serversidePortMap: options.serversidePortMap,
|
|
47
51
|
skipTypeChecking: options.skipTypeChecking,
|
|
@@ -16,6 +16,7 @@ const extensionLoaderCache_1 = require("./extensionLoaderCache");
|
|
|
16
16
|
const loadCssInjectedByJsPlugin_1 = require("./loadCssInjectedByJsPlugin");
|
|
17
17
|
const manifestCache_1 = require("./manifestCache");
|
|
18
18
|
const manifestLoader_1 = require("./manifestLoader");
|
|
19
|
+
const resolveSdkVersion_1 = require("./resolveSdkVersion");
|
|
19
20
|
// Only import enableTsConfigPath statically - other utilities are dynamically imported
|
|
20
21
|
// AFTER tsconfig paths are registered to avoid oxc analysis warnings
|
|
21
22
|
// MIME types for serving extension assets during development
|
|
@@ -151,8 +152,11 @@ async function getTrackunitIrisAppVitePlugins(options) {
|
|
|
151
152
|
// ESM-only since v5 (Vite 8). Load via file URL — Nx CJS executor hooks cannot
|
|
152
153
|
// resolve the package's import-only exports map.
|
|
153
154
|
const cssInjectedByJsPlugin = await (0, loadCssInjectedByJsPlugin_1.loadCssInjectedByJsPlugin)(workspaceRoot);
|
|
154
|
-
//
|
|
155
|
-
|
|
155
|
+
// Prefer the executor-provided manifest (may already carry stamped sdkVersion);
|
|
156
|
+
// fall back to a fresh disk load for direct/plugin-only callers.
|
|
157
|
+
const initialLoad = options.manifest === undefined
|
|
158
|
+
? await (0, manifestLoader_1.loadManifestWithSources)(workspaceRoot, resolvedAppDir)
|
|
159
|
+
: { manifest: options.manifest, sourcePaths: [] };
|
|
156
160
|
const initialManifest = initialLoad.manifest;
|
|
157
161
|
// Directories holding the sources the manifest was derived from. The dev
|
|
158
162
|
// server's own watcher only covers the app root, but a manifest reads across
|
|
@@ -267,6 +271,13 @@ async function getTrackunitIrisAppVitePlugins(options) {
|
|
|
267
271
|
const appSrc = path.join(resolvedAppDir, "src");
|
|
268
272
|
manifestCopy.customFieldDefinitions = (0, iris_app_build_utilities_1.updateCustomFields)(manifestData.customFieldDefinitions, appSrc);
|
|
269
273
|
manifestCopy.extensions = (0, iris_app_build_utilities_1.updateExtensions)([...manifestData.extensions]);
|
|
274
|
+
// Stamp (or refresh) the installed SDK version on every emit so serve HMR
|
|
275
|
+
// reloads and production builds both publish it — the build executor also
|
|
276
|
+
// stamps before config construction, but this path reloads from disk.
|
|
277
|
+
const sdkVersion = (0, resolveSdkVersion_1.resolveSdkVersion)(resolvedAppDir);
|
|
278
|
+
if (sdkVersion !== undefined) {
|
|
279
|
+
manifestCopy.sdkVersion = sdkVersion;
|
|
280
|
+
}
|
|
270
281
|
return (0, iris_app_build_utilities_1.injectFullDescriptionImages)(manifestCopy, resolvedAppDir);
|
|
271
282
|
};
|
|
272
283
|
const manifestCache = (0, manifestCache_1.createManifestCache)({
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IRIS_APP_SDK_PACKAGE_NAME = exports.resolveSdkVersion = exports.defaultSearchRoots = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs = tslib_1.__importStar(require("node:fs"));
|
|
6
|
+
const path = tslib_1.__importStar(require("node:path"));
|
|
7
|
+
const PACKAGE_NAME = "@trackunit/iris-app";
|
|
8
|
+
const readPackageName = (packageDir) => {
|
|
9
|
+
try {
|
|
10
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(packageDir, "package.json"), "utf-8"));
|
|
11
|
+
if (typeof packageJson === "object" &&
|
|
12
|
+
packageJson !== null &&
|
|
13
|
+
"name" in packageJson &&
|
|
14
|
+
typeof packageJson.name === "string") {
|
|
15
|
+
return packageJson.name;
|
|
16
|
+
}
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const isIrisAppPackageDir = (packageDir) => fs.existsSync(path.join(packageDir, "package.json")) && readPackageName(packageDir) === PACKAGE_NAME;
|
|
24
|
+
/**
|
|
25
|
+
* Walks `node_modules` upwards from `fromDir` looking for `@trackunit/iris-app`.
|
|
26
|
+
* Mirrors the layout-tolerant walk in `loadCssInjectedByJsPlugin` so both classic
|
|
27
|
+
* hoisted installs and Yarn/pnpm isolated layouts resolve correctly.
|
|
28
|
+
*/
|
|
29
|
+
const findIrisAppInNodeModules = (fromDir) => {
|
|
30
|
+
let dir = path.resolve(fromDir);
|
|
31
|
+
for (;;) {
|
|
32
|
+
const candidate = path.join(dir, "node_modules", "@trackunit", "iris-app");
|
|
33
|
+
if (isIrisAppPackageDir(candidate)) {
|
|
34
|
+
return candidate;
|
|
35
|
+
}
|
|
36
|
+
const parent = path.dirname(dir);
|
|
37
|
+
if (parent === dir) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
dir = parent;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Manager monorepo layout: `@trackunit/iris-app` lives at
|
|
45
|
+
* `libs/iris-app-sdk/iris-app` beside `@trackunit/iris-app-sdk-vite`, and is
|
|
46
|
+
* often *not* linked into any `node_modules` (Yarn `nodeLinker: pnpm` + TS path
|
|
47
|
+
* mappings). Walking up from the vite package and accepting a sibling / child
|
|
48
|
+
* `iris-app` directory recovers the stamped version for in-repo Iris app builds.
|
|
49
|
+
*/
|
|
50
|
+
const findIrisAppAsMonorepoSibling = (fromDir) => {
|
|
51
|
+
let dir = path.resolve(fromDir);
|
|
52
|
+
for (;;) {
|
|
53
|
+
const sibling = path.join(path.dirname(dir), "iris-app");
|
|
54
|
+
if (isIrisAppPackageDir(sibling)) {
|
|
55
|
+
return sibling;
|
|
56
|
+
}
|
|
57
|
+
const child = path.join(dir, "iris-app");
|
|
58
|
+
if (isIrisAppPackageDir(child)) {
|
|
59
|
+
return child;
|
|
60
|
+
}
|
|
61
|
+
const parent = path.dirname(dir);
|
|
62
|
+
if (parent === dir) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
dir = parent;
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Search the consumer app first, then this vite package's own tree.
|
|
70
|
+
*
|
|
71
|
+
* Under isolated node_modules layouts (pnpm, Yarn's `nodeLinker: pnpm`) monorepo
|
|
72
|
+
* Iris apps typically do not link `@trackunit/iris-app` under the app root — it
|
|
73
|
+
* sits beside `@trackunit/iris-app-sdk-vite` instead. A root-only walk then
|
|
74
|
+
* leaves `sdkVersion` unstamped and the host keeps the legacy content inset.
|
|
75
|
+
* ASA leftovers without `p-content-space` go flush; that is the GLU-1873
|
|
76
|
+
* proving state on this feature branch (pad/accept before master), not a
|
|
77
|
+
* reason to skip the stamp.
|
|
78
|
+
*/
|
|
79
|
+
const defaultSearchRoots = (fromDir) => [fromDir, __dirname];
|
|
80
|
+
exports.defaultSearchRoots = defaultSearchRoots;
|
|
81
|
+
const findIrisAppPackageDirFromRoots = (searchRoots) => {
|
|
82
|
+
for (const root of searchRoots) {
|
|
83
|
+
if (isIrisAppPackageDir(root)) {
|
|
84
|
+
return root;
|
|
85
|
+
}
|
|
86
|
+
const inNodeModules = findIrisAppInNodeModules(root);
|
|
87
|
+
if (inNodeModules !== undefined) {
|
|
88
|
+
return inNodeModules;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
for (const root of searchRoots) {
|
|
92
|
+
const sibling = findIrisAppAsMonorepoSibling(root);
|
|
93
|
+
if (sibling !== undefined) {
|
|
94
|
+
return sibling;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return undefined;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Resolves the *installed* `@trackunit/iris-app` version from `node_modules`
|
|
101
|
+
* (not the declared semver range in package.json). Returns `undefined` on any
|
|
102
|
+
* failure so callers can keep the safe "absent means legacy inset" default.
|
|
103
|
+
*
|
|
104
|
+
* @param fromDir - Directory to start the node_modules walk from (typically the app root)
|
|
105
|
+
* @param searchRoots - Optional override of roots to walk (defaults to app + this package)
|
|
106
|
+
* @returns {string | undefined} the installed package version, or undefined if unresolved
|
|
107
|
+
*/
|
|
108
|
+
const resolveSdkVersion = (fromDir, searchRoots = (0, exports.defaultSearchRoots)(fromDir)) => {
|
|
109
|
+
try {
|
|
110
|
+
const packageDir = findIrisAppPackageDirFromRoots(searchRoots);
|
|
111
|
+
if (packageDir === undefined) {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
const packageJson = JSON.parse(fs.readFileSync(path.join(packageDir, "package.json"), "utf-8"));
|
|
115
|
+
if (typeof packageJson !== "object" ||
|
|
116
|
+
packageJson === null ||
|
|
117
|
+
!("version" in packageJson) ||
|
|
118
|
+
typeof packageJson.version !== "string" ||
|
|
119
|
+
packageJson.version.length === 0) {
|
|
120
|
+
return undefined;
|
|
121
|
+
}
|
|
122
|
+
return packageJson.version;
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
exports.resolveSdkVersion = resolveSdkVersion;
|
|
129
|
+
exports.IRIS_APP_SDK_PACKAGE_NAME = PACKAGE_NAME;
|
|
130
|
+
//# sourceMappingURL=resolveSdkVersion.js.map
|