@ms-cloudpack/config 0.26.0 → 0.26.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/sortGeneratedConfig.d.ts.map +1 -1
- package/lib/sortGeneratedConfig.js +4 -1
- package/lib/sortGeneratedConfig.js.map +1 -1
- package/lib/writeGeneratedConfig.d.ts +15 -2
- package/lib/writeGeneratedConfig.d.ts.map +1 -1
- package/lib/writeGeneratedConfig.js +25 -4
- package/lib/writeGeneratedConfig.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sortGeneratedConfig.d.ts","sourceRoot":"","sources":["../src/sortGeneratedConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAyC,MAAM,4BAA4B,CAAC;AAIzG;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"sortGeneratedConfig.d.ts","sourceRoot":"","sources":["../src/sortGeneratedConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAyC,MAAM,4BAA4B,CAAC;AAIzG;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,eAAe,QAoC7D"}
|
|
@@ -5,7 +5,10 @@ import { compareSettings } from './compareSettings.js';
|
|
|
5
5
|
* order of operations.
|
|
6
6
|
*/
|
|
7
7
|
export function sortGeneratedConfig(generated) {
|
|
8
|
-
const { packageSettings
|
|
8
|
+
const { packageSettings } = generated;
|
|
9
|
+
if (!packageSettings) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
9
12
|
// Ensure package overrides are sorted based on package name and version requirement.
|
|
10
13
|
packageSettings.sort(compareSettings);
|
|
11
14
|
for (let i = 0; i < packageSettings.length; i++) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sortGeneratedConfig.js","sourceRoot":"","sources":["../src/sortGenerat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BACvC,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, PackageSettings, PackageSettingsMatch } 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 overrides 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: PackageSettingsMatch;\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 PackageSettings)[]) {\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"]}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import type { GeneratedConfig } from '@ms-cloudpack/common-types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Comment added to the top of the generated file (exported for testing only).
|
|
4
|
+
* @internal
|
|
4
5
|
*/
|
|
5
|
-
export declare
|
|
6
|
+
export declare const fileHeaderComment = "/**\n * THIS FILE IS AUTO-GENERATED.\n * DO NOT MANUALLY EDIT THIS FILE.\n */\n";
|
|
7
|
+
/**
|
|
8
|
+
* Clean up the generated config (sort it and remove empty settings) and write it to
|
|
9
|
+
* cloudpack.generated.json. This is used at the end of `init`.
|
|
10
|
+
*
|
|
11
|
+
* If the config file exists but is no longer needed, it will be deleted.
|
|
12
|
+
*
|
|
13
|
+
* @returns
|
|
14
|
+
* - `'written'` if the config was written
|
|
15
|
+
* - `'deleted'` if the config previously existed but is now empty and was deleted
|
|
16
|
+
* - `'no-op'` if the config didn't previously exist and is still empty
|
|
17
|
+
*/
|
|
18
|
+
export declare function writeGeneratedConfig(config: GeneratedConfig, appPath: string): Promise<'written' | 'deleted' | 'no-op'>;
|
|
6
19
|
//# sourceMappingURL=writeGeneratedConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeGeneratedConfig.d.ts","sourceRoot":"","sources":["../src/writeGeneratedConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"writeGeneratedConfig.d.ts","sourceRoot":"","sources":["../src/writeGeneratedConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAQlE;;;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"}
|
|
@@ -1,19 +1,40 @@
|
|
|
1
1
|
import { writeJson } from '@ms-cloudpack/json-utilities';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { cleanGeneratedConfig } from './cleanGeneratedConfig.js';
|
|
2
4
|
import { getConfigPath } from './getConfigPath.js';
|
|
3
5
|
import { generatedAppConfigSchemaUrl } from './schemaUrls.js';
|
|
4
6
|
import { sortGeneratedConfig } from './sortGeneratedConfig.js';
|
|
5
|
-
import { cleanGeneratedConfig } from './cleanGeneratedConfig.js';
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* Comment added to the top of the generated file (exported for testing only).
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export const fileHeaderComment = `/**\n * THIS FILE IS AUTO-GENERATED.\n * DO NOT MANUALLY EDIT THIS FILE.\n */\n`;
|
|
12
|
+
/**
|
|
13
|
+
* Clean up the generated config (sort it and remove empty settings) and write it to
|
|
14
|
+
* cloudpack.generated.json. This is used at the end of `init`.
|
|
15
|
+
*
|
|
16
|
+
* If the config file exists but is no longer needed, it will be deleted.
|
|
17
|
+
*
|
|
18
|
+
* @returns
|
|
19
|
+
* - `'written'` if the config was written
|
|
20
|
+
* - `'deleted'` if the config previously existed but is now empty and was deleted
|
|
21
|
+
* - `'no-op'` if the config didn't previously exist and is still empty
|
|
8
22
|
*/
|
|
9
23
|
export async function writeGeneratedConfig(config, appPath) {
|
|
10
24
|
const { generatedConfigPath } = getConfigPath(appPath);
|
|
11
|
-
const fileHeaderComment = `/**\n * THIS FILE IS AUTO-GENERATED.\n * DO NOT MANUALLY EDIT THIS FILE.\n */\n`;
|
|
12
25
|
sortGeneratedConfig(config);
|
|
13
26
|
cleanGeneratedConfig(config);
|
|
14
|
-
|
|
27
|
+
if (!config.packageSettings?.length) {
|
|
28
|
+
if (fs.existsSync(generatedConfigPath)) {
|
|
29
|
+
fs.unlinkSync(generatedConfigPath);
|
|
30
|
+
return 'deleted';
|
|
31
|
+
}
|
|
32
|
+
return 'no-op';
|
|
33
|
+
}
|
|
34
|
+
await writeJson(generatedConfigPath, {
|
|
15
35
|
$schema: generatedAppConfigSchemaUrl,
|
|
16
36
|
...config,
|
|
17
37
|
}, { fileHeaderComment });
|
|
38
|
+
return 'written';
|
|
18
39
|
}
|
|
19
40
|
//# sourceMappingURL=writeGeneratedConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeGeneratedConfig.js","sourceRoot":"","sources":["../src/writeGeneratedConfig.ts"],"names":[],"mappings":"
|
|
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,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,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","sourcesContent":["import type { GeneratedConfig } from '@ms-cloudpack/common-types';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport fs from 'fs';\nimport { cleanGeneratedConfig } from './cleanGeneratedConfig.js';\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"]}
|