@ms-cloudpack/config 0.33.4 → 0.33.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"getConfigPath.d.ts","sourceRoot":"","sources":["../src/getConfigPath.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM;;;EAKxC"}
1
+ {"version":3,"file":"getConfigPath.d.ts","sourceRoot":"","sources":["../src/getConfigPath.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,mBAAmB,EAAE,MAAM,CAAA;CAAE,CAKjG"}
@@ -1 +1 @@
1
- {"version":3,"file":"getConfigPath.js","sourceRoot":"","sources":["../src/getConfigPath.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAE5E;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,OAAO;QACL,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,iBAAiB,CAAC;QAChD,mBAAmB,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,uBAAuB,CAAC;KAC7D,CAAC;AACJ,CAAC","sourcesContent":["import path from 'path';\nimport { appConfigFileName, generatedConfigFileName } from './constants.js';\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 appConfigPath: path.join(cwd, appConfigFileName),\n generatedConfigPath: path.join(cwd, generatedConfigFileName),\n };\n}\n"]}
1
+ {"version":3,"file":"getConfigPath.js","sourceRoot":"","sources":["../src/getConfigPath.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAE5E;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,OAAO;QACL,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,iBAAiB,CAAC;QAChD,mBAAmB,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,uBAAuB,CAAC;KAC7D,CAAC;AACJ,CAAC","sourcesContent":["import path from 'path';\nimport { appConfigFileName, generatedConfigFileName } from './constants.js';\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): { appConfigPath: string; generatedConfigPath: string } {\n return {\n appConfigPath: path.join(cwd, appConfigFileName),\n generatedConfigPath: path.join(cwd, generatedConfigFileName),\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"expandEnvironmentVariables.d.ts","sourceRoot":"","sources":["../../src/readConfig/expandEnvironmentVariables.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAazE"}
1
+ {"version":3,"file":"expandEnvironmentVariables.d.ts","sourceRoot":"","sources":["../../src/readConfig/expandEnvironmentVariables.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAahF"}
@@ -1 +1 @@
1
- {"version":3,"file":"expandEnvironmentVariables.js","sourceRoot":"","sources":["../../src/readConfig/expandEnvironmentVariables.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CAAC,MAA+B;IACxE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,kIAAkI;YAClI,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC,mCAAmC,CAAC,CAAC;YACpE,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC5B,oGAAoG;gBACpG,MAAM,CAAC,GAAG,CAAC,GAAI,MAAM,CAAC,GAAG,CAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YACvF,CAAC;QACH,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACrC,0BAA0B,CAAC,KAAgC,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/**\n * Expands all symbols in the format `{env:VAR_NAME}` with the value of the environment variable `VAR_NAME`.\n * If no such environment variable is set, the symbol is replaced with an empty string.\n * Symbols without the `env:` prefix are not replaced.\n *\n * @param config Any JSON object, but typically an AppConfig object\n */\nexport function expandEnvironmentVariables(config: Record<string, unknown>) {\n for (const [key, value] of Object.entries(config)) {\n if (typeof value === 'string') {\n // Valid environment variable names must start with a letter or underscore and can only contain letters, numbers, and underscores.\n const matches = value.matchAll(/\\{env:([A-Za-z_][A-Za-z0-9_]*)\\}/g);\n for (const match of matches) {\n // eslint-disable-next-line no-restricted-properties -- standard env properties aren't relevant here\n config[key] = (config[key] as string).replace(match[0], process.env[match[1]] ?? '');\n }\n } else if (typeof value === 'object') {\n expandEnvironmentVariables(value as Record<string, unknown>);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"expandEnvironmentVariables.js","sourceRoot":"","sources":["../../src/readConfig/expandEnvironmentVariables.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CAAC,MAA+B;IACxE,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,kIAAkI;YAClI,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC,mCAAmC,CAAC,CAAC;YACpE,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC5B,oGAAoG;gBACpG,MAAM,CAAC,GAAG,CAAC,GAAI,MAAM,CAAC,GAAG,CAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YACvF,CAAC;QACH,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACrC,0BAA0B,CAAC,KAAgC,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["/**\n * Expands all symbols in the format `{env:VAR_NAME}` with the value of the environment variable `VAR_NAME`.\n * If no such environment variable is set, the symbol is replaced with an empty string.\n * Symbols without the `env:` prefix are not replaced.\n *\n * @param config Any JSON object, but typically an AppConfig object\n */\nexport function expandEnvironmentVariables(config: Record<string, unknown>): void {\n for (const [key, value] of Object.entries(config)) {\n if (typeof value === 'string') {\n // Valid environment variable names must start with a letter or underscore and can only contain letters, numbers, and underscores.\n const matches = value.matchAll(/\\{env:([A-Za-z_][A-Za-z0-9_]*)\\}/g);\n for (const match of matches) {\n // eslint-disable-next-line no-restricted-properties -- standard env properties aren't relevant here\n config[key] = (config[key] as string).replace(match[0], process.env[match[1]] ?? '');\n }\n } else if (typeof value === 'object') {\n expandEnvironmentVariables(value as Record<string, unknown>);\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"readAppConfig.js","sourceRoot":"","sources":["../../src/readConfig/readAppConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,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AAC;QAC1B,OAAO,MAAM,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAI,MAAM,EAAE,MAAM,EAAE,CAAC;QACnB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC9B,OAAO,MAAM,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,MAAM,OAAO,IAAI,eAAe,EAAE,CAAC;QACtC,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;YACxB,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC;YACtC,OAAO,OAAO,CAAC,WAAW,CAAC;QAC7B,CAAC;IACH,CAAC;IACD,qCAAqC;AACvC,CAAC","sourcesContent":["import type { AppConfig, PackageSettings } from '@ms-cloudpack/common-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport fs from 'fs';\nimport { getConfigPath } from '../getConfigPath.js';\nimport { mergeParentConfig } from './mergeParentConfig.js';\nimport { resolveParentConfig } from './resolveParentConfig.js';\nimport { resolveModule } from '@ms-cloudpack/path-utilities';\nimport { validateMatch } from '../packageSettings/validateMatch.js';\nimport { expandEnvironmentVariables } from './expandEnvironmentVariables.js';\n\nexport interface ReadAppConfigOptions {\n /**\n * Extra package settings to add at the end of user-provided settings (so they take precedence).\n */\n extraPackageSettings?: PackageSettings[];\n}\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, there's some error reading it,\n * or any settings are invalid. (As of writing, this doesn't do full schema validation; it only\n * checks certain specific settings.)\n */\nexport async function readAppConfig(appPath: string, options?: ReadAppConfigOptions): Promise<AppConfig> {\n const { extraPackageSettings } = options || {};\n\n const { appConfigPath } = getConfigPath(appPath);\n\n // Do a separate existence check for the top-level config, since it's fine if that doesn't exist.\n // (readAppConfigInternal throws if the file doesn't exist because it's also used for reading\n // parent configs from \"extends\", which must exist if specified.)\n let config: AppConfig;\n if (!fs.existsSync(appConfigPath)) {\n config = {};\n } else {\n config = (await readAppConfigInternal(appConfigPath)) || {};\n expandEnvironmentVariables(config as Record<string, unknown>);\n }\n\n if (extraPackageSettings) {\n // Add these last so they take precedence.\n (config.packageSettings ??= []).push(...extraPackageSettings);\n }\n\n return config;\n}\n\n/**\n * Resolve import specifiers for bundler capabilities registry.\n * Throws if a specifier can't be resolved.\n */\nfunction resolveBundlerCapabilities(params: { appConfig: AppConfig; configPath: string }): void {\n const {\n appConfig: { bundlerCapabilitiesRegistry },\n configPath,\n } = params;\n if (!bundlerCapabilitiesRegistry) {\n return;\n }\n\n for (const [name, importSpecifier] of Object.entries(bundlerCapabilitiesRegistry)) {\n try {\n const moduleUrl = resolveModule({ parentUrl: configPath, importSpecifier });\n bundlerCapabilitiesRegistry[name] = moduleUrl;\n } catch (e) {\n throw new Error(`Error resolving bundler capability \"${importSpecifier}\":\\n${(e as Error).message || e}`);\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> {\n const appConfig = await readJson<AppConfig>(configPath, { mode: 'permissive', throwOnError: true });\n if (!appConfig) {\n // shouldn't happen, but just in case/to satisfy the types...\n throw new Error(`Could not read config file ${configPath}`);\n }\n\n if (!validateConfig(appConfig)) {\n throw new Error(`Config file ${configPath} has invalid settings (see above for details)`);\n }\n\n resolveBundlerCapabilities({ appConfig, configPath });\n\n processDeprecatedValues(appConfig);\n\n // Read and merge with any parent configs (the same processing is applied to parent configs)\n const { extends: _extends = [] } = appConfig;\n const extendsArray = Array.isArray(_extends) ? _extends : [_extends];\n const parentConfigs = await Promise.all(\n extendsArray.map((importSpecifier) => readAppConfigInternal(resolveParentConfig({ configPath, importSpecifier }))),\n );\n return mergeParentConfig({ appConfig, parentConfigs });\n}\n\n/**\n * Validate parts of the current config file (before merging with parents) and log any errors.\n * Logging here and then letting the caller throw if needed allows us to show more errors at once.\n * @returns true if valid, false if not\n */\nfunction validateConfig(appConfig: AppConfig) {\n let isValid = true;\n\n // Verify that there are no matches with a negated name and a version\n for (const setting of appConfig.packageSettings || []) {\n const { match } = setting;\n const matches = Array.isArray(match) ? match : [match];\n for (const m of matches) {\n const result = validateMatch(m);\n if (!result.isValid) {\n isValid = false;\n console.error(`Invalid packageSettings match: ${result.error}`);\n }\n }\n }\n\n return isValid;\n}\n\n/**\n * Delete deprecated values and convert them to the new format. (This mutates the `config` object.)\n */\nfunction processDeprecatedValues(config: AppConfig): void {\n /* eslint-disable etc/no-deprecated */\n const { devServer, server, packageSettings = [] } = config;\n\n if (devServer) {\n if (server) {\n throw new Error('Cannot have both \"devServer\" and \"server\" in the config file. Use \"server\" only.');\n }\n\n config.server = devServer;\n delete config.devServer;\n }\n\n if (server?.routes) {\n config.routes = server.routes;\n delete server.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 /* eslint-enable etc/no-deprecated */\n}\n"]}
1
+ {"version":3,"file":"readAppConfig.js","sourceRoot":"","sources":["../../src/readConfig/readAppConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAS7E;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAe,EAAE,OAA8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AAC","sourcesContent":["import type { AppConfig, PackageSettings } from '@ms-cloudpack/common-types';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport fs from 'fs';\nimport { getConfigPath } from '../getConfigPath.js';\nimport { mergeParentConfig } from './mergeParentConfig.js';\nimport { resolveParentConfig } from './resolveParentConfig.js';\nimport { resolveModule } from '@ms-cloudpack/path-utilities';\nimport { validateMatch } from '../packageSettings/validateMatch.js';\nimport { expandEnvironmentVariables } from './expandEnvironmentVariables.js';\n\nexport interface ReadAppConfigOptions {\n /**\n * Extra package settings to add at the end of user-provided settings (so they take precedence).\n */\n extraPackageSettings?: PackageSettings[];\n}\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, there's some error reading it,\n * or any settings are invalid. (As of writing, this doesn't do full schema validation; it only\n * checks certain specific settings.)\n */\nexport async function readAppConfig(appPath: string, options?: ReadAppConfigOptions): Promise<AppConfig> {\n const { extraPackageSettings } = options || {};\n\n const { appConfigPath } = getConfigPath(appPath);\n\n // Do a separate existence check for the top-level config, since it's fine if that doesn't exist.\n // (readAppConfigInternal throws if the file doesn't exist because it's also used for reading\n // parent configs from \"extends\", which must exist if specified.)\n let config: AppConfig;\n if (!fs.existsSync(appConfigPath)) {\n config = {};\n } else {\n config = (await readAppConfigInternal(appConfigPath)) || {};\n expandEnvironmentVariables(config as Record<string, unknown>);\n }\n\n if (extraPackageSettings) {\n // Add these last so they take precedence.\n (config.packageSettings ??= []).push(...extraPackageSettings);\n }\n\n return config;\n}\n\n/**\n * Resolve import specifiers for bundler capabilities registry.\n * Throws if a specifier can't be resolved.\n */\nfunction resolveBundlerCapabilities(params: { appConfig: AppConfig; configPath: string }): void {\n const {\n appConfig: { bundlerCapabilitiesRegistry },\n configPath,\n } = params;\n if (!bundlerCapabilitiesRegistry) {\n return;\n }\n\n for (const [name, importSpecifier] of Object.entries(bundlerCapabilitiesRegistry)) {\n try {\n const moduleUrl = resolveModule({ parentUrl: configPath, importSpecifier });\n bundlerCapabilitiesRegistry[name] = moduleUrl;\n } catch (e) {\n throw new Error(`Error resolving bundler capability \"${importSpecifier}\":\\n${(e as Error).message || e}`);\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> {\n const appConfig = await readJson<AppConfig>(configPath, { mode: 'permissive', throwOnError: true });\n if (!appConfig) {\n // shouldn't happen, but just in case/to satisfy the types...\n throw new Error(`Could not read config file ${configPath}`);\n }\n\n if (!validateConfig(appConfig)) {\n throw new Error(`Config file ${configPath} has invalid settings (see above for details)`);\n }\n\n resolveBundlerCapabilities({ appConfig, configPath });\n\n processDeprecatedValues(appConfig);\n\n // Read and merge with any parent configs (the same processing is applied to parent configs)\n const { extends: _extends = [] } = appConfig;\n const extendsArray = Array.isArray(_extends) ? _extends : [_extends];\n const parentConfigs = await Promise.all(\n extendsArray.map((importSpecifier) => readAppConfigInternal(resolveParentConfig({ configPath, importSpecifier }))),\n );\n return mergeParentConfig({ appConfig, parentConfigs });\n}\n\n/**\n * Validate parts of the current config file (before merging with parents) and log any errors.\n * Logging here and then letting the caller throw if needed allows us to show more errors at once.\n * @returns true if valid, false if not\n */\nfunction validateConfig(appConfig: AppConfig): boolean {\n let isValid = true;\n\n // Verify that there are no matches with a negated name and a version\n for (const setting of appConfig.packageSettings || []) {\n const { match } = setting;\n const matches = Array.isArray(match) ? match : [match];\n for (const m of matches) {\n const result = validateMatch(m);\n if (!result.isValid) {\n isValid = false;\n console.error(`Invalid packageSettings match: ${result.error}`);\n }\n }\n }\n\n return isValid;\n}\n\n/**\n * Delete deprecated values and convert them to the new format. (This mutates the `config` object.)\n */\nfunction processDeprecatedValues(config: AppConfig): void {\n /* eslint-disable etc/no-deprecated */\n const { devServer, server, packageSettings = [] } = config;\n\n if (devServer) {\n if (server) {\n throw new Error('Cannot have both \"devServer\" and \"server\" in the config file. Use \"server\" only.');\n }\n\n config.server = devServer;\n delete config.devServer;\n }\n\n if (server?.routes) {\n config.routes = server.routes;\n delete server.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 /* eslint-enable etc/no-deprecated */\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"getCachePath.d.ts","sourceRoot":"","sources":["../../src/userPreferences/getCachePath.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAAC,YAAY,CAAC,EAAE,MAAM,mBAEvD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,UAEhD"}
1
+ {"version":3,"file":"getCachePath.d.ts","sourceRoot":"","sources":["../../src/userPreferences/getCachePath.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAEzE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEzD"}
@@ -1 +1 @@
1
- {"version":3,"file":"getCachePath.js","sourceRoot":"","sources":["../../src/userPreferences/getCachePath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,YAAqB;IACtD,OAAO,YAAY,IAAI,CAAC,MAAM,mBAAmB,EAAE,CAAC,EAAE,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAC;AAC3G,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import os from 'os';\nimport path from 'path';\nimport { readUserPreferences } from './readUserPreferences.js';\n\n/**\n * Get the cache path from user preferences if set.\n * Falls back to the default cache path `~/.cloudpack`.\n *\n * NOTE: If a session object is available, you should use `session.cachePath` instead.\n *\n * @param overridePath If set, this path (probably from a CLI option) will be used instead\n * of the path from preferences.\n */\nexport async function getCachePath(overridePath?: string) {\n return overridePath || (await readUserPreferences())?.cachePath || path.join(os.homedir(), '.cloudpack');\n}\n\n/**\n * Gets the path to the app's local cache directory.\n */\nexport function getLocalCachePath(appPath: string) {\n return path.join(appPath, 'node_modules', '.cache', 'cloudpack');\n}\n"]}
1
+ {"version":3,"file":"getCachePath.js","sourceRoot":"","sources":["../../src/userPreferences/getCachePath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,YAAqB;IACtD,OAAO,YAAY,IAAI,CAAC,MAAM,mBAAmB,EAAE,CAAC,EAAE,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAC;AAC3G,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAAe;IAC/C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;AACnE,CAAC","sourcesContent":["import os from 'os';\nimport path from 'path';\nimport { readUserPreferences } from './readUserPreferences.js';\n\n/**\n * Get the cache path from user preferences if set.\n * Falls back to the default cache path `~/.cloudpack`.\n *\n * NOTE: If a session object is available, you should use `session.cachePath` instead.\n *\n * @param overridePath If set, this path (probably from a CLI option) will be used instead\n * of the path from preferences.\n */\nexport async function getCachePath(overridePath?: string): Promise<string> {\n return overridePath || (await readUserPreferences())?.cachePath || path.join(os.homedir(), '.cloudpack');\n}\n\n/**\n * Gets the path to the app's local cache directory.\n */\nexport function getLocalCachePath(appPath: string): string {\n return path.join(appPath, 'node_modules', '.cache', 'cloudpack');\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"getUserPreferencesPath.d.ts","sourceRoot":"","sources":["../../src/userPreferences/getUserPreferencesPath.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,wBAAgB,sBAAsB,WAErC;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,QAExD;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,uBAEzC"}
1
+ {"version":3,"file":"getUserPreferencesPath.d.ts","sourceRoot":"","sources":["../../src/userPreferences/getUserPreferencesPath.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE/D;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,GAAG,SAAS,CAE/D"}
@@ -1 +1 @@
1
- {"version":3,"file":"getUserPreferencesPath.js","sourceRoot":"","sources":["../../src/userPreferences/getUserPreferencesPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,IAAI,sBAA0C,CAAC;AAE/C;;GAEG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,IAAI,CAAC,IAAI,CAAC,sBAAsB,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,uBAAuB,CAAC,CAAC;AACpF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,yBAAyB,CAAC,OAAe;IACvD,sBAAsB,GAAG,OAAO,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B;IACxC,OAAO,sBAAsB,CAAC;AAChC,CAAC","sourcesContent":["import os from 'os';\nimport path from 'path';\nimport { userPreferencesFileName } from '../constants.js';\n\nlet mockUserPreferencesDir: string | undefined;\n\n/**\n * Path to the user-level preferences file.\n */\nexport function getUserPreferencesPath() {\n return path.join(mockUserPreferencesDir || os.homedir(), userPreferencesFileName);\n}\n\n/**\n * For testing only: use this folder instead of the home directory for the user preferences.\n */\nexport function setMockUserPreferencesDir(newPath: string) {\n mockUserPreferencesDir = newPath;\n}\n\n/**\n * Get the currently set mock user preferences directory.\n * @internal\n */\nexport function _getMockUserPreferencesDir() {\n return mockUserPreferencesDir;\n}\n"]}
1
+ {"version":3,"file":"getUserPreferencesPath.js","sourceRoot":"","sources":["../../src/userPreferences/getUserPreferencesPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,IAAI,sBAA0C,CAAC;AAE/C;;GAEG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,IAAI,CAAC,IAAI,CAAC,sBAAsB,IAAI,EAAE,CAAC,OAAO,EAAE,EAAE,uBAAuB,CAAC,CAAC;AACpF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,yBAAyB,CAAC,OAAe;IACvD,sBAAsB,GAAG,OAAO,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B;IACxC,OAAO,sBAAsB,CAAC;AAChC,CAAC","sourcesContent":["import os from 'os';\nimport path from 'path';\nimport { userPreferencesFileName } from '../constants.js';\n\nlet mockUserPreferencesDir: string | undefined;\n\n/**\n * Path to the user-level preferences file.\n */\nexport function getUserPreferencesPath(): string {\n return path.join(mockUserPreferencesDir || os.homedir(), userPreferencesFileName);\n}\n\n/**\n * For testing only: use this folder instead of the home directory for the user preferences.\n */\nexport function setMockUserPreferencesDir(newPath: string): void {\n mockUserPreferencesDir = newPath;\n}\n\n/**\n * Get the currently set mock user preferences directory.\n * @internal\n */\nexport function _getMockUserPreferencesDir(): string | undefined {\n return mockUserPreferencesDir;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"updateUserPreference.d.ts","sourceRoot":"","sources":["../../src/userPreferences/updateUserPreference.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAOlE;;;;;GAKG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE;IACjD,GAAG,EAAE,MAAM,eAAe,CAAC;IAC3B,iCAAiC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mBAAmB;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,iBAiCA"}
1
+ {"version":3,"file":"updateUserPreference.d.ts","sourceRoot":"","sources":["../../src/userPreferences/updateUserPreference.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAOlE;;;;;GAKG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE;IACjD,GAAG,EAAE,MAAM,eAAe,CAAC;IAC3B,iCAAiC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mBAAmB;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiChB"}
@@ -1 +1 @@
1
- {"version":3,"file":"updateUserPreference.js","sourceRoot":"","sources":["../../src/userPreferences/updateUserPreference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM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KAAK,CAAC;IAC9B,CAAC;IAED,OAAO,SAAS,CAAC,sBAAsB,EAAE,EAAE,cAAc,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;AACnG,CAAC;AAED,SAAS,aAAa,CAAC,GAA0B,EAAE,KAAa;IAC9D,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,WAAW,CAAC,CAAC,CAAC;YACjB,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;YACvD,CAAC;YAED,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;YAChE,CAAC;YAED,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACzC,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,CAAC;gBAChC,MAAM,IAAI,KAAK,CAAC,sBAAsB,YAAY,uCAAuC,CAAC,CAAC;YAC7F,CAAC;YAED,sBAAsB;YACtB,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,CAAC,CAAC,CAAC;YACR,uDAAuD;YACvD,MAAM,eAAe,GAAU,GAAG,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,+BAA+B,eAAe,GAAG,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { environmentInfo } from '@ms-cloudpack/environment';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport type { UserPreferences } from '@ms-cloudpack/common-types';\nimport { _getMockUserPreferencesDir, getUserPreferencesPath } from './getUserPreferencesPath.js';\nimport { allUserPreferences, userPreferencesSchemaUrl } from '../constants.js';\nimport { readUserPreferences } from './readUserPreferences.js';\nimport path from 'path';\nimport { isFolderSync } from '@ms-cloudpack/path-utilities';\n\n/**\n * Validate and write an update to a user preference item.\n * Creates the file if it doesn't already exist.\n *\n * Throws an error if the key is not a valid user preference name.\n */\nexport async function updateUserPreference(params: {\n key: keyof UserPreferences;\n /** Update `key` to `newValue` */\n newValue?: string;\n /** Delete `key` */\n deleteValue?: boolean;\n}) {\n const { key, deleteValue } = params;\n\n if (environmentInfo.isJest && !_getMockUserPreferencesDir()) {\n // Prevent tests from accidentally messing with real global state...\n throw new Error('Tests must call setMockUserPreferencesDir before calling updateUserPreference.');\n }\n\n // The key is user input which could potentially be invalid, despite the types.\n if (!allUserPreferences[key]) {\n throw new Error(`\"${key}\" is not a valid user preference name.`);\n }\n\n let value = params.newValue?.trim();\n\n if (!deleteValue) {\n if (value === undefined) {\n throw new Error('Must specify newValue or deleteValue (this is a bug in Cloudpack)');\n }\n value = validateValue(key, value);\n }\n\n const newPreferences = {\n ...(await readUserPreferences()),\n $schema: userPreferencesSchemaUrl,\n };\n if (deleteValue) {\n delete newPreferences[key];\n } else {\n newPreferences[key] = value;\n }\n\n return writeJson(getUserPreferencesPath(), newPreferences, { update: true, mode: 'permissive' });\n}\n\nfunction validateValue(key: keyof UserPreferences, value: string) {\n switch (key) {\n case 'cachePath': {\n if (!value) {\n throw new Error('The cache folder cannot be empty.');\n }\n\n if (!path.isAbsolute(value)) {\n throw new Error('The cache folder must be an absolute path.');\n }\n\n const parentFolder = path.dirname(value);\n if (!isFolderSync(parentFolder)) {\n throw new Error(`The parent folder \"${parentFolder}\" of the cache folder does not exist.`);\n }\n\n // The folder is valid\n return value;\n }\n\n default: {\n // this gives a type error if a new preference is added\n const exhaustiveCheck: never = key;\n throw new Error(`Unhandled user preference: \"${exhaustiveCheck}\"`);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"updateUserPreference.js","sourceRoot":"","sources":["../../src/userPreferences/updateUserPreference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,OA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IAED,OAAO,SAAS,CAAC,sBAAsB,EAAE,EAAE,cAAc,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;AACnG,CAAC;AAED,SAAS,aAAa,CAAC,GAA0B,EAAE,KAAa;IAC9D,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,WAAW,CAAC,CAAC,CAAC;YACjB,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;YACvD,CAAC;YAED,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;YAChE,CAAC;YAED,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACzC,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,CAAC;gBAChC,MAAM,IAAI,KAAK,CAAC,sBAAsB,YAAY,uCAAuC,CAAC,CAAC;YAC7F,CAAC;YAED,sBAAsB;YACtB,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,CAAC,CAAC,CAAC;YACR,uDAAuD;YACvD,MAAM,eAAe,GAAU,GAAG,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,+BAA+B,eAAe,GAAG,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { environmentInfo } from '@ms-cloudpack/environment';\nimport { writeJson } from '@ms-cloudpack/json-utilities';\nimport type { UserPreferences } from '@ms-cloudpack/common-types';\nimport { _getMockUserPreferencesDir, getUserPreferencesPath } from './getUserPreferencesPath.js';\nimport { allUserPreferences, userPreferencesSchemaUrl } from '../constants.js';\nimport { readUserPreferences } from './readUserPreferences.js';\nimport path from 'path';\nimport { isFolderSync } from '@ms-cloudpack/path-utilities';\n\n/**\n * Validate and write an update to a user preference item.\n * Creates the file if it doesn't already exist.\n *\n * Throws an error if the key is not a valid user preference name.\n */\nexport async function updateUserPreference(params: {\n key: keyof UserPreferences;\n /** Update `key` to `newValue` */\n newValue?: string;\n /** Delete `key` */\n deleteValue?: boolean;\n}): Promise<void> {\n const { key, deleteValue } = params;\n\n if (environmentInfo.isJest && !_getMockUserPreferencesDir()) {\n // Prevent tests from accidentally messing with real global state...\n throw new Error('Tests must call setMockUserPreferencesDir before calling updateUserPreference.');\n }\n\n // The key is user input which could potentially be invalid, despite the types.\n if (!allUserPreferences[key]) {\n throw new Error(`\"${key}\" is not a valid user preference name.`);\n }\n\n let value = params.newValue?.trim();\n\n if (!deleteValue) {\n if (value === undefined) {\n throw new Error('Must specify newValue or deleteValue (this is a bug in Cloudpack)');\n }\n value = validateValue(key, value);\n }\n\n const newPreferences = {\n ...(await readUserPreferences()),\n $schema: userPreferencesSchemaUrl,\n };\n if (deleteValue) {\n delete newPreferences[key];\n } else {\n newPreferences[key] = value;\n }\n\n return writeJson(getUserPreferencesPath(), newPreferences, { update: true, mode: 'permissive' });\n}\n\nfunction validateValue(key: keyof UserPreferences, value: string): string {\n switch (key) {\n case 'cachePath': {\n if (!value) {\n throw new Error('The cache folder cannot be empty.');\n }\n\n if (!path.isAbsolute(value)) {\n throw new Error('The cache folder must be an absolute path.');\n }\n\n const parentFolder = path.dirname(value);\n if (!isFolderSync(parentFolder)) {\n throw new Error(`The parent folder \"${parentFolder}\" of the cache folder does not exist.`);\n }\n\n // The folder is valid\n return value;\n }\n\n default: {\n // this gives a type error if a new preference is added\n const exhaustiveCheck: never = key;\n throw new Error(`Unhandled user preference: \"${exhaustiveCheck}\"`);\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sortGeneratedConfig.d.ts","sourceRoot":"","sources":["../../src/writeConfig/sortGeneratedConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAA4B,MAAM,4BAA4B,CAAC;AAI5F;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,eAAe,QAoC7D"}
1
+ {"version":3,"file":"sortGeneratedConfig.d.ts","sourceRoot":"","sources":["../../src/writeConfig/sortGeneratedConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAA4B,MAAM,4BAA4B,CAAC;AAI5F;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI,CAoCpE"}
@@ -1 +1 @@
1
- {"version":3,"file":"sortGeneratedConfig.js","sourceRoot":"","sources":["../../src/writeConfig/sortGeneratedConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE;;;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 '../packageSettings/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}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,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 '../packageSettings/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): void {\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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"writeAppConfig.d.ts","sourceRoot":"","sources":["../../src/writeConfig/writeAppConfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAI5D;;;GAGG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,iBAWtE"}
1
+ {"version":3,"file":"writeAppConfig.d.ts","sourceRoot":"","sources":["../../src/writeConfig/writeAppConfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAI5D;;;GAGG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAWtF"}
@@ -1 +1 @@
1
- {"version":3,"file":"writeAppConfig.js","sourceRoot":"","sources":["../../src/writeConfig/writeAppConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAiB,EAAE,OAAe;IACrE,MAAM,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAEjD,OAAO,SAAS,CACd,aAAa,EACb;QACE,OAAO,EAAE,kBAAkB;QAC3B,GAAG,MAAM;KACV,EACD,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CACrC,CAAC;AACJ,CAAC","sourcesContent":["import { writeJson } from '@ms-cloudpack/json-utilities';\nimport type { AppConfig } from '@ms-cloudpack/common-types';\nimport { getConfigPath } from '../getConfigPath.js';\nimport { appConfigSchemaUrl } from '../constants.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 writeAppConfig(config: AppConfig, appPath: string) {\n const { appConfigPath } = getConfigPath(appPath);\n\n return writeJson(\n appConfigPath,\n {\n $schema: appConfigSchemaUrl,\n ...config,\n },\n { update: true, mode: 'permissive' },\n );\n}\n"]}
1
+ {"version":3,"file":"writeAppConfig.js","sourceRoot":"","sources":["../../src/writeConfig/writeAppConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAiB,EAAE,OAAe;IACrE,MAAM,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAEjD,OAAO,SAAS,CACd,aAAa,EACb;QACE,OAAO,EAAE,kBAAkB;QAC3B,GAAG,MAAM;KACV,EACD,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,CACrC,CAAC;AACJ,CAAC","sourcesContent":["import { writeJson } from '@ms-cloudpack/json-utilities';\nimport type { AppConfig } from '@ms-cloudpack/common-types';\nimport { getConfigPath } from '../getConfigPath.js';\nimport { appConfigSchemaUrl } from '../constants.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 writeAppConfig(config: AppConfig, appPath: string): Promise<void> {\n const { appConfigPath } = getConfigPath(appPath);\n\n return writeJson(\n appConfigPath,\n {\n $schema: appConfigSchemaUrl,\n ...config,\n },\n { update: true, mode: 'permissive' },\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"writeGeneratedConfig.d.ts","sourceRoot":"","sources":["../../src/writeConfig/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
+ {"version":3,"file":"writeGeneratedConfig.d.ts","sourceRoot":"","sources":["../../src/writeConfig/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,GAAG,IAAI,CAElE"}
@@ -1 +1 @@
1
- {"version":3,"file":"writeGeneratedConfig.js","sourceRoot":"","sources":["../../src/writeConfig/writeGeneratedConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,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 '../constants.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"]}
1
+ {"version":3,"file":"writeGeneratedConfig.js","sourceRoot":"","sources":["../../src/writeConfig/writeGeneratedConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,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 '../constants.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): void {\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.33.4",
3
+ "version": "0.33.5",
4
4
  "description": "Configuration handling for cloudpack.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -17,7 +17,7 @@
17
17
  "@ms-cloudpack/common-types": "^0.23.7",
18
18
  "@ms-cloudpack/environment": "^0.1.1",
19
19
  "@ms-cloudpack/json-utilities": "^0.1.9",
20
- "@ms-cloudpack/package-utilities": "^11.0.0",
20
+ "@ms-cloudpack/package-utilities": "^11.0.1",
21
21
  "@ms-cloudpack/path-string-parsing": "^1.2.6",
22
22
  "@ms-cloudpack/path-utilities": "^2.8.0",
23
23
  "semver": "^7.6.0"