@ms-cloudpack/config 0.4.0 → 0.5.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.
- package/lib/config.d.ts +0 -6
- package/lib/config.js +12 -12
- package/lib/config.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/config.d.ts
CHANGED
|
@@ -27,9 +27,3 @@ 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;
|
package/lib/config.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import { readJson, readJsonSync, writeJson
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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,
|
|
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,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,oFAAoF;IACpF,MAAM,eAAe,GACnB,MAAM,CAAC,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"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { configTemplate } from './configTemplate.js';
|
|
2
|
-
export { configFileName, generatedConfigFileName, getConfigPath, readConfig, readConfigSync, writeGeneratedConfig,
|
|
2
|
+
export { configFileName, generatedConfigFileName, getConfigPath, readConfig, readConfigSync, writeGeneratedConfig, } from './config.js';
|
|
3
3
|
export type { CloudpackConfig, DevServer, PackageOverride, Route, TelemetryConfig } from './types.js';
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { configTemplate } from './configTemplate.js';
|
|
2
|
-
export { configFileName, generatedConfigFileName, getConfigPath, readConfig, readConfigSync, writeGeneratedConfig,
|
|
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,
|
|
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"]}
|