@scaleway/changesets-renovate 2.2.3 → 2.2.4

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.
@@ -0,0 +1,3 @@
1
+ # Licenses
2
+
3
+ The app does not bundle any dependencies with licenses.
package/dist/cli.js CHANGED
@@ -1,43 +1,36 @@
1
1
  #!/usr/bin/env node
2
- import { env } from "node:process";
3
- import { simpleGit } from "simple-git";
4
2
  import { handleCatalogChanges } from "./handle-catalog.js";
5
3
  import { handlePackageChanges } from "./handle-packages.js";
4
+ import { env } from "node:process";
5
+ import { simpleGit } from "simple-git";
6
6
  async function run() {
7
- const branch = await simpleGit().branch();
8
- const branchPrefix = env["BRANCH_PREFIX"] ?? "renovate/";
9
- console.log("Detected branch:", branch);
10
- if (!(branch.current.startsWith(branchPrefix) || env["SKIP_BRANCH_CHECK"])) {
11
- console.log("Not a renovate branch, skipping");
12
- return;
13
- }
14
- const diffOutput = await simpleGit().diffSummary(["--name-only", "HEAD~1"]);
15
- const diffFiles = diffOutput.files.map((file) => file.file);
16
- console.log("Found changed files:", diffFiles);
17
- if (diffFiles.find((f) => f.startsWith(".changeset"))) {
18
- console.log("Changeset already exists, skipping");
19
- return;
20
- }
21
- const hasPackageChanges = diffFiles.some(
22
- (file) => file.includes("package.json")
23
- );
24
- const hasWorkspaceChanges = diffFiles.some(
25
- (file) => file.includes("pnpm-workspace.yaml")
26
- );
27
- if (!(hasPackageChanges || hasWorkspaceChanges)) {
28
- console.log("No relevant changes detected, skipping");
29
- return;
30
- }
31
- if (hasWorkspaceChanges) {
32
- console.log("šŸ“š Processing pnpm workspace catalog changes...");
33
- await handleCatalogChanges(diffFiles);
34
- }
35
- if (hasPackageChanges) {
36
- console.log("šŸ“¦ Processing package.json changes...");
37
- await handlePackageChanges(diffFiles);
38
- }
7
+ const branch = await simpleGit().branch();
8
+ const branchPrefix = env["BRANCH_PREFIX"] ?? "renovate/";
9
+ console.log("Detected branch:", branch);
10
+ if (!(branch.current.startsWith(branchPrefix) || env["SKIP_BRANCH_CHECK"])) {
11
+ console.log("Not a renovate branch, skipping");
12
+ return;
13
+ }
14
+ const diffFiles = (await simpleGit().diffSummary(["--name-only", "HEAD~1"])).files.map((file) => file.file);
15
+ console.log("Found changed files:", diffFiles);
16
+ if (diffFiles.find((f) => f.startsWith(".changeset"))) {
17
+ console.log("Changeset already exists, skipping");
18
+ return;
19
+ }
20
+ const hasPackageChanges = diffFiles.some((file) => file.includes("package.json"));
21
+ const hasWorkspaceChanges = diffFiles.some((file) => file.includes("pnpm-workspace.yaml"));
22
+ if (!(hasPackageChanges || hasWorkspaceChanges)) {
23
+ console.log("No relevant changes detected, skipping");
24
+ return;
25
+ }
26
+ if (hasWorkspaceChanges) {
27
+ console.log("šŸ“š Processing pnpm workspace catalog changes...");
28
+ await handleCatalogChanges(diffFiles);
29
+ }
30
+ if (hasPackageChanges) {
31
+ console.log("šŸ“¦ Processing package.json changes...");
32
+ await handlePackageChanges(diffFiles);
33
+ }
39
34
  }
40
35
  run().catch(console.error);
41
- export {
42
- run
43
- };
36
+ export { run };
@@ -1,24 +1,13 @@
1
- import { writeFile } from "node:fs/promises";
2
1
  import { env } from "node:process";
2
+ import { writeFile } from "node:fs/promises";
3
3
  async function createChangeset(fileName, packageBumps, packages) {
4
- const messageLines = [];
5
- for (const [pkg, bump] of packageBumps) {
6
- messageLines.push(`Updated dependency \`${pkg}\` to \`${bump}\`.`);
7
- }
8
- if (env["SORT_CHANGESETS"]) {
9
- packages.sort();
10
- messageLines.sort();
11
- }
12
- const message = messageLines.join("\n");
13
- const pkgs = packages.map((pkg) => `'${pkg}': patch`).join("\n");
14
- const body = `---
15
- ${pkgs}
16
- ---
17
-
18
- ${message.trim()}
19
- `;
20
- await writeFile(fileName, body);
4
+ const messageLines = [];
5
+ for (const [pkg, bump] of packageBumps) messageLines.push(`Updated dependency \`${pkg}\` to \`${bump}\`.`);
6
+ if (env["SORT_CHANGESETS"]) {
7
+ packages.sort();
8
+ messageLines.sort();
9
+ }
10
+ const message = messageLines.join("\n");
11
+ await writeFile(fileName, `---\n${packages.map((pkg) => `'${pkg}': patch`).join("\n")}\n---\n\n${message.trim()}\n`);
21
12
  }
22
- export {
23
- createChangeset
24
- };
13
+ export { createChangeset };
package/dist/git-utils.js CHANGED
@@ -1,86 +1,60 @@
1
- import { readFile } from "node:fs/promises";
2
1
  import { env } from "node:process";
2
+ import { simpleGit } from "simple-git";
3
+ import { readFile } from "node:fs/promises";
3
4
  import fg from "fast-glob";
4
5
  import { load } from "js-yaml";
5
- import { simpleGit } from "simple-git";
6
- const { globSync } = fg;
6
+ var { globSync } = fg;
7
7
  async function loadCatalogFromGit(revision = "HEAD", filePath = "pnpm-workspace.yaml") {
8
- try {
9
- if (!revision) {
10
- return {};
11
- }
12
- const git = simpleGit();
13
- const content = await git.show([`${revision}:${filePath}`]);
14
- const parsed = load(content);
15
- return parsed?.catalog ?? {};
16
- } catch {
17
- return {};
18
- }
8
+ try {
9
+ if (!revision) return {};
10
+ return load(await simpleGit().show([`${revision}:${filePath}`]))?.catalog ?? {};
11
+ } catch {
12
+ return {};
13
+ }
19
14
  }
20
15
  async function findChangedDependenciesFromGit(oldRevision, newRevision = "HEAD", filePath = "pnpm-workspace.yaml") {
21
- const oldCatalog = await loadCatalogFromGit(oldRevision, filePath);
22
- const newCatalog = await loadCatalogFromGit(newRevision, filePath);
23
- const bumps = /* @__PURE__ */ new Map();
24
- const filtedPackage = Object.entries(newCatalog).filter(
25
- ([pkg, newVersion]) => oldCatalog[pkg] && oldCatalog[pkg] !== newVersion
26
- );
27
- for (const [pkg, newVersion] of filtedPackage) {
28
- bumps.set(pkg, newVersion);
29
- }
30
- return bumps;
16
+ const oldCatalog = await loadCatalogFromGit(oldRevision, filePath);
17
+ const newCatalog = await loadCatalogFromGit(newRevision, filePath);
18
+ const bumps = /* @__PURE__ */ new Map();
19
+ const filtedPackage = Object.entries(newCatalog).filter(([pkg, newVersion]) => oldCatalog[pkg] && oldCatalog[pkg] !== newVersion);
20
+ for (const [pkg, newVersion] of filtedPackage) bumps.set(pkg, newVersion);
21
+ return bumps;
31
22
  }
32
23
  async function getBumpsFromGit(files) {
33
- const bumps = /* @__PURE__ */ new Map();
34
- const promises = files.map(async (file) => {
35
- const changes = await simpleGit().show([file]);
36
- for (const change of changes.split("\n")) {
37
- if (change.startsWith("+ ")) {
38
- const match = change.match(/"(.*?)"/g);
39
- if (match?.[0] && match[1]) {
40
- bumps.set(match[0].replace(/"/g, ""), match[1].replace(/"/g, ""));
41
- }
42
- }
43
- }
44
- });
45
- await Promise.all(promises);
46
- return bumps;
24
+ const bumps = /* @__PURE__ */ new Map();
25
+ const promises = files.map(async (file) => {
26
+ const changes = await simpleGit().show([file]);
27
+ for (const change of changes.split("\n")) if (change.startsWith("+ ")) {
28
+ const match = change.match(/"(.*?)"/g);
29
+ if (match?.[0] && match[1]) bumps.set(match[0].replace(/"/g, ""), match[1].replace(/"/g, ""));
30
+ }
31
+ });
32
+ await Promise.all(promises);
33
+ return bumps;
47
34
  }
48
35
  async function findAffectedPackages(changedDeps, packageJsonGlob = "packages/*/package.json") {
49
- if (changedDeps.length === 0) {
50
- return /* @__PURE__ */ new Set();
51
- }
52
- const packageJsonPaths = globSync(packageJsonGlob);
53
- const affectedPackages = /* @__PURE__ */ new Set();
54
- for (const pkgJsonPath of packageJsonPaths) {
55
- try {
56
- const json = JSON.parse(await readFile(pkgJsonPath, "utf8"));
57
- const deps = {
58
- ...json.dependencies,
59
- ...json.devDependencies,
60
- ...json.peerDependencies
61
- };
62
- for (const dep of changedDeps) {
63
- if (deps[dep]) {
64
- affectedPackages.add(json.name);
65
- break;
66
- }
67
- }
68
- } catch {
69
- }
70
- }
71
- return affectedPackages;
36
+ if (changedDeps.length === 0) return /* @__PURE__ */ new Set();
37
+ const packageJsonPaths = globSync(packageJsonGlob);
38
+ const affectedPackages = /* @__PURE__ */ new Set();
39
+ for (const pkgJsonPath of packageJsonPaths) try {
40
+ const json = JSON.parse(await readFile(pkgJsonPath, "utf8"));
41
+ const deps = {
42
+ ...json.dependencies,
43
+ ...json.devDependencies,
44
+ ...json.peerDependencies
45
+ };
46
+ for (const dep of changedDeps) if (deps[dep]) {
47
+ affectedPackages.add(json.name);
48
+ break;
49
+ }
50
+ } catch {}
51
+ return affectedPackages;
72
52
  }
73
53
  async function handleChangesetFile(fileName) {
74
- if (!env["SKIP_COMMIT"]) {
75
- await simpleGit().add(fileName);
76
- await simpleGit().commit(`chore: add ${fileName}`);
77
- await simpleGit().push();
78
- }
54
+ if (!env["SKIP_COMMIT"]) {
55
+ await simpleGit().add(fileName);
56
+ await simpleGit().commit(`chore: add ${fileName}`);
57
+ await simpleGit().push();
58
+ }
79
59
  }
80
- export {
81
- findAffectedPackages,
82
- findChangedDependenciesFromGit,
83
- getBumpsFromGit,
84
- handleChangesetFile,
85
- loadCatalogFromGit
86
- };
60
+ export { findAffectedPackages, findChangedDependenciesFromGit, getBumpsFromGit, handleChangesetFile };
@@ -1,48 +1,28 @@
1
- import { simpleGit } from "simple-git";
2
1
  import { createChangeset } from "./createChangeset.js";
3
- const {
4
- findChangedDependenciesFromGit,
5
- findAffectedPackages,
6
- handleChangesetFile
7
- } = await import("./git-utils.js");
2
+ import { simpleGit } from "simple-git";
3
+ var { findChangedDependenciesFromGit, findAffectedPackages, handleChangesetFile } = await import("./git-utils.js");
8
4
  async function handleCatalogChanges(diffFiles) {
9
- const workspaceFiles = diffFiles.filter(
10
- (file) => file.includes("pnpm-workspace.yaml")
11
- );
12
- if (workspaceFiles.length === 0) {
13
- return;
14
- }
15
- console.log(
16
- "šŸ” Detected pnpm workspace changes, checking for catalog updates..."
17
- );
18
- console.log("šŸ” Comparing catalogs: HEAD~1 -> HEAD");
19
- const changedDeps = await findChangedDependenciesFromGit(
20
- "HEAD~1",
21
- "HEAD",
22
- "pnpm-workspace.yaml"
23
- );
24
- if (changedDeps.size === 0) {
25
- console.log("āœ… No catalog dependency changes.", { changedDeps });
26
- return;
27
- }
28
- console.log("šŸ“¦ Changed dependencies:", changedDeps);
29
- const affectedPackages = await findAffectedPackages([...changedDeps.keys()]);
30
- if (affectedPackages.size === 0) {
31
- console.log("šŸ“¦ No packages affected by catalog changes.");
32
- return;
33
- }
34
- console.log("\nšŸ“ Affected packages:");
35
- for (const pkg of affectedPackages) {
36
- console.log(` - ${pkg}`);
37
- }
38
- console.log("\nāœļø Creating changesets...");
39
- const packageNames = [...affectedPackages.keys()];
40
- const shortHash = (await simpleGit().revparse(["--short", "HEAD"])).trim();
41
- const fileName = `.changeset/renovate-${shortHash}.md`;
42
- await createChangeset(fileName, changedDeps, packageNames);
43
- await handleChangesetFile(fileName);
44
- console.log("\nāœ… Done creating changesets.");
5
+ if (diffFiles.filter((file) => file.includes("pnpm-workspace.yaml")).length === 0) return;
6
+ console.log("šŸ” Detected pnpm workspace changes, checking for catalog updates...");
7
+ console.log("šŸ” Comparing catalogs: HEAD~1 -> HEAD");
8
+ const changedDeps = await findChangedDependenciesFromGit("HEAD~1", "HEAD", "pnpm-workspace.yaml");
9
+ if (changedDeps.size === 0) {
10
+ console.log("āœ… No catalog dependency changes.", { changedDeps });
11
+ return;
12
+ }
13
+ console.log("šŸ“¦ Changed dependencies:", changedDeps);
14
+ const affectedPackages = await findAffectedPackages([...changedDeps.keys()]);
15
+ if (affectedPackages.size === 0) {
16
+ console.log("šŸ“¦ No packages affected by catalog changes.");
17
+ return;
18
+ }
19
+ console.log("\nšŸ“ Affected packages:");
20
+ for (const pkg of affectedPackages) console.log(` - ${pkg}`);
21
+ console.log("\nāœļø Creating changesets...");
22
+ const packageNames = [...affectedPackages.keys()];
23
+ const fileName = `.changeset/renovate-${(await simpleGit().revparse(["--short", "HEAD"])).trim()}.md`;
24
+ await createChangeset(fileName, changedDeps, packageNames);
25
+ await handleChangesetFile(fileName);
26
+ console.log("\nāœ… Done creating changesets.");
45
27
  }
46
- export {
47
- handleCatalogChanges
48
- };
28
+ export { handleCatalogChanges };
@@ -1,24 +1,20 @@
1
- import { simpleGit } from "simple-git";
2
1
  import { createChangeset } from "./createChangeset.js";
3
2
  import { getBumpsFromGit, handleChangesetFile } from "./git-utils.js";
4
3
  import { getPackagesNames } from "./utils.js";
4
+ import { simpleGit } from "simple-git";
5
5
  async function handlePackageChanges(diffFiles) {
6
- const files = diffFiles.filter((file) => file.includes("package.json"));
7
- if (files.length === 0) {
8
- console.log("No package.json changes to published packages, skipping");
9
- return;
10
- }
11
- const packageNames = await getPackagesNames(files);
12
- if (packageNames.length === 0) {
13
- console.log("No packages modified, skipping");
14
- return;
15
- }
16
- const shortHash = (await simpleGit().revparse(["--short", "HEAD"])).trim();
17
- const fileName = `.changeset/renovate-${shortHash}.md`;
18
- const packageBumps = await getBumpsFromGit(files);
19
- await createChangeset(fileName, packageBumps, packageNames);
20
- await handleChangesetFile(fileName);
6
+ const files = diffFiles.filter((file) => file.includes("package.json"));
7
+ if (files.length === 0) {
8
+ console.log("No package.json changes to published packages, skipping");
9
+ return;
10
+ }
11
+ const packageNames = await getPackagesNames(files);
12
+ if (packageNames.length === 0) {
13
+ console.log("No packages modified, skipping");
14
+ return;
15
+ }
16
+ const fileName = `.changeset/renovate-${(await simpleGit().revparse(["--short", "HEAD"])).trim()}.md`;
17
+ await createChangeset(fileName, await getBumpsFromGit(files), packageNames);
18
+ await handleChangesetFile(fileName);
21
19
  }
22
- export {
23
- handlePackageChanges
24
- };
20
+ export { handlePackageChanges };
package/dist/utils.js CHANGED
@@ -1,38 +1,25 @@
1
1
  import { readFile } from "node:fs/promises";
2
2
  import fg from "fast-glob";
3
- import "js-yaml";
4
- const { globSync } = fg;
3
+ import { load } from "js-yaml";
4
+ var { globSync } = fg;
5
5
  function shouldIgnorePackage(packageName, ignoredPackages) {
6
- return ignoredPackages.some((ignoredPackage) => {
7
- if (ignoredPackage.endsWith("*")) {
8
- return packageName.startsWith(ignoredPackage.slice(0, -1));
9
- }
10
- return packageName === ignoredPackage;
11
- });
6
+ return ignoredPackages.some((ignoredPackage) => {
7
+ if (ignoredPackage.endsWith("*")) return packageName.startsWith(ignoredPackage.slice(0, -1));
8
+ return packageName === ignoredPackage;
9
+ });
12
10
  }
13
11
  async function getChangesetIgnoredPackages() {
14
- const changesetConfig = JSON.parse(
15
- await readFile(".changeset/config.json", "utf8")
16
- );
17
- return changesetConfig.ignore ?? [];
12
+ return JSON.parse(await readFile(".changeset/config.json", "utf8")).ignore ?? [];
18
13
  }
19
14
  async function getPackagesNames(files) {
20
- const ignoredPackages = await getChangesetIgnoredPackages();
21
- const packages = [];
22
- const promises = files.map(async (file) => {
23
- const data = JSON.parse(await readFile(file, "utf8"));
24
- if (shouldIgnorePackage(data.name, ignoredPackages)) {
25
- return;
26
- }
27
- if (!data.workspaces && data.version) {
28
- packages.push(data.name);
29
- }
30
- });
31
- await Promise.all(promises);
32
- return packages;
15
+ const ignoredPackages = await getChangesetIgnoredPackages();
16
+ const packages = [];
17
+ const promises = files.map(async (file) => {
18
+ const data = JSON.parse(await readFile(file, "utf8"));
19
+ if (shouldIgnorePackage(data.name, ignoredPackages)) return;
20
+ if (!data.workspaces && data.version) packages.push(data.name);
21
+ });
22
+ await Promise.all(promises);
23
+ return packages;
33
24
  }
34
- export {
35
- getChangesetIgnoredPackages,
36
- getPackagesNames,
37
- shouldIgnorePackage
38
- };
25
+ export { getPackagesNames };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scaleway/changesets-renovate",
3
- "version": "2.2.3",
3
+ "version": "2.2.4",
4
4
  "description": "Automatically create changesets for Renovate and pnpm catalogs",
5
5
  "type": "module",
6
6
  "module": "./dist/cli.js",
@@ -51,7 +51,6 @@
51
51
  "type:generate:go": "tsgo --declaration -p tsconfig.build.json",
52
52
  "build": "vite build --config vite.config.ts && pnpm run type:generate",
53
53
  "build:profile": "npx vite-bundle-visualizer -c vite.config.ts",
54
- "lint": "eslint --report-unused-disable-directives --cache --cache-strategy content --ext ts,tsx .",
55
54
  "test:unit": "vitest --run --config vite.config.ts",
56
55
  "test:unit:coverage": "pnpm test:unit --coverage"
57
56
  }
package/LICENSE.md DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Scaleway
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.