@cluerise/tools 5.3.13 → 5.4.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.
@@ -1 +1 @@
1
- v25.4.0
1
+ v25.8.1
@@ -36,6 +36,7 @@ export const createReleaseConfig = ({
36
36
  repository,
37
37
  path = '',
38
38
  tagFormat,
39
+ branchFormat,
39
40
  releaseRules: inputReleaseRules = defaultReleaseRules,
40
41
  changelogTypes: inputChangelogTypes = defaultChangelogTypes,
41
42
  dependencyScopes = ['prod'],
@@ -59,6 +60,7 @@ export const createReleaseConfig = ({
59
60
  branches: ['main'],
60
61
  repositoryUrl: getRepositoryUrl(path),
61
62
  tagFormat,
63
+ branchFormat,
62
64
  preset: 'conventionalcommits',
63
65
  dryRun: true,
64
66
 
@@ -2,240 +2,239 @@ import SemVer from "semver";
2
2
  import FileSystem from "node:fs/promises";
3
3
  import { z } from "zod";
4
4
  import { parse } from "smol-toml";
5
- const gitProviderOrigins = {
6
- github: "https://github.com"
5
+ //#region src/modules/core/package-json/git-provider.ts
6
+ var gitProviderOrigins = { github: "https://github.com" };
7
+ var GitProvider = class {
8
+ static #origins = gitProviderOrigins;
9
+ static #names = Object.keys(this.#origins);
10
+ /**
11
+ * Check if the provided name is a valid Git provider name.
12
+ *
13
+ * @param name The name to check.
14
+ * @returns True if the name is valid, otherwise false.
15
+ */
16
+ static isValidName(name) {
17
+ return this.#names.includes(name);
18
+ }
19
+ /**
20
+ * Get the origin URL for the given Git provider name.
21
+ *
22
+ * @param name The Git provider name.
23
+ * @returns The origin URL.
24
+ */
25
+ static getOrigin(name) {
26
+ return this.#origins[name];
27
+ }
7
28
  };
8
- class GitProvider {
9
- static #origins = gitProviderOrigins;
10
- static #names = Object.keys(this.#origins);
11
- /**
12
- * Check if the provided name is a valid Git provider name.
13
- *
14
- * @param name The name to check.
15
- * @returns True if the name is valid, otherwise false.
16
- */
17
- static isValidName(name) {
18
- return this.#names.includes(name);
19
- }
20
- /**
21
- * Get the origin URL for the given Git provider name.
22
- *
23
- * @param name The Git provider name.
24
- * @returns The origin URL.
25
- */
26
- static getOrigin(name) {
27
- return this.#origins[name];
28
- }
29
- }
30
- const enginesSchema = z.object({
31
- node: z.string()
29
+ //#endregion
30
+ //#region src/modules/core/package-json/package-json-data.ts
31
+ var enginesSchema = z.object({ node: z.string() });
32
+ var repositoryObjectSchema = z.object({
33
+ type: z.string(),
34
+ url: z.string(),
35
+ directory: z.string().optional()
32
36
  });
33
- const repositoryObjectSchema = z.object({
34
- type: z.string(),
35
- url: z.string(),
36
- directory: z.string().optional()
37
+ var repositorySchema = z.union([z.string(), repositoryObjectSchema]);
38
+ var packageJsonDataSchema = z.object({
39
+ name: z.string(),
40
+ version: z.string().optional(),
41
+ description: z.string().optional(),
42
+ engines: enginesSchema.optional(),
43
+ repository: repositorySchema.optional()
37
44
  });
38
- const repositorySchema = z.union([z.string(), repositoryObjectSchema]);
39
- const packageJsonDataSchema = z.object({
40
- name: z.string(),
41
- version: z.string().optional(),
42
- description: z.string().optional(),
43
- engines: enginesSchema.optional(),
44
- repository: repositorySchema.optional()
45
- });
46
- class PackageJson {
47
- #data;
48
- constructor(data) {
49
- this.#data = data;
50
- }
51
- /**
52
- * Load and parse the `package.json` file, returning a `PackageJson` instance.
53
- *
54
- * Throws an error if the file is invalid or cannot be parsed.
55
- *
56
- * @returns A new `PackageJson` instance with parsed data.
57
- */
58
- static async init() {
59
- const content = await FileSystem.readFile("package.json", { encoding: "utf8" });
60
- const data = JsonUtils.parse(content);
61
- const parseResult = packageJsonDataSchema.safeParse(data);
62
- if (!parseResult.success) {
63
- throw new Error("Invalid package.json", {
64
- cause: parseResult.error
65
- });
66
- }
67
- return new PackageJson(data);
68
- }
69
- /**
70
- * Get the package name from `package.json`.
71
- *
72
- * @returns The package name.
73
- */
74
- get name() {
75
- return this.#data.name;
76
- }
77
- /**
78
- * Get the package version from `package.json`.
79
- *
80
- * @returns The package version.
81
- */
82
- get version() {
83
- return this.#data.version;
84
- }
85
- /**
86
- * Get the engines field from `package.json`, if present.
87
- *
88
- * @returns The engines object or undefined.
89
- */
90
- get engines() {
91
- return this.#data.engines;
92
- }
93
- /**
94
- * Set the engines field in `package.json`.
95
- *
96
- * @param engines The engines object to set.
97
- */
98
- set engines(engines) {
99
- this.#data.engines = engines;
100
- }
101
- /**
102
- * Get the repository field from `package.json`, if present.
103
- *
104
- * @returns The repository object or string, or undefined.
105
- */
106
- get repository() {
107
- return this.#data.repository;
108
- }
109
- #parseGitRepository(urlString) {
110
- if (!urlString) {
111
- return null;
112
- }
113
- const urlValue = urlString.includes(":") ? urlString : `https://${urlString}`;
114
- const url = new URL(urlValue);
115
- const scheme = url.protocol.slice(0, -1);
116
- if (GitProvider.isValidName(scheme)) {
117
- const [owner, repositoryName] = url.pathname.split("/");
118
- if (!owner || !repositoryName) {
119
- throw new Error("Unknown owner or repositoryName");
120
- }
121
- return {
122
- origin: GitProvider.getOrigin(scheme),
123
- owner,
124
- repositoryName
125
- };
126
- }
127
- if (scheme === "https") {
128
- const [, owner, repositoryName] = url.pathname.split("/");
129
- if (!owner || !repositoryName) {
130
- throw new Error("Unknown owner or repositoryName");
131
- }
132
- return {
133
- origin: url.origin,
134
- owner,
135
- repositoryName: repositoryName.endsWith(".git") ? repositoryName.slice(0, -4) : repositoryName
136
- };
137
- }
138
- throw new Error("Unsupported repository URL");
139
- }
140
- /**
141
- * Parse the repository information from `package.json` and return a `GitRepository` object or null.
142
- *
143
- * Returns null if no repository is defined or if parsing fails.
144
- *
145
- * @returns The parsed `GitRepository`, or null if not available.
146
- */
147
- parseGitRepository() {
148
- if (!this.repository) {
149
- return null;
150
- }
151
- if (typeof this.repository === "string") {
152
- return this.#parseGitRepository(this.repository);
153
- }
154
- return this.#parseGitRepository(this.repository.url);
155
- }
156
- /**
157
- * Save the current `package.json` data to disk, formatting it as prettified JSON.
158
- */
159
- async save() {
160
- const content = JsonUtils.prettify(this.#data) + "\n";
161
- await FileSystem.writeFile("package.json", content, { encoding: "utf8" });
162
- }
163
- }
164
- const runMain = (main2) => {
165
- Promise.resolve().then(() => main2(process.argv.slice(2))).then((exitCode) => {
166
- process.exit(exitCode);
167
- }).catch((error) => {
168
- console.error("Error:", error);
169
- process.exit(1);
170
- });
45
+ //#endregion
46
+ //#region src/modules/core/package-json/package-json.ts
47
+ var PackageJson = class PackageJson {
48
+ #data;
49
+ constructor(data) {
50
+ this.#data = data;
51
+ }
52
+ /**
53
+ * Load and parse the `package.json` file, returning a `PackageJson` instance.
54
+ *
55
+ * Throws an error if the file is invalid or cannot be parsed.
56
+ *
57
+ * @returns A new `PackageJson` instance with parsed data.
58
+ */
59
+ static async init() {
60
+ const content = await FileSystem.readFile("package.json", { encoding: "utf8" });
61
+ const data = JsonUtils.parse(content);
62
+ const parseResult = packageJsonDataSchema.safeParse(data);
63
+ if (!parseResult.success) throw new Error("Invalid package.json", { cause: parseResult.error });
64
+ return new PackageJson(data);
65
+ }
66
+ /**
67
+ * Get the package name from `package.json`.
68
+ *
69
+ * @returns The package name.
70
+ */
71
+ get name() {
72
+ return this.#data.name;
73
+ }
74
+ /**
75
+ * Get the package version from `package.json`.
76
+ *
77
+ * @returns The package version.
78
+ */
79
+ get version() {
80
+ return this.#data.version;
81
+ }
82
+ /**
83
+ * Get the engines field from `package.json`, if present.
84
+ *
85
+ * @returns The engines object or undefined.
86
+ */
87
+ get engines() {
88
+ return this.#data.engines;
89
+ }
90
+ /**
91
+ * Set the engines field in `package.json`.
92
+ *
93
+ * @param engines The engines object to set.
94
+ */
95
+ set engines(engines) {
96
+ this.#data.engines = engines;
97
+ }
98
+ /**
99
+ * Get the repository field from `package.json`, if present.
100
+ *
101
+ * @returns The repository object or string, or undefined.
102
+ */
103
+ get repository() {
104
+ return this.#data.repository;
105
+ }
106
+ #parseGitRepository(urlString) {
107
+ if (!urlString) return null;
108
+ const urlValue = urlString.includes(":") ? urlString : `https://${urlString}`;
109
+ const url = new URL(urlValue);
110
+ const scheme = url.protocol.slice(0, -1);
111
+ if (GitProvider.isValidName(scheme)) {
112
+ const [owner, repositoryName] = url.pathname.split("/");
113
+ if (!owner || !repositoryName) throw new Error("Unknown owner or repositoryName");
114
+ return {
115
+ origin: GitProvider.getOrigin(scheme),
116
+ owner,
117
+ repositoryName
118
+ };
119
+ }
120
+ if (scheme === "https") {
121
+ const [, owner, repositoryName] = url.pathname.split("/");
122
+ if (!owner || !repositoryName) throw new Error("Unknown owner or repositoryName");
123
+ return {
124
+ origin: url.origin,
125
+ owner,
126
+ repositoryName: repositoryName.endsWith(".git") ? repositoryName.slice(0, -4) : repositoryName
127
+ };
128
+ }
129
+ throw new Error("Unsupported repository URL");
130
+ }
131
+ /**
132
+ * Parse the repository information from `package.json` and return a `GitRepository` object or null.
133
+ *
134
+ * Returns null if no repository is defined or if parsing fails.
135
+ *
136
+ * @returns The parsed `GitRepository`, or null if not available.
137
+ */
138
+ parseGitRepository() {
139
+ if (!this.repository) return null;
140
+ if (typeof this.repository === "string") return this.#parseGitRepository(this.repository);
141
+ return this.#parseGitRepository(this.repository.url);
142
+ }
143
+ /**
144
+ * Save the current `package.json` data to disk, formatting it as prettified JSON.
145
+ */
146
+ async save() {
147
+ const content = JsonUtils.prettify(this.#data) + "\n";
148
+ await FileSystem.writeFile("package.json", content, { encoding: "utf8" });
149
+ }
150
+ };
151
+ //#endregion
152
+ //#region src/modules/core/run-main.ts
153
+ /**
154
+ * Execute the provided main function and handle any errors that occur.
155
+ *
156
+ * If the main function resolves, the process exits with the returned code.
157
+ * If an error is thrown, it logs the error and exits with code 1.
158
+ *
159
+ * @param main The main function to execute.
160
+ */
161
+ var runMain = (main) => {
162
+ Promise.resolve().then(() => main(process.argv.slice(2))).then((exitCode) => {
163
+ process.exit(exitCode);
164
+ }).catch((error) => {
165
+ console.error("Error:", error);
166
+ process.exit(1);
167
+ });
171
168
  };
172
- class JsonUtils {
173
- static stringify(value) {
174
- return JSON.stringify(value);
175
- }
176
- static prettify(value) {
177
- return JSON.stringify(value, null, 2);
178
- }
179
- static parse(value) {
180
- return JSON.parse(value);
181
- }
182
- }
183
- const herokuNodeReleaseSchema = z.object({
184
- version: z.string(),
185
- channel: z.string(),
186
- arch: z.string(),
187
- url: z.string(),
188
- etag: z.string()
169
+ //#endregion
170
+ //#region src/modules/core/utils/json-utils.ts
171
+ var JsonUtils = class {
172
+ static stringify(value) {
173
+ return JSON.stringify(value);
174
+ }
175
+ static prettify(value) {
176
+ return JSON.stringify(value, null, 2);
177
+ }
178
+ static parse(value) {
179
+ return JSON.parse(value);
180
+ }
181
+ };
182
+ //#endregion
183
+ //#region src/modules/heroku/heroku-node-release.ts
184
+ var herokuNodeReleaseSchema = z.object({
185
+ version: z.string(),
186
+ channel: z.string(),
187
+ arch: z.string(),
188
+ url: z.string(),
189
+ etag: z.string()
189
190
  });
190
- const herokuNodeReleasesSchema = z.object({
191
- name: z.string(),
192
- releases: z.array(herokuNodeReleaseSchema)
191
+ var herokuNodeReleasesSchema = z.object({
192
+ name: z.string(),
193
+ releases: z.array(herokuNodeReleaseSchema)
193
194
  });
194
- class Heroku {
195
- static #nodeReleasesUrl = "https://raw.githubusercontent.com/heroku/heroku-buildpack-nodejs/latest/inventory/node.toml";
196
- /**
197
- * Fetch supported Node.js releases on Heroku.
198
- *
199
- * @returns A promise that resolves to an array of HerokuNodeRelease objects.
200
- */
201
- static async fetchNodeReleases() {
202
- const response = await fetch(this.#nodeReleasesUrl);
203
- const data = await response.text();
204
- const releasesData = parse(data);
205
- const { releases } = herokuNodeReleasesSchema.parse(releasesData);
206
- return releases;
207
- }
208
- }
209
- const getResultMessage = (nodeVersion, supported) => {
210
- const nodeVersionIsRange = SemVer.valid(nodeVersion) === null;
211
- const name = `Node.js version ${nodeVersionIsRange ? `range "${nodeVersion}"` : nodeVersion}`;
212
- return `${name} is ${supported ? "" : "not "}supported on Heroku`;
195
+ //#endregion
196
+ //#region src/modules/heroku/heroku.ts
197
+ var Heroku = class {
198
+ static #nodeReleasesUrl = "https://raw.githubusercontent.com/heroku/heroku-buildpack-nodejs/latest/inventory/node.toml";
199
+ /**
200
+ * Fetch supported Node.js releases on Heroku.
201
+ *
202
+ * @returns A promise that resolves to an array of HerokuNodeRelease objects.
203
+ */
204
+ static async fetchNodeReleases() {
205
+ const releasesData = parse(await (await fetch(this.#nodeReleasesUrl)).text());
206
+ const { releases } = herokuNodeReleasesSchema.parse(releasesData);
207
+ return releases;
208
+ }
209
+ };
210
+ //#endregion
211
+ //#region src/app/scripts/check-heroku-node-version/main.ts
212
+ var getResultMessage = (nodeVersion, supported) => {
213
+ return `${`Node.js version ${SemVer.valid(nodeVersion) === null ? `range "${nodeVersion}"` : nodeVersion}`} is ${supported ? "" : "not "}supported on Heroku`;
213
214
  };
214
- const main = async () => {
215
- try {
216
- const packageJson = await PackageJson.init();
217
- const nodeVersion = packageJson.engines?.node;
218
- if (!nodeVersion) {
219
- console.error("Error: Node.js version is not specified in package.json");
220
- return 1;
221
- }
222
- const nodeVersionIsValid = SemVer.validRange(nodeVersion) !== null;
223
- if (!nodeVersionIsValid) {
224
- console.error(`Error: Node.js version "${nodeVersion}" is not valid semver version or range`);
225
- return 1;
226
- }
227
- const releases = await Heroku.fetchNodeReleases();
228
- const nodeVersionIsSupported = releases.some((release) => SemVer.satisfies(release.version, nodeVersion));
229
- if (!nodeVersionIsSupported) {
230
- console.error(`Error: ${getResultMessage(nodeVersion, false)}`);
231
- return 1;
232
- }
233
- console.info(`Info: ${getResultMessage(nodeVersion, true)}`);
234
- return 0;
235
- } catch (error) {
236
- console.error("Error: Cannot check Node.js version on Heroku");
237
- console.error(error);
238
- return 1;
239
- }
215
+ var main = async () => {
216
+ try {
217
+ const nodeVersion = (await PackageJson.init()).engines?.node;
218
+ if (!nodeVersion) {
219
+ console.error("Error: Node.js version is not specified in package.json");
220
+ return 1;
221
+ }
222
+ if (!(SemVer.validRange(nodeVersion) !== null)) {
223
+ console.error(`Error: Node.js version "${nodeVersion}" is not valid semver version or range`);
224
+ return 1;
225
+ }
226
+ if (!(await Heroku.fetchNodeReleases()).some((release) => SemVer.satisfies(release.version, nodeVersion))) {
227
+ console.error(`Error: ${getResultMessage(nodeVersion, false)}`);
228
+ return 1;
229
+ }
230
+ console.info(`Info: ${getResultMessage(nodeVersion, true)}`);
231
+ return 0;
232
+ } catch (error) {
233
+ console.error("Error: Cannot check Node.js version on Heroku");
234
+ console.error(error);
235
+ return 1;
236
+ }
240
237
  };
241
238
  runMain(main);
239
+ //#endregion
240
+ export {};