@ms-cloudpack/config 0.35.15 → 0.37.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.
@@ -6,7 +6,13 @@ export declare const appConfigFileName = "cloudpack.config.json";
6
6
  /**
7
7
  * File name constants for the user defined app config JS.
8
8
  */
9
- export declare const appConfigFileNamesJS: string[];
9
+ export declare const appConfigFileNamesJS: readonly ["cloudpack.config.js", "cloudpack.config.mjs", "cloudpack.config.cjs"];
10
+ /**
11
+ * Glob pattern for matching any Cloudpack config file (basename only).
12
+ * Use with appropriate prefixes like `./` as needed.
13
+ * Matches: cloudpack.config.json, cloudpack.config.js, cloudpack.config.mjs, cloudpack.config.cjs
14
+ */
15
+ export declare const appConfigFileGlob = "cloudpack.config.{json,js,mjs,cjs}";
10
16
  export declare const generatedConfigFileName = "cloudpack.generated.json";
11
17
  export declare const userPreferencesFileName = ".cloudpack.preferences.json";
12
18
  /**
@@ -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;AACzD;;GAEG;AACH,eAAO,MAAM,oBAAoB,UAA0E,CAAC;AAC5G,eAAO,MAAM,uBAAuB,6BAA6B,CAAC;AAClE,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,6EAAyC,CAAC;AAElF,8CAA8C;AAC9C,eAAO,MAAM,kBAAkB,uEAAmC,CAAC;AAEnE,oDAAoD;AACpD,eAAO,MAAM,wBAAwB,6EAAyC,CAAC"}
package/lib/constants.js CHANGED
@@ -6,6 +6,12 @@ export const appConfigFileName = 'cloudpack.config.json';
6
6
  * File name constants for the user defined app config JS.
7
7
  */
8
8
  export const appConfigFileNamesJS = ['cloudpack.config.js', 'cloudpack.config.mjs', 'cloudpack.config.cjs'];
9
+ /**
10
+ * Glob pattern for matching any Cloudpack config file (basename only).
11
+ * Use with appropriate prefixes like `./` as needed.
12
+ * Matches: cloudpack.config.json, cloudpack.config.js, cloudpack.config.mjs, cloudpack.config.cjs
13
+ */
14
+ export const appConfigFileGlob = 'cloudpack.config.{json,js,mjs,cjs}';
9
15
  export const generatedConfigFileName = 'cloudpack.generated.json';
10
16
  export const userPreferencesFileName = '.cloudpack.preferences.json';
11
17
  /**
@@ -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;AACzD;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,qBAAqB,EAAE,sBAAsB,EAAE,sBAAsB,CAAC,CAAC;AAC5G,MAAM,CAAC,MAAM,uBAAuB,GAAG,0BAA0B,CAAC;AAClE,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 * File name constants for the user defined app config JS.\n */\nexport const appConfigFileNamesJS = ['cloudpack.config.js', 'cloudpack.config.mjs', 'cloudpack.config.cjs'];\nexport const generatedConfigFileName = 'cloudpack.generated.json';\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,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,10 +1,12 @@
1
1
  /**
2
+ * Get config paths for the app at `cwd`.
2
3
  * @param cwd - base path of the config file
3
- * @returns the path of the config file
4
4
  */
5
5
  export declare function getConfigPath(cwd: string): {
6
- appConfigPath: string;
7
- appConfigPathsJS: string[];
6
+ /** Default JSON app config path */
7
+ defaultAppConfigPath: string;
8
+ /** All app config paths including JSON and JS */
9
+ appConfigPaths: string[];
8
10
  generatedConfigPath: string;
9
11
  };
10
12
  //# sourceMappingURL=getConfigPath.d.ts.map
@@ -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,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CAMA"}
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,13 +1,14 @@
1
1
  import path from 'path';
2
2
  import { appConfigFileName, appConfigFileNamesJS, generatedConfigFileName } from './constants.js';
3
3
  /**
4
+ * Get config paths for the app at `cwd`.
4
5
  * @param cwd - base path of the config file
5
- * @returns the path of the config file
6
6
  */
7
7
  export function getConfigPath(cwd) {
8
+ const defaultAppConfigPath = path.join(cwd, appConfigFileName);
8
9
  return {
9
- appConfigPath: path.join(cwd, appConfigFileName),
10
- appConfigPathsJS: appConfigFileNamesJS.map((fileName) => path.join(cwd, fileName)),
10
+ defaultAppConfigPath,
11
+ appConfigPaths: [defaultAppConfigPath, ...appConfigFileNamesJS.map((fileName) => path.join(cwd, fileName))],
11
12
  generatedConfigPath: path.join(cwd, generatedConfigFileName),
12
13
  };
13
14
  }
@@ -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;IAKvC,OAAO;QACL,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,iBAAiB,CAAC;QAChD,gBAAgB,EAAE,oBAAoB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;QAClF,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 * @param cwd - base path of the config file\n * @returns the path of the config file\n */\nexport function getConfigPath(cwd: string): {\n appConfigPath: string;\n appConfigPathsJS: string[];\n generatedConfigPath: string;\n} {\n return {\n appConfigPath: path.join(cwd, appConfigFileName),\n appConfigPathsJS: 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;;;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"]}
package/lib/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
+ export { augmentAppConfig } from './readConfig/augmentAppConfig.js';
1
2
  export { checkMatch } from './packageSettings/checkMatch.js';
2
3
  export { ensureAppConfig } from './writeConfig/ensureAppConfig.js';
3
4
  export { getBuiltInSettings } from './builtInSettings/getBuiltInSettings.js';
4
- export { generatedConfigFileName, appConfigFileName } from './constants.js';
5
+ export { generatedConfigFileName, appConfigFileName, appConfigFileNamesJS, appConfigFileGlob } from './constants.js';
5
6
  export { allUserPreferences } from './constants.js';
6
7
  export { createPackageDefinitions } from './packageDefinitions/createPackageDefinitions.js';
7
8
  export { getCachePath, getLocalCachePath } from './userPreferences/getCachePath.js';
@@ -18,5 +19,4 @@ export { writeAppConfig } from './writeConfig/writeAppConfig.js';
18
19
  export { ensureGeneratedSettingsForPackage } from './packageSettings/ensureGeneratedSettingsForPackage.js';
19
20
  export { updateUserPreference } from './userPreferences/updateUserPreference.js';
20
21
  export { validateMatch } from './packageSettings/validateMatch.js';
21
- export { addReadAppConfigOptions } from './readConfig/addReadAppConfigOptions.js';
22
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,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,MAAM,gBAAgB,CAAC;AAC5E,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,M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,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,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"}
package/lib/index.js CHANGED
@@ -1,7 +1,8 @@
1
+ export { augmentAppConfig } from './readConfig/augmentAppConfig.js';
1
2
  export { checkMatch } from './packageSettings/checkMatch.js';
2
3
  export { ensureAppConfig } from './writeConfig/ensureAppConfig.js';
3
4
  export { getBuiltInSettings } from './builtInSettings/getBuiltInSettings.js';
4
- export { generatedConfigFileName, appConfigFileName } from './constants.js';
5
+ export { generatedConfigFileName, appConfigFileName, appConfigFileNamesJS, appConfigFileGlob } from './constants.js';
5
6
  export { allUserPreferences } from './constants.js';
6
7
  export { createPackageDefinitions } from './packageDefinitions/createPackageDefinitions.js';
7
8
  export { getCachePath, getLocalCachePath } from './userPreferences/getCachePath.js';
@@ -18,5 +19,4 @@ export { writeAppConfig } from './writeConfig/writeAppConfig.js';
18
19
  export { ensureGeneratedSettingsForPackage } from './packageSettings/ensureGeneratedSettingsForPackage.js';
19
20
  export { updateUserPreference } from './userPreferences/updateUserPreference.js';
20
21
  export { validateMatch } from './packageSettings/validateMatch.js';
21
- export { addReadAppConfigOptions } from './readConfig/addReadAppConfigOptions.js';
22
22
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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,MAAM,gBAAgB,CAAC;AAC5E,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;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC","sourcesContent":["export { checkMatch } from './packageSettings/checkMatch.js';\nexport { ensureAppConfig } from './writeConfig/ensureAppConfig.js';\nexport { getBuiltInSettings } from './builtInSettings/getBuiltInSettings.js';\nexport { generatedConfigFileName, appConfigFileName } 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';\nexport { addReadAppConfigOptions } from './readConfig/addReadAppConfigOptions.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,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"]}
@@ -0,0 +1,8 @@
1
+ import { type AppConfig } from '@ms-cloudpack/common-types';
2
+ import type { ReadAppConfigOptions } from './readAppConfig.js';
3
+ /**
4
+ * Update the app config read from disk with extra settings that were passed in from CLI options.
5
+ * This is called after any extended configs have been merged.
6
+ */
7
+ export declare function augmentAppConfig<TConfig extends Pick<AppConfig, 'packageSettings' | 'features' | 'define'>>(config: TConfig, options: ReadAppConfigOptions): TConfig;
8
+ //# sourceMappingURL=augmentAppConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"augmentAppConfig.d.ts","sourceRoot":"","sources":["../../src/readConfig/augmentAppConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,SAAS,IAAI,CAAC,SAAS,EAAE,iBAAiB,GAAG,UAAU,GAAG,QAAQ,CAAC,EACzG,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAwBT"}
@@ -0,0 +1,26 @@
1
+ import { defaultFeatures } from '@ms-cloudpack/common-types';
2
+ /**
3
+ * Update the app config read from disk with extra settings that were passed in from CLI options.
4
+ * This is called after any extended configs have been merged.
5
+ */
6
+ export function augmentAppConfig(config, options) {
7
+ const { extraPackageSettings, extraFeatures, extraDefineFlags, enableDefaultFeatures } = options;
8
+ if (extraPackageSettings) {
9
+ // Add these last so they take precedence.
10
+ (config.packageSettings ??= []).push(...extraPackageSettings);
11
+ }
12
+ if (extraFeatures) {
13
+ // Merge extra features
14
+ config.features = { ...config.features, ...extraFeatures };
15
+ }
16
+ if (extraDefineFlags) {
17
+ config.define = { ...config.define, ...extraDefineFlags };
18
+ }
19
+ if (enableDefaultFeatures) {
20
+ // Enable select features by default.
21
+ // User-provided features should override the defaults.
22
+ config.features = { ...defaultFeatures, ...config.features };
23
+ }
24
+ return config;
25
+ }
26
+ //# sourceMappingURL=augmentAppConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"augmentAppConfig.js","sourceRoot":"","sources":["../../src/readConfig/augmentAppConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAkB,MAAM,4BAA4B,CAAC;AAG7E;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAe,EACf,OAA6B;IAE7B,MAAM,EAAE,oBAAoB,EAAE,aAAa,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC;IAEjG,IAAI,oBAAoB,EAAE,CAAC;QACzB,0CAA0C;QAC1C,CAAC,MAAM,CAAC,eAAe,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC,CAAC;IAChE,CAAC;IAED,IAAI,aAAa,EAAE,CAAC;QAClB,uBAAuB;QACvB,MAAM,CAAC,QAAQ,GAAG,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE,GAAG,aAAa,EAAE,CAAC;IAC7D,CAAC;IAED,IAAI,gBAAgB,EAAE,CAAC;QACrB,MAAM,CAAC,MAAM,GAAG,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,gBAAgB,EAAE,CAAC;IAC5D,CAAC;IAED,IAAI,qBAAqB,EAAE,CAAC;QAC1B,qCAAqC;QACrC,uDAAuD;QACvD,MAAM,CAAC,QAAQ,GAAG,EAAE,GAAG,eAAe,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC/D,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { defaultFeatures, type AppConfig } from '@ms-cloudpack/common-types';\nimport type { ReadAppConfigOptions } from './readAppConfig.js';\n\n/**\n * Update the app config read from disk with extra settings that were passed in from CLI options.\n * This is called after any extended configs have been merged.\n */\nexport function augmentAppConfig<TConfig extends Pick<AppConfig, 'packageSettings' | 'features' | 'define'>>(\n config: TConfig,\n options: ReadAppConfigOptions,\n): TConfig {\n const { extraPackageSettings, extraFeatures, extraDefineFlags, enableDefaultFeatures } = options;\n\n if (extraPackageSettings) {\n // Add these last so they take precedence.\n (config.packageSettings ??= []).push(...extraPackageSettings);\n }\n\n if (extraFeatures) {\n // Merge extra features\n config.features = { ...config.features, ...extraFeatures };\n }\n\n if (extraDefineFlags) {\n config.define = { ...config.define, ...extraDefineFlags };\n }\n\n if (enableDefaultFeatures) {\n // Enable select features by default.\n // User-provided features should override the defaults.\n config.features = { ...defaultFeatures, ...config.features };\n }\n\n return config;\n}\n"]}
@@ -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;AAYvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEtE,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,CAwCvG"}
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,14 +1,15 @@
1
1
  import { allFeatures } from '@ms-cloudpack/common-types';
2
2
  import { readJson } from '@ms-cloudpack/json-utilities';
3
+ import { resolveModule } from '@ms-cloudpack/path-utilities';
3
4
  import fs from 'fs';
5
+ import path from 'path';
6
+ import { pathToFileURL } from 'url';
4
7
  import { getConfigPath } from '../getConfigPath.js';
5
- import { mergeParentConfig } from './mergeParentConfig.js';
6
- import { resolveParentConfig } from './resolveParentConfig.js';
7
- import { resolveModule } from '@ms-cloudpack/path-utilities';
8
8
  import { validateMatch } from '../packageSettings/validateMatch.js';
9
9
  import { expandEnvironmentVariables } from './expandEnvironmentVariables.js';
10
- import { addReadAppConfigOptions } from './addReadAppConfigOptions.js';
11
- import { pathToFileURL } from 'url'; // Import the pathToFileURL function
10
+ import { mergeParentConfig } from './mergeParentConfig.js';
11
+ import { resolveParentConfig } from './resolveParentConfig.js';
12
+ import { augmentAppConfig } from './augmentAppConfig.js';
12
13
  /**
13
14
  * Reads the user config file and merges with any parent configs asynchronously.
14
15
  * Note this is only useful for making modifications to the user config.
@@ -19,37 +20,31 @@ import { pathToFileURL } from 'url'; // Import the pathToFileURL function
19
20
  * checks certain specific settings.)
20
21
  */
21
22
  export async function readAppConfig(appPath, options) {
22
- const { appConfigPath, appConfigPathsJS } = getConfigPath(appPath);
23
- // Do a separate existence check for the top-level config, since it's fine if that doesn't exist.
24
- // (readJs[on]AppConfig throws if the file doesn't exist because it's also used for reading
25
- // parent configs from "extends", which must exist if specified.)
23
+ const { appConfigPaths } = getConfigPath(appPath);
26
24
  let config;
27
- // Find the js config that exists amongst the possible options.
28
- // .js .cjs .mjs
29
- const JSConfigPaths = appConfigPathsJS.filter((p) => fs.existsSync(p));
30
- if (JSConfigPaths.length > 1) {
31
- console.warn(`Multiple JS config files found:\n ${JSConfigPaths.join('\n ')}\n` + `Using: ${JSConfigPaths[0]}`);
32
- }
33
- const appConfigPathJS = JSConfigPaths.length > 0 ? JSConfigPaths[0] : undefined;
34
- if (appConfigPathJS && fs.existsSync(appConfigPath)) {
35
- console.warn(`Both JSON: ${appConfigPath} and Javascript: ${appConfigPathJS} configs exist.\n` +
36
- `Using Javascript: ${appConfigPathJS}`);
37
- }
38
- if (appConfigPathJS) {
39
- // If the JS config exists, use that instead of the JSON file.
40
- config = await readJsAppConfig(appConfigPathJS);
41
- expandEnvironmentVariables(config);
42
- }
43
- else if (fs.existsSync(appConfigPath)) {
25
+ // Check for JS and JSON config files.
26
+ const existingPaths = appConfigPaths.filter((p) => fs.existsSync(p));
27
+ if (existingPaths.length > 1) {
28
+ const message = 'Multiple Cloudpack config files found. Determine the correct one and delete the others:';
29
+ throw new Error([message, ...existingPaths].join('\n '));
30
+ }
31
+ const appConfigPath = existingPaths[0];
32
+ if (!appConfigPath) {
33
+ // This is fine, use an empty config
34
+ config = {};
35
+ }
36
+ else if (path.extname(appConfigPath) === '.json') {
37
+ // Check for an existing JSON app config first
44
38
  config = await readJsonAppConfig(appConfigPath);
45
- expandEnvironmentVariables(config);
46
39
  }
47
40
  else {
48
- // If neither exists, return an empty config object.
49
- config = {};
41
+ // Otherwise, read as a JS file
42
+ config = await readJsAppConfig(appConfigPath);
50
43
  }
44
+ expandEnvironmentVariables(config);
45
+ // Merge extra settings (usually from CLI options) into the final config.
51
46
  if (options) {
52
- config = addReadAppConfigOptions(config, options);
47
+ config = augmentAppConfig(config, options);
53
48
  }
54
49
  return config;
55
50
  }
@@ -82,7 +77,7 @@ async function readJsonAppConfig(configPath) {
82
77
  const appConfig = await readJson(configPath, { mode: 'permissive', throwOnError: true });
83
78
  if (!appConfig) {
84
79
  // shouldn't happen, but just in case/to satisfy the types...
85
- throw new Error(`Could not read config file ${configPath}`);
80
+ throw new Error(`Cloudpack config not found at ${configPath}`);
86
81
  }
87
82
  return processConfig(configPath, appConfig);
88
83
  }
@@ -95,7 +90,11 @@ async function readJsonAppConfig(configPath) {
95
90
  async function readJsAppConfig(configPath) {
96
91
  // Convert configPath to a URL for import.
97
92
  try {
98
- const appConfig = (await import(pathToFileURL(configPath).toString())).default;
93
+ const appConfig = (await import(pathToFileURL(configPath).toString()))
94
+ .default;
95
+ if (!appConfig) {
96
+ throw new Error(`Missing default export from Cloudpack config at ${configPath}`);
97
+ }
99
98
  return processConfig(configPath, appConfig);
100
99
  }
101
100
  catch (e) {
@@ -118,7 +117,9 @@ async function processConfig(configPath, appConfig) {
118
117
  const extendsArray = Array.isArray(_extends) ? _extends : [_extends];
119
118
  const parentConfigs = await Promise.all(extendsArray.map((importSpecifier) => {
120
119
  const parentConfigPath = resolveParentConfig({ configPath, importSpecifier });
121
- return readJsonAppConfig(parentConfigPath);
120
+ return path.extname(parentConfigPath).toLowerCase() === '.json'
121
+ ? readJsonAppConfig(parentConfigPath)
122
+ : readJsAppConfig(parentConfigPath);
122
123
  }));
123
124
  return mergeParentConfig({ appConfig, parentConfigs });
124
125
  }
@@ -1 +1 @@
1
- {"version":3,"file":"readAppConfig.js","sourceRoot":"","sources":["../../src/readConfig/readAppConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,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;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC,CAAC,oCAAoC;AAyBzE;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAe,EAAE,OAA8B;IACjF,MAAM,EAAE,aAAa,EAAE,gBAAgB,EAAE,G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ACH,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 { 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';\nimport { addReadAppConfigOptions } from './addReadAppConfigOptions.js';\nimport { pathToFileURL } from 'url'; // Import the pathToFileURL function\nimport type { DefineFlags } from '@ms-cloudpack/common-types-browser';\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 { appConfigPath, appConfigPathsJS } = getConfigPath(appPath);\n\n // Do a separate existence check for the top-level config, since it's fine if that doesn't exist.\n // (readJs[on]AppConfig 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\n // Find the js config that exists amongst the possible options.\n // .js .cjs .mjs\n const JSConfigPaths = appConfigPathsJS.filter((p) => fs.existsSync(p));\n if (JSConfigPaths.length > 1) {\n console.warn(`Multiple JS config files found:\\n ${JSConfigPaths.join('\\n ')}\\n` + `Using: ${JSConfigPaths[0]}`);\n }\n\n const appConfigPathJS = JSConfigPaths.length > 0 ? JSConfigPaths[0] : undefined;\n if (appConfigPathJS && fs.existsSync(appConfigPath)) {\n console.warn(\n `Both JSON: ${appConfigPath} and Javascript: ${appConfigPathJS} configs exist.\\n` +\n `Using Javascript: ${appConfigPathJS}`,\n );\n }\n\n if (appConfigPathJS) {\n // If the JS config exists, use that instead of the JSON file.\n config = await readJsAppConfig(appConfigPathJS);\n expandEnvironmentVariables(config as Record<string, unknown>);\n } else if (fs.existsSync(appConfigPath)) {\n config = await readJsonAppConfig(appConfigPath);\n expandEnvironmentVariables(config as Record<string, unknown>);\n } else {\n // If neither exists, return an empty config object.\n config = {};\n }\n\n if (options) {\n config = addReadAppConfigOptions(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(`Could not read config file ${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 }>)).default;\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 readJsonAppConfig(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;AAwBzD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAe,EAAE,OAA8B;IACjF,MAAM,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAElD,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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;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 +1 @@
1
- {"version":3,"file":"ensureAppConfig.d.ts","sourceRoot":"","sources":["../../src/writeConfig/ensureAppConfig.ts"],"names":[],"mappings":"AA6BA;;;GAGG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAMtE"}
1
+ {"version":3,"file":"ensureAppConfig.d.ts","sourceRoot":"","sources":["../../src/writeConfig/ensureAppConfig.ts"],"names":[],"mappings":"AA6BA;;;GAGG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAStE"}
@@ -25,10 +25,13 @@ const configTemplate = {
25
25
  * @returns Path to the config file.
26
26
  */
27
27
  export async function ensureAppConfig(appPath) {
28
- const { appConfigPath } = getConfigPath(appPath);
29
- if (!fs.existsSync(appConfigPath)) {
28
+ const { defaultAppConfigPath, appConfigPaths } = getConfigPath(appPath);
29
+ let configPath = appConfigPaths.find((path) => fs.existsSync(path)) || defaultAppConfigPath;
30
+ if (!configPath) {
31
+ // If no config file exists, write the default one.
30
32
  await writeAppConfig(configTemplate, appPath);
33
+ configPath = defaultAppConfigPath;
31
34
  }
32
- return appConfigPath;
35
+ return configPath;
33
36
  }
34
37
  //# sourceMappingURL=ensureAppConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ensureAppConfig.js","sourceRoot":"","sources":["../../src/writeConfig/ensureAppConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,cAAc,GAAc;IAChC,eAAe,EAAE;QACf;YACE,KAAK,EAAE;gBACL,IAAI,EAAE,cAAc;gBACpB,OAAO,EAAE,GAAG;aACb;YAED,OAAO,EAAE;gBACP,GAAG,EAAE,YAAY;gBACjB,QAAQ,EAAE,WAAW;gBACrB,cAAc,EAAE,iBAAiB;aAClC;YAED,mBAAmB,EAAE,EAAE;YAEvB,oBAAoB,EAAE,EAAE;YACxB,oBAAoB,EAAE,EAAE;YAExB,OAAO,EAAE,SAAS;SACnB;KACF;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAAe;IACnD,MAAM,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACjD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QAClC,MAAM,cAAc,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import type { AppConfig } from '@ms-cloudpack/common-types';\nimport fs from 'fs';\nimport { getConfigPath } from '../getConfigPath.js';\nimport { writeAppConfig } from './writeAppConfig.js';\n\nconst configTemplate: AppConfig = {\n packageSettings: [\n {\n match: {\n name: 'package-name',\n version: '*',\n },\n\n exports: {\n '.': './index.js',\n './path': './path.js',\n './other-path': './other-path.js',\n },\n\n inlinedDependencies: [],\n\n includedDependencies: [],\n excludedDependencies: [],\n\n bundler: undefined,\n },\n ],\n};\n\n/**\n * If no `cloudpack.config.json` exists at `appPath`, create one with some demo settings.\n * @returns Path to the config file.\n */\nexport async function ensureAppConfig(appPath: string): Promise<string> {\n const { appConfigPath } = getConfigPath(appPath);\n if (!fs.existsSync(appConfigPath)) {\n await writeAppConfig(configTemplate, appPath);\n }\n return appConfigPath;\n}\n"]}
1
+ {"version":3,"file":"ensureAppConfig.js","sourceRoot":"","sources":["../../src/writeConfig/ensureAppConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,cAAc,GAAc;IAChC,eAAe,EAAE;QACf;YACE,KAAK,EAAE;gBACL,IAAI,EAAE,cAAc;gBACpB,OAAO,EAAE,GAAG;aACb;YAED,OAAO,EAAE;gBACP,GAAG,EAAE,YAAY;gBACjB,QAAQ,EAAE,WAAW;gBACrB,cAAc,EAAE,iBAAiB;aAClC;YAED,mBAAmB,EAAE,EAAE;YAEvB,oBAAoB,EAAE,EAAE;YACxB,oBAAoB,EAAE,EAAE;YAExB,OAAO,EAAE,SAAS;SACnB;KACF;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAAe;IACnD,MAAM,EAAE,oBAAoB,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACxE,IAAI,UAAU,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,oBAAoB,CAAC;IAC5F,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,mDAAmD;QACnD,MAAM,cAAc,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAC9C,UAAU,GAAG,oBAAoB,CAAC;IACpC,CAAC;IACD,OAAO,UAAU,CAAC;AACpB,CAAC","sourcesContent":["import type { AppConfig } from '@ms-cloudpack/common-types';\nimport fs from 'fs';\nimport { getConfigPath } from '../getConfigPath.js';\nimport { writeAppConfig } from './writeAppConfig.js';\n\nconst configTemplate: AppConfig = {\n packageSettings: [\n {\n match: {\n name: 'package-name',\n version: '*',\n },\n\n exports: {\n '.': './index.js',\n './path': './path.js',\n './other-path': './other-path.js',\n },\n\n inlinedDependencies: [],\n\n includedDependencies: [],\n excludedDependencies: [],\n\n bundler: undefined,\n },\n ],\n};\n\n/**\n * If no `cloudpack.config.json` exists at `appPath`, create one with some demo settings.\n * @returns Path to the config file.\n */\nexport async function ensureAppConfig(appPath: string): Promise<string> {\n const { defaultAppConfigPath, appConfigPaths } = getConfigPath(appPath);\n let configPath = appConfigPaths.find((path) => fs.existsSync(path)) || defaultAppConfigPath;\n if (!configPath) {\n // If no config file exists, write the default one.\n await writeAppConfig(configTemplate, appPath);\n configPath = defaultAppConfigPath;\n }\n return configPath;\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { AppConfig } from '@ms-cloudpack/common-types';
2
2
  /**
3
- * Writes updates to the user config. Unlike writing generated config, this does not sort existing package settings,
4
- * with the intent of minimizing churn.
3
+ * Writes updates to the user config JSON.
4
+ * This is ONLY used when creating a default app config or by tests.
5
5
  */
6
6
  export declare function writeAppConfig(config: AppConfig, appPath: string): Promise<void>;
7
7
  //# sourceMappingURL=writeAppConfig.d.ts.map
@@ -2,12 +2,12 @@ import { writeJson } from '@ms-cloudpack/json-utilities';
2
2
  import { getConfigPath } from '../getConfigPath.js';
3
3
  import { appConfigSchemaUrl } from '../constants.js';
4
4
  /**
5
- * Writes updates to the user config. Unlike writing generated config, this does not sort existing package settings,
6
- * with the intent of minimizing churn.
5
+ * Writes updates to the user config JSON.
6
+ * This is ONLY used when creating a default app config or by tests.
7
7
  */
8
8
  export async function writeAppConfig(config, appPath) {
9
- const { appConfigPath } = getConfigPath(appPath);
10
- return writeJson(appConfigPath, {
9
+ const { defaultAppConfigPath } = getConfigPath(appPath);
10
+ return writeJson(defaultAppConfigPath, {
11
11
  $schema: appConfigSchemaUrl,
12
12
  ...config,
13
13
  }, { update: true, mode: 'permissive' });
@@ -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): 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
+ {"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,oBAAoB,EAAE,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAExD,OAAO,SAAS,CACd,oBAAoB,EACpB;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 JSON.\n * This is ONLY used when creating a default app config or by tests.\n */\nexport async function writeAppConfig(config: AppConfig, appPath: string): Promise<void> {\n const { defaultAppConfigPath } = getConfigPath(appPath);\n\n return writeJson(\n defaultAppConfigPath,\n {\n $schema: appConfigSchemaUrl,\n ...config,\n },\n { update: true, mode: 'permissive' },\n );\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/config",
3
- "version": "0.35.15",
3
+ "version": "0.37.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.26.1",
17
+ "@ms-cloudpack/common-types": "^0.26.2",
18
18
  "@ms-cloudpack/environment": "^0.1.1",
19
19
  "@ms-cloudpack/json-utilities": "^0.1.10",
20
- "@ms-cloudpack/package-utilities": "^12.3.17",
20
+ "@ms-cloudpack/package-utilities": "^12.3.18",
21
21
  "@ms-cloudpack/path-string-parsing": "^1.2.7",
22
- "@ms-cloudpack/path-utilities": "^3.1.11",
22
+ "@ms-cloudpack/path-utilities": "^3.1.12",
23
23
  "semver": "^7.6.0"
24
24
  },
25
25
  "devDependencies": {
@@ -1,4 +0,0 @@
1
- import type { AppConfig } from '@ms-cloudpack/common-types';
2
- import type { ReadAppConfigOptions } from './readAppConfig.js';
3
- export declare function addReadAppConfigOptions<TConfig extends Pick<AppConfig, 'packageSettings' | 'features' | 'define'>>(config: TConfig, options: ReadAppConfigOptions): TConfig;
4
- //# sourceMappingURL=addReadAppConfigOptions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addReadAppConfigOptions.d.ts","sourceRoot":"","sources":["../../src/readConfig/addReadAppConfigOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAY,MAAM,4BAA4B,CAAC;AACtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,wBAAgB,uBAAuB,CAAC,OAAO,SAAS,IAAI,CAAC,SAAS,EAAE,iBAAiB,GAAG,UAAU,GAAG,QAAQ,CAAC,EAChH,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAkDT"}
@@ -1,44 +0,0 @@
1
- export function addReadAppConfigOptions(config, options) {
2
- const { extraPackageSettings, extraFeatures, extraDefineFlags, enableDefaultFeatures } = options;
3
- if (extraPackageSettings) {
4
- // Add these last so they take precedence.
5
- (config.packageSettings ??= []).push(...extraPackageSettings);
6
- }
7
- if (extraFeatures) {
8
- // Merge extra features
9
- config.features = { ...config.features, ...extraFeatures };
10
- }
11
- if (extraDefineFlags) {
12
- config.define = {
13
- ...config.define,
14
- ...extraDefineFlags,
15
- };
16
- }
17
- if (enableDefaultFeatures) {
18
- // Enable select features by default.
19
- if (!config.features) {
20
- config.features = {};
21
- }
22
- const { features } = config;
23
- const defaultFeatures = [
24
- // Default to provide a more flexible experience.
25
- 'autoUpdateEntries',
26
- // Default to true for better support.
27
- 'enableModuleWorkers',
28
- // Default to true for better performance.
29
- 'enableWatcherInFork',
30
- // Default to true for a more portable import map.
31
- 'relativeImportMapPaths',
32
- // Default to true to also enable worker support.
33
- 'useSingleWebServer',
34
- ];
35
- // Enable any default features that are not already set.
36
- for (const featureName of defaultFeatures) {
37
- if (features[featureName] === undefined) {
38
- features[featureName] = true;
39
- }
40
- }
41
- }
42
- return config;
43
- }
44
- //# sourceMappingURL=addReadAppConfigOptions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addReadAppConfigOptions.js","sourceRoot":"","sources":["../../src/readConfig/addReadAppConfigOptions.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,uBAAuB,CACrC,MAAe,EACf,OAA6B;IAE7B,MAAM,EAAE,oBAAoB,EAAE,aAAa,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC;IAEjG,IAAI,oBAAoB,EAAE,CAAC;QACzB,0CAA0C;QAC1C,CAAC,MAAM,CAAC,eAAe,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC,CAAC;IAChE,CAAC;IAED,IAAI,aAAa,EAAE,CAAC;QAClB,uBAAuB;QACvB,MAAM,CAAC,QAAQ,GAAG,EAAE,GAAG,MAAM,CAAC,QAAQ,EAAE,GAAG,aAAa,EAAE,CAAC;IAC7D,CAAC;IAED,IAAI,gBAAgB,EAAE,CAAC;QACrB,MAAM,CAAC,MAAM,GAAG;YACd,GAAG,MAAM,CAAC,MAAM;YAChB,GAAG,gBAAgB;SACpB,CAAC;IACJ,CAAC;IAED,IAAI,qBAAqB,EAAE,CAAC;QAC1B,qCAAqC;QACrC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACrB,MAAM,CAAC,QAAQ,GAAG,EAAE,CAAC;QACvB,CAAC;QAED,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,CAAC;QAE5B,MAAM,eAAe,GAAuB;YAC1C,iDAAiD;YACjD,mBAAmB;YACnB,sCAAsC;YACtC,qBAAqB;YACrB,0CAA0C;YAC1C,qBAAqB;YACrB,kDAAkD;YAClD,wBAAwB;YACxB,iDAAiD;YACjD,oBAAoB;SACrB,CAAC;QAEF,wDAAwD;QACxD,KAAK,MAAM,WAAW,IAAI,eAAe,EAAE,CAAC;YAC1C,IAAI,QAAQ,CAAC,WAAW,CAAC,KAAK,SAAS,EAAE,CAAC;gBACxC,QAAQ,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;YAC/B,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { AppConfig, Features } from '@ms-cloudpack/common-types';\nimport type { ReadAppConfigOptions } from './readAppConfig.js';\n\nexport function addReadAppConfigOptions<TConfig extends Pick<AppConfig, 'packageSettings' | 'features' | 'define'>>(\n config: TConfig,\n options: ReadAppConfigOptions,\n): TConfig {\n const { extraPackageSettings, extraFeatures, extraDefineFlags, enableDefaultFeatures } = options;\n\n if (extraPackageSettings) {\n // Add these last so they take precedence.\n (config.packageSettings ??= []).push(...extraPackageSettings);\n }\n\n if (extraFeatures) {\n // Merge extra features\n config.features = { ...config.features, ...extraFeatures };\n }\n\n if (extraDefineFlags) {\n config.define = {\n ...config.define,\n ...extraDefineFlags,\n };\n }\n\n if (enableDefaultFeatures) {\n // Enable select features by default.\n if (!config.features) {\n config.features = {};\n }\n\n const { features } = config;\n\n const defaultFeatures: (keyof Features)[] = [\n // Default to provide a more flexible experience.\n 'autoUpdateEntries',\n // Default to true for better support.\n 'enableModuleWorkers',\n // Default to true for better performance.\n 'enableWatcherInFork',\n // Default to true for a more portable import map.\n 'relativeImportMapPaths',\n // Default to true to also enable worker support.\n 'useSingleWebServer',\n ];\n\n // Enable any default features that are not already set.\n for (const featureName of defaultFeatures) {\n if (features[featureName] === undefined) {\n features[featureName] = true;\n }\n }\n }\n\n return config;\n}\n"]}