@ms-cloudpack/config 0.7.6 → 0.8.1
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/compareOverrides.d.ts +3 -0
- package/lib/compareOverrides.d.ts.map +1 -0
- package/lib/compareOverrides.js +9 -0
- package/lib/compareOverrides.js.map +1 -0
- package/lib/compareSettings.d.ts +3 -0
- package/lib/compareSettings.d.ts.map +1 -0
- package/lib/compareSettings.js +9 -0
- package/lib/compareSettings.js.map +1 -0
- package/lib/configTemplate.d.ts +2 -13
- package/lib/configTemplate.d.ts.map +1 -1
- package/lib/configTemplate.js +14 -9
- package/lib/configTemplate.js.map +1 -1
- package/lib/constants.d.ts +3 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +3 -0
- package/lib/constants.js.map +1 -0
- package/lib/createPackageDefinitions.d.ts +10 -0
- package/lib/createPackageDefinitions.d.ts.map +1 -0
- package/lib/createPackageDefinitions.js +12 -0
- package/lib/createPackageDefinitions.js.map +1 -0
- package/lib/createPackageOverrideTransform.d.ts +8 -0
- package/lib/createPackageOverrideTransform.d.ts.map +1 -0
- package/lib/createPackageOverrideTransform.js +40 -0
- package/lib/createPackageOverrideTransform.js.map +1 -0
- package/lib/getConfigPath.d.ts +9 -0
- package/lib/getConfigPath.d.ts.map +1 -0
- package/lib/getConfigPath.js +13 -0
- package/lib/getConfigPath.js.map +1 -0
- package/lib/getPackageSettings.d.ts +11 -0
- package/lib/getPackageSettings.d.ts.map +1 -0
- package/lib/getPackageSettings.js +22 -0
- package/lib/getPackageSettings.js.map +1 -0
- package/lib/index.d.ts +11 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +9 -1
- package/lib/index.js.map +1 -1
- package/lib/mergePackageSettings.d.ts +6 -0
- package/lib/mergePackageSettings.d.ts.map +1 -0
- package/lib/mergePackageSettings.js +45 -0
- package/lib/mergePackageSettings.js.map +1 -0
- package/lib/processConfig.d.ts +6 -0
- package/lib/processConfig.d.ts.map +1 -0
- package/lib/processConfig.js +21 -0
- package/lib/processConfig.js.map +1 -0
- package/lib/readConfig.d.ts +6 -0
- package/lib/readConfig.d.ts.map +1 -0
- package/lib/readConfig.js +19 -0
- package/lib/readConfig.js.map +1 -0
- package/lib/readGeneratedConfig.d.ts +7 -0
- package/lib/readGeneratedConfig.d.ts.map +1 -0
- package/lib/readGeneratedConfig.js +11 -0
- package/lib/readGeneratedConfig.js.map +1 -0
- package/lib/readUserConfig.d.ts +7 -0
- package/lib/readUserConfig.d.ts.map +1 -0
- package/lib/readUserConfig.js +11 -0
- package/lib/readUserConfig.js.map +1 -0
- package/lib/types/GeneratedConfig.d.ts +8 -0
- package/lib/types/GeneratedConfig.d.ts.map +1 -1
- package/lib/types/GeneratedConfig.js.map +1 -1
- package/lib/types/PackageSettings.d.ts +50 -0
- package/lib/types/PackageSettings.d.ts.map +1 -0
- package/lib/types/PackageSettings.js +2 -0
- package/lib/types/PackageSettings.js.map +1 -0
- package/lib/types/UserConfig.d.ts +5 -0
- package/lib/types/UserConfig.d.ts.map +1 -1
- package/lib/types/UserConfig.js.map +1 -1
- package/lib/writeGeneratedConfig.d.ts +6 -0
- package/lib/writeGeneratedConfig.d.ts.map +1 -0
- package/lib/writeGeneratedConfig.js +21 -0
- package/lib/writeGeneratedConfig.js.map +1 -0
- package/lib/writeUserConfig.d.ts +7 -0
- package/lib/writeUserConfig.d.ts.map +1 -0
- package/lib/writeUserConfig.js +11 -0
- package/lib/writeUserConfig.js.map +1 -0
- package/package.json +11 -6
- package/lib/config.d.ts +0 -31
- package/lib/config.d.ts.map +0 -1
- package/lib/config.js +0 -60
- package/lib/config.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compareOverrides.d.ts","sourceRoot":"","sources":["../src/compareOverrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,GAAG,MAAM,CAS/E"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function compareOverrides(a, b) {
|
|
2
|
+
const { name: aName = '', versionRequirement: aVersion = '*' } = a;
|
|
3
|
+
const { name: bName = '', versionRequirement: bVersion = '*' } = b;
|
|
4
|
+
if (aName === bName) {
|
|
5
|
+
return aVersion.localeCompare(bVersion);
|
|
6
|
+
}
|
|
7
|
+
return aName.localeCompare(bName);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=compareOverrides.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compareOverrides.js","sourceRoot":"","sources":["../src/compareOverrides.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB,CAAC,CAAkB,EAAE,CAAkB;IACrE,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,EAAE,EAAE,kBAAkB,EAAE,QAAQ,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC;IACnE,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,EAAE,EAAE,kBAAkB,EAAE,QAAQ,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC;IAEnE,IAAI,KAAK,KAAK,KAAK,EAAE;QACnB,OAAO,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;KACzC;IAED,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC","sourcesContent":["import type { PackageOverride } from './index.js';\n\nexport function compareOverrides(a: PackageOverride, b: PackageOverride): number {\n const { name: aName = '', versionRequirement: aVersion = '*' } = a;\n const { name: bName = '', versionRequirement: bVersion = '*' } = b;\n\n if (aName === bName) {\n return aVersion.localeCompare(bVersion);\n }\n\n return aName.localeCompare(bName);\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compareSettings.d.ts","sourceRoot":"","sources":["../src/compareSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,wBAAgB,eAAe,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,GAAG,MAAM,CAS9E"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function compareSettings(a, b) {
|
|
2
|
+
const { name: aName = '', version: aVersion = '*' } = a.match || {};
|
|
3
|
+
const { name: bName = '', version: bVersion = '*' } = b.match || {};
|
|
4
|
+
if (aName === bName) {
|
|
5
|
+
return aVersion.localeCompare(bVersion);
|
|
6
|
+
}
|
|
7
|
+
return aName.localeCompare(bName);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=compareSettings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compareSettings.js","sourceRoot":"","sources":["../src/compareSettings.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,eAAe,CAAC,CAAkB,EAAE,CAAkB;IACpE,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,EAAE,EAAE,OAAO,EAAE,QAAQ,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;IACpE,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,EAAE,EAAE,OAAO,EAAE,QAAQ,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;IAEpE,IAAI,KAAK,KAAK,KAAK,EAAE;QACnB,OAAO,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;KACzC;IAED,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC","sourcesContent":["import type { PackageSettings } from './types/PackageSettings.js';\n\nexport function compareSettings(a: PackageSettings, b: PackageSettings): number {\n const { name: aName = '', version: aVersion = '*' } = a.match || {};\n const { name: bName = '', version: bVersion = '*' } = b.match || {};\n\n if (aName === bName) {\n return aVersion.localeCompare(bVersion);\n }\n\n return aName.localeCompare(bName);\n}\n"]}
|
package/lib/configTemplate.d.ts
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
name: string;
|
|
4
|
-
versionRequirement: string;
|
|
5
|
-
overrides: {
|
|
6
|
-
exports: {
|
|
7
|
-
'.': string;
|
|
8
|
-
'./path': string;
|
|
9
|
-
'./other-path': string;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
}[];
|
|
13
|
-
};
|
|
1
|
+
import type { UserConfig } from './types/UserConfig.js';
|
|
2
|
+
export declare const configTemplate: UserConfig;
|
|
14
3
|
//# sourceMappingURL=configTemplate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configTemplate.d.ts","sourceRoot":"","sources":["../src/configTemplate.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"configTemplate.d.ts","sourceRoot":"","sources":["../src/configTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,eAAO,MAAM,cAAc,EAAE,UAuB5B,CAAC"}
|
package/lib/configTemplate.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
export const configTemplate = {
|
|
2
|
-
|
|
2
|
+
packageSettings: [
|
|
3
3
|
{
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports: {
|
|
8
|
-
'.': './index.js',
|
|
9
|
-
'./path': './path.js',
|
|
10
|
-
'./other-path': './other-path.js',
|
|
11
|
-
},
|
|
4
|
+
match: {
|
|
5
|
+
name: 'package-name',
|
|
6
|
+
version: '*',
|
|
12
7
|
},
|
|
8
|
+
exports: {
|
|
9
|
+
'.': './index.js',
|
|
10
|
+
'./path': './path.js',
|
|
11
|
+
'./other-path': './other-path.js',
|
|
12
|
+
},
|
|
13
|
+
inlinedDependencies: [],
|
|
14
|
+
includedDependencies: [],
|
|
15
|
+
excludedDependencies: [],
|
|
16
|
+
bundlerType: undefined,
|
|
17
|
+
bundlerOptions: undefined,
|
|
13
18
|
},
|
|
14
19
|
],
|
|
15
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configTemplate.js","sourceRoot":"","sources":["../src/configTemplate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"configTemplate.js","sourceRoot":"","sources":["../src/configTemplate.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,cAAc,GAAe;IACxC,eAAe,EAAE;QACf;YACE,KAAK,EAAE;gBACL,IAAI,EAAE,cAAc;gBACpB,OAAO,EAAE,GAAG;aACb;YAED,OAAO,EAAE;gBACP,GAAG,EAAE,YAAY;gBACjB,QAAQ,EAAE,WAAW;gBACrB,cAAc,EAAE,iBAAiB;aAClC;YAED,mBAAmB,EAAE,EAAE;YAEvB,oBAAoB,EAAE,EAAE;YACxB,oBAAoB,EAAE,EAAE;YAExB,WAAW,EAAE,SAAS;YACtB,cAAc,EAAE,SAAS;SAC1B;KACF;CACF,CAAC","sourcesContent":["import type { UserConfig } from './types/UserConfig.js';\n\nexport const configTemplate: UserConfig = {\n packageSettings: [\n {\n match: {\n name: 'package-name',\n version: '*',\n },\n\n exports: {\n '.': './index.js',\n './path': './path.js',\n './other-path': './other-path.js',\n },\n\n inlinedDependencies: [],\n\n includedDependencies: [],\n excludedDependencies: [],\n\n bundlerType: undefined,\n bundlerOptions: undefined,\n },\n ],\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,0BAA0B,CAAC;AAC1D,eAAO,MAAM,uBAAuB,6BAA6B,CAAC"}
|
package/lib/constants.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;AAC1D,MAAM,CAAC,MAAM,uBAAuB,GAAG,0BAA0B,CAAC","sourcesContent":["export const userConfigFileName = 'cloudpack.config.json';\nexport const generatedConfigFileName = 'cloudpack.generated.json';\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
|
|
2
|
+
import type { CloudpackConfig } from './types/CloudpackConfig.js';
|
|
3
|
+
/**
|
|
4
|
+
* Given a Cloudpack config, create a package definitions cache with transforms resulting from settings defined
|
|
5
|
+
* within the config.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createPackageDefinitions({ config }: {
|
|
8
|
+
config: CloudpackConfig;
|
|
9
|
+
}): PackageDefinitionsCache;
|
|
10
|
+
//# sourceMappingURL=createPackageDefinitions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPackageDefinitions.d.ts","sourceRoot":"","sources":["../src/createPackageDefinitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAG3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,eAAe,CAAA;CAAE,GAAG,uBAAuB,CAMzG"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PackageDefinitions } from '@ms-cloudpack/package-utilities';
|
|
2
|
+
import { createPackageOverrideTransform } from './createPackageOverrideTransform.js';
|
|
3
|
+
/**
|
|
4
|
+
* Given a Cloudpack config, create a package definitions cache with transforms resulting from settings defined
|
|
5
|
+
* within the config.
|
|
6
|
+
*/
|
|
7
|
+
export function createPackageDefinitions({ config }) {
|
|
8
|
+
const packages = new PackageDefinitions(undefined, config);
|
|
9
|
+
packages.registerTransform((newConfig) => createPackageOverrideTransform(newConfig));
|
|
10
|
+
return packages;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=createPackageDefinitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPackageDefinitions.js","sourceRoot":"","sources":["../src/createPackageDefinitions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAGrF;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,EAAE,MAAM,EAA+B;IAC9E,MAAM,QAAQ,GAAG,IAAI,kBAAkB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAE3D,QAAQ,CAAC,iBAAiB,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,8BAA8B,CAAC,SAA4B,CAAC,CAAC,CAAC;IAExG,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport { PackageDefinitions } from '@ms-cloudpack/package-utilities';\nimport { createPackageOverrideTransform } from './createPackageOverrideTransform.js';\nimport type { CloudpackConfig } from './types/CloudpackConfig.js';\n\n/**\n * Given a Cloudpack config, create a package definitions cache with transforms resulting from settings defined\n * within the config.\n */\nexport function createPackageDefinitions({ config }: { config: CloudpackConfig }): PackageDefinitionsCache {\n const packages = new PackageDefinitions(undefined, config);\n\n packages.registerTransform((newConfig) => createPackageOverrideTransform(newConfig as CloudpackConfig));\n\n return packages;\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PackageDefinitionTransform } from '@ms-cloudpack/bundler-types';
|
|
2
|
+
import type { CloudpackConfig } from '@ms-cloudpack/config';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a transform to be registered with a PackageDefinitions registry for applying overrides to from the config
|
|
5
|
+
* to package.json definitions.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createPackageOverrideTransform(config: CloudpackConfig): PackageDefinitionTransform;
|
|
8
|
+
//# sourceMappingURL=createPackageOverrideTransform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPackageOverrideTransform.d.ts","sourceRoot":"","sources":["../src/createPackageOverrideTransform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAe,MAAM,6BAA6B,CAAC;AAC3F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,eAAe,GAAG,0BAA0B,CA4ClG"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { getPackageSettings } from './getPackageSettings.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a transform to be registered with a PackageDefinitions registry for applying overrides to from the config
|
|
4
|
+
* to package.json definitions.
|
|
5
|
+
*/
|
|
6
|
+
export function createPackageOverrideTransform(config) {
|
|
7
|
+
return (packageDefinition) => {
|
|
8
|
+
const { name = '', version = '' } = packageDefinition;
|
|
9
|
+
const packageSettings = getPackageSettings({ name, version, config });
|
|
10
|
+
if (!packageSettings) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const result = { ...packageDefinition };
|
|
14
|
+
// If we have a custom exports map for the package, apply it.
|
|
15
|
+
if (packageSettings.exports) {
|
|
16
|
+
result.exports = packageSettings.exports;
|
|
17
|
+
}
|
|
18
|
+
// If we have included dependencies, add them.
|
|
19
|
+
if (packageSettings.includedDependencies?.length) {
|
|
20
|
+
for (const dep of packageSettings.includedDependencies) {
|
|
21
|
+
if (!result.dependencies?.[dep]) {
|
|
22
|
+
// Initialize dependencies map if it doesn't exist.
|
|
23
|
+
result.dependencies ??= {};
|
|
24
|
+
// Add the dependency from other sources, or use a wildcard.
|
|
25
|
+
result.dependencies[dep] =
|
|
26
|
+
result.devDependencies?.[dep] ||
|
|
27
|
+
result.peerDependencies?.[dep] ||
|
|
28
|
+
result.optionalDependencies?.[dep] ||
|
|
29
|
+
'*';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// If we have excluded dependencies, remove them.
|
|
34
|
+
if (packageSettings.excludedDependencies?.length) {
|
|
35
|
+
result.dependencies = Object.fromEntries(Object.entries(result.dependencies || {}).filter(([dep]) => !packageSettings.excludedDependencies?.includes(dep)));
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=createPackageOverrideTransform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPackageOverrideTransform.js","sourceRoot":"","sources":["../src/createPackageOverrideTransform.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAAC,MAAuB;IACpE,OAAO,CAAC,iBAA8B,EAAE,EAAE;QACxC,MAAM,EAAE,IAAI,GAAG,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,iBAAiB,CAAC;QACtD,MAAM,eAAe,GAAG,kBAAkB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QAEtE,IAAI,CAAC,eAAe,EAAE;YACpB,OAAO,SAAS,CAAC;SAClB;QAED,MAAM,MAAM,GAAG,EAAE,GAAG,iBAAiB,EAAE,CAAC;QAExC,6DAA6D;QAC7D,IAAI,eAAe,CAAC,OAAO,EAAE;YAC3B,MAAM,CAAC,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC;SAC1C;QAED,8CAA8C;QAC9C,IAAI,eAAe,CAAC,oBAAoB,EAAE,MAAM,EAAE;YAChD,KAAK,MAAM,GAAG,IAAI,eAAe,CAAC,oBAAoB,EAAE;gBACtD,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC,EAAE;oBAC/B,mDAAmD;oBACnD,MAAM,CAAC,YAAY,KAAK,EAAE,CAAC;oBAE3B,4DAA4D;oBAC5D,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC;wBACtB,MAAM,CAAC,eAAe,EAAE,CAAC,GAAG,CAAC;4BAC7B,MAAM,CAAC,gBAAgB,EAAE,CAAC,GAAG,CAAC;4BAC9B,MAAM,CAAC,oBAAoB,EAAE,CAAC,GAAG,CAAC;4BAClC,GAAG,CAAC;iBACP;aACF;SACF;QAED,iDAAiD;QACjD,IAAI,eAAe,CAAC,oBAAoB,EAAE,MAAM,EAAE;YAChD,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,CACtC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,MAAM,CAC9C,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,eAAe,CAAC,oBAAoB,EAAE,QAAQ,CAAC,GAAG,CAAC,CAChE,CACF,CAAC;SACH;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { PackageDefinitionTransform, PackageJson } from '@ms-cloudpack/bundler-types';\nimport type { CloudpackConfig } from '@ms-cloudpack/config';\nimport { getPackageSettings } from './getPackageSettings.js';\n\n/**\n * Creates a transform to be registered with a PackageDefinitions registry for applying overrides to from the config\n * to package.json definitions.\n */\nexport function createPackageOverrideTransform(config: CloudpackConfig): PackageDefinitionTransform {\n return (packageDefinition: PackageJson) => {\n const { name = '', version = '' } = packageDefinition;\n const packageSettings = getPackageSettings({ name, version, config });\n\n if (!packageSettings) {\n return undefined;\n }\n\n const result = { ...packageDefinition };\n\n // If we have a custom exports map for the package, apply it.\n if (packageSettings.exports) {\n result.exports = packageSettings.exports;\n }\n\n // If we have included dependencies, add them.\n if (packageSettings.includedDependencies?.length) {\n for (const dep of packageSettings.includedDependencies) {\n if (!result.dependencies?.[dep]) {\n // Initialize dependencies map if it doesn't exist.\n result.dependencies ??= {};\n\n // Add the dependency from other sources, or use a wildcard.\n result.dependencies[dep] =\n result.devDependencies?.[dep] ||\n result.peerDependencies?.[dep] ||\n result.optionalDependencies?.[dep] ||\n '*';\n }\n }\n }\n\n // If we have excluded dependencies, remove them.\n if (packageSettings.excludedDependencies?.length) {\n result.dependencies = Object.fromEntries(\n Object.entries(result.dependencies || {}).filter(\n ([dep]) => !packageSettings.excludedDependencies?.includes(dep),\n ),\n );\n }\n\n return result;\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getConfigPath.d.ts","sourceRoot":"","sources":["../src/getConfigPath.ts"],"names":[],"mappings":"AAGA;;;GAGG;AAEH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM;;;EAKxC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { userConfigFileName, generatedConfigFileName } from './constants.js';
|
|
3
|
+
/**
|
|
4
|
+
* @param cwd - base path of the config file
|
|
5
|
+
* @returns the path of the config file
|
|
6
|
+
*/
|
|
7
|
+
export function getConfigPath(cwd) {
|
|
8
|
+
return {
|
|
9
|
+
userConfigPath: path.join(cwd, userConfigFileName),
|
|
10
|
+
generatedConfigPath: path.join(cwd, generatedConfigFileName),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=getConfigPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getConfigPath.js","sourceRoot":"","sources":["../src/getConfigPath.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAE7E;;;GAGG;AAEH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,OAAO;QACL,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,kBAAkB,CAAC;QAClD,mBAAmB,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,uBAAuB,CAAC;KAC7D,CAAC;AACJ,CAAC","sourcesContent":["import path from 'path';\nimport { userConfigFileName, generatedConfigFileName } from './constants.js';\n\n/**\n * @param cwd - base path of the config file\n * @returns the path of the config file\n */\n\nexport function getConfigPath(cwd: string) {\n return {\n userConfigPath: path.join(cwd, userConfigFileName),\n generatedConfigPath: path.join(cwd, generatedConfigFileName),\n };\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CloudpackConfig } from './types/CloudpackConfig.js';
|
|
2
|
+
import type { PackageSettings } from './types/PackageSettings.js';
|
|
3
|
+
/**
|
|
4
|
+
* Gets the single set of package settings for a given package using the given config.
|
|
5
|
+
*/
|
|
6
|
+
export declare function getPackageSettings({ name, version, config, }: {
|
|
7
|
+
name: string;
|
|
8
|
+
version: string;
|
|
9
|
+
config: CloudpackConfig;
|
|
10
|
+
}): PackageSettings | undefined;
|
|
11
|
+
//# sourceMappingURL=getPackageSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPackageSettings.d.ts","sourceRoot":"","sources":["../src/getPackageSettings.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,IAAI,EACJ,OAAO,EACP,MAAM,GACP,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,eAAe,CAAC;CACzB,GAAG,eAAe,GAAG,SAAS,CAoB9B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { satisfies } from 'semver';
|
|
2
|
+
import { mergePackageSettings } from './mergePackageSettings.js';
|
|
3
|
+
/**
|
|
4
|
+
* Gets the single set of package settings for a given package using the given config.
|
|
5
|
+
*/
|
|
6
|
+
export function getPackageSettings({ name, version, config, }) {
|
|
7
|
+
const { packageSettings = [] } = config;
|
|
8
|
+
if (!packageSettings.length) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
const matchedSettings = packageSettings.filter(({ match }) => {
|
|
12
|
+
if (match?.name === name) {
|
|
13
|
+
return !match.version || satisfies(version, match.version);
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
});
|
|
17
|
+
if (!matchedSettings.length) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
return mergePackageSettings(matchedSettings);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=getPackageSettings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPackageSettings.js","sourceRoot":"","sources":["../src/getPackageSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAIjE;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,EACjC,IAAI,EACJ,OAAO,EACP,MAAM,GAKP;IACC,MAAM,EAAE,eAAe,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC;IAExC,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE;QAC3B,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,eAAe,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;QAC3D,IAAI,KAAK,EAAE,IAAI,KAAK,IAAI,EAAE;YACxB,OAAO,CAAC,KAAK,CAAC,OAAO,IAAI,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;SAC5D;QAED,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE;QAC3B,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,oBAAoB,CAAC,eAAe,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import { satisfies } from 'semver';\nimport { mergePackageSettings } from './mergePackageSettings.js';\nimport type { CloudpackConfig } from './types/CloudpackConfig.js';\nimport type { PackageSettings } from './types/PackageSettings.js';\n\n/**\n * Gets the single set of package settings for a given package using the given config.\n */\nexport function getPackageSettings({\n name,\n version,\n config,\n}: {\n name: string;\n version: string;\n config: CloudpackConfig;\n}): PackageSettings | undefined {\n const { packageSettings = [] } = config;\n\n if (!packageSettings.length) {\n return undefined;\n }\n\n const matchedSettings = packageSettings.filter(({ match }) => {\n if (match?.name === name) {\n return !match.version || satisfies(version, match.version);\n }\n\n return false;\n });\n\n if (!matchedSettings.length) {\n return undefined;\n }\n\n return mergePackageSettings(matchedSettings);\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
export { allFeatures } from './allFeatures.js';
|
|
2
|
-
export { configFileName, generatedConfigFileName, getConfigPath, readConfig, readConfigSync, writeGeneratedConfig, } from './config.js';
|
|
3
2
|
export { configTemplate } from './configTemplate.js';
|
|
4
|
-
export
|
|
3
|
+
export { generatedConfigFileName, userConfigFileName } from './constants.js';
|
|
4
|
+
export { createPackageDefinitions } from './createPackageDefinitions.js';
|
|
5
|
+
export { getConfigPath } from './getConfigPath.js';
|
|
6
|
+
export { getPackageSettings } from './getPackageSettings.js';
|
|
7
|
+
export { readConfig } from './readConfig.js';
|
|
8
|
+
export { readGeneratedConfig } from './readGeneratedConfig.js';
|
|
9
|
+
export { readUserConfig } from './readUserConfig.js';
|
|
5
10
|
export type { CloudpackConfig } from './types/CloudpackConfig.js';
|
|
6
11
|
export type { DevServer } from './types/DevServer.js';
|
|
12
|
+
export type { Feature } from './types/Feature.js';
|
|
7
13
|
export type { Features } from './types/Features.js';
|
|
8
14
|
export type { GeneratedConfig } from './types/GeneratedConfig.js';
|
|
9
15
|
export type { PackageOverride } from './types/PackageOverride.js';
|
|
16
|
+
export type { PackageSettings } from './types/PackageSettings.js';
|
|
10
17
|
export type { Route } from './types/Route.js';
|
|
11
18
|
export type { TelemetryConfig } from './types/TelemetryConfig.js';
|
|
12
19
|
export type { UserConfig } from './types/UserConfig.js';
|
|
20
|
+
export { writeGeneratedConfig } from './writeGeneratedConfig.js';
|
|
21
|
+
export { writeUserConfig } from './writeUserConfig.js';
|
|
13
22
|
//# sourceMappingURL=index.d.ts.map
|
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,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,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,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,YAAY,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,YAAY,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,YAAY,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
export { allFeatures } from './allFeatures.js';
|
|
2
|
-
export { configFileName, generatedConfigFileName, getConfigPath, readConfig, readConfigSync, writeGeneratedConfig, } from './config.js';
|
|
3
2
|
export { configTemplate } from './configTemplate.js';
|
|
3
|
+
export { generatedConfigFileName, userConfigFileName } from './constants.js';
|
|
4
|
+
export { createPackageDefinitions } from './createPackageDefinitions.js';
|
|
5
|
+
export { getConfigPath } from './getConfigPath.js';
|
|
6
|
+
export { getPackageSettings } from './getPackageSettings.js';
|
|
7
|
+
export { readConfig } from './readConfig.js';
|
|
8
|
+
export { readGeneratedConfig } from './readGeneratedConfig.js';
|
|
9
|
+
export { readUserConfig } from './readUserConfig.js';
|
|
10
|
+
export { writeGeneratedConfig } from './writeGeneratedConfig.js';
|
|
11
|
+
export { writeUserConfig } from './writeUserConfig.js';
|
|
4
12
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAC7E,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,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAWrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["export { allFeatures } from './allFeatures.js';\nexport { configTemplate } from './configTemplate.js';\nexport { generatedConfigFileName, userConfigFileName } 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 { readUserConfig } from './readUserConfig.js';\nexport type { CloudpackConfig } from './types/CloudpackConfig.js';\nexport type { DevServer } from './types/DevServer.js';\nexport type { Feature } from './types/Feature.js';\nexport type { Features } from './types/Features.js';\nexport type { GeneratedConfig } from './types/GeneratedConfig.js';\nexport type { PackageOverride } from './types/PackageOverride.js';\nexport type { PackageSettings } from './types/PackageSettings.js';\nexport type { Route } from './types/Route.js';\nexport type { TelemetryConfig } from './types/TelemetryConfig.js';\nexport type { UserConfig } from './types/UserConfig.js';\nexport { writeGeneratedConfig } from './writeGeneratedConfig.js';\nexport { writeUserConfig } from './writeUserConfig.js';\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PackageSettings } from './types/PackageSettings.js';
|
|
2
|
+
/**
|
|
3
|
+
* Merges package settings together. Takes care to merge exports maps correctly.
|
|
4
|
+
*/
|
|
5
|
+
export declare function mergePackageSettings(settings: PackageSettings[]): PackageSettings;
|
|
6
|
+
//# sourceMappingURL=mergePackageSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergePackageSettings.d.ts","sourceRoot":"","sources":["../src/mergePackageSettings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,eAAe,CA+CjF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merges package settings together. Takes care to merge exports maps correctly.
|
|
3
|
+
*/
|
|
4
|
+
export function mergePackageSettings(settings) {
|
|
5
|
+
const result = settings.reduce((acc, setting) => {
|
|
6
|
+
const { exports } = setting;
|
|
7
|
+
if (exports) {
|
|
8
|
+
// If we don't have any exports yet, just set it.
|
|
9
|
+
if (!acc.exports) {
|
|
10
|
+
acc.exports = exports;
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
// If we have an exports but it's not an array, make it an array.
|
|
14
|
+
if (!Array.isArray(acc.exports)) {
|
|
15
|
+
acc.exports = [acc.exports];
|
|
16
|
+
}
|
|
17
|
+
// If the accumulated exports is an array, expand the array to `push`; else push the single item.
|
|
18
|
+
if (Array.isArray(exports)) {
|
|
19
|
+
acc.exports.push(...exports);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
acc.exports.push(exports);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (setting.includedDependencies) {
|
|
27
|
+
acc.includedDependencies = [...(acc.includedDependencies || []), ...setting.includedDependencies];
|
|
28
|
+
}
|
|
29
|
+
if (setting.excludedDependencies) {
|
|
30
|
+
acc.excludedDependencies = [...(acc.excludedDependencies || []), ...setting.excludedDependencies];
|
|
31
|
+
}
|
|
32
|
+
if (setting.inlinedDependencies) {
|
|
33
|
+
acc.inlinedDependencies = [...(acc.inlinedDependencies || []), ...setting.inlinedDependencies];
|
|
34
|
+
}
|
|
35
|
+
if (setting.bundlerType) {
|
|
36
|
+
acc.bundlerType = setting.bundlerType;
|
|
37
|
+
}
|
|
38
|
+
if (setting.bundlerOptions) {
|
|
39
|
+
acc.bundlerOptions = setting.bundlerOptions;
|
|
40
|
+
}
|
|
41
|
+
return acc;
|
|
42
|
+
}, {});
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=mergePackageSettings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergePackageSettings.js","sourceRoot":"","sources":["../src/mergePackageSettings.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAA2B;IAC9D,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;QAC9C,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;QAE5B,IAAI,OAAO,EAAE;YACX,iDAAiD;YACjD,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;gBAChB,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;aACvB;iBAAM;gBACL,iEAAiE;gBACjE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;oBAC/B,GAAG,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;iBAC7B;gBAED,iGAAiG;gBACjG,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;oBACzB,GAAG,CAAC,OAAgC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC;iBACxD;qBAAM;oBACJ,GAAG,CAAC,OAAgC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;iBACrD;aACF;SACF;QAED,IAAI,OAAO,CAAC,oBAAoB,EAAE;YAChC,GAAG,CAAC,oBAAoB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,oBAAoB,IAAI,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;SACnG;QAED,IAAI,OAAO,CAAC,oBAAoB,EAAE;YAChC,GAAG,CAAC,oBAAoB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,oBAAoB,IAAI,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;SACnG;QAED,IAAI,OAAO,CAAC,mBAAmB,EAAE;YAC/B,GAAG,CAAC,mBAAmB,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,mBAAmB,IAAI,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;SAChG;QAED,IAAI,OAAO,CAAC,WAAW,EAAE;YACvB,GAAG,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;SACvC;QAED,IAAI,OAAO,CAAC,cAAc,EAAE;YAC1B,GAAG,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;SAC7C;QAED,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAqB,CAAC,CAAC;IAE1B,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { PackageJsonExports } from '@ms-cloudpack/bundler-types';\nimport type { PackageSettings } from './types/PackageSettings.js';\n\n/**\n * Merges package settings together. Takes care to merge exports maps correctly.\n */\nexport function mergePackageSettings(settings: PackageSettings[]): PackageSettings {\n const result = settings.reduce((acc, setting) => {\n const { exports } = setting;\n\n if (exports) {\n // If we don't have any exports yet, just set it.\n if (!acc.exports) {\n acc.exports = exports;\n } else {\n // If we have an exports but it's not an array, make it an array.\n if (!Array.isArray(acc.exports)) {\n acc.exports = [acc.exports];\n }\n\n // If the accumulated exports is an array, expand the array to `push`; else push the single item.\n if (Array.isArray(exports)) {\n (acc.exports as PackageJsonExports[]).push(...exports);\n } else {\n (acc.exports as PackageJsonExports[]).push(exports);\n }\n }\n }\n\n if (setting.includedDependencies) {\n acc.includedDependencies = [...(acc.includedDependencies || []), ...setting.includedDependencies];\n }\n\n if (setting.excludedDependencies) {\n acc.excludedDependencies = [...(acc.excludedDependencies || []), ...setting.excludedDependencies];\n }\n\n if (setting.inlinedDependencies) {\n acc.inlinedDependencies = [...(acc.inlinedDependencies || []), ...setting.inlinedDependencies];\n }\n\n if (setting.bundlerType) {\n acc.bundlerType = setting.bundlerType;\n }\n\n if (setting.bundlerOptions) {\n acc.bundlerOptions = setting.bundlerOptions;\n }\n\n return acc;\n }, {} as PackageSettings);\n\n return result;\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CloudpackConfig } from './types/CloudpackConfig.js';
|
|
2
|
+
/**
|
|
3
|
+
* An internal function for processing a config object after reading the json values.
|
|
4
|
+
*/
|
|
5
|
+
export declare function processConfig(config: CloudpackConfig): void;
|
|
6
|
+
//# sourceMappingURL=processConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processConfig.d.ts","sourceRoot":"","sources":["../src/processConfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,QAmBpD"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An internal function for processing a config object after reading the json values.
|
|
3
|
+
*/
|
|
4
|
+
export function processConfig(config) {
|
|
5
|
+
// eslint-disable-next-line etc/no-deprecated
|
|
6
|
+
const { packageOverrides } = config;
|
|
7
|
+
// Convert package overrides into settings to preserve the deprecated support.
|
|
8
|
+
if (packageOverrides) {
|
|
9
|
+
config.packageSettings = config.packageSettings || [];
|
|
10
|
+
for (const override of packageOverrides || []) {
|
|
11
|
+
const settings = {
|
|
12
|
+
match: { name: override.name, version: override.versionRequirement },
|
|
13
|
+
exports: override.overrides.exports,
|
|
14
|
+
};
|
|
15
|
+
config.packageSettings.push(settings);
|
|
16
|
+
}
|
|
17
|
+
// eslint-disable-next-line etc/no-deprecated
|
|
18
|
+
delete config.packageOverrides;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=processConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"processConfig.js","sourceRoot":"","sources":["../src/processConfig.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,MAAuB;IACnD,6CAA6C;IAC7C,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAAC;IAEpC,8EAA8E;IAC9E,IAAI,gBAAgB,EAAE;QACpB,MAAM,CAAC,eAAe,GAAG,MAAM,CAAC,eAAe,IAAI,EAAE,CAAC;QAEtD,KAAK,MAAM,QAAQ,IAAI,gBAAgB,IAAI,EAAE,EAAE;YAC7C,MAAM,QAAQ,GAAoB;gBAChC,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,kBAAkB,EAAE;gBACpE,OAAO,EAAE,QAAQ,CAAC,SAAS,CAAC,OAAO;aACpC,CAAC;YACF,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACvC;QAED,6CAA6C;QAC7C,OAAO,MAAM,CAAC,gBAAgB,CAAC;KAChC;AACH,CAAC","sourcesContent":["import type { PackageSettings } from './index.js';\nimport type { CloudpackConfig } from './types/CloudpackConfig.js';\n\n/**\n * An internal function for processing a config object after reading the json values.\n */\nexport function processConfig(config: CloudpackConfig) {\n // eslint-disable-next-line etc/no-deprecated\n const { packageOverrides } = config;\n\n // Convert package overrides into settings to preserve the deprecated support.\n if (packageOverrides) {\n config.packageSettings = config.packageSettings || [];\n\n for (const override of packageOverrides || []) {\n const settings: PackageSettings = {\n match: { name: override.name, version: override.versionRequirement },\n exports: override.overrides.exports,\n };\n config.packageSettings.push(settings);\n }\n\n // eslint-disable-next-line etc/no-deprecated\n delete config.packageOverrides;\n }\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CloudpackConfig } from './types/CloudpackConfig.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reads the config file asynchronously (and merges generated config into the result.)
|
|
4
|
+
*/
|
|
5
|
+
export declare function readConfig(appPath: string): Promise<CloudpackConfig>;
|
|
6
|
+
//# sourceMappingURL=readConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readConfig.d.ts","sourceRoot":"","sources":["../src/readConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAKlE;;GAEG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAc1E"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { processConfig } from './processConfig.js';
|
|
2
|
+
import { readUserConfig } from './readUserConfig.js';
|
|
3
|
+
import { readGeneratedConfig } from './readGeneratedConfig.js';
|
|
4
|
+
/**
|
|
5
|
+
* Reads the config file asynchronously (and merges generated config into the result.)
|
|
6
|
+
*/
|
|
7
|
+
export async function readConfig(appPath) {
|
|
8
|
+
const [userConfig, generatedConfig] = await Promise.all([readUserConfig(appPath), readGeneratedConfig(appPath)]);
|
|
9
|
+
const config = {
|
|
10
|
+
...generatedConfig,
|
|
11
|
+
...userConfig,
|
|
12
|
+
};
|
|
13
|
+
if (userConfig.packageSettings || generatedConfig.packageSettings) {
|
|
14
|
+
config.packageSettings = [...(userConfig.packageSettings || []), ...(generatedConfig.packageSettings || [])];
|
|
15
|
+
}
|
|
16
|
+
processConfig(config);
|
|
17
|
+
return config;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=readConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readConfig.js","sourceRoot":"","sources":["../src/readConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAe;IAC9C,MAAM,CAAC,UAAU,EAAE,eAAe,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACjH,MAAM,MAAM,GAAoB;QAC9B,GAAG,eAAe;QAClB,GAAG,UAAU;KACd,CAAC;IAEF,IAAI,UAAU,CAAC,eAAe,IAAI,eAAe,CAAC,eAAe,EAAE;QACjE,MAAM,CAAC,eAAe,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,eAAe,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,eAAe,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC,CAAC;KAC9G;IAED,aAAa,CAAC,MAAM,CAAC,CAAC;IAEtB,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { CloudpackConfig } from './types/CloudpackConfig.js';\nimport { processConfig } from './processConfig.js';\nimport { readUserConfig } from './readUserConfig.js';\nimport { readGeneratedConfig } from './readGeneratedConfig.js';\n\n/**\n * Reads the config file asynchronously (and merges generated config into the result.)\n */\nexport async function readConfig(appPath: string): Promise<CloudpackConfig> {\n const [userConfig, generatedConfig] = await Promise.all([readUserConfig(appPath), readGeneratedConfig(appPath)]);\n const config: CloudpackConfig = {\n ...generatedConfig,\n ...userConfig,\n };\n\n if (userConfig.packageSettings || generatedConfig.packageSettings) {\n config.packageSettings = [...(userConfig.packageSettings || []), ...(generatedConfig.packageSettings || [])];\n }\n\n processConfig(config);\n\n return config;\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { GeneratedConfig } from './types/GeneratedConfig.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reads the generated config file asynchronously. This is only useful for the `init` verb generating or updated
|
|
4
|
+
* the generated overrides. For a full merged representation of config, use `readConfig` instead.
|
|
5
|
+
*/
|
|
6
|
+
export declare function readGeneratedConfig(appPath: string): Promise<GeneratedConfig>;
|
|
7
|
+
//# sourceMappingURL=readGeneratedConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readGeneratedConfig.d.ts","sourceRoot":"","sources":["../src/readGeneratedConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAInF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { readJson } from '@ms-cloudpack/json-utilities';
|
|
2
|
+
import { getConfigPath } from './getConfigPath.js';
|
|
3
|
+
/**
|
|
4
|
+
* Reads the generated config file asynchronously. This is only useful for the `init` verb generating or updated
|
|
5
|
+
* the generated overrides. For a full merged representation of config, use `readConfig` instead.
|
|
6
|
+
*/
|
|
7
|
+
export async function readGeneratedConfig(appPath) {
|
|
8
|
+
const { generatedConfigPath } = getConfigPath(appPath);
|
|
9
|
+
return (await readJson(generatedConfigPath)) || {};
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=readGeneratedConfig.js.map
|
|
@@ -0,0 +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;;;GAGG;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,CAAC,CAAC,IAAI,EAAE,CAAC;AACrD,CAAC","sourcesContent":["import { readJson } from '@ms-cloudpack/json-utilities';\nimport { getConfigPath } from './getConfigPath.js';\nimport type { GeneratedConfig } from './types/GeneratedConfig.js';\n\n/**\n * Reads the generated config file asynchronously. This is only useful for the `init` verb generating or updated\n * the generated overrides. For a full merged representation of config, use `readConfig` instead.\n */\nexport async function readGeneratedConfig(appPath: string): Promise<GeneratedConfig> {\n const { generatedConfigPath } = getConfigPath(appPath);\n\n return (await readJson(generatedConfigPath)) || {};\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { UserConfig } from './index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Reads the user config file asynchronously. Note this is only useful for making modifications to the user config.
|
|
4
|
+
* For a full merged representation of config, use `readConfig` instead.
|
|
5
|
+
*/
|
|
6
|
+
export declare function readUserConfig(appPath: string): Promise<UserConfig>;
|
|
7
|
+
//# sourceMappingURL=readUserConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readUserConfig.d.ts","sourceRoot":"","sources":["../src/readUserConfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;;GAGG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAIzE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { readJson } from '@ms-cloudpack/json-utilities';
|
|
2
|
+
import { getConfigPath } from './getConfigPath.js';
|
|
3
|
+
/**
|
|
4
|
+
* Reads the user config file asynchronously. Note this is only useful for making modifications to the user config.
|
|
5
|
+
* For a full merged representation of config, use `readConfig` instead.
|
|
6
|
+
*/
|
|
7
|
+
export async function readUserConfig(appPath) {
|
|
8
|
+
const { userConfigPath } = getConfigPath(appPath);
|
|
9
|
+
return (await readJson(userConfigPath)) || {};
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=readUserConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readUserConfig.js","sourceRoot":"","sources":["../src/readUserConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAAe;IAClD,MAAM,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAElD,OAAO,CAAC,MAAM,QAAQ,CAAC,cAAc,CAAC,CAAC,IAAI,EAAE,CAAC;AAChD,CAAC","sourcesContent":["import { readJson } from '@ms-cloudpack/json-utilities';\nimport { getConfigPath } from './getConfigPath.js';\nimport type { UserConfig } from './index.js';\n\n/**\n * Reads the user config file 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 readJson(userConfigPath)) || {};\n}\n"]}
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import type { PackageOverride } from './PackageOverride.js';
|
|
2
|
+
import type { PackageSettings } from './PackageSettings.js';
|
|
2
3
|
/**
|
|
3
4
|
* Per-application generated configuration for Cloudpack.
|
|
4
5
|
*/
|
|
5
6
|
export interface GeneratedConfig {
|
|
6
7
|
/**
|
|
8
|
+
* An array of PackageSettings objects, used to provide settings for how we bundle packages.
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
packageSettings?: PackageSettings[];
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated - Use packageSettings instead.
|
|
14
|
+
*
|
|
7
15
|
* An array of PackageOverride objects, used to provide overrides for packages without modifying their
|
|
8
16
|
* definitions directly. This is primarily used for providing exports maps for packages that don't have them.
|
|
9
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeneratedConfig.d.ts","sourceRoot":"","sources":["../../src/types/GeneratedConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;GAEG;AAEH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;CACtC"}
|
|
1
|
+
{"version":3,"file":"GeneratedConfig.d.ts","sourceRoot":"","sources":["../../src/types/GeneratedConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;GAEG;AAEH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,eAAe,CAAC,EAAE,eAAe,EAAE,CAAC;IAEpC;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;CACtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GeneratedConfig.js","sourceRoot":"","sources":["../../src/types/GeneratedConfig.ts"],"names":[],"mappings":"","sourcesContent":["import type { PackageOverride } from './PackageOverride.js';\n\n/**\n * Per-application generated configuration for Cloudpack.\n */\n\nexport interface GeneratedConfig {\n /**\n * An array of PackageOverride objects, used to provide overrides for packages without modifying their\n * definitions directly. This is primarily used for providing exports maps for packages that don't have them.\n */\n packageOverrides?: PackageOverride[];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"GeneratedConfig.js","sourceRoot":"","sources":["../../src/types/GeneratedConfig.ts"],"names":[],"mappings":"","sourcesContent":["import type { PackageOverride } from './PackageOverride.js';\nimport type { PackageSettings } from './PackageSettings.js';\n\n/**\n * Per-application generated configuration for Cloudpack.\n */\n\nexport interface GeneratedConfig {\n /**\n * An array of PackageSettings objects, used to provide settings for how we bundle packages.\n *\n */\n packageSettings?: PackageSettings[];\n\n /**\n * @deprecated - Use packageSettings instead.\n *\n * An array of PackageOverride objects, used to provide overrides for packages without modifying their\n * definitions directly. This is primarily used for providing exports maps for packages that don't have them.\n */\n packageOverrides?: PackageOverride[];\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { PackageJsonExports } from '@ms-cloudpack/bundler-types';
|
|
2
|
+
/**
|
|
3
|
+
* Settings which apply to a single package (app or library) as it pertains to the Cloudpack start experience.
|
|
4
|
+
*/
|
|
5
|
+
export interface PackageSettings {
|
|
6
|
+
/**
|
|
7
|
+
* A match to indicate the target for the settings to be applied to.
|
|
8
|
+
*/
|
|
9
|
+
match: {
|
|
10
|
+
/**
|
|
11
|
+
* Name of the package.
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
/**
|
|
15
|
+
* Version of the package. Unspecified matches any version.
|
|
16
|
+
*/
|
|
17
|
+
version?: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The dependencies which should be included when computing the import map. This is primarily used when
|
|
21
|
+
* devDependencies are needed by the app. This often happens when a library has a demo app which relies
|
|
22
|
+
* on devDependencies.
|
|
23
|
+
*/
|
|
24
|
+
includedDependencies?: string[];
|
|
25
|
+
/**
|
|
26
|
+
* The dependencies which should be ignored by Cloudpack verbs. For example, if "react-native" is a dependency
|
|
27
|
+
* which should not be included in the import map or evaluated during `init`, it can be listed here to ignore it.
|
|
28
|
+
*/
|
|
29
|
+
excludedDependencies?: string[];
|
|
30
|
+
/**
|
|
31
|
+
* Dependencies which should be inlined in the library bundled by Cloudpack. This is useful for libraries which
|
|
32
|
+
* are small and don't need to be loaded separately, or ones which have issues being resolved by the browser.
|
|
33
|
+
*/
|
|
34
|
+
inlinedDependencies?: string[];
|
|
35
|
+
/**
|
|
36
|
+
* The exports map that should be used for this package, ignoring entries which are defined in the original
|
|
37
|
+
* package.json. This is useful for libraries which have a missing or broken exports map, or when we want to
|
|
38
|
+
* trim the exports to reduce the api surface we expose to the inner loop experience.
|
|
39
|
+
*/
|
|
40
|
+
exports?: PackageJsonExports;
|
|
41
|
+
/**
|
|
42
|
+
* Forces the package to be bundled using a specific bundler.
|
|
43
|
+
*/
|
|
44
|
+
bundlerType?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Options to pass to the bundler.
|
|
47
|
+
*/
|
|
48
|
+
bundlerOptions?: Record<string, unknown>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=PackageSettings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PackageSettings.d.ts","sourceRoot":"","sources":["../../src/types/PackageSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,KAAK,EAAE;QACL;;WAEG;QACH,IAAI,EAAE,MAAM,CAAC;QAEb;;WAEG;QACH,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IAEF;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAEhC;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAEhC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAE/B;;;;OAIG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAE7B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PackageSettings.js","sourceRoot":"","sources":["../../src/types/PackageSettings.ts"],"names":[],"mappings":"","sourcesContent":["import type { PackageJsonExports } from '@ms-cloudpack/bundler-types';\n\n/**\n * Settings which apply to a single package (app or library) as it pertains to the Cloudpack start experience.\n */\nexport interface PackageSettings {\n /**\n * A match to indicate the target for the settings to be applied to.\n */\n match: {\n /**\n * Name of the package.\n */\n name: string;\n\n /**\n * Version of the package. Unspecified matches any version.\n */\n version?: string;\n };\n\n /**\n * The dependencies which should be included when computing the import map. This is primarily used when\n * devDependencies are needed by the app. This often happens when a library has a demo app which relies\n * on devDependencies.\n */\n includedDependencies?: string[];\n\n /**\n * The dependencies which should be ignored by Cloudpack verbs. For example, if \"react-native\" is a dependency\n * which should not be included in the import map or evaluated during `init`, it can be listed here to ignore it.\n */\n excludedDependencies?: string[];\n\n /**\n * Dependencies which should be inlined in the library bundled by Cloudpack. This is useful for libraries which\n * are small and don't need to be loaded separately, or ones which have issues being resolved by the browser.\n */\n inlinedDependencies?: string[];\n\n /**\n * The exports map that should be used for this package, ignoring entries which are defined in the original\n * package.json. This is useful for libraries which have a missing or broken exports map, or when we want to\n * trim the exports to reduce the api surface we expose to the inner loop experience.\n */\n exports?: PackageJsonExports;\n\n /**\n * Forces the package to be bundled using a specific bundler.\n */\n bundlerType?: string;\n\n /**\n * Options to pass to the bundler.\n */\n bundlerOptions?: Record<string, unknown>;\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DevServer } from './DevServer.js';
|
|
2
2
|
import type { Features } from './Features.js';
|
|
3
|
+
import type { PackageSettings } from './PackageSettings.js';
|
|
3
4
|
import type { TelemetryConfig } from './TelemetryConfig.js';
|
|
4
5
|
/**
|
|
5
6
|
* Per-application user-provided configuration for Cloudpack.
|
|
@@ -22,5 +23,9 @@ export interface UserConfig {
|
|
|
22
23
|
* Help message to display when Cloudpack starts up.
|
|
23
24
|
*/
|
|
24
25
|
helpMessage?: string;
|
|
26
|
+
/**
|
|
27
|
+
* An array of PackageSettings objects, used to provide settings for how we bundle packages.
|
|
28
|
+
*/
|
|
29
|
+
packageSettings?: PackageSettings[];
|
|
25
30
|
}
|
|
26
31
|
//# sourceMappingURL=UserConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserConfig.d.ts","sourceRoot":"","sources":["../../src/types/UserConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;GAEG;AAEH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB;;OAEG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAE5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"UserConfig.d.ts","sourceRoot":"","sources":["../../src/types/UserConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D;;GAEG;AAEH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IAEtB;;OAEG;IACH,SAAS,CAAC,EAAE,eAAe,CAAC;IAE5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,eAAe,CAAC,EAAE,eAAe,EAAE,CAAC;CACrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserConfig.js","sourceRoot":"","sources":["../../src/types/UserConfig.ts"],"names":[],"mappings":"","sourcesContent":["import type { DevServer } from './DevServer.js';\nimport type { Features } from './Features.js';\nimport type { TelemetryConfig } from './TelemetryConfig.js';\n\n/**\n * Per-application user-provided configuration for Cloudpack.\n */\n\nexport interface UserConfig {\n /**\n * A set of options for configuring how the dev server works.\n */\n devServer?: DevServer;\n\n /**\n * A set of options for configuring telemetry\n */\n telemetry?: TelemetryConfig;\n\n /**\n * A set of options for configuring the experience. Features can be set to true to change the default\n * behavior.\n */\n features?: Features;\n\n /**\n * Help message to display when Cloudpack starts up.\n */\n helpMessage?: string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UserConfig.js","sourceRoot":"","sources":["../../src/types/UserConfig.ts"],"names":[],"mappings":"","sourcesContent":["import type { DevServer } from './DevServer.js';\nimport type { Features } from './Features.js';\nimport type { PackageSettings } from './PackageSettings.js';\nimport type { TelemetryConfig } from './TelemetryConfig.js';\n\n/**\n * Per-application user-provided configuration for Cloudpack.\n */\n\nexport interface UserConfig {\n /**\n * A set of options for configuring how the dev server works.\n */\n devServer?: DevServer;\n\n /**\n * A set of options for configuring telemetry\n */\n telemetry?: TelemetryConfig;\n\n /**\n * A set of options for configuring the experience. Features can be set to true to change the default\n * behavior.\n */\n features?: Features;\n\n /**\n * Help message to display when Cloudpack starts up.\n */\n helpMessage?: string;\n\n /**\n * An array of PackageSettings objects, used to provide settings for how we bundle packages.\n */\n packageSettings?: PackageSettings[];\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GeneratedConfig } from './types/GeneratedConfig.js';
|
|
2
|
+
/**
|
|
3
|
+
* Writes generated config. This is used for `init` to provide package overrides needed.
|
|
4
|
+
*/
|
|
5
|
+
export declare function writeGeneratedConfig(config: GeneratedConfig, appPath: string): Promise<void>;
|
|
6
|
+
//# sourceMappingURL=writeGeneratedConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeGeneratedConfig.d.ts","sourceRoot":"","sources":["../src/writeGeneratedConfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAKlE;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,iBAelF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { writeJson } from '@ms-cloudpack/json-utilities';
|
|
2
|
+
import { compareSettings } from './compareSettings.js';
|
|
3
|
+
import { getConfigPath } from './getConfigPath.js';
|
|
4
|
+
import { compareOverrides } from './compareOverrides.js';
|
|
5
|
+
/**
|
|
6
|
+
* Writes generated config. This is used for `init` to provide package overrides needed.
|
|
7
|
+
*/
|
|
8
|
+
export async function writeGeneratedConfig(config, appPath) {
|
|
9
|
+
const { generatedConfigPath } = getConfigPath(appPath);
|
|
10
|
+
// Ensure package overrides are sorted based on package name and version requirement.
|
|
11
|
+
// eslint-disable-next-line etc/no-deprecated
|
|
12
|
+
const { packageOverrides, packageSettings, ...rest } = config;
|
|
13
|
+
const sortedSettings = packageSettings?.sort(compareSettings);
|
|
14
|
+
const sortedOverrides = packageOverrides?.sort(compareOverrides);
|
|
15
|
+
return writeJson(generatedConfigPath, {
|
|
16
|
+
...rest,
|
|
17
|
+
packageSettings: sortedSettings,
|
|
18
|
+
packageOverrides: sortedOverrides,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=writeGeneratedConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeGeneratedConfig.js","sourceRoot":"","sources":["../src/writeGeneratedConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,MAAuB,EAAE,OAAe;IACjF,MAAM,EAAE,mBAAmB,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAEvD,qFAAqF;IACrF,6CAA6C;IAC7C,MAAM,EAAE,gBAAgB,EAAE,eAAe,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM,CAAC;IAE9D,MAAM,cAAc,GAAG,eAAe,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;IAC9D,MAAM,eAAe,GAAG,gBAAgB,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAEjE,OAAO,SAAS,CAAC,mBAAmB,EAAE;QACpC,GAAG,IAAI;QACP,eAAe,EAAE,cAAc;QAC/B,gBAAgB,EAAE,eAAe;KAClC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { writeJson } from '@ms-cloudpack/json-utilities';\nimport type { GeneratedConfig } from './types/GeneratedConfig.js';\nimport { compareSettings } from './compareSettings.js';\nimport { getConfigPath } from './getConfigPath.js';\nimport { compareOverrides } from './compareOverrides.js';\n\n/**\n * Writes generated config. This is used for `init` to provide package overrides needed.\n */\nexport async function writeGeneratedConfig(config: GeneratedConfig, appPath: string) {\n const { generatedConfigPath } = getConfigPath(appPath);\n\n // Ensure package overrides are sorted based on package name and version requirement.\n // eslint-disable-next-line etc/no-deprecated\n const { packageOverrides, packageSettings, ...rest } = config;\n\n const sortedSettings = packageSettings?.sort(compareSettings);\n const sortedOverrides = packageOverrides?.sort(compareOverrides);\n\n return writeJson(generatedConfigPath, {\n ...rest,\n packageSettings: sortedSettings,\n packageOverrides: sortedOverrides,\n });\n}\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { UserConfig } from './index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Writes updates to the user config. Unlike writing generated config, this does not sort existing package settings,
|
|
4
|
+
* with the intent of minimizing churn.
|
|
5
|
+
*/
|
|
6
|
+
export declare function writeUserConfig(config: UserConfig, appPath: string): Promise<void>;
|
|
7
|
+
//# sourceMappingURL=writeUserConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeUserConfig.d.ts","sourceRoot":"","sources":["../src/writeUserConfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C;;;GAGG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,iBAIxE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { writeJson } from '@ms-cloudpack/json-utilities';
|
|
2
|
+
import { getConfigPath } from './getConfigPath.js';
|
|
3
|
+
/**
|
|
4
|
+
* Writes updates to the user config. Unlike writing generated config, this does not sort existing package settings,
|
|
5
|
+
* with the intent of minimizing churn.
|
|
6
|
+
*/
|
|
7
|
+
export async function writeUserConfig(config, appPath) {
|
|
8
|
+
const { userConfigPath } = getConfigPath(appPath);
|
|
9
|
+
return writeJson(userConfigPath, config);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=writeUserConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writeUserConfig.js","sourceRoot":"","sources":["../src/writeUserConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,MAAkB,EAAE,OAAe;IACvE,MAAM,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAElD,OAAO,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["import { writeJson } from '@ms-cloudpack/json-utilities';\nimport type { UserConfig } from './index.js';\nimport { getConfigPath } from './getConfigPath.js';\n\n/**\n * Writes updates to the user config. Unlike writing generated config, this does not sort existing package settings,\n * with the intent of minimizing churn.\n */\nexport async function writeUserConfig(config: UserConfig, appPath: string) {\n const { userConfigPath } = getConfigPath(appPath);\n\n return writeJson(userConfigPath, config);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/config",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Configuration handling for cloudpack.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -13,20 +13,25 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@ms-cloudpack/bundler-types": "^0.
|
|
17
|
-
"@ms-cloudpack/create-express-app": "^1.3.
|
|
18
|
-
"@ms-cloudpack/json-utilities": "^0.0.
|
|
16
|
+
"@ms-cloudpack/bundler-types": "^0.16.0",
|
|
17
|
+
"@ms-cloudpack/create-express-app": "^1.3.8",
|
|
18
|
+
"@ms-cloudpack/json-utilities": "^0.0.7",
|
|
19
|
+
"@ms-cloudpack/package-utilities": "^5.0.0"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
22
|
"@ms-cloudpack/eslint-plugin-internal": "*",
|
|
22
|
-
"@ms-cloudpack/scripts": "*"
|
|
23
|
+
"@ms-cloudpack/scripts": "*",
|
|
24
|
+
"@ms-cloudpack/test-utilities": "*"
|
|
23
25
|
},
|
|
24
26
|
"scripts": {
|
|
25
27
|
"api": "cloudpack-scripts api",
|
|
26
28
|
"build:watch": "cloudpack-scripts build-watch",
|
|
27
29
|
"build": "cloudpack-scripts build",
|
|
28
30
|
"lint:update": "cloudpack-scripts lint-update",
|
|
29
|
-
"lint": "cloudpack-scripts lint"
|
|
31
|
+
"lint": "cloudpack-scripts lint",
|
|
32
|
+
"test:update": "cloudpack-scripts test-update",
|
|
33
|
+
"test:watch": "cloudpack-scripts test-watch",
|
|
34
|
+
"test": "cloudpack-scripts test"
|
|
30
35
|
},
|
|
31
36
|
"files": [
|
|
32
37
|
"lib/**/!(*.test.*)"
|
package/lib/config.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { GeneratedConfig } from './types/GeneratedConfig.js';
|
|
2
|
-
import type { CloudpackConfig } from './types/CloudpackConfig.js';
|
|
3
|
-
export declare const configFileName = "cloudpack.config.json";
|
|
4
|
-
export declare const generatedConfigFileName = "cloudpack.generated.json";
|
|
5
|
-
/**
|
|
6
|
-
* @param cwd - base path of the config file
|
|
7
|
-
* @returns the path of the config file
|
|
8
|
-
*/
|
|
9
|
-
export declare function getConfigPath(cwd: string): {
|
|
10
|
-
configPath: string;
|
|
11
|
-
overridesPath: string;
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Reads the config file synchronously
|
|
15
|
-
* @param cwd - base path of the config file
|
|
16
|
-
* @returns cloudpack config object or empty object if no config file exists.
|
|
17
|
-
*/
|
|
18
|
-
export declare function readConfigSync(cwd: string): CloudpackConfig;
|
|
19
|
-
/**
|
|
20
|
-
* Reads the config file asynchronously
|
|
21
|
-
* @param cwd - base path of the config file
|
|
22
|
-
* @returns cloudpack config object or empty object if no config file exists.
|
|
23
|
-
*/
|
|
24
|
-
export declare function readConfig(cwd: string): Promise<CloudpackConfig>;
|
|
25
|
-
/**
|
|
26
|
-
* Writes generated config. This is used for `init` to provide package overrides needed.
|
|
27
|
-
* @param config - updated config object to be written
|
|
28
|
-
* @param cwd - base path of the config file
|
|
29
|
-
*/
|
|
30
|
-
export declare function writeGeneratedConfig(config: GeneratedConfig, cwd: string): Promise<void>;
|
|
31
|
-
//# sourceMappingURL=config.d.ts.map
|
package/lib/config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAGlE,eAAO,MAAM,cAAc,0BAA0B,CAAC;AACtD,eAAO,MAAM,uBAAuB,6BAA6B,CAAC;AAElE;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM;;;EAKxC;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,mBASzC;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAOtE;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,iBAiB9E"}
|
package/lib/config.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { readJson, readJsonSync, writeJson } from '@ms-cloudpack/json-utilities';
|
|
3
|
-
export const configFileName = 'cloudpack.config.json';
|
|
4
|
-
export const generatedConfigFileName = 'cloudpack.generated.json';
|
|
5
|
-
/**
|
|
6
|
-
* @param cwd - base path of the config file
|
|
7
|
-
* @returns the path of the config file
|
|
8
|
-
*/
|
|
9
|
-
export function getConfigPath(cwd) {
|
|
10
|
-
return {
|
|
11
|
-
configPath: path.join(cwd, configFileName),
|
|
12
|
-
overridesPath: path.join(cwd, generatedConfigFileName),
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Reads the config file synchronously
|
|
17
|
-
* @param cwd - base path of the config file
|
|
18
|
-
* @returns cloudpack config object or empty object if no config file exists.
|
|
19
|
-
*/
|
|
20
|
-
export function readConfigSync(cwd) {
|
|
21
|
-
const { configPath, overridesPath } = getConfigPath(cwd);
|
|
22
|
-
return {
|
|
23
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
24
|
-
...(readJsonSync(configPath) || {}),
|
|
25
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
26
|
-
...(readJsonSync(overridesPath) || {}),
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Reads the config file asynchronously
|
|
31
|
-
* @param cwd - base path of the config file
|
|
32
|
-
* @returns cloudpack config object or empty object if no config file exists.
|
|
33
|
-
*/
|
|
34
|
-
export async function readConfig(cwd) {
|
|
35
|
-
const { configPath, overridesPath } = getConfigPath(cwd);
|
|
36
|
-
return {
|
|
37
|
-
...((await readJson(configPath)) || {}),
|
|
38
|
-
...((await readJson(overridesPath)) || {}),
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Writes generated config. This is used for `init` to provide package overrides needed.
|
|
43
|
-
* @param config - updated config object to be written
|
|
44
|
-
* @param cwd - base path of the config file
|
|
45
|
-
*/
|
|
46
|
-
export async function writeGeneratedConfig(config, cwd) {
|
|
47
|
-
const { overridesPath } = getConfigPath(cwd);
|
|
48
|
-
// Ensure package overrides are sorted based on package name and versionRequirement.
|
|
49
|
-
const sortedOverrides = config.packageOverrides?.sort((a, b) => {
|
|
50
|
-
if (a.name === b.name) {
|
|
51
|
-
return a.versionRequirement.localeCompare(b.versionRequirement);
|
|
52
|
-
}
|
|
53
|
-
return a.name.localeCompare(b.name);
|
|
54
|
-
}) || [];
|
|
55
|
-
return writeJson(overridesPath, {
|
|
56
|
-
...config,
|
|
57
|
-
packageOverrides: sortedOverrides,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=config.js.map
|
package/lib/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEjF,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAuB,CAAC;AACtD,MAAM,CAAC,MAAM,uBAAuB,GAAG,0BAA0B,CAAC;AAElE;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,OAAO;QACL,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC;QAC1C,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,uBAAuB,CAAC;KACvD,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IAEzD,OAAO;QACL,gDAAgD;QAChD,GAAG,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QACnC,gDAAgD;QAChD,GAAG,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;KACpB,CAAC;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAW;IAC1C,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IAEzD,OAAO;QACL,GAAG,CAAC,CAAC,MAAM,QAAQ,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC;QACvC,GAAG,CAAC,CAAC,MAAM,QAAQ,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,CAAC;KACxB,CAAC;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,MAAuB,EAAE,GAAW;IAC7E,MAAM,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IAE7C,oFAAoF;IACpF,MAAM,eAAe,GACnB,MAAM,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACrC,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,EAAE;YACrB,OAAO,CAAC,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC;SACjE;QAED,OAAO,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC,CAAC,IAAI,EAAE,CAAC;IAEX,OAAO,SAAS,CAAC,aAAa,EAAE;QAC9B,GAAG,MAAM;QACT,gBAAgB,EAAE,eAAe;KAClC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import path from 'path';\nimport type { GeneratedConfig } from './types/GeneratedConfig.js';\nimport type { CloudpackConfig } from './types/CloudpackConfig.js';\nimport { readJson, readJsonSync, writeJson } from '@ms-cloudpack/json-utilities';\n\nexport const configFileName = 'cloudpack.config.json';\nexport const generatedConfigFileName = 'cloudpack.generated.json';\n\n/**\n * @param cwd - base path of the config file\n * @returns the path of the config file\n */\nexport function getConfigPath(cwd: string) {\n return {\n configPath: path.join(cwd, configFileName),\n overridesPath: path.join(cwd, generatedConfigFileName),\n };\n}\n\n/**\n * Reads the config file synchronously\n * @param cwd - base path of the config file\n * @returns cloudpack config object or empty object if no config file exists.\n */\nexport function readConfigSync(cwd: string) {\n const { configPath, overridesPath } = getConfigPath(cwd);\n\n return {\n // eslint-disable-next-line no-restricted-syntax\n ...(readJsonSync(configPath) || {}),\n // eslint-disable-next-line no-restricted-syntax\n ...(readJsonSync(overridesPath) || {}),\n } as CloudpackConfig;\n}\n\n/**\n * Reads the config file asynchronously\n * @param cwd - base path of the config file\n * @returns cloudpack config object or empty object if no config file exists.\n */\nexport async function readConfig(cwd: string): Promise<CloudpackConfig> {\n const { configPath, overridesPath } = getConfigPath(cwd);\n\n return {\n ...((await readJson(configPath)) || {}),\n ...((await readJson(overridesPath)) || {}),\n } as CloudpackConfig;\n}\n\n/**\n * Writes generated config. This is used for `init` to provide package overrides needed.\n * @param config - updated config object to be written\n * @param cwd - base path of the config file\n */\nexport async function writeGeneratedConfig(config: GeneratedConfig, cwd: string) {\n const { overridesPath } = getConfigPath(cwd);\n\n // Ensure package overrides are sorted based on package name and versionRequirement.\n const sortedOverrides =\n config.packageOverrides?.sort((a, b) => {\n if (a.name === b.name) {\n return a.versionRequirement.localeCompare(b.versionRequirement);\n }\n\n return a.name.localeCompare(b.name);\n }) || [];\n\n return writeJson(overridesPath, {\n ...config,\n packageOverrides: sortedOverrides,\n });\n}\n"]}
|