@ms-cloudpack/config 0.26.2 → 0.27.0
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/checkMatch.d.ts.map +1 -1
- package/lib/checkMatch.js +2 -5
- package/lib/checkMatch.js.map +1 -1
- package/lib/compareSettings.d.ts +5 -2
- package/lib/compareSettings.d.ts.map +1 -1
- package/lib/compareSettings.js +7 -26
- package/lib/compareSettings.js.map +1 -1
- package/lib/createPackageSettingsTransform.d.ts +1 -1
- package/lib/createPackageSettingsTransform.d.ts.map +1 -1
- package/lib/createPackageSettingsTransform.js +1 -0
- package/lib/createPackageSettingsTransform.js.map +1 -1
- package/lib/ensureGeneratedSettingsForPackage.d.ts +3 -3
- package/lib/ensureGeneratedSettingsForPackage.d.ts.map +1 -1
- package/lib/ensureGeneratedSettingsForPackage.js +5 -9
- package/lib/ensureGeneratedSettingsForPackage.js.map +1 -1
- package/lib/getGeneratedPackageSettings.d.ts +13 -0
- package/lib/getGeneratedPackageSettings.d.ts.map +1 -0
- package/lib/getGeneratedPackageSettings.js +12 -0
- package/lib/getGeneratedPackageSettings.js.map +1 -0
- package/lib/getPackageSettings.d.ts +17 -12
- package/lib/getPackageSettings.d.ts.map +1 -1
- package/lib/getPackageSettings.js +13 -18
- package/lib/getPackageSettings.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/mergePackageSettings.d.ts +2 -2
- package/lib/mergePackageSettings.d.ts.map +1 -1
- package/lib/mergePackageSettings.js +2 -0
- package/lib/mergePackageSettings.js.map +1 -1
- package/lib/readAppConfig.d.ts.map +1 -1
- package/lib/readAppConfig.js +39 -0
- package/lib/readAppConfig.js.map +1 -1
- package/lib/readGeneratedConfig.d.ts +1 -1
- package/lib/readGeneratedConfig.js +1 -1
- package/lib/readGeneratedConfig.js.map +1 -1
- package/lib/resolveModule.d.ts +9 -0
- package/lib/resolveModule.d.ts.map +1 -0
- package/lib/resolveModule.js +15 -0
- package/lib/resolveModule.js.map +1 -0
- package/lib/resolveParentConfig.d.ts.map +1 -1
- package/lib/resolveParentConfig.js +4 -10
- package/lib/resolveParentConfig.js.map +1 -1
- package/lib/sortGeneratedConfig.d.ts.map +1 -1
- package/lib/sortGeneratedConfig.js +1 -1
- package/lib/sortGeneratedConfig.js.map +1 -1
- package/lib/writeGeneratedConfig.d.ts +6 -0
- package/lib/writeGeneratedConfig.d.ts.map +1 -1
- package/lib/writeGeneratedConfig.js +8 -1
- package/lib/writeGeneratedConfig.js.map +1 -1
- package/package.json +4 -4
- package/lib/cleanGeneratedConfig.d.ts +0 -8
- package/lib/cleanGeneratedConfig.d.ts.map +0 -1
- package/lib/cleanGeneratedConfig.js +0 -16
- package/lib/cleanGeneratedConfig.js.map +0 -1
package/lib/checkMatch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkMatch.d.ts","sourceRoot":"","sources":["../src/checkMatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAGlE;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE;IACjC,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;IAChC,8EAA8E;IAC9E,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"checkMatch.d.ts","sourceRoot":"","sources":["../src/checkMatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAGlE;;GAEG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE;IACjC,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;IAChC,8EAA8E;IAC9E,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,OAAO,CAoBV"}
|
package/lib/checkMatch.js
CHANGED
|
@@ -4,18 +4,15 @@ import { satisfies } from 'semver';
|
|
|
4
4
|
*/
|
|
5
5
|
export function checkMatch(params) {
|
|
6
6
|
const { name, version, match, exactMatch } = params;
|
|
7
|
-
if (!match) {
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
7
|
let matchName;
|
|
11
8
|
let matchVersion;
|
|
12
9
|
if (typeof match === 'string') {
|
|
13
10
|
matchName = match;
|
|
14
11
|
}
|
|
15
12
|
else {
|
|
16
|
-
matchName = match
|
|
13
|
+
matchName = match.name;
|
|
17
14
|
// If any version is allowed, unset the version to skip the satisfies() check for efficiency.
|
|
18
|
-
matchVersion = match
|
|
15
|
+
matchVersion = match.version === '*' ? undefined : match.version;
|
|
19
16
|
}
|
|
20
17
|
// For exact or non-wildcard matches, check the full name and possibly the version.
|
|
21
18
|
if (exactMatch || !matchName.endsWith('*')) {
|
package/lib/checkMatch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkMatch.js","sourceRoot":"","sources":["../src/checkMatch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,MAS1B;IACC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAEpD,IAAI,
|
|
1
|
+
{"version":3,"file":"checkMatch.js","sourceRoot":"","sources":["../src/checkMatch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,MAS1B;IACC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,MAAM,CAAC;IAEpD,IAAI,SAAiB,CAAC;IACtB,IAAI,YAAgC,CAAC;IACrC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,SAAS,GAAG,KAAK,CAAC;IACpB,CAAC;SAAM,CAAC;QACN,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,6FAA6F;QAC7F,YAAY,GAAG,KAAK,CAAC,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;IACnE,CAAC;IAED,mFAAmF;IACnF,IAAI,UAAU,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAC3C,OAAO,SAAS,KAAK,IAAI,IAAI,CAAC,CAAC,YAAY,IAAI,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;IACnF,CAAC;IAED,sFAAsF;IACtF,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,IAAI,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC;AACxG,CAAC","sourcesContent":["import type { PackageSettings } from '@ms-cloudpack/common-types';\nimport { satisfies } from 'semver';\n\n/**\n * Checks if the package is a match for the given package settings.\n */\nexport function checkMatch(params: {\n /** The name of the package. */\n name: string;\n /** The version of the package. */\n version: string;\n /** The match to check against. */\n match: PackageSettings['match'];\n /** If true, require an exact match for the name (don't process wildcards). */\n exactMatch?: boolean;\n}): boolean {\n const { name, version, match, exactMatch } = params;\n\n let matchName: string;\n let matchVersion: string | undefined;\n if (typeof match === 'string') {\n matchName = match;\n } else {\n matchName = match.name;\n // If any version is allowed, unset the version to skip the satisfies() check for efficiency.\n matchVersion = match.version === '*' ? undefined : match.version;\n }\n\n // For exact or non-wildcard matches, check the full name and possibly the version.\n if (exactMatch || !matchName.endsWith('*')) {\n return matchName === name && (!matchVersion || satisfies(version, matchVersion));\n }\n\n // Remove the trailing wildcard and check for a prefix match and possibly the version.\n return name.startsWith(matchName.slice(0, -1)) && (!matchVersion || satisfies(version, matchVersion));\n}\n"]}
|
package/lib/compareSettings.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { GeneratedPackageSettings } from '@ms-cloudpack/common-types';
|
|
2
|
+
/**
|
|
3
|
+
* Compare generated package settings for array sorting.
|
|
4
|
+
*/
|
|
5
|
+
export declare function compareSettings(a: GeneratedPackageSettings, b: GeneratedPackageSettings): number;
|
|
3
6
|
//# sourceMappingURL=compareSettings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compareSettings.d.ts","sourceRoot":"","sources":["../src/compareSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"compareSettings.d.ts","sourceRoot":"","sources":["../src/compareSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAE3E;;GAEG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,wBAAwB,EAAE,CAAC,EAAE,wBAAwB,GAAG,MAAM,CAchG"}
|
package/lib/compareSettings.js
CHANGED
|
@@ -1,36 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compare generated package settings for array sorting.
|
|
3
|
+
*/
|
|
1
4
|
export function compareSettings(a, b) {
|
|
2
5
|
// TypeScript's type narrowing doesn't work well with object properties,
|
|
3
6
|
// so we can assign them to variables to help it out.
|
|
4
7
|
const aMatch = a.match;
|
|
5
8
|
const bMatch = b.match;
|
|
6
|
-
//
|
|
9
|
+
// Place string matches at the beginning of the list.
|
|
7
10
|
const isAString = typeof aMatch === 'string';
|
|
8
11
|
const isBString = typeof bMatch === 'string';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (!bMatch) {
|
|
12
|
-
return 0;
|
|
13
|
-
}
|
|
14
|
-
return -1;
|
|
15
|
-
}
|
|
16
|
-
if (!bMatch) {
|
|
17
|
-
return 1;
|
|
18
|
-
}
|
|
19
|
-
// Place string matches at the beginning of the list.
|
|
20
|
-
if (isAString && isBString) {
|
|
21
|
-
return aMatch.localeCompare(bMatch);
|
|
22
|
-
}
|
|
23
|
-
else if (isAString) {
|
|
24
|
-
return -1;
|
|
25
|
-
}
|
|
26
|
-
else if (isBString) {
|
|
27
|
-
return 1;
|
|
28
|
-
}
|
|
29
|
-
const { name: aName = '', version: aVersion = '*' } = aMatch;
|
|
30
|
-
const { name: bName = '', version: bVersion = '*' } = bMatch;
|
|
31
|
-
if (aName === bName) {
|
|
32
|
-
return aVersion.localeCompare(bVersion);
|
|
12
|
+
if (isAString || isBString) {
|
|
13
|
+
return isAString ? (isBString ? aMatch.localeCompare(bMatch) : -1) : 1;
|
|
33
14
|
}
|
|
34
|
-
return
|
|
15
|
+
return aMatch.name.localeCompare(bMatch.name) || aMatch.version.localeCompare(bMatch.version);
|
|
35
16
|
}
|
|
36
17
|
//# sourceMappingURL=compareSettings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compareSettings.js","sourceRoot":"","sources":["../src/compareSettings.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,eAAe,CAAC,
|
|
1
|
+
{"version":3,"file":"compareSettings.js","sourceRoot":"","sources":["../src/compareSettings.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,CAA2B,EAAE,CAA2B;IACtF,wEAAwE;IACxE,qDAAqD;IACrD,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC;IACvB,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC;IAEvB,qDAAqD;IACrD,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC;IAC7C,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC;IAC7C,IAAI,SAAS,IAAI,SAAS,EAAE,CAAC;QAC3B,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACzE,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAChG,CAAC","sourcesContent":["import type { GeneratedPackageSettings } from '@ms-cloudpack/common-types';\n\n/**\n * Compare generated package settings for array sorting.\n */\nexport function compareSettings(a: GeneratedPackageSettings, b: GeneratedPackageSettings): number {\n // TypeScript's type narrowing doesn't work well with object properties,\n // so we can assign them to variables to help it out.\n const aMatch = a.match;\n const bMatch = b.match;\n\n // Place string matches at the beginning of the list.\n const isAString = typeof aMatch === 'string';\n const isBString = typeof bMatch === 'string';\n if (isAString || isBString) {\n return isAString ? (isBString ? aMatch.localeCompare(bMatch) : -1) : 1;\n }\n\n return aMatch.name.localeCompare(bMatch.name) || aMatch.version.localeCompare(bMatch.version);\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { CloudpackConfig, PackageDefinitionTransform } from '@ms-cloudpack/common-types';
|
|
2
2
|
/**
|
|
3
3
|
* Creates a transform to be registered with a PackageDefinitions registry for updating package.json
|
|
4
4
|
* based on package settings from the config.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPackageSettingsTransform.d.ts","sourceRoot":"","sources":["../src/createPackageSettingsTransform.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"createPackageSettingsTransform.d.ts","sourceRoot":"","sources":["../src/createPackageSettingsTransform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,0BAA0B,EAO3B,MAAM,4BAA4B,CAAC;AAKpC;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,eAAe,GAAG,0BAA0B,CA4ClG"}
|
|
@@ -81,6 +81,7 @@ function computeDependencies(options) {
|
|
|
81
81
|
async function computeExports(options, context) {
|
|
82
82
|
const { packagePath, definition, userPackageSettings, generatedPackageSettings } = options;
|
|
83
83
|
const { appPath } = context.config;
|
|
84
|
+
// TODO: an array of export objects is not really valid per the spec and most implementations
|
|
84
85
|
const exports = [];
|
|
85
86
|
// If this is the app package, ensure the routes are part of the exports map.
|
|
86
87
|
if (appPath === packagePath) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPackageSettingsTransform.js","sourceRoot":"","sources":["../src/createPackageSettingsTransform.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAAC,MAAuB;IACpE,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,EAAE;QACrD,MAAM,EAAE,IAAI,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,UAAU,CAAC;QAC/C,MAAM,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,GAAG,kBAAkB,CAAC;YAC3E,IAAI;YACJ,OAAO;YACP,mBAAmB,EAAE,MAAM,CAAC,eAAe;YAC3C,wBAAwB,EAAE,MAAM,CAAC,SAAS,CAAC,eAAe;SAC3D,CAAC,CAAC;QAEH,6GAA6G;QA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H,CAAC;QACH,CAAC;QAED,oEAAoE;QACpE,IAAI,eAAe,EAAE,CAAC;YACpB,uFAAuF;YACvF,+BAA+B;YAC/B,OAAO,YAAY,CAAC;QACtB,CAAC;IACH,CAAC;IAED,iCAAiC;IACjC,OAAO,CAAC,IAAI,CACV,mBAAmB,EAAE,OAAO;QAC1B,UAAU,CAAC,OAAO;QAClB,CAAC,MAAM,aAAa,CAAC,EAAE,WAAW,EAAE,iBAAiB,EAAE,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC,CAC3E,CAAC;IAEF,0BAA0B;IAC1B,IAAI,wBAAwB,EAAE,OAAO,EAAE,CAAC;QACtC,OAAO,CAAC,IAAI,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import {\n type CloudpackConfig,\n type PackageDefinitionTransform,\n type PackageDefinitionsCache,\n type PackageJson,\n type PackageJsonDependencies,\n type PackageJsonExports,\n type PackageSettings,\n type RenderedRoute,\n} from '@ms-cloudpack/common-types';\nimport { getPackageSettings } from './getPackageSettings.js';\nimport { addExportsMapEntry, getExportsMap } from '@ms-cloudpack/package-utilities';\nimport { mergePackageSettings } from './mergePackageSettings.js';\n\n/**\n * Creates a transform to be registered with a PackageDefinitions registry for updating package.json\n * based on package settings from the config.\n */\nexport function createPackageSettingsTransform(config: CloudpackConfig): PackageDefinitionTransform {\n return async ({ definition, packagePath, packages }) => {\n const { name = '', version = '' } = definition;\n const { userPackageSettings, generatedPackageSettings } = getPackageSettings({\n name,\n version,\n userPackageSettings: config.packageSettings,\n generatedPackageSettings: config.generated.packageSettings,\n });\n\n // Exclude all things not important in preserving within the package.json. This limits what we end up hashing\n // when we hash the definition.\n const { exports, includedDependencies, excludedDependencies, ...settings } = mergePackageSettings([\n userPackageSettings || {},\n generatedPackageSettings || {},\n ]);\n\n const newDefinition: PackageJson = {\n name,\n version,\n exports: await computeExports(\n { packagePath, definition, userPackageSettings, generatedPackageSettings },\n { packages, config },\n ),\n dependencies: computeDependencies({ definition, userPackageSettings, generatedPackageSettings }),\n };\n\n if (definition.peerDependencies && !userPackageSettings?.excludedDependencies?.includes('$peerDependencies')) {\n newDefinition.peerDependencies = !excludedDependencies?.length\n ? definition.peerDependencies\n : Object.fromEntries(\n Object.entries(definition.peerDependencies).filter(([dep]) => !excludedDependencies.includes(dep)),\n );\n }\n\n if (config.mode || Object.keys(settings).length > 0) {\n newDefinition.cloudpack = {\n mode: config.mode,\n ...settings,\n };\n }\n\n return newDefinition;\n };\n}\n\nfunction computeDependencies(options: {\n definition: PackageJson;\n userPackageSettings?: PackageSettings;\n generatedPackageSettings?: PackageSettings;\n}): PackageJsonDependencies {\n const { definition, userPackageSettings, generatedPackageSettings } = options;\n const { dependencies = {} } = definition;\n const newDependencies = { ...dependencies };\n\n // If we have included dependencies, add them.\n const includedDependencies = [\n ...(userPackageSettings?.includedDependencies || []),\n ...(generatedPackageSettings?.includedDependencies || []),\n ];\n\n // Expand the $devDependencies placeholder to the actual dev dependencies.\n const includeDevDependencies = includedDependencies.indexOf('$devDependencies');\n\n if (includeDevDependencies !== -1) {\n includedDependencies.splice(includeDevDependencies, 1, ...Object.keys(definition.devDependencies || {}));\n }\n\n // Add the dependency from other sources, or use a wildcard.\n for (const dep of includedDependencies) {\n newDependencies[dep] =\n definition.dependencies?.[dep] ||\n definition.devDependencies?.[dep] ||\n definition.peerDependencies?.[dep] ||\n definition.optionalDependencies?.[dep] ||\n '*';\n }\n\n const excludedDependencies = [\n ...(userPackageSettings?.excludedDependencies || []),\n ...(generatedPackageSettings?.excludedDependencies || []),\n ];\n\n // Expand the $peerDependencies placeholder to the actual peer dependencies.\n const excludePeerDependencies = excludedDependencies.indexOf('$peerDependencies');\n\n if (excludePeerDependencies !== -1) {\n // Add peer dependencies to the list of excluded dependencies.\n excludedDependencies.splice(excludePeerDependencies, 1, ...Object.keys(definition.peerDependencies || {}));\n }\n\n for (const dep of excludedDependencies) {\n delete newDependencies[dep];\n }\n\n return newDependencies;\n}\n\nasync function computeExports(\n options: {\n packagePath: string;\n definition: PackageJson;\n userPackageSettings?: PackageSettings;\n generatedPackageSettings?: PackageSettings;\n },\n context: { packages: PackageDefinitionsCache; config: CloudpackConfig },\n): Promise<PackageJsonExports | undefined> {\n const { packagePath, definition, userPackageSettings, generatedPackageSettings } = options;\n const { appPath } = context.config;\n const exports = [];\n\n // If this is the app package, ensure the routes are part of the exports map.\n if (appPath === packagePath) {\n const { routes = [] } = context.config;\n const routeExports = {};\n let hasRouteExports = false;\n\n for (const route of routes) {\n const { entry } = route as RenderedRoute;\n\n if (entry?.length) {\n for (const entryItem of entry) {\n hasRouteExports =\n (await addExportsMapEntry(\n {\n exports: routeExports,\n packagePath,\n environmentCondition: 'browser',\n filePath: entryItem.sourcePath,\n importPath: entryItem.importPath,\n },\n context,\n )) || hasRouteExports;\n }\n }\n }\n\n // Insert them at the start, so that future exports have precedence.\n if (hasRouteExports) {\n // We short circuit here because we don't want to include any unused exports that might\n // be pulled from package.json.\n return routeExports;\n }\n }\n\n // Push exports from the package.\n exports.push(\n userPackageSettings?.exports ||\n definition.exports ||\n (await getExportsMap({ packagePath, disableTransforms: true }, context)),\n );\n\n // Push generated exports.\n if (generatedPackageSettings?.exports) {\n exports.push(generatedPackageSettings.exports);\n }\n\n if (exports.length === 0) {\n return undefined;\n }\n\n if (exports.length === 1) {\n return exports[0];\n }\n\n return exports;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"createPackageSettingsTransform.js","sourceRoot":"","sources":["../src/createPackageSettingsTransform.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,kBAAkB,EAAiC,MAAM,yB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CAAC,CAAC;IACpB,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type {\n CloudpackConfig,\n PackageDefinitionTransform,\n PackageDefinitionsCache,\n PackageJson,\n PackageJsonDependencies,\n PackageJsonExports,\n PackageJsonExportsObject,\n RenderedRoute,\n} from '@ms-cloudpack/common-types';\nimport { getPackageSettings, type GetPackageSettingsResult } from './getPackageSettings.js';\nimport { addExportsMapEntry, getExportsMap } from '@ms-cloudpack/package-utilities';\nimport { mergePackageSettings } from './mergePackageSettings.js';\n\n/**\n * Creates a transform to be registered with a PackageDefinitions registry for updating package.json\n * based on package settings from the config.\n */\nexport function createPackageSettingsTransform(config: CloudpackConfig): PackageDefinitionTransform {\n return async ({ definition, packagePath, packages }) => {\n const { name = '', version = '' } = definition;\n const { userPackageSettings, generatedPackageSettings } = getPackageSettings({\n name,\n version,\n userPackageSettings: config.packageSettings,\n generatedPackageSettings: config.generated.packageSettings,\n });\n\n // Exclude all things not important in preserving within the package.json. This limits what we end up hashing\n // when we hash the definition.\n const { exports, includedDependencies, excludedDependencies, ...settings } = mergePackageSettings([\n userPackageSettings || {},\n generatedPackageSettings || {},\n ]);\n\n const newDefinition: PackageJson = {\n name,\n version,\n exports: await computeExports(\n { packagePath, definition, userPackageSettings, generatedPackageSettings },\n { packages, config },\n ),\n dependencies: computeDependencies({ definition, userPackageSettings, generatedPackageSettings }),\n };\n\n if (definition.peerDependencies && !userPackageSettings?.excludedDependencies?.includes('$peerDependencies')) {\n newDefinition.peerDependencies = !excludedDependencies?.length\n ? definition.peerDependencies\n : Object.fromEntries(\n Object.entries(definition.peerDependencies).filter(([dep]) => !excludedDependencies.includes(dep)),\n );\n }\n\n if (config.mode || Object.keys(settings).length > 0) {\n newDefinition.cloudpack = {\n mode: config.mode,\n ...settings,\n };\n }\n\n return newDefinition;\n };\n}\n\nfunction computeDependencies(\n options: GetPackageSettingsResult & {\n definition: PackageJson;\n },\n): PackageJsonDependencies {\n const { definition, userPackageSettings, generatedPackageSettings } = options;\n const { dependencies = {} } = definition;\n const newDependencies = { ...dependencies };\n\n // If we have included dependencies, add them.\n const includedDependencies = [\n ...(userPackageSettings?.includedDependencies || []),\n ...(generatedPackageSettings?.includedDependencies || []),\n ];\n\n // Expand the $devDependencies placeholder to the actual dev dependencies.\n const includeDevDependencies = includedDependencies.indexOf('$devDependencies');\n\n if (includeDevDependencies !== -1) {\n includedDependencies.splice(includeDevDependencies, 1, ...Object.keys(definition.devDependencies || {}));\n }\n\n // Add the dependency from other sources, or use a wildcard.\n for (const dep of includedDependencies) {\n newDependencies[dep] =\n definition.dependencies?.[dep] ||\n definition.devDependencies?.[dep] ||\n definition.peerDependencies?.[dep] ||\n definition.optionalDependencies?.[dep] ||\n '*';\n }\n\n const excludedDependencies = [\n ...(userPackageSettings?.excludedDependencies || []),\n ...(generatedPackageSettings?.excludedDependencies || []),\n ];\n\n // Expand the $peerDependencies placeholder to the actual peer dependencies.\n const excludePeerDependencies = excludedDependencies.indexOf('$peerDependencies');\n\n if (excludePeerDependencies !== -1) {\n // Add peer dependencies to the list of excluded dependencies.\n excludedDependencies.splice(excludePeerDependencies, 1, ...Object.keys(definition.peerDependencies || {}));\n }\n\n for (const dep of excludedDependencies) {\n delete newDependencies[dep];\n }\n\n return newDependencies;\n}\n\nasync function computeExports(\n options: GetPackageSettingsResult & {\n packagePath: string;\n definition: PackageJson;\n },\n context: { packages: PackageDefinitionsCache; config: CloudpackConfig },\n): Promise<PackageJsonExports | undefined> {\n const { packagePath, definition, userPackageSettings, generatedPackageSettings } = options;\n const { appPath } = context.config;\n // TODO: an array of export objects is not really valid per the spec and most implementations\n const exports: PackageJsonExports[] = [];\n\n // If this is the app package, ensure the routes are part of the exports map.\n if (appPath === packagePath) {\n const { routes = [] } = context.config;\n const routeExports: PackageJsonExportsObject = {};\n let hasRouteExports = false;\n\n for (const route of routes) {\n const { entry } = route as RenderedRoute;\n\n if (entry?.length) {\n for (const entryItem of entry) {\n hasRouteExports =\n (await addExportsMapEntry(\n {\n exports: routeExports,\n packagePath,\n environmentCondition: 'browser',\n filePath: entryItem.sourcePath,\n importPath: entryItem.importPath,\n },\n context,\n )) || hasRouteExports;\n }\n }\n }\n\n // Insert them at the start, so that future exports have precedence.\n if (hasRouteExports) {\n // We short circuit here because we don't want to include any unused exports that might\n // be pulled from package.json.\n return routeExports;\n }\n }\n\n // Push exports from the package.\n exports.push(\n userPackageSettings?.exports ||\n definition.exports ||\n (await getExportsMap({ packagePath, disableTransforms: true }, context)),\n );\n\n // Push generated exports.\n if (generatedPackageSettings?.exports) {\n exports.push(generatedPackageSettings.exports);\n }\n\n if (exports.length === 0) {\n return undefined;\n }\n\n if (exports.length === 1) {\n return exports[0];\n }\n\n return exports;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CloudpackConfig, PackageDefinitionsCache,
|
|
1
|
+
import type { CloudpackConfig, PackageDefinitionsCache, GeneratedPackageSettings, PackageJsonExports } from '@ms-cloudpack/common-types';
|
|
2
2
|
/**
|
|
3
3
|
* Ensures the generated package setting for the package provided exists.
|
|
4
4
|
* Used to consistently write to the generated config.
|
|
@@ -9,7 +9,7 @@ export declare function ensureGeneratedSettingsForPackage(options: {
|
|
|
9
9
|
packagePath: string;
|
|
10
10
|
defaultExportsMap?: PackageJsonExports;
|
|
11
11
|
}, context: {
|
|
12
|
-
config: CloudpackConfig
|
|
12
|
+
config: Pick<CloudpackConfig, 'generated'>;
|
|
13
13
|
packages: PackageDefinitionsCache;
|
|
14
|
-
}): Promise<
|
|
14
|
+
}): Promise<GeneratedPackageSettings>;
|
|
15
15
|
//# sourceMappingURL=ensureGeneratedSettingsForPackage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureGeneratedSettingsForPackage.d.ts","sourceRoot":"","sources":["../src/ensureGeneratedSettingsForPackage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EACvB,
|
|
1
|
+
{"version":3,"file":"ensureGeneratedSettingsForPackage.d.ts","sourceRoot":"","sources":["../src/ensureGeneratedSettingsForPackage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,uBAAuB,EACvB,wBAAwB,EACxB,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;AAIpC;;;;;GAKG;AACH,wBAAsB,iCAAiC,CACrD,OAAO,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,kBAAkB,CAAA;CAAE,EACxE,OAAO,EAAE;IAAE,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;IAAC,QAAQ,EAAE,uBAAuB,CAAA;CAAE,GACzF,OAAO,CAAC,wBAAwB,CAAC,CA4BnC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getPackageSettings } from './getPackageSettings.js';
|
|
2
1
|
import { isExternalPackage } from '@ms-cloudpack/package-utilities';
|
|
2
|
+
import { getGeneratedPackageSettings } from './getGeneratedPackageSettings.js';
|
|
3
3
|
/**
|
|
4
4
|
* Ensures the generated package setting for the package provided exists.
|
|
5
5
|
* Used to consistently write to the generated config.
|
|
@@ -14,22 +14,18 @@ export async function ensureGeneratedSettingsForPackage(options, context) {
|
|
|
14
14
|
throw new Error(`Valid package definition not found for ${packagePath}`);
|
|
15
15
|
}
|
|
16
16
|
const { name, version } = definition;
|
|
17
|
-
|
|
18
|
-
let { generatedPackageSettings } = getPackageSettings({
|
|
19
|
-
userPackageSettings: config.packageSettings,
|
|
17
|
+
let generatedPackageSettings = getGeneratedPackageSettings({
|
|
20
18
|
generatedPackageSettings: config.generated.packageSettings,
|
|
21
19
|
name,
|
|
22
20
|
version,
|
|
23
|
-
firstMatch: true,
|
|
24
21
|
});
|
|
25
22
|
if (!generatedPackageSettings) {
|
|
26
23
|
generatedPackageSettings = {
|
|
27
24
|
match: isExternalPackage(packagePath) ? { name, version: `^${version}` } : name,
|
|
25
|
+
...(options.defaultExportsMap && { exports: options.defaultExportsMap }),
|
|
28
26
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
packageSettings.push(generatedPackageSettings);
|
|
27
|
+
config.generated.packageSettings ??= [];
|
|
28
|
+
config.generated.packageSettings.push(generatedPackageSettings);
|
|
33
29
|
}
|
|
34
30
|
return generatedPackageSettings;
|
|
35
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureGeneratedSettingsForPackage.js","sourceRoot":"","sources":["../src/ensureGeneratedSettingsForPackage.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"ensureGeneratedSettingsForPackage.js","sourceRoot":"","sources":["../src/ensureGeneratedSettingsForPackage.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,iCAAiC,CACrD,OAAwE,EACxE,OAA0F;IAE1F,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAChC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAErC,MAAM,UAAU,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAEnD,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CAAC,0CAA0C,WAAW,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC;IACrC,IAAI,wBAAwB,GAAG,2BAA2B,CAAC;QACzD,wBAAwB,EAAE,MAAM,CAAC,SAAS,CAAC,eAAe;QAC1D,IAAI;QACJ,OAAO;KACR,CAAC,CAAC;IAEH,IAAI,CAAC,wBAAwB,EAAE,CAAC;QAC9B,wBAAwB,GAAG;YACzB,KAAK,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI;YAC/E,GAAG,CAAC,OAAO,CAAC,iBAAiB,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,iBAAiB,EAAE,CAAC;SACzE,CAAC;QAEF,MAAM,CAAC,SAAS,CAAC,eAAe,KAAK,EAAE,CAAC;QACxC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,wBAAwB,CAAC;AAClC,CAAC","sourcesContent":["import type {\n CloudpackConfig,\n PackageDefinitionsCache,\n GeneratedPackageSettings,\n PackageJsonExports,\n} from '@ms-cloudpack/common-types';\nimport { isExternalPackage } from '@ms-cloudpack/package-utilities';\nimport { getGeneratedPackageSettings } from './getGeneratedPackageSettings.js';\n\n/**\n * Ensures the generated package setting for the package provided exists.\n * Used to consistently write to the generated config.\n * Only call this function when you will create a package setting for the package.\n * Note: Does not write to disk.\n */\nexport async function ensureGeneratedSettingsForPackage(\n options: { packagePath: string; defaultExportsMap?: PackageJsonExports },\n context: { config: Pick<CloudpackConfig, 'generated'>; packages: PackageDefinitionsCache },\n): Promise<GeneratedPackageSettings> {\n const { packagePath } = options;\n const { config, packages } = context;\n\n const definition = await packages.get(packagePath);\n\n if (!definition || !definition.name || !definition.version) {\n throw new Error(`Valid package definition not found for ${packagePath}`);\n }\n\n const { name, version } = definition;\n let generatedPackageSettings = getGeneratedPackageSettings({\n generatedPackageSettings: config.generated.packageSettings,\n name,\n version,\n });\n\n if (!generatedPackageSettings) {\n generatedPackageSettings = {\n match: isExternalPackage(packagePath) ? { name, version: `^${version}` } : name,\n ...(options.defaultExportsMap && { exports: options.defaultExportsMap }),\n };\n\n config.generated.packageSettings ??= [];\n config.generated.packageSettings.push(generatedPackageSettings);\n }\n\n return generatedPackageSettings;\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { GeneratedPackageSettings } from '@ms-cloudpack/common-types';
|
|
2
|
+
/**
|
|
3
|
+
* Get the first matching generated package settings for this package name and version.
|
|
4
|
+
* This will return the original object which currently is mutated to update the settings.
|
|
5
|
+
*
|
|
6
|
+
* To get all matching user and generated package settings, use `getPackageSettings` instead.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getGeneratedPackageSettings(params: {
|
|
9
|
+
name: string;
|
|
10
|
+
version: string;
|
|
11
|
+
generatedPackageSettings: GeneratedPackageSettings[] | undefined;
|
|
12
|
+
}): GeneratedPackageSettings | undefined;
|
|
13
|
+
//# sourceMappingURL=getGeneratedPackageSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getGeneratedPackageSettings.d.ts","sourceRoot":"","sources":["../src/getGeneratedPackageSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAG3E;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,wBAAwB,EAAE,wBAAwB,EAAE,GAAG,SAAS,CAAC;CAClE,GAAG,wBAAwB,GAAG,SAAS,CAGvC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { checkMatch } from './checkMatch.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get the first matching generated package settings for this package name and version.
|
|
4
|
+
* This will return the original object which currently is mutated to update the settings.
|
|
5
|
+
*
|
|
6
|
+
* To get all matching user and generated package settings, use `getPackageSettings` instead.
|
|
7
|
+
*/
|
|
8
|
+
export function getGeneratedPackageSettings(params) {
|
|
9
|
+
const { name, version, generatedPackageSettings } = params;
|
|
10
|
+
return generatedPackageSettings?.find(({ match }) => checkMatch({ name, version, match, exactMatch: true }));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=getGeneratedPackageSettings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getGeneratedPackageSettings.js","sourceRoot":"","sources":["../src/getGeneratedPackageSettings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAC,MAI3C;IACC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,wBAAwB,EAAE,GAAG,MAAM,CAAC;IAC3D,OAAO,wBAAwB,EAAE,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC/G,CAAC","sourcesContent":["import type { GeneratedPackageSettings } from '@ms-cloudpack/common-types';\nimport { checkMatch } from './checkMatch.js';\n\n/**\n * Get the first matching generated package settings for this package name and version.\n * This will return the original object which currently is mutated to update the settings.\n *\n * To get all matching user and generated package settings, use `getPackageSettings` instead.\n */\nexport function getGeneratedPackageSettings(params: {\n name: string;\n version: string;\n generatedPackageSettings: GeneratedPackageSettings[] | undefined;\n}): GeneratedPackageSettings | undefined {\n const { name, version, generatedPackageSettings } = params;\n return generatedPackageSettings?.find(({ match }) => checkMatch({ name, version, match, exactMatch: true }));\n}\n"]}
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import type { PackageSettings } from '@ms-cloudpack/common-types';
|
|
1
|
+
import type { PackageSettings, GeneratedPackageSettings } from '@ms-cloudpack/common-types';
|
|
2
|
+
/** Result of calling `getPackageSettings`. */
|
|
3
|
+
export interface GetPackageSettingsResult {
|
|
4
|
+
/** Merged user package settings, with `match` removed. */
|
|
5
|
+
userPackageSettings: Omit<PackageSettings, 'match'> | undefined;
|
|
6
|
+
/** Merged generated package settings, with `match` removed. */
|
|
7
|
+
generatedPackageSettings: Omit<GeneratedPackageSettings, 'match'> | undefined;
|
|
8
|
+
}
|
|
2
9
|
/**
|
|
3
|
-
* Gets the
|
|
10
|
+
* Gets the user and generated package settings which apply to this package name and version,
|
|
11
|
+
* with the settings from each source merged together.
|
|
12
|
+
*
|
|
13
|
+
* NOTE: If you're calling from init-related code and would like to modify the result to update
|
|
14
|
+
* the generated config, use `getGeneratedPackageSettings` instead.
|
|
4
15
|
*/
|
|
5
16
|
export declare function getPackageSettings(params: {
|
|
6
17
|
name: string;
|
|
7
18
|
version: string;
|
|
19
|
+
/** User package settings from the config */
|
|
8
20
|
userPackageSettings: PackageSettings[] | undefined;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* This is useful in the `init` case, where we want to attach new settings to the first matching entry.
|
|
13
|
-
*/
|
|
14
|
-
firstMatch?: boolean;
|
|
15
|
-
}): {
|
|
16
|
-
userPackageSettings: PackageSettings | undefined;
|
|
17
|
-
generatedPackageSettings: PackageSettings | undefined;
|
|
18
|
-
};
|
|
21
|
+
/** Generated package settings from the config */
|
|
22
|
+
generatedPackageSettings: GeneratedPackageSettings[] | undefined;
|
|
23
|
+
}): GetPackageSettingsResult;
|
|
19
24
|
//# sourceMappingURL=getPackageSettings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackageSettings.d.ts","sourceRoot":"","sources":["../src/getPackageSettings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getPackageSettings.d.ts","sourceRoot":"","sources":["../src/getPackageSettings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAG5F,8CAA8C;AAC9C,MAAM,WAAW,wBAAwB;IACvC,0DAA0D;IAC1D,mBAAmB,EAAE,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAChE,+DAA+D;IAC/D,wBAAwB,EAAE,IAAI,CAAC,wBAAwB,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CAC/E;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,mBAAmB,EAAE,eAAe,EAAE,GAAG,SAAS,CAAC;IACnD,iDAAiD;IACjD,wBAAwB,EAAE,wBAAwB,EAAE,GAAG,SAAS,CAAC;CAClE,GAAG,wBAAwB,CAgB3B"}
|
|
@@ -1,27 +1,22 @@
|
|
|
1
1
|
import { mergePackageSettings } from './mergePackageSettings.js';
|
|
2
2
|
import { checkMatch } from './checkMatch.js';
|
|
3
3
|
/**
|
|
4
|
-
* Gets the
|
|
4
|
+
* Gets the user and generated package settings which apply to this package name and version,
|
|
5
|
+
* with the settings from each source merged together.
|
|
6
|
+
*
|
|
7
|
+
* NOTE: If you're calling from init-related code and would like to modify the result to update
|
|
8
|
+
* the generated config, use `getGeneratedPackageSettings` instead.
|
|
5
9
|
*/
|
|
6
10
|
export function getPackageSettings(params) {
|
|
7
|
-
const { userPackageSettings, generatedPackageSettings } = params;
|
|
11
|
+
const { name, version, userPackageSettings, generatedPackageSettings } = params;
|
|
12
|
+
const matchingUserSettings = userPackageSettings?.filter(({ match }) => checkMatch({ name, version, match }));
|
|
13
|
+
// For generated settings, restrict to exact matches since the name won't have wildcards
|
|
14
|
+
const matchingGeneratedSettings = generatedPackageSettings?.filter(({ match }) => checkMatch({ name, version, match, exactMatch: true }));
|
|
8
15
|
return {
|
|
9
|
-
userPackageSettings:
|
|
10
|
-
generatedPackageSettings:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}),
|
|
16
|
+
userPackageSettings: matchingUserSettings?.length ? mergePackageSettings(matchingUserSettings) : undefined,
|
|
17
|
+
generatedPackageSettings: matchingGeneratedSettings?.length
|
|
18
|
+
? mergePackageSettings(matchingGeneratedSettings)
|
|
19
|
+
: undefined,
|
|
14
20
|
};
|
|
15
21
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Get the package settings for a given package name and version.
|
|
18
|
-
*/
|
|
19
|
-
function filterSettings(params) {
|
|
20
|
-
const { name, version, packageSettings, firstMatch } = params;
|
|
21
|
-
if (firstMatch) {
|
|
22
|
-
return packageSettings?.find(({ match }) => checkMatch({ name, version, match, exactMatch: firstMatch }));
|
|
23
|
-
}
|
|
24
|
-
const filteredSettings = packageSettings?.filter(({ match }) => checkMatch({ name, version, match }));
|
|
25
|
-
return filteredSettings?.length ? mergePackageSettings(filteredSettings) : undefined;
|
|
26
|
-
}
|
|
27
22
|
//# sourceMappingURL=getPackageSettings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPackageSettings.js","sourceRoot":"","sources":["../src/getPackageSettings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getPackageSettings.js","sourceRoot":"","sources":["../src/getPackageSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAU7C;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAOlC;IACC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,GAAG,MAAM,CAAC;IAEhF,MAAM,oBAAoB,GAAG,mBAAmB,EAAE,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAE9G,wFAAwF;IACxF,MAAM,yBAAyB,GAAG,wBAAwB,EAAE,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAC/E,UAAU,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CACvD,CAAC;IAEF,OAAO;QACL,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,CAAC,CAAC,CAAC,oBAAoB,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,SAAS;QAC1G,wBAAwB,EAAE,yBAAyB,EAAE,MAAM;YACzD,CAAC,CAAC,oBAAoB,CAAC,yBAAyB,CAAC;YACjD,CAAC,CAAC,SAAS;KACd,CAAC;AACJ,CAAC","sourcesContent":["import { mergePackageSettings } from './mergePackageSettings.js';\nimport type { PackageSettings, GeneratedPackageSettings } from '@ms-cloudpack/common-types';\nimport { checkMatch } from './checkMatch.js';\n\n/** Result of calling `getPackageSettings`. */\nexport interface GetPackageSettingsResult {\n /** Merged user package settings, with `match` removed. */\n userPackageSettings: Omit<PackageSettings, 'match'> | undefined;\n /** Merged generated package settings, with `match` removed. */\n generatedPackageSettings: Omit<GeneratedPackageSettings, 'match'> | undefined;\n}\n\n/**\n * Gets the user and generated package settings which apply to this package name and version,\n * with the settings from each source merged together.\n *\n * NOTE: If you're calling from init-related code and would like to modify the result to update\n * the generated config, use `getGeneratedPackageSettings` instead.\n */\nexport function getPackageSettings(params: {\n name: string;\n version: string;\n /** User package settings from the config */\n userPackageSettings: PackageSettings[] | undefined;\n /** Generated package settings from the config */\n generatedPackageSettings: GeneratedPackageSettings[] | undefined;\n}): GetPackageSettingsResult {\n const { name, version, userPackageSettings, generatedPackageSettings } = params;\n\n const matchingUserSettings = userPackageSettings?.filter(({ match }) => checkMatch({ name, version, match }));\n\n // For generated settings, restrict to exact matches since the name won't have wildcards\n const matchingGeneratedSettings = generatedPackageSettings?.filter(({ match }) =>\n checkMatch({ name, version, match, exactMatch: true }),\n );\n\n return {\n userPackageSettings: matchingUserSettings?.length ? mergePackageSettings(matchingUserSettings) : undefined,\n generatedPackageSettings: matchingGeneratedSettings?.length\n ? mergePackageSettings(matchingGeneratedSettings)\n : undefined,\n };\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { generatedConfigFileName, appConfigFileName } from './constants.js';
|
|
|
4
4
|
export { createPackageDefinitions } from './createPackageDefinitions.js';
|
|
5
5
|
export { getConfigPath } from './getConfigPath.js';
|
|
6
6
|
export { getPackageSettings } from './getPackageSettings.js';
|
|
7
|
+
export { getGeneratedPackageSettings } from './getGeneratedPackageSettings.js';
|
|
7
8
|
export { readConfig } from './readConfig.js';
|
|
8
9
|
export { readGeneratedConfig } from './readGeneratedConfig.js';
|
|
9
10
|
export { readAppConfig } from './readAppConfig.js';
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { generatedConfigFileName, appConfigFileName } from './constants.js';
|
|
|
4
4
|
export { createPackageDefinitions } from './createPackageDefinitions.js';
|
|
5
5
|
export { getConfigPath } from './getConfigPath.js';
|
|
6
6
|
export { getPackageSettings } from './getPackageSettings.js';
|
|
7
|
+
export { getGeneratedPackageSettings } from './getGeneratedPackageSettings.js';
|
|
7
8
|
export { readConfig } from './readConfig.js';
|
|
8
9
|
export { readGeneratedConfig } from './readGeneratedConfig.js';
|
|
9
10
|
export { readAppConfig } from './readAppConfig.js';
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC","sourcesContent":["export { checkMatch } from './checkMatch.js';\nexport { configTemplate } from './configTemplate.js';\nexport { generatedConfigFileName, appConfigFileName } from './constants.js';\nexport { createPackageDefinitions } from './createPackageDefinitions.js';\nexport { getConfigPath } from './getConfigPath.js';\nexport { getPackageSettings } from './getPackageSettings.js';\nexport { readConfig } from './readConfig.js';\nexport { readGeneratedConfig } from './readGeneratedConfig.js';\nexport { readAppConfig } from './readAppConfig.js';\nexport { writeGeneratedConfig } from './writeGeneratedConfig.js';\nexport { writeAppConfig } from './writeAppConfig.js';\nexport { ensureGeneratedSettingsForPackage } from './ensureGeneratedSettingsForPackage.js';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC","sourcesContent":["export { checkMatch } from './checkMatch.js';\nexport { configTemplate } from './configTemplate.js';\nexport { generatedConfigFileName, appConfigFileName } from './constants.js';\nexport { createPackageDefinitions } from './createPackageDefinitions.js';\nexport { getConfigPath } from './getConfigPath.js';\nexport { getPackageSettings } from './getPackageSettings.js';\nexport { getGeneratedPackageSettings } from './getGeneratedPackageSettings.js';\nexport { readConfig } from './readConfig.js';\nexport { readGeneratedConfig } from './readGeneratedConfig.js';\nexport { readAppConfig } from './readAppConfig.js';\nexport { writeGeneratedConfig } from './writeGeneratedConfig.js';\nexport { writeAppConfig } from './writeAppConfig.js';\nexport { ensureGeneratedSettingsForPackage } from './ensureGeneratedSettingsForPackage.js';\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PackageSettings } from '@ms-cloudpack/common-types';
|
|
1
|
+
import type { GeneratedPackageSettings, PackageSettings } from '@ms-cloudpack/common-types';
|
|
2
2
|
/**
|
|
3
3
|
* Merges package settings together.
|
|
4
4
|
*
|
|
@@ -7,5 +7,5 @@ import type { PackageSettings } from '@ms-cloudpack/common-types';
|
|
|
7
7
|
* conditions that will be applied at the time the map is used), so more thought would be required
|
|
8
8
|
* for how to handle multiple exports maps properly.
|
|
9
9
|
*/
|
|
10
|
-
export declare function mergePackageSettings(settings:
|
|
10
|
+
export declare function mergePackageSettings<TSettings extends Partial<PackageSettings | GeneratedPackageSettings>>(settings: TSettings[]): Omit<TSettings, 'match'>;
|
|
11
11
|
//# sourceMappingURL=mergePackageSettings.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergePackageSettings.d.ts","sourceRoot":"","sources":["../src/mergePackageSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"mergePackageSettings.d.ts","sourceRoot":"","sources":["../src/mergePackageSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAK5F;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,SAAS,OAAO,CAAC,eAAe,GAAG,wBAAwB,CAAC,EACxG,QAAQ,EAAE,SAAS,EAAE,GACpB,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CA+B1B"}
|
|
@@ -9,6 +9,8 @@ const defaultInputPaths = ['src/**', '*.json', '!**/node_modules/**'];
|
|
|
9
9
|
* for how to handle multiple exports maps properly.
|
|
10
10
|
*/
|
|
11
11
|
export function mergePackageSettings(settings) {
|
|
12
|
+
// Use PackageSettings as the type while merging so that the key-based typings work
|
|
13
|
+
// (if the key is not present in generated settings, it does nothing)
|
|
12
14
|
const result = mergeObjects(settings, {
|
|
13
15
|
// match is deleted after merging, so it is best to overwrite it to avoid merging conflicts.
|
|
14
16
|
overwriteKeys: ['ignoreMissingExports', 'bundlerOptions', 'match'],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergePackageSettings.js","sourceRoot":"","sources":["../src/mergePackageSettings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EA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C,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBACrD,CAAC;gBAED,OAAO,GAAG,CAAC;YACb,CAAC;YACD,UAAU,EAAE,CAAC,GAAG,GAAG,EAAE,EAAE,IAAI,GAAG,EAAE,EAAE,EAAE;gBAClC,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,kBAAkB,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC,CAAC;YAClE,CAAC;SACF;KACF,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,KAAK,CAAC;IACpB,OAAO,MAAmB,CAAC;AAC7B,CAAC","sourcesContent":["import type { GeneratedPackageSettings, PackageSettings } from '@ms-cloudpack/common-types';\nimport { mergeObjects, mergeArrayDefaults } from '@ms-cloudpack/package-utilities';\n\nconst defaultInputPaths = ['src/**', '*.json', '!**/node_modules/**'];\n\n/**\n * Merges package settings together.\n *\n * TODO: This \"merges\" exports maps by concatenating them in an array, which is not correct per the\n * spec in Node. However, merging them properly is much more difficult to implement (depends on the\n * conditions that will be applied at the time the map is used), so more thought would be required\n * for how to handle multiple exports maps properly.\n */\nexport function mergePackageSettings<TSettings extends Partial<PackageSettings | GeneratedPackageSettings>>(\n settings: TSettings[],\n): Omit<TSettings, 'match'> {\n // Use PackageSettings as the type while merging so that the key-based typings work\n // (if the key is not present in generated settings, it does nothing)\n const result = mergeObjects(settings as Partial<PackageSettings>[], {\n // match is deleted after merging, so it is best to overwrite it to avoid merging conflicts.\n overwriteKeys: ['ignoreMissingExports', 'bundlerOptions', 'match'],\n customMerge: {\n exports: (acc, curr) => {\n // Use the current setting if it's explicitly null or was previously not set.\n if (!acc || curr === null) {\n // Make a copy if it's an array, so later additions don't affect the original.\n return Array.isArray(curr) ? [...curr] : curr;\n }\n\n if (curr) {\n // If we have previous exports but it's not an array, make it an array.\n acc = acc ? (Array.isArray(acc) ? acc : [acc]) : [];\n // Add the new exports.\n acc.push(...(Array.isArray(curr) ? curr : [curr]));\n }\n\n return acc;\n },\n inputPaths: (acc = [], curr = []) => {\n return [...acc, ...mergeArrayDefaults(curr, defaultInputPaths)];\n },\n },\n });\n\n delete result.match;\n return result as TSettings;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readAppConfig.d.ts","sourceRoot":"","sources":["../src/readAppConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"readAppConfig.d.ts","sourceRoot":"","sources":["../src/readAppConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAA8B,MAAM,4BAA4B,CAAC;AAOxF;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAIvE"}
|
package/lib/readAppConfig.js
CHANGED
|
@@ -2,6 +2,7 @@ import { readJson } from '@ms-cloudpack/json-utilities';
|
|
|
2
2
|
import { getConfigPath } from './getConfigPath.js';
|
|
3
3
|
import { mergeParentConfig } from './mergeParentConfig.js';
|
|
4
4
|
import { resolveParentConfig } from './resolveParentConfig.js';
|
|
5
|
+
import { resolveModule } from './resolveModule.js';
|
|
5
6
|
/**
|
|
6
7
|
* Reads the user config file and merges with any parent configs asynchronously.
|
|
7
8
|
* Note this is only useful for making modifications to the user config.
|
|
@@ -13,6 +14,15 @@ export async function readAppConfig(appPath) {
|
|
|
13
14
|
const { appConfigPath } = getConfigPath(appPath);
|
|
14
15
|
return (await readAppConfigInternal(appConfigPath)) || {};
|
|
15
16
|
}
|
|
17
|
+
function tryResolveBundlerCapability(importSpecifier, parentUrl) {
|
|
18
|
+
try {
|
|
19
|
+
return resolveModule({ parentUrl, importSpecifier });
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
console.warn(`Error resolving bundler capability "${importSpecifier}", Error:`, e);
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
16
26
|
/**
|
|
17
27
|
* Reads the user config, with any `extends` parent configs merged in.
|
|
18
28
|
* Throws an error if the config file exists but is not valid JSON, or there's some error reading it.
|
|
@@ -22,6 +32,35 @@ async function readAppConfigInternal(configPath) {
|
|
|
22
32
|
if (!AppConfig) {
|
|
23
33
|
return undefined;
|
|
24
34
|
}
|
|
35
|
+
// Resolve import specifiers for bundler capabilities registry
|
|
36
|
+
if (AppConfig.bundlerCapabilitiesRegistry) {
|
|
37
|
+
for (const [key, value] of Object.entries(AppConfig.bundlerCapabilitiesRegistry)) {
|
|
38
|
+
const moduleUrl = tryResolveBundlerCapability(value, configPath);
|
|
39
|
+
if (moduleUrl) {
|
|
40
|
+
AppConfig.bundlerCapabilitiesRegistry[key] = moduleUrl;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// PackageSettings's bundlerCapabilities may contain short-hand keys that need to be resolved to full import specifiers before bundler capabilities can be processed
|
|
45
|
+
// This is done by looking up the short-hand keys in the bundlerCapabilitiesRegistry
|
|
46
|
+
// If the short-hand key is not found in the registry, it is assumed to be a full import specifier
|
|
47
|
+
if (AppConfig.packageSettings && AppConfig.bundlerCapabilitiesRegistry) {
|
|
48
|
+
for (const setting of AppConfig.packageSettings) {
|
|
49
|
+
if (setting.bundlerCapabilities) {
|
|
50
|
+
const newBundlerCapabilities = {};
|
|
51
|
+
for (const key in setting.bundlerCapabilities) {
|
|
52
|
+
if (key in AppConfig.bundlerCapabilitiesRegistry) {
|
|
53
|
+
const newKey = AppConfig.bundlerCapabilitiesRegistry[key];
|
|
54
|
+
newBundlerCapabilities[newKey] = setting.bundlerCapabilities[key];
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
newBundlerCapabilities[key] = setting.bundlerCapabilities[key];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
setting.bundlerCapabilities = newBundlerCapabilities;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
25
64
|
const extendsArray = AppConfig.extends
|
|
26
65
|
? Array.isArray(AppConfig.extends)
|
|
27
66
|
? AppConfig.extends
|
package/lib/readAppConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readAppConfig.js","sourceRoot":"","sources":["../src/readAppConfig.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;
|
|
1
|
+
{"version":3,"file":"readAppConfig.js","sourceRoot":"","sources":["../src/readAppConfig.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;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAe;IACjD,MAAM,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAEjD,OAAO,CAAC,MAAM,qBAAqB,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,CAAC;AAC5D,CAAC;AAED,SAAS,2BAA2B,CAAC,eAAuB,EAAE,SAAiB;IAC7E,IAAI,CAAC;QACH,OAAO,aAAa,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;IACvD,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,IAAI,CAAC,uCAAuC,eAAe,WAAW,EAAE,CAAC,CAAC,CAAC;QACnF,OAAO,SAAS,CA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E,CAAC;YACxB,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC;YACtC,OAAO,OAAO,CAAC,WAAW,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;IACd,qCAAqC;AACvC,CAAC","sourcesContent":["import type { AppConfig, BundlerCapabilitiesOptions } from '@ms-cloudpack/common-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport { getConfigPath } from './getConfigPath.js';\nimport { mergeParentConfig } from './mergeParentConfig.js';\nimport { resolveParentConfig } from './resolveParentConfig.js';\nimport { resolveModule } from './resolveModule.js';\n\n/**\n * Reads the user config file and merges with any parent configs asynchronously.\n * Note this is only useful for making modifications to the user config.\n * For a full merged representation of config, use `readConfig` instead.\n *\n * Throws an error if the config file exists but is not valid JSON (or there's some error reading it).\n */\nexport async function readAppConfig(appPath: string): Promise<AppConfig> {\n const { appConfigPath } = getConfigPath(appPath);\n\n return (await readAppConfigInternal(appConfigPath)) || {};\n}\n\nfunction tryResolveBundlerCapability(importSpecifier: string, parentUrl: string) {\n try {\n return resolveModule({ parentUrl, importSpecifier });\n } catch (e) {\n console.warn(`Error resolving bundler capability \"${importSpecifier}\", Error:`, e);\n return undefined;\n }\n}\n\n/**\n * Reads the user config, with any `extends` parent configs merged in.\n * Throws an error if the config file exists but is not valid JSON, or there's some error reading it.\n */\nasync function readAppConfigInternal(configPath: string): Promise<AppConfig | undefined> {\n const AppConfig = await readJson<AppConfig>(configPath, { mode: 'permissive', throwOnError: true });\n if (!AppConfig) {\n return undefined;\n }\n\n // Resolve import specifiers for bundler capabilities registry\n if (AppConfig.bundlerCapabilitiesRegistry) {\n for (const [key, value] of Object.entries(AppConfig.bundlerCapabilitiesRegistry)) {\n const moduleUrl = tryResolveBundlerCapability(value, configPath);\n if (moduleUrl) {\n AppConfig.bundlerCapabilitiesRegistry[key] = moduleUrl;\n }\n }\n }\n\n // PackageSettings's bundlerCapabilities may contain short-hand keys that need to be resolved to full import specifiers before bundler capabilities can be processed\n // This is done by looking up the short-hand keys in the bundlerCapabilitiesRegistry\n // If the short-hand key is not found in the registry, it is assumed to be a full import specifier\n if (AppConfig.packageSettings && AppConfig.bundlerCapabilitiesRegistry) {\n for (const setting of AppConfig.packageSettings) {\n if (setting.bundlerCapabilities) {\n const newBundlerCapabilities: BundlerCapabilitiesOptions = {};\n for (const key in setting.bundlerCapabilities) {\n if (key in AppConfig.bundlerCapabilitiesRegistry) {\n const newKey = AppConfig.bundlerCapabilitiesRegistry[key];\n newBundlerCapabilities[newKey] = setting.bundlerCapabilities[key];\n } else {\n newBundlerCapabilities[key] = setting.bundlerCapabilities[key];\n }\n }\n setting.bundlerCapabilities = newBundlerCapabilities;\n }\n }\n }\n\n const extendsArray = AppConfig.extends\n ? Array.isArray(AppConfig.extends)\n ? AppConfig.extends\n : [AppConfig.extends]\n : [];\n\n // Recursively read any parent config files\n const parentConfigs: AppConfig[] = [];\n for (const importSpecifier of extendsArray) {\n const resolvedPath = resolveParentConfig({ configPath, importSpecifier });\n if (resolvedPath) {\n const parentConfig = await readAppConfigInternal(resolvedPath);\n if (parentConfig) {\n parentConfigs.push(parentConfig);\n }\n }\n }\n\n return processDeprecatedValues(mergeParentConfig({ AppConfig, parentConfigs }));\n}\n\n/**\n * Delete deprecated values and convert them to the new format. (This mutates the `config` object.)\n */\nfunction processDeprecatedValues(config: AppConfig) {\n /* eslint-disable etc/no-deprecated */\n const { devServer, packageSettings = [] } = config;\n\n if (devServer?.routes) {\n config.routes = devServer.routes;\n delete devServer.routes;\n }\n\n for (const setting of packageSettings) {\n if (setting.bundlerType) {\n setting.bundler = setting.bundlerType;\n delete setting.bundlerType;\n }\n }\n\n return config;\n /* eslint-enable etc/no-deprecated */\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { GeneratedConfig } from '@ms-cloudpack/common-types';
|
|
2
2
|
/**
|
|
3
3
|
* Reads the generated config file asynchronously. This is only useful for the `init` verb generating or updated
|
|
4
|
-
* the generated
|
|
4
|
+
* the generated settings. For a full merged representation of config, use `readConfig` instead.
|
|
5
5
|
*
|
|
6
6
|
* Throws an error if the config file exists but is not valid JSON (or there's some error reading it).
|
|
7
7
|
*/
|
|
@@ -2,7 +2,7 @@ import { readJson } from '@ms-cloudpack/json-utilities';
|
|
|
2
2
|
import { getConfigPath } from './getConfigPath.js';
|
|
3
3
|
/**
|
|
4
4
|
* Reads the generated config file asynchronously. This is only useful for the `init` verb generating or updated
|
|
5
|
-
* the generated
|
|
5
|
+
* the generated settings. For a full merged representation of config, use `readConfig` instead.
|
|
6
6
|
*
|
|
7
7
|
* Throws an error if the config file exists but is not valid JSON (or there's some error reading it).
|
|
8
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readGeneratedConfig.js","sourceRoot":"","sources":["../src/readGeneratedConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAAe;IACvD,MAAM,EAAE,mBAAmB,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAEvD,OAAO,CAAC,MAAM,QAAQ,CAAC,mBAAmB,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AACjG,CAAC","sourcesContent":["import { readJson } from '@ms-cloudpack/json-utilities';\nimport { getConfigPath } from './getConfigPath.js';\nimport type { GeneratedConfig } from '@ms-cloudpack/common-types';\n\n/**\n * Reads the generated config file asynchronously. This is only useful for the `init` verb generating or updated\n * the generated
|
|
1
|
+
{"version":3,"file":"readGeneratedConfig.js","sourceRoot":"","sources":["../src/readGeneratedConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAAe;IACvD,MAAM,EAAE,mBAAmB,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAEvD,OAAO,CAAC,MAAM,QAAQ,CAAC,mBAAmB,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AACjG,CAAC","sourcesContent":["import { readJson } from '@ms-cloudpack/json-utilities';\nimport { getConfigPath } from './getConfigPath.js';\nimport type { GeneratedConfig } from '@ms-cloudpack/common-types';\n\n/**\n * Reads the generated config file asynchronously. This is only useful for the `init` verb generating or updated\n * the generated settings. For a full merged representation of config, use `readConfig` instead.\n *\n * Throws an error if the config file exists but is not valid JSON (or there's some error reading it).\n */\nexport async function readGeneratedConfig(appPath: string): Promise<GeneratedConfig> {\n const { generatedConfigPath } = getConfigPath(appPath);\n\n return (await readJson(generatedConfigPath, { throwOnError: true, mode: 'permissive' })) || {};\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve a module specifier to a file path. Throws if it can't be resolved.
|
|
3
|
+
* @returns - The resolved file path
|
|
4
|
+
*/
|
|
5
|
+
export declare function resolveModule(params: {
|
|
6
|
+
importSpecifier: string;
|
|
7
|
+
parentUrl: string;
|
|
8
|
+
}): string;
|
|
9
|
+
//# sourceMappingURL=resolveModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveModule.d.ts","sourceRoot":"","sources":["../src/resolveModule.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE;IAAE,eAAe,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAK5F"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { moduleResolve } from 'import-meta-resolve';
|
|
2
|
+
import { pathToFileURL, fileURLToPath } 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']);
|
|
6
|
+
/**
|
|
7
|
+
* Resolve a module specifier to a file path. Throws if it can't be resolved.
|
|
8
|
+
* @returns - The resolved file path
|
|
9
|
+
*/
|
|
10
|
+
export function resolveModule(params) {
|
|
11
|
+
const { importSpecifier, parentUrl } = params;
|
|
12
|
+
const resolvedUrl = moduleResolve(importSpecifier, pathToFileURL(parentUrl), conditions);
|
|
13
|
+
return fileURLToPath(resolvedUrl);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=resolveModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveModule.js","sourceRoot":"","sources":["../src/resolveModule.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,aAAa,CAAC,MAAsD;IAClF,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;IAE9C,MAAM,WAAW,GAAG,aAAa,CAAC,eAAe,EAAE,aAAa,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC,CAAC;IACzF,OAAO,aAAa,CAAC,WAAW,CAAC,CAAC;AACpC,CAAC","sourcesContent":["import { moduleResolve } from 'import-meta-resolve';\nimport { pathToFileURL, fileURLToPath } 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 a module specifier to a file path. Throws if it can't be resolved.\n * @returns - The resolved file path\n */\nexport function resolveModule(params: { importSpecifier: string; parentUrl: string }): string {\n const { importSpecifier, parentUrl } = params;\n\n const resolvedUrl = moduleResolve(importSpecifier, pathToFileURL(parentUrl), conditions);\n return fileURLToPath(resolvedUrl);\n}\n"]}
|
|
@@ -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":"AAEA;;;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,CAUrB"}
|
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
import {
|
|
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']);
|
|
1
|
+
import { resolveModule } from './resolveModule.js';
|
|
6
2
|
/**
|
|
7
3
|
* Resolve an import specifier for a parent config file.
|
|
8
4
|
* Returns undefined if it can't be resolved or doesn't exist.
|
|
9
5
|
*/
|
|
10
6
|
export function resolveParentConfig(params) {
|
|
11
|
-
const { importSpecifier
|
|
12
|
-
let resolvedConfigPath;
|
|
7
|
+
const { importSpecifier } = params;
|
|
13
8
|
try {
|
|
14
|
-
|
|
15
|
-
resolvedConfigPath = fileURLToPath(resolvedUrl);
|
|
9
|
+
return resolveModule({ importSpecifier, parentUrl: params.configPath });
|
|
16
10
|
}
|
|
17
11
|
catch (err) {
|
|
18
12
|
console.warn(`Error resolving config "extends": "${importSpecifier}": ${err.message || err}`);
|
|
19
13
|
}
|
|
20
|
-
return
|
|
14
|
+
return undefined;
|
|
21
15
|
}
|
|
22
16
|
//# sourceMappingURL=resolveParentConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveParentConfig.js","sourceRoot":"","sources":["../src/resolveParentConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"resolveParentConfig.js","sourceRoot":"","sources":["../src/resolveParentConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAKnC;IACC,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,CAAC;IAEnC,IAAI,CAAC;QACH,OAAO,aAAa,CAAC,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IAC1E,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,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { resolveModule } from './resolveModule.js';\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 } = params;\n\n try {\n return resolveModule({ importSpecifier, parentUrl: params.configPath });\n } catch (err) {\n console.warn(`Error resolving config \"extends\": \"${importSpecifier}\": ${(err as Error).message || err}`);\n }\n\n return undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sortGeneratedConfig.d.ts","sourceRoot":"","sources":["../src/sortGeneratedConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"sortGeneratedConfig.d.ts","sourceRoot":"","sources":["../src/sortGeneratedConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAA4B,MAAM,4BAA4B,CAAC;AAI5F;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,eAAe,QAoC7D"}
|
|
@@ -9,7 +9,7 @@ export function sortGeneratedConfig(generated) {
|
|
|
9
9
|
if (!packageSettings) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
// Ensure package
|
|
12
|
+
// Ensure package settings are sorted based on package name and version requirement.
|
|
13
13
|
packageSettings.sort(compareSettings);
|
|
14
14
|
for (let i = 0; i < packageSettings.length; i++) {
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sortGeneratedConfig.js","sourceRoot":"","sources":["../src/sortGeneratedConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAA0B;IAC5D,MAAM,EAAE,eAAe,EAAE,GAAG,SAAS,CAAC;IACtC,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,OAAO;IACT,CAAC;IAED,
|
|
1
|
+
{"version":3,"file":"sortGeneratedConfig.js","sourceRoot":"","sources":["../src/sortGeneratedConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAA0B;IAC5D,MAAM,EAAE,eAAe,EAAE,GAAG,SAAS,CAAC;IACtC,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,OAAO;IACT,CAAC;IAED,oFAAoF;IACpF,eAAe,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAEtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAChD,8DAA8D;QAC9D,MAAM,eAAe,GAAG,eAAe,CAAC,CAAC,CAAwB,CAAC;QAClE,MAAM,gBAAgB,GAGlB;YACF,mEAAmE;YACnE,KAAK,EAAE,eAAe,CAAC,KAAK;SAC7B,CAAC;QAEF,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,EAAwC,EAAE,CAAC;YAC5F,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;gBACpB,mEAAmE;gBACnE,MAAM,KAAK,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;gBACnC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;oBACzB,gBAAgB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;gBACvC,CAAC;qBAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;oBACvD,gBAAgB,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;gBAChD,CAAC;qBAAM,CAAC;oBACN,gBAAgB,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;gBAChC,CAAC;YACH,CAAC;QACH,CAAC;QAED,eAAe,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,gBAAgB,CAAC,CAAC;IACjD,CAAC;AACH,CAAC","sourcesContent":["import type { GeneratedConfig, GeneratedPackageSettings } from '@ms-cloudpack/common-types';\nimport { sortObjectKeys } from './sortObjectKeys.js';\nimport { compareSettings } from './compareSettings.js';\n\n/**\n * Sorts the generated config so that we don't have unneeded changes due to differences in\n * order of operations.\n */\nexport function sortGeneratedConfig(generated: GeneratedConfig) {\n const { packageSettings } = generated;\n if (!packageSettings) {\n return;\n }\n\n // Ensure package settings are sorted based on package name and version requirement.\n packageSettings.sort(compareSettings);\n\n for (let i = 0; i < packageSettings.length; i++) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const originalSetting = packageSettings[i] as Record<string, any>;\n const formattedSetting: {\n match: GeneratedPackageSettings['match'];\n [key: string]: unknown;\n } = {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n match: originalSetting.match,\n };\n\n for (const key of Object.keys(originalSetting).sort() as (keyof GeneratedPackageSettings)[]) {\n if (key !== 'match') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const value = originalSetting[key];\n if (Array.isArray(value)) {\n formattedSetting[key] = value.sort();\n } else if (typeof value === 'object' && value !== null) {\n formattedSetting[key] = sortObjectKeys(value);\n } else {\n formattedSetting[key] = value;\n }\n }\n }\n\n packageSettings.splice(i, 1, formattedSetting);\n }\n}\n"]}
|
|
@@ -16,4 +16,10 @@ export declare const fileHeaderComment = "/**\n * THIS FILE IS AUTO-GENERATED.\n
|
|
|
16
16
|
* - `'no-op'` if the config didn't previously exist and is still empty
|
|
17
17
|
*/
|
|
18
18
|
export declare function writeGeneratedConfig(config: GeneratedConfig, appPath: string): Promise<'written' | 'deleted' | 'no-op'>;
|
|
19
|
+
/**
|
|
20
|
+
* Due to optimization, some package settings may end up with a "match" key but nothing else.
|
|
21
|
+
* These would add useless bloat, so filter them out before writing the generated config.
|
|
22
|
+
* This function removes those settings by mutating the input generated config.
|
|
23
|
+
*/
|
|
24
|
+
export declare function cleanGeneratedConfig(config: GeneratedConfig): void;
|
|
19
25
|
//# sourceMappingURL=writeGeneratedConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeGeneratedConfig.d.ts","sourceRoot":"","sources":["../src/writeGeneratedConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"writeGeneratedConfig.d.ts","sourceRoot":"","sources":["../src/writeGeneratedConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAOlE;;;GAGG;AACH,eAAO,MAAM,iBAAiB,oFAAoF,CAAC;AAEnH;;;;;;;;;;GAUG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC,CAwB1C;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,QAE3D"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { writeJson } from '@ms-cloudpack/json-utilities';
|
|
2
2
|
import fs from 'fs';
|
|
3
|
-
import { cleanGeneratedConfig } from './cleanGeneratedConfig.js';
|
|
4
3
|
import { getConfigPath } from './getConfigPath.js';
|
|
5
4
|
import { generatedAppConfigSchemaUrl } from './schemaUrls.js';
|
|
6
5
|
import { sortGeneratedConfig } from './sortGeneratedConfig.js';
|
|
@@ -37,4 +36,12 @@ export async function writeGeneratedConfig(config, appPath) {
|
|
|
37
36
|
}, { fileHeaderComment });
|
|
38
37
|
return 'written';
|
|
39
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Due to optimization, some package settings may end up with a "match" key but nothing else.
|
|
41
|
+
* These would add useless bloat, so filter them out before writing the generated config.
|
|
42
|
+
* This function removes those settings by mutating the input generated config.
|
|
43
|
+
*/
|
|
44
|
+
export function cleanGeneratedConfig(config) {
|
|
45
|
+
config.packageSettings = config.packageSettings?.filter((s) => Object.keys(s).length > 1);
|
|
46
|
+
}
|
|
40
47
|
//# sourceMappingURL=writeGeneratedConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeGeneratedConfig.js","sourceRoot":"","sources":["../src/writeGeneratedConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"writeGeneratedConfig.js","sourceRoot":"","sources":["../src/writeGeneratedConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,iFAAiF,CAAC;AAEnH;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAAuB,EACvB,OAAe;IAEf,MAAM,EAAE,mBAAmB,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAEvD,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAE5B,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAE7B,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,MAAM,EAAE,CAAC;QACpC,IAAI,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC,EAAE,CAAC;YACvC,EAAE,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC;YACnC,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,SAAS,CACb,mBAAmB,EACnB;QACE,OAAO,EAAE,2BAA2B;QACpC,GAAG,MAAM;KACV,EACD,EAAE,iBAAiB,EAAE,CACtB,CAAC;IACF,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAuB;IAC1D,MAAM,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AAC5F,CAAC","sourcesContent":["import type { GeneratedConfig } from '@ms-cloudpack/common-types';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport fs from 'fs';\nimport { getConfigPath } from './getConfigPath.js';\nimport { generatedAppConfigSchemaUrl } from './schemaUrls.js';\nimport { sortGeneratedConfig } from './sortGeneratedConfig.js';\n\n/**\n * Comment added to the top of the generated file (exported for testing only).\n * @internal\n */\nexport const fileHeaderComment = `/**\\n * THIS FILE IS AUTO-GENERATED.\\n * DO NOT MANUALLY EDIT THIS FILE.\\n */\\n`;\n\n/**\n * Clean up the generated config (sort it and remove empty settings) and write it to\n * cloudpack.generated.json. This is used at the end of `init`.\n *\n * If the config file exists but is no longer needed, it will be deleted.\n *\n * @returns\n * - `'written'` if the config was written\n * - `'deleted'` if the config previously existed but is now empty and was deleted\n * - `'no-op'` if the config didn't previously exist and is still empty\n */\nexport async function writeGeneratedConfig(\n config: GeneratedConfig,\n appPath: string,\n): Promise<'written' | 'deleted' | 'no-op'> {\n const { generatedConfigPath } = getConfigPath(appPath);\n\n sortGeneratedConfig(config);\n\n cleanGeneratedConfig(config);\n\n if (!config.packageSettings?.length) {\n if (fs.existsSync(generatedConfigPath)) {\n fs.unlinkSync(generatedConfigPath);\n return 'deleted';\n }\n return 'no-op';\n }\n\n await writeJson(\n generatedConfigPath,\n {\n $schema: generatedAppConfigSchemaUrl,\n ...config,\n },\n { fileHeaderComment },\n );\n return 'written';\n}\n\n/**\n * Due to optimization, some package settings may end up with a \"match\" key but nothing else.\n * These would add useless bloat, so filter them out before writing the generated config.\n * This function removes those settings by mutating the input generated config.\n */\nexport function cleanGeneratedConfig(config: GeneratedConfig) {\n config.packageSettings = config.packageSettings?.filter((s) => Object.keys(s).length > 1);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"description": "Configuration handling for cloudpack.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@ms-cloudpack/common-types": "^0.
|
|
17
|
+
"@ms-cloudpack/common-types": "^0.18.0",
|
|
18
18
|
"@ms-cloudpack/json-utilities": "^0.1.7",
|
|
19
|
-
"@ms-cloudpack/package-utilities": "^9.0.
|
|
20
|
-
"@ms-cloudpack/path-utilities": "^2.7.
|
|
19
|
+
"@ms-cloudpack/package-utilities": "^9.0.5",
|
|
20
|
+
"@ms-cloudpack/path-utilities": "^2.7.36",
|
|
21
21
|
"import-meta-resolve": "^4.0.0",
|
|
22
22
|
"semver": "^7.6.0"
|
|
23
23
|
},
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { GeneratedConfig } from '@ms-cloudpack/common-types';
|
|
2
|
-
/**
|
|
3
|
-
* Due to optimization, some package settings may end up with a "match" key but nothing else.
|
|
4
|
-
* These would add useless bloat, so filter them out before writing the generated config.
|
|
5
|
-
* This function removes those settings by mutating the input generated config.
|
|
6
|
-
*/
|
|
7
|
-
export declare function cleanGeneratedConfig(config: GeneratedConfig): void;
|
|
8
|
-
//# sourceMappingURL=cleanGeneratedConfig.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cleanGeneratedConfig.d.ts","sourceRoot":"","sources":["../src/cleanGeneratedConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAmB,MAAM,4BAA4B,CAAC;AAEnF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,eAAe,QAE3D"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Due to optimization, some package settings may end up with a "match" key but nothing else.
|
|
3
|
-
* These would add useless bloat, so filter them out before writing the generated config.
|
|
4
|
-
* This function removes those settings by mutating the input generated config.
|
|
5
|
-
*/
|
|
6
|
-
export function cleanGeneratedConfig(config) {
|
|
7
|
-
config.packageSettings = config.packageSettings?.filter(isValidSetting);
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* This function checks if a package setting is valid.
|
|
11
|
-
* This means that it has at least one key other than "match".
|
|
12
|
-
*/
|
|
13
|
-
function isValidSetting(setting) {
|
|
14
|
-
return Object.keys(setting).length > 1 && 'match' in setting;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=cleanGeneratedConfig.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cleanGeneratedConfig.js","sourceRoot":"","sources":["../src/cleanGeneratedConfig.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAuB;IAC1D,MAAM,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC;AAC1E,CAAC;AAED;;;GAGG;AACH,SAAS,cAAc,CAAC,OAAwB;IAC9C,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,IAAI,OAAO,CAAC;AAC/D,CAAC","sourcesContent":["import type { GeneratedConfig, PackageSettings } from '@ms-cloudpack/common-types';\n\n/**\n * Due to optimization, some package settings may end up with a \"match\" key but nothing else.\n * These would add useless bloat, so filter them out before writing the generated config.\n * This function removes those settings by mutating the input generated config.\n */\nexport function cleanGeneratedConfig(config: GeneratedConfig) {\n config.packageSettings = config.packageSettings?.filter(isValidSetting);\n}\n\n/**\n * This function checks if a package setting is valid.\n * This means that it has at least one key other than \"match\".\n */\nfunction isValidSetting(setting: PackageSettings) {\n return Object.keys(setting).length > 1 && 'match' in setting;\n}\n"]}
|