Skip to content

Commit a7c406d

Browse files
author
Illia Obukhau
authored
ci(dependabot): add script to update dependabot config (#160)
2 parents 24f0ef5 + a4290b1 commit a7c406d

File tree

5 files changed

+99
-0
lines changed

5 files changed

+99
-0
lines changed

automation/e2e/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "@mendix/web-widgets-e2e",
3+
"version": "0.1.0",
4+
"private": true,
5+
"license": "Apache-2.0",
6+
"copyright": "© Mendix Technology BV 2022. All rights reserved.",
7+
"type": "module",
8+
"engines": {
9+
"node": ">=18"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "https://github.com/mendix/web-widgets.git"
14+
}
15+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { writeFileSync } from "node:fs";
2+
import { execSync } from "node:child_process";
3+
import path from "node:path";
4+
import yaml from "yaml";
5+
6+
// Dependabot config uses posix path, so normalize.
7+
const normalizePath = (pkgs, root) =>
8+
pkgs.map(p => {
9+
const pkgPath = path.relative(root, p.path);
10+
p.path = path.posix.resolve("/", pkgPath.split(path.sep).join(path.posix.sep));
11+
return p;
12+
});
13+
14+
function main() {
15+
const root = execSync("git rev-parse --show-toplevel", { encoding: "utf-8" }).trim();
16+
const listing = execSync("pnpm -r ls --json", {
17+
encoding: "utf-8"
18+
}).trim();
19+
20+
const packages = normalizePath(JSON.parse(listing !== "" ? listing : "[]"), root);
21+
22+
const dependabotConfig = {
23+
version: 2,
24+
updates: [
25+
{
26+
"package-ecosystem": "github-actions",
27+
directory: "/",
28+
schedule: {
29+
interval: "weekly"
30+
}
31+
},
32+
...packages.map(pkg => ({
33+
"package-ecosystem": "npm",
34+
directory: pkg.path,
35+
schedule: { interval: "weekly" },
36+
ignore: [
37+
// Disable updates for typescript as we will update it manually.
38+
{ "dependency-name": "typescript" },
39+
// Disable major updates for all dependencies
40+
{ "dependency-name": "*", "update-types": ["version-update:semver-major"] }
41+
]
42+
}))
43+
]
44+
};
45+
46+
writeFileSync(path.resolve(root, ".github/dependabot.yml"), yaml.stringify(dependabotConfig), {
47+
encoding: "utf-8"
48+
});
49+
}
50+
51+
main();

automation/scripts/package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "@mendix/web-widgets-scripts",
3+
"version": "0.1.0",
4+
"private": true,
5+
"license": "Apache-2.0",
6+
"copyright": "© Mendix Technology BV 2022. All rights reserved.",
7+
"type": "module",
8+
"engines": {
9+
"node": ">=18"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "https://github.com/mendix/web-widgets.git"
14+
},
15+
"scripts": {
16+
"update-dependabot-config": "node generate-dependabot-config.mjs"
17+
},
18+
"dependencies": {
19+
"yaml": "^2.1.3"
20+
}
21+
}

pnpm-lock.yaml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
packages:
22
- "packages/*/*"
3+
- "automation/*"
34
- "!packages/customWidgets/*"
45
- "!packages/tools/custom-widgets-utils-internal"

0 commit comments

Comments
 (0)