@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-export-manifest.js","sourceRoot":"","sources":["../../src/bin/create-export-manifest.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,QAAQ,CAAC;AAEtD,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAG3D,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,yDAAyD;AACzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAE,EAAE;IAChD,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,CAAC,aAAa,YAAY,MAAM,EAAE,8CAA8C,CAAC,CAAC;IAExF,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,aAAa,CAA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from '@equinor/fusion-framework-module-services';
|
|
|
15
15
|
import { enableFeatureFlagging } from '@equinor/fusion-framework-module-feature-flag';
|
|
16
16
|
import { createLocalStoragePlugin, createUrlPlugin, } from '@equinor/fusion-framework-module-feature-flag/plugins';
|
|
17
17
|
export const configure = (config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
config.logger.level = 0;
|
|
19
18
|
config.configureServiceDiscovery({
|
|
20
19
|
client: {
|
|
21
|
-
baseUri:
|
|
20
|
+
baseUri: 'https://discovery.fusion.equinor.com/service-registry/environments/ci/services',
|
|
22
21
|
defaultScopes: ['5a842df8-3238-415d-b168-9f16a6a6031b/.default'],
|
|
23
22
|
},
|
|
24
23
|
});
|
|
24
|
+
// Add custom client for app
|
|
25
|
+
config.configureHttpClient('app', {
|
|
26
|
+
baseUri: new URL('/apps-proxy/', window.location.href).href,
|
|
27
|
+
defaultScopes: ['5a842df8-3238-415d-b168-9f16a6a6031b/.default'],
|
|
28
|
+
});
|
|
25
29
|
config.configureMsal({
|
|
26
30
|
tenantId: '3aa4a235-b6e2-48d5-9195-7fcf05b459b0',
|
|
27
31
|
clientId: '9b707e3a-3e90-41ed-a47e-652a1e3b53d0',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/bin/dev-portal/config.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAE3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6CAA6C,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AACtF,OAAO,EACH,wBAAwB,EACxB,eAAe,GAClB,MAAM,uDAAuD,CAAC;A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,CAAC,CAAC;IAEvB,cAAc,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAC/B,OAAO,CAAC,eAAe,CAAC;YACpB,SAAS,EAAE,KAAK;YAChB,UAAU,EAAE,YAAY;YACxB,IAAI,EAAE,YAAY;SACrB,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,sCAAsC;IACtC,qBAAqB,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QACtC,OAAO,CAAC,SAAS,CACb,wBAAwB,CAAC;YACrB;gBACI,GAAG,EAAE,aAAa;gBAClB,KAAK,EAAE,kBAAkB;gBACzB,WAAW,EAAE,kCAAkC;aAClD;YACD;gBACI,GAAG,EAAE,QAAQ;gBACb,KAAK,EAAE,cAAc;gBACrB,WAAW,EAAE,4CAA4C;aAC5D;SACJ,CAAC,CACL,CAAC;QACF,OAAO,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE;QACrB,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,aAAa,CAAC,CAAO,MAAM,EAAE,EAAE;QAClC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1D,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;IAClD,CAAC,CAAA,CAAC,CAAC;AACP,CAAC,CAAA,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
package/dist/bin/main.app.js
CHANGED
|
@@ -9,6 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { createDevServer } from './create-dev-serve.js';
|
|
11
11
|
import { buildApplication } from './build-application.js';
|
|
12
|
+
import { publishApplication } from './publish-application.js';
|
|
13
|
+
import { uploadApplication } from './upload-application.js';
|
|
14
|
+
import { tagApplication } from './tag-application.js';
|
|
12
15
|
import { formatPath, chalk } from './utils/format.js';
|
|
13
16
|
import createExportManifest from './create-export-manifest.js';
|
|
14
17
|
import { bundleApplication } from './bundle-application.js';
|
|
@@ -20,7 +23,7 @@ export default (program) => {
|
|
|
20
23
|
.command('app')
|
|
21
24
|
.description('Tooling for developing applications build on Fusion Framework');
|
|
22
25
|
app.command('dev')
|
|
23
|
-
.description('
|
|
26
|
+
.description('Start development server for application')
|
|
24
27
|
.option('-p, --port <number>', 'dev-server port')
|
|
25
28
|
.option('-P, --portal <string>', 'fusion portal host')
|
|
26
29
|
.option('-c, --config <file>', `use specified application config, by default search for ${formatPath('app.config.{ts,js,json}')}`)
|
|
@@ -46,6 +49,7 @@ export default (program) => {
|
|
|
46
49
|
});
|
|
47
50
|
}));
|
|
48
51
|
app.command('build')
|
|
52
|
+
.description('Builds application')
|
|
49
53
|
.option('-o, --outDir, <string>', 'output directory of package', 'dist')
|
|
50
54
|
.option('-c, --config <string>', 'Use specified config file, see https://vitejs.dev/guide/cli.html#build')
|
|
51
55
|
.option(' --vite <string>', `use specified Vite config file, by default search for ${formatPath('app.config.vite.{ts,js,json}')}`)
|
|
@@ -59,15 +63,23 @@ export default (program) => {
|
|
|
59
63
|
});
|
|
60
64
|
}));
|
|
61
65
|
app.command('config')
|
|
66
|
+
.description('Generate config')
|
|
62
67
|
.option('-o, --output <string>', 'output file')
|
|
63
68
|
.option('-c, --config <string>', 'application config file')
|
|
69
|
+
.option('-p, --publish <string>', `Publish app config to version [${chalk.yellowBright('(semver | current | latest | preview)')}]`)
|
|
70
|
+
.option('-e, --env, <ci | fqa | tr | fprd>', 'Fusion environment to build api urls from. used when publishing config.')
|
|
71
|
+
.option('-s, --service, <string>', 'Define uri to custom app service. You can also define the env variable CUSTOM_APPAPI to be used on all publish commands. the --env parameter is ignored when set')
|
|
64
72
|
.action((opt) => {
|
|
65
73
|
createExportConfig({
|
|
66
74
|
outputFile: opt.output,
|
|
67
75
|
configFile: opt.config,
|
|
76
|
+
publish: opt.publish,
|
|
77
|
+
env: opt.env,
|
|
78
|
+
service: opt.service,
|
|
68
79
|
});
|
|
69
80
|
});
|
|
70
81
|
app.command('manifest')
|
|
82
|
+
.description('Generate manifest')
|
|
71
83
|
.option('-o, --output <string>', 'output file')
|
|
72
84
|
.option('-c, --config <string>', 'manifest config file')
|
|
73
85
|
.action((opt) => {
|
|
@@ -77,11 +89,40 @@ export default (program) => {
|
|
|
77
89
|
});
|
|
78
90
|
});
|
|
79
91
|
app.command('pack')
|
|
92
|
+
.description('Create distributable app bundle of the application')
|
|
80
93
|
.option('-o, --outDir, <string>', 'output directory of package', 'dist')
|
|
81
94
|
.option('-a, --archive, <string>', 'output filename', 'app-bundle.zip')
|
|
82
95
|
.action((opt) => __awaiter(void 0, void 0, void 0, function* () {
|
|
83
96
|
const { outDir, archive } = opt;
|
|
84
97
|
bundleApplication({ archive, outDir });
|
|
85
98
|
}));
|
|
99
|
+
app.command('publish')
|
|
100
|
+
.description('Publish application to app api')
|
|
101
|
+
.option('-t, --tag, <string>', `Tagname to publish this build as [${chalk.yellowBright('(latest | preview)')}]`, 'latest')
|
|
102
|
+
.requiredOption('-e, --env, <ci | fqa | tr | fprd>', 'Fusion environment to build api urls from')
|
|
103
|
+
.option('-s, --service, <string>', 'Define uri to custom app service. You can also define the env variable CUSTOM_APPAPI to be used on all publish commands. the --env parameter is ignored when set')
|
|
104
|
+
.action((opt) => __awaiter(void 0, void 0, void 0, function* () {
|
|
105
|
+
const { tag, env, service } = opt;
|
|
106
|
+
publishApplication({ tag, env, service });
|
|
107
|
+
}));
|
|
108
|
+
app.command('upload')
|
|
109
|
+
.description('Upload packaged app bundle to app api')
|
|
110
|
+
.option('-b, --bundle, <string>', 'The packaged app bundle file to upload', 'app-bundle.zip')
|
|
111
|
+
.requiredOption('-e, --env, <ci | fqa | tr | fprd>', 'Fusion environment to build api urls from')
|
|
112
|
+
.option('-s, --service, <string>', 'Define uri to custom app service. You can also define the env variable CUSTOM_APPAPI to be used on all publish commands. the --env parameter is ignored when set')
|
|
113
|
+
.action((opt) => __awaiter(void 0, void 0, void 0, function* () {
|
|
114
|
+
const { bundle, env, service } = opt;
|
|
115
|
+
uploadApplication({ bundle, env, service });
|
|
116
|
+
}));
|
|
117
|
+
app.command('tag')
|
|
118
|
+
.description('Tag a published version')
|
|
119
|
+
.option('-t, --tag, <string>', `Tag the published version with tagname [${chalk.yellowBright('(latest | preview)')}]`, 'latest')
|
|
120
|
+
.requiredOption('-v, --version, <string>', 'Version number to tag, must be a published version number')
|
|
121
|
+
.requiredOption('-e, --env, <ci | fqa | tr | fprd>', 'Fusion environment to build api urls from')
|
|
122
|
+
.option('-s, --service, <string>', 'Define uri to custom app service. You can also define the env variable CUSTOM_APPAPI to be used on all publish commands. the --env parameter is ignored when set')
|
|
123
|
+
.action((opt) => __awaiter(void 0, void 0, void 0, function* () {
|
|
124
|
+
const { tag, version, env, service } = opt;
|
|
125
|
+
tagApplication({ tag, version, env, service });
|
|
126
|
+
}));
|
|
86
127
|
};
|
|
87
128
|
//# sourceMappingURL=main.app.js.map
|
package/dist/bin/main.app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.app.js","sourceRoot":"","sources":["../../src/bin/main.app.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"main.app.js","sourceRoot":"","sources":["../../src/bin/main.app.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;A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zB,kKAAkK,CACrK;SACA,MAAM,CAAC,CAAO,GAAG,EAAE,EAAE;QAClB,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC;QAC3C,cAAc,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;IACnD,CAAC,CAAA,CAAC,CAAC;AACX,CAAC,CAAC"}
|
package/dist/bin/main.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
var _a;
|
|
2
1
|
import { fileURLToPath } from 'node:url';
|
|
3
2
|
import { dirname, resolve } from 'node:path';
|
|
4
3
|
/** find cli package.json */
|
|
@@ -11,8 +10,8 @@ process.env.CLI_BIN = resolve(dirname(pkg.path), String(pkg.packageJson.bin['fus
|
|
|
11
10
|
import { Command } from 'commander';
|
|
12
11
|
const program = new Command();
|
|
13
12
|
program.name(pkg.packageJson.name);
|
|
14
|
-
program.description(
|
|
15
|
-
program.version(pkg.packageJson.version);
|
|
13
|
+
program.description(`fusion-framework-cli@${pkg.packageJson.version}.\nCLI for the Fusion Framework`);
|
|
14
|
+
program.version(pkg.packageJson.version, '-V, --vers', 'CLI version');
|
|
16
15
|
/** add app commands */
|
|
17
16
|
import app from './main.app.js';
|
|
18
17
|
app(program);
|
package/dist/bin/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/bin/main.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/bin/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7C,4BAA4B;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,MAAM,GAAG,GAAG,iBAAiB,CAAC,EAAE,GAAG,EAAE,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;AACvE,IAAI,CAAC,GAAG,EAAE,CAAC;IACP,MAAM,KAAK,CAAC,6BAA6B,CAAC,CAAC;AAC/C,CAAC;AACD,OAAO,CAAC,GAAG,CAAC,OAAO,GAAG,OAAO,CACzB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EACjB,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,GAAI,CAAC,sBAAsB,CAAC,CAAC,CACvD,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAC9B,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;AACnC,OAAO,CAAC,WAAW,CACf,wBAAwB,GAAG,CAAC,WAAW,CAAC,OAAO,iCAAiC,CACnF,CAAC;AACF,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;AAEtE,uBAAuB;AACvB,OAAO,GAAG,MAAM,eAAe,CAAC;AAChC,GAAG,CAAC,OAAO,CAAC,CAAC;AAEb,iDAAiD;AACjD,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
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 { assert } from 'node:console';
|
|
11
|
+
/**
|
|
12
|
+
* Preserve token for executing proxy assets
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* This assumes the client will execute a api call using bearer token before
|
|
16
|
+
* acquiring a asset. By default the Framework will execute a rest call to load
|
|
17
|
+
* application manifest for resolving build assets to import.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* This is a quick and dirty method to authorize requests without bearer token
|
|
21
|
+
* like browser `import`.
|
|
22
|
+
* The correct way would be to have a auth controller within the dev-server,
|
|
23
|
+
* but since the token is only exposed to the plugin and the cli is a tool for local
|
|
24
|
+
* development, this should be sufficient.
|
|
25
|
+
*/
|
|
26
|
+
let __APP_API_TOKEN__ = '';
|
|
27
|
+
/**
|
|
28
|
+
* The `appProxyPlugin` function creates a Vite plugin that configures a proxy for API and bundle requests
|
|
29
|
+
* to the Fusion apps backend. It also serves the app manifest, config, and local bundles if an app is provided.
|
|
30
|
+
*
|
|
31
|
+
* @param {AppProxyPluginOptions} options - The options for configuring the app proxy plugin.
|
|
32
|
+
*
|
|
33
|
+
* @returns {Plugin} - The configured Vite plugin.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const plugin = appProxyPlugin({
|
|
38
|
+
* proxy: {
|
|
39
|
+
* path: '/app-proxy',
|
|
40
|
+
* target: 'https://fusion-s-apps-ci.azurewebsites.net/',
|
|
41
|
+
* onProxyReq: (proxyReq, req, res) => {
|
|
42
|
+
* proxyReq.on('response', (res) => { console.log(res.statusCode) });
|
|
43
|
+
* },
|
|
44
|
+
* },
|
|
45
|
+
* app: {
|
|
46
|
+
* key: 'my-app',
|
|
47
|
+
* version: '1.0.0',
|
|
48
|
+
* generateConfig: async () => ({}),
|
|
49
|
+
* generateManifest: async () => ({}),
|
|
50
|
+
* },
|
|
51
|
+
* });
|
|
52
|
+
*
|
|
53
|
+
* // api calls
|
|
54
|
+
* fetch('/app-proxy/apps/my-app/builds/1.0.0/config'); // will generate app config by provided function
|
|
55
|
+
* fetch('/app-proxy/apps/my-app/builds/0.0.9/config'); // will proxy to the target, since version does not match
|
|
56
|
+
* fetch('/app-proxy/apps/other-app/builds/1.0.0/config'); // will proxy to the target, since app key does not match
|
|
57
|
+
*
|
|
58
|
+
* // asset calls
|
|
59
|
+
* fetch('/app-proxy/bundles/my-app/builds/1.0.0/index.js'); // will generate bundle by provided function
|
|
60
|
+
* fetch('/app-proxy/bundles/my-app/builds/0.0.9/index.js'); // will proxy to the target, since version does not match
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
*/
|
|
64
|
+
export const appProxyPlugin = (options) => {
|
|
65
|
+
const { proxy: { onProxyReq = () => void 0, path: proxyPath, target }, } = options;
|
|
66
|
+
return {
|
|
67
|
+
name: 'fusion:app-proxy',
|
|
68
|
+
apply: 'serve',
|
|
69
|
+
config(config) {
|
|
70
|
+
var _a;
|
|
71
|
+
(_a = config.server) !== null && _a !== void 0 ? _a : (config.server = {});
|
|
72
|
+
config.server.proxy = {
|
|
73
|
+
// proxy all api calls to the fusion apps backend
|
|
74
|
+
[`${proxyPath}/apps`]: {
|
|
75
|
+
target,
|
|
76
|
+
changeOrigin: true,
|
|
77
|
+
secure: false,
|
|
78
|
+
rewrite: (path) => path.replace(proxyPath, ''),
|
|
79
|
+
configure: (proxy) => {
|
|
80
|
+
proxy.on('proxyReq', (proxyReq) => {
|
|
81
|
+
const token = proxyReq.getHeader('authorization');
|
|
82
|
+
if (typeof token === 'string') {
|
|
83
|
+
__APP_API_TOKEN__ = token;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
proxy.on('proxyReq', onProxyReq);
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
// proxy all bundle requests to the fusion apps backend
|
|
90
|
+
[`${proxyPath}/bundles`]: {
|
|
91
|
+
target,
|
|
92
|
+
changeOrigin: true,
|
|
93
|
+
secure: false,
|
|
94
|
+
rewrite: (path) => path.replace(proxyPath, ''),
|
|
95
|
+
configure: (proxy) => {
|
|
96
|
+
proxy.on('proxyReq', (proxyReq) => {
|
|
97
|
+
assert(__APP_API_TOKEN__, 'expected token to be set');
|
|
98
|
+
proxyReq.setHeader('authorization', __APP_API_TOKEN__);
|
|
99
|
+
});
|
|
100
|
+
proxy.on('proxyReq', onProxyReq);
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
configureServer(server) {
|
|
106
|
+
const { app } = options;
|
|
107
|
+
// disable local assets if no app configuration provided
|
|
108
|
+
if (!app)
|
|
109
|
+
return;
|
|
110
|
+
// serve app manifest if request matches the current app
|
|
111
|
+
// todo this should have version
|
|
112
|
+
const manifestPath = `${proxyPath}/apps/${app.key}`;
|
|
113
|
+
server.middlewares.use(manifestPath, (_req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
res.setHeader('content-type', 'application/json');
|
|
115
|
+
res.end(JSON.stringify(yield app.generateManifest()));
|
|
116
|
+
}));
|
|
117
|
+
// serve app config if request matches the current app and version
|
|
118
|
+
const configPath = `${proxyPath}/apps/${app.key}/builds/${app.version}/config`;
|
|
119
|
+
server.middlewares.use(configPath, (_req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
res.setHeader('content-type', 'application/json');
|
|
121
|
+
res.end(JSON.stringify(yield app.generateConfig()));
|
|
122
|
+
}));
|
|
123
|
+
// serve local bundles if request matches the current app and version
|
|
124
|
+
const bundlePath = `${proxyPath}/bundles/apps/${app.key}/${app.version}`;
|
|
125
|
+
server.middlewares.use((req, _res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
var _a;
|
|
127
|
+
if ((_a = req.url) === null || _a === void 0 ? void 0 : _a.match(bundlePath)) {
|
|
128
|
+
// remove proxy path from url
|
|
129
|
+
req.url = req.url.replace(bundlePath, '');
|
|
130
|
+
}
|
|
131
|
+
next();
|
|
132
|
+
}));
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
export default appProxyPlugin;
|
|
137
|
+
//# sourceMappingURL=app-proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-proxy.js","sourceRoot":"","sources":["../../../src/bin/plugins/app-proxy.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAKtC;;;;;;;;;;;;;;GAcG;AACH,IAAI,iBAAiB,GAAG,EAAE,CAAC;AA+B3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAA8B,EAAU,EAAE;IACrE,MAAM,EACF,KAAK,EAAE,EAAE,UAAU,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,GAChE,GAAG,OAAO,CAAC;IACZ,OAAO;QACH,IAAI,EAAE,kBAAkB;QACxB,KAAK,EAAE,OAAO;QACd,MAAM,CAAC,MAAM;;YACT,MAAA,MAAM,CAAC,MAAM,oCAAb,MAAM,CAAC,MAAM,GAAK,EAAE,EAAC;YACrB,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG;gBAClB,iDAAiD;gBACjD,CAAC,GAAG,SAAS,OAAO,CAAC,EAAE;oBACnB,MAAM;oBACN,YAAY,EAAE,IAAI;oBAClB,MAAM,EAAE,KAAK;oBACb,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;oBAC9C,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;wBACjB,KAAK,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,EAAE;4BAC9B,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,CAAC,eAAe,CAAC,CAA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,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;YAC1D,CAAC,CAAA,CAAC,CAAC;YAEH,kEAAkE;YAClE,MAAM,UAAU,GAAG,GAAG,SAAS,SAAS,GAAG,CAAC,GAAG,WAAW,GAAG,CAAC,OAAO,SAAS,CAAC;YAC/E,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,EAAE,CAAO,IAAI,EAAE,GAAG,EAAE,EAAE;gBACnD,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;gBAClD,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC;YACxD,CAAC,CAAA,CAAC,CAAC;YAEH,qEAAqE;YACrE,MAAM,UAAU,GAAG,GAAG,SAAS,iBAAiB,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YACzE,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAO,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;;gBAC7C,IAAI,MAAA,GAAG,CAAC,GAAG,0CAAE,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC;oBAC7B,6BAA6B;oBAC7B,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;gBAC/C,CAAC;gBACD,IAAI,EAAE,CAAC;YACX,CAAC,CAAA,CAAC,CAAC;QACP,CAAC;KACJ,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
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 { join } from 'node:path';
|
|
11
|
+
import { readFileSync } from 'node:fs';
|
|
12
|
+
/**
|
|
13
|
+
* Creates a plugin that serves an external public directory.
|
|
14
|
+
*
|
|
15
|
+
* 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.
|
|
16
|
+
* Vite`s built in `mode: 'spa'` will only look for the `index.html` file in the configured `root` directory,
|
|
17
|
+
* so this plugin is necessary to serve the `index.html` file from a different directory.
|
|
18
|
+
*
|
|
19
|
+
* @param path - The path to the external public directory.
|
|
20
|
+
* @returns A Plugin object configured to serve the specified public directory.
|
|
21
|
+
*
|
|
22
|
+
* The plugin:
|
|
23
|
+
* - Sets the `publicDir` configuration to the provided path.
|
|
24
|
+
* - Adds a middleware to the server that serves the `index.html` file from the specified path.
|
|
25
|
+
*
|
|
26
|
+
* The middleware:
|
|
27
|
+
* - Reads the `index.html` file from the specified path.
|
|
28
|
+
* - Transforms the HTML using the server's `transformIndexHtml` method.
|
|
29
|
+
* - Responds with the transformed HTML, setting appropriate headers.
|
|
30
|
+
*/
|
|
31
|
+
export const externalPublicPlugin = (path) => {
|
|
32
|
+
return {
|
|
33
|
+
name: 'fusion:external-public',
|
|
34
|
+
apply: 'serve',
|
|
35
|
+
config(config) {
|
|
36
|
+
config.publicDir = path;
|
|
37
|
+
},
|
|
38
|
+
configureServer(server) {
|
|
39
|
+
// intercept requests to serve the index.html file
|
|
40
|
+
server.middlewares.use((req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
var _a;
|
|
42
|
+
if (
|
|
43
|
+
// Only accept GET or HEAD
|
|
44
|
+
(req.method !== 'GET' && req.method !== 'HEAD') ||
|
|
45
|
+
// Only accept text/html
|
|
46
|
+
!((_a = req.headers.accept) === null || _a === void 0 ? void 0 : _a.includes('text/html'))) {
|
|
47
|
+
return next();
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
// load the raw html from provided path
|
|
51
|
+
const htmlRaw = readFileSync(join(path, 'index.html'), 'utf-8');
|
|
52
|
+
// transform the html, this is where vite plugin hooks are applied
|
|
53
|
+
const html = yield server.transformIndexHtml(req.url, htmlRaw, req.originalUrl);
|
|
54
|
+
// apply content headers and configured additional headers
|
|
55
|
+
res.writeHead(200, Object.assign({ 'content-type': 'text/html', 'content-length': Buffer.byteLength(html), 'cache-control': 'no-cache' }, server.config.server.headers));
|
|
56
|
+
// send the transformed html and end the response
|
|
57
|
+
res.end(html);
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
next(e);
|
|
61
|
+
}
|
|
62
|
+
}));
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export default externalPublicPlugin;
|
|
67
|
+
//# sourceMappingURL=external-public.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external-public.js","sourceRoot":"","sources":["../../../src/bin/plugins/external-public.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAIvC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAU,EAAE;IACzD,OAAO;QACH,IAAI,EAAE,wBAAwB;QAC9B,KAAK,EAAE,OAAO;QACd,MAAM,CAAC,MAAM;YACT,MAAM,CAAC,SAAS,GAAG,IAAI,CAAC;QAC5B,CAAC;QACD,eAAe,CAAC,MAAM;YAClB,kDAAkD;YAClD,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAO,GAAG,EAAE,GAAG,EAAE,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