@ms-cloudpack/config 0.4.0 → 0.5.1

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.
package/lib/config.d.ts CHANGED
@@ -27,9 +27,4 @@ export declare function readConfig(cwd?: string): Promise<CloudpackConfig>;
27
27
  * @param cwd - base path of the config file
28
28
  */
29
29
  export declare function writeGeneratedConfig(config: GeneratedConfig, cwd?: string): Promise<void>;
30
- /**
31
- * Writes generated config. This is used for `init` to provide package overrides needed.
32
- * @param config - updated config object to be written
33
- * @param cwd - base path of the config file
34
- */
35
- export declare function writeGeneratedConfigSync(config: GeneratedConfig, cwd?: string): void;
30
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGnE,eAAO,MAAM,cAAc,0BAA0B,CAAC;AACtD,eAAO,MAAM,uBAAuB,6BAA6B,CAAC;AAElE;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,CAAC,EAAE,MAAM;;;EAMzC;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,CAAC,EAAE,MAAM,mBAS1C;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAOvE;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,CAAC,EAAE,MAAM,iBAiB/E"}
package/lib/config.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import path from 'path';
2
- import { readJson, readJsonSync, writeJson, writeJsonSync } from '@ms-cloudpack/json-utilities';
2
+ import { readJson, readJsonSync, writeJson } from '@ms-cloudpack/json-utilities';
3
3
  export const configFileName = 'cloudpack.config.json';
4
4
  export const generatedConfigFileName = 'cloudpack.generated.json';
5
5
  /**
@@ -46,16 +46,16 @@ export async function readConfig(cwd) {
46
46
  */
47
47
  export async function writeGeneratedConfig(config, cwd) {
48
48
  const { overridesPath } = getConfigPath(cwd);
49
- return writeJson(overridesPath, config);
50
- }
51
- /**
52
- * Writes generated config. This is used for `init` to provide package overrides needed.
53
- * @param config - updated config object to be written
54
- * @param cwd - base path of the config file
55
- */
56
- export function writeGeneratedConfigSync(config, cwd) {
57
- const { overridesPath } = getConfigPath(cwd);
58
- // eslint-disable-next-line no-restricted-syntax
59
- return writeJsonSync(overridesPath, config);
49
+ // Ensure package overrides are sorted based on package name and versionRequirement.
50
+ const sortedOverrides = config.packageOverrides?.sort((a, b) => {
51
+ if (a.name === b.name) {
52
+ return a.versionRequirement.localeCompare(b.versionRequirement);
53
+ }
54
+ return a.name.localeCompare(b.name);
55
+ }) || [];
56
+ return writeJson(overridesPath, {
57
+ ...config,
58
+ packageOverrides: sortedOverrides,
59
+ });
60
60
  }
61
61
  //# sourceMappingURL=config.js.map
package/lib/config.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAEhG,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAuB,CAAC;AACtD,MAAM,CAAC,MAAM,uBAAuB,GAAG,0BAA0B,CAAC;AAElE;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,GAAY;IACxC,MAAM,QAAQ,GAAG,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACtC,OAAO;QACL,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC;QAC/C,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,uBAAuB,CAAC;KAC5D,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,GAAY;IACzC,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IAEzD,OAAO;QACL,gDAAgD;QAChD,GAAG,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QACnC,gDAAgD;QAChD,GAAG,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC;KACpB,CAAC;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAY;IAC3C,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IAEzD,OAAO;QACL,GAAG,CAAC,CAAC,MAAM,QAAQ,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAAC;QACvC,GAAG,CAAC,CAAC,MAAM,QAAQ,CAAC,aAAa,CAAC,CAAC,IAAI,EAAE,CAAC;KACxB,CAAC;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,MAAuB,EAAE,GAAY;IAC9E,MAAM,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IAE7C,OAAO,SAAS,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;AAC1C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAAuB,EAAE,GAAY;IAC5E,MAAM,EAAE,aAAa,EAAE,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;IAE7C,gDAAgD;IAChD,OAAO,aAAa,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;AAC9C,CAAC","sourcesContent":["import path from 'path';\nimport type { CloudpackConfig, GeneratedConfig } from './types.js';\nimport { readJson, readJsonSync, writeJson, writeJsonSync } from '@ms-cloudpack/json-utilities';\n\nexport const configFileName = 'cloudpack.config.json';\nexport const generatedConfigFileName = 'cloudpack.generated.json';\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 const basePath = cwd || process.cwd();\n return {\n configPath: path.join(basePath, configFileName),\n overridesPath: path.join(basePath, generatedConfigFileName),\n };\n}\n\n/**\n * Reads the config file synchronously\n * @param cwd - base path of the config file\n * @returns cloudpack config object or empty object if no config file exists.\n */\nexport function readConfigSync(cwd?: string) {\n const { configPath, overridesPath } = getConfigPath(cwd);\n\n return {\n // eslint-disable-next-line no-restricted-syntax\n ...(readJsonSync(configPath) || {}),\n // eslint-disable-next-line no-restricted-syntax\n ...(readJsonSync(overridesPath) || {}),\n } as CloudpackConfig;\n}\n\n/**\n * Reads the config file asynchronously\n * @param cwd - base path of the config file\n * @returns cloudpack config object or empty object if no config file exists.\n */\nexport async function readConfig(cwd?: string): Promise<CloudpackConfig> {\n const { configPath, overridesPath } = getConfigPath(cwd);\n\n return {\n ...((await readJson(configPath)) || {}),\n ...((await readJson(overridesPath)) || {}),\n } as CloudpackConfig;\n}\n\n/**\n * Writes generated config. This is used for `init` to provide package overrides needed.\n * @param config - updated config object to be written\n * @param cwd - base path of the config file\n */\nexport async function writeGeneratedConfig(config: GeneratedConfig, cwd?: string) {\n const { overridesPath } = getConfigPath(cwd);\n\n return writeJson(overridesPath, config);\n}\n\n/**\n * Writes generated config. This is used for `init` to provide package overrides needed.\n * @param config - updated config object to be written\n * @param cwd - base path of the config file\n */\nexport function writeGeneratedConfigSync(config: GeneratedConfig, cwd?: string) {\n const { overridesPath } = getConfigPath(cwd);\n\n // eslint-disable-next-line no-restricted-syntax\n return writeJsonSync(overridesPath, config);\n}\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAEjF,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,gBAAgB,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACrC,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,EAAE;YACrB,OAAO,CAAC,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC;SACjE;QAED,OAAO,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC,CAAC,IAAI,EAAE,CAAC;IAEX,OAAO,SAAS,CAAC,aAAa,EAAE;QAC9B,GAAG,MAAM;QACT,gBAAgB,EAAE,eAAe;KAClC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import path from 'path';\nimport type { CloudpackConfig, GeneratedConfig } from './types.js';\nimport { readJson, readJsonSync, writeJson } from '@ms-cloudpack/json-utilities';\n\nexport const configFileName = 'cloudpack.config.json';\nexport const generatedConfigFileName = 'cloudpack.generated.json';\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 const basePath = cwd || process.cwd();\n return {\n configPath: path.join(basePath, configFileName),\n overridesPath: path.join(basePath, generatedConfigFileName),\n };\n}\n\n/**\n * Reads the config file synchronously\n * @param cwd - base path of the config file\n * @returns cloudpack config object or empty object if no config file exists.\n */\nexport function readConfigSync(cwd?: string) {\n const { configPath, overridesPath } = getConfigPath(cwd);\n\n return {\n // eslint-disable-next-line no-restricted-syntax\n ...(readJsonSync(configPath) || {}),\n // eslint-disable-next-line no-restricted-syntax\n ...(readJsonSync(overridesPath) || {}),\n } as CloudpackConfig;\n}\n\n/**\n * Reads the config file asynchronously\n * @param cwd - base path of the config file\n * @returns cloudpack config object or empty object if no config file exists.\n */\nexport async function readConfig(cwd?: string): Promise<CloudpackConfig> {\n const { configPath, overridesPath } = getConfigPath(cwd);\n\n return {\n ...((await readJson(configPath)) || {}),\n ...((await readJson(overridesPath)) || {}),\n } as CloudpackConfig;\n}\n\n/**\n * Writes generated config. This is used for `init` to provide package overrides needed.\n * @param config - updated config object to be written\n * @param cwd - base path of the config file\n */\nexport async function writeGeneratedConfig(config: GeneratedConfig, cwd?: string) {\n const { overridesPath } = getConfigPath(cwd);\n\n // Ensure package overrides are sorted based on package name and versionRequirement.\n const sortedOverrides =\n config.packageOverrides?.sort((a, b) => {\n if (a.name === b.name) {\n return a.versionRequirement.localeCompare(b.versionRequirement);\n }\n\n return a.name.localeCompare(b.name);\n }) || [];\n\n return writeJson(overridesPath, {\n ...config,\n packageOverrides: sortedOverrides,\n });\n}\n"]}
@@ -11,3 +11,4 @@ export declare const configTemplate: {
11
11
  };
12
12
  }[];
13
13
  };
14
+ //# sourceMappingURL=configTemplate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configTemplate.d.ts","sourceRoot":"","sources":["../src/configTemplate.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc;;;;;;;;;;;;CAc1B,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { configTemplate } from './configTemplate.js';
2
- export { configFileName, generatedConfigFileName, getConfigPath, readConfig, readConfigSync, writeGeneratedConfig, writeGeneratedConfigSync, } from './config.js';
2
+ export { configFileName, generatedConfigFileName, getConfigPath, readConfig, readConfigSync, writeGeneratedConfig, } from './config.js';
3
3
  export type { CloudpackConfig, DevServer, PackageOverride, Route, TelemetryConfig } from './types.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,aAAa,EACb,UAAU,EACV,cAAc,EACd,oBAAoB,GACrB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
package/lib/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export { configTemplate } from './configTemplate.js';
2
- export { configFileName, generatedConfigFileName, getConfigPath, readConfig, readConfigSync, writeGeneratedConfig, writeGeneratedConfigSync, } from './config.js';
2
+ export { configFileName, generatedConfigFileName, getConfigPath, readConfig, readConfigSync, writeGeneratedConfig, } from './config.js';
3
3
  //# 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,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,aAAa,EACb,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,aAAa,CAAC","sourcesContent":["export { configTemplate } from './configTemplate.js';\nexport {\n configFileName,\n generatedConfigFileName,\n getConfigPath,\n readConfig,\n readConfigSync,\n writeGeneratedConfig,\n writeGeneratedConfigSync,\n} from './config.js';\nexport type { CloudpackConfig, DevServer, PackageOverride, Route, TelemetryConfig } from './types.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EACL,cAAc,EACd,uBAAuB,EACvB,aAAa,EACb,UAAU,EACV,cAAc,EACd,oBAAoB,GACrB,MAAM,aAAa,CAAC","sourcesContent":["export { configTemplate } from './configTemplate.js';\nexport {\n configFileName,\n generatedConfigFileName,\n getConfigPath,\n readConfig,\n readConfigSync,\n writeGeneratedConfig,\n} from './config.js';\nexport type { CloudpackConfig, DevServer, PackageOverride, Route, TelemetryConfig } from './types.js';\n"]}
package/lib/types.d.ts CHANGED
@@ -102,3 +102,4 @@ export interface GeneratedConfig {
102
102
  */
103
103
  packageOverrides?: PackageOverride[];
104
104
  }
105
+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;;;WAGG;QACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;KAC7B,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;CACtC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ms-cloudpack/config",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "Configuration handling for cloudpack.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -13,7 +13,7 @@
13
13
  }
14
14
  },
15
15
  "dependencies": {
16
- "@ms-cloudpack/bundler-types": "^0.12.0",
16
+ "@ms-cloudpack/bundler-types": "^0.12.1",
17
17
  "@ms-cloudpack/create-express-app": "^1.3.3",
18
18
  "@ms-cloudpack/json-utilities": "^0.0.6"
19
19
  },