pob 29.8.0 → 30.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 +37 -0
- package/lib/generators/app/PobAppGenerator.js +10 -6
- package/lib/generators/app/ignorePaths.js +2 -1
- package/lib/generators/common/format-lint/CommonLintGenerator.js +18 -14
- package/lib/generators/common/format-lint/templates/prettierignore.ejs +1 -4
- package/lib/generators/common/husky/CommonHuskyGenerator.js +8 -11
- package/lib/generators/common/old-dependencies/CommonRemoveOldDependenciesGenerator.js +1 -0
- package/lib/generators/common/release/CommonReleaseGenerator.js +0 -7
- package/lib/generators/common/release/templates/workflow-release.yml.ejs +8 -12
- package/lib/generators/common/testing/CommonTestingGenerator.js +17 -85
- package/lib/generators/common/typescript/CommonTypescriptGenerator.js +1 -1
- package/lib/generators/core/ci/CoreCIGenerator.js +0 -36
- package/lib/generators/core/ci/templates/github-action-documentation-workflow.yml.ejs +6 -3
- package/lib/generators/core/ci/templates/github-action-push-workflow-split.yml.ejs +9 -5
- package/lib/generators/core/ci/templates/github-action-push-workflow.yml.ejs +8 -4
- package/lib/generators/core/yarn/CoreYarnGenerator.js +2 -2
- package/lib/generators/lib/PobLibGenerator.js +1 -4
- package/lib/generators/monorepo/PobMonorepoGenerator.js +41 -30
- package/lib/generators/monorepo/lerna/MonorepoLernaGenerator.js +12 -25
- package/lib/generators/monorepo/workspaces/MonorepoWorkspacesGenerator.js +6 -10
- package/lib/generators/pob/PobBaseGenerator.js +1 -1
- package/lib/utils/packageDependencyDescriptorUtils.js +52 -0
- package/lib/utils/packageDependencyDescriptorUtils.ts.backup +79 -0
- package/lib/utils/workspaceUtils.js +131 -0
- package/lib/utils/workspaceUtils.test.js +134 -0
- package/lib/utils/workspaceUtils.ts.backup +167 -0
- package/package.json +5 -9
- package/lib/generators/common/husky/templates/lint-staged.config.cjs.txt +0 -5
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
3
|
+
import { glob } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import type { PackageJson } from "type-fest";
|
|
6
|
+
import {
|
|
7
|
+
PackageDependencyDescriptorUtils,
|
|
8
|
+
PackageDescriptorNameUtils,
|
|
9
|
+
} from "./packageDependencyDescriptorUtils";
|
|
10
|
+
import type { PackageDependencyDescriptor } from "./packageDependencyDescriptorUtils.ts";
|
|
11
|
+
|
|
12
|
+
export interface Workspace {
|
|
13
|
+
name?: string;
|
|
14
|
+
location: string;
|
|
15
|
+
manifest: { raw: PackageJson };
|
|
16
|
+
relativeCwd: { toString: () => string };
|
|
17
|
+
isRoot?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const getWorkspaceName = (workspace: Workspace): string => {
|
|
21
|
+
if (workspace?.manifest?.raw?.name) return workspace.manifest.raw.name;
|
|
22
|
+
return path.basename(workspace.location) || "unnamed-workspace";
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type DependencyType =
|
|
26
|
+
| "dependencies"
|
|
27
|
+
| "devDependencies"
|
|
28
|
+
| "peerDependencies";
|
|
29
|
+
|
|
30
|
+
type WorkspacesDependenciesMap = Map<
|
|
31
|
+
Workspace,
|
|
32
|
+
[Workspace, DependencyType, PackageDependencyDescriptor][]
|
|
33
|
+
>;
|
|
34
|
+
|
|
35
|
+
export const discoverWorkspaces = async (
|
|
36
|
+
rootPath: string,
|
|
37
|
+
): Promise<Workspace[]> => {
|
|
38
|
+
const rootPackageJSONPath = path.join(rootPath, "package.json");
|
|
39
|
+
const rootPkg: PackageJson = JSON.parse(fs.readFileSync(rootPackageJSONPath));
|
|
40
|
+
|
|
41
|
+
let workspaceGlobs: string[] = [];
|
|
42
|
+
if (Array.isArray((rootPkg as any).workspaces)) {
|
|
43
|
+
workspaceGlobs = (rootPkg as any).workspaces;
|
|
44
|
+
} else if (typeof (rootPkg as any).workspaces === "object") {
|
|
45
|
+
workspaceGlobs = (rootPkg as any).workspaces.packages || [];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// include root as workspace
|
|
49
|
+
const workspaces: Workspace[] = [
|
|
50
|
+
{
|
|
51
|
+
name: rootPkg.name,
|
|
52
|
+
location: ".",
|
|
53
|
+
manifest: { raw: rootPkg },
|
|
54
|
+
relativeCwd: { toString: () => "." },
|
|
55
|
+
isRoot: true,
|
|
56
|
+
} as Workspace,
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
const patternPackageJsons = workspaceGlobs.map((globPattern) =>
|
|
60
|
+
path.join(globPattern, "package.json"),
|
|
61
|
+
);
|
|
62
|
+
const found = new Set<string>();
|
|
63
|
+
for (const pattern of patternPackageJsons) {
|
|
64
|
+
for await (const match of glob(pattern, { cwd: rootPath, nodir: true })) {
|
|
65
|
+
if (found.has(match)) continue;
|
|
66
|
+
found.add(match);
|
|
67
|
+
const filePath = path.join(rootPath, match);
|
|
68
|
+
const content = JSON.parse(fs.readFileSync(filePath));
|
|
69
|
+
const dir = path.dirname(match);
|
|
70
|
+
workspaces.push({
|
|
71
|
+
name: content.name,
|
|
72
|
+
location: dir || ".",
|
|
73
|
+
manifest: { raw: content },
|
|
74
|
+
relativeCwd: { toString: () => dir || "." },
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return workspaces;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const buildDependenciesMaps = (
|
|
83
|
+
workspaces: Workspace[],
|
|
84
|
+
): WorkspacesDependenciesMap => {
|
|
85
|
+
const dependenciesMap: WorkspacesDependenciesMap = new Map();
|
|
86
|
+
|
|
87
|
+
const workspacesByName = new Map<string, Workspace>(
|
|
88
|
+
workspaces.filter((w) => !!w.name).map((w) => [w.name, w]),
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
const dependencyTypes: DependencyType[] = [
|
|
92
|
+
"dependencies",
|
|
93
|
+
"devDependencies",
|
|
94
|
+
"peerDependencies",
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
for (const dependent of workspaces) {
|
|
98
|
+
for (const set of dependencyTypes) {
|
|
99
|
+
const deps = (dependent.manifest.raw as any)[set] || {};
|
|
100
|
+
for (const [dependencyKey, dependencyValue] of Object.entries(deps)) {
|
|
101
|
+
if (!dependencyValue) continue;
|
|
102
|
+
const descriptor = PackageDependencyDescriptorUtils.parse(
|
|
103
|
+
dependencyKey,
|
|
104
|
+
String(dependencyValue),
|
|
105
|
+
);
|
|
106
|
+
const workspace = workspacesByName.get(descriptor.npmName);
|
|
107
|
+
if (!workspace) continue;
|
|
108
|
+
|
|
109
|
+
const entries = dependenciesMap.get(dependent) || [];
|
|
110
|
+
entries.push([workspace, set, descriptor]);
|
|
111
|
+
dependenciesMap.set(dependent, entries);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return dependenciesMap;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export const buildTopologicalOrderBatches = (
|
|
120
|
+
workspaces: Workspace[],
|
|
121
|
+
dependenciesMap: WorkspacesDependenciesMap,
|
|
122
|
+
): Workspace[][] => {
|
|
123
|
+
const batches: Workspace[][] = [];
|
|
124
|
+
|
|
125
|
+
const added = new Set<Workspace>();
|
|
126
|
+
const toAdd = new Set<Workspace>(workspaces);
|
|
127
|
+
|
|
128
|
+
while (toAdd.size > 0) {
|
|
129
|
+
const batch = new Set<Workspace>();
|
|
130
|
+
for (const workspace of toAdd) {
|
|
131
|
+
// skip root workspace until the end when there are others
|
|
132
|
+
if (workspace.isRoot && toAdd.size > 1) continue;
|
|
133
|
+
|
|
134
|
+
const dependencies = dependenciesMap.get(workspace);
|
|
135
|
+
if (!dependencies || dependencies.every((w) => added.has(w[0]))) {
|
|
136
|
+
batch.add(workspace);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
for (const workspace of batch) {
|
|
141
|
+
added.add(workspace);
|
|
142
|
+
toAdd.delete(workspace);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (batch.size === 0) {
|
|
146
|
+
throw new Error("Circular dependency detected");
|
|
147
|
+
}
|
|
148
|
+
batches.push([...batch]);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return batches;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export const buildDependentsMaps = (
|
|
155
|
+
workspaces: Workspace[],
|
|
156
|
+
): WorkspacesDependenciesMap => {
|
|
157
|
+
const dependentsMap: WorkspacesDependenciesMap = new Map();
|
|
158
|
+
const dependenciesMap = buildDependenciesMaps(workspaces);
|
|
159
|
+
for (const [dependent, relations] of dependenciesMap) {
|
|
160
|
+
for (const [workspace, set, descriptor] of relations) {
|
|
161
|
+
const cmd = dependentsMap.get(workspace) || [];
|
|
162
|
+
cmd.push([dependent, set, descriptor]);
|
|
163
|
+
dependentsMap.set(workspace, cmd);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return dependentsMap;
|
|
167
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pob",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "30.0.0",
|
|
4
4
|
"description": "Pile of bones, library generator with git/babel/typescript/typedoc/readme/jest",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"skeleton"
|
|
@@ -50,16 +50,13 @@
|
|
|
50
50
|
"@pob/sort-pkg": "12.1.0",
|
|
51
51
|
"@prettier/sync": "0.6.1",
|
|
52
52
|
"@types/inquirer": "9.0.9",
|
|
53
|
-
"@yarnpkg/cli": "4.10.3",
|
|
54
|
-
"@yarnpkg/core": "4.4.4",
|
|
55
|
-
"@yarnpkg/fslib": "3.1.3",
|
|
56
53
|
"@yeoman/adapter": "3.1.0",
|
|
57
54
|
"@yeoman/types": "1.8.0",
|
|
58
55
|
"eslint": "9.39.1",
|
|
59
56
|
"findup-sync": "^5.0.0",
|
|
60
57
|
"git-remote-url": "^1.0.1",
|
|
61
58
|
"github-username": "^9.0.0",
|
|
62
|
-
"js-yaml": "^4.1.
|
|
59
|
+
"js-yaml": "^4.1.1",
|
|
63
60
|
"json5": "^2.2.3",
|
|
64
61
|
"lodash.camelcase": "^4.3.0",
|
|
65
62
|
"lodash.kebabcase": "^4.1.1",
|
|
@@ -67,17 +64,16 @@
|
|
|
67
64
|
"mem-fs-editor": "11.1.4",
|
|
68
65
|
"minimist": "1.2.8",
|
|
69
66
|
"parse-author": "2.0.0",
|
|
70
|
-
"pob-dependencies": "
|
|
67
|
+
"pob-dependencies": "21.0.0",
|
|
71
68
|
"prettier": "3.6.2",
|
|
72
69
|
"semver": "7.7.3",
|
|
73
70
|
"typescript": "5.9.3",
|
|
74
71
|
"validate-npm-package-name": "^6.0.2",
|
|
75
|
-
"yarn-workspace-utils": "9.4.1",
|
|
76
72
|
"yeoman-environment": "5.0.0",
|
|
77
73
|
"yeoman-generator": "7.5.1"
|
|
78
74
|
},
|
|
79
75
|
"devDependencies": {
|
|
80
|
-
"@pob/root": "
|
|
81
|
-
"@types/node": "22.19.
|
|
76
|
+
"@pob/root": "20.0.0",
|
|
77
|
+
"@types/node": "22.19.1"
|
|
82
78
|
}
|
|
83
79
|
}
|