typescript-bedrock 0.1.0 → 0.1.2

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.
@@ -8,10 +8,11 @@ mod? typescript ".just/typescript.just"
8
8
  mod? rust ".just/rust.just"
9
9
  mod? swift ".just/swift.just"
10
10
  mod? cpp ".just/cpp.just"
11
+ mod? jvm ".just/jvm.just"
11
12
 
12
13
  import? "project.just"
13
14
 
14
- languages := "typescript rust swift cpp"
15
+ languages := "typescript rust swift cpp jvm"
15
16
 
16
17
  # List the recipes.
17
18
  default:
@@ -4,5 +4,5 @@
4
4
  "compilerOptions": {
5
5
  "rootDir": "."
6
6
  },
7
- "exclude": ["**/.build", "**/coverage", "**/dist", "**/target"]
7
+ "exclude": ["**/.build", "**/build", "**/coverage", "**/dist", "**/target"]
8
8
  }
package/oxlintrc.json CHANGED
@@ -339,6 +339,12 @@
339
339
  "import/no-default-export": "off"
340
340
  }
341
341
  },
342
+ {
343
+ "files": ["**/src/theme/**"],
344
+ "rules": {
345
+ "import/no-default-export": "off"
346
+ }
347
+ },
342
348
  {
343
349
  "files": ["**/*.d.{ts,mts,cts}"],
344
350
  "rules": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typescript-bedrock",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Strictest Bun + TypeScript 7 tooling: shared configs, git hooks, a guard, and an adopt command.",
5
5
  "license": "MIT",
6
6
  "author": "xsyetopz",
@@ -28,7 +28,7 @@
28
28
  "eslint-plugin-jsdoc": "65.4.5",
29
29
  "markdownlint-cli2": "0.24.0",
30
30
  "markdownlint-rule-title-case-style": "0.4.3",
31
- "oxlint": "1.91.0",
31
+ "oxlint": "1.93.0",
32
32
  "oxlint-tsgolint": "7.0.2006",
33
33
  "typescript": "7.0.2"
34
34
  },
@@ -17,6 +17,7 @@ const ORDER = [
17
17
  "rust-bedrock",
18
18
  "swift-bedrock",
19
19
  "swift-bedrock-cxx",
20
+ "jvm-bedrock",
20
21
  ];
21
22
 
22
23
  /** Where the first line starting with `marker` begins in `text`, or -1. */
@@ -1,5 +1,6 @@
1
1
  import { join } from "node:path";
2
2
 
3
+ import { listFiles } from "../files.ts";
3
4
  import type { Step } from "./steps.ts";
4
5
 
5
6
  const TEST_FILES = new Bun.Glob(
@@ -39,18 +40,15 @@ export const migrateTestFile = (text: string): string => {
39
40
  : text;
40
41
  };
41
42
 
42
- /** Rewrites each test file outside node_modules that is not on bun:test yet. */
43
+ /** Rewrites each test file outside node_modules and git's ignored files that is not on bun:test yet. */
43
44
  export const testSteps = async (target: string): Promise<Step[]> => {
44
- const steps: Step[] = [];
45
- for await (const path of TEST_FILES.scan({ cwd: target, dot: false })) {
46
- if (path.split("/").includes("node_modules")) {
47
- continue;
48
- }
49
- const text = await Bun.file(join(target, path)).text();
45
+ const paths = await listFiles(target, TEST_FILES);
46
+ const texts = await Promise.all(
47
+ paths.map((path) => Bun.file(join(target, path)).text()),
48
+ );
49
+ return paths.flatMap((path, index): Step[] => {
50
+ const text = texts[index] ?? "";
50
51
  const content = migrateTestFile(text);
51
- if (content !== text) {
52
- steps.push({ kind: "write", path, content });
53
- }
54
- }
55
- return steps;
52
+ return content === text ? [] : [{ kind: "write", path, content }];
53
+ });
56
54
  };
@@ -23,8 +23,17 @@ const REMOVED_OPTIONS = new Set([
23
23
  /** Project facts the base config cannot know. */
24
24
  const PROJECT_OPTIONS = new Set(["jsx", "lib", "types"]);
25
25
  const BASE_FILE = "typescript-bedrock/tsconfig.base.json";
26
- /** Build output a repo can hold: Bun's, Rust's (`cargo doc` writes JavaScript), and SwiftPM's. */
27
- const GENERATED_DIRS = ["**/.build", "**/coverage", "**/dist", "**/target"];
26
+ /**
27
+ * Build output a repo can hold: Bun's, Rust's (`cargo doc` writes JavaScript), SwiftPM's, and
28
+ * Gradle's (its test reports are JavaScript).
29
+ */
30
+ const GENERATED_DIRS = [
31
+ "**/.build",
32
+ "**/build",
33
+ "**/coverage",
34
+ "**/dist",
35
+ "**/target",
36
+ ];
28
37
  const EMIT_OPTIONS = [
29
38
  "composite",
30
39
  "declaration",
package/src/files.ts ADDED
@@ -0,0 +1,23 @@
1
+ import { join } from "node:path";
2
+
3
+ import { $, type Glob } from "bun";
4
+
5
+ /** The files under `cwd` that match `glob`, without the ones git ignores and without node_modules. */
6
+ export const listFiles = async (cwd: string, glob: Glob): Promise<string[]> => {
7
+ const git = await $`git ls-files --cached --others --exclude-standard`
8
+ .cwd(cwd)
9
+ .nothrow()
10
+ .quiet();
11
+ const listed = (
12
+ git.exitCode === 0
13
+ ? git.stdout.toString().split("\n")
14
+ : await Array.fromAsync(glob.scan({ cwd }))
15
+ ).filter(
16
+ (path) => glob.match(path) && !path.split("/").includes("node_modules"),
17
+ );
18
+ // The index still lists a file deleted since the last commit.
19
+ const present = await Promise.all(
20
+ listed.map((path) => Bun.file(join(cwd, path)).exists()),
21
+ );
22
+ return listed.filter((_, index) => present[index] === true);
23
+ };
package/src/guard.ts CHANGED
@@ -4,6 +4,7 @@ import { fileURLToPath } from "node:url";
4
4
  import { $, Glob } from "bun";
5
5
 
6
6
  import { planAdoption, PROJECT_FILES } from "./adopt/adopt.ts";
7
+ import { listFiles } from "./files.ts";
7
8
 
8
9
  // Written as alternations so this file does not match itself.
9
10
  const SUPPRESSION =
@@ -40,25 +41,6 @@ const FOREIGN_FILES = [
40
41
  "yarn.lock",
41
42
  ];
42
43
 
43
- const listFiles = async (cwd: string, glob: Glob): Promise<string[]> => {
44
- const git = await $`git ls-files --cached --others --exclude-standard`
45
- .cwd(cwd)
46
- .nothrow()
47
- .quiet();
48
- const listed = (
49
- git.exitCode === 0
50
- ? git.stdout.toString().split("\n")
51
- : await Array.fromAsync(glob.scan({ cwd }))
52
- ).filter(
53
- (path) => glob.match(path) && !path.split("/").includes("node_modules"),
54
- );
55
- // The index still lists a file deleted since the last commit.
56
- const present = await Promise.all(
57
- listed.map((path) => Bun.file(join(cwd, path)).exists()),
58
- );
59
- return listed.filter((_, index) => present[index] === true);
60
- };
61
-
62
44
  export const findSuppressions = async (
63
45
  cwd: string,
64
46
  paths: readonly string[],