@pob/root 9.4.3 → 10.0.0
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 +26 -0
- package/README.md +1 -1
- package/bin/commitlint.cjs +5 -5
- package/bin/pob-root-lint-staged.js +1 -1
- package/bin/pob-root-postinstall.js +14 -14
- package/bin/postinstall/install-github-workflows.js +15 -15
- package/bin/postinstall/install-husky.js +47 -45
- package/bin/postinstall/install-scripts.js +10 -10
- package/bin/postinstall/install-vscode-tasks.js +24 -24
- package/bin/postinstall/update-yarn.js +14 -14
- package/bin/prettier.cjs +5 -5
- package/bin/pretty-eslint-config.js +1 -1
- package/bin/pretty-pkg.js +1 -1
- package/bin/repository-check-dirty.js +1 -1
- package/createLintStagedConfig.cjs +40 -40
- package/createLintStagedConfig.js +2 -2
- package/package.json +5 -5
- package/prettier-config.cjs +4 -15
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,32 @@
|
|
|
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
|
+
## [10.0.0](https://github.com/christophehurpeau/pob/compare/@pob/root@9.5.0...@pob/root@10.0.0) (2024-05-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### ⚠ BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* change prettier config to get closer to default
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* change prettier config to get closer to default ([8e472a9](https://github.com/christophehurpeau/pob/commit/8e472a98b0a722c5cd779e4731ff625b0bfa07bb))
|
|
16
|
+
|
|
17
|
+
Version bump for dependency: pretty-eslint-config
|
|
18
|
+
Version bump for dependency: pretty-pkg
|
|
19
|
+
Version bump for dependency: repository-check-dirty
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [9.5.0](https://github.com/christophehurpeau/pob/compare/@pob/root@9.4.3...@pob/root@9.5.0) (2024-05-05)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* support yarn nodeLinker pnpm ([340e5ab](https://github.com/christophehurpeau/pob/commit/340e5aba71f6943614445f50b20f1c3d3e68f01a))
|
|
28
|
+
|
|
29
|
+
Version bump for dependency: repository-check-dirty
|
|
30
|
+
|
|
31
|
+
|
|
6
32
|
## [9.4.3](https://github.com/christophehurpeau/pob/compare/@pob/root@9.4.2...@pob/root@9.4.3) (2024-05-04)
|
|
7
33
|
|
|
8
34
|
|
package/README.md
CHANGED
package/bin/commitlint.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
"use strict";
|
|
4
4
|
|
|
5
|
-
const path = require(
|
|
6
|
-
const pkg = require(
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
const pkg = require("@commitlint/cli/package.json");
|
|
7
7
|
|
|
8
8
|
// eslint-disable-next-line import/no-dynamic-require
|
|
9
9
|
require(path.join(
|
|
10
|
-
|
|
11
|
-
typeof pkg.bin ===
|
|
10
|
+
"@commitlint/cli",
|
|
11
|
+
typeof pkg.bin === "string" ? pkg.bin : pkg.bin.commitlint
|
|
12
12
|
));
|
|
@@ -1,48 +1,48 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/* eslint-disable unicorn/no-await-expression-member */
|
|
3
3
|
|
|
4
|
-
import fs from
|
|
5
|
-
import path from
|
|
6
|
-
import whichPmRuns from
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import whichPmRuns from "which-pm-runs";
|
|
7
7
|
|
|
8
8
|
if (!process.env.INIT_CWD) {
|
|
9
9
|
console.error(
|
|
10
|
-
|
|
10
|
+
"Missing process.env.INIT_CWD. Did you use postinstall script ?"
|
|
11
11
|
);
|
|
12
12
|
process.exit(1);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
process.chdir(process.env.PROJECT_CWD || process.env.INIT_CWD);
|
|
16
16
|
|
|
17
|
-
const pkg = JSON.parse(fs.readFileSync(path.resolve(
|
|
17
|
+
const pkg = JSON.parse(fs.readFileSync(path.resolve("package.json")));
|
|
18
18
|
|
|
19
19
|
/* Check Package Manager */
|
|
20
20
|
|
|
21
21
|
const pm = process.env.POB_ROOT_FAKE_PM
|
|
22
22
|
? JSON.parse(process.env.POB_ROOT_FAKE_PM)
|
|
23
23
|
: whichPmRuns() ||
|
|
24
|
-
(fs.existsSync(
|
|
24
|
+
(fs.existsSync("package-lock.json") ? { name: "npm" } : undefined);
|
|
25
25
|
|
|
26
26
|
if (!pm) {
|
|
27
|
-
console.error(
|
|
27
|
+
console.error("Invalid pm, please run with postinstall hook!");
|
|
28
28
|
process.exit(1);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
if (pm.name !==
|
|
31
|
+
if (pm.name !== "yarn" && pm.name !== "npm" && pm.name !== "bun") {
|
|
32
32
|
console.error(
|
|
33
|
-
`Package manager not supported: ${pm.name}. Please run with yarn or npm
|
|
33
|
+
`Package manager not supported: ${pm.name}. Please run with yarn or npm!`
|
|
34
34
|
);
|
|
35
35
|
process.exit(1);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
(await import(
|
|
39
|
-
(await import(
|
|
40
|
-
(await import(
|
|
38
|
+
(await import("./postinstall/update-yarn.js")).default({ pkg, pm });
|
|
39
|
+
(await import("./postinstall/install-husky.js")).default({ pkg, pm });
|
|
40
|
+
(await import("./postinstall/install-github-workflows.js")).default({
|
|
41
41
|
pkg,
|
|
42
42
|
pm,
|
|
43
43
|
});
|
|
44
|
-
(await import(
|
|
44
|
+
(await import("./postinstall/install-scripts.js")).default({ pkg, pm });
|
|
45
45
|
|
|
46
46
|
if (process.env.POB_EXPERIMENTAL_VSCODE_TASKS) {
|
|
47
|
-
(await import(
|
|
47
|
+
(await import("./postinstall/install-vscode-tasks.js")).default({ pkg, pm });
|
|
48
48
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import path from
|
|
3
|
-
import { fileURLToPath } from
|
|
4
|
-
import semver from
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import semver from "semver";
|
|
5
5
|
|
|
6
6
|
const ensureWorkflowUninstalled = (workflowName) => {
|
|
7
7
|
try {
|
|
@@ -16,9 +16,9 @@ const installWorkflow = (workflowName, condition = true) => {
|
|
|
16
16
|
fs.readFileSync(
|
|
17
17
|
path.resolve(
|
|
18
18
|
path.dirname(fileURLToPath(import.meta.url)),
|
|
19
|
-
`github-workflows/${workflowName}.yml
|
|
20
|
-
)
|
|
21
|
-
)
|
|
19
|
+
`github-workflows/${workflowName}.yml`
|
|
20
|
+
)
|
|
21
|
+
)
|
|
22
22
|
);
|
|
23
23
|
} else {
|
|
24
24
|
ensureWorkflowUninstalled(workflowName);
|
|
@@ -26,23 +26,23 @@ const installWorkflow = (workflowName, condition = true) => {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
export default function installGithubWorkflows({ pkg, pm }) {
|
|
29
|
-
const yarnMajorVersion = pm.name ===
|
|
30
|
-
const isYarnBerry = pm.name ===
|
|
29
|
+
const yarnMajorVersion = pm.name === "yarn" && semver.major(pm.version);
|
|
30
|
+
const isYarnBerry = pm.name === "yarn" && yarnMajorVersion >= 2;
|
|
31
31
|
|
|
32
32
|
if (!isYarnBerry) return;
|
|
33
33
|
|
|
34
|
-
if (fs.existsSync(
|
|
35
|
-
installWorkflow(
|
|
36
|
-
installWorkflow(
|
|
37
|
-
ensureWorkflowUninstalled(
|
|
34
|
+
if (fs.existsSync(".github")) {
|
|
35
|
+
installWorkflow("push-renovate-pob_root");
|
|
36
|
+
installWorkflow("push-renovate-prettier");
|
|
37
|
+
ensureWorkflowUninstalled("push-renovate-typedoc");
|
|
38
38
|
if (
|
|
39
39
|
pkg.devDependencies &&
|
|
40
40
|
pkg.devDependencies.rollup &&
|
|
41
41
|
pkg.scripts?.build
|
|
42
42
|
) {
|
|
43
|
-
installWorkflow(
|
|
43
|
+
installWorkflow("push-renovate-build");
|
|
44
44
|
} else {
|
|
45
|
-
ensureWorkflowUninstalled(
|
|
45
|
+
ensureWorkflowUninstalled("push-renovate-build");
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
/* eslint-disable complexity */
|
|
2
2
|
|
|
3
|
-
import fs from
|
|
4
|
-
import path from
|
|
5
|
-
import husky from
|
|
6
|
-
import semver from
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import husky from "husky";
|
|
6
|
+
import semver from "semver";
|
|
7
7
|
|
|
8
8
|
const ensureLegacyHuskyConfigDeleted = () => {
|
|
9
9
|
try {
|
|
10
|
-
fs.unlinkSync(path.resolve(
|
|
10
|
+
fs.unlinkSync(path.resolve("husky.config.js"));
|
|
11
11
|
} catch {}
|
|
12
12
|
try {
|
|
13
|
-
fs.unlinkSync(path.resolve(
|
|
13
|
+
fs.unlinkSync(path.resolve(".huskyrc"));
|
|
14
14
|
} catch {}
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
const ensureHuskyNotInDevDependencies = (pkg) => {
|
|
18
18
|
if (pkg.devDependencies && pkg.devDependencies.husky) {
|
|
19
19
|
throw new Error(
|
|
20
|
-
|
|
20
|
+
"Found husky in devDependencies. Husky is provided by @pob/root, please remove"
|
|
21
21
|
);
|
|
22
22
|
}
|
|
23
23
|
};
|
|
@@ -27,8 +27,8 @@ const writeHook = (hookName, hookContent) => {
|
|
|
27
27
|
path.resolve(`.husky/${hookName}`),
|
|
28
28
|
`#!/usr/bin/env sh\n\n${hookContent.trim()}\n`,
|
|
29
29
|
{
|
|
30
|
-
mode:
|
|
31
|
-
}
|
|
30
|
+
mode: "755",
|
|
31
|
+
}
|
|
32
32
|
);
|
|
33
33
|
};
|
|
34
34
|
|
|
@@ -40,17 +40,19 @@ const ensureHookDeleted = (hookName) => {
|
|
|
40
40
|
|
|
41
41
|
const readYarnConfigFile = () => {
|
|
42
42
|
try {
|
|
43
|
-
return fs.readFileSync(path.resolve(
|
|
43
|
+
return fs.readFileSync(path.resolve(".yarnrc.yml"));
|
|
44
44
|
} catch {
|
|
45
|
-
return
|
|
45
|
+
return "";
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
export default function installHusky({ pkg, pm }) {
|
|
50
|
-
const yarnMajorVersion = pm.name ===
|
|
51
|
-
const isYarnBerry = pm.name ===
|
|
50
|
+
const yarnMajorVersion = pm.name === "yarn" && semver.major(pm.version);
|
|
51
|
+
const isYarnBerry = pm.name === "yarn" && yarnMajorVersion >= 2;
|
|
52
|
+
const yarnConfig = isYarnBerry && readYarnConfigFile();
|
|
52
53
|
const isYarnPnp =
|
|
53
|
-
|
|
54
|
+
!yarnConfig.includes("nodeLinker: node-modules") &&
|
|
55
|
+
!yarnConfig.includes("nodeLinker: pnpm");
|
|
54
56
|
|
|
55
57
|
/* Check legacy */
|
|
56
58
|
|
|
@@ -64,48 +66,48 @@ export default function installHusky({ pkg, pm }) {
|
|
|
64
66
|
const shouldRunLint = () => pkg.scripts && pkg.scripts.lint;
|
|
65
67
|
|
|
66
68
|
try {
|
|
67
|
-
fs.mkdirSync(path.resolve(
|
|
69
|
+
fs.mkdirSync(path.resolve(".husky"));
|
|
68
70
|
} catch {}
|
|
69
71
|
|
|
70
72
|
const { lockfile, pmExec, installOnDiffCommand } = (() => {
|
|
71
|
-
if (pm.name ===
|
|
73
|
+
if (pm.name === "yarn") {
|
|
72
74
|
return {
|
|
73
|
-
lockfile:
|
|
74
|
-
pmExec:
|
|
75
|
+
lockfile: "yarn.lock",
|
|
76
|
+
pmExec: "yarn",
|
|
75
77
|
installOnDiffCommand: `yarn install ${
|
|
76
78
|
isYarnBerry
|
|
77
|
-
?
|
|
78
|
-
:
|
|
79
|
+
? "--immutable"
|
|
80
|
+
: "--prefer-offline --pure-lockfile --ignore-optional"
|
|
79
81
|
}`,
|
|
80
82
|
};
|
|
81
83
|
}
|
|
82
|
-
if (pm.name ===
|
|
84
|
+
if (pm.name === "npm") {
|
|
83
85
|
return {
|
|
84
|
-
lockfile:
|
|
85
|
-
pmExec:
|
|
86
|
-
installOnDiffCommand:
|
|
86
|
+
lockfile: "package-lock.json",
|
|
87
|
+
pmExec: "npx --no-install",
|
|
88
|
+
installOnDiffCommand: "npm i",
|
|
87
89
|
};
|
|
88
90
|
}
|
|
89
|
-
if (pm.name ===
|
|
91
|
+
if (pm.name === "bun") {
|
|
90
92
|
return {
|
|
91
|
-
lockfile:
|
|
92
|
-
pmExec:
|
|
93
|
-
installOnDiffCommand:
|
|
93
|
+
lockfile: "bun.lockb",
|
|
94
|
+
pmExec: "bun run",
|
|
95
|
+
installOnDiffCommand: "bun i",
|
|
94
96
|
};
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
throw new Error(
|
|
98
|
-
`Package manager not supported: ${pm.name}. Please run with yarn, npm or bun
|
|
100
|
+
`Package manager not supported: ${pm.name}. Please run with yarn, npm or bun !`
|
|
99
101
|
);
|
|
100
102
|
})();
|
|
101
103
|
|
|
102
|
-
writeHook(
|
|
103
|
-
writeHook(
|
|
104
|
+
writeHook("commit-msg", `${pmExec} commitlint --edit $1`);
|
|
105
|
+
writeHook("pre-commit", `${pmExec} pob-root-lint-staged`);
|
|
104
106
|
|
|
105
107
|
if (isYarnPnp) {
|
|
106
|
-
ensureHookDeleted(
|
|
107
|
-
ensureHookDeleted(
|
|
108
|
-
ensureHookDeleted(
|
|
108
|
+
ensureHookDeleted("post-checkout");
|
|
109
|
+
ensureHookDeleted("post-merge");
|
|
110
|
+
ensureHookDeleted("post-rewrite");
|
|
109
111
|
} else {
|
|
110
112
|
const runInstallOnDiff = (() => {
|
|
111
113
|
return `
|
|
@@ -115,9 +117,9 @@ fi`;
|
|
|
115
117
|
})();
|
|
116
118
|
|
|
117
119
|
// https://yarnpkg.com/features/zero-installs
|
|
118
|
-
writeHook(
|
|
119
|
-
writeHook(
|
|
120
|
-
writeHook(
|
|
120
|
+
writeHook("post-checkout", runInstallOnDiff);
|
|
121
|
+
writeHook("post-merge", runInstallOnDiff);
|
|
122
|
+
writeHook("post-rewrite", runInstallOnDiff);
|
|
121
123
|
}
|
|
122
124
|
|
|
123
125
|
const prePushHook = [];
|
|
@@ -133,19 +135,19 @@ fi`;
|
|
|
133
135
|
if (shouldRunTest()) {
|
|
134
136
|
const getTestCommand = () => {
|
|
135
137
|
if (pkg.devDependencies?.jest) {
|
|
136
|
-
return
|
|
138
|
+
return "test --watchAll=false --changedSince=origin/main";
|
|
137
139
|
}
|
|
138
140
|
if (pkg.devDependencies?.vitest) {
|
|
139
|
-
return
|
|
141
|
+
return "test --run --changed origin/main";
|
|
140
142
|
}
|
|
141
|
-
return
|
|
143
|
+
return "test";
|
|
142
144
|
};
|
|
143
145
|
prePushHook.push(`${pmExec} ${getTestCommand()}`);
|
|
144
146
|
}
|
|
145
147
|
|
|
146
148
|
if (prePushHook.length > 0) {
|
|
147
149
|
writeHook(
|
|
148
|
-
|
|
150
|
+
"pre-push",
|
|
149
151
|
`
|
|
150
152
|
# z40 is the value matching the empty blob/commit/tree SHA (zero x 40)
|
|
151
153
|
z40=0000000000000000000000000000000000000000
|
|
@@ -156,15 +158,15 @@ do
|
|
|
156
158
|
# Skip if branch deletion
|
|
157
159
|
if [ "$local_sha" != "$z40" ]; then
|
|
158
160
|
if [ "$local_ref" = "$branch_ref" ]; then
|
|
159
|
-
${prePushHook.join(
|
|
161
|
+
${prePushHook.join(" && ")}
|
|
160
162
|
fi
|
|
161
163
|
fi
|
|
162
164
|
done
|
|
163
|
-
|
|
165
|
+
`
|
|
164
166
|
);
|
|
165
167
|
} else {
|
|
166
|
-
ensureHookDeleted(
|
|
168
|
+
ensureHookDeleted("pre-push");
|
|
167
169
|
}
|
|
168
170
|
|
|
169
|
-
process.stdout.write(husky(
|
|
171
|
+
process.stdout.write(husky(".husky"));
|
|
170
172
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import fs from
|
|
1
|
+
import fs from "node:fs";
|
|
2
2
|
|
|
3
3
|
const addPobRootPostinstallInScript = (pkg, scriptName) => {
|
|
4
4
|
if (!pkg.scripts[scriptName]) {
|
|
5
|
-
pkg.scripts[scriptName] =
|
|
6
|
-
} else if (!pkg.scripts[scriptName].includes(
|
|
5
|
+
pkg.scripts[scriptName] = "pob-root-postinstall";
|
|
6
|
+
} else if (!pkg.scripts[scriptName].includes("pob-root-postinstall")) {
|
|
7
7
|
pkg.scripts[
|
|
8
8
|
scriptName
|
|
9
9
|
] = `pob-root-postinstall ; ${pkg.scripts.postinstall}`;
|
|
@@ -12,21 +12,21 @@ const addPobRootPostinstallInScript = (pkg, scriptName) => {
|
|
|
12
12
|
|
|
13
13
|
export default function installScripts({ pkg, pm }) {
|
|
14
14
|
if (!pkg.scripts) pkg.scripts = {};
|
|
15
|
-
if (pkg.name ===
|
|
15
|
+
if (pkg.name === "pob-monorepo") return;
|
|
16
16
|
|
|
17
|
-
if (pm.name ===
|
|
17
|
+
if (pm.name === "yarn") {
|
|
18
18
|
if (pkg.private) {
|
|
19
19
|
delete pkg.scripts.postinstallDev;
|
|
20
|
-
addPobRootPostinstallInScript(pkg,
|
|
20
|
+
addPobRootPostinstallInScript(pkg, "postinstall");
|
|
21
21
|
} else {
|
|
22
|
-
if (pkg.scripts.postinstall ===
|
|
22
|
+
if (pkg.scripts.postinstall === "pob-root-postinstall") {
|
|
23
23
|
delete pkg.scripts.postinstall;
|
|
24
24
|
}
|
|
25
|
-
pkg.scripts.postinstallDev =
|
|
25
|
+
pkg.scripts.postinstallDev = "pob-root-postinstall";
|
|
26
26
|
}
|
|
27
27
|
} else {
|
|
28
|
-
addPobRootPostinstallInScript(pkg,
|
|
28
|
+
addPobRootPostinstallInScript(pkg, "prepare");
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
fs.writeFileSync(
|
|
31
|
+
fs.writeFileSync("package.json", `${JSON.stringify(pkg, null, 2)}\n`, "utf8");
|
|
32
32
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import JSON5 from
|
|
3
|
-
import prettier from
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import JSON5 from "json5";
|
|
3
|
+
import prettier from "prettier";
|
|
4
4
|
|
|
5
5
|
function readJSON5(path, defaults = null) {
|
|
6
6
|
try {
|
|
@@ -12,41 +12,41 @@ function readJSON5(path, defaults = null) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
function getGroupNameFromScriptName(scriptName) {
|
|
15
|
-
if (scriptName.startsWith(
|
|
16
|
-
if (scriptName.startsWith(
|
|
17
|
-
if (scriptName.startsWith(
|
|
18
|
-
return
|
|
15
|
+
if (scriptName.startsWith("lint") || scriptName === "tsc") return "lint";
|
|
16
|
+
if (scriptName.startsWith("test")) return "test";
|
|
17
|
+
if (scriptName.startsWith("start") || scriptName.startsWith("build")) {
|
|
18
|
+
return "build";
|
|
19
19
|
}
|
|
20
20
|
return undefined;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
function getProblemMatcherFromScriptName(scriptName) {
|
|
24
|
-
if (scriptName ===
|
|
25
|
-
if (scriptName ===
|
|
24
|
+
if (scriptName === "lint:eslint") return ["$eslint-stylish"];
|
|
25
|
+
if (scriptName === "tsc") return ["$tsc"];
|
|
26
26
|
return [];
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export default function installVscodeTasks({ pkg }) {
|
|
30
|
-
const existingConfig = readJSON5(
|
|
30
|
+
const existingConfig = readJSON5(".vscode/tasks.json");
|
|
31
31
|
const existingTasks = existingConfig?.tasks || [];
|
|
32
32
|
|
|
33
33
|
// filter all npm tasks, we will recreate them right after
|
|
34
|
-
const tasks = existingTasks.filter((task) => task.type !==
|
|
34
|
+
const tasks = existingTasks.filter((task) => task.type !== "npm");
|
|
35
35
|
|
|
36
36
|
if (pkg.scripts) {
|
|
37
37
|
const scriptNames = Object.keys(pkg.scripts);
|
|
38
38
|
Object.entries(pkg.scripts).forEach(([scriptName, scriptCommand]) => {
|
|
39
|
-
if (scriptName ===
|
|
40
|
-
if (scriptName ===
|
|
39
|
+
if (scriptName === "postinstall") return;
|
|
40
|
+
if (scriptName === "lint") {
|
|
41
41
|
tasks.push({
|
|
42
42
|
label: scriptName,
|
|
43
43
|
group: getGroupNameFromScriptName(scriptName),
|
|
44
44
|
dependsOn: scriptNames.filter(
|
|
45
45
|
(name) =>
|
|
46
|
-
(name !==
|
|
47
|
-
name.startsWith(
|
|
48
|
-
!name.endsWith(
|
|
49
|
-
name ===
|
|
46
|
+
(name !== "lint" &&
|
|
47
|
+
name.startsWith("lint") &&
|
|
48
|
+
!name.endsWith(":fix")) ||
|
|
49
|
+
name === "tsc"
|
|
50
50
|
),
|
|
51
51
|
});
|
|
52
52
|
return;
|
|
@@ -55,17 +55,17 @@ export default function installVscodeTasks({ pkg }) {
|
|
|
55
55
|
const task = {
|
|
56
56
|
label: scriptName,
|
|
57
57
|
problemMatcher: getProblemMatcherFromScriptName(scriptName),
|
|
58
|
-
type:
|
|
58
|
+
type: "npm",
|
|
59
59
|
script: scriptName,
|
|
60
60
|
group: getGroupNameFromScriptName(scriptName),
|
|
61
61
|
presentation: {
|
|
62
|
-
panel:
|
|
62
|
+
panel: "dedicated",
|
|
63
63
|
group: getGroupNameFromScriptName(scriptName),
|
|
64
64
|
clear: true,
|
|
65
65
|
},
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
if (scriptName ===
|
|
68
|
+
if (scriptName === "start" || scriptName === "watch") {
|
|
69
69
|
task.isBackground = true;
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -74,7 +74,7 @@ export default function installVscodeTasks({ pkg }) {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
fs.writeFileSync(
|
|
77
|
-
|
|
77
|
+
".vscode/tasks.json",
|
|
78
78
|
prettier.format(
|
|
79
79
|
`{
|
|
80
80
|
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
|
@@ -84,8 +84,8 @@ export default function installVscodeTasks({ pkg }) {
|
|
|
84
84
|
}
|
|
85
85
|
`,
|
|
86
86
|
{
|
|
87
|
-
filepath:
|
|
88
|
-
}
|
|
89
|
-
)
|
|
87
|
+
filepath: ".vscode/tasks.json",
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
90
|
);
|
|
91
91
|
}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { execSync } from
|
|
2
|
-
import semver from
|
|
1
|
+
import { execSync } from "node:child_process";
|
|
2
|
+
import semver from "semver";
|
|
3
3
|
|
|
4
4
|
export default function updateYarn({ pkg, pm }) {
|
|
5
|
-
if (pm.name !==
|
|
5
|
+
if (pm.name !== "yarn" || !pm.version) return;
|
|
6
6
|
|
|
7
|
-
if (semver.lt(pm.version,
|
|
7
|
+
if (semver.lt(pm.version, "3.2.1")) {
|
|
8
8
|
// Upgrade from yarn 1
|
|
9
|
-
if (semver.lt(pm.version,
|
|
10
|
-
console.log(
|
|
9
|
+
if (semver.lt(pm.version, "2.0.0")) {
|
|
10
|
+
console.log("-- Install yarn berry --");
|
|
11
11
|
} else {
|
|
12
|
-
console.log(
|
|
12
|
+
console.log("-- Update yarn --");
|
|
13
13
|
}
|
|
14
|
-
execSync(
|
|
14
|
+
execSync("yarn set version stable", { stdio: "inherit" });
|
|
15
15
|
|
|
16
16
|
// removes yarn paths (can have 2) to use the newly installed yarn
|
|
17
|
-
const paths = process.env.PATH.split(
|
|
18
|
-
while (paths[0].startsWith(
|
|
17
|
+
const paths = process.env.PATH.split(":");
|
|
18
|
+
while (paths[0].startsWith("/tmp/xfs-")) paths.shift();
|
|
19
19
|
|
|
20
|
-
execSync(
|
|
21
|
-
stdio:
|
|
20
|
+
execSync("yarn install", {
|
|
21
|
+
stdio: "inherit",
|
|
22
22
|
env: {
|
|
23
23
|
...process.env,
|
|
24
|
-
PATH: paths.join(
|
|
24
|
+
PATH: paths.join(":"),
|
|
25
25
|
},
|
|
26
26
|
});
|
|
27
|
-
console.log(
|
|
27
|
+
console.log("Yarn update success !");
|
|
28
28
|
}
|
|
29
29
|
}
|
package/bin/prettier.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
"use strict";
|
|
4
4
|
|
|
5
|
-
const path = require(
|
|
6
|
-
const pkg = require(
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
const pkg = require("prettier/package.json");
|
|
7
7
|
|
|
8
8
|
// eslint-disable-next-line import/no-dynamic-require
|
|
9
9
|
require(path.join(
|
|
10
|
-
|
|
11
|
-
typeof pkg.bin ===
|
|
10
|
+
"prettier",
|
|
11
|
+
typeof pkg.bin === "string" ? pkg.bin : pkg.bin.prettier
|
|
12
12
|
));
|
package/bin/pretty-pkg.js
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
const fs = require(
|
|
4
|
-
const path = require(
|
|
5
|
-
const semver = require(
|
|
6
|
-
const whichPmRuns = require(
|
|
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
7
|
|
|
8
8
|
const pm =
|
|
9
9
|
whichPmRuns() ||
|
|
10
|
-
(fs.existsSync(
|
|
10
|
+
(fs.existsSync("package-lock.json") ? { name: "npm" } : undefined);
|
|
11
11
|
|
|
12
|
-
const yarnMajorVersion = pm.name ===
|
|
12
|
+
const yarnMajorVersion = pm.name === "yarn" && semver.major(pm.version);
|
|
13
13
|
const { lockfile, installAndDedupe } = (() => {
|
|
14
|
-
if (pm.name ===
|
|
14
|
+
if (pm.name === "yarn") {
|
|
15
15
|
return {
|
|
16
|
-
lockfile:
|
|
17
|
-
installAndDedupe: [
|
|
16
|
+
lockfile: "yarn.lock",
|
|
17
|
+
installAndDedupe: ["yarn", "yarn dedupe"],
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
if (pm.name ===
|
|
20
|
+
if (pm.name === "npm") {
|
|
21
21
|
return {
|
|
22
|
-
lockfile:
|
|
23
|
-
installAndDedupe: [
|
|
22
|
+
lockfile: "package-lock.json",
|
|
23
|
+
installAndDedupe: ["npm install", "npm dedupe"],
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
if (pm.name ===
|
|
26
|
+
if (pm.name === "bun") {
|
|
27
27
|
return {
|
|
28
|
-
lockfile:
|
|
29
|
-
installAndDedupe: [
|
|
28
|
+
lockfile: "bun.lockb",
|
|
29
|
+
installAndDedupe: ["bun i"],
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
throw new Error(
|
|
34
|
-
`Package manager not supported: ${pm.name}. Please run with yarn, npm or bun
|
|
34
|
+
`Package manager not supported: ${pm.name}. Please run with yarn, npm or bun !`
|
|
35
35
|
);
|
|
36
36
|
})();
|
|
37
37
|
|
|
38
38
|
// eslint-disable-next-line import/no-dynamic-require
|
|
39
|
-
const pkg = require(path.resolve(
|
|
39
|
+
const pkg = require(path.resolve("package.json"));
|
|
40
40
|
const workspaces = pkg.workspaces || false;
|
|
41
41
|
|
|
42
42
|
const getSrcDirectories = () => {
|
|
43
43
|
if (workspaces) {
|
|
44
44
|
return `${
|
|
45
|
-
workspaces.length === 1 ? workspaces[0] : `{${workspaces.join(
|
|
45
|
+
workspaces.length === 1 ? workspaces[0] : `{${workspaces.join(",")}}`
|
|
46
46
|
}/{src,lib}`;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
return
|
|
49
|
+
return "{src,lib}";
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
// const getDistDirectories = () => {
|
|
@@ -67,11 +67,11 @@ module.exports = function createLintStagedConfig() {
|
|
|
67
67
|
workspaces
|
|
68
68
|
? `,${workspaces
|
|
69
69
|
.map((workspacePath) => `${workspacePath}/package.json`)
|
|
70
|
-
.join(
|
|
71
|
-
:
|
|
70
|
+
.join(",")}`
|
|
71
|
+
: ""
|
|
72
72
|
}}`]: (filenames) => {
|
|
73
73
|
const packagejsonFilenames = filenames.filter((filename) =>
|
|
74
|
-
filename.endsWith(
|
|
74
|
+
filename.endsWith(".json")
|
|
75
75
|
);
|
|
76
76
|
|
|
77
77
|
return [
|
|
@@ -81,36 +81,36 @@ module.exports = function createLintStagedConfig() {
|
|
|
81
81
|
? undefined
|
|
82
82
|
: `pretty-pkg "${packagejsonFilenames.join('" "')}"`,
|
|
83
83
|
`git add ${lockfile}${
|
|
84
|
-
pm.name ===
|
|
85
|
-
?
|
|
86
|
-
:
|
|
84
|
+
pm.name === "yarn" && yarnMajorVersion >= 2
|
|
85
|
+
? " .yarn .yarnrc.yml"
|
|
86
|
+
: ""
|
|
87
87
|
}`,
|
|
88
88
|
].filter(Boolean);
|
|
89
89
|
},
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
"!(package|package-lock|.eslintrc).json": ["prettier --write"],
|
|
91
|
+
".eslintrc.json": ["pretty-eslint-config"],
|
|
92
92
|
[`{scripts,config,${srcDirectories}}/**/*.{yml,yaml,md}`]: [
|
|
93
|
-
|
|
93
|
+
"prettier --write",
|
|
94
94
|
],
|
|
95
|
-
|
|
95
|
+
"./*.{yml,yaml,md}": ["prettier --write"],
|
|
96
96
|
[`${srcDirectories}/**/*.{js,ts,tsx}`]: [
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
"prettier --write",
|
|
98
|
+
"eslint --fix --quiet --report-unused-disable-directives --resolve-plugins-relative-to .",
|
|
99
99
|
],
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
"{scripts,config,.storyboook}/**/*.{js,mjs,cjs}": [
|
|
101
|
+
"prettier --write",
|
|
102
|
+
"eslint --fix --quiet --report-unused-disable-directives --resolve-plugins-relative-to .",
|
|
103
103
|
],
|
|
104
104
|
[`{.storybook,${srcDirectories}}/**/*.css`]: [
|
|
105
|
-
|
|
105
|
+
"prettier --parser css --write",
|
|
106
106
|
],
|
|
107
107
|
[`${srcDirectories}/**/*.{ts,tsx}`]: () =>
|
|
108
|
-
pkg.devDependencies && pkg.devDependencies[
|
|
108
|
+
pkg.devDependencies && pkg.devDependencies["pob-babel"]
|
|
109
109
|
? [
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
"rollup --config rollup.config.mjs",
|
|
111
|
+
"tsc -b",
|
|
112
112
|
// `git --glob-pathspecs add ${getDistDirectories()}/**/*`,
|
|
113
113
|
]
|
|
114
|
-
: [
|
|
114
|
+
: ["tsc"],
|
|
115
115
|
};
|
|
116
116
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createRequire } from
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
2
|
|
|
3
3
|
const require = createRequire(import.meta.url);
|
|
4
4
|
|
|
5
5
|
// eslint-disable-next-line import/no-commonjs
|
|
6
|
-
export default require(
|
|
6
|
+
export default require("./createLintStagedConfig.cjs");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pob/root",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "root package",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Christophe Hurpeau <christophe@hurpeau.com> (https://christophe.hurpeau.com)",
|
|
@@ -69,16 +69,16 @@
|
|
|
69
69
|
"prettier": "@pob/root/prettier-config",
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"@commitlint/cli": "18.6.1",
|
|
72
|
-
"@pob/pretty-eslint-config": "5.4.
|
|
73
|
-
"@pob/pretty-pkg": "7.1.
|
|
72
|
+
"@pob/pretty-eslint-config": "5.4.1",
|
|
73
|
+
"@pob/pretty-pkg": "7.1.1",
|
|
74
74
|
"conventional-changelog-conventionalcommits": "^7.0.0",
|
|
75
75
|
"cosmiconfig": "^8.3.6",
|
|
76
76
|
"husky": "~9.0.11",
|
|
77
77
|
"json5": "^2.2.2",
|
|
78
78
|
"lint-staged": "15.2.2",
|
|
79
|
-
"pob-dependencies": "11.
|
|
79
|
+
"pob-dependencies": "11.3.1",
|
|
80
80
|
"prettier": "2.8.8",
|
|
81
|
-
"repository-check-dirty": "6.3.
|
|
81
|
+
"repository-check-dirty": "6.3.3",
|
|
82
82
|
"semver": "^7.3.7",
|
|
83
83
|
"which-pm-runs": "1.1.0"
|
|
84
84
|
}
|
package/prettier-config.cjs
CHANGED
|
@@ -1,27 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
|
-
trailingComma: 'all',
|
|
5
|
-
singleQuote: true,
|
|
6
|
-
// https://github.com/airbnb/javascript/pull/1863
|
|
7
|
-
arrowParens: 'always',
|
|
8
|
-
|
|
9
4
|
overrides: [
|
|
10
5
|
// use json-stringify for lerna.json as lerna will reformat it on new version
|
|
11
6
|
{
|
|
12
|
-
files: [
|
|
13
|
-
options: {
|
|
14
|
-
parser: 'json-stringify',
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
files: ['*.yml'],
|
|
7
|
+
files: ["lerna.json"],
|
|
19
8
|
options: {
|
|
20
|
-
|
|
9
|
+
parser: "json-stringify",
|
|
21
10
|
},
|
|
22
11
|
},
|
|
23
12
|
{
|
|
24
|
-
files: [
|
|
13
|
+
files: [".yarnrc.yml"],
|
|
25
14
|
options: {
|
|
26
15
|
printWidth: 9999,
|
|
27
16
|
},
|