@equinor/fusion-framework-cli 9.12.14 → 10.0.0-alpha-afdec66178b3cac96597125945ba7e1b4ca2ca7e
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 +144 -0
- package/README.md +31 -9
- package/dist/bin/bundle-application.js +3 -2
- package/dist/bin/bundle-application.js.map +1 -1
- package/dist/bin/create-dev-serve.js +84 -113
- package/dist/bin/create-dev-serve.js.map +1 -1
- package/dist/bin/create-export-config.js +68 -6
- package/dist/bin/create-export-config.js.map +1 -1
- package/dist/bin/create-export-manifest.js +3 -4
- package/dist/bin/create-export-manifest.js.map +1 -1
- package/dist/bin/dev-portal/config.js +6 -2
- package/dist/bin/dev-portal/config.js.map +1 -1
- package/dist/bin/main.app.js +42 -1
- package/dist/bin/main.app.js.map +1 -1
- package/dist/bin/main.js +2 -3
- package/dist/bin/main.js.map +1 -1
- package/dist/bin/plugins/app-proxy.js +137 -0
- package/dist/bin/plugins/app-proxy.js.map +1 -0
- package/dist/bin/plugins/external-public.js +67 -0
- package/dist/bin/plugins/external-public.js.map +1 -0
- package/dist/bin/public/assets/{index-D2ohTVV3.js → index-BF2-imeq.js} +407 -407
- package/dist/bin/public/index.html +1 -1
- package/dist/bin/publish-application.js +102 -0
- package/dist/bin/publish-application.js.map +1 -0
- package/dist/bin/tag-application.js +80 -0
- package/dist/bin/tag-application.js.map +1 -0
- package/dist/bin/upload-application.js +69 -0
- package/dist/bin/upload-application.js.map +1 -0
- package/dist/bin/utils/{execute-commant.js → execute-command.js} +1 -1
- package/dist/bin/utils/{execute-commant.js.map → execute-command.js.map} +1 -1
- package/dist/bin/utils/format.js +1 -1
- package/dist/bin/utils/format.js.map +1 -1
- package/dist/bin/utils/getEndpointUrl.js +49 -0
- package/dist/bin/utils/getEndpointUrl.js.map +1 -0
- package/dist/bin/utils/index.js +14 -0
- package/dist/bin/utils/index.js.map +1 -0
- package/dist/bin/utils/isAppRegistered.js +30 -0
- package/dist/bin/utils/isAppRegistered.js.map +1 -0
- package/dist/bin/utils/load-manifest.js +7 -3
- package/dist/bin/utils/load-manifest.js.map +1 -1
- package/dist/bin/utils/proxy-request-logger.js +34 -0
- package/dist/bin/utils/proxy-request-logger.js.map +1 -0
- package/dist/bin/utils/publishAppConfig.js +34 -0
- package/dist/bin/utils/publishAppConfig.js.map +1 -0
- package/dist/bin/utils/requireToken.js +10 -0
- package/dist/bin/utils/requireToken.js.map +1 -0
- package/dist/bin/utils/tagAppBundle.js +33 -0
- package/dist/bin/utils/tagAppBundle.js.map +1 -0
- package/dist/bin/utils/uploadAppBundle.js +52 -0
- package/dist/bin/utils/uploadAppBundle.js.map +1 -0
- package/dist/lib/app-config.js.map +1 -1
- package/dist/lib/app-manifest.js +35 -11
- package/dist/lib/app-manifest.js.map +1 -1
- package/dist/lib/app-package.js +55 -6
- package/dist/lib/app-package.js.map +1 -1
- package/dist/lib/index.js +1 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/vite-config.js +1 -3
- package/dist/lib/vite-config.js.map +1 -1
- package/dist/types/bin/create-export-config.d.ts +6 -2
- package/dist/types/bin/create-export-manifest.d.ts +1 -8
- package/dist/types/bin/plugins/app-proxy.d.ts +70 -0
- package/dist/types/bin/plugins/external-public.d.ts +22 -0
- package/dist/types/bin/publish-application.d.ts +6 -0
- package/dist/types/bin/tag-application.d.ts +12 -0
- package/dist/types/bin/upload-application.d.ts +6 -0
- package/dist/types/bin/utils/getEndpointUrl.d.ts +10 -0
- package/dist/types/bin/utils/index.d.ts +14 -0
- package/dist/types/bin/utils/isAppRegistered.d.ts +7 -0
- package/dist/types/bin/utils/load-app-config.d.ts +1 -1
- package/dist/types/bin/utils/load-manifest.d.ts +2 -1
- package/dist/types/bin/utils/proxy-request-logger.d.ts +15 -0
- package/dist/types/bin/utils/publishAppConfig.d.ts +9 -0
- package/dist/types/bin/utils/requireToken.d.ts +4 -0
- package/dist/types/bin/utils/tagAppBundle.d.ts +7 -0
- package/dist/types/bin/utils/uploadAppBundle.d.ts +7 -0
- package/dist/types/lib/app-config.d.ts +1 -6
- package/dist/types/lib/app-manifest.d.ts +16 -20
- package/dist/types/lib/app-package.d.ts +35 -4
- package/dist/types/lib/index.d.ts +2 -2
- package/package.json +25 -30
- package/dist/bin/dev-proxy.js +0 -82
- package/dist/bin/dev-proxy.js.map +0 -1
- package/dist/index.js +0 -13
- package/dist/index.js.map +0 -1
- package/dist/types/bin/dev-proxy.d.ts +0 -27
- package/dist/types/index.d.ts +0 -4
- /package/dist/types/bin/utils/{execute-commant.d.ts → execute-command.d.ts} +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { readFileSync } from 'node:fs';
|
|
11
|
+
/**
|
|
12
|
+
* Function that uploads a zip bundle to the endpoint.
|
|
13
|
+
* @param endpoint string The endpoint to upload to
|
|
14
|
+
* @param bundle string The filename to upload
|
|
15
|
+
* @returns Object
|
|
16
|
+
*/
|
|
17
|
+
export const uploadAppBundle = (endpoint, bundle) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
const state = {
|
|
19
|
+
buffer: null,
|
|
20
|
+
};
|
|
21
|
+
try {
|
|
22
|
+
state.buffer = readFileSync(bundle);
|
|
23
|
+
}
|
|
24
|
+
catch (_a) {
|
|
25
|
+
throw new Error(`😞 Could not read bundle ${bundle}, does it exist?`);
|
|
26
|
+
}
|
|
27
|
+
const requestBundle = yield fetch(endpoint, {
|
|
28
|
+
method: 'POST',
|
|
29
|
+
body: state.buffer,
|
|
30
|
+
headers: {
|
|
31
|
+
Authorization: `Bearer ${process.env.FUSION_TOKEN}`,
|
|
32
|
+
'Content-Type': 'application/zip',
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
if (requestBundle.status === 401 || requestBundle.status === 403) {
|
|
36
|
+
throw new Error(`This is not allowed for this role on this app. HTTP message: ${requestBundle.statusText}`);
|
|
37
|
+
}
|
|
38
|
+
if (requestBundle.status === 404) {
|
|
39
|
+
throw new Error(`This app do not exist. HTTP message: ${requestBundle.statusText}`);
|
|
40
|
+
}
|
|
41
|
+
if (requestBundle.status === 409) {
|
|
42
|
+
throw new Error(`This version is already published. HTTP message: ${requestBundle.statusText}`);
|
|
43
|
+
}
|
|
44
|
+
if (requestBundle.status === 410) {
|
|
45
|
+
throw new Error(`This app is deleted. HTTP message: ${requestBundle.statusText}`);
|
|
46
|
+
}
|
|
47
|
+
if (!requestBundle.ok) {
|
|
48
|
+
throw new Error(`Failed to publish bundle. HTTP status ${requestBundle.status}, ${requestBundle.statusText}`);
|
|
49
|
+
}
|
|
50
|
+
return yield requestBundle.json();
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=uploadAppBundle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uploadAppBundle.js","sourceRoot":"","sources":["../../../src/bin/utils/uploadAppBundle.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAO,QAAgB,EAAE,MAAc,EAAE,EAAE;IACtE,MAAM,KAAK,GAA8B;QACrC,MAAM,EAAE,IAAI;KACf,CAAC;IAEF,IAAI,CAAC;QACD,KAAK,CAAC,MAAM,GAAG,YAAY,C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"version":3,"file":"app-config.js","sourceRoot":"","sources":["../../src/lib/app-config.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACH,UAAU,EAGV,cAAc,EAEd,aAAa,GAChB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjE,OAAO,SAAS,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"app-config.js","sourceRoot":"","sources":["../../src/lib/app-config.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACH,UAAU,EAGV,cAAc,EAEd,aAAa,GAChB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjE,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAc3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,YAAY,CAAC;AAE9C,MAAM,UAAU,eAAe,CAAC,KAAgB;IAC5C,OAAO;IACP,YAAY,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAAe,EAAE,EAAE,CAAC,EAAE,CAAC;AAEvD,MAAM,CAAC,MAAM,eAAe,GAAG,CAC3B,IAAwB,EACxB,SAA6B,EACpB,EAAE;IACX,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,EAAE,SAAS,CAAyB,CAAC;IACpE,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC1B,OAAO,QAAQ,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,QAAiB,EAAE,EAAE,CAC/C,UAAU,CAAY,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,iBAAiB,CAAC,CAAC;AAEzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC5B,OAEC,EAC0C,EAAE;IAC7C,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAA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, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import deepmerge from 'deepmerge';
|
|
11
|
-
import {
|
|
11
|
+
import { execSync } from 'node:child_process';
|
|
12
|
+
import { resolveEntryPoint } from './app-package.js';
|
|
12
13
|
import { loadConfig, initiateConfig, resolveConfig, } from './utils/config.js';
|
|
13
14
|
import { AssertionError, assert, assertObject } from './utils/assert.js';
|
|
14
15
|
/** base filename for configuration files */
|
|
@@ -78,23 +79,46 @@ export const resolveManifest = (options) => __awaiter(void 0, void 0, void 0, fu
|
|
|
78
79
|
}
|
|
79
80
|
return resolveConfig(manifestConfigFilename, { find: options });
|
|
80
81
|
});
|
|
82
|
+
const getGithubRepo = (pkg) => {
|
|
83
|
+
try {
|
|
84
|
+
/* get reporurl from package.json */
|
|
85
|
+
if (pkg.repository) {
|
|
86
|
+
return typeof pkg.repository === 'string' ? pkg.repository : pkg.repository.url;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
/* get reporurl from git command */
|
|
90
|
+
return execSync('git remote get-url origin')
|
|
91
|
+
.toString()
|
|
92
|
+
.trim()
|
|
93
|
+
.replace('git@github.com:', 'https://github.com/')
|
|
94
|
+
.replace(/.git$/, '');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (_a) {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const getGitCommitSha = () => {
|
|
102
|
+
try {
|
|
103
|
+
return execSync('git rev-parse HEAD').toString().trim();
|
|
104
|
+
}
|
|
105
|
+
catch (_a) {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
81
109
|
export const createManifestFromPackage = (pkg) => {
|
|
82
|
-
var _a, _b, _c, _d;
|
|
83
110
|
const { packageJson } = pkg;
|
|
84
111
|
assertObject(packageJson, 'expected packageJson');
|
|
85
112
|
assert(packageJson.name, 'expected [name] in packageJson');
|
|
86
113
|
assert(packageJson.version, 'expected [version] in packageJson');
|
|
87
|
-
const
|
|
88
|
-
const entry = resolveEntryPoint(pkg.packageJson);
|
|
89
|
-
assert(entry, 'expected [version] in packageJson');
|
|
114
|
+
const entryPoint = resolveEntryPoint(packageJson);
|
|
90
115
|
const manifest = {
|
|
91
|
-
key,
|
|
92
|
-
entry,
|
|
93
116
|
version: packageJson.version,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
117
|
+
entryPoint,
|
|
118
|
+
timestamp: new Date().toISOString(),
|
|
119
|
+
githubRepo: getGithubRepo(packageJson),
|
|
120
|
+
commitSha: getGitCommitSha(),
|
|
121
|
+
projectPage: packageJson.homepage,
|
|
98
122
|
};
|
|
99
123
|
assertAppManifest(manifest);
|
|
100
124
|
return manifest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-manifest.js","sourceRoot":"","sources":["../../src/lib/app-manifest.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"app-manifest.js","sourceRoot":"","sources":["../../src/lib/app-manifest.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAsC,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAEzF,OAAO,EACH,UAAU,EACV,cAAc,EACd,aAAa,GAIhB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAyBzE,4CAA4C;AAC5C,MAAM,CAAC,MAAM,sBAAsB,GAAG,qBAAqB,CAAC;AAE5D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAAiB,EAAE,EAAE,CAAC,EAAE,CAAC;AAE3D,MAAM,UAAU,iBAAiB,CAAC,KAAwB;IACt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C;IAC5B,OAAO,QAAQ,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAC1B,GAAsB,EACtB,IAAuB,EACvB,OAA6B,EAC0B,EAAE;IACzD,MAAM,QAAQ,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC;IAChD,IAAI,QAAQ,EAAE,CAAC;QACX,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;QACtE,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QAC5B,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC7C,CAAC;SAAM,IAAI,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,EAAE,CAAC;QACvB,MAAM,IAAI,cAAc,CAAC;YACrB,OAAO,EAAE,kCAAkC,OAAO,CAAC,IAAI,EAAE;YACzD,QAAQ,EAAE,YAAY;SACzB,CAAC,CAAC;IACP,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAC9B,CAAC,CAAA,CAAC"}
|
package/dist/lib/app-package.js
CHANGED
|
@@ -7,22 +7,71 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
import { existsSync } from 'node:fs';
|
|
11
|
+
import { dirname, relative } from 'node:path';
|
|
10
12
|
import { readPackageUp, } from 'read-package-up';
|
|
11
13
|
import { assert } from './utils/assert.js';
|
|
12
14
|
export function defineAppPackage(fnOrObject) {
|
|
13
15
|
return fnOrObject;
|
|
14
16
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Resolves the entry point of a given package.
|
|
19
|
+
*
|
|
20
|
+
* This function attempts to find the entry point of a package by checking several
|
|
21
|
+
* common properties in the package's `package.json` file, such as `entrypoint`, `main`,
|
|
22
|
+
* and `module`. If none of these properties are found, it defaults to checking for
|
|
23
|
+
* common entry files like `src/index.ts`, `src/index.tsx`, `src/index.js`, and `src/index.jsx`.
|
|
24
|
+
*
|
|
25
|
+
* @param pkg - The resolved application package containing the package.json and path information.
|
|
26
|
+
* @returns The relative path to the resolved entry point.
|
|
27
|
+
* @throws Will throw an error if no entry point can be resolved.
|
|
28
|
+
*/
|
|
29
|
+
export const resolveEntryPoint = (packageJson, pkgPath = '') => {
|
|
30
|
+
const entrypoint = [
|
|
31
|
+
packageJson.entrypoint,
|
|
32
|
+
packageJson.main,
|
|
33
|
+
packageJson.module,
|
|
34
|
+
'src/index.ts',
|
|
35
|
+
'src/index.tsx',
|
|
36
|
+
'src/index.js',
|
|
37
|
+
'src/index.jsx',
|
|
38
|
+
]
|
|
39
|
+
.filter((x) => !!x)
|
|
40
|
+
.map((x) => relative(dirname(pkgPath), x))
|
|
41
|
+
.find((entry) => {
|
|
42
|
+
console.log(entry, existsSync(entry));
|
|
43
|
+
return existsSync(entry);
|
|
44
|
+
});
|
|
45
|
+
assert(entrypoint, 'failed to resolve entrypoint');
|
|
46
|
+
return entrypoint;
|
|
19
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Resolves the application key from the given package.json object.
|
|
50
|
+
*
|
|
51
|
+
* @param packageJson - An object containing the 'name' property from the package.json.
|
|
52
|
+
* @returns The resolved application key, which is the package name with any leading '@' or scope removed.
|
|
53
|
+
* @throws Will throw an error if the 'name' property is not present in the packageJson.
|
|
54
|
+
*/
|
|
20
55
|
export const resolveAppKey = (packageJson) => {
|
|
21
56
|
assert(packageJson.name, 'expected [name] in packageJson');
|
|
22
57
|
return packageJson.name.replace(/^@|\w.*\//gm, '');
|
|
23
58
|
};
|
|
24
|
-
|
|
25
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Asserts the validity of a given package by resolving its application key and entry point.
|
|
61
|
+
*
|
|
62
|
+
* @param pkg - A partial representation of the application's package JSON.
|
|
63
|
+
*/
|
|
64
|
+
export const assertPackage = (pkg) => {
|
|
65
|
+
assert(resolveAppKey(pkg));
|
|
66
|
+
assert(resolveEntryPoint(pkg));
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Resolves the application package by searching for the nearest `package.json` file.
|
|
70
|
+
*
|
|
71
|
+
* @param options - Optional parameters to customize the search behavior.
|
|
72
|
+
* @returns A promise that resolves to the found package information.
|
|
73
|
+
* @throws Will throw an error if the `package.json` file is not found.
|
|
74
|
+
*/
|
|
26
75
|
export const resolveAppPackage = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
76
|
const result = yield readPackageUp(options);
|
|
28
77
|
if (!result) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-package.js","sourceRoot":"","sources":["../../src/lib/app-package.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAEH,aAAa,GAEhB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAsB3C,MAAM,UAAU,gBAAgB,CAAC,UAAiC;IAC9D,OAAO,UAAU,CAAC;AACtB,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"app-package.js","sourceRoot":"","sources":["../../src/lib/app-package.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAEH,aAAa,GAEhB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAsB3C,MAAM,UAAU,gBAAgB,CAAC,UAAiC;IAC9D,OAAO,UAAU,CAAC;AACtB,CAAC;AAED;;;;;;;;;;;GAWG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MAAM,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,CAAC;IAC5C,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,MAAM,KAAK,CAAC,6BAA6B,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC,CAAA,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
package/dist/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { mergeManifests, defineAppManifest
|
|
1
|
+
export { mergeManifests, defineAppManifest } from './app-manifest.js';
|
|
2
2
|
export { mergeAppConfigs, defineAppConfig, } from './app-config.js';
|
|
3
3
|
export { defineAppPackage, resolveAppKey, resolveEntryPoint, } from './app-package.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAsB,MAAM,mBAAmB,CAAC;AAE1F,OAAO,EACH,eAAe,EACf,eAAe,GAGlB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACH,gBAAgB,EAChB,aAAa,EACb,iBAAiB,GAGpB,MAAM,kBAAkB,CAAC"}
|
package/dist/lib/vite-config.js
CHANGED
|
@@ -65,10 +65,8 @@ export const createViteConfig = (env, overrides) => __awaiter(void 0, void 0, vo
|
|
|
65
65
|
FUSION_LOG_LEVEL: ((_a = process.env.FUSION_LOG_LEVEL) !== null && _a !== void 0 ? _a : env.mode === 'development') ? '3' : '1',
|
|
66
66
|
}),
|
|
67
67
|
],
|
|
68
|
+
mode: env.mode,
|
|
68
69
|
root,
|
|
69
|
-
server: {
|
|
70
|
-
middlewareMode: true,
|
|
71
|
-
},
|
|
72
70
|
appType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ACX,MAAM,EAAE;oBACJ,YAAY,EAAE,SAAS;iBAC1B;aACJ;SACJ;QACD,YAAY,EAAE,gBAAgB,EAAE;KACnC,CAAC,CAAC;IACH,OAAO,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;AAC7E,CAAC,CAAA,CAAC"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import type { FusionEnv } from './utils/index.js';
|
|
1
2
|
import { ConfigExecuterEnv } from '../lib/utils/config.js';
|
|
2
|
-
export declare const createExportConfig: (options
|
|
3
|
+
export declare const createExportConfig: (options: {
|
|
3
4
|
command?: ConfigExecuterEnv["command"];
|
|
4
5
|
configFile?: string;
|
|
6
|
+
publish?: string;
|
|
5
7
|
outputFile?: string;
|
|
6
|
-
|
|
8
|
+
env: FusionEnv;
|
|
9
|
+
service: string;
|
|
10
|
+
}) => Promise<import("@equinor/fusion-framework-module-app").AppConfig>;
|
|
7
11
|
export default createExportConfig;
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import { ConfigExecuterEnv } from '../lib/utils/config.js';
|
|
2
|
-
import {
|
|
2
|
+
import type { AppManifestExport } from '../lib/app-manifest.js';
|
|
3
3
|
export declare const normalizeVersion: (version: string) => {
|
|
4
4
|
major: number;
|
|
5
5
|
minor: number;
|
|
6
6
|
patch: number;
|
|
7
7
|
};
|
|
8
|
-
type AppManifestExport = Omit<AppManifest, 'version'> & {
|
|
9
|
-
version: {
|
|
10
|
-
major: number;
|
|
11
|
-
minor: number;
|
|
12
|
-
patch: number;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
8
|
export declare const createExportManifest: (options?: {
|
|
16
9
|
command?: ConfigExecuterEnv["command"];
|
|
17
10
|
configFile?: string;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
import { AppConfig, ApplicationManifest } from '@equinor/fusion-framework-app';
|
|
3
|
+
import { ClientRequest, IncomingMessage, ServerResponse } from 'node:http';
|
|
4
|
+
/**
|
|
5
|
+
* Options for configuring the App Proxy Plugin.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* When not providing an app configuration, the plugin will only proxy requests to the target.
|
|
9
|
+
*/
|
|
10
|
+
export type AppProxyPluginOptions = {
|
|
11
|
+
/** Configuration for the proxy. */
|
|
12
|
+
proxy: {
|
|
13
|
+
/** The path to be proxied. */
|
|
14
|
+
path: string;
|
|
15
|
+
/** The target URL for the proxy. */
|
|
16
|
+
target: string;
|
|
17
|
+
/** Optional callback function to modify the proxy request. */
|
|
18
|
+
onProxyReq?: (proxyReq: ClientRequest, req: IncomingMessage, res: ServerResponse) => void;
|
|
19
|
+
};
|
|
20
|
+
/** Optional configuration for the app. */
|
|
21
|
+
app?: {
|
|
22
|
+
/** application key */
|
|
23
|
+
key: string;
|
|
24
|
+
/** application version */
|
|
25
|
+
version: string;
|
|
26
|
+
/** callback function for generating configuration for the application */
|
|
27
|
+
generateConfig: () => Promise<AppConfig>;
|
|
28
|
+
/** callback function for generating manifest for the application */
|
|
29
|
+
generateManifest: () => Promise<ApplicationManifest>;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The `appProxyPlugin` function creates a Vite plugin that configures a proxy for API and bundle requests
|
|
34
|
+
* to the Fusion apps backend. It also serves the app manifest, config, and local bundles if an app is provided.
|
|
35
|
+
*
|
|
36
|
+
* @param {AppProxyPluginOptions} options - The options for configuring the app proxy plugin.
|
|
37
|
+
*
|
|
38
|
+
* @returns {Plugin} - The configured Vite plugin.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const plugin = appProxyPlugin({
|
|
43
|
+
* proxy: {
|
|
44
|
+
* path: '/app-proxy',
|
|
45
|
+
* target: 'https://fusion-s-apps-ci.azurewebsites.net/',
|
|
46
|
+
* onProxyReq: (proxyReq, req, res) => {
|
|
47
|
+
* proxyReq.on('response', (res) => { console.log(res.statusCode) });
|
|
48
|
+
* },
|
|
49
|
+
* },
|
|
50
|
+
* app: {
|
|
51
|
+
* key: 'my-app',
|
|
52
|
+
* version: '1.0.0',
|
|
53
|
+
* generateConfig: async () => ({}),
|
|
54
|
+
* generateManifest: async () => ({}),
|
|
55
|
+
* },
|
|
56
|
+
* });
|
|
57
|
+
*
|
|
58
|
+
* // api calls
|
|
59
|
+
* fetch('/app-proxy/apps/my-app/builds/1.0.0/config'); // will generate app config by provided function
|
|
60
|
+
* fetch('/app-proxy/apps/my-app/builds/0.0.9/config'); // will proxy to the target, since version does not match
|
|
61
|
+
* fetch('/app-proxy/apps/other-app/builds/1.0.0/config'); // will proxy to the target, since app key does not match
|
|
62
|
+
*
|
|
63
|
+
* // asset calls
|
|
64
|
+
* fetch('/app-proxy/bundles/my-app/builds/1.0.0/index.js'); // will generate bundle by provided function
|
|
65
|
+
* fetch('/app-proxy/bundles/my-app/builds/0.0.9/index.js'); // will proxy to the target, since version does not match
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
*/
|
|
69
|
+
export declare const appProxyPlugin: (options: AppProxyPluginOptions) => Plugin;
|
|
70
|
+
export default appProxyPlugin;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type Plugin } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a plugin that serves an external public directory.
|
|
4
|
+
*
|
|
5
|
+
* This plugin is useful when you want to serve a static site from a different directory than the one where the Vite server is running.
|
|
6
|
+
* Vite`s built in `mode: 'spa'` will only look for the `index.html` file in the configured `root` directory,
|
|
7
|
+
* so this plugin is necessary to serve the `index.html` file from a different directory.
|
|
8
|
+
*
|
|
9
|
+
* @param path - The path to the external public directory.
|
|
10
|
+
* @returns A Plugin object configured to serve the specified public directory.
|
|
11
|
+
*
|
|
12
|
+
* The plugin:
|
|
13
|
+
* - Sets the `publicDir` configuration to the provided path.
|
|
14
|
+
* - Adds a middleware to the server that serves the `index.html` file from the specified path.
|
|
15
|
+
*
|
|
16
|
+
* The middleware:
|
|
17
|
+
* - Reads the `index.html` file from the specified path.
|
|
18
|
+
* - Transforms the HTML using the server's `transformIndexHtml` method.
|
|
19
|
+
* - Responds with the transformed HTML, setting appropriate headers.
|
|
20
|
+
*/
|
|
21
|
+
export declare const externalPublicPlugin: (path: string) => Plugin;
|
|
22
|
+
export default externalPublicPlugin;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FusionEnv } from './utils/index.js';
|
|
2
|
+
declare enum Tags {
|
|
3
|
+
preview = "preview",
|
|
4
|
+
latest = "latest"
|
|
5
|
+
}
|
|
6
|
+
export declare const tagApplication: (options: {
|
|
7
|
+
tag: keyof typeof Tags;
|
|
8
|
+
version: string;
|
|
9
|
+
env: FusionEnv;
|
|
10
|
+
service: string;
|
|
11
|
+
}) => Promise<void>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type FusionEnv = 'ci' | 'fqa' | 'tr' | 'fprd';
|
|
2
|
+
/**
|
|
3
|
+
* Retreive full endpoint URI to env in service-discovery
|
|
4
|
+
* @param endpoint <string> The endpoint to call in+ uri
|
|
5
|
+
* @param fusionEnv <FusionEnv> The Fusion env to get uri for
|
|
6
|
+
* @param service <string> Custom service uri to use insted of Fusion
|
|
7
|
+
* @param version <string> The version of the api to use
|
|
8
|
+
* @returns <string> The uri with endpoint
|
|
9
|
+
*/
|
|
10
|
+
export declare const getEndpointUrl: (endpoint: string, fusionEnv: FusionEnv, service: string, version?: string) => Promise<string>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { getEndpointUrl } from './getEndpointUrl.js';
|
|
2
|
+
export type { FusionEnv } from './getEndpointUrl.js';
|
|
3
|
+
export { requireToken } from './requireToken.js';
|
|
4
|
+
export { isAppRegistered } from './isAppRegistered.js';
|
|
5
|
+
export { loadAppConfig } from './load-app-config.js';
|
|
6
|
+
export { loadAppManifest } from './load-manifest.js';
|
|
7
|
+
export { loadPackage } from './load-package.js';
|
|
8
|
+
export { loadViteConfig } from './load-vite-config.js';
|
|
9
|
+
export { formatPath, formatByteSize } from './format.js';
|
|
10
|
+
export { executeCommand } from './execute-command.js';
|
|
11
|
+
export { publishAppConfig } from './publishAppConfig.js';
|
|
12
|
+
export { tagAppBundle } from './tagAppBundle.js';
|
|
13
|
+
export { uploadAppBundle } from './uploadAppBundle.js';
|
|
14
|
+
export { Spinner } from './spinner.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Make sure the app is registerred in the app-service
|
|
3
|
+
* @param endpoint <string> The endpoint to make a call to
|
|
4
|
+
* @param appKey <string> The appkey to check for
|
|
5
|
+
* @returns response object as json
|
|
6
|
+
*/
|
|
7
|
+
export declare const isAppRegistered: (endpoint: string, appKey: string) => Promise<any>;
|
|
@@ -3,7 +3,7 @@ import { type ResolvedAppPackage } from '../../lib/app-package.js';
|
|
|
3
3
|
export declare const loadAppConfig: (env: ConfigExecuterEnv, pkg: ResolvedAppPackage, options?: {
|
|
4
4
|
file?: string;
|
|
5
5
|
}) => Promise<{
|
|
6
|
-
config: import("
|
|
6
|
+
config: import("@equinor/fusion-framework-module-app").AppConfig;
|
|
7
7
|
path?: string;
|
|
8
8
|
}>;
|
|
9
9
|
export default loadAppConfig;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { AppManifestExport } from '../../lib/app-manifest.js';
|
|
1
2
|
import { type ConfigExecuterEnv } from '../../lib/utils/config.js';
|
|
2
3
|
import { type ResolvedAppPackage } from '../../lib/app-package.js';
|
|
3
4
|
export declare const loadAppManifest: (env: ConfigExecuterEnv, pkg: ResolvedAppPackage, options?: {
|
|
4
5
|
file?: string;
|
|
5
6
|
}) => Promise<{
|
|
6
|
-
manifest:
|
|
7
|
+
manifest: AppManifestExport;
|
|
7
8
|
path?: string;
|
|
8
9
|
}>;
|
|
9
10
|
export default loadAppManifest;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ClientRequest } from 'http';
|
|
2
|
+
/**
|
|
3
|
+
* Logs the status of a proxy request using a spinner.
|
|
4
|
+
*
|
|
5
|
+
* @param proxyReq - The proxy request to log.
|
|
6
|
+
*
|
|
7
|
+
* The function attaches event listeners to the proxy request to handle
|
|
8
|
+
* 'response' and 'error' events. It uses a spinner to indicate the status
|
|
9
|
+
* of the request:
|
|
10
|
+
* - On a successful response (status code < 400), the spinner succeeds.
|
|
11
|
+
* - On a response with a status code >= 400, the spinner warns with the status message.
|
|
12
|
+
* - On an error, the spinner fails.
|
|
13
|
+
*/
|
|
14
|
+
export declare const proxyRequestLogger: (proxyReq: ClientRequest) => void;
|
|
15
|
+
export default proxyRequestLogger;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AppConfig } from '@equinor/fusion-framework-module-app';
|
|
2
|
+
/**
|
|
3
|
+
* Publishes app config to the apps-service endpoint
|
|
4
|
+
* @param endpoint string The endpoint to upload to
|
|
5
|
+
* @param appKey The application key
|
|
6
|
+
* @param config Object with app config
|
|
7
|
+
* @returns HTTP response as json
|
|
8
|
+
*/
|
|
9
|
+
export declare const publishAppConfig: (endpoint: string, appKey: string, config: AppConfig) => Promise<any>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Send request to apps-service to tag a bundle.
|
|
3
|
+
* @param endpoint string The endpoint to send request to.
|
|
4
|
+
* @param version string The version to tag the bundle with.
|
|
5
|
+
* @returns Response object as json.
|
|
6
|
+
*/
|
|
7
|
+
export declare const tagAppBundle: (endpoint: string, version: string) => Promise<any>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function that uploads a zip bundle to the endpoint.
|
|
3
|
+
* @param endpoint string The endpoint to upload to
|
|
4
|
+
* @param bundle string The filename to upload
|
|
5
|
+
* @returns Object
|
|
6
|
+
*/
|
|
7
|
+
export declare const uploadAppBundle: (endpoint: string, bundle: string) => Promise<any>;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { type ResolvedConfig, type FindConfigOptions, ConfigExecuterEnv } from './utils/config.js';
|
|
2
2
|
import { ResolvedAppPackage } from './app-package.js';
|
|
3
|
-
|
|
4
|
-
/** application config */
|
|
5
|
-
environment?: Record<string, unknown>;
|
|
6
|
-
/** application urls @todo missing scope, use environment until further notice */
|
|
7
|
-
endpoints?: Record<string, string>;
|
|
8
|
-
};
|
|
3
|
+
import type { AppConfig } from '@equinor/fusion-framework-module-app';
|
|
9
4
|
type FindAppConfigOptions = FindConfigOptions & {
|
|
10
5
|
file?: string;
|
|
11
6
|
};
|