@equinor/fusion-framework-cli 10.1.0 → 10.1.1
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 +6 -0
- package/dist/bin/public/assets/{index-VsB-fOGc.js → index-CvJ4Uui7.js} +323 -323
- package/dist/bin/public/index.html +1 -1
- package/dist/lib/plugins/app-proxy/app-proxy-plugin.js +1 -1
- package/dist/lib/plugins/app-proxy/app-proxy-plugin.js.map +1 -1
- package/dist/types/app-config.d.ts +26 -0
- package/dist/types/app-manifest.d.ts +52 -0
- package/dist/types/app-package.d.ts +54 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/plugins/app-assets/app-asset-plugin.d.ts +36 -0
- package/dist/types/plugins/app-assets/emit-asset.d.ts +18 -0
- package/dist/types/plugins/app-assets/extension-filter-pattern.d.ts +14 -0
- package/dist/types/plugins/app-assets/index.d.ts +3 -0
- package/dist/types/plugins/app-assets/read-asset-content.d.ts +14 -0
- package/dist/types/plugins/app-assets/resolve-asset-id.d.ts +16 -0
- package/dist/types/plugins/app-assets/static.d.ts +5 -0
- package/dist/types/plugins/app-proxy/app-proxy-plugin.d.ts +71 -0
- package/dist/types/plugins/app-proxy/index.d.ts +1 -0
- package/dist/types/plugins/external-public/external-public-plugin.d.ts +30 -0
- package/dist/types/plugins/external-public/index.d.ts +1 -0
- package/dist/types/utils/assert.d.ts +11 -0
- package/dist/types/utils/config.d.ts +32 -0
- package/dist/types/utils/expect.d.ts +4 -0
- package/dist/types/utils/file-exists.d.ts +6 -0
- package/dist/types/utils/ts-transpile.d.ts +2 -0
- package/dist/types/utils/types.d.ts +6 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types/vite-config.d.ts +17 -0
- package/dist/types/vite-logger.d.ts +2 -0
- package/dist/version.js +1 -1
- package/package.json +7 -7
|
@@ -107,7 +107,7 @@ export const appProxyPlugin = (options) => {
|
|
|
107
107
|
}));
|
|
108
108
|
// serve app manifest if request matches the current app
|
|
109
109
|
const manifestPath = join(proxyPath, (_b = app.manifestPath) !== null && _b !== void 0 ? _b : `apps/${app.key}`);
|
|
110
|
-
server.middlewares.use(
|
|
110
|
+
server.middlewares.use(manifestPath, (_req, res) => __awaiter(this, void 0, void 0, function* () {
|
|
111
111
|
res.setHeader('content-type', 'application/json');
|
|
112
112
|
res.end(JSON.stringify(yield app.generateManifest()));
|
|
113
113
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-proxy-plugin.js","sourceRoot":"","sources":["../../../../src/lib/plugins/app-proxy/app-proxy-plugin.ts"],"names":[],"mappings":";;;;;;;;;AAOA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;;;;;;;;;;GAcG;AACH,IAAI,iBAAiB,GAAG,EAAE,CAAC;AAqD3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,SAAS,CAAC,EAAE;oBACT,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,K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CAAC,CAAC;YAEH,qEAAqE;YACrE,MAAM,UAAU,GAAG,IAAI,CACnB,SAAS,EACT,MAAA,GAAG,CAAC,UAAU,mCAAI,gBAAgB,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE,CAC7D,CAAC;YACF,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,26 @@
|
|
|
1
|
+
import { type ResolvedConfig, type FindConfigOptions, ConfigExecuterEnv } from './utils/config.js';
|
|
2
|
+
import { ApiAppConfig } from '@equinor/fusion-framework-module-app/schemas.js';
|
|
3
|
+
type FindAppConfigOptions = FindConfigOptions & {
|
|
4
|
+
file?: string;
|
|
5
|
+
};
|
|
6
|
+
export type AppConfigFn = (env: ConfigExecuterEnv, args: {
|
|
7
|
+
base: ApiAppConfig;
|
|
8
|
+
}) => ApiAppConfig | Promise<ApiAppConfig | void> | void;
|
|
9
|
+
export type AppConfigExport = ApiAppConfig | AppConfigFn;
|
|
10
|
+
export declare const appConfigFilename = "app.config";
|
|
11
|
+
export declare const defineAppConfig: (fn: AppConfigFn) => AppConfigFn;
|
|
12
|
+
export declare const loadAppConfig: (filename?: string) => Promise<import("./utils/config.js").ConfigExecuter<{
|
|
13
|
+
environment: Record<string, any>;
|
|
14
|
+
endpoints?: Record<string, {
|
|
15
|
+
url: string;
|
|
16
|
+
scopes: string[];
|
|
17
|
+
}> | undefined;
|
|
18
|
+
}, import("./utils/config.js").ConfigExecuterArgs>>;
|
|
19
|
+
export declare const resolveAppConfig: (options?: FindConfigOptions & {
|
|
20
|
+
file?: string;
|
|
21
|
+
}) => Promise<ResolvedConfig<AppConfigFn> | void>;
|
|
22
|
+
export declare const createAppConfig: (env: ConfigExecuterEnv, base: ApiAppConfig, options?: FindAppConfigOptions) => Promise<{
|
|
23
|
+
config: ApiAppConfig;
|
|
24
|
+
path?: string;
|
|
25
|
+
}>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ResolvedAppPackage } from './app-package.js';
|
|
2
|
+
import { type FindConfigOptions, type ResolvedConfig, ConfigExecuterEnv } from './utils/config.js';
|
|
3
|
+
import { RecursivePartial } from './utils/types.js';
|
|
4
|
+
import { AppManifest } from '@equinor/fusion-framework-module-app';
|
|
5
|
+
export type AppManifestFn = (env: ConfigExecuterEnv, args: {
|
|
6
|
+
base: AppManifest;
|
|
7
|
+
}) => Partial<AppManifest> | Promise<Partial<AppManifest> | void> | void;
|
|
8
|
+
type FindManifestOptions = FindConfigOptions & {
|
|
9
|
+
file?: string;
|
|
10
|
+
};
|
|
11
|
+
/** base filename for configuration files */
|
|
12
|
+
export declare const manifestConfigFilename = "app.manifest.config";
|
|
13
|
+
/**
|
|
14
|
+
* Define a manifest for an application
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* export default defineAppManifest(async() => {
|
|
19
|
+
* return {
|
|
20
|
+
* ...AppManifest_properties
|
|
21
|
+
* }
|
|
22
|
+
* })
|
|
23
|
+
* ```
|
|
24
|
+
* @param fnOrObj - defines the manifest as an object or callback
|
|
25
|
+
*/
|
|
26
|
+
export declare const defineAppManifest: (fn: AppManifestFn) => AppManifestFn;
|
|
27
|
+
export declare function assertAppManifest(value: AppManifest): asserts value;
|
|
28
|
+
/**
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* export default defineAppManifest(base) => mergeManifests(base, {prop: value});
|
|
32
|
+
* ```
|
|
33
|
+
* @param base base manifest to merge with
|
|
34
|
+
* @param overrides target manifest to apply to base
|
|
35
|
+
* @returns deep merged manifest
|
|
36
|
+
*/
|
|
37
|
+
export declare const mergeManifests: (base: RecursivePartial<AppManifest>, overrides: RecursivePartial<AppManifest>) => AppManifest;
|
|
38
|
+
/** loads manifestFn from file */
|
|
39
|
+
export declare const loadManifest: (filename?: string) => Promise<import("./utils/config.js").ConfigExecuter<AppManifest, import("./utils/config.js").ConfigExecuterArgs>>;
|
|
40
|
+
/**
|
|
41
|
+
* tries to resolve manifest
|
|
42
|
+
* @see {@link resolveConfig | resolving config}
|
|
43
|
+
*/
|
|
44
|
+
export declare const resolveManifest: (options?: FindConfigOptions & {
|
|
45
|
+
file?: string;
|
|
46
|
+
}) => Promise<ResolvedConfig<AppManifestFn> | void>;
|
|
47
|
+
export declare const createManifestFromPackage: (pkg: ResolvedAppPackage) => AppManifest;
|
|
48
|
+
export declare const createManifest: (env: ConfigExecuterEnv, base: AppManifest, options?: FindManifestOptions) => Promise<{
|
|
49
|
+
manifest: AppManifest;
|
|
50
|
+
path?: string;
|
|
51
|
+
}>;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { PackageJson, type NormalizeOptions as ResolveAppPackageOptions } from 'read-package-up';
|
|
2
|
+
import { AppManifest } from '@equinor/fusion-framework-module-app';
|
|
3
|
+
export type AppPackageJson = PackageJson & {
|
|
4
|
+
manifest?: AppManifest;
|
|
5
|
+
};
|
|
6
|
+
type DefinePackageFn = () => AppPackageJson | Promise<AppPackageJson>;
|
|
7
|
+
type DefinePackageExporter = AppPackageJson | DefinePackageFn;
|
|
8
|
+
export interface defineAppPackage {
|
|
9
|
+
(obj: AppPackageJson): AppPackageJson;
|
|
10
|
+
}
|
|
11
|
+
export interface defineAppPackage {
|
|
12
|
+
(fn: DefinePackageFn): void;
|
|
13
|
+
}
|
|
14
|
+
export type ResolvedAppPackage = {
|
|
15
|
+
packageJson: AppPackageJson;
|
|
16
|
+
path: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function defineAppPackage(fnOrObject: DefinePackageExporter): DefinePackageExporter;
|
|
19
|
+
/**
|
|
20
|
+
* Resolves the entry point of a given package.
|
|
21
|
+
*
|
|
22
|
+
* This function attempts to find the entry point of a package by checking several
|
|
23
|
+
* common properties in the package's `package.json` file, such as `entrypoint`, `main`,
|
|
24
|
+
* and `module`. If none of these properties are found, it defaults to checking for
|
|
25
|
+
* common entry files like `src/index.ts`, `src/index.tsx`, `src/index.js`, and `src/index.jsx`.
|
|
26
|
+
*
|
|
27
|
+
* @param pkg - The resolved application package containing the package.json and path information.
|
|
28
|
+
* @returns The relative path to the resolved entry point.
|
|
29
|
+
* @throws Will throw an error if no entry point can be resolved.
|
|
30
|
+
*/
|
|
31
|
+
export declare const resolveEntryPoint: (packageJson: PackageJson, pkgPath?: string) => string;
|
|
32
|
+
/**
|
|
33
|
+
* Resolves the application key from the given package.json object.
|
|
34
|
+
*
|
|
35
|
+
* @param packageJson - An object containing the 'name' property from the package.json.
|
|
36
|
+
* @returns The resolved application key, which is the package name with any leading '@' or scope removed.
|
|
37
|
+
* @throws Will throw an error if the 'name' property is not present in the packageJson.
|
|
38
|
+
*/
|
|
39
|
+
export declare const resolveAppKey: (packageJson: Pick<PackageJson, "name">) => string;
|
|
40
|
+
/**
|
|
41
|
+
* Asserts the validity of a given package by resolving its application key and entry point.
|
|
42
|
+
*
|
|
43
|
+
* @param pkg - A partial representation of the application's package JSON.
|
|
44
|
+
*/
|
|
45
|
+
export declare const assertPackage: (pkg: Partial<AppPackageJson>) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Resolves the application package by searching for the nearest `package.json` file.
|
|
48
|
+
*
|
|
49
|
+
* @param options - Optional parameters to customize the search behavior.
|
|
50
|
+
* @returns A promise that resolves to the found package information.
|
|
51
|
+
* @throws Will throw an error if the `package.json` file is not found.
|
|
52
|
+
*/
|
|
53
|
+
export declare const resolveAppPackage: (options?: ResolveAppPackageOptions) => Promise<ResolvedAppPackage>;
|
|
54
|
+
export default resolveAppPackage;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { mergeManifests, defineAppManifest, type AppManifestFn } from './app-manifest.js';
|
|
2
|
+
export { defineAppConfig, type AppConfigFn, type AppConfigExport } from './app-config.js';
|
|
3
|
+
export { defineAppPackage, resolveAppKey, resolveEntryPoint, type AppPackageJson, type ResolvedAppPackage, } from './app-package.js';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type FilterPattern, type Plugin } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* A Vite plugin to handle external resources in a library build.
|
|
4
|
+
*
|
|
5
|
+
* @param options - Configuration options for the plugin.
|
|
6
|
+
* @param options.name - Optional name for the emitted assets.
|
|
7
|
+
* @param options.include - Filter pattern to include specific files.
|
|
8
|
+
* @param options.exclude - Filter pattern to exclude specific files.
|
|
9
|
+
* @returns A Vite plugin object.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* This plugin is intended to be used only during the Vite library build process.
|
|
13
|
+
* It resolves asset IDs, emits assets, and exports them as URLs.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // vite.config.ts
|
|
18
|
+
* import { ExternalAppAssetPlugin } from '@equinor/fusion-framework-cli/plugins/app-assets-plugin';
|
|
19
|
+
*
|
|
20
|
+
* export default {
|
|
21
|
+
* plugins: [
|
|
22
|
+
* ExternalAppAssetPlugin({
|
|
23
|
+
* name: 'my-asset',
|
|
24
|
+
* include: ['svg', 'png'],
|
|
25
|
+
* exclude: 'node_modules/**',
|
|
26
|
+
* }),
|
|
27
|
+
* ],
|
|
28
|
+
* };
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare const AppAssetExportPlugin: (options?: {
|
|
32
|
+
name?: string;
|
|
33
|
+
include?: FilterPattern;
|
|
34
|
+
exclude?: FilterPattern;
|
|
35
|
+
}) => Plugin;
|
|
36
|
+
export default AppAssetExportPlugin;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type PluginContext } from 'rollup';
|
|
2
|
+
/**
|
|
3
|
+
* Synchronously emits an asset file based on the provided context and options.
|
|
4
|
+
*
|
|
5
|
+
* @param context - The plugin context used for emitting the file and logging warnings.
|
|
6
|
+
* @param id - The identifier of the asset, which may include a resource query.
|
|
7
|
+
* @param options - Optional parameters for customizing the emitted asset.
|
|
8
|
+
* @param options.name - The name template for the emitted asset file. Defaults to '[name].[ext]'.
|
|
9
|
+
* @param options.outDir - The output directory where the asset will be emitted. Defaults to 'dist'.
|
|
10
|
+
* @param options.assetsDir - The directory within the output directory where assets will be stored. Defaults to 'assets'.
|
|
11
|
+
* @returns The path of the emitted asset relative to the assets directory, or null if the asset content could not be read.
|
|
12
|
+
*/
|
|
13
|
+
export declare const emitAssetSync: (context: PluginContext, id: string, options?: {
|
|
14
|
+
name?: string;
|
|
15
|
+
outDir?: string;
|
|
16
|
+
assetsDir?: string;
|
|
17
|
+
}) => string | null;
|
|
18
|
+
export default emitAssetSync;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a regular expression pattern to filter files based on their extensions.
|
|
3
|
+
*
|
|
4
|
+
* @param exts - An array of file extensions to include in the pattern.
|
|
5
|
+
* @returns A RegExp object that matches files with the specified extensions.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const pattern = createExtensionFilterPattern(['.js', '.ts']);
|
|
10
|
+
* console.log(pattern); // Output: /\.(js|ts)(\?.*)?$/
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare const createExtensionFilterPattern: (exts: string[]) => RegExp;
|
|
14
|
+
export default createExtensionFilterPattern;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads the content of an asset synchronously.
|
|
3
|
+
*
|
|
4
|
+
* @param id - The identifier of the asset, which can include a query string.
|
|
5
|
+
* @returns The content of the asset as a Buffer if it exists, otherwise null.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* - If the asset content is already cached, it returns the cached content.
|
|
9
|
+
* - The function extracts the filename from the identifier by removing any query string.
|
|
10
|
+
* - If the file exists, it reads the content, caches it, and then returns it.
|
|
11
|
+
* - If the file does not exist, it logs a warning and returns null.
|
|
12
|
+
*/
|
|
13
|
+
export declare const readAssetContentSync: (id: string) => Buffer | null;
|
|
14
|
+
export default readAssetContentSync;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type PluginContext, type PartialResolvedId } from 'rollup';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves the asset ID based on the provided context, ID, importer, and options.
|
|
4
|
+
*
|
|
5
|
+
* @param context - The plugin context used for resolving the ID.
|
|
6
|
+
* @param id - The asset ID to resolve.
|
|
7
|
+
* @param importer - The path of the module that is importing the asset.
|
|
8
|
+
* @param options - Optional resolution options.
|
|
9
|
+
* @returns A promise that resolves to a `PartialResolvedId` object or `null`.
|
|
10
|
+
*
|
|
11
|
+
* The function handles three cases:
|
|
12
|
+
* 1. If the ID is an absolute path, it returns an object with the ID, marked as external and resolved by the plugin.
|
|
13
|
+
* 2. If the ID is a relative path, it resolves the path relative to the importer and returns an object with the resolved ID, marked as external and resolved by the plugin.
|
|
14
|
+
* 3. For all other cases, it delegates the resolution to the context's resolve method.
|
|
15
|
+
*/
|
|
16
|
+
export declare const resolveAssetId: (context: PluginContext, id: string, importer: string, options?: Parameters<PluginContext["resolve"]>[2]) => Promise<PartialResolvedId | null>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
import { AppManifest } from '@equinor/fusion-framework-app';
|
|
3
|
+
import { ClientRequest, IncomingMessage, ServerResponse } from 'node:http';
|
|
4
|
+
import { ApiAppConfig } from '@equinor/fusion-framework-module-app/schemas.js';
|
|
5
|
+
/**
|
|
6
|
+
* Options for configuring the App Proxy Plugin.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* When not providing an app configuration, the plugin will only proxy requests to the target.
|
|
10
|
+
*/
|
|
11
|
+
export type AppProxyPluginOptions = {
|
|
12
|
+
/** Configuration for the proxy. */
|
|
13
|
+
proxy: {
|
|
14
|
+
/** The path to be proxied. */
|
|
15
|
+
path: string;
|
|
16
|
+
/** The target URL for the proxy. */
|
|
17
|
+
target: string;
|
|
18
|
+
/** Optional callback function to modify the proxy request. */
|
|
19
|
+
onProxyReq?: (proxyReq: ClientRequest, req: IncomingMessage, res: ServerResponse) => void;
|
|
20
|
+
};
|
|
21
|
+
/** Optional configuration for the app. */
|
|
22
|
+
app?: {
|
|
23
|
+
/** application key */
|
|
24
|
+
key: string;
|
|
25
|
+
/** application version */
|
|
26
|
+
version: string;
|
|
27
|
+
/** callback function for generating configuration for the application */
|
|
28
|
+
generateConfig: () => Promise<ApiAppConfig>;
|
|
29
|
+
/** callback function for generating manifest for the application */
|
|
30
|
+
generateManifest: () => Promise<AppManifest>;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* The `appProxyPlugin` function creates a Vite plugin that configures a proxy for API and bundle requests
|
|
35
|
+
* to the Fusion apps backend. It also serves the app manifest, config, and local bundles if an app is provided.
|
|
36
|
+
*
|
|
37
|
+
* @param {AppProxyPluginOptions} options - The options for configuring the app proxy plugin.
|
|
38
|
+
*
|
|
39
|
+
* @returns {Plugin} - The configured Vite plugin.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const plugin = appProxyPlugin({
|
|
44
|
+
* proxy: {
|
|
45
|
+
* path: '/app-proxy',
|
|
46
|
+
* target: 'https://fusion-s-apps-ci.azurewebsites.net/',
|
|
47
|
+
* onProxyReq: (proxyReq, req, res) => {
|
|
48
|
+
* proxyReq.on('response', (res) => { console.log(res.statusCode) });
|
|
49
|
+
* },
|
|
50
|
+
* },
|
|
51
|
+
* app: {
|
|
52
|
+
* key: 'my-app',
|
|
53
|
+
* version: '1.0.0',
|
|
54
|
+
* generateConfig: async () => ({}),
|
|
55
|
+
* generateManifest: async () => ({}),
|
|
56
|
+
* },
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* // api calls
|
|
60
|
+
* fetch('/app-proxy/apps/my-app/builds/1.0.0/config'); // will generate app config by provided function
|
|
61
|
+
* fetch('/app-proxy/apps/my-app/builds/0.0.9/config'); // will proxy to the target, since version does not match
|
|
62
|
+
* fetch('/app-proxy/apps/other-app/builds/1.0.0/config'); // will proxy to the target, since app key does not match
|
|
63
|
+
*
|
|
64
|
+
* // asset calls
|
|
65
|
+
* fetch('/app-proxy/bundles/my-app/builds/1.0.0/index.js'); // will generate bundle by provided function
|
|
66
|
+
* fetch('/app-proxy/bundles/my-app/builds/0.0.9/index.js'); // will proxy to the target, since version does not match
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
export declare const appProxyPlugin: (options: AppProxyPluginOptions) => Plugin;
|
|
71
|
+
export default appProxyPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, appProxyPlugin, type AppProxyPluginOptions } from './app-proxy-plugin.js';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type FilterPattern, 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
|
+
* @param options - Optional filter patterns to include or exclude specific assets.
|
|
11
|
+
* @param options.include - A filter pattern to include specific assets.
|
|
12
|
+
* @param options.exclude - A filter pattern to exclude specific assets.
|
|
13
|
+
* @returns A Vite plugin object.
|
|
14
|
+
*
|
|
15
|
+
* The plugin:
|
|
16
|
+
* - Sets the `path` configuration to the provided path.
|
|
17
|
+
* - Adds a middleware to the server that serves static assets from the specified path.
|
|
18
|
+
* - Adds a middleware to the server that serves the `index.html` file from the specified path.
|
|
19
|
+
*
|
|
20
|
+
* The middleware:
|
|
21
|
+
* - Checks if the request is for a static asset and serves it from the specified path.
|
|
22
|
+
* - Reads the `index.html` file from the specified path.
|
|
23
|
+
* - Transforms the HTML using the server's `transformIndexHtml` method.
|
|
24
|
+
* - Responds with the transformed HTML, setting appropriate headers.
|
|
25
|
+
*/
|
|
26
|
+
export declare const externalPublicPlugin: (path: string, options?: {
|
|
27
|
+
include?: FilterPattern;
|
|
28
|
+
exclude?: FilterPattern;
|
|
29
|
+
}) => Plugin;
|
|
30
|
+
export default externalPublicPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default, externalPublicPlugin } from './external-public-plugin.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import assert, { AssertionError } from 'node:assert';
|
|
2
|
+
export { assert, AssertionError };
|
|
3
|
+
export declare function assertNumber(value: unknown, message?: string): asserts value;
|
|
4
|
+
export declare function assertObject(value: object, message?: string | Error): asserts value;
|
|
5
|
+
declare function assertObjectEntryValue<P>(value: unknown, prop: P, message?: string): asserts value;
|
|
6
|
+
export declare function assertObjectEntries<T extends object, P extends Array<keyof T>>(// extends Record<string, unknown> = unknown>(
|
|
7
|
+
value: T, options?: {
|
|
8
|
+
props?: P;
|
|
9
|
+
assertion?: typeof assertObjectEntryValue;
|
|
10
|
+
preMessage?: string;
|
|
11
|
+
}): asserts value;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Options } from 'find-up';
|
|
2
|
+
export declare const supportedExt: readonly [".ts", ".mjs", ".js", ".json"];
|
|
3
|
+
export type SupportedExt = (typeof supportedExt)[number];
|
|
4
|
+
export type FindConfigOptions = Omit<Options, 'file'> & {
|
|
5
|
+
extensions?: Array<SupportedExt>;
|
|
6
|
+
};
|
|
7
|
+
export type ResolveConfigOptions = {
|
|
8
|
+
find?: FindConfigOptions;
|
|
9
|
+
};
|
|
10
|
+
export type ConfigExecuterEnv = {
|
|
11
|
+
/** cli command */
|
|
12
|
+
command: 'serve' | 'build';
|
|
13
|
+
/** cli mode */
|
|
14
|
+
mode: string;
|
|
15
|
+
/** root of the package */
|
|
16
|
+
root?: string;
|
|
17
|
+
};
|
|
18
|
+
export type ConfigExecuterArgs = [ConfigExecuterEnv, ...any[]];
|
|
19
|
+
export type ConfigExecuter<TType = any, TArgs extends ConfigExecuterArgs = ConfigExecuterArgs> = (...args: TArgs) => TType | Promise<TType>;
|
|
20
|
+
export type ConfigExecuterType<T> = T extends ConfigExecuter<infer TType> ? TType : never;
|
|
21
|
+
export type ResolvedConfig<TType extends ConfigExecuter> = {
|
|
22
|
+
path: string;
|
|
23
|
+
config: TType;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* @param filename name if config file without extension
|
|
27
|
+
*/
|
|
28
|
+
export declare const findConfigs: (filename: string, options?: FindConfigOptions) => Promise<string[]>;
|
|
29
|
+
export declare const resolveConfig: <TType>(filename: string, options?: ResolveConfigOptions) => Promise<ResolvedConfig<ConfigExecuter<TType>> | void>;
|
|
30
|
+
export declare const loadConfig: <TType>(file: string) => Promise<ConfigExecuter<TType>>;
|
|
31
|
+
export declare function initiateConfig<TConfig extends ConfigExecuter>(config: TConfig, ...args: Parameters<TConfig>): Promise<ConfigExecuterType<TConfig> | void>;
|
|
32
|
+
export default loadConfig;
|
package/dist/types/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "10.
|
|
1
|
+
export declare const version = "10.2.0";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type UserConfig, type UserConfigFn } from 'vite';
|
|
2
|
+
import { type FindConfigOptions, type ResolvedConfig, ConfigExecuterEnv } from './utils/config.js';
|
|
3
|
+
export declare function assertViteConfig(config: UserConfig): asserts config;
|
|
4
|
+
export declare const loadViteConfig: (filename?: string) => Promise<import("./utils/config.js").ConfigExecuter<UserConfig, import("./utils/config.js").ConfigExecuterArgs>>;
|
|
5
|
+
export declare const resolveViteConfig: (options?: FindConfigOptions & {
|
|
6
|
+
file?: string;
|
|
7
|
+
}) => Promise<ResolvedConfig<UserConfigFn> | void>;
|
|
8
|
+
export declare const createAppViteConfig: (env: ConfigExecuterEnv, options?: FindConfigOptions & {
|
|
9
|
+
file?: string;
|
|
10
|
+
}) => Promise<{
|
|
11
|
+
config?: UserConfig;
|
|
12
|
+
path?: string;
|
|
13
|
+
} | void>;
|
|
14
|
+
export declare const resolveEntryPoint: (cwd?: string, dir?: string, opt?: {
|
|
15
|
+
files?: string[];
|
|
16
|
+
}) => string | undefined;
|
|
17
|
+
export declare const createViteConfig: (env: ConfigExecuterEnv, overrides?: UserConfig) => Promise<UserConfig>;
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/fusion-framework-cli",
|
|
3
|
-
"version": "10.1.
|
|
3
|
+
"version": "10.1.1",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"Fusion",
|
|
6
6
|
"Fusion Framework",
|
|
@@ -84,20 +84,20 @@
|
|
|
84
84
|
"rxjs": "^7.8.1",
|
|
85
85
|
"styled-components": "^6.0.7",
|
|
86
86
|
"typescript": "^5.5.4",
|
|
87
|
-
"@equinor/fusion-framework-module-app": "^6.0.2",
|
|
88
|
-
"@equinor/fusion-framework": "^7.2.9",
|
|
89
87
|
"@equinor/fusion-framework-app": "^9.1.12",
|
|
90
|
-
"@equinor/fusion-framework
|
|
88
|
+
"@equinor/fusion-framework": "^7.2.9",
|
|
89
|
+
"@equinor/fusion-framework-module-bookmark": "^1.2.13",
|
|
90
|
+
"@equinor/fusion-framework-module-app": "^6.0.2",
|
|
91
91
|
"@equinor/fusion-framework-module-feature-flag": "^1.1.10",
|
|
92
|
+
"@equinor/fusion-framework-module-context": "^5.0.13",
|
|
92
93
|
"@equinor/fusion-framework-module-msal": "^3.1.5",
|
|
93
|
-
"@equinor/fusion-framework-module-bookmark": "^1.2.13",
|
|
94
94
|
"@equinor/fusion-framework-module-navigation": "^4.0.7",
|
|
95
95
|
"@equinor/fusion-framework-module-services": "^4.1.5",
|
|
96
|
+
"@equinor/fusion-framework-react": "^7.3.1",
|
|
96
97
|
"@equinor/fusion-framework-react-components-bookmark": "^0.5.3",
|
|
97
98
|
"@equinor/fusion-framework-react-components-people-provider": "^1.4.10",
|
|
98
|
-
"@equinor/fusion-observable": "^8.4.2",
|
|
99
99
|
"@equinor/fusion-framework-react-module-bookmark": "^2.1.19",
|
|
100
|
-
"@equinor/fusion-
|
|
100
|
+
"@equinor/fusion-observable": "^8.4.2",
|
|
101
101
|
"@equinor/fusion-query": "^5.1.4"
|
|
102
102
|
},
|
|
103
103
|
"scripts": {
|