@ms-cloudpack/config
Advanced tools
Comparing version
@@ -19,16 +19,2 @@ import type { PackageSettings } from '@ms-cloudpack/common-types'; | ||
}; | ||
/** | ||
* Checks if the package is a match for the given package settings. | ||
* @returns True if the package is a match for the given package settings. | ||
*/ | ||
export declare function checkMatch(params: { | ||
/** The name of the package. */ | ||
name: string; | ||
/** The version of the package. */ | ||
version: string; | ||
/** The match to check against. */ | ||
match: PackageSettings['match']; | ||
/** If true, require an exact match for the name (don't process wildcards). */ | ||
exactMatch?: boolean; | ||
}): boolean; | ||
//# sourceMappingURL=getPackageSettings.d.ts.map |
@@ -1,3 +0,3 @@ | ||
import { satisfies } from 'semver'; | ||
import { mergePackageSettings } from './mergePackageSettings.js'; | ||
import { checkMatch } from './checkMatch.js'; | ||
/** | ||
@@ -27,26 +27,2 @@ * Gets the single set of package settings for a given package using the given config. | ||
} | ||
/** | ||
* Checks if the package is a match for the given package settings. | ||
* @returns True if the package is a match for the given package settings. | ||
*/ | ||
export function checkMatch(params) { | ||
const { name, version, match, exactMatch } = params; | ||
let matchName, matchVersion; | ||
if (!match) { | ||
return true; | ||
} | ||
else if (typeof match === 'string') { | ||
matchName = match; | ||
} | ||
else { | ||
matchName = match?.name; | ||
matchVersion = match?.version === '*' ? undefined : match?.version; | ||
} | ||
// For exact or non-wildcard matches, check the full name and possibly the version. | ||
if (exactMatch || !matchName.endsWith('*')) { | ||
return matchName === name && (!matchVersion || satisfies(version, matchVersion)); | ||
} | ||
// Remove the trailing wildcard and check for a prefix match and possibly the version. | ||
return name.startsWith(matchName.slice(0, -1)) && (!matchVersion || satisfies(version, matchVersion)); | ||
} | ||
//# sourceMappingURL=getPackageSettings.js.map |
@@ -0,1 +1,2 @@ | ||
export { checkMatch } from './checkMatch.js'; | ||
export { configTemplate } from './configTemplate.js'; | ||
@@ -5,3 +6,3 @@ export { generatedConfigFileName, appConfigFileName } from './constants.js'; | ||
export { getConfigPath } from './getConfigPath.js'; | ||
export { getPackageSettings, checkMatch } from './getPackageSettings.js'; | ||
export { getPackageSettings } from './getPackageSettings.js'; | ||
export { readConfig } from './readConfig.js'; | ||
@@ -8,0 +9,0 @@ export { readGeneratedConfig } from './readGeneratedConfig.js'; |
@@ -0,1 +1,2 @@ | ||
export { checkMatch } from './checkMatch.js'; | ||
export { configTemplate } from './configTemplate.js'; | ||
@@ -5,3 +6,3 @@ export { generatedConfigFileName, appConfigFileName } from './constants.js'; | ||
export { getConfigPath } from './getConfigPath.js'; | ||
export { getPackageSettings, checkMatch } from './getPackageSettings.js'; | ||
export { getPackageSettings } from './getPackageSettings.js'; | ||
export { readConfig } from './readConfig.js'; | ||
@@ -8,0 +9,0 @@ export { readGeneratedConfig } from './readGeneratedConfig.js'; |
import type { AppConfig } from '@ms-cloudpack/common-types'; | ||
/** | ||
* Reads the user config file and merges with any parent configs asynchronously. Note this is only useful for making modifications to the user config. | ||
* 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. | ||
* | ||
* Throws an error if the config file exists but is not valid JSON (or there's some error reading it). | ||
*/ | ||
export declare function readAppConfig(appPath: string): Promise<AppConfig>; | ||
//# sourceMappingURL=readAppConfig.d.ts.map |
@@ -6,4 +6,7 @@ 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. | ||
* 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. | ||
* | ||
* Throws an error if the config file exists but is not valid JSON (or there's some error reading it). | ||
*/ | ||
@@ -16,5 +19,6 @@ export async function readAppConfig(appPath) { | ||
* Reads the user config, with any `extends` parent configs merged in. | ||
* Throws an error if the config file exists but is not valid JSON, or there's some error reading it. | ||
*/ | ||
async function readAppConfigInternal(configPath) { | ||
const AppConfig = await readJson(configPath, { verbose: true, mode: 'permissive' }); | ||
const AppConfig = await readJson(configPath, { mode: 'permissive', throwOnError: true }); | ||
if (!AppConfig) { | ||
@@ -21,0 +25,0 @@ return undefined; |
@@ -5,4 +5,6 @@ import type { GeneratedConfig } from '@ms-cloudpack/common-types'; | ||
* the generated overrides. For a full merged representation of config, use `readConfig` instead. | ||
* | ||
* Throws an error if the config file exists but is not valid JSON (or there's some error reading it). | ||
*/ | ||
export declare function readGeneratedConfig(appPath: string): Promise<GeneratedConfig>; | ||
//# sourceMappingURL=readGeneratedConfig.d.ts.map |
@@ -6,6 +6,8 @@ import { readJson } from '@ms-cloudpack/json-utilities'; | ||
* the generated overrides. For a full merged representation of config, use `readConfig` instead. | ||
* | ||
* Throws an error if the config file exists but is not valid JSON (or there's some error reading it). | ||
*/ | ||
export async function readGeneratedConfig(appPath) { | ||
const { generatedConfigPath } = getConfigPath(appPath); | ||
return processDeprecatedValues((await readJson(generatedConfigPath, { verbose: true, mode: 'permissive' })) || {}); | ||
return processDeprecatedValues((await readJson(generatedConfigPath, { throwOnError: true, mode: 'permissive' })) || {}); | ||
} | ||
@@ -12,0 +14,0 @@ /** |
{ | ||
"name": "@ms-cloudpack/config", | ||
"version": "0.23.7", | ||
"version": "0.24.0", | ||
"description": "Configuration handling for cloudpack.", | ||
@@ -17,5 +17,5 @@ "license": "MIT", | ||
"dependencies": { | ||
"@ms-cloudpack/common-types": "^0.13.2", | ||
"@ms-cloudpack/json-utilities": "^0.1.5", | ||
"@ms-cloudpack/package-utilities": "^8.0.0", | ||
"@ms-cloudpack/common-types": "^0.13.3", | ||
"@ms-cloudpack/json-utilities": "^0.1.6", | ||
"@ms-cloudpack/package-utilities": "^8.0.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
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
92198
1.95%95
4.4%763
2.01%