@ms-cloudpack/config
Advanced tools
Comparing version 0.22.1 to 0.23.0
@@ -7,2 +7,6 @@ import type { AppConfig } from '@ms-cloudpack/common-types'; | ||
export declare function readAppConfig(appPath: string): Promise<AppConfig>; | ||
/** | ||
* An internal function for processing a config object after reading the json values. | ||
*/ | ||
export declare function processDeprecatedValues(config: AppConfig): AppConfig; | ||
//# sourceMappingURL=readAppConfig.d.ts.map |
@@ -6,2 +6,10 @@ import { readJson } from '@ms-cloudpack/json-utilities'; | ||
/** | ||
* Reads the user config file and merges with any parent configs asynchronously. Note this is only useful for making modifications to the user config. | ||
* For a full merged representation of config, use `readConfig` instead. | ||
*/ | ||
export async function readAppConfig(appPath) { | ||
const { appConfigPath } = getConfigPath(appPath); | ||
return (await readAppConfigInternal(appConfigPath)) || {}; | ||
} | ||
/** | ||
* Reads the user config, with any `extends` parent configs merged in. | ||
@@ -30,12 +38,20 @@ */ | ||
} | ||
return mergeParentConfig({ AppConfig, parentConfigs }); | ||
return processDeprecatedValues(mergeParentConfig({ AppConfig, parentConfigs })); | ||
} | ||
/** | ||
* Reads the user config file and merges with any parent configs asynchronously. Note this is only useful for making modifications to the user config. | ||
* For a full merged representation of config, use `readConfig` instead. | ||
* An internal function for processing a config object after reading the json values. | ||
*/ | ||
export async function readAppConfig(appPath) { | ||
const { appConfigPath } = getConfigPath(appPath); | ||
return (await readAppConfigInternal(appConfigPath)) || {}; | ||
export function processDeprecatedValues(config) { | ||
const { devServer } = config; | ||
if (devServer) { | ||
// eslint-disable-next-line etc/no-deprecated | ||
const { routes } = devServer; | ||
if (routes) { | ||
config.routes = routes; | ||
// eslint-disable-next-line etc/no-deprecated | ||
delete config.devServer?.routes; | ||
} | ||
} | ||
return config; | ||
} | ||
//# sourceMappingURL=readAppConfig.js.map |
@@ -1,2 +0,1 @@ | ||
import { processConfig } from './processConfig.js'; | ||
import { readAppConfig } from './readAppConfig.js'; | ||
@@ -8,12 +7,29 @@ import { readGeneratedConfig } from './readGeneratedConfig.js'; | ||
export async function readConfig(appPath, mode = 'library') { | ||
const [AppConfig, generatedConfig] = await Promise.all([readAppConfig(appPath), readGeneratedConfig(appPath)]); | ||
const [appConfig, generatedConfig] = await Promise.all([readAppConfig(appPath), readGeneratedConfig(appPath)]); | ||
const config = { | ||
...appConfig, | ||
appPath, | ||
mode, | ||
generated: generatedConfig, | ||
...AppConfig, | ||
}; | ||
processConfig(config.generated); | ||
// Expands all routes which refer to source files into fully transformed route objects. | ||
expandRouteShorthandEntries(config); | ||
return config; | ||
} | ||
/** | ||
* | ||
* @param config | ||
*/ | ||
function expandRouteShorthandEntries(config) { | ||
const { routes } = config; | ||
if (routes) { | ||
for (let i = 0; i < routes.length; i++) { | ||
const route = routes[i]; | ||
if (typeof route === 'string') { | ||
routes[i] = { match: route, entry: route }; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
//# sourceMappingURL=readConfig.js.map |
@@ -9,4 +9,26 @@ import { readJson } from '@ms-cloudpack/json-utilities'; | ||
const { generatedConfigPath } = getConfigPath(appPath); | ||
return (await readJson(generatedConfigPath, { verbose: true, mode: 'permissive' })) || {}; | ||
return processDeprecatedValues((await readJson(generatedConfigPath, { verbose: true, mode: 'permissive' })) || {}); | ||
} | ||
/** | ||
* Delete deprecated values and convert them to the new format. Note that this function | ||
* mutates the passed-in config object to avoid reallocation. | ||
*/ | ||
function processDeprecatedValues(config) { | ||
// eslint-disable-next-line etc/no-deprecated | ||
const { packageOverrides } = config; | ||
// Convert package overrides into settings to preserve the deprecated support. | ||
if (packageOverrides) { | ||
config.packageSettings = config.packageSettings || []; | ||
for (const override of packageOverrides) { | ||
const settings = { | ||
match: { name: override.name, version: override.versionRequirement }, | ||
exports: override.overrides.exports, | ||
}; | ||
config.packageSettings.push(settings); | ||
} | ||
// eslint-disable-next-line etc/no-deprecated | ||
delete config.packageOverrides; | ||
} | ||
return config; | ||
} | ||
//# sourceMappingURL=readGeneratedConfig.js.map |
{ | ||
"name": "@ms-cloudpack/config", | ||
"version": "0.22.1", | ||
"version": "0.23.0", | ||
"description": "Configuration handling for cloudpack.", | ||
@@ -17,5 +17,5 @@ "license": "MIT", | ||
"dependencies": { | ||
"@ms-cloudpack/common-types": "^0.9.0", | ||
"@ms-cloudpack/common-types": "^0.10.0", | ||
"@ms-cloudpack/json-utilities": "^0.1.4", | ||
"@ms-cloudpack/package-utilities": "^7.8.0", | ||
"@ms-cloudpack/package-utilities": "^7.8.1", | ||
"import-meta-resolve": "^4.0.0", | ||
@@ -22,0 +22,0 @@ "semver": "^7.6.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
89531
741
91
+ Added@ms-cloudpack/common-types@0.10.0(transitive)
- Removed@ms-cloudpack/common-types@0.9.0(transitive)