@ms-cloudpack/config 0.38.21 → 0.38.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import type { AppConfig } from '@ms-cloudpack/common-types';
2
2
  /**
3
3
  * Expand template variables in module resolution paths.
4
- * Currently supports {configDir} to reference the configuration file's directory.
4
+ * Currently supports `{configDir}` to reference the configuration file's directory.
5
5
  */
6
6
  export declare function expandModulePaths(params: {
7
7
  appConfig: AppConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"expandModulePaths.d.ts","sourceRoot":"","sources":["../../src/readConfig/expandModulePaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAe5D;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE,SAAS,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAsC5F"}
1
+ {"version":3,"file":"expandModulePaths.d.ts","sourceRoot":"","sources":["../../src/readConfig/expandModulePaths.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAK5D;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IAAE,SAAS,EAAE,SAAS,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAiC5F"}
@@ -1,17 +1,8 @@
1
1
  import path from 'path';
2
2
  const configDirTemplate = '{configDir}';
3
- function countOccurrences(str, substring) {
4
- let count = 0;
5
- let index = 0;
6
- while ((index = str.indexOf(substring, index)) !== -1) {
7
- count++;
8
- index += substring.length;
9
- }
10
- return count;
11
- }
12
3
  /**
13
4
  * Expand template variables in module resolution paths.
14
- * Currently supports {configDir} to reference the configuration file's directory.
5
+ * Currently supports `{configDir}` to reference the configuration file's directory.
15
6
  */
16
7
  export function expandModulePaths(params) {
17
8
  const { appConfig: { resolve }, configPath, } = params;
@@ -23,22 +14,17 @@ export function expandModulePaths(params) {
23
14
  }
24
15
  const configDir = path.dirname(configPath);
25
16
  // Process each module path and expand template variables
26
- resolve.modules = resolve.modules.map((modulePath) => {
27
- // Count occurrences of the template variable
28
- const templateCount = countOccurrences(modulePath, configDirTemplate);
29
- if (templateCount === 0) {
30
- // Return unchanged paths without template variables
31
- return modulePath;
32
- }
33
- if (templateCount > 1) {
34
- throw new Error(`Multiple template variables not allowed in the same path: "${modulePath}"`);
17
+ resolve.modules = resolve.modules.map((origModulePath) => {
18
+ let modulePath = origModulePath;
19
+ if (modulePath.startsWith(configDirTemplate)) {
20
+ // Replace template at start of path with actual directory
21
+ modulePath = modulePath.replace(configDirTemplate, configDir);
35
22
  }
36
- // Single template variable - must be at the beginning
37
- if (!modulePath.startsWith(configDirTemplate)) {
38
- throw new Error(`${configDirTemplate} template variable must be at the beginning of the path: "${modulePath}"`);
23
+ if (modulePath.includes(configDirTemplate)) {
24
+ // There were multiple occurrences, or it was not at the start
25
+ throw new Error(`${configDirTemplate} template variable is only allowed at the beginning of a \`resolve.modules\` path. Received: "${modulePath}"`);
39
26
  }
40
- // Replace template at start of path with actual directory
41
- return modulePath.replace(configDirTemplate, configDir);
27
+ return modulePath;
42
28
  });
43
29
  }
44
30
  //# sourceMappingURL=expandModulePaths.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"expandModulePaths.js","sourceRoot":"","sources":["../../src/readConfig/expandModulePaths.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAExC,SAAS,gBAAgB,CAAC,GAAW,EAAE,SAAiB;IACtD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,OAAO,CAAC,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,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AC","sourcesContent":["import type { AppConfig } from '@ms-cloudpack/common-types';\nimport path from 'path';\n\nconst configDirTemplate = '{configDir}';\n\nfunction countOccurrences(str: string, substring: string): number {\n let count = 0;\n let index = 0;\n while ((index = str.indexOf(substring, index)) !== -1) {\n count++;\n index += substring.length;\n }\n return count;\n}\n\n/**\n * Expand template variables in module resolution paths.\n * Currently supports {configDir} to reference the configuration file's directory.\n */\nexport function expandModulePaths(params: { appConfig: AppConfig; configPath: string }): void {\n const {\n appConfig: { resolve },\n configPath,\n } = params;\n\n if (!path.isAbsolute(configPath)) {\n throw new Error(`configPath must be an absolute path, got: \"${configPath}\"`);\n }\n\n if (!resolve?.modules) {\n return;\n }\n\n const configDir = path.dirname(configPath);\n\n // Process each module path and expand template variables\n resolve.modules = resolve.modules.map((modulePath) => {\n // Count occurrences of the template variable\n const templateCount = countOccurrences(modulePath, configDirTemplate);\n\n if (templateCount === 0) {\n // Return unchanged paths without template variables\n return modulePath;\n }\n\n if (templateCount > 1) {\n throw new Error(`Multiple template variables not allowed in the same path: \"${modulePath}\"`);\n }\n\n // Single template variable - must be at the beginning\n if (!modulePath.startsWith(configDirTemplate)) {\n throw new Error(`${configDirTemplate} template variable must be at the beginning of the path: \"${modulePath}\"`);\n }\n\n // Replace template at start of path with actual directory\n return modulePath.replace(configDirTemplate, configDir);\n });\n}\n"]}
1
+ {"version":3,"file":"expandModulePaths.js","sourceRoot":"","sources":["../../src/readConfig/expandModulePaths.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,iBAAiB,GAAG,aAAa,CAAC;AAExC;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAoD;IACpF,MAAM,EACJ,SAAS,EAAE,EAAE,OAAO,EAAE,EACtB,UAAU,GACX,GAAG,MAAM,CAAC;IAEX,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,8CAA8C,UAAU,GAAG,CAAC,CAAC;IAC/E,CAAC;IAED,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC;QACtB,OAAO;IACT,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAE3C,yDAAyD;IACzD,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE;QACvD,IAAI,UAAU,GAAG,cAAc,CAAC;QAChC,IAAI,UAAU,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAC7C,0DAA0D;YAC1D,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC;QAChE,CAAC;QAED,IAAI,UAAU,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAC3C,8DAA8D;YAC9D,MAAM,IAAI,KAAK,CACb,GAAG,iBAAiB,iGAAiG,UAAU,GAAG,CACnI,CAAC;QACJ,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { AppConfig } from '@ms-cloudpack/common-types';\nimport path from 'path';\n\nconst configDirTemplate = '{configDir}';\n\n/**\n * Expand template variables in module resolution paths.\n * Currently supports `{configDir}` to reference the configuration file's directory.\n */\nexport function expandModulePaths(params: { appConfig: AppConfig; configPath: string }): void {\n const {\n appConfig: { resolve },\n configPath,\n } = params;\n\n if (!path.isAbsolute(configPath)) {\n throw new Error(`configPath must be an absolute path, got: \"${configPath}\"`);\n }\n\n if (!resolve?.modules) {\n return;\n }\n\n const configDir = path.dirname(configPath);\n\n // Process each module path and expand template variables\n resolve.modules = resolve.modules.map((origModulePath) => {\n let modulePath = origModulePath;\n if (modulePath.startsWith(configDirTemplate)) {\n // Replace template at start of path with actual directory\n modulePath = modulePath.replace(configDirTemplate, configDir);\n }\n\n if (modulePath.includes(configDirTemplate)) {\n // There were multiple occurrences, or it was not at the start\n throw new Error(\n `${configDirTemplate} template variable is only allowed at the beginning of a \\`resolve.modules\\` path. Received: \"${modulePath}\"`,\n );\n }\n\n return modulePath;\n });\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/config",
3
- "version": "0.38.21",
3
+ "version": "0.38.22",
4
4
  "description": "Configuration handling for Cloudpack",
5
5
  "license": "MIT",
6
6
  "type": "module",