@equinor/fusion-framework-cli
Version:
--- title: Fusion Framework CLI ---
42 lines • 2.2 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { loadConfig, initiateConfig, resolveConfig, } from './utils/config.js';
import { AssertionError } from './utils/assert.js';
import { ApiAppConfigSchema } from '../schemas.js';
export const appConfigFilename = 'app.config';
export const defineAppConfig = (fn) => fn;
export const loadAppConfig = (filename) => loadConfig(filename !== null && filename !== void 0 ? filename : appConfigFilename);
export const resolveAppConfig = (options) => __awaiter(void 0, void 0, void 0, function* () {
if (options === null || options === void 0 ? void 0 : options.file) {
const config = yield loadAppConfig(options.file);
return {
config,
path: options.file,
};
}
return resolveConfig(appConfigFilename, { find: options });
});
export const createAppConfig = (env, base, options) => __awaiter(void 0, void 0, void 0, function* () {
var _a;
const resolved = yield resolveAppConfig(options);
if (resolved) {
const configValue = (_a = (yield initiateConfig(resolved.config, env, { base }))) !== null && _a !== void 0 ? _a : {};
const config = ApiAppConfigSchema.parse(configValue);
return { config, path: resolved.path };
}
else if (options === null || options === void 0 ? void 0 : options.file) {
throw new AssertionError({
message: `Expected to load config from ${options.file}`,
expected: '<file>',
});
}
return { config: base };
});
//# sourceMappingURL=app-config.js.map