pob 35.6.0 → 35.7.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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  </h1>
4
4
 
5
5
  <p align="center">
6
- Pile of bones, library generator with git/babel/typescript/typedoc/readme/jest
6
+ Pile of bones, library generator with git/babel/typescript/typedoc/readme/vitest
7
7
  </p>
8
8
 
9
9
  <p align="center">
@@ -28,30 +28,11 @@ You can now use `yarn run watch` !
28
28
 
29
29
  ### How this works
30
30
 
31
- #### Babel
32
-
33
- Write code in the `src` directory, it's then transpiled with babel and rollup to `dist`.
34
- Use the task `yarn run build` or `yarn run watch` to transpile the code.
35
-
36
- There are several environments: `node`, `browser`.
37
- For each of these environments, there is also a `dev` version that add flow runtime checks.
38
-
39
31
  #### Coding Rules
40
32
 
41
33
  Eslint is used to ensure a common coding style. I mostly follow the [Airbnb coding style](https://github.com/airbnb/javascript/blob/master/README.md).
42
34
  You can check the code by running the task `yarn run lint`. With an editor, install the plugins to validate the code as you type !
43
35
 
44
- #### Documentation
45
-
46
- [typedoc](https://typedoc.org/) allows to document the code and generate the api.
47
- [jest](https://www.npmjs.com/package/jest) is used to generate the coverage.
48
-
49
- Documentation can be generated by github actions and pushed to github-pages.
50
-
51
- #### Tests
52
-
53
- Tests are in the directory `src` with jest. Use the task `yarn test` to run the tests with jest.
54
-
55
36
  ### Available tasks with `yarn run`
56
37
 
57
38
  #### Code, Transpile, Lint
@@ -59,7 +40,7 @@ Tests are in the directory `src` with jest. Use the task `yarn test` to run the
59
40
  - `build`: `clean` the directory, build `src` to `dist` with rollup
60
41
  - `watch`: `clean` then build and watch with rollup
61
42
  - `lint`: execute `eslint`
62
- - `test`: run tests with jest
43
+ - `test`: run tests
63
44
 
64
45
  ### Generate documentation
65
46
 
@@ -304,6 +304,12 @@ export default class CommonBabelGenerator extends Generator {
304
304
  (env) => env.target === "browser",
305
305
  );
306
306
 
307
+ if (useBabel) {
308
+ throw new Error(
309
+ "pob-babel is deprecated. Use @pob/rollup-esbuild or @pob/rollup-typescript instead.",
310
+ );
311
+ }
312
+
307
313
  /* dependencies */
308
314
 
309
315
  if (
@@ -324,11 +330,6 @@ export default class CommonBabelGenerator extends Generator {
324
330
  if (pkg.dependencies && pkg.dependencies["pob-babel"]) {
325
331
  throw new Error("pob-babel is deprecated.");
326
332
  }
327
- if (pkg.dependencies && pkg.dependencies["@babel/runtime"]) {
328
- // update pob-babel in alp-dev
329
- packageUtils.addDependencies(pkg, ["@babel/runtime"], "^");
330
- }
331
-
332
333
  const isLibraryRollupPlugin = pkg.name.includes("rollup-plugin");
333
334
 
334
335
  packageUtils.addOrRemoveDevDependencies(
@@ -440,13 +441,7 @@ export default class CommonBabelGenerator extends Generator {
440
441
  this.fs.delete(".babelrc");
441
442
  this.fs.delete("babel.config.json");
442
443
  this.fs.delete("babel.config.mjs");
443
- if (this.fs.exists(this.destinationPath("babel.config.js"))) {
444
- this.fs.move(
445
- this.destinationPath("babel.config.js"),
446
- this.destinationPath("babel.config.cjs"),
447
- );
448
- }
449
-
444
+ this.fs.delete("babel.config.js");
450
445
  this.fs.writeJSON(this.destinationPath("package.json"), pkg);
451
446
  }
452
447
  }
@@ -30,7 +30,7 @@ export default class CommonTestingGenerator extends Generator {
30
30
  this.option("runner", {
31
31
  type: String,
32
32
  default: "node",
33
- description: "test runner (jest or node)",
33
+ description: "test runner (vitest or node)",
34
34
  });
35
35
 
36
36
  this.option("ci", {
@@ -157,14 +157,14 @@ export default class CommonTestingGenerator extends Generator {
157
157
  (inMonorepo && inMonorepo.pobMonorepoConfig) || {};
158
158
  const globalTesting = yoConfigPobMonorepo && yoConfigPobMonorepo.testing;
159
159
  const enableForMonorepo = this.options.monorepo && globalTesting;
160
- const transpileWithEsbuild = packageUtils.transpileWithEsbuild(pkg);
160
+ const transpileWithEsbuild = false;
161
161
  const transpileWithBabel = transpileWithEsbuild
162
162
  ? false
163
163
  : // eslint-disable-next-line unicorn/no-nested-ternary
164
164
  this.options.monorepo
165
165
  ? yoConfigPobMonorepo.typescript &&
166
166
  yoConfigPobMonorepo.typescript !== "check-only"
167
- : packageUtils.transpileWithBabel(pkg);
167
+ : false;
168
168
  const withTypescript =
169
169
  transpileWithBabel ||
170
170
  pkg.pob?.bundler === "tsc" ||
@@ -389,7 +389,7 @@ export default class CommonTestingGenerator extends Generator {
389
389
  }),
390
390
  "test:coverage:generate": createTestCommand({
391
391
  workspacesPattern,
392
- coverageJson: true,
392
+ coverage: "generate",
393
393
  }),
394
394
  });
395
395
  } else {
@@ -160,7 +160,6 @@ export default class CommonTranspilerGenerator extends Generator {
160
160
  const cleanCommand = (() => {
161
161
  if (bundler === "rollup-typescript") return "pob-typescript-clean-out";
162
162
  if (bundler === "rollup-esbuild") return "pob-esbuild-clean-out";
163
- if (bundler === "rollup-babel") return "pob-babel-clean-out";
164
163
  if (bundler === "esbuild") return "pob-esbuild-clean-out";
165
164
  if (bundler === "tsc") return "rm -Rf";
166
165
  if (bundler) throw new Error(`Invalid bundler: ${bundler}`);
@@ -0,0 +1,81 @@
1
+ import Generator from "yeoman-generator";
2
+ import { writeAndFormatJson } from "../../../utils/writeAndFormat.js";
3
+
4
+ const claudePostToolUseHook = {
5
+ matcher: "Edit|Write|MultiEdit",
6
+ hooks: [{ type: "command", command: "pob-claude-run-lint-staged" }],
7
+ };
8
+
9
+ export default class CoreClaudeGenerator extends Generator {
10
+ constructor(args, opts) {
11
+ super(args, opts);
12
+
13
+ this.option("root", {
14
+ type: Boolean,
15
+ required: false,
16
+ default: true,
17
+ description: "Root package.",
18
+ });
19
+ }
20
+
21
+ async writing() {
22
+ const pkg = this.fs.readJSON(this.destinationPath("package.json"), {});
23
+ const claudeGitignorePath = this.destinationPath(".claude/.gitignore");
24
+ const claudeSettingsPath = this.destinationPath(".claude/settings.json");
25
+
26
+ if (!this.options.root) {
27
+ this.fs.delete(claudeGitignorePath);
28
+ this.fs.delete(claudeSettingsPath);
29
+ return;
30
+ }
31
+
32
+ this.fs.write(
33
+ claudeGitignorePath,
34
+ "/settings.local.json\n/skills/local.*\n",
35
+ );
36
+
37
+ const existing = this.fs.readJSON(claudeSettingsPath, {
38
+ hooks: {
39
+ PostToolUse: [
40
+ {
41
+ matcher: "Edit|Write|MultiEdit",
42
+ hooks: [
43
+ {
44
+ type: "command",
45
+ command:
46
+ pkg.name === "pob-monorepo"
47
+ ? "node ./@pob/root/bin/pob-claude-run-lint-staged.js"
48
+ : "./node_modules/.bin/pob-claude-run-lint-staged",
49
+ },
50
+ ],
51
+ },
52
+ ],
53
+ },
54
+ });
55
+
56
+ // Find or create the PostToolUse hook entry for our matcher
57
+ const postToolUse = existing.hooks?.PostToolUse ?? [];
58
+
59
+ const existingEntry = postToolUse.find(
60
+ (entry) => entry.matcher === claudePostToolUseHook.matcher,
61
+ );
62
+ if (existingEntry) {
63
+ // Add any of our hooks not already present
64
+ for (const hook of claudePostToolUseHook.hooks) {
65
+ if (!existingEntry.hooks?.some((h) => h.command === hook.command)) {
66
+ (existingEntry.hooks ??= []).push(hook);
67
+ }
68
+ }
69
+ } else {
70
+ postToolUse.push(claudePostToolUseHook);
71
+ }
72
+
73
+ await writeAndFormatJson(this.fs, claudeSettingsPath, {
74
+ ...existing,
75
+ hooks: {
76
+ ...existing.hooks,
77
+ PostToolUse: postToolUse,
78
+ },
79
+ });
80
+ }
81
+ }
@@ -37,7 +37,7 @@ export default class CoreVSCodeGenerator extends Generator {
37
37
  this.option("testRunner", {
38
38
  type: String,
39
39
  required: false,
40
- description: "Test runner (jest, vitest, ...)",
40
+ description: "Test runner (node, vitest, ...)",
41
41
  });
42
42
 
43
43
  this.option("yarnNodeLinker", {
@@ -40,12 +40,6 @@
40
40
  "source.organizeImports": "never"
41
41
  },
42
42
 
43
-
44
- <% if (testing && module && (!testRunner || testRunner === 'jest')) { -%>
45
- // jest
46
- "jest.jestCommandLine": "NODE_OPTIONS=--experimental-vm-modules node_modules/.bin/jest",
47
- <% } -%>
48
-
49
43
  // extension eslint config
50
44
  "eslint.workingDirectories": ["."],
51
45
  "eslint.useFlatConfig": true,
@@ -406,12 +406,6 @@ export default class PobMonorepoGenerator extends Generator {
406
406
  build: `${packageManagerRun(this.options.packageManager, "clean:build")} && rollup --config rollup.config.mjs`,
407
407
  watch: `${packageManagerRun(this.options.packageManager, "clean:build")} && rollup --config rollup.config.mjs --watch`,
408
408
  });
409
- packageUtils.addOrRemoveDevDependencies(
410
- pkg,
411
- rollupConfigs.length > 0 &&
412
- (rollupKinds.size === 0 || rollupKinds.has("babel")),
413
- ["@babel/core", "pob-babel"],
414
- );
415
409
 
416
410
  packageUtils.addOrRemoveDevDependencies(pkg, rollupKinds.has("esbuild"), [
417
411
  "@pob/rollup-esbuild",
@@ -63,12 +63,15 @@ export default class MonorepoWorkspacesGenerator extends Generator {
63
63
  writing() {
64
64
  const getPackagePobConfig = (config) => ({
65
65
  babelEnvs: [],
66
+ envs: [],
66
67
  ...(config && config.pob),
67
68
  });
68
69
  const withBundler = this.packages.some((config) => {
69
70
  const pobConfig = getPackagePobConfig(config);
70
71
  return (
71
- pobConfig.babelEnvs.length > 0 || pobConfig.bundler === "rollup-babel"
72
+ pobConfig.envs.length > 0 ||
73
+ pobConfig.babelEnvs.length > 0 ||
74
+ pobConfig.bundler === "rollup-babel"
72
75
  );
73
76
  });
74
77
 
@@ -199,6 +199,10 @@ export default class PobBaseGenerator extends Generator {
199
199
 
200
200
  this.composeWith("pob:core:editorconfig");
201
201
 
202
+ this.composeWith("pob:core:claude", {
203
+ root: this.isRoot,
204
+ });
205
+
202
206
  this.composeWith("pob:core:clean", {
203
207
  root: this.isRoot,
204
208
  });
package/lib/pob.js CHANGED
@@ -24,6 +24,7 @@ import CommonTranspilerGenerator from "./generators/common/transpiler/CommonTran
24
24
  import CommonTypescriptGenerator from "./generators/common/typescript/CommonTypescriptGenerator.js";
25
25
  import CoreBunGenerator from "./generators/core/bun/CoreBunGenerator.js";
26
26
  import CoreCIGenerator from "./generators/core/ci/CoreCIGenerator.js";
27
+ import CoreClaudeGenerator from "./generators/core/claude/CoreClaudeGenerator.js";
27
28
  import CoreCleanGenerator from "./generators/core/clean/CoreCleanGenerator.js";
28
29
  import CoreEditorConfigGenerator from "./generators/core/editorconfig/CoreEditorConfigGenerator.js";
29
30
  import CoreGitGenerator from "./generators/core/git/CoreGitGenerator.js";
@@ -156,6 +157,11 @@ env.registerStub(
156
157
  "pob:core:editorconfig",
157
158
  `${__dirname}/generators/core/editorconfig/CoreEditorConfigGenerator.js`,
158
159
  );
160
+ env.registerStub(
161
+ CoreClaudeGenerator,
162
+ "pob:core:claude",
163
+ `${__dirname}/generators/core/claude/CoreClaudeGenerator.js`,
164
+ );
159
165
  env.registerStub(
160
166
  CoreGitGenerator,
161
167
  "pob:core:git",
@@ -16,32 +16,6 @@ export { default as parseAuthor } from "parse-author";
16
16
  export const parsePkgAuthor = (pkg) =>
17
17
  typeof pkg.author === "string" ? parseAuthor(pkg.author) : pkg.author;
18
18
 
19
- export const hasLerna = (pkg) =>
20
- !!(pkg.devDependencies && pkg.devDependencies.lerna);
21
-
22
- export const hasBabel = (pkg) =>
23
- !!(
24
- pkg.devDependencies &&
25
- (pkg.devDependencies["pob-babel"] || pkg.devDependencies["@babel/core"])
26
- );
27
-
28
- export const transpileWithEsbuild = (pkg) =>
29
- !!(pkg.devDependencies && pkg.devDependencies["jest-esbuild"]);
30
-
31
- export const transpileWithBabel = (pkg) =>
32
- !!(
33
- (pkg.devDependencies &&
34
- (pkg.devDependencies["pob-babel"] ||
35
- pkg.devDependencies.next ||
36
- pkg.devDependencies["@yarnpkg/builder"] ||
37
- pkg.devDependencies["alp-dev"])) ||
38
- // alp-dev has pob-babel in dependencies
39
- (pkg.dependencies &&
40
- (pkg.dependencies["pob-babel"] ||
41
- pkg.dependencies.next ||
42
- pkg.dependencies["alp-dev"]))
43
- );
44
-
45
19
  export const hasReact = (pkg) =>
46
20
  !!(
47
21
  (pkg.dependencies && pkg.dependencies.react) ||
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pob",
3
- "version": "35.6.0",
4
- "description": "Pile of bones, library generator with git/babel/typescript/typedoc/readme/jest",
3
+ "version": "35.7.0",
4
+ "description": "Pile of bones, library generator with git/babel/typescript/typedoc/readme/vitest",
5
5
  "keywords": [
6
6
  "skeleton"
7
7
  ],
@@ -33,7 +33,7 @@
33
33
  "@types/inquirer": "9.0.10",
34
34
  "@yeoman/adapter": "4.0.2",
35
35
  "@yeoman/types": "1.11.1",
36
- "eslint": "10.4.0",
36
+ "eslint": "10.7.0",
37
37
  "findup-sync": "^5.0.0",
38
38
  "git-remote-url": "^1.0.1",
39
39
  "github-username": "^9.0.0",
@@ -41,7 +41,7 @@
41
41
  "json5": "^2.2.3",
42
42
  "lodash.camelcase": "^4.3.0",
43
43
  "lodash.kebabcase": "^4.1.1",
44
- "mem-fs": "4.1.4",
44
+ "mem-fs": "4.1.5",
45
45
  "mem-fs-editor": "12.0.4",
46
46
  "minimist": "1.2.8",
47
47
  "oxfmt": "0.54.0",
@@ -52,12 +52,12 @@
52
52
  "yeoman-environment": "6.1.0",
53
53
  "yeoman-generator": "8.2.2",
54
54
  "@pob/sort-object": "11.1.1",
55
- "@pob/sort-pkg": "13.1.1",
56
- "pob-dependencies": "24.3.0"
55
+ "pob-dependencies": "24.4.0",
56
+ "@pob/sort-pkg": "13.1.2"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/node": "24.13.3",
60
- "@pob/root": "24.6.0"
60
+ "@pob/root": "24.7.0"
61
61
  },
62
62
  "engines": {
63
63
  "node": ">=22.18.0"
@@ -1,26 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = function babelConfig(api) {
4
- const isTest = api.env('test');
5
-
6
- if (!isTest) return {};
7
-
8
- return {
9
- only: [<%- only %>],
10
- presets: [
11
- ['pob-babel/preset.js', { modules: <%- jestExperimentalESM ? 'false' : "'commonjs'" %> }]
12
- <% if (hasReact) { %>, [
13
- '@babel/preset-react',
14
- {
15
- runtime: 'automatic',
16
- development: false,
17
- useBuiltIns: true,
18
- useSpread: true,
19
- },
20
- ]<% } %>
21
- <% if (hasLinaria) { %>, [
22
- '@linaria/babel-preset'
23
- ]<% } %>
24
- ],
25
- };
26
- };