@ms-cloudpack/config 0.17.21 → 0.17.23
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/lib/mergeParentConfig.d.ts +6 -0
- package/lib/mergeParentConfig.d.ts.map +1 -0
- package/lib/mergeParentConfig.js +15 -0
- package/lib/mergeParentConfig.js.map +1 -0
- package/lib/readUserConfig.d.ts.map +1 -1
- package/lib/readUserConfig.js +2 -11
- package/lib/readUserConfig.js.map +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeParentConfig.d.ts","sourceRoot":"","sources":["../src/mergeParentConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAG7D,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IAAE,UAAU,EAAE,UAAU,CAAC;IAAC,YAAY,EAAE,UAAU,CAAA;CAAE,GAAG,UAAU,CAgB1G"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { recursive as recursiveMerge } from 'merge';
|
|
2
|
+
export function mergeParentConfig(params) {
|
|
3
|
+
const { userConfig, parentConfig } = params;
|
|
4
|
+
// NOTE: This must merge into an empty object to avoid modifying the originals
|
|
5
|
+
const result = recursiveMerge({}, parentConfig, userConfig);
|
|
6
|
+
// Remove the extends property from the result
|
|
7
|
+
delete result.extends;
|
|
8
|
+
if (userConfig.packageSettings && parentConfig.packageSettings) {
|
|
9
|
+
// Concatenate the package settings. User config comes first here since order can matter
|
|
10
|
+
// in some cases (and the user config should override the parent).
|
|
11
|
+
result.packageSettings = [...userConfig.packageSettings, ...parentConfig.packageSettings];
|
|
12
|
+
}
|
|
13
|
+
return result;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=mergeParentConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeParentConfig.js","sourceRoot":"","sources":["../src/mergeParentConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,IAAI,cAAc,EAAE,MAAM,OAAO,CAAC;AAEpD,MAAM,UAAU,iBAAiB,CAAC,MAA4D;IAC5F,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;IAE5C,8EAA8E;IAC9E,MAAM,MAAM,GAAG,cAAc,CAAC,EAAE,EAAE,YAAY,EAAE,UAAU,CAAe,CAAC;IAE1E,8CAA8C;IAC9C,OAAO,MAAM,CAAC,OAAO,CAAC;IAEtB,IAAI,UAAU,CAAC,eAAe,IAAI,YAAY,CAAC,eAAe,EAAE,CAAC;QAC/D,wFAAwF;QACxF,kEAAkE;QAClE,MAAM,CAAC,eAAe,GAAG,CAAC,GAAG,UAAU,CAAC,eAAe,EAAE,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC;IAC5F,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { UserConfig } from '@ms-cloudpack/config-types';\nimport { recursive as recursiveMerge } from 'merge';\n\nexport function mergeParentConfig(params: { userConfig: UserConfig; parentConfig: UserConfig }): UserConfig {\n const { userConfig, parentConfig } = params;\n\n // NOTE: This must merge into an empty object to avoid modifying the originals\n const result = recursiveMerge({}, parentConfig, userConfig) as UserConfig;\n\n // Remove the extends property from the result\n delete result.extends;\n\n if (userConfig.packageSettings && parentConfig.packageSettings) {\n // Concatenate the package settings. User config comes first here since order can matter\n // in some cases (and the user config should override the parent).\n result.packageSettings = [...userConfig.packageSettings, ...parentConfig.packageSettings];\n }\n\n return result;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readUserConfig.d.ts","sourceRoot":"","sources":["../src/readUserConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"readUserConfig.d.ts","sourceRoot":"","sources":["../src/readUserConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAyD7D;;;GAGG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAMzE"}
|
package/lib/readUserConfig.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readJson } from '@ms-cloudpack/json-utilities';
|
|
2
2
|
import { getConfigPath } from './getConfigPath.js';
|
|
3
|
+
import { mergeParentConfig } from './mergeParentConfig.js';
|
|
3
4
|
import { safeImportParentConfig } from './safeImportParentConfig.js';
|
|
4
5
|
/**
|
|
5
6
|
* Reads the user config file and merges it with any parent configs.
|
|
@@ -37,17 +38,7 @@ async function readUserConfigInternal(params) {
|
|
|
37
38
|
if (!parentConfig) {
|
|
38
39
|
return userConfig;
|
|
39
40
|
}
|
|
40
|
-
|
|
41
|
-
const result = {
|
|
42
|
-
...parentConfig,
|
|
43
|
-
...userConfig,
|
|
44
|
-
features: {
|
|
45
|
-
...(parentConfig.features || {}),
|
|
46
|
-
...(userConfig.features || {}),
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
delete result.extends; // Remove the extends property from the result
|
|
50
|
-
return result;
|
|
41
|
+
return mergeParentConfig({ userConfig, parentConfig });
|
|
51
42
|
}
|
|
52
43
|
/**
|
|
53
44
|
* Reads the user config file and merges with any parent configs asynchronously. Note this is only useful for making modifications to the user config.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readUserConfig.js","sourceRoot":"","sources":["../src/readUserConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"readUserConfig.js","sourceRoot":"","sources":["../src/readUserConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE;;;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,CAAC,KAAK,UAAU,cAAc,CAAC,OAAe;IAClD,MAAM,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAElD,MAAM,UAAU,GAAG,CAAC,MAAM,sBAAsB,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAEtF,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import type { UserConfig } from '@ms-cloudpack/config-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport { getConfigPath } from './getConfigPath.js';\nimport { mergeParentConfig } from './mergeParentConfig.js';\nimport { safeImportParentConfig } from './safeImportParentConfig.js';\n\n/**\n * Reads the user config file and merges it with any parent configs.\n * @param params - The path to the user config file or the import specifier for the parent config file.\n */\nasync function readUserConfigInternal(\n params:\n | { filePath: string }\n | {\n fromConfigPath: string;\n importSpecifier: string;\n },\n): Promise<UserConfig | undefined> {\n if ('filePath' in params && 'importSpecifier' in params) {\n throw new Error('Only one of filePath or importSpecifier can be specified');\n }\n\n // Read the user config file\n let userConfig: UserConfig | undefined;\n let resolvedConfigPath: string | undefined;\n\n if ('filePath' in params) {\n userConfig = await readJson(params.filePath, { verbose: true, mode: 'permissive' });\n resolvedConfigPath = params.filePath;\n } else {\n const { importSpecifier, fromConfigPath } = params;\n const result = await safeImportParentConfig({ importSpecifier, configPath: fromConfigPath });\n if (result) {\n resolvedConfigPath = result.resolvedConfigPath;\n userConfig = result.config;\n }\n }\n\n // If there is no userConfig or 'extends' property, return it early\n if (!userConfig?.extends || !resolvedConfigPath) {\n return userConfig;\n }\n\n // Recursively read the parent config file\n const parentConfig = await readUserConfigInternal({\n fromConfigPath: resolvedConfigPath,\n importSpecifier: userConfig.extends,\n });\n\n // If unable to read the parent config file, return the userConfig\n if (!parentConfig) {\n return userConfig;\n }\n\n return mergeParentConfig({ userConfig, parentConfig });\n}\n\n/**\n * Reads the user config file and merges with any parent configs asynchronously. Note this is only useful for making modifications to the user config.\n * For a full merged representation of config, use `readConfig` instead.\n */\nexport async function readUserConfig(appPath: string): Promise<UserConfig> {\n const { userConfigPath } = getConfigPath(appPath);\n\n const userConfig = (await readUserConfigInternal({ filePath: userConfigPath })) || {};\n\n return userConfig;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/config",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.23",
|
|
4
4
|
"description": "Configuration handling for cloudpack.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@ms-cloudpack/bundler-types": "^0.24.
|
|
17
|
+
"@ms-cloudpack/bundler-types": "^0.24.1",
|
|
18
18
|
"@ms-cloudpack/config-types": "^0.4.3",
|
|
19
19
|
"@ms-cloudpack/json-utilities": "^0.1.3",
|
|
20
|
-
"@ms-cloudpack/package-utilities": "^5.8.
|
|
20
|
+
"@ms-cloudpack/package-utilities": "^5.8.3",
|
|
21
21
|
"@ms-cloudpack/path-string-parsing": "^1.1.3",
|
|
22
|
+
"merge": "^2.1.1",
|
|
22
23
|
"semver": "^7.6.0"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|