@ms-cloudpack/config 0.17.28 → 0.17.30
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/readUserConfig.js
CHANGED
|
@@ -18,7 +18,7 @@ async function readUserConfigInternal(configPath) {
|
|
|
18
18
|
// Recursively read any parent config files
|
|
19
19
|
const parentConfigs = [];
|
|
20
20
|
for (const importSpecifier of extendsArray) {
|
|
21
|
-
const resolvedPath =
|
|
21
|
+
const resolvedPath = resolveParentConfig({ configPath, importSpecifier });
|
|
22
22
|
if (resolvedPath) {
|
|
23
23
|
const parentConfig = await readUserConfigInternal(resolvedPath);
|
|
24
24
|
if (parentConfig) {
|
|
@@ -1 +1 @@
|
|
|
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,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;GAEG;AACH,KAAK,UAAU,sBAAsB,CAAC,UAAkB;IACtD,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAa,UAAU,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;IACjG,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO;QACrC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC;YACjC,CAAC,CAAC,UAAU,CAAC,OAAO;YACpB,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC;QACxB,CAAC,CAAC,EAAE,CAAC;IAEP,2CAA2C;IAC3C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QACH,CAAC;IACH,CAAC;IAED,OAAO,iBAAiB,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC,CAAC;AAC1D,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAe;IAClD,MAAM,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAElD,OAAO,CAAC,MAAM,sBAAsB,CAAC,cAAc,CAAC,CAAC,IAAI,EAAE,CAAC;AAC9D,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 { resolveParentConfig } from './resolveParentConfig.js';\n\n/**\n * Reads the user config, with any `extends` parent configs merged in.\n */\nasync function readUserConfigInternal(configPath: string): Promise<UserConfig | undefined> {\n const userConfig = await readJson<UserConfig>(configPath, { verbose: true, mode: 'permissive' });\n if (!userConfig) {\n return undefined;\n }\n\n const extendsArray = userConfig.extends\n ? Array.isArray(userConfig.extends)\n ? userConfig.extends\n : [userConfig.extends]\n : [];\n\n // Recursively read any parent config files\n const parentConfigs: UserConfig[] = [];\n for (const importSpecifier of extendsArray) {\n const resolvedPath = resolveParentConfig({ configPath, importSpecifier });\n if (resolvedPath) {\n const parentConfig = await readUserConfigInternal(resolvedPath);\n if (parentConfig) {\n parentConfigs.push(parentConfig);\n }\n }\n }\n\n return mergeParentConfig({ userConfig, parentConfigs });\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 return (await readUserConfigInternal(userConfigPath)) || {};\n}\n"]}
|
|
@@ -7,5 +7,5 @@ export declare function resolveParentConfig(params: {
|
|
|
7
7
|
configPath: string;
|
|
8
8
|
/** The import specifier for the parent (extends) config file. */
|
|
9
9
|
importSpecifier: string;
|
|
10
|
-
}):
|
|
10
|
+
}): string | undefined;
|
|
11
11
|
//# sourceMappingURL=resolveParentConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveParentConfig.d.ts","sourceRoot":"","sources":["../src/resolveParentConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolveParentConfig.d.ts","sourceRoot":"","sources":["../src/resolveParentConfig.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE;IAC1C,+CAA+C;IAC/C,UAAU,EAAE,MAAM,CAAC;IACnB,iEAAiE;IACjE,eAAe,EAAE,MAAM,CAAC;CACzB,GAAG,MAAM,GAAG,SAAS,CAarB"}
|
|
@@ -1,33 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { moduleResolve } from 'import-meta-resolve';
|
|
2
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
3
|
+
// Conditions used for resolution if the package has an exports map.
|
|
4
|
+
// More could be added later if desired ("default" is implicitly included).
|
|
5
|
+
const conditions = new Set(['import', 'require', 'node']);
|
|
5
6
|
/**
|
|
6
7
|
* Resolve an import specifier for a parent config file.
|
|
7
8
|
* Returns undefined if it can't be resolved or doesn't exist.
|
|
8
9
|
*/
|
|
9
|
-
export
|
|
10
|
+
export function resolveParentConfig(params) {
|
|
10
11
|
const { importSpecifier, configPath } = params;
|
|
11
12
|
let resolvedConfigPath;
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
try {
|
|
14
|
+
const resolvedUrl = moduleResolve(importSpecifier, pathToFileURL(configPath), conditions);
|
|
15
|
+
resolvedConfigPath = fileURLToPath(resolvedUrl);
|
|
14
16
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const resolvedPackage = await resolve(parsedImport.packageName, path.dirname(configPath));
|
|
18
|
-
if (resolvedPackage) {
|
|
19
|
-
resolvedConfigPath = path.join(resolvedPackage, parsedImport.importPath);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
if (!resolvedConfigPath) {
|
|
23
|
-
console.warn(`Unable to resolve config "extends": "${importSpecifier}" from ${configPath}`);
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
// Explicitly check if the file exists and log a warning (so the user knows their config is wrong),
|
|
27
|
-
// rather than letting readJson quietly return nothing later.
|
|
28
|
-
if (!fs.existsSync(resolvedConfigPath)) {
|
|
29
|
-
console.warn(`Resolved config "extends": "${importSpecifier}" (from ${configPath}) to ${resolvedConfigPath}, but the file doesn't exist`);
|
|
30
|
-
return undefined;
|
|
17
|
+
catch (err) {
|
|
18
|
+
console.warn(`Error resolving config "extends": "${importSpecifier}": ${err.message || err}`);
|
|
31
19
|
}
|
|
32
20
|
return resolvedConfigPath;
|
|
33
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveParentConfig.js","sourceRoot":"","sources":["../src/resolveParentConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"resolveParentConfig.js","sourceRoot":"","sources":["../src/resolveParentConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEnD,oEAAoE;AACpE,2EAA2E;AAC3E,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;AAE1D;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAKnC;IACC,MAAM,EAAE,eAAe,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAE/C,IAAI,kBAAsC,CAAC;IAE3C,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,aAAa,CAAC,eAAe,EAAE,aAAa,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC,CAAC;QAC1F,kBAAkB,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,IAAI,CAAC,sCAAsC,eAAe,MAAO,GAAa,CAAC,OAAO,IAAI,GAAG,EAAE,CAAC,CAAC;IAC3G,CAAC;IAED,OAAO,kBAAkB,CAAC;AAC5B,CAAC","sourcesContent":["import { moduleResolve } from 'import-meta-resolve';\nimport { fileURLToPath, pathToFileURL } from 'url';\n\n// Conditions used for resolution if the package has an exports map.\n// More could be added later if desired (\"default\" is implicitly included).\nconst conditions = new Set(['import', 'require', 'node']);\n\n/**\n * Resolve an import specifier for a parent config file.\n * Returns undefined if it can't be resolved or doesn't exist.\n */\nexport function resolveParentConfig(params: {\n /** Path of the config file being processed. */\n configPath: string;\n /** The import specifier for the parent (extends) config file. */\n importSpecifier: string;\n}): string | undefined {\n const { importSpecifier, configPath } = params;\n\n let resolvedConfigPath: string | undefined;\n\n try {\n const resolvedUrl = moduleResolve(importSpecifier, pathToFileURL(configPath), conditions);\n resolvedConfigPath = fileURLToPath(resolvedUrl);\n } catch (err) {\n console.warn(`Error resolving config \"extends\": \"${importSpecifier}\": ${(err as Error).message || err}`);\n }\n\n return resolvedConfigPath;\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.30",
|
|
4
4
|
"description": "Configuration handling for cloudpack.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@ms-cloudpack/bundler-types": "^0.24.
|
|
18
|
-
"@ms-cloudpack/config-types": "^0.5.
|
|
17
|
+
"@ms-cloudpack/bundler-types": "^0.24.5",
|
|
18
|
+
"@ms-cloudpack/config-types": "^0.5.1",
|
|
19
19
|
"@ms-cloudpack/json-utilities": "^0.1.4",
|
|
20
|
-
"@ms-cloudpack/package-utilities": "^5.10.
|
|
21
|
-
"
|
|
20
|
+
"@ms-cloudpack/package-utilities": "^5.10.5",
|
|
21
|
+
"import-meta-resolve": "^4.0.0",
|
|
22
22
|
"merge": "^2.1.1",
|
|
23
23
|
"semver": "^7.6.0"
|
|
24
24
|
},
|