@equinor/fusion-framework-cli 11.0.0-next.5 → 11.0.0-next.7

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.
Files changed (89) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/bin/build/bin.js +7 -7
  3. package/bin/build/cli.js +426 -188
  4. package/bin/build/{portal-pack-qpEBTWNW.js → portal-config-publish-OZ7Ocme4.js} +219 -22
  5. package/dist/esm/bin/helpers/resolve-portal-config.js +46 -0
  6. package/dist/esm/bin/helpers/resolve-portal-config.js.map +1 -0
  7. package/dist/esm/bin/index.js +2 -0
  8. package/dist/esm/bin/index.js.map +1 -1
  9. package/dist/esm/bin/portal-config-publish.js +74 -0
  10. package/dist/esm/bin/portal-config-publish.js.map +1 -0
  11. package/dist/esm/bin/portal-config.js +48 -0
  12. package/dist/esm/bin/portal-config.js.map +1 -0
  13. package/dist/esm/bin/portal-dev.js +3 -4
  14. package/dist/esm/bin/portal-dev.js.map +1 -1
  15. package/dist/esm/cli/commands/app/alias.js +4 -4
  16. package/dist/esm/cli/commands/app/alias.js.map +1 -1
  17. package/dist/esm/cli/commands/app/build.js +10 -3
  18. package/dist/esm/cli/commands/app/build.js.map +1 -1
  19. package/dist/esm/cli/commands/app/check.js +15 -5
  20. package/dist/esm/cli/commands/app/check.js.map +1 -1
  21. package/dist/esm/cli/commands/app/config.js +20 -8
  22. package/dist/esm/cli/commands/app/config.js.map +1 -1
  23. package/dist/esm/cli/commands/app/dev.js +10 -4
  24. package/dist/esm/cli/commands/app/dev.js.map +1 -1
  25. package/dist/esm/cli/commands/app/index.js +18 -1
  26. package/dist/esm/cli/commands/app/index.js.map +1 -1
  27. package/dist/esm/cli/commands/app/manifest.js +12 -3
  28. package/dist/esm/cli/commands/app/manifest.js.map +1 -1
  29. package/dist/esm/cli/commands/app/pack.js +16 -9
  30. package/dist/esm/cli/commands/app/pack.js.map +1 -1
  31. package/dist/esm/cli/commands/app/publish.js +15 -4
  32. package/dist/esm/cli/commands/app/publish.js.map +1 -1
  33. package/dist/esm/cli/commands/app/tag.js +16 -4
  34. package/dist/esm/cli/commands/app/tag.js.map +1 -1
  35. package/dist/esm/cli/commands/app/upload.js +13 -8
  36. package/dist/esm/cli/commands/app/upload.js.map +1 -1
  37. package/dist/esm/cli/commands/auth/index.js +13 -1
  38. package/dist/esm/cli/commands/auth/index.js.map +1 -1
  39. package/dist/esm/cli/commands/auth/login.js +11 -7
  40. package/dist/esm/cli/commands/auth/login.js.map +1 -1
  41. package/dist/esm/cli/commands/auth/logout.js +10 -7
  42. package/dist/esm/cli/commands/auth/logout.js.map +1 -1
  43. package/dist/esm/cli/commands/auth/token.js +13 -9
  44. package/dist/esm/cli/commands/auth/token.js.map +1 -1
  45. package/dist/esm/cli/commands/disco/resolve.js +13 -16
  46. package/dist/esm/cli/commands/disco/resolve.js.map +1 -1
  47. package/dist/esm/cli/commands/portal/build.js +12 -7
  48. package/dist/esm/cli/commands/portal/build.js.map +1 -1
  49. package/dist/esm/cli/commands/portal/config.js +101 -0
  50. package/dist/esm/cli/commands/portal/config.js.map +1 -0
  51. package/dist/esm/cli/commands/portal/dev.js +9 -6
  52. package/dist/esm/cli/commands/portal/dev.js.map +1 -1
  53. package/dist/esm/cli/commands/portal/index.js +3 -1
  54. package/dist/esm/cli/commands/portal/index.js.map +1 -1
  55. package/dist/esm/cli/commands/portal/manifest.js +11 -8
  56. package/dist/esm/cli/commands/portal/manifest.js.map +1 -1
  57. package/dist/esm/cli/commands/portal/pack.js +13 -8
  58. package/dist/esm/cli/commands/portal/pack.js.map +1 -1
  59. package/dist/esm/cli/commands/portal/publish.js +11 -8
  60. package/dist/esm/cli/commands/portal/publish.js.map +1 -1
  61. package/dist/esm/cli/commands/portal/schema.js +10 -8
  62. package/dist/esm/cli/commands/portal/schema.js.map +1 -1
  63. package/dist/esm/cli/commands/portal/tag.js +12 -8
  64. package/dist/esm/cli/commands/portal/tag.js.map +1 -1
  65. package/dist/esm/cli/commands/portal/upload.js +8 -7
  66. package/dist/esm/cli/commands/portal/upload.js.map +1 -1
  67. package/dist/esm/lib/portal/index.js +2 -0
  68. package/dist/esm/lib/portal/index.js.map +1 -1
  69. package/dist/esm/lib/portal/load-portal-config.js +49 -0
  70. package/dist/esm/lib/portal/load-portal-config.js.map +1 -0
  71. package/dist/esm/lib/portal/portal-config.js +23 -0
  72. package/dist/esm/lib/portal/portal-config.js.map +1 -0
  73. package/dist/esm/version.js +1 -1
  74. package/dist/tsconfig.tsbuildinfo +1 -1
  75. package/dist/types/bin/helpers/resolve-portal-config.d.ts +18 -0
  76. package/dist/types/bin/index.d.ts +2 -0
  77. package/dist/types/bin/portal-config-publish.d.ts +26 -0
  78. package/dist/types/bin/portal-config.d.ts +46 -0
  79. package/dist/types/cli/commands/app/config.d.ts +3 -3
  80. package/dist/types/cli/commands/app/pack.d.ts +1 -1
  81. package/dist/types/cli/commands/auth/logout.d.ts +0 -4
  82. package/dist/types/cli/commands/auth/token.d.ts +0 -5
  83. package/dist/types/cli/commands/disco/resolve.d.ts +0 -7
  84. package/dist/types/cli/commands/portal/config.d.ts +32 -0
  85. package/dist/types/lib/portal/index.d.ts +2 -0
  86. package/dist/types/lib/portal/load-portal-config.d.ts +83 -0
  87. package/dist/types/lib/portal/portal-config.d.ts +69 -0
  88. package/dist/types/version.d.ts +1 -1
  89. package/package.json +8 -7
@@ -0,0 +1,18 @@
1
+ import type { RuntimeEnv } from '../../lib';
2
+ import type { ConsoleLogger } from '../utils';
3
+ import { type PortalConfig } from '../../lib/portal';
4
+ /**
5
+ * Resolves the portal configuration based on the provided runtime environment and options.
6
+ * Handles logging, error reporting, and fallback to built-in config if no local config is found.
7
+ *
8
+ * @param env - The runtime environment containing the command and mode information.
9
+ * @param options - Optional parameters:
10
+ * - config: Path to a specific configuration file.
11
+ * - log: Logger utility for progress and status messages.
12
+ * @returns A promise resolving to the loaded portal configuration.
13
+ * @throws If the portal configuration cannot be resolved.
14
+ */
15
+ export declare const resolvePortalConfig: <T extends PortalConfig = PortalConfig>(env: RuntimeEnv, options: {
16
+ config?: string;
17
+ log?: ConsoleLogger | null;
18
+ }) => Promise<T>;
@@ -6,4 +6,6 @@ export { startAppDevServer } from './app-dev.js';
6
6
  export { buildPortal } from './portal-build.js';
7
7
  export { bundlePortal } from './portal-pack.js';
8
8
  export { loadPortalManifest } from './portal-manifest.js';
9
+ export { generatePortalConfig } from './portal-config.js';
10
+ export { publishPortalConfig } from './portal-config-publish.js';
9
11
  export { pack } from './pack.js';
@@ -0,0 +1,26 @@
1
+ import { type FusionEnv, type FusionFrameworkSettings } from '../lib/framework.node.js';
2
+ import { type ConsoleLogger } from './utils';
3
+ type PortalConfigPublishOptions = {
4
+ config?: string;
5
+ portal: {
6
+ name: string;
7
+ version: string;
8
+ };
9
+ environment: Exclude<FusionEnv, FusionEnv.Development>;
10
+ auth: FusionFrameworkSettings['auth'];
11
+ debug?: boolean;
12
+ log?: ConsoleLogger | null;
13
+ };
14
+ /**
15
+ * Publishes the portal configuration to the portal store for a specific build version.
16
+ *
17
+ * This function generates the portal config, loads the manifest, initializes the Fusion Framework,
18
+ * and sends the config to the portal service. Handles and logs errors for common failure scenarios.
19
+ *
20
+ * @param options - Options for config, manifest, environment, authentication, and logging.
21
+ * @returns A promise that resolves when publishing is complete.
22
+ * @throws If the build version is missing or publishing fails.
23
+ * @public
24
+ */
25
+ export declare const publishPortalConfig: (options: PortalConfigPublishOptions) => Promise<void>;
26
+ export default publishPortalConfig;
@@ -0,0 +1,46 @@
1
+ import type { RuntimeEnv } from '../lib';
2
+ import { type ConsoleLogger } from './utils';
3
+ /**
4
+ * Options for generating the portal configuration.
5
+ *
6
+ * This interface defines the shape of the options object accepted by
7
+ * {@link generatePortalConfig}. It allows for optional logging, environment overrides,
8
+ * config file path, and output file path.
9
+ *
10
+ * @public
11
+ */
12
+ interface GeneratePortalConfigOptions {
13
+ /**
14
+ * Logger instance for outputting progress and debug information (optional).
15
+ */
16
+ log?: ConsoleLogger | null;
17
+ /**
18
+ * Partial runtime environment overrides (optional).
19
+ */
20
+ env?: Partial<RuntimeEnv>;
21
+ /**
22
+ * Path to the config file to resolve (optional).
23
+ */
24
+ config?: string;
25
+ /**
26
+ * Output file path for writing the generated config (optional).
27
+ */
28
+ output?: string;
29
+ }
30
+ /**
31
+ * Generates the portal configuration object for the current project.
32
+ *
33
+ * This function resolves the portal package, sets up the runtime environment, resolves the portal config,
34
+ * and optionally writes the config to a file if an output path is provided. Logging is supported for
35
+ * debugging and progress tracking.
36
+ *
37
+ * @param options - Optional settings for logger, environment overrides, config path, and output file.
38
+ * @returns An object containing the generated config and the resolved package info.
39
+ * @throws If writing the config to file fails.
40
+ * @public
41
+ */
42
+ export declare const generatePortalConfig: (options?: GeneratePortalConfigOptions) => Promise<{
43
+ config: import("../lib/portal").PortalConfig;
44
+ pkg: import("../lib").ResolvedPackage;
45
+ }>;
46
+ export {};
@@ -24,9 +24,9 @@
24
24
  * -o, --output <stdout|path> Output to stdout or a file (default: stdout)
25
25
  *
26
26
  * Example:
27
- * $ fusion config app.config.ts
28
- * $ fusion config app.config.prod.ts --output ./dist/app.config.json
29
- * $ fusion config --publish --manifest app.manifest.ts --env prod
27
+ * $ fusion-framework-cli config app.config.ts
28
+ * $ fusion-framework-cli config app.config.prod.ts --output ./dist/app.config.json
29
+ * $ fusion-framework-cli config --publish --manifest app.manifest.ts --env prod
30
30
  *
31
31
  * @see generateApplicationConfig, publishAppConfig for implementation details
32
32
  */
@@ -1,4 +1,4 @@
1
- export declare const defaultArchive = "app-bundle.zip";
1
+ export declare const DEFAULT_ARCHIVE: "app-bundle.zip";
2
2
  /**
3
3
  * CLI command: `pack`
4
4
  *
@@ -3,10 +3,6 @@
3
3
  *
4
4
  * This command removes your current authentication state from the Fusion Framework CLI.
5
5
  * Supports custom tenant and client options for advanced scenarios.
6
- *
7
- * @example
8
- * $ fusion logout
9
- * $ fusion logout --tenant my-tenant --client my-client-id
10
6
  */
11
7
  export declare const command: import("commander").Command;
12
8
  export default command;
@@ -3,11 +3,6 @@
3
3
  *
4
4
  * This command retrieves an access token for the specified scopes, tenant, and client.
5
5
  * Supports debug and silent modes for flexible output.
6
- *
7
- * @example
8
- * $ fusion token
9
- * $ fusion token --scope api://my-app/.default
10
- * $ fusion token --tenant my-tenant --client my-client-id --silent
11
6
  */
12
7
  export declare const command: import("commander").Command;
13
8
  export default command;
@@ -5,13 +5,6 @@
5
5
  *
6
6
  * Supports environment selection and authentication options.
7
7
  *
8
- * ## Examples
9
- *
10
- * ```sh
11
- * $ fusion resolve my-service
12
- * $ fusion resolve my-service --env prod
13
- * ```
14
- *
15
8
  * @command resolve
16
9
  * @description Resolve and display information about a service registered in Fusion service discovery.
17
10
  * @argument {string} service - Name of the service to resolve in Fusion service discovery.
@@ -0,0 +1,32 @@
1
+ /**
2
+ * CLI command: `portal config`
3
+ *
4
+ * Generates and/or publishes the portal configuration for Fusion portals.
5
+ *
6
+ * Features:
7
+ * - Outputs the generated config to stdout or a file.
8
+ * - Use --publish to upload the config to the Fusion portal registry.
9
+ * - Options [token, tenant, client, config, identifier, env, output] are only relevant when --publish is used.
10
+ * - Option [--env] cannot be set to dev when --publish is used.
11
+ *
12
+ * Usage:
13
+ * $ fusion-framework-cli portal config --identifier <portal@version> [options]
14
+ *
15
+ * Options:
16
+ * --debug Enable debug mode for verbose logging
17
+ * --silent Silent mode, suppresses output except errors
18
+ * --publish Publish config to Fusion portal registry
19
+ * --identifier <name@version> Identifier of the portal, example my-portal@1.2.3 (required with --publish)
20
+ * -o, --output <stdout|path> Output to stdout or a file (default: stdout)
21
+ * <config> Path to the portal config file (e.g., portal.config[.env]?.[ts,js,json])
22
+ * --env <env> Target environment
23
+ *
24
+ * Examples:
25
+ * $ fusion-framework-cli portal config --identifier my-portal@1.2.3 -o stdout portal.config.ts
26
+ * $ fusion-framework-cli portal config --identifier my-portal@1.2.3 -o ./dist/portal.config.json portal.config.prod.ts
27
+ * $ fusion-framework-cli portal config --publish --env prod --identifier my-portal@1.2.3 portal.config.ts
28
+ *
29
+ * @see generatePortalConfig, publishPortalConfig for implementation details
30
+ */
31
+ export declare const command: import("commander").Command;
32
+ export default command;
@@ -1,2 +1,4 @@
1
1
  export { createPortalManifestFromPackage, definePortalManifest, loadPortalManifest, validatePortalManifest, type PortalManifest, type PortalManifestExport, type PortalManifestFn, } from './portal-manifest.js';
2
2
  export { loadPortalSchema, definePortalSchema, type PortalSchema, type PortalSchemaExport, type PortalSchemaFn, } from './load-portal-schema.js';
3
+ export { definePortalConfig, type PortalConfig, type PortalConfigFn, } from './portal-config.js';
4
+ export { loadPortalConfig, type PortalConfigExport, } from './load-portal-config.js';
@@ -0,0 +1,83 @@
1
+ import z from 'zod';
2
+ import { type ImportConfigResult } from '@equinor/fusion-imports';
3
+ import type { RuntimeEnv } from '../types.js';
4
+ import type { PortalConfig, PortalConfigFn } from './portal-config.js';
5
+ /**
6
+ * Represents the configuration export for a portal.
7
+ *
8
+ * This can either be a static configuration object (`PortalConfig`) or a function (`PortalConfigFn`)
9
+ * that returns or modifies the portal configuration dynamically.
10
+ *
11
+ * Used for both static and dynamic portal config patterns.
12
+ *
13
+ * @remarks
14
+ * - Enables flexible config authoring for different deployment scenarios.
15
+ * - Supports both object and function-based portal configuration.
16
+ *
17
+ * @example <caption>Static export</caption>
18
+ * ```ts
19
+ * export default {
20
+ * environment: { name: 'production' },
21
+ * features: { enableBeta: true },
22
+ * };
23
+ * ```
24
+ *
25
+ * @example <caption>Dynamic export</caption>
26
+ * ```ts
27
+ * export default (env, { base }) => ({
28
+ * ...base,
29
+ * environment: { name: env.environment },
30
+ * features: { enableBeta: env.environment === 'dev' },
31
+ * });
32
+ * ```
33
+ */
34
+ export type PortalConfigExport = PortalConfig | PortalConfigFn;
35
+ /**
36
+ * Options for loading a portal config file.
37
+ *
38
+ * @property base - A base configuration object to merge with the imported configuration.
39
+ * @property file - The name of the configuration file to import. Defaults to 'portal.config'.
40
+ * @property extensions - An array of file extensions to consider when resolving the configuration file.
41
+ * @property schema - An optional Zod schema for validating the loaded portal configuration.
42
+ *
43
+ * @remarks
44
+ * - Allows for custom config file resolution and merging strategies.
45
+ * - Useful for multi-environment setups and advanced config loading.
46
+ * - Schema validation ensures type safety for portal configuration.
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * const config = await loadPortalConfig(env, {
51
+ * file: 'custom-portal.config.ts',
52
+ * schema: z.object({ environment: z.object({ name: z.string() }) })
53
+ * });
54
+ * ```
55
+ */
56
+ export type LoadPortalConfigOptions = {
57
+ base?: PortalConfig;
58
+ file?: string;
59
+ extensions?: string[];
60
+ schema?: z.ZodSchema<PortalConfig>;
61
+ };
62
+ /**
63
+ * Loads and resolves the portal configuration from a file or function export.
64
+ *
65
+ * This function uses a script resolver to handle dynamic imports. If the imported module's default export
66
+ * is a function, it will be invoked with the base configuration and runtime environment. The result
67
+ * is validated against the provided schema (or a permissive passthrough schema by default).
68
+ *
69
+ * @param env - The runtime environment containing the root directory and other environment-specific settings.
70
+ * @param options - Optional parameters for configuring the import process.
71
+ * @returns A promise that resolves to the imported and validated portal configuration.
72
+ *
73
+ * @remarks
74
+ * - Supports both static and dynamic config authoring patterns for portals.
75
+ * - Ensures all configs are validated against the schema for type safety.
76
+ * - Designed for maintainability and RAG-based documentation extraction.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * const config = await loadPortalConfig(env, { file: 'custom-portal.config.ts' });
81
+ * ```
82
+ */
83
+ export declare const loadPortalConfig: <T extends PortalConfig = PortalConfig>(env: RuntimeEnv, options?: LoadPortalConfigOptions) => Promise<ImportConfigResult<T>>;
@@ -0,0 +1,69 @@
1
+ import type { RuntimeEnv } from '../types';
2
+ /**
3
+ * Represents the configuration object for a portal.
4
+ *
5
+ * @remarks
6
+ * This is a placeholder type for the portal configuration. In a real implementation,
7
+ * this should be replaced with a more specific type or interface that describes
8
+ * the shape of your portal's configuration.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const config: PortalConfig = {
13
+ * environment: { name: 'production' },
14
+ * features: { enableBeta: true },
15
+ * };
16
+ * ```
17
+ */
18
+ export type PortalConfig = Record<any, any>;
19
+ /**
20
+ * A function type for defining dynamic or static portal configuration.
21
+ *
22
+ * @param env - The runtime environment object, providing context such as root directory, environment variables, etc.
23
+ * @param args - An object containing the base portal configuration (useful for merging or extending configs).
24
+ * @returns The portal configuration object, a promise resolving to it, or void if no configuration is provided.
25
+ *
26
+ * @remarks
27
+ * This function enables both static and dynamic configuration patterns. It can be used to
28
+ * return a configuration object directly, or to compute it asynchronously (e.g., by reading files or fetching data).
29
+ *
30
+ * @example <caption>Static configuration</caption>
31
+ * ```ts
32
+ * export const config: PortalConfigFn = (env, { base }) => ({
33
+ * ...base,
34
+ * environment: { name: env.environment },
35
+ * features: { enableBeta: false },
36
+ * });
37
+ * ```
38
+ *
39
+ * @example <caption>Async configuration</caption>
40
+ * ```ts
41
+ * export const config: PortalConfigFn = async (env, { base }) => {
42
+ * const remoteSettings = await fetchRemoteSettings(env);
43
+ * return { ...base, ...remoteSettings };
44
+ * };
45
+ * ```
46
+ */
47
+ export type PortalConfigFn = (config: PortalConfig, env: RuntimeEnv) => PortalConfig | Promise<PortalConfig | void> | void;
48
+ /**
49
+ * Utility to define a portal configuration function for the framework.
50
+ *
51
+ * @param fn - A function that returns the portal configuration object (either synchronously or asynchronously).
52
+ * @returns The provided configuration function, unchanged.
53
+ *
54
+ * @remarks
55
+ * This utility is used to provide type safety and tooling support for portal configuration authoring.
56
+ * It is a no-op at runtime, but helps with code completion and documentation for consumers.
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * import { definePortalConfig } from 'fusion-framework';
61
+ *
62
+ * export default definePortalConfig((env, { base }) => ({
63
+ * ...base,
64
+ * environment: { name: env.environment },
65
+ * features: { enableBeta: true },
66
+ * }));
67
+ * ```
68
+ */
69
+ export declare const definePortalConfig: (fn: PortalConfigFn) => PortalConfigFn;
@@ -1 +1 @@
1
- export declare const version = "11.0.0-next.5";
1
+ export declare const version = "11.0.0-next.7";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-cli",
3
- "version": "11.0.0-next.5",
3
+ "version": "11.0.0-next.7",
4
4
  "homepage": "https://github.com/equinor/fusion-framework",
5
5
  "keywords": [
6
6
  "Fusion",
@@ -21,7 +21,8 @@
21
21
  ],
22
22
  "type": "module",
23
23
  "bin": {
24
- "fusion-framework-cli": "./bin/cli.mjs"
24
+ "fusion-framework-cli": "./bin/cli.mjs",
25
+ "ffc": "./bin/cli.mjs"
25
26
  },
26
27
  "main": "./bin/main.js",
27
28
  "types": "./dist/types/lib.d.ts",
@@ -73,7 +74,7 @@
73
74
  "vite": "^6.3.5",
74
75
  "zod": "^3.25.20",
75
76
  "@equinor/fusion-framework-dev-portal": "^1.0.0-next.2",
76
- "@equinor/fusion-framework-dev-server": "^1.0.0-next.3",
77
+ "@equinor/fusion-framework-dev-server": "^1.0.0-next.4",
77
78
  "@equinor/fusion-imports": "^1.1.1-next.0"
78
79
  },
79
80
  "devDependencies": {
@@ -82,11 +83,11 @@
82
83
  "@types/node": "^20.11.14",
83
84
  "rxjs": "^7.8.1",
84
85
  "typescript": "^5.8.2",
85
- "@equinor/fusion-framework-module": "^4.4.3-next.0",
86
- "@equinor/fusion-framework-module-http": "^6.3.3-next.1",
87
86
  "@equinor/fusion-framework-module-app": "^6.1.13",
88
- "@equinor/fusion-framework-module-service-discovery": "^8.0.15-next.1",
89
- "@equinor/fusion-framework-module-msal-node": "^0.1.1-next.1"
87
+ "@equinor/fusion-framework-module": "^4.4.3-next.1",
88
+ "@equinor/fusion-framework-module-http": "^6.3.3-next.2",
89
+ "@equinor/fusion-framework-module-msal-node": "^0.1.1-next.2",
90
+ "@equinor/fusion-framework-module-service-discovery": "^8.0.15-next.2"
90
91
  },
91
92
  "peerDependenciesMeta": {
92
93
  "typescript": {