@pob/root 19.8.0 → 20.0.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.
- package/CHANGELOG.md +31 -0
- package/bin/pob-root-postinstall.js +1 -1
- package/bin/pob-version.js +3 -0
- package/bin/postinstall/install-github-workflows.js +3 -4
- package/bin/postinstall/install-husky.js +4 -5
- package/bin/postinstall/update-yarn.js +1 -1
- package/bin/repository-check-dirty.js +15 -1
- package/createLintStagedConfig.js +92 -4
- package/lib/assert-yarn-berry.js +7 -0
- package/lib/which-pm-runs.js +13 -0
- package/package.json +9 -13
- package/bin/yarn-version.js +0 -3
- package/createLintStagedConfig.cjs +0 -126
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,37 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [20.0.1](https://github.com/christophehurpeau/pob/compare/@pob/root@20.0.0...@pob/root@20.0.1) (2025-12-06)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* properly import pob/version in pob/root
|
|
11
|
+
|
|
12
|
+
Version bump for dependency: @pob/pretty-pkg
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## [20.0.0](https://github.com/christophehurpeau/pob/compare/@pob/root@19.8.0...@pob/root@20.0.0) (2025-11-24)
|
|
16
|
+
|
|
17
|
+
### ⚠ BREAKING CHANGES
|
|
18
|
+
|
|
19
|
+
* migrate createLintStagedConfig to ES module and remove CommonJS version
|
|
20
|
+
|
|
21
|
+
### Features
|
|
22
|
+
|
|
23
|
+
* implement assertYarnBerry function to enforce Yarn v2 or later
|
|
24
|
+
* implement repository check for uncommitted changes in @pob//root directly
|
|
25
|
+
* migrate createLintStagedConfig to ES module and remove CommonJS version
|
|
26
|
+
* update yarn to 4.12.0
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* **deps:** update lint-staged to version 16.2.7
|
|
31
|
+
* fix assert-yarn-berry.js path
|
|
32
|
+
|
|
33
|
+
Version bump for dependency: @pob/pretty-pkg
|
|
34
|
+
Version bump for dependency: yarn-version
|
|
35
|
+
|
|
36
|
+
|
|
6
37
|
## [19.8.0](https://github.com/christophehurpeau/pob/compare/@pob/root@19.7.1...@pob/root@19.8.0) (2025-11-18)
|
|
7
38
|
|
|
8
39
|
Version bump for dependency: yarn-version
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
|
-
import
|
|
4
|
+
import { assertYarnBerry } from "../../lib/assert-yarn-berry.js";
|
|
5
5
|
import { getPackageManagerCommands } from "./packageManagerHelpers.js";
|
|
6
6
|
|
|
7
7
|
const ensureWorkflowUninstalled = (workflowName) => {
|
|
@@ -37,10 +37,9 @@ const installWorkflow = (
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
export default function installGithubWorkflows({ pkg, pm }) {
|
|
40
|
-
|
|
41
|
-
const isYarnBerry = pm.name === "yarn" && yarnMajorVersion >= 2;
|
|
40
|
+
assertYarnBerry(pm);
|
|
42
41
|
|
|
43
|
-
const pmCommands = getPackageManagerCommands(pm,
|
|
42
|
+
const pmCommands = getPackageManagerCommands(pm, true);
|
|
44
43
|
|
|
45
44
|
if (fs.existsSync(".github")) {
|
|
46
45
|
installWorkflow("push-renovate-pob_root", pmCommands);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import husky from "husky";
|
|
4
|
-
import
|
|
4
|
+
import { assertYarnBerry } from "../../lib/assert-yarn-berry.js";
|
|
5
5
|
import { getPackageManagerCommands } from "./packageManagerHelpers.js";
|
|
6
6
|
|
|
7
7
|
const ensureLegacyHuskyConfigDeleted = () => {
|
|
@@ -46,9 +46,8 @@ const readYarnConfigFile = () => {
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
export default function installHusky({ pkg, pm }) {
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
const yarnConfig = isYarnBerry && readYarnConfigFile();
|
|
49
|
+
assertYarnBerry(pm);
|
|
50
|
+
const yarnConfig = readYarnConfigFile();
|
|
52
51
|
const isYarnPnp = yarnConfig
|
|
53
52
|
? !yarnConfig.includes("nodeLinker: node-modules") &&
|
|
54
53
|
!yarnConfig.includes("nodeLinker: pnpm")
|
|
@@ -77,7 +76,7 @@ export default function installHusky({ pkg, pm }) {
|
|
|
77
76
|
installOnDiffCommand,
|
|
78
77
|
beforeDiffCommand = "",
|
|
79
78
|
afterDiffCommand = "",
|
|
80
|
-
} = getPackageManagerCommands(pm,
|
|
79
|
+
} = getPackageManagerCommands(pm, true);
|
|
81
80
|
|
|
82
81
|
writeHook("commit-msg", `${pmExec} pob-check-commit-msg $1`);
|
|
83
82
|
writeHook(
|
|
@@ -13,7 +13,7 @@ const isCorepackInstalled = () => {
|
|
|
13
13
|
export default function updateYarn({ pkg, pm }) {
|
|
14
14
|
if (pm.name !== "yarn" || !pm.version) return;
|
|
15
15
|
|
|
16
|
-
if (semver.lt(pm.version, "4.
|
|
16
|
+
if (semver.lt(pm.version, "4.12.0")) {
|
|
17
17
|
// Upgrade from yarn 1
|
|
18
18
|
if (semver.lt(pm.version, "2.0.0")) {
|
|
19
19
|
console.log("-- Install yarn berry --");
|
|
@@ -1,3 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import "
|
|
3
|
+
import { execSync } from "node:child_process";
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
const stdout = execSync("git status --porcelain", { encoding: "utf8" });
|
|
7
|
+
if (stdout) {
|
|
8
|
+
console.log(
|
|
9
|
+
"Repository has uncommitted changes, please commit or remove these files:\n",
|
|
10
|
+
);
|
|
11
|
+
console.log(stdout);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.error(error.message);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
@@ -1,6 +1,94 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { assertYarnBerry } from "./lib/assert-yarn-berry.js";
|
|
4
|
+
import { whichPmRuns } from "./lib/which-pm-runs.js";
|
|
2
5
|
|
|
3
|
-
const
|
|
6
|
+
const pm = whichPmRuns();
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
assertYarnBerry(pm);
|
|
9
|
+
|
|
10
|
+
const { lockfile, installAndDedupe } = (() => {
|
|
11
|
+
if (pm.name === "yarn") {
|
|
12
|
+
return {
|
|
13
|
+
lockfile: "yarn.lock",
|
|
14
|
+
installAndDedupe: ["yarn", "yarn dedupe"],
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
if (pm.name === "npm") {
|
|
18
|
+
return {
|
|
19
|
+
lockfile: "package-lock.json",
|
|
20
|
+
installAndDedupe: ["npm install", "npm dedupe"],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (pm.name === "bun") {
|
|
24
|
+
return {
|
|
25
|
+
lockfile: "bun.lock",
|
|
26
|
+
installAndDedupe: ["bun i"],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
throw new Error(
|
|
31
|
+
`Package manager not supported: ${pm.name}. Please run with yarn, npm or bun !`,
|
|
32
|
+
);
|
|
33
|
+
})();
|
|
34
|
+
|
|
35
|
+
const pkg = JSON.parse(fs.readFileSync(path.resolve("package.json")));
|
|
36
|
+
const workspaces = pkg.workspaces || false;
|
|
37
|
+
|
|
38
|
+
const getSrcDirectories = () => {
|
|
39
|
+
if (workspaces) {
|
|
40
|
+
return `${
|
|
41
|
+
workspaces.length === 1 ? workspaces[0] : `{${workspaces.join(",")}}`
|
|
42
|
+
}/{src,lib}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return "{src,lib}";
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default function createLintStagedConfig() {
|
|
49
|
+
const srcDirectories = getSrcDirectories();
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
[`{${lockfile},package.json${
|
|
53
|
+
workspaces
|
|
54
|
+
? `,${workspaces
|
|
55
|
+
.map((workspacePath) => `${workspacePath}/package.json`)
|
|
56
|
+
.join(",")}`
|
|
57
|
+
: ""
|
|
58
|
+
}}`]: (filenames) => {
|
|
59
|
+
const packagejsonFilenames = filenames.filter((filename) =>
|
|
60
|
+
filename.endsWith(".json"),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
return [
|
|
64
|
+
...installAndDedupe,
|
|
65
|
+
pkg.scripts?.checks ? `${pm.name} run checks` : undefined,
|
|
66
|
+
"eslint --fix --quiet",
|
|
67
|
+
packagejsonFilenames.length === 0
|
|
68
|
+
? undefined
|
|
69
|
+
: `pretty-pkg "${packagejsonFilenames.join('" "')}"`,
|
|
70
|
+
`git add ${lockfile}${pm.name === "yarn" ? " .yarn .yarnrc.yml" : ""}`,
|
|
71
|
+
].filter(Boolean);
|
|
72
|
+
},
|
|
73
|
+
"!(package|package-lock|.eslintrc).json": ["prettier --write"],
|
|
74
|
+
[`{scripts,config,${srcDirectories}}/**/*.{yml,yaml,md}`]: [
|
|
75
|
+
"prettier --write",
|
|
76
|
+
],
|
|
77
|
+
"./*.{yml,yaml,md}": ["prettier --write"],
|
|
78
|
+
[`${srcDirectories}/**/*.{js,ts,tsx}`]: [
|
|
79
|
+
"prettier --write",
|
|
80
|
+
"eslint --fix --quiet",
|
|
81
|
+
],
|
|
82
|
+
"{scripts,config,.storyboook}/**/*.{js,mjs,cjs}": [
|
|
83
|
+
"prettier --write",
|
|
84
|
+
"eslint --fix --quiet",
|
|
85
|
+
],
|
|
86
|
+
[`{.storybook,${srcDirectories}}/**/*.css`]: [
|
|
87
|
+
"prettier --parser css --write",
|
|
88
|
+
],
|
|
89
|
+
[`${srcDirectories}/**/*.{ts,tsx}`]: () =>
|
|
90
|
+
pkg.devDependencies && pkg.devDependencies["pob-babel"]
|
|
91
|
+
? ["rollup --config rollup.config.mjs", "tsc -b"]
|
|
92
|
+
: ["tsc"],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function whichPmRuns() {
|
|
2
|
+
const userAgent = process.env.npm_config_user_agent;
|
|
3
|
+
if (!userAgent) {
|
|
4
|
+
return undefined;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const pmSpec = userAgent.split(" ")[0];
|
|
8
|
+
const separatorPos = pmSpec.lastIndexOf("/");
|
|
9
|
+
return {
|
|
10
|
+
name: pmSpec.slice(0, separatorPos),
|
|
11
|
+
version: pmSpec.slice(separatorPos + 1),
|
|
12
|
+
};
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pob/root",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "20.0.1",
|
|
4
4
|
"description": "root package",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Christophe Hurpeau <christophe@hurpeau.com> (https://christophe.hurpeau.com)",
|
|
@@ -21,17 +21,17 @@
|
|
|
21
21
|
"pob-root-lint-staged": "./bin/pob-root-lint-staged.js",
|
|
22
22
|
"pob-root-postinstall": "./bin/pob-root-postinstall.js",
|
|
23
23
|
"pob-root-prettier": "./bin/prettier.cjs",
|
|
24
|
+
"pob-version": "./bin/pob-version.js",
|
|
24
25
|
"prettier": "./bin/prettier.cjs",
|
|
25
26
|
"pretty-pkg": "./bin/pretty-pkg.js",
|
|
26
27
|
"repository-check-dirty": "./bin/repository-check-dirty.js",
|
|
27
|
-
"yarn-version": "./bin/
|
|
28
|
+
"yarn-version": "./bin/pob-version.js"
|
|
28
29
|
},
|
|
29
30
|
"main": "./lib/index.js",
|
|
30
31
|
"exports": {
|
|
31
32
|
".": "./lib/index.js",
|
|
32
33
|
"./createLintStagedConfig": "./createLintStagedConfig.js",
|
|
33
34
|
"./createLintStagedConfig.js": "./createLintStagedConfig.js",
|
|
34
|
-
"./createLintStagedConfig.cjs": "./createLintStagedConfig.cjs",
|
|
35
35
|
"./prettier-config": "./prettier-config.cjs",
|
|
36
36
|
"./prettier-config.js": "./prettier-config.cjs",
|
|
37
37
|
"./prettier-config.cjs": "./prettier-config.cjs",
|
|
@@ -55,13 +55,12 @@
|
|
|
55
55
|
"lib",
|
|
56
56
|
"bin",
|
|
57
57
|
"createLintStagedConfig.js",
|
|
58
|
-
"createLintStagedConfig.cjs",
|
|
59
58
|
"prettier-config.cjs",
|
|
60
59
|
"tsconfigs"
|
|
61
60
|
],
|
|
62
61
|
"scripts": {
|
|
63
62
|
"lint": "yarn run lint:eslint",
|
|
64
|
-
"lint:eslint": "yarn ../.. run eslint --quiet @pob/root"
|
|
63
|
+
"lint:eslint": "yarn ../.. run eslint --quiet '@pob/root'"
|
|
65
64
|
},
|
|
66
65
|
"pob": {},
|
|
67
66
|
"prettier": "@pob/root/prettier-config",
|
|
@@ -69,19 +68,16 @@
|
|
|
69
68
|
"@commitlint/format": "20.0.0",
|
|
70
69
|
"@commitlint/lint": "20.0.0",
|
|
71
70
|
"@commitlint/types": "20.0.0",
|
|
72
|
-
"@pob/pretty-pkg": "13.1
|
|
71
|
+
"@pob/pretty-pkg": "13.2.1",
|
|
72
|
+
"@pob/version": "1.0.0",
|
|
73
73
|
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
74
74
|
"conventional-changelog-writer": "^8.2.0",
|
|
75
75
|
"conventional-commits-parser": "^6.2.1",
|
|
76
|
-
"cosmiconfig": "^9.0.0",
|
|
77
76
|
"husky": "~9.1.7",
|
|
78
77
|
"json5": "^2.2.3",
|
|
79
|
-
"lint-staged": "16.2.
|
|
80
|
-
"pob-dependencies": "
|
|
78
|
+
"lint-staged": "16.2.7",
|
|
79
|
+
"pob-dependencies": "21.0.1",
|
|
81
80
|
"prettier": "3.6.2",
|
|
82
|
-
"
|
|
83
|
-
"semver": "^7.7.3",
|
|
84
|
-
"which-pm-runs": "1.1.0",
|
|
85
|
-
"yarn-version": "8.7.0"
|
|
81
|
+
"semver": "^7.7.3"
|
|
86
82
|
}
|
|
87
83
|
}
|
package/bin/yarn-version.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const fs = require("node:fs");
|
|
4
|
-
const path = require("node:path");
|
|
5
|
-
const semver = require("semver");
|
|
6
|
-
const whichPmRuns = require("which-pm-runs");
|
|
7
|
-
|
|
8
|
-
const pm =
|
|
9
|
-
whichPmRuns() ||
|
|
10
|
-
(fs.existsSync("package-lock.json") ? { name: "npm" } : undefined);
|
|
11
|
-
const isEslintFlatConfig =
|
|
12
|
-
fs.existsSync("eslint.config.js") || fs.existsSync("eslint.config.mjs");
|
|
13
|
-
|
|
14
|
-
const yarnMajorVersion = pm.name === "yarn" && semver.major(pm.version);
|
|
15
|
-
const { lockfile, installAndDedupe } = (() => {
|
|
16
|
-
if (pm.name === "yarn") {
|
|
17
|
-
return {
|
|
18
|
-
lockfile: "yarn.lock",
|
|
19
|
-
installAndDedupe: ["yarn", "yarn dedupe"],
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
if (pm.name === "npm") {
|
|
23
|
-
return {
|
|
24
|
-
lockfile: "package-lock.json",
|
|
25
|
-
installAndDedupe: ["npm install", "npm dedupe"],
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
if (pm.name === "bun") {
|
|
29
|
-
return {
|
|
30
|
-
lockfile: "bun.lock",
|
|
31
|
-
installAndDedupe: ["bun i"],
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
throw new Error(
|
|
36
|
-
`Package manager not supported: ${pm.name}. Please run with yarn, npm or bun !`,
|
|
37
|
-
);
|
|
38
|
-
})();
|
|
39
|
-
|
|
40
|
-
// eslint-disable-next-line import/no-dynamic-require
|
|
41
|
-
const pkg = require(path.resolve("package.json"));
|
|
42
|
-
const workspaces = pkg.workspaces || false;
|
|
43
|
-
|
|
44
|
-
const getSrcDirectories = () => {
|
|
45
|
-
if (workspaces) {
|
|
46
|
-
return `${
|
|
47
|
-
workspaces.length === 1 ? workspaces[0] : `{${workspaces.join(",")}}`
|
|
48
|
-
}/{src,lib}`;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return "{src,lib}";
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
// const getDistDirectories = () => {
|
|
55
|
-
// if (workspaces) {
|
|
56
|
-
// return `${
|
|
57
|
-
// workspaces.length === 1 ? workspaces[0] : `{${workspaces.join(',')}}`
|
|
58
|
-
// }/dist`;
|
|
59
|
-
// }
|
|
60
|
-
|
|
61
|
-
// return 'dist';
|
|
62
|
-
// };
|
|
63
|
-
|
|
64
|
-
module.exports = function createLintStagedConfig() {
|
|
65
|
-
const srcDirectories = getSrcDirectories();
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
[`{${lockfile},package.json${
|
|
69
|
-
workspaces
|
|
70
|
-
? `,${workspaces
|
|
71
|
-
.map((workspacePath) => `${workspacePath}/package.json`)
|
|
72
|
-
.join(",")}`
|
|
73
|
-
: ""
|
|
74
|
-
}}`]: (filenames) => {
|
|
75
|
-
const packagejsonFilenames = filenames.filter((filename) =>
|
|
76
|
-
filename.endsWith(".json"),
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
return [
|
|
80
|
-
...installAndDedupe,
|
|
81
|
-
pkg.scripts?.checks ? `${pm.name} run checks` : undefined,
|
|
82
|
-
"eslint --fix --quiet",
|
|
83
|
-
packagejsonFilenames.length === 0
|
|
84
|
-
? undefined
|
|
85
|
-
: `pretty-pkg "${packagejsonFilenames.join('" "')}"`,
|
|
86
|
-
`git add ${lockfile}${
|
|
87
|
-
pm.name === "yarn" && yarnMajorVersion >= 2
|
|
88
|
-
? " .yarn .yarnrc.yml"
|
|
89
|
-
: ""
|
|
90
|
-
}`,
|
|
91
|
-
].filter(Boolean);
|
|
92
|
-
},
|
|
93
|
-
"!(package|package-lock|.eslintrc).json": ["prettier --write"],
|
|
94
|
-
[`{scripts,config,${srcDirectories}}/**/*.{yml,yaml,md}`]: [
|
|
95
|
-
"prettier --write",
|
|
96
|
-
],
|
|
97
|
-
"./*.{yml,yaml,md}": ["prettier --write"],
|
|
98
|
-
[`${srcDirectories}/**/*.{js,ts,tsx}`]: [
|
|
99
|
-
"prettier --write",
|
|
100
|
-
`eslint --fix --quiet${
|
|
101
|
-
isEslintFlatConfig
|
|
102
|
-
? ""
|
|
103
|
-
: " --report-unused-disable-directives --resolve-plugins-relative-to ."
|
|
104
|
-
}`,
|
|
105
|
-
],
|
|
106
|
-
"{scripts,config,.storyboook}/**/*.{js,mjs,cjs}": [
|
|
107
|
-
"prettier --write",
|
|
108
|
-
`eslint --fix --quiet${
|
|
109
|
-
isEslintFlatConfig
|
|
110
|
-
? ""
|
|
111
|
-
: " --report-unused-disable-directives --resolve-plugins-relative-to ."
|
|
112
|
-
}`,
|
|
113
|
-
],
|
|
114
|
-
[`{.storybook,${srcDirectories}}/**/*.css`]: [
|
|
115
|
-
"prettier --parser css --write",
|
|
116
|
-
],
|
|
117
|
-
[`${srcDirectories}/**/*.{ts,tsx}`]: () =>
|
|
118
|
-
pkg.devDependencies && pkg.devDependencies["pob-babel"]
|
|
119
|
-
? [
|
|
120
|
-
"rollup --config rollup.config.mjs",
|
|
121
|
-
"tsc -b",
|
|
122
|
-
// `git --glob-pathspecs add ${getDistDirectories()}/**/*`,
|
|
123
|
-
]
|
|
124
|
-
: ["tsc"],
|
|
125
|
-
};
|
|
126
|
-
};
|