@ms-cloudpack/config 0.37.5 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,9 +20,9 @@ export declare const userPreferencesFileName = ".cloudpack.preferences.json";
20
20
  */
21
21
  export declare const allUserPreferences: Readonly<Record<keyof UserPreferences, string>>;
22
22
  /** unpkg URL for the GeneratedConfig JSON schema */
23
- export declare const generatedAppConfigSchemaUrl = "https://unpkg.com/@ms-cloudpack/common-types/schema/GeneratedConfig.json";
23
+ export declare const generatedAppConfigSchemaUrl = "https://unpkg.com/@ms-cloudpack/cli/schema/GeneratedConfig.json";
24
24
  /** unpkg URL for the AppConfig JSON schema */
25
- export declare const appConfigSchemaUrl = "https://unpkg.com/@ms-cloudpack/common-types/schema/AppConfig.json";
25
+ export declare const appConfigSchemaUrl = "https://unpkg.com/@ms-cloudpack/cli/schema/AppConfig.json";
26
26
  /** unpkg URL for the UserPreferences JSON schema */
27
- export declare const userPreferencesSchemaUrl = "https://unpkg.com/@ms-cloudpack/common-types/schema/UserPreferences.json";
27
+ export declare const userPreferencesSchemaUrl = "https://unpkg.com/@ms-cloudpack/cli/schema/UserPreferences.json";
28
28
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE;;GAEG;AACH,eAAO,MAAM,iBAAiB,0BAA0B,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,oBAAoB,kFAAmF,CAAC;AAErH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,uCAAuC,CAAC;AAEtE,eAAO,MAAM,uBAAuB,6BAA6B,CAAC;AAElE,eAAO,MAAM,uBAAuB,gCAAgC,CAAC;AAErE;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,eAAe,EAAE,MAAM,CAAC,CAE9E,CAAC;AAIF,oDAAoD;AACpD,eAAO,MAAM,2BAA2B,6EAAyC,CAAC;AAElF,8CAA8C;AAC9C,eAAO,MAAM,kBAAkB,uEAAmC,CAAC;AAEnE,oDAAoD;AACpD,eAAO,MAAM,wBAAwB,6EAAyC,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE;;GAEG;AACH,eAAO,MAAM,iBAAiB,0BAA0B,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,oBAAoB,kFAAmF,CAAC;AAErH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,uCAAuC,CAAC;AAEtE,eAAO,MAAM,uBAAuB,6BAA6B,CAAC;AAElE,eAAO,MAAM,uBAAuB,gCAAgC,CAAC;AAErE;;GAEG;AACH,eAAO,MAAM,kBAAkB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,eAAe,EAAE,MAAM,CAAC,CAE9E,CAAC;AAIF,oDAAoD;AACpD,eAAO,MAAM,2BAA2B,oEAAyC,CAAC;AAElF,8CAA8C;AAC9C,eAAO,MAAM,kBAAkB,8DAAmC,CAAC;AAEnE,oDAAoD;AACpD,eAAO,MAAM,wBAAwB,oEAAyC,CAAC"}
package/lib/constants.js CHANGED
@@ -20,7 +20,7 @@ export const userPreferencesFileName = '.cloudpack.preferences.json';
20
20
  export const allUserPreferences = {
21
21
  cachePath: 'Absolute path to the cache folder, instead of the default <home>/.cloudpack',
22
22
  };
23
- const schemaPrefix = 'https://unpkg.com/@ms-cloudpack/common-types/schema';
23
+ const schemaPrefix = 'https://unpkg.com/@ms-cloudpack/cli/schema';
24
24
  /** unpkg URL for the GeneratedConfig JSON schema */
25
25
  export const generatedAppConfigSchemaUrl = `${schemaPrefix}/GeneratedConfig.json`;
26
26
  /** unpkg URL for the AppConfig JSON schema */
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AAEzD;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,qBAAqB,EAAE,sBAAsB,EAAE,sBAAsB,CAAU,CAAC;AAErH;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,oCAAoC,CAAC;AAEtE,MAAM,CAAC,MAAM,uBAAuB,GAAG,0BAA0B,CAAC;AAElE,MAAM,CAAC,MAAM,uBAAuB,GAAG,6BAA6B,CAAC;AAErE;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAoD;IACjF,SAAS,EAAE,6EAA6E;CACzF,CAAC;AAEF,MAAM,YAAY,GAAG,qDAAqD,CAAC;AAE3E,oDAAoD;AACpD,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,YAAY,uBAAuB,CAAC;AAElF,8CAA8C;AAC9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,YAAY,iBAAiB,CAAC;AAEnE,oDAAoD;AACpD,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,YAAY,uBAAuB,CAAC","sourcesContent":["import type { UserPreferences } from '@ms-cloudpack/common-types';\n\n/**\n * File name constant for the user defined app config JSON.\n */\nexport const appConfigFileName = 'cloudpack.config.json';\n\n/**\n * File name constants for the user defined app config JS.\n */\nexport const appConfigFileNamesJS = ['cloudpack.config.js', 'cloudpack.config.mjs', 'cloudpack.config.cjs'] as const;\n\n/**\n * Glob pattern for matching any Cloudpack config file (basename only).\n * Use with appropriate prefixes like `./` as needed.\n * Matches: cloudpack.config.json, cloudpack.config.js, cloudpack.config.mjs, cloudpack.config.cjs\n */\nexport const appConfigFileGlob = 'cloudpack.config.{json,js,mjs,cjs}';\n\nexport const generatedConfigFileName = 'cloudpack.generated.json';\n\nexport const userPreferencesFileName = '.cloudpack.preferences.json';\n\n/**\n * Object with descriptions of each user preference key.\n */\nexport const allUserPreferences: Readonly<Record<keyof UserPreferences, string>> = {\n cachePath: 'Absolute path to the cache folder, instead of the default <home>/.cloudpack',\n};\n\nconst schemaPrefix = 'https://unpkg.com/@ms-cloudpack/common-types/schema';\n\n/** unpkg URL for the GeneratedConfig JSON schema */\nexport const generatedAppConfigSchemaUrl = `${schemaPrefix}/GeneratedConfig.json`;\n\n/** unpkg URL for the AppConfig JSON schema */\nexport const appConfigSchemaUrl = `${schemaPrefix}/AppConfig.json`;\n\n/** unpkg URL for the UserPreferences JSON schema */\nexport const userPreferencesSchemaUrl = `${schemaPrefix}/UserPreferences.json`;\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AAEzD;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,qBAAqB,EAAE,sBAAsB,EAAE,sBAAsB,CAAU,CAAC;AAErH;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,oCAAoC,CAAC;AAEtE,MAAM,CAAC,MAAM,uBAAuB,GAAG,0BAA0B,CAAC;AAElE,MAAM,CAAC,MAAM,uBAAuB,GAAG,6BAA6B,CAAC;AAErE;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAoD;IACjF,SAAS,EAAE,6EAA6E;CACzF,CAAC;AAEF,MAAM,YAAY,GAAG,4CAA4C,CAAC;AAElE,oDAAoD;AACpD,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,YAAY,uBAAuB,CAAC;AAElF,8CAA8C;AAC9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,YAAY,iBAAiB,CAAC;AAEnE,oDAAoD;AACpD,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,YAAY,uBAAuB,CAAC","sourcesContent":["import type { UserPreferences } from '@ms-cloudpack/common-types';\n\n/**\n * File name constant for the user defined app config JSON.\n */\nexport const appConfigFileName = 'cloudpack.config.json';\n\n/**\n * File name constants for the user defined app config JS.\n */\nexport const appConfigFileNamesJS = ['cloudpack.config.js', 'cloudpack.config.mjs', 'cloudpack.config.cjs'] as const;\n\n/**\n * Glob pattern for matching any Cloudpack config file (basename only).\n * Use with appropriate prefixes like `./` as needed.\n * Matches: cloudpack.config.json, cloudpack.config.js, cloudpack.config.mjs, cloudpack.config.cjs\n */\nexport const appConfigFileGlob = 'cloudpack.config.{json,js,mjs,cjs}';\n\nexport const generatedConfigFileName = 'cloudpack.generated.json';\n\nexport const userPreferencesFileName = '.cloudpack.preferences.json';\n\n/**\n * Object with descriptions of each user preference key.\n */\nexport const allUserPreferences: Readonly<Record<keyof UserPreferences, string>> = {\n cachePath: 'Absolute path to the cache folder, instead of the default <home>/.cloudpack',\n};\n\nconst schemaPrefix = 'https://unpkg.com/@ms-cloudpack/cli/schema';\n\n/** unpkg URL for the GeneratedConfig JSON schema */\nexport const generatedAppConfigSchemaUrl = `${schemaPrefix}/GeneratedConfig.json`;\n\n/** unpkg URL for the AppConfig JSON schema */\nexport const appConfigSchemaUrl = `${schemaPrefix}/AppConfig.json`;\n\n/** unpkg URL for the UserPreferences JSON schema */\nexport const userPreferencesSchemaUrl = `${schemaPrefix}/UserPreferences.json`;\n"]}
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Get config paths for the app at `cwd`.
3
3
  * @param cwd - base path of the config file
4
+ * @param customConfigFileName - optional custom config file name to use instead of defaults
4
5
  */
5
- export declare function getConfigPath(cwd: string): {
6
+ export declare function getConfigPath(cwd: string, customConfigFileName?: string): {
6
7
  /** Default JSON app config path */
7
8
  defaultAppConfigPath: string;
8
9
  /** All app config paths including JSON and JS */
@@ -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,GAAG;IAC1C,mCAAmC;IACnC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,iDAAiD;IACjD,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CAOA"}
1
+ {"version":3,"file":"getConfigPath.d.ts","sourceRoot":"","sources":["../src/getConfigPath.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,oBAAoB,CAAC,EAAE,MAAM,GAC5B;IACD,mCAAmC;IACnC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,iDAAiD;IACjD,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CAgBA"}
@@ -3,8 +3,17 @@ import { appConfigFileName, appConfigFileNamesJS, generatedConfigFileName } from
3
3
  /**
4
4
  * Get config paths for the app at `cwd`.
5
5
  * @param cwd - base path of the config file
6
+ * @param customConfigFileName - optional custom config file name to use instead of defaults
6
7
  */
7
- export function getConfigPath(cwd) {
8
+ export function getConfigPath(cwd, customConfigFileName) {
9
+ if (customConfigFileName) {
10
+ const customConfigPath = path.join(cwd, customConfigFileName);
11
+ return {
12
+ defaultAppConfigPath: customConfigPath,
13
+ appConfigPaths: [customConfigPath],
14
+ generatedConfigPath: path.join(cwd, generatedConfigFileName),
15
+ };
16
+ }
8
17
  const defaultAppConfigPath = path.join(cwd, appConfigFileName);
9
18
  return {
10
19
  defaultAppConfigPath,
@@ -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,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAElG;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IAOvC,MAAM,oBAAoB,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;IAC/D,OAAO;QACL,oBAAoB;QACpB,cAAc,EAAE,CAAC,oBAAoB,EAAE,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;QAC3G,mBAAmB,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,uBAAuB,CAAC;KAC7D,CAAC;AACJ,CAAC","sourcesContent":["import path from 'path';\nimport { appConfigFileName, appConfigFileNamesJS, generatedConfigFileName } from './constants.js';\n\n/**\n * Get config paths for the app at `cwd`.\n * @param cwd - base path of the config file\n */\nexport function getConfigPath(cwd: string): {\n /** Default JSON app config path */\n defaultAppConfigPath: string;\n /** All app config paths including JSON and JS */\n appConfigPaths: string[];\n generatedConfigPath: string;\n} {\n const defaultAppConfigPath = path.join(cwd, appConfigFileName);\n return {\n defaultAppConfigPath,\n appConfigPaths: [defaultAppConfigPath, ...appConfigFileNamesJS.map((fileName) => path.join(cwd, fileName))],\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,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAElG;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAC3B,GAAW,EACX,oBAA6B;IAQ7B,IAAI,oBAAoB,EAAE,CAAC;QACzB,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;QAC9D,OAAO;YACL,oBAAoB,EAAE,gBAAgB;YACtC,cAAc,EAAE,CAAC,gBAAgB,CAAC;YAClC,mBAAmB,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,uBAAuB,CAAC;SAC7D,CAAC;IACJ,CAAC;IAED,MAAM,oBAAoB,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;IAC/D,OAAO;QACL,oBAAoB;QACpB,cAAc,EAAE,CAAC,oBAAoB,EAAE,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;QAC3G,mBAAmB,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,uBAAuB,CAAC;KAC7D,CAAC;AACJ,CAAC","sourcesContent":["import path from 'path';\nimport { appConfigFileName, appConfigFileNamesJS, generatedConfigFileName } from './constants.js';\n\n/**\n * Get config paths for the app at `cwd`.\n * @param cwd - base path of the config file\n * @param customConfigFileName - optional custom config file name to use instead of defaults\n */\nexport function getConfigPath(\n cwd: string,\n customConfigFileName?: string,\n): {\n /** Default JSON app config path */\n defaultAppConfigPath: string;\n /** All app config paths including JSON and JS */\n appConfigPaths: string[];\n generatedConfigPath: string;\n} {\n if (customConfigFileName) {\n const customConfigPath = path.join(cwd, customConfigFileName);\n return {\n defaultAppConfigPath: customConfigPath,\n appConfigPaths: [customConfigPath],\n generatedConfigPath: path.join(cwd, generatedConfigFileName),\n };\n }\n\n const defaultAppConfigPath = path.join(cwd, appConfigFileName);\n return {\n defaultAppConfigPath,\n appConfigPaths: [defaultAppConfigPath, ...appConfigFileNamesJS.map((fileName) => path.join(cwd, fileName))],\n generatedConfigPath: path.join(cwd, generatedConfigFileName),\n };\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -12,7 +12,6 @@ export { getPackageSettings } from './packageSettings/getPackageSettings.js';
12
12
  export { getGeneratedPackageSettings } from './packageSettings/getGeneratedPackageSettings.js';
13
13
  export { readConfig, type ReadConfigOptions } from './readConfig/readConfig.js';
14
14
  export { readGeneratedConfig } from './readConfig/readGeneratedConfig.js';
15
- export { readAppConfig } from './readConfig/readAppConfig.js';
16
15
  export { readUserPreferences } from './userPreferences/readUserPreferences.js';
17
16
  export { writeGeneratedConfig } from './writeConfig/writeGeneratedConfig.js';
18
17
  export { writeAppConfig } from './writeConfig/writeAppConfig.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACrH,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kDAAkD,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AAChH,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAC;AAC/F,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAA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E,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,iCAAiC,EAAE,MAAM,wDAAwD,CAAC;AAC3G,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC"}
package/lib/index.js CHANGED
@@ -12,7 +12,6 @@ export { getPackageSettings } from './packageSettings/getPackageSettings.js';
12
12
  export { getGeneratedPackageSettings } from './packageSettings/getGeneratedPackageSettings.js';
13
13
  export { readConfig } from './readConfig/readConfig.js';
14
14
  export { readGeneratedConfig } from './readConfig/readGeneratedConfig.js';
15
- export { readAppConfig } from './readConfig/readAppConfig.js';
16
15
  export { readUserPreferences } from './userPreferences/readUserPreferences.js';
17
16
  export { writeGeneratedConfig } from './writeConfig/writeGeneratedConfig.js';
18
17
  export { writeAppConfig } from './writeConfig/writeAppConfig.js';
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACrH,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kDAAkD,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AAChH,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAC;AAC/F,OAAO,EAAE,UAAU,EAA0B,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,iCAAiC,EAAE,MAAM,wDAAwD,CAAC;AAC3G,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC","sourcesContent":["export { augmentAppConfig } from './readConfig/augmentAppConfig.js';\nexport { checkMatch } from './packageSettings/checkMatch.js';\nexport { ensureAppConfig } from './writeConfig/ensureAppConfig.js';\nexport { getBuiltInSettings } from './builtInSettings/getBuiltInSettings.js';\nexport { generatedConfigFileName, appConfigFileName, appConfigFileNamesJS, appConfigFileGlob } from './constants.js';\nexport { allUserPreferences } from './constants.js';\nexport { createPackageDefinitions } from './packageDefinitions/createPackageDefinitions.js';\nexport { getCachePath, getLocalCachePath } from './userPreferences/getCachePath.js';\nexport { getConfigPath } from './getConfigPath.js';\nexport { getUserPreferencesPath, setMockUserPreferencesDir } from './userPreferences/getUserPreferencesPath.js';\nexport { getPackageSettings } from './packageSettings/getPackageSettings.js';\nexport { getGeneratedPackageSettings } from './packageSettings/getGeneratedPackageSettings.js';\nexport { readConfig, type ReadConfigOptions } from './readConfig/readConfig.js';\nexport { readGeneratedConfig } from './readConfig/readGeneratedConfig.js';\nexport { readAppConfig } from './readConfig/readAppConfig.js';\nexport { readUserPreferences } from './userPreferences/readUserPreferences.js';\nexport { writeGeneratedConfig } from './writeConfig/writeGeneratedConfig.js';\nexport { writeAppConfig } from './writeConfig/writeAppConfig.js';\nexport { ensureGeneratedSettingsForPackage } from './packageSettings/ensureGeneratedSettingsForPackage.js';\nexport { updateUserPreference } from './userPreferences/updateUserPreference.js';\nexport { validateMatch } from './packageSettings/validateMatch.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACrH,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kDAAkD,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,6CAA6C,CAAC;AAChH,OAAO,EAAE,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAC;AAC/F,OAAO,EAAE,UAAU,EAA0B,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,iCAAiC,EAAE,MAAM,wDAAwD,CAAC;AAC3G,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC","sourcesContent":["export { augmentAppConfig } from './readConfig/augmentAppConfig.js';\nexport { checkMatch } from './packageSettings/checkMatch.js';\nexport { ensureAppConfig } from './writeConfig/ensureAppConfig.js';\nexport { getBuiltInSettings } from './builtInSettings/getBuiltInSettings.js';\nexport { generatedConfigFileName, appConfigFileName, appConfigFileNamesJS, appConfigFileGlob } from './constants.js';\nexport { allUserPreferences } from './constants.js';\nexport { createPackageDefinitions } from './packageDefinitions/createPackageDefinitions.js';\nexport { getCachePath, getLocalCachePath } from './userPreferences/getCachePath.js';\nexport { getConfigPath } from './getConfigPath.js';\nexport { getUserPreferencesPath, setMockUserPreferencesDir } from './userPreferences/getUserPreferencesPath.js';\nexport { getPackageSettings } from './packageSettings/getPackageSettings.js';\nexport { getGeneratedPackageSettings } from './packageSettings/getGeneratedPackageSettings.js';\nexport { readConfig, type ReadConfigOptions } from './readConfig/readConfig.js';\nexport { readGeneratedConfig } from './readConfig/readGeneratedConfig.js';\nexport { readUserPreferences } from './userPreferences/readUserPreferences.js';\nexport { writeGeneratedConfig } from './writeConfig/writeGeneratedConfig.js';\nexport { writeAppConfig } from './writeConfig/writeAppConfig.js';\nexport { ensureGeneratedSettingsForPackage } from './packageSettings/ensureGeneratedSettingsForPackage.js';\nexport { updateUserPreference } from './userPreferences/updateUserPreference.js';\nexport { validateMatch } from './packageSettings/validateMatch.js';\n"]}
@@ -17,6 +17,10 @@ export interface ReadAppConfigOptions {
17
17
  * Enable default features that are not explicitly set in the config.
18
18
  */
19
19
  enableDefaultFeatures?: boolean;
20
+ /**
21
+ * Custom config file name to use instead of cloudpack.config.json
22
+ */
23
+ configFileName?: string;
20
24
  }
21
25
  /**
22
26
  * Reads the user config file and merges with any parent configs asynchronously.
@@ -1 +1 @@
1
- {"version":3,"file":"readAppConfig.d.ts","sourceRoot":"","sources":["../../src/readConfig/readAppConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAEvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAatE,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,aAAa,CAAC,EAAE,QAAQ,CAAC;IAEzB;;OAEG;IACH,oBAAoB,CAAC,EAAE,eAAe,EAAE,CAAC;IAEzC;;OAEG;IACH,gBAAgB,CAAC,EAAE,WAAW,CAAC;IAE/B;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,SAAS,CAAC,CAgCvG"}
1
+ {"version":3,"file":"readAppConfig.d.ts","sourceRoot":"","sources":["../../src/readConfig/readAppConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAEvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAatE,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,aAAa,CAAC,EAAE,QAAQ,CAAC;IAEzB;;OAEG;IACH,oBAAoB,CAAC,EAAE,eAAe,EAAE,CAAC;IAEzC;;OAEG;IACH,gBAAgB,CAAC,EAAE,WAAW,CAAC;IAE/B;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,SAAS,CAAC,CAoCvG"}
@@ -20,7 +20,7 @@ import { augmentAppConfig } from './augmentAppConfig.js';
20
20
  * checks certain specific settings.)
21
21
  */
22
22
  export async function readAppConfig(appPath, options) {
23
- const { appConfigPaths } = getConfigPath(appPath);
23
+ const { appConfigPaths } = getConfigPath(appPath, options?.configFileName);
24
24
  let config;
25
25
  // Check for JS and JSON config files.
26
26
  const existingPaths = appConfigPaths.filter((p) => fs.existsSync(p));
@@ -30,6 +30,10 @@ export async function readAppConfig(appPath, options) {
30
30
  }
31
31
  const appConfigPath = existingPaths[0];
32
32
  if (!appConfigPath) {
33
+ // If a custom config was specified, it must exist
34
+ if (options?.configFileName) {
35
+ throw new Error(`Config file not found: ${options.configFileName}`);
36
+ }
33
37
  // This is fine, use an empty config
34
38
  config = {};
35
39
  }
@@ -1 +1 @@
1
- {"version":3,"file":"readAppConfig.js","sourceRoot":"","sources":["../../src/readConfig/readAppConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,C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BAA+B,UAAU,iEAAiE;YACxG,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAC7B,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,uBAAuB,CAAC,MAAiB;IAChD,sCAAsC;IACtC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC;IAE3D,IAAI,SAAS,EAAE,CAAC;QACd,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,kFAAkF,CAAC,CAAC;QACtG,CAAC;QAED,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC;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, Features, PackageSettings } from '@ms-cloudpack/common-types';\nimport { allFeatures } from '@ms-cloudpack/common-types';\nimport type { DefineFlags } from '@ms-cloudpack/common-types-browser';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport { resolveModule } from '@ms-cloudpack/path-utilities';\nimport fs from 'fs';\nimport path from 'path';\nimport { pathToFileURL } from 'url';\nimport { getConfigPath } from '../getConfigPath.js';\nimport { validateMatch } from '../packageSettings/validateMatch.js';\nimport { expandEnvironmentVariables } from './expandEnvironmentVariables.js';\nimport { mergeParentConfig } from './mergeParentConfig.js';\nimport { resolveParentConfig } from './resolveParentConfig.js';\nimport { augmentAppConfig } from './augmentAppConfig.js';\n\nexport interface ReadAppConfigOptions {\n /**\n * Extra feature settings. There will be a warning if any of these are invalid.\n */\n extraFeatures?: Features;\n\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 * Extra define flags to add at the end of user-provided settings (so they take precedence).\n */\n extraDefineFlags?: DefineFlags;\n\n /**\n * Enable default features that are not explicitly set in the config.\n */\n enableDefaultFeatures?: boolean;\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 { appConfigPaths } = getConfigPath(appPath);\n\n let config: AppConfig;\n\n // Check for JS and JSON config files.\n const existingPaths = appConfigPaths.filter((p) => fs.existsSync(p));\n if (existingPaths.length > 1) {\n const message = 'Multiple Cloudpack config files found. Determine the correct one and delete the others:';\n throw new Error([message, ...existingPaths].join('\\n '));\n }\n\n const appConfigPath = existingPaths[0];\n if (!appConfigPath) {\n // This is fine, use an empty config\n config = {};\n } else if (path.extname(appConfigPath) === '.json') {\n // Check for an existing JSON app config first\n config = await readJsonAppConfig(appConfigPath);\n } else {\n // Otherwise, read as a JS file\n config = await readJsAppConfig(appConfigPath);\n }\n\n expandEnvironmentVariables(config as Record<string, unknown>);\n\n // Merge extra settings (usually from CLI options) into the final config.\n if (options) {\n config = augmentAppConfig(config, options);\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({ parentPath: configPath, importSpecifier });\n bundlerCapabilitiesRegistry[name] = moduleUrl.toString();\n } catch (e) {\n throw new Error(`Error resolving bundler capability \"${importSpecifier}\":\\n${(e as Error).message || e}`);\n }\n }\n}\n\n/**\n * Reads the JSON app config file and calls `processConfig` on it.\n * Throws an error if the config file exists but is not valid JSON, or there's some error reading it.\n * @param configPath - The path to the config file.\n * @returns The parsed AppConfig object.\n */\nasync function readJsonAppConfig(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(`Cloudpack config not found at ${configPath}`);\n }\n return processConfig(configPath, appConfig);\n}\n\n/**\n * Reads the JavaScript app config file and calls `processConfig` on it.\n * Throws an error if the config file exists but is not valid, or there's some error reading it.\n * @param configPath - The path to the config file.\n * @returns The parsed AppConfig object.\n */\nasync function readJsAppConfig(configPath: string): Promise<AppConfig> {\n // Convert configPath to a URL for import.\n try {\n const appConfig = (await (import(pathToFileURL(configPath).toString()) as Promise<{ default?: AppConfig }>))\n .default;\n if (!appConfig) {\n throw new Error(`Missing default export from Cloudpack config at ${configPath}`);\n }\n return processConfig(configPath, appConfig);\n } catch (e) {\n throw new Error(`Error reading config file ${configPath}:\\n${(e as Error).message || e}`);\n }\n}\n\n/**\n * Processes the app config file and merges it with any parent configs.\n * This includes validating the config, checking for deprecated values, and resolving bundler capabilities.\n */\nasync function processConfig(configPath: string, appConfig: AppConfig): Promise<AppConfig> {\n if (!validateConfig(appConfig)) {\n throw new Error(`Config file ${configPath} has invalid settings (see above for details)`);\n }\n\n checkFeatures(appConfig.features, configPath);\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) => {\n const parentConfigPath = resolveParentConfig({ configPath, importSpecifier });\n return path.extname(parentConfigPath).toLowerCase() === '.json'\n ? readJsonAppConfig(parentConfigPath)\n : readJsAppConfig(parentConfigPath);\n }),\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 * Warn if any feature names are invalid, and remove them.\n */\nfunction checkFeatures(features: Record<string, boolean> | undefined, configPath: string): void {\n if (!features) {\n return;\n }\n\n const invalidFeatures: string[] = [];\n for (const featureName of Object.keys(features)) {\n if (!allFeatures[featureName as keyof Features]) {\n invalidFeatures.push(featureName);\n delete features[featureName];\n }\n }\n\n if (invalidFeatures.length) {\n console.warn(\n `Unknown feature(s) found in ${configPath} (most likely they were graduated or removed in Cloudpack):\\n ` +\n invalidFeatures.join(', '),\n );\n }\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,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AA6BzD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAe,EAAE,OAA8B;IACjF,MAAM,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;IAE3E,IAAI,MAAiB,CAAC;IAEtB,sCAAsC;IACtC,MAAM,aAAa,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACrE,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAG,yFAAyF,CAAC;QAC1G,MAAM,IAAI,KAAK,CAAC,CAAC,OAAO,E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AAM,CAAC,MAAM,GAAG,SAAS,CAAC;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, Features, PackageSettings } from '@ms-cloudpack/common-types';\nimport { allFeatures } from '@ms-cloudpack/common-types';\nimport type { DefineFlags } from '@ms-cloudpack/common-types-browser';\nimport { readJson } from '@ms-cloudpack/json-utilities';\nimport { resolveModule } from '@ms-cloudpack/path-utilities';\nimport fs from 'fs';\nimport path from 'path';\nimport { pathToFileURL } from 'url';\nimport { getConfigPath } from '../getConfigPath.js';\nimport { validateMatch } from '../packageSettings/validateMatch.js';\nimport { expandEnvironmentVariables } from './expandEnvironmentVariables.js';\nimport { mergeParentConfig } from './mergeParentConfig.js';\nimport { resolveParentConfig } from './resolveParentConfig.js';\nimport { augmentAppConfig } from './augmentAppConfig.js';\n\nexport interface ReadAppConfigOptions {\n /**\n * Extra feature settings. There will be a warning if any of these are invalid.\n */\n extraFeatures?: Features;\n\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 * Extra define flags to add at the end of user-provided settings (so they take precedence).\n */\n extraDefineFlags?: DefineFlags;\n\n /**\n * Enable default features that are not explicitly set in the config.\n */\n enableDefaultFeatures?: boolean;\n\n /**\n * Custom config file name to use instead of cloudpack.config.json\n */\n configFileName?: string;\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 { appConfigPaths } = getConfigPath(appPath, options?.configFileName);\n\n let config: AppConfig;\n\n // Check for JS and JSON config files.\n const existingPaths = appConfigPaths.filter((p) => fs.existsSync(p));\n if (existingPaths.length > 1) {\n const message = 'Multiple Cloudpack config files found. Determine the correct one and delete the others:';\n throw new Error([message, ...existingPaths].join('\\n '));\n }\n\n const appConfigPath = existingPaths[0];\n if (!appConfigPath) {\n // If a custom config was specified, it must exist\n if (options?.configFileName) {\n throw new Error(`Config file not found: ${options.configFileName}`);\n }\n // This is fine, use an empty config\n config = {};\n } else if (path.extname(appConfigPath) === '.json') {\n // Check for an existing JSON app config first\n config = await readJsonAppConfig(appConfigPath);\n } else {\n // Otherwise, read as a JS file\n config = await readJsAppConfig(appConfigPath);\n }\n\n expandEnvironmentVariables(config as Record<string, unknown>);\n\n // Merge extra settings (usually from CLI options) into the final config.\n if (options) {\n config = augmentAppConfig(config, options);\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({ parentPath: configPath, importSpecifier });\n bundlerCapabilitiesRegistry[name] = moduleUrl.toString();\n } catch (e) {\n throw new Error(`Error resolving bundler capability \"${importSpecifier}\":\\n${(e as Error).message || e}`);\n }\n }\n}\n\n/**\n * Reads the JSON app config file and calls `processConfig` on it.\n * Throws an error if the config file exists but is not valid JSON, or there's some error reading it.\n * @param configPath - The path to the config file.\n * @returns The parsed AppConfig object.\n */\nasync function readJsonAppConfig(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(`Cloudpack config not found at ${configPath}`);\n }\n return processConfig(configPath, appConfig);\n}\n\n/**\n * Reads the JavaScript app config file and calls `processConfig` on it.\n * Throws an error if the config file exists but is not valid, or there's some error reading it.\n * @param configPath - The path to the config file.\n * @returns The parsed AppConfig object.\n */\nasync function readJsAppConfig(configPath: string): Promise<AppConfig> {\n // Convert configPath to a URL for import.\n try {\n const appConfig = (await (import(pathToFileURL(configPath).toString()) as Promise<{ default?: AppConfig }>))\n .default;\n if (!appConfig) {\n throw new Error(`Missing default export from Cloudpack config at ${configPath}`);\n }\n return processConfig(configPath, appConfig);\n } catch (e) {\n throw new Error(`Error reading config file ${configPath}:\\n${(e as Error).message || e}`);\n }\n}\n\n/**\n * Processes the app config file and merges it with any parent configs.\n * This includes validating the config, checking for deprecated values, and resolving bundler capabilities.\n */\nasync function processConfig(configPath: string, appConfig: AppConfig): Promise<AppConfig> {\n if (!validateConfig(appConfig)) {\n throw new Error(`Config file ${configPath} has invalid settings (see above for details)`);\n }\n\n checkFeatures(appConfig.features, configPath);\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) => {\n const parentConfigPath = resolveParentConfig({ configPath, importSpecifier });\n return path.extname(parentConfigPath).toLowerCase() === '.json'\n ? readJsonAppConfig(parentConfigPath)\n : readJsAppConfig(parentConfigPath);\n }),\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 * Warn if any feature names are invalid, and remove them.\n */\nfunction checkFeatures(features: Record<string, boolean> | undefined, configPath: string): void {\n if (!features) {\n return;\n }\n\n const invalidFeatures: string[] = [];\n for (const featureName of Object.keys(features)) {\n if (!allFeatures[featureName as keyof Features]) {\n invalidFeatures.push(featureName);\n delete features[featureName];\n }\n }\n\n if (invalidFeatures.length) {\n console.warn(\n `Unknown feature(s) found in ${configPath} (most likely they were graduated or removed in Cloudpack):\\n ` +\n invalidFeatures.join(', '),\n );\n }\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,6 +1,9 @@
1
1
  import type { CloudpackConfig } from '@ms-cloudpack/common-types';
2
2
  import { type ReadAppConfigOptions } from './readAppConfig.js';
3
- export type ReadConfigOptions = ReadAppConfigOptions & Partial<Pick<CloudpackConfig, 'mode' | 'logBundleInfo'>>;
3
+ export type ReadConfigOptions = ReadAppConfigOptions & Partial<Pick<CloudpackConfig, 'mode' | 'logBundleInfo'>> & {
4
+ /** Custom config file name to use instead of cloudpack.config.json */
5
+ configFileName?: string;
6
+ };
4
7
  /**
5
8
  * Read the app config and generated config if they exist.
6
9
  *
@@ -1 +1 @@
1
- {"version":3,"file":"readConfig.d.ts","sourceRoot":"","sources":["../../src/readConfig/readConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EAOhB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAc9E,MAAM,MAAM,iBAAiB,GAAG,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,eAAe,CAAC,CAAC,CAAC;AAEhH;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAyBvG"}
1
+ {"version":3,"file":"readConfig.d.ts","sourceRoot":"","sources":["../../src/readConfig/readConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,eAAe,EAOhB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAiB,KAAK,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAc9E,MAAM,MAAM,iBAAiB,GAAG,oBAAoB,GAClD,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,MAAM,GAAG,eAAe,CAAC,CAAC,GAAG;IACzD,sEAAsE;IACtE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEJ;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAyBvG"}
@@ -13,8 +13,8 @@ import { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';
13
13
  * this doesn't do full schema validation; it only validates certain specific settings.)
14
14
  */
15
15
  export async function readConfig(appPath, options) {
16
- const { mode = 'library', logBundleInfo, ...appConfigOptions } = options || {};
17
- const { routes, ...appConfig } = await readAppConfig(appPath, appConfigOptions);
16
+ const { mode = 'library', logBundleInfo, configFileName, ...appConfigOptions } = options || {};
17
+ const { routes, ...appConfig } = await readAppConfig(appPath, { ...appConfigOptions, configFileName });
18
18
  const generatedConfig = await readGeneratedConfig(appPath);
19
19
  const config = {
20
20
  ...appConfig,
@@ -1 +1 @@
1
- {"version":3,"file":"readConfig.js","sourceRoot":"","sources":["../../src/readConfig/readConfig.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACjG,OAAO,EAAE,aAAa,EAA6B,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAU1E;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAe,EAAE,OAA2B;IAC3E,MAAM,EAAE,IAAI,GAAG,SAAS,EAAE,aAAa,EAAE,GAAG,gBAAgB,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;IAE/E,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,GAAG,MAAM,aAAa,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;IAChF,MAAM,eAAe,GAAG,MAAM,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAE3D,MAAM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AC","sourcesContent":["import type {\n BootstrapRoute,\n CloudpackConfig,\n ExpandedSourcePath,\n PackageJson,\n RenderedRoute,\n Route,\n ShorthandRenderedRoute,\n ShorthandRoute,\n} from '@ms-cloudpack/common-types';\nimport { isShorthandBootstrapRoute, isShorthandRenderedRoute } from '@ms-cloudpack/common-types';\nimport { readAppConfig, type ReadAppConfigOptions } from './readAppConfig.js';\nimport { readGeneratedConfig } from './readGeneratedConfig.js';\nimport { intermediateToSourcePath, sourceToIntermediatePath } from '@ms-cloudpack/path-utilities';\nimport { flattenExportsMap } from '@ms-cloudpack/package-utilities';\nimport path from 'path';\nimport { cloneJson, readJsonSync } from '@ms-cloudpack/json-utilities';\nimport { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\n\n/**\n * package.json with only the keys used in this file, since we're missing some logic from\n * PackageDefinitions which is assumed in the full type.\n */\ntype PartialPackageJson = Pick<PackageJson, 'exports' | 'module' | 'main'>;\n\nexport type ReadConfigOptions = ReadAppConfigOptions & Partial<Pick<CloudpackConfig, 'mode' | 'logBundleInfo'>>;\n\n/**\n * Read the app config and generated config if they exist.\n *\n * Throws if there's an error reading a file or certain settings are invalid. (As of writing,\n * this doesn't do full schema validation; it only validates certain specific settings.)\n */\nexport async function readConfig(appPath: string, options?: ReadConfigOptions): Promise<CloudpackConfig> {\n const { mode = 'library', logBundleInfo, ...appConfigOptions } = options || {};\n\n const { routes, ...appConfig } = await readAppConfig(appPath, appConfigOptions);\n const generatedConfig = await readGeneratedConfig(appPath);\n\n const config: CloudpackConfig = {\n ...appConfig,\n appPath,\n mode,\n generated: generatedConfig,\n generatedSnapshot: cloneJson(generatedConfig),\n };\n\n if (logBundleInfo) {\n // Only set this if true, mainly to avoid interfering with tests.\n config.logBundleInfo = true;\n }\n\n // Expands all routes which refer to source files into fully transformed route objects.\n if (routes?.length) {\n config.routes = expandRoutes(routes, appPath);\n }\n\n return config;\n}\n\n/**\n * Ensure all source entries in routes are expanded to fully qualified entry paths.\n */\nfunction expandRoutes(routes: ShorthandRoute[], appPath: string): Route[] {\n // Cached flattened exports for appPath, used to expand entries\n const flattenedExports = getFlattenedExports(appPath);\n\n return routes.map((route) => {\n if (!isShorthandRenderedRoute(route) && !isShorthandBootstrapRoute(route)) {\n // Skip extra processing for other route types.\n return route;\n }\n\n // eslint-disable-next-line etc/no-deprecated\n const { entry, exportEntry, serverEntry, ...rest } = route as ShorthandRenderedRoute;\n const renderedRoute: RenderedRoute | BootstrapRoute = rest;\n\n if (entry?.length) {\n // Expand the entry to full info about the file path.\n renderedRoute.entry = expandEntry({ entry, appPath, flattenedExports });\n }\n\n if (serverEntry) {\n // eslint-disable-next-line etc/no-deprecated\n if (renderedRoute.renderScript) {\n throw new Error(\n // eslint-disable-next-line etc/no-deprecated\n `A route cannot have both serverEntry (\"${serverEntry}\") and renderScript (\"${renderedRoute.renderScript}\").`,\n );\n }\n\n renderedRoute.serverEntry = expandRouteEntry({\n // Usually entryPath will be a source path, but also handle if it's an exports map key.\n importPath: flattenedExports[serverEntry] ? serverEntry : undefined,\n filePath: flattenedExports[serverEntry] || serverEntry,\n entryType: 'serverEntry',\n appPath,\n });\n }\n\n if (exportEntry) {\n // Handle backwards compatibility with moving from exportEntry to entry.\n const filePath = flattenedExports[exportEntry];\n\n if (!filePath) {\n throw new Error(\n `A route referenced exportEntry \"${exportEntry}\" but this couldn't be resolved from the package.json.`,\n );\n }\n\n const expanded = expandRouteEntry({ importPath: exportEntry, filePath, appPath });\n\n console.warn(\n 'The route property \"exportEntry\" is deprecated. Update your route as follows:',\n JSON.stringify({ ...renderedRoute, entry: expanded.sourcePath }, null, 2),\n );\n (renderedRoute.entry ??= []).push(expanded);\n }\n\n return renderedRoute;\n });\n}\n\nfunction expandEntry(params: {\n entry: ShorthandRenderedRoute['entry'];\n appPath: string;\n flattenedExports: Record<string, string | undefined>;\n}): ExpandedSourcePath[] {\n const { entry, appPath, flattenedExports } = params;\n const entryArray = Array.isArray(entry) ? entry : entry !== undefined ? [entry] : [];\n\n return entryArray.map((entryPath) =>\n expandRouteEntry({\n // Usually entryPath will be a source path, but also handle if it's an exports map key.\n importPath: flattenedExports[entryPath] ? entryPath : undefined,\n filePath: flattenedExports[entryPath] || entryPath,\n appPath,\n }),\n );\n}\n\n/**\n * Get flattened exports from package.json at `appPath`.\n * If there's no export for `.`, it will be filled in from `module || main`.\n */\nfunction getFlattenedExports(appPath: string): Record<string, string | undefined> {\n // We can't use PackageDefinitions.get here because we're reading the config, and definitions\n // cache requires config resulting in a cycle.\n const definition = readJsonSync<PartialPackageJson>(path.join(appPath, 'package.json')) || {};\n const flatExports: Record<string, string | undefined> = flattenExportsMap(definition.exports || {});\n flatExports['.'] ??= definition.module || definition.main;\n return flatExports;\n}\n\n/** Expands shorthand route entries into fully qualified ones. */\nfunction expandRouteEntry(options: {\n importPath: string | undefined;\n filePath: string;\n appPath: string;\n entryType?: 'entry' | 'serverEntry';\n}): ExpandedSourcePath {\n const { filePath, appPath, importPath, entryType = 'entry' } = options;\n const sourcePath = intermediateToSourcePath(filePath, appPath);\n\n if (!sourcePath) {\n throw new Error(`Could not resolve source path for ${entryType}: ${filePath}`);\n }\n\n return {\n // Used to derive bundle entry path\n sourcePath,\n // Import map key\n importPath: importPath ? normalizeRelativePath(importPath) : sourceToIntermediatePath(sourcePath),\n };\n}\n"]}
1
+ {"version":3,"file":"readConfig.js","sourceRoot":"","sources":["../../src/readConfig/readConfig.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACjG,OAAO,EAAE,aAAa,EAA6B,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,O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EAAiE;AACjE,SAAS,gBAAgB,CAAC,OAKzB;IACC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,GAAG,OAAO,EAAE,GAAG,OAAO,CAAC;IACvE,MAAM,UAAU,GAAG,wBAAwB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAE/D,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,qCAAqC,SAAS,KAAK,QAAQ,EAAE,CAAC,CAAC;IACjF,CAAC;IAED,OAAO;QACL,mCAAmC;QACnC,UAAU;QACV,iBAAiB;QACjB,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC,UAAU,CAAC;KAClG,CAAC;AACJ,CAAC","sourcesContent":["import type {\n BootstrapRoute,\n CloudpackConfig,\n ExpandedSourcePath,\n PackageJson,\n RenderedRoute,\n Route,\n ShorthandRenderedRoute,\n ShorthandRoute,\n} from '@ms-cloudpack/common-types';\nimport { isShorthandBootstrapRoute, isShorthandRenderedRoute } from '@ms-cloudpack/common-types';\nimport { readAppConfig, type ReadAppConfigOptions } from './readAppConfig.js';\nimport { readGeneratedConfig } from './readGeneratedConfig.js';\nimport { intermediateToSourcePath, sourceToIntermediatePath } from '@ms-cloudpack/path-utilities';\nimport { flattenExportsMap } from '@ms-cloudpack/package-utilities';\nimport path from 'path';\nimport { cloneJson, readJsonSync } from '@ms-cloudpack/json-utilities';\nimport { normalizeRelativePath } from '@ms-cloudpack/path-string-parsing';\n\n/**\n * package.json with only the keys used in this file, since we're missing some logic from\n * PackageDefinitions which is assumed in the full type.\n */\ntype PartialPackageJson = Pick<PackageJson, 'exports' | 'module' | 'main'>;\n\nexport type ReadConfigOptions = ReadAppConfigOptions &\n Partial<Pick<CloudpackConfig, 'mode' | 'logBundleInfo'>> & {\n /** Custom config file name to use instead of cloudpack.config.json */\n configFileName?: string;\n };\n\n/**\n * Read the app config and generated config if they exist.\n *\n * Throws if there's an error reading a file or certain settings are invalid. (As of writing,\n * this doesn't do full schema validation; it only validates certain specific settings.)\n */\nexport async function readConfig(appPath: string, options?: ReadConfigOptions): Promise<CloudpackConfig> {\n const { mode = 'library', logBundleInfo, configFileName, ...appConfigOptions } = options || {};\n\n const { routes, ...appConfig } = await readAppConfig(appPath, { ...appConfigOptions, configFileName });\n const generatedConfig = await readGeneratedConfig(appPath);\n\n const config: CloudpackConfig = {\n ...appConfig,\n appPath,\n mode,\n generated: generatedConfig,\n generatedSnapshot: cloneJson(generatedConfig),\n };\n\n if (logBundleInfo) {\n // Only set this if true, mainly to avoid interfering with tests.\n config.logBundleInfo = true;\n }\n\n // Expands all routes which refer to source files into fully transformed route objects.\n if (routes?.length) {\n config.routes = expandRoutes(routes, appPath);\n }\n\n return config;\n}\n\n/**\n * Ensure all source entries in routes are expanded to fully qualified entry paths.\n */\nfunction expandRoutes(routes: ShorthandRoute[], appPath: string): Route[] {\n // Cached flattened exports for appPath, used to expand entries\n const flattenedExports = getFlattenedExports(appPath);\n\n return routes.map((route) => {\n if (!isShorthandRenderedRoute(route) && !isShorthandBootstrapRoute(route)) {\n // Skip extra processing for other route types.\n return route;\n }\n\n // eslint-disable-next-line etc/no-deprecated\n const { entry, exportEntry, serverEntry, ...rest } = route as ShorthandRenderedRoute;\n const renderedRoute: RenderedRoute | BootstrapRoute = rest;\n\n if (entry?.length) {\n // Expand the entry to full info about the file path.\n renderedRoute.entry = expandEntry({ entry, appPath, flattenedExports });\n }\n\n if (serverEntry) {\n // eslint-disable-next-line etc/no-deprecated\n if (renderedRoute.renderScript) {\n throw new Error(\n // eslint-disable-next-line etc/no-deprecated\n `A route cannot have both serverEntry (\"${serverEntry}\") and renderScript (\"${renderedRoute.renderScript}\").`,\n );\n }\n\n renderedRoute.serverEntry = expandRouteEntry({\n // Usually entryPath will be a source path, but also handle if it's an exports map key.\n importPath: flattenedExports[serverEntry] ? serverEntry : undefined,\n filePath: flattenedExports[serverEntry] || serverEntry,\n entryType: 'serverEntry',\n appPath,\n });\n }\n\n if (exportEntry) {\n // Handle backwards compatibility with moving from exportEntry to entry.\n const filePath = flattenedExports[exportEntry];\n\n if (!filePath) {\n throw new Error(\n `A route referenced exportEntry \"${exportEntry}\" but this couldn't be resolved from the package.json.`,\n );\n }\n\n const expanded = expandRouteEntry({ importPath: exportEntry, filePath, appPath });\n\n console.warn(\n 'The route property \"exportEntry\" is deprecated. Update your route as follows:',\n JSON.stringify({ ...renderedRoute, entry: expanded.sourcePath }, null, 2),\n );\n (renderedRoute.entry ??= []).push(expanded);\n }\n\n return renderedRoute;\n });\n}\n\nfunction expandEntry(params: {\n entry: ShorthandRenderedRoute['entry'];\n appPath: string;\n flattenedExports: Record<string, string | undefined>;\n}): ExpandedSourcePath[] {\n const { entry, appPath, flattenedExports } = params;\n const entryArray = Array.isArray(entry) ? entry : entry !== undefined ? [entry] : [];\n\n return entryArray.map((entryPath) =>\n expandRouteEntry({\n // Usually entryPath will be a source path, but also handle if it's an exports map key.\n importPath: flattenedExports[entryPath] ? entryPath : undefined,\n filePath: flattenedExports[entryPath] || entryPath,\n appPath,\n }),\n );\n}\n\n/**\n * Get flattened exports from package.json at `appPath`.\n * If there's no export for `.`, it will be filled in from `module || main`.\n */\nfunction getFlattenedExports(appPath: string): Record<string, string | undefined> {\n // We can't use PackageDefinitions.get here because we're reading the config, and definitions\n // cache requires config resulting in a cycle.\n const definition = readJsonSync<PartialPackageJson>(path.join(appPath, 'package.json')) || {};\n const flatExports: Record<string, string | undefined> = flattenExportsMap(definition.exports || {});\n flatExports['.'] ??= definition.module || definition.main;\n return flatExports;\n}\n\n/** Expands shorthand route entries into fully qualified ones. */\nfunction expandRouteEntry(options: {\n importPath: string | undefined;\n filePath: string;\n appPath: string;\n entryType?: 'entry' | 'serverEntry';\n}): ExpandedSourcePath {\n const { filePath, appPath, importPath, entryType = 'entry' } = options;\n const sourcePath = intermediateToSourcePath(filePath, appPath);\n\n if (!sourcePath) {\n throw new Error(`Could not resolve source path for ${entryType}: ${filePath}`);\n }\n\n return {\n // Used to derive bundle entry path\n sourcePath,\n // Import map key\n importPath: importPath ? normalizeRelativePath(importPath) : sourceToIntermediatePath(sourcePath),\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/config",
3
- "version": "0.37.5",
3
+ "version": "0.38.0",
4
4
  "description": "Configuration handling for cloudpack.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,12 +14,12 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@ms-cloudpack/common-types": "^0.27.2",
17
+ "@ms-cloudpack/common-types": "^0.27.3",
18
18
  "@ms-cloudpack/environment": "^0.1.1",
19
19
  "@ms-cloudpack/json-utilities": "^0.1.10",
20
- "@ms-cloudpack/package-utilities": "^12.3.23",
20
+ "@ms-cloudpack/package-utilities": "^12.3.24",
21
21
  "@ms-cloudpack/path-string-parsing": "^1.2.7",
22
- "@ms-cloudpack/path-utilities": "^3.1.17",
22
+ "@ms-cloudpack/path-utilities": "^3.1.18",
23
23
  "semver": "^7.6.0"
24
24
  },
25
25
  "devDependencies": {