@scaleway/changesets-renovate 2.0.2 → 2.0.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.
- package/dist/index.d.ts +1 -3
- package/dist/index.js +41 -32
- package/package.json +23 -2
- package/.npmignore +0 -4
- package/CHANGELOG.md +0 -131
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import fs from
|
|
3
|
-
import { simpleGit } from
|
|
4
|
-
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import { simpleGit } from "simple-git";
|
|
4
|
+
console.debug("simpleGit", simpleGit);
|
|
5
5
|
async function getChangesetIgnoredPackages() {
|
|
6
|
-
const changesetConfig = JSON.parse(
|
|
6
|
+
const changesetConfig = JSON.parse(
|
|
7
|
+
await fs.readFile(".changeset/config.json", "utf8")
|
|
8
|
+
);
|
|
7
9
|
return changesetConfig.ignore ?? [];
|
|
8
10
|
}
|
|
9
11
|
function shouldIgnorePackage(packageName, ignoredPackages) {
|
|
10
|
-
return ignoredPackages.some(ignoredPackage => {
|
|
11
|
-
if (ignoredPackage.endsWith(
|
|
12
|
+
return ignoredPackages.some((ignoredPackage) => {
|
|
13
|
+
if (ignoredPackage.endsWith("*")) {
|
|
12
14
|
return packageName.startsWith(ignoredPackage.slice(0, -1));
|
|
13
15
|
}
|
|
14
16
|
return packageName === ignoredPackage;
|
|
@@ -17,8 +19,8 @@ function shouldIgnorePackage(packageName, ignoredPackages) {
|
|
|
17
19
|
async function getPackagesNames(files) {
|
|
18
20
|
const ignoredPackages = await getChangesetIgnoredPackages();
|
|
19
21
|
const packages = [];
|
|
20
|
-
const promises = files.map(async file => {
|
|
21
|
-
const data = JSON.parse(await fs.readFile(file,
|
|
22
|
+
const promises = files.map(async (file) => {
|
|
23
|
+
const data = JSON.parse(await fs.readFile(file, "utf8"));
|
|
22
24
|
if (shouldIgnorePackage(data.name, ignoredPackages)) {
|
|
23
25
|
return;
|
|
24
26
|
}
|
|
@@ -30,23 +32,29 @@ async function getPackagesNames(files) {
|
|
|
30
32
|
return packages;
|
|
31
33
|
}
|
|
32
34
|
async function createChangeset(fileName, packageBumps, packages) {
|
|
33
|
-
let message =
|
|
35
|
+
let message = "";
|
|
34
36
|
for (const [pkg, bump] of packageBumps) {
|
|
35
|
-
message += `Updated dependency \`${pkg}\` to \`${bump}
|
|
37
|
+
message += `Updated dependency \`${pkg}\` to \`${bump}\`.
|
|
38
|
+
`;
|
|
36
39
|
}
|
|
37
|
-
const pkgs = packages.map(pkg => `'${pkg}': patch`).join(
|
|
38
|
-
const body =
|
|
40
|
+
const pkgs = packages.map((pkg) => `'${pkg}': patch`).join("\n");
|
|
41
|
+
const body = `---
|
|
42
|
+
${pkgs}
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
${message.trim()}
|
|
46
|
+
`;
|
|
39
47
|
await fs.writeFile(fileName, body);
|
|
40
48
|
}
|
|
41
49
|
async function getBumps(files) {
|
|
42
|
-
const bumps = new Map();
|
|
43
|
-
const promises = files.map(async file => {
|
|
50
|
+
const bumps = /* @__PURE__ */ new Map();
|
|
51
|
+
const promises = files.map(async (file) => {
|
|
44
52
|
const changes = await simpleGit().show([file]);
|
|
45
|
-
for (const change of changes.split(
|
|
46
|
-
if (change.startsWith(
|
|
53
|
+
for (const change of changes.split("\n")) {
|
|
54
|
+
if (change.startsWith("+ ")) {
|
|
47
55
|
const match = change.match(/"(.*?)"/g);
|
|
48
56
|
if (match?.[0] && match[1]) {
|
|
49
|
-
bumps.set(match[0].replace(/"/g,
|
|
57
|
+
bumps.set(match[0].replace(/"/g, ""), match[1].replace(/"/g, ""));
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
60
|
}
|
|
@@ -56,38 +64,39 @@ async function getBumps(files) {
|
|
|
56
64
|
}
|
|
57
65
|
async function run() {
|
|
58
66
|
const branch = await simpleGit().branch();
|
|
59
|
-
console.log(
|
|
60
|
-
if (!branch.current.startsWith(
|
|
61
|
-
console.log(
|
|
67
|
+
console.log("Detected branch:", branch);
|
|
68
|
+
if (!branch.current.startsWith("renovate/")) {
|
|
69
|
+
console.log("Not a renovate branch, skipping");
|
|
62
70
|
return;
|
|
63
71
|
}
|
|
64
|
-
const diffOutput = await simpleGit().diffSummary([
|
|
65
|
-
const diffFiles = diffOutput.files.map(file => file.file);
|
|
66
|
-
console.log(
|
|
67
|
-
if (diffFiles.find(f => f.startsWith(
|
|
68
|
-
console.log(
|
|
72
|
+
const diffOutput = await simpleGit().diffSummary(["--name-only", "HEAD~1"]);
|
|
73
|
+
const diffFiles = diffOutput.files.map((file) => file.file);
|
|
74
|
+
console.log("Found changed files:", diffFiles);
|
|
75
|
+
if (diffFiles.find((f) => f.startsWith(".changeset"))) {
|
|
76
|
+
console.log("Changeset already exists, skipping");
|
|
69
77
|
return;
|
|
70
78
|
}
|
|
71
|
-
const files = diffFiles.filter(file => file.includes(
|
|
79
|
+
const files = diffFiles.filter((file) => file.includes("package.json"));
|
|
72
80
|
if (!files.length) {
|
|
73
|
-
console.log(
|
|
81
|
+
console.log("No package.json changes to published packages, skipping");
|
|
74
82
|
return;
|
|
75
83
|
}
|
|
76
84
|
const packageNames = await getPackagesNames(files);
|
|
77
85
|
if (packageNames.length === 0) {
|
|
78
|
-
console.log(
|
|
86
|
+
console.log("No packages modified, skipping");
|
|
79
87
|
return;
|
|
80
88
|
}
|
|
81
|
-
const shortHash = (await simpleGit().revparse([
|
|
89
|
+
const shortHash = (await simpleGit().revparse(["--short", "HEAD"])).trim();
|
|
82
90
|
const fileName = `.changeset/renovate-${shortHash}.md`;
|
|
83
91
|
const packageBumps = await getBumps(files);
|
|
84
92
|
await createChangeset(fileName, packageBumps, packageNames);
|
|
85
|
-
if (!process.env[
|
|
93
|
+
if (!process.env["SKIP_COMMIT"]) {
|
|
86
94
|
await simpleGit().add(fileName);
|
|
87
95
|
await simpleGit().commit(`chore: add changeset renovate-${shortHash}`);
|
|
88
96
|
await simpleGit().push();
|
|
89
97
|
}
|
|
90
98
|
}
|
|
91
99
|
run().catch(console.error);
|
|
92
|
-
|
|
93
|
-
|
|
100
|
+
export {
|
|
101
|
+
run
|
|
102
|
+
};
|
package/package.json
CHANGED
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleway/changesets-renovate",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "Automatically create changesets for Renovate",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
6
18
|
"engines": {
|
|
7
19
|
"node": ">=20.x"
|
|
8
20
|
},
|
|
9
21
|
"bin": {
|
|
10
22
|
"changesets-renovate": "dist/index.js"
|
|
11
23
|
},
|
|
12
|
-
"sideEffects": false,
|
|
13
24
|
"publishConfig": {
|
|
14
25
|
"access": "public"
|
|
15
26
|
},
|
|
@@ -26,5 +37,15 @@
|
|
|
26
37
|
],
|
|
27
38
|
"dependencies": {
|
|
28
39
|
"simple-git": "3.24.0"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"prebuild": "shx rm -rf dist",
|
|
43
|
+
"typecheck": "tsc --noEmit",
|
|
44
|
+
"type:generate": "tsc --declaration -p tsconfig.build.json",
|
|
45
|
+
"build": "vite build --config vite.config.ts && pnpm run type:generate",
|
|
46
|
+
"build:profile": "npx vite-bundle-visualizer -c vite.config.ts",
|
|
47
|
+
"lint": "eslint --report-unused-disable-directives --cache --cache-strategy content --ext ts,tsx .",
|
|
48
|
+
"test:unit": "vitest --run --config vite.config.ts",
|
|
49
|
+
"test:unit:coverage": "pnpm test:unit --coverage"
|
|
29
50
|
}
|
|
30
51
|
}
|
package/.npmignore
DELETED
package/CHANGELOG.md
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
## 2.0.2
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- [#1907](https://github.com/scaleway/scaleway-lib/pull/1907) [`6a76c20`](https://github.com/scaleway/scaleway-lib/commit/6a76c20acd8b7ed11e8223d9f3f5899cdffcee75) Thanks [@renovate](https://github.com/apps/renovate)! - Updated dependency `simple-git` to `3.24.0`.
|
|
8
|
-
|
|
9
|
-
## 2.0.1
|
|
10
|
-
|
|
11
|
-
### Patch Changes
|
|
12
|
-
|
|
13
|
-
- [#1890](https://github.com/scaleway/scaleway-lib/pull/1890) [`620ff91`](https://github.com/scaleway/scaleway-lib/commit/620ff91fab5e5c1b5ca1509c7d2ed9080b0fb416) Thanks [@renovate](https://github.com/apps/renovate)! - Updated dependency `simple-git` to `3.23.0`.
|
|
14
|
-
|
|
15
|
-
## 2.0.0
|
|
16
|
-
|
|
17
|
-
### Major Changes
|
|
18
|
-
|
|
19
|
-
- [#1837](https://github.com/scaleway/scaleway-lib/pull/1837) [`5404963`](https://github.com/scaleway/scaleway-lib/commit/5404963ddd01fafe6ed9753d8324fb19849065ca) Thanks [@philibea](https://github.com/philibea)! - upgrade node version from 14 to 20
|
|
20
|
-
|
|
21
|
-
## 1.4.1
|
|
22
|
-
|
|
23
|
-
### Patch Changes
|
|
24
|
-
|
|
25
|
-
- [#1761](https://github.com/scaleway/scaleway-lib/pull/1761) [`f378e4c`](https://github.com/scaleway/scaleway-lib/commit/f378e4c915eab3cf53bfc1885845a802c83eceb3) Thanks [@renovate](https://github.com/apps/renovate)! - Updated dependency `simple-git` to `3.22.0`.
|
|
26
|
-
|
|
27
|
-
## 1.4.0
|
|
28
|
-
|
|
29
|
-
### Minor Changes
|
|
30
|
-
|
|
31
|
-
- [#1705](https://github.com/scaleway/scaleway-lib/pull/1705) [`d3e1246`](https://github.com/scaleway/scaleway-lib/commit/d3e1246f70229cf9e3a7a5d464d921fe5e379af0) Thanks [@wrighbr](https://github.com/wrighbr)! - add the ability to skip commit
|
|
32
|
-
|
|
33
|
-
## 1.3.2
|
|
34
|
-
|
|
35
|
-
### Patch Changes
|
|
36
|
-
|
|
37
|
-
- [#1687](https://github.com/scaleway/scaleway-lib/pull/1687) [`d47550d`](https://github.com/scaleway/scaleway-lib/commit/d47550d1a306db83e665a7195dee7df6d09e866a) Thanks [@renovate](https://github.com/apps/renovate)! - Updated dependency `simple-git` to `3.21.0`.
|
|
38
|
-
|
|
39
|
-
## 1.3.1
|
|
40
|
-
|
|
41
|
-
### Patch Changes
|
|
42
|
-
|
|
43
|
-
- [#1545](https://github.com/scaleway/scaleway-lib/pull/1545) [`1d2867b`](https://github.com/scaleway/scaleway-lib/commit/1d2867b19980b841c888913015abfa421c7d4ec6) Thanks [@renovate](https://github.com/apps/renovate)! - Updated dependency `simple-git` to `3.20.0`.
|
|
44
|
-
|
|
45
|
-
## 1.3.0
|
|
46
|
-
|
|
47
|
-
### Minor Changes
|
|
48
|
-
|
|
49
|
-
- [#1531](https://github.com/scaleway/scaleway-lib/pull/1531) [`5f1fc75`](https://github.com/scaleway/scaleway-lib/commit/5f1fc750d93333a4ae3f48abcd96dd3af21fd886) Thanks [@QuiiBz](https://github.com/QuiiBz)! - Ignore packages that are ignored in the changeset config
|
|
50
|
-
|
|
51
|
-
## 1.2.7
|
|
52
|
-
|
|
53
|
-
### Patch Changes
|
|
54
|
-
|
|
55
|
-
- [#1380](https://github.com/scaleway/scaleway-lib/pull/1380) [`c0e0d51`](https://github.com/scaleway/scaleway-lib/commit/c0e0d5104680149f9b38ae509b17d14a66c4d733) Thanks [@QuiiBz](https://github.com/QuiiBz)! - Add `exports` field & fix package lint errors
|
|
56
|
-
|
|
57
|
-
## 1.2.6
|
|
58
|
-
|
|
59
|
-
### Patch Changes
|
|
60
|
-
|
|
61
|
-
- [#1346](https://github.com/scaleway/scaleway-lib/pull/1346) [`07a728a`](https://github.com/scaleway/scaleway-lib/commit/07a728a28e5fa5f43f1d1344bb6fd5bd858da3b1) Thanks [@renovate](https://github.com/apps/renovate)! - Updated dependency `simple-git` to `3.19.1`.
|
|
62
|
-
|
|
63
|
-
## 1.2.5
|
|
64
|
-
|
|
65
|
-
### Patch Changes
|
|
66
|
-
|
|
67
|
-
- [#1325](https://github.com/scaleway/scaleway-lib/pull/1325) [`ef2fb63`](https://github.com/scaleway/scaleway-lib/commit/ef2fb636abd6f15e6dd9d28809f141036fafa50a) Thanks [@renovate](https://github.com/apps/renovate)! - Updated dependency `simple-git` to `3.19.0`.
|
|
68
|
-
Updated dependency `eslint` to `8.40.0`.
|
|
69
|
-
|
|
70
|
-
## 1.2.4
|
|
71
|
-
|
|
72
|
-
### Patch Changes
|
|
73
|
-
|
|
74
|
-
- [#1309](https://github.com/scaleway/scaleway-lib/pull/1309) [`429f630`](https://github.com/scaleway/scaleway-lib/commit/429f630831de30fc14cfe3216620f32b464a78bd) Thanks [@QuiiBz](https://github.com/QuiiBz)! - Do not generate changeset for `package.json` without `version` field
|
|
75
|
-
|
|
76
|
-
## 1.2.3
|
|
77
|
-
|
|
78
|
-
### Patch Changes
|
|
79
|
-
|
|
80
|
-
- [#1295](https://github.com/scaleway/scaleway-lib/pull/1295) [`d3ef5a4`](https://github.com/scaleway/scaleway-lib/commit/d3ef5a460fa496d23d3e376128e88042d52baed8) Thanks [@chambo-e](https://github.com/chambo-e)! - Update dependencies
|
|
81
|
-
|
|
82
|
-
## 1.2.2
|
|
83
|
-
|
|
84
|
-
### Patch Changes
|
|
85
|
-
|
|
86
|
-
- [#1240](https://github.com/scaleway/scaleway-lib/pull/1240) [`51e15d2`](https://github.com/scaleway/scaleway-lib/commit/51e15d2ba75172b90736e48a827744490fdf9a51) Thanks [@QuiiBz](https://github.com/QuiiBz)! - Commit message respects commitlint
|
|
87
|
-
|
|
88
|
-
## 1.2.1
|
|
89
|
-
|
|
90
|
-
### Patch Changes
|
|
91
|
-
|
|
92
|
-
- [#1236](https://github.com/scaleway/scaleway-lib/pull/1236) [`3d05f84`](https://github.com/scaleway/scaleway-lib/commit/3d05f84b283859ef7ff336fc02e59a9ea1959d04) Thanks [@QuiiBz](https://github.com/QuiiBz)! - Create a new commit instead of amend + force push
|
|
93
|
-
|
|
94
|
-
## 1.2.0
|
|
95
|
-
|
|
96
|
-
### Minor Changes
|
|
97
|
-
|
|
98
|
-
- [#1232](https://github.com/scaleway/scaleway-lib/pull/1232) [`00df173`](https://github.com/scaleway/scaleway-lib/commit/00df173821b759c5fd34b582142bafa8b86d276d) Thanks [@QuiiBz](https://github.com/QuiiBz)! - Ignore changes in workspace's root package.json
|
|
99
|
-
|
|
100
|
-
## 1.1.4
|
|
101
|
-
|
|
102
|
-
### Patch Changes
|
|
103
|
-
|
|
104
|
-
- [#1230](https://github.com/scaleway/scaleway-lib/pull/1230) [`32ffb7c`](https://github.com/scaleway/scaleway-lib/commit/32ffb7c1dad41251a881f5eb58ca29d180c8a5d5) Thanks [@QuiiBz](https://github.com/QuiiBz)! - Fix commit command
|
|
105
|
-
|
|
106
|
-
## 1.1.3
|
|
107
|
-
|
|
108
|
-
### Patch Changes
|
|
109
|
-
|
|
110
|
-
- [#1228](https://github.com/scaleway/scaleway-lib/pull/1228) [`2324e6b`](https://github.com/scaleway/scaleway-lib/commit/2324e6b37feec7793567692336d24fcec5064eab) Thanks [@QuiiBz](https://github.com/QuiiBz)! - Fix current branch check
|
|
111
|
-
|
|
112
|
-
## 1.1.2
|
|
113
|
-
|
|
114
|
-
### Patch Changes
|
|
115
|
-
|
|
116
|
-
- [#1224](https://github.com/scaleway/scaleway-lib/pull/1224) [`8361723`](https://github.com/scaleway/scaleway-lib/commit/8361723984c6a7c9c586570ce573db8dc73d7366) Thanks [@QuiiBz](https://github.com/QuiiBz)! - Add more logging
|
|
117
|
-
|
|
118
|
-
All notable changes to this project will be documented in this file.
|
|
119
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
120
|
-
|
|
121
|
-
## [1.1.1](https://github.com/scaleway/scaleway-lib/compare/@scaleway/changesets-renovate@1.1.0...@scaleway/changesets-renovate@1.1.1) (2023-03-09)
|
|
122
|
-
|
|
123
|
-
### :bug: Bug Fixes
|
|
124
|
-
|
|
125
|
-
- **deps:** pin dependency simple-git to 3.17.0 ([#1217](https://github.com/scaleway/scaleway-lib/issues/1217)) ([0dab5cf](https://github.com/scaleway/scaleway-lib/commit/0dab5cfd184991906c246c44fba50c49b18cde7b))
|
|
126
|
-
|
|
127
|
-
## 1.1.0 (2023-03-09)
|
|
128
|
-
|
|
129
|
-
### :gear: Features
|
|
130
|
-
|
|
131
|
-
- introduce new @scaleway/changesets-renovate package ([#1216](https://github.com/scaleway/scaleway-lib/issues/1216)) ([db88cd0](https://github.com/scaleway/scaleway-lib/commit/db88cd04970fa234a1fb83b5f6f18f2dbbb3c635))
|