@yorozu/build 0.3.1 → 0.5.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.
@@ -0,0 +1,32 @@
1
+ import { SpawnOptions } from 'node:child_process';
2
+ import { WorkspacePackage } from '../../package-json/collect-package-jsons';
3
+ import { ExecResult } from '../../misc/exec';
4
+ import { bc } from './_utils';
5
+ export interface TypecheckPackageResult {
6
+ name: string;
7
+ path: string;
8
+ ok: boolean;
9
+ output: string;
10
+ }
11
+ export interface TypecheckResult {
12
+ ok: boolean;
13
+ results: Array<TypecheckPackageResult>;
14
+ }
15
+ export type TypecheckExists = (file: string) => Promise<boolean>;
16
+ export type TypecheckRun = (cmd: Array<string>, options?: SpawnOptions & {
17
+ throwOnError?: boolean;
18
+ quiet?: boolean;
19
+ }) => Promise<ExecResult>;
20
+ export declare function typecheckTargets(packages: Array<WorkspacePackage>, exists?: TypecheckExists): Promise<Array<WorkspacePackage>>;
21
+ export declare function typecheckWorkspace(params: {
22
+ packages: Array<WorkspacePackage>;
23
+ exists?: TypecheckExists;
24
+ run?: TypecheckRun;
25
+ }): Promise<TypecheckResult>;
26
+ export declare let typecheckCli: bc.Command<{
27
+ workspace: string | undefined;
28
+ noErrorCode: boolean;
29
+ }, {
30
+ workspace: string | undefined;
31
+ noErrorCode: boolean;
32
+ }>;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@yorozu/build",
3
3
  "type": "module",
4
- "version": "0.3.1",
4
+ "version": "0.5.0",
5
5
  "description": "build and release utilities for yorozu packages",
6
6
  "license": "MIT",
7
7
  "dependencies": {
8
8
  "@drizzle-team/brocli": "0.12.0",
9
- "@yorozu/utils": "^0.3.1",
9
+ "@yorozu/utils": "^0.5.0",
10
10
  "cross-spawn": "7.0.6",
11
11
  "detect-indent": "7.0.2",
12
12
  "esbuild": "0.25.12",
package/yorozu-build.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import { asNonNull, collectPackageJsons, error, filterPackageJsonsForPublish, findRootPackage, getWorkspaceRoot, info, parallelMap, warn } from "./chunks/Boit7C7A.js";
2
+ import { asNonNull, collectPackageJsons, error, fileExists, filterPackageJsonsForPublish, findRootPackage, getWorkspaceRoot, info, parallelMap, warn } from "./chunks/Boit7C7A.js";
3
3
  import { boolean, buildPackageCli, bumpVersion, command, createGithubRelease, findProjectChangedPackages, generateChangelog, generateDepsGraphCli, generateDocsCli, getCommitsBetween, getLatestTag, gitTagExists, isRunningInGithubActions, loadConfig, publishPackages, publishPackagesCli, resolveWorkspaceRoot, run, runContinuousReleaseCli, string, validatePreferProtected, validateWorkspaceDeps, writeGithubActionsOutput } from "./chunks/D0lp9Y4h.js";
4
4
  import { ExecError, exec, sortWorkspaceByPublishOrder } from "./chunks/C8taqIWx.js";
5
5
  import { generateDenoWorkspace, jsrCreatePackages, populateFromUpstream } from "./chunks/DOprhwii.js";
6
6
  import process from "node:process";
7
- import { basename } from "node:path";
7
+ import { basename, join } from "node:path";
8
8
  import { readFile } from "node:fs/promises";
9
9
  //#region src/cli/commands/lint/index.ts
10
10
  var INTERNAL_MESSAGES = {
@@ -58,6 +58,70 @@ function reportMemberErrors(errors) {
58
58
  }
59
59
  }
60
60
  //#endregion
61
+ //#region src/cli/commands/typecheck.ts
62
+ async function typecheckTargets(packages, exists = fileExists) {
63
+ let targets = [];
64
+ for (let item of packages) {
65
+ if (item.root) continue;
66
+ if (!await exists(join(item.path, "tsconfig.json"))) continue;
67
+ targets.push(item);
68
+ }
69
+ return targets;
70
+ }
71
+ async function typecheckWorkspace(params) {
72
+ let run = params.run ?? exec;
73
+ let targets = await typecheckTargets(params.packages, params.exists);
74
+ let results = [];
75
+ for (let item of targets) {
76
+ let spawned = await run([
77
+ "npx",
78
+ "tsc",
79
+ "--noEmit",
80
+ "--pretty",
81
+ "false",
82
+ "-p",
83
+ "tsconfig.json"
84
+ ], {
85
+ cwd: item.path,
86
+ throwOnError: false
87
+ });
88
+ let output = `${spawned.stdout}${spawned.stderr}`;
89
+ results.push({
90
+ name: asNonNull(item.json.name),
91
+ path: item.path,
92
+ ok: spawned.exitCode === 0,
93
+ output
94
+ });
95
+ }
96
+ return {
97
+ ok: results.every((item) => item.ok),
98
+ results
99
+ };
100
+ }
101
+ var typecheckCli = command({
102
+ name: "typecheck",
103
+ desc: "run tsc --noEmit for every workspace package",
104
+ options: {
105
+ workspace: string().desc("path to the workspace root (default: cwd)"),
106
+ noErrorCode: boolean("no-error-code").desc("whether to always exit with a zero code").default(false)
107
+ },
108
+ handler: async (args) => {
109
+ let result = await typecheckWorkspace({ packages: await collectPackageJsons(resolveWorkspaceRoot(args.workspace), true) });
110
+ for (let item of result.results) {
111
+ if (item.ok) {
112
+ info(`typecheck ok: ${item.name}`);
113
+ continue;
114
+ }
115
+ error(/* @__PURE__ */ new Error(`typecheck failed: ${item.name}\n${item.output}`));
116
+ }
117
+ if (result.ok) {
118
+ info("all packages typecheck");
119
+ return;
120
+ }
121
+ if (!args.noErrorCode) process.exit(1);
122
+ }
123
+ });
124
+ //#endregion
61
125
  //#region src/cli/commands/bump-version.ts
62
126
  function sharedWorkspaceBumpOptions(params) {
63
127
  return {
@@ -220,6 +284,7 @@ async function nextDateTag(root) {
220
284
  //#region src/cli/main.ts
221
285
  await run([
222
286
  lintCli,
287
+ typecheckCli,
223
288
  buildPackageCli,
224
289
  publishPackagesCli,
225
290
  bumpVersionCli,