@release-change/config 0.1.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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +15 -0
  3. package/dist/config.types.d.ts +14 -0
  4. package/dist/config.types.d.ts.map +1 -0
  5. package/dist/config.types.js +2 -0
  6. package/dist/config.types.js.map +1 -0
  7. package/dist/constants.d.ts +39 -0
  8. package/dist/constants.d.ts.map +1 -0
  9. package/dist/constants.js +40 -0
  10. package/dist/constants.js.map +1 -0
  11. package/dist/debug-config.d.ts +7 -0
  12. package/dist/debug-config.d.ts.map +1 -0
  13. package/dist/debug-config.js +25 -0
  14. package/dist/debug-config.js.map +1 -0
  15. package/dist/get-config-file.d.ts +7 -0
  16. package/dist/get-config-file.d.ts.map +1 -0
  17. package/dist/get-config-file.js +14 -0
  18. package/dist/get-config-file.js.map +1 -0
  19. package/dist/get-config.d.ts +9 -0
  20. package/dist/get-config.d.ts.map +1 -0
  21. package/dist/get-config.js +21 -0
  22. package/dist/get-config.js.map +1 -0
  23. package/dist/get-repository-url.d.ts +7 -0
  24. package/dist/get-repository-url.d.ts.map +1 -0
  25. package/dist/get-repository-url.js +21 -0
  26. package/dist/get-repository-url.js.map +1 -0
  27. package/dist/get-root-package.d.ts +8 -0
  28. package/dist/get-root-package.d.ts.map +1 -0
  29. package/dist/get-root-package.js +10 -0
  30. package/dist/get-root-package.js.map +1 -0
  31. package/dist/index.d.ts +6 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +5 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/switch-url-to-https-protocol.d.ts +7 -0
  36. package/dist/switch-url-to-https-protocol.d.ts.map +1 -0
  37. package/dist/switch-url-to-https-protocol.js +19 -0
  38. package/dist/switch-url-to-https-protocol.js.map +1 -0
  39. package/dist/switch-url-to-ssh-protocol.d.ts +7 -0
  40. package/dist/switch-url-to-ssh-protocol.d.ts.map +1 -0
  41. package/dist/switch-url-to-ssh-protocol.js +19 -0
  42. package/dist/switch-url-to-ssh-protocol.js.map +1 -0
  43. package/package.json +37 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-present Victor Brito
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # @release-change/config
2
+
3
+ Read and parse the repository configuration
4
+
5
+ ![License: MIT](https://img.shields.io/github/license/release-change/release-change)
6
+ [![ESM-only package](https://img.shields.io/badge/package-ESM--only-ffe536)](https://nodejs.org/api/esm.html)
7
+ [![Conventional Commits 1.0.0](https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white)](https://conventionalcommits.org)
8
+ [![Formatted with Biome](https://img.shields.io/badge/Formatted_with-Biome-60a5fa?style=flat&logo=biome)](https://biomejs.dev/)
9
+ ![NPM latest version](https://img.shields.io/npm/v/%40release-change%2Fconfig/latest)
10
+ ![Node support](https://img.shields.io/node/v/%40release-change%2Fconfig)
11
+ ![Build status](https://img.shields.io/github/actions/workflow/status/release-change/release-change/run-tests.yml)
12
+
13
+ ## Copyright & licence
14
+
15
+ © 2025-present Victor Brito — Released under the [MIT licence](./LICENSE).
@@ -0,0 +1,14 @@
1
+ export type PackageManifest = {
2
+ name: string;
3
+ version: string;
4
+ private?: boolean;
5
+ repository?: string | {
6
+ type: string;
7
+ url: string;
8
+ directory?: string;
9
+ };
10
+ workspaces?: string[];
11
+ dependencies?: Record<string, string>;
12
+ devDependencies?: Record<string, string>;
13
+ };
14
+ //# sourceMappingURL=config.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.types.d.ts","sourceRoot":"","sources":["../src/config.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EACP,MAAM,GACN;QACE,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,MAAM,CAAC;QACZ,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACN,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=config.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.types.js","sourceRoot":"","sources":["../src/config.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ export declare const HTTPS_URL_PATTERN: RegExp;
2
+ export declare const STANDALONE_SSH_URL_PATTERN: RegExp;
3
+ export declare const SSH_URL_PATTERN: RegExp;
4
+ export declare const GITHUB_URL_PATTERN: RegExp;
5
+ export declare const HTTPS_GITHUB_URL_REPLACEMENT_PATTERN = "https://github.com/$<user>/$<repo>.git";
6
+ export declare const SSH_GITHUB_URL_REPLACEMENT_PATTERN = "ssh://git@github.com/$<user>/$<repo>.git";
7
+ export declare const DEFAULT_CONFIG: {
8
+ readonly branches: readonly ["alpha", "beta", "main", "master", "next"];
9
+ readonly releaseType: {
10
+ readonly alpha: {
11
+ readonly channel: "alpha";
12
+ readonly prerelease: true;
13
+ readonly prereleaseIdentifier: "alpha";
14
+ };
15
+ readonly beta: {
16
+ readonly channel: "beta";
17
+ readonly prerelease: true;
18
+ readonly prereleaseIdentifier: "beta";
19
+ };
20
+ readonly main: {
21
+ readonly channel: "default";
22
+ };
23
+ readonly master: {
24
+ readonly channel: "default";
25
+ };
26
+ readonly next: {
27
+ readonly channel: "next";
28
+ readonly prerelease: true;
29
+ readonly prereleaseIdentifier: "rc";
30
+ };
31
+ };
32
+ readonly isMonorepo: false;
33
+ readonly dependencyUpdateMethod: null;
34
+ readonly remoteName: "origin";
35
+ readonly debug: false;
36
+ readonly dryRun: false;
37
+ };
38
+ export declare const CONFIG_FILE_NAME: string;
39
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,QAC+E,CAAC;AAC9G,eAAO,MAAM,0BAA0B,QACoD,CAAC;AAC5F,eAAO,MAAM,eAAe,QACmF,CAAC;AAChH,eAAO,MAAM,kBAAkB,QAA6D,CAAC;AAC7F,eAAO,MAAM,oCAAoC,2CAA2C,CAAC;AAC7F,eAAO,MAAM,kCAAkC,6CAA6C,CAAC;AAC7F,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BjB,CAAC;AACX,eAAO,MAAM,gBAAgB,QAAkC,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { WORKSPACE_NAME } from "@release-change/shared";
2
+ export const HTTPS_URL_PATTERN = /^(git\+)?ht{2}ps:\/{2}(?<host>[^/]+)\/(?<user>[-_./a-z0-9]+)\/(?<repo>[-_./a-z0-9]+)(?<extension>\.git)$/i;
3
+ export const STANDALONE_SSH_URL_PATTERN = /^git@(?<host>[^:]+):(?<user>[-_./a-z0-9]+)\/(?<repo>[-_./a-z0-9]+)(?<extension>\.git)$/i;
4
+ export const SSH_URL_PATTERN = /^(git\+)?s{2}h:\/{2}git@(?<host>[^/]+)\/(?<user>[-_./a-z0-9]+)\/(?<repo>[-_./a-z0-9]+)(?<extension>\.git)$/i;
5
+ export const GITHUB_URL_PATTERN = /^github:(?<user>[-_./a-z0-9]+)\/(?<repo>[-_./a-z0-9]+)$/i;
6
+ export const HTTPS_GITHUB_URL_REPLACEMENT_PATTERN = "https://github.com/$<user>/$<repo>.git";
7
+ export const SSH_GITHUB_URL_REPLACEMENT_PATTERN = "ssh://git@github.com/$<user>/$<repo>.git";
8
+ export const DEFAULT_CONFIG = {
9
+ branches: ["alpha", "beta", "main", "master", "next"],
10
+ releaseType: {
11
+ alpha: {
12
+ channel: "alpha",
13
+ prerelease: true,
14
+ prereleaseIdentifier: "alpha"
15
+ },
16
+ beta: {
17
+ channel: "beta",
18
+ prerelease: true,
19
+ prereleaseIdentifier: "beta"
20
+ },
21
+ main: {
22
+ channel: "default"
23
+ },
24
+ master: {
25
+ channel: "default"
26
+ },
27
+ next: {
28
+ channel: "next",
29
+ prerelease: true,
30
+ prereleaseIdentifier: "rc"
31
+ }
32
+ },
33
+ isMonorepo: false,
34
+ dependencyUpdateMethod: null,
35
+ remoteName: "origin",
36
+ debug: false,
37
+ dryRun: false
38
+ };
39
+ export const CONFIG_FILE_NAME = `${WORKSPACE_NAME}.config.json`;
40
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,CAAC,MAAM,iBAAiB,GAC5B,2GAA2G,CAAC;AAC9G,MAAM,CAAC,MAAM,0BAA0B,GACrC,yFAAyF,CAAC;AAC5F,MAAM,CAAC,MAAM,eAAe,GAC1B,6GAA6G,CAAC;AAChH,MAAM,CAAC,MAAM,kBAAkB,GAAG,0DAA0D,CAAC;AAC7F,MAAM,CAAC,MAAM,oCAAoC,GAAG,wCAAwC,CAAC;AAC7F,MAAM,CAAC,MAAM,kCAAkC,GAAG,0CAA0C,CAAC;AAC7F,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC;IACrD,WAAW,EAAE;QACX,KAAK,EAAE;YACL,OAAO,EAAE,OAAO;YAChB,UAAU,EAAE,IAAI;YAChB,oBAAoB,EAAE,OAAO;SAC9B;QACD,IAAI,EAAE;YACJ,OAAO,EAAE,MAAM;YACf,UAAU,EAAE,IAAI;YAChB,oBAAoB,EAAE,MAAM;SAC7B;QACD,IAAI,EAAE;YACJ,OAAO,EAAE,SAAS;SACnB;QACD,MAAM,EAAE;YACN,OAAO,EAAE,SAAS;SACnB;QACD,IAAI,EAAE;YACJ,OAAO,EAAE,MAAM;YACf,UAAU,EAAE,IAAI;YAChB,oBAAoB,EAAE,IAAI;SAC3B;KACF;IACD,UAAU,EAAE,KAAK;IACjB,sBAAsB,EAAE,IAAI;IAC5B,UAAU,EAAE,QAAQ;IACpB,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,KAAK;CACL,CAAC;AACX,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,cAAc,cAAc,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { Context } from "@release-change/shared";
2
+ /**
3
+ * Logs environment variables and config in debug mode.
4
+ * @param context - The context where the CLI is running.
5
+ */
6
+ export declare const debugConfig: (context: Context) => void;
7
+ //# sourceMappingURL=debug-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-config.d.ts","sourceRoot":"","sources":["../src/debug-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAUtD;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,SAAS,OAAO,KAAG,IAe9C,CAAC"}
@@ -0,0 +1,25 @@
1
+ import util from "node:util";
2
+ import { setLogger } from "@release-change/logger";
3
+ import { getConfigFile } from "./get-config-file.js";
4
+ import { CONFIG_FILE_NAME } from "./constants.js";
5
+ /**
6
+ * Logs environment variables and config in debug mode.
7
+ * @param context - The context where the CLI is running.
8
+ */
9
+ export const debugConfig = (context) => {
10
+ const { env, config, cwd } = context;
11
+ const logger = setLogger(config.debug);
12
+ if (config.debug) {
13
+ logger.setDebugScope("config:debug-config");
14
+ logger.logDebug("Load environment variables");
15
+ logger.logDebug(util.inspect(env, { depth: Number.POSITIVE_INFINITY }));
16
+ logger.logDebug("Load config");
17
+ const isConfigFile = Boolean(getConfigFile());
18
+ const configFileResult = isConfigFile
19
+ ? `Config loaded from \`${cwd}/${CONFIG_FILE_NAME}\``
20
+ : "Config file not found";
21
+ logger.logDebug(configFileResult);
22
+ logger.logDebug(util.inspect(config, { depth: Number.POSITIVE_INFINITY }));
23
+ }
24
+ };
25
+ //# sourceMappingURL=debug-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug-config.js","sourceRoot":"","sources":["../src/debug-config.ts"],"names":[],"mappings":"AAEA,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAgB,EAAQ,EAAE;IACpD,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;IACrC,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvC,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,MAAM,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC;QAC5C,MAAM,CAAC,QAAQ,CAAC,4BAA4B,CAAC,CAAC;QAC9C,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC;QACxE,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;QAC/B,MAAM,YAAY,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;QAC9C,MAAM,gBAAgB,GAAG,YAAY;YACnC,CAAC,CAAC,wBAAwB,GAAG,IAAI,gBAAgB,IAAI;YACrD,CAAC,CAAC,uBAAuB,CAAC;QAC5B,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QAClC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC;IAC7E,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import type { Config } from "@release-change/shared";
2
+ /**
3
+ * Gets the options defined within the config file.
4
+ * @return The config file contents parsed in JSON if the config file is found, `null` otherwise.
5
+ */
6
+ export declare const getConfigFile: () => Config | null;
7
+ //# sourceMappingURL=get-config-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-config-file.d.ts","sourceRoot":"","sources":["../src/get-config-file.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAOrD;;;GAGG;AACH,eAAO,MAAM,aAAa,QAAO,MAAM,GAAG,IAKzC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import fs from "node:fs";
2
+ import { cwd } from "node:process";
3
+ import { CONFIG_FILE_NAME } from "./constants.js";
4
+ /**
5
+ * Gets the options defined within the config file.
6
+ * @return The config file contents parsed in JSON if the config file is found, `null` otherwise.
7
+ */
8
+ export const getConfigFile = () => {
9
+ const pathToConfigFile = `${cwd()}/${CONFIG_FILE_NAME}`;
10
+ return fs.existsSync(pathToConfigFile)
11
+ ? JSON.parse(fs.readFileSync(pathToConfigFile, "utf8"))
12
+ : null;
13
+ };
14
+ //# sourceMappingURL=get-config-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-config-file.js","sourceRoot":"","sources":["../src/get-config-file.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAkB,EAAE;IAC/C,MAAM,gBAAgB,GAAG,GAAG,GAAG,EAAE,IAAI,gBAAgB,EAAE,CAAC;IACxD,OAAO,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAAC;QACpC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;QACvD,CAAC,CAAC,IAAI,CAAC;AACX,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { CliOptions, Config } from "@release-change/shared";
2
+ /**
3
+ * Gets the config. CLI options have precedence over config file options, which have precedence over default config options.
4
+ * @param [cliOptions] - The options from the CLI.
5
+ * @param [isMonorepo] - Whether the current directory is a monorepo or not.
6
+ * @return The config to use based on CLI options, config file and/or default config.
7
+ */
8
+ export declare const getConfig: (cliOptions?: CliOptions, isMonorepo?: boolean) => Promise<Config>;
9
+ //# sourceMappingURL=get-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-config.d.ts","sourceRoot":"","sources":["../src/get-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAOjE;;;;;GAKG;AACH,eAAO,MAAM,SAAS,GACpB,aAAY,UAAe,EAC3B,oBAAkB,KACjB,OAAO,CAAC,MAAM,CAehB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { getConfigFile } from "./get-config-file.js";
2
+ import { getRepositoryUrl } from "./get-repository-url.js";
3
+ import { DEFAULT_CONFIG } from "./constants.js";
4
+ /**
5
+ * Gets the config. CLI options have precedence over config file options, which have precedence over default config options.
6
+ * @param [cliOptions] - The options from the CLI.
7
+ * @param [isMonorepo] - Whether the current directory is a monorepo or not.
8
+ * @return The config to use based on CLI options, config file and/or default config.
9
+ */
10
+ export const getConfig = async (cliOptions = {}, isMonorepo = false) => {
11
+ const configFile = getConfigFile();
12
+ const dependencyUpdateMethod = isMonorepo ? (configFile?.dependencyUpdateMethod ?? "pin") : null;
13
+ const defaultConfig = {
14
+ ...DEFAULT_CONFIG,
15
+ repositoryUrl: String(getRepositoryUrl())
16
+ };
17
+ return configFile
18
+ ? Object.assign({}, defaultConfig, { ...configFile, isMonorepo, dependencyUpdateMethod }, cliOptions)
19
+ : Object.assign({}, defaultConfig, { isMonorepo, dependencyUpdateMethod }, cliOptions);
20
+ };
21
+ //# sourceMappingURL=get-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-config.js","sourceRoot":"","sources":["../src/get-config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAC5B,aAAyB,EAAE,EAC3B,UAAU,GAAG,KAAK,EACD,EAAE;IACnB,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,MAAM,sBAAsB,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,sBAAsB,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACjG,MAAM,aAAa,GAAG;QACpB,GAAG,cAAc;QACjB,aAAa,EAAE,MAAM,CAAC,gBAAgB,EAAE,CAAC;KAC1C,CAAC;IACF,OAAO,UAAU;QACf,CAAC,CAAC,MAAM,CAAC,MAAM,CACX,EAAE,EACF,aAAa,EACb,EAAE,GAAG,UAAU,EAAE,UAAU,EAAE,sBAAsB,EAAE,EACrD,UAAU,CACX;QACH,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,sBAAsB,EAAE,EAAE,UAAU,CAAC,CAAC;AAC3F,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Gets repository URL from the package file.
3
+ * If necessary, the URL is switched from Git+HTTPS to HTTPS protocol.
4
+ * @return The URL (using HTTPS protocol) if it is defined by the package file, `null` otherwise.
5
+ */
6
+ export declare const getRepositoryUrl: () => string | null;
7
+ //# sourceMappingURL=get-repository-url.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-repository-url.d.ts","sourceRoot":"","sources":["../src/get-repository-url.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,QAAO,MAAM,GAAG,IAS5C,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { cwd } from "node:process";
2
+ import { getRootPackage } from "./get-root-package.js";
3
+ import { switchUrlToHttpsProtocol } from "./switch-url-to-https-protocol.js";
4
+ /**
5
+ * Gets repository URL from the package file.
6
+ * If necessary, the URL is switched from Git+HTTPS to HTTPS protocol.
7
+ * @return The URL (using HTTPS protocol) if it is defined by the package file, `null` otherwise.
8
+ */
9
+ export const getRepositoryUrl = () => {
10
+ const rootPackage = getRootPackage(`${cwd()}/package.json`);
11
+ if (rootPackage) {
12
+ const { repository } = rootPackage;
13
+ if (typeof repository === "string")
14
+ return switchUrlToHttpsProtocol(repository);
15
+ if (typeof repository === "object")
16
+ return switchUrlToHttpsProtocol(repository.url);
17
+ return null;
18
+ }
19
+ return null;
20
+ };
21
+ //# sourceMappingURL=get-repository-url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-repository-url.js","sourceRoot":"","sources":["../src/get-repository-url.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mCAAmC,CAAC;AAE7E;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAkB,EAAE;IAClD,MAAM,WAAW,GAAG,cAAc,CAAC,GAAG,GAAG,EAAE,eAAe,CAAC,CAAC;IAC5D,IAAI,WAAW,EAAE,CAAC;QAChB,MAAM,EAAE,UAAU,EAAE,GAAG,WAAW,CAAC;QACnC,IAAI,OAAO,UAAU,KAAK,QAAQ;YAAE,OAAO,wBAAwB,CAAC,UAAU,CAAC,CAAC;QAChF,IAAI,OAAO,UAAU,KAAK,QAAQ;YAAE,OAAO,wBAAwB,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACpF,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { PackageManifest } from "./config.types.js";
2
+ /**
3
+ * Gets the content of the root package file.
4
+ * @param path - The path to the root package file.
5
+ * @return The content of the package file as JSON if the file is found, `null` otherwise.
6
+ */
7
+ export declare const getRootPackage: (path: string) => PackageManifest | null;
8
+ //# sourceMappingURL=get-root-package.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-root-package.d.ts","sourceRoot":"","sources":["../src/get-root-package.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIzD;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,eAAe,GAAG,IAE/D,CAAC"}
@@ -0,0 +1,10 @@
1
+ import fs from "node:fs";
2
+ /**
3
+ * Gets the content of the root package file.
4
+ * @param path - The path to the root package file.
5
+ * @return The content of the package file as JSON if the file is found, `null` otherwise.
6
+ */
7
+ export const getRootPackage = (path) => {
8
+ return fs.existsSync(path) ? JSON.parse(fs.readFileSync(path, "utf8")) : null;
9
+ };
10
+ //# sourceMappingURL=get-root-package.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-root-package.js","sourceRoot":"","sources":["../src/get-root-package.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAY,EAA0B,EAAE;IACrE,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAChF,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export type { PackageManifest } from "./config.types.js";
2
+ export { debugConfig } from "./debug-config.js";
3
+ export { getConfig } from "./get-config.js";
4
+ export { getRootPackage } from "./get-root-package.js";
5
+ export { DEFAULT_CONFIG } from "./constants.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { debugConfig } from "./debug-config.js";
2
+ export { getConfig } from "./get-config.js";
3
+ export { getRootPackage } from "./get-root-package.js";
4
+ export { DEFAULT_CONFIG } from "./constants.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Switches URL from non-HTTPS to HTTPS protocol.
3
+ * @param url - The URL to parse.
4
+ * @return The URL transformed to conform the HTTPS protocol.
5
+ */
6
+ export declare const switchUrlToHttpsProtocol: (url: string) => string;
7
+ //# sourceMappingURL=switch-url-to-https-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch-url-to-https-protocol.d.ts","sourceRoot":"","sources":["../src/switch-url-to-https-protocol.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GAAI,KAAK,MAAM,KAAG,MAWtD,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { GITHUB_URL_PATTERN, HTTPS_GITHUB_URL_REPLACEMENT_PATTERN, SSH_URL_PATTERN, STANDALONE_SSH_URL_PATTERN } from "./constants.js";
2
+ /**
3
+ * Switches URL from non-HTTPS to HTTPS protocol.
4
+ * @param url - The URL to parse.
5
+ * @return The URL transformed to conform the HTTPS protocol.
6
+ */
7
+ export const switchUrlToHttpsProtocol = (url) => {
8
+ switch (true) {
9
+ case STANDALONE_SSH_URL_PATTERN.test(url):
10
+ return url.replace(STANDALONE_SSH_URL_PATTERN, HTTPS_GITHUB_URL_REPLACEMENT_PATTERN);
11
+ case SSH_URL_PATTERN.test(url):
12
+ return url.replace(SSH_URL_PATTERN, HTTPS_GITHUB_URL_REPLACEMENT_PATTERN);
13
+ case GITHUB_URL_PATTERN.test(url):
14
+ return url.replace(GITHUB_URL_PATTERN, HTTPS_GITHUB_URL_REPLACEMENT_PATTERN);
15
+ default:
16
+ return url.replace("git+", "");
17
+ }
18
+ };
19
+ //# sourceMappingURL=switch-url-to-https-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch-url-to-https-protocol.js","sourceRoot":"","sources":["../src/switch-url-to-https-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,oCAAoC,EACpC,eAAe,EACf,0BAA0B,EAC3B,MAAM,gBAAgB,CAAC;AAExB;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,GAAW,EAAU,EAAE;IAC9D,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,0BAA0B,CAAC,IAAI,CAAC,GAAG,CAAC;YACvC,OAAO,GAAG,CAAC,OAAO,CAAC,0BAA0B,EAAE,oCAAoC,CAAC,CAAC;QACvF,KAAK,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC;YAC5B,OAAO,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,oCAAoC,CAAC,CAAC;QAC5E,KAAK,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC;YAC/B,OAAO,GAAG,CAAC,OAAO,CAAC,kBAAkB,EAAE,oCAAoC,CAAC,CAAC;QAC/E;YACE,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACnC,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Switches URL from non-SSH to SSH protocol.
3
+ * @param url - The URL to parse.
4
+ * @return The URL transformed to conform the SSH protocol.
5
+ */
6
+ export declare const switchUrlToSshProtocol: (url: string) => string;
7
+ //# sourceMappingURL=switch-url-to-ssh-protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch-url-to-ssh-protocol.d.ts","sourceRoot":"","sources":["../src/switch-url-to-ssh-protocol.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAAI,KAAK,MAAM,KAAG,MAWpD,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { GITHUB_URL_PATTERN, HTTPS_URL_PATTERN, SSH_GITHUB_URL_REPLACEMENT_PATTERN, STANDALONE_SSH_URL_PATTERN } from "./constants.js";
2
+ /**
3
+ * Switches URL from non-SSH to SSH protocol.
4
+ * @param url - The URL to parse.
5
+ * @return The URL transformed to conform the SSH protocol.
6
+ */
7
+ export const switchUrlToSshProtocol = (url) => {
8
+ switch (true) {
9
+ case STANDALONE_SSH_URL_PATTERN.test(url):
10
+ return url.replace(STANDALONE_SSH_URL_PATTERN, SSH_GITHUB_URL_REPLACEMENT_PATTERN);
11
+ case HTTPS_URL_PATTERN.test(url):
12
+ return url.replace(HTTPS_URL_PATTERN, SSH_GITHUB_URL_REPLACEMENT_PATTERN);
13
+ case GITHUB_URL_PATTERN.test(url):
14
+ return url.replace(GITHUB_URL_PATTERN, SSH_GITHUB_URL_REPLACEMENT_PATTERN);
15
+ default:
16
+ return url.replace("git+", "");
17
+ }
18
+ };
19
+ //# sourceMappingURL=switch-url-to-ssh-protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch-url-to-ssh-protocol.js","sourceRoot":"","sources":["../src/switch-url-to-ssh-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,kCAAkC,EAClC,0BAA0B,EAC3B,MAAM,gBAAgB,CAAC;AAExB;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAW,EAAU,EAAE;IAC5D,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,0BAA0B,CAAC,IAAI,CAAC,GAAG,CAAC;YACvC,OAAO,GAAG,CAAC,OAAO,CAAC,0BAA0B,EAAE,kCAAkC,CAAC,CAAC;QACrF,KAAK,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC;YAC9B,OAAO,GAAG,CAAC,OAAO,CAAC,iBAAiB,EAAE,kCAAkC,CAAC,CAAC;QAC5E,KAAK,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC;YAC/B,OAAO,GAAG,CAAC,OAAO,CAAC,kBAAkB,EAAE,kCAAkC,CAAC,CAAC;QAC7E;YACE,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACnC,CAAC;AACH,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@release-change/config",
3
+ "version": "0.1.0",
4
+ "description": "Read and parse the repository configuration",
5
+ "keywords": [],
6
+ "homepage": "https://github.com/release-change/release-change",
7
+ "bugs": {
8
+ "url": "https://github.com/release-change/release-change/issues"
9
+ },
10
+ "author": "Victor Brito (https://victor-brito.dev)",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/release-change/release-change.git"
14
+ },
15
+ "type": "module",
16
+ "license": "MIT",
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "exports": {
21
+ "import": "./dist/index.js",
22
+ "types": "./dist/index.d.ts"
23
+ },
24
+ "engines": {
25
+ "node": "^20.18.3 || ^22.12.0 || ^24.0.0",
26
+ "npm": ">=10.8.2",
27
+ "pnpm": ">=10.28.0"
28
+ },
29
+ "dependencies": {
30
+ "@release-change/logger": "0.1.0",
31
+ "@release-change/shared": "0.1.0"
32
+ },
33
+ "scripts": {
34
+ "build": "tsc",
35
+ "dev": "tsc --watch --preserveWatchOutput & vitest"
36
+ }
37
+ }