@ms-cloudpack/config
Advanced tools
Comparing version 0.26.0 to 0.26.1
@@ -8,3 +8,6 @@ import { sortObjectKeys } from './sortObjectKeys.js'; | ||
export function sortGeneratedConfig(generated) { | ||
const { packageSettings = [] } = generated; | ||
const { packageSettings } = generated; | ||
if (!packageSettings) { | ||
return; | ||
} | ||
// Ensure package overrides are sorted based on package name and version requirement. | ||
@@ -11,0 +14,0 @@ packageSettings.sort(compareSettings); |
import type { GeneratedConfig } from '@ms-cloudpack/common-types'; | ||
/** | ||
* Writes generated config. This is used for `init` to provide package overrides needed. | ||
* Comment added to the top of the generated file (exported for testing only). | ||
* @internal | ||
*/ | ||
export declare function writeGeneratedConfig(config: GeneratedConfig, appPath: string): Promise<void>; | ||
export declare const fileHeaderComment = "/**\n * THIS FILE IS AUTO-GENERATED.\n * DO NOT MANUALLY EDIT THIS FILE.\n */\n"; | ||
/** | ||
* Clean up the generated config (sort it and remove empty settings) and write it to | ||
* cloudpack.generated.json. This is used at the end of `init`. | ||
* | ||
* If the config file exists but is no longer needed, it will be deleted. | ||
* | ||
* @returns | ||
* - `'written'` if the config was written | ||
* - `'deleted'` if the config previously existed but is now empty and was deleted | ||
* - `'no-op'` if the config didn't previously exist and is still empty | ||
*/ | ||
export declare function writeGeneratedConfig(config: GeneratedConfig, appPath: string): Promise<'written' | 'deleted' | 'no-op'>; | ||
//# sourceMappingURL=writeGeneratedConfig.d.ts.map |
import { writeJson } from '@ms-cloudpack/json-utilities'; | ||
import fs from 'fs'; | ||
import { cleanGeneratedConfig } from './cleanGeneratedConfig.js'; | ||
import { getConfigPath } from './getConfigPath.js'; | ||
import { generatedAppConfigSchemaUrl } from './schemaUrls.js'; | ||
import { sortGeneratedConfig } from './sortGeneratedConfig.js'; | ||
import { cleanGeneratedConfig } from './cleanGeneratedConfig.js'; | ||
/** | ||
* Writes generated config. This is used for `init` to provide package overrides needed. | ||
* Comment added to the top of the generated file (exported for testing only). | ||
* @internal | ||
*/ | ||
export const fileHeaderComment = `/**\n * THIS FILE IS AUTO-GENERATED.\n * DO NOT MANUALLY EDIT THIS FILE.\n */\n`; | ||
/** | ||
* Clean up the generated config (sort it and remove empty settings) and write it to | ||
* cloudpack.generated.json. This is used at the end of `init`. | ||
* | ||
* If the config file exists but is no longer needed, it will be deleted. | ||
* | ||
* @returns | ||
* - `'written'` if the config was written | ||
* - `'deleted'` if the config previously existed but is now empty and was deleted | ||
* - `'no-op'` if the config didn't previously exist and is still empty | ||
*/ | ||
export async function writeGeneratedConfig(config, appPath) { | ||
const { generatedConfigPath } = getConfigPath(appPath); | ||
const fileHeaderComment = `/**\n * THIS FILE IS AUTO-GENERATED.\n * DO NOT MANUALLY EDIT THIS FILE.\n */\n`; | ||
sortGeneratedConfig(config); | ||
cleanGeneratedConfig(config); | ||
return writeJson(generatedConfigPath, { | ||
if (!config.packageSettings?.length) { | ||
if (fs.existsSync(generatedConfigPath)) { | ||
fs.unlinkSync(generatedConfigPath); | ||
return 'deleted'; | ||
} | ||
return 'no-op'; | ||
} | ||
await writeJson(generatedConfigPath, { | ||
$schema: generatedAppConfigSchemaUrl, | ||
...config, | ||
}, { fileHeaderComment }); | ||
return 'written'; | ||
} | ||
//# sourceMappingURL=writeGeneratedConfig.js.map |
{ | ||
"name": "@ms-cloudpack/config", | ||
"version": "0.26.0", | ||
"version": "0.26.1", | ||
"description": "Configuration handling for cloudpack.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
103254
870
2