wp-typia 0.22.6 → 0.22.7

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/bin/wp-typia.js CHANGED
@@ -35,6 +35,24 @@ const buildScriptEntrypoint = path.join(
35
35
  'build-bunli-runtime.ts',
36
36
  );
37
37
  const sourceCliEntrypoint = path.join(packageRoot, 'src', 'cli.ts');
38
+ const sourceCheckoutRoot = path.resolve(packageRoot, '..', '..');
39
+ const sourceProjectToolsPackageRoot = path.resolve(
40
+ packageRoot,
41
+ '..',
42
+ 'wp-typia-project-tools',
43
+ );
44
+ const sourceProjectToolsPackageManifest = path.join(
45
+ sourceProjectToolsPackageRoot,
46
+ 'package.json',
47
+ );
48
+ const sourceProjectToolsRuntimeProbe = path.join(
49
+ sourceProjectToolsPackageRoot,
50
+ 'dist',
51
+ 'runtime',
52
+ 'cli-diagnostics.js',
53
+ );
54
+ const sourceProjectToolsBuildCommand =
55
+ 'bun run --filter @wp-typia/project-tools build';
38
56
  const standaloneGuidance =
39
57
  'Prefer not to install Bun? Use the standalone wp-typia binary from the GitHub release assets.';
40
58
 
@@ -67,7 +85,72 @@ function canAutobuildSourceCheckout() {
67
85
  );
68
86
  }
69
87
 
88
+ function hasMissingSourceProjectToolsRuntime() {
89
+ return (
90
+ canAutobuildSourceCheckout() &&
91
+ fs.existsSync(path.join(sourceCheckoutRoot, 'package.json')) &&
92
+ fs.existsSync(sourceProjectToolsPackageManifest) &&
93
+ !fs.existsSync(sourceProjectToolsRuntimeProbe)
94
+ );
95
+ }
96
+
97
+ function ensureSourceProjectToolsRuntime() {
98
+ if (!hasMissingSourceProjectToolsRuntime()) {
99
+ return true;
100
+ }
101
+
102
+ const relativeProbe = path.relative(
103
+ sourceCheckoutRoot,
104
+ sourceProjectToolsRuntimeProbe,
105
+ );
106
+
107
+ console.error(
108
+ `wp-typia source checkout is missing @wp-typia/project-tools build artifacts (${relativeProbe}).`,
109
+ );
110
+
111
+ if (!isWorkingBunBinary()) {
112
+ console.error(
113
+ `Error: wp-typia cannot rebuild @wp-typia/project-tools because no working Bun binary was found. Run \`${sourceProjectToolsBuildCommand}\` from the repository root after installing Bun, then rerun wp-typia.`,
114
+ );
115
+ process.exit(1);
116
+ }
117
+
118
+ console.error(
119
+ `Running \`${sourceProjectToolsBuildCommand}\` from ${sourceCheckoutRoot} before rebuilding the CLI runtime...`,
120
+ );
121
+
122
+ const buildResult = spawnSync(
123
+ bunBinary,
124
+ ['run', '--filter', '@wp-typia/project-tools', 'build'],
125
+ {
126
+ cwd: sourceCheckoutRoot,
127
+ env: process.env,
128
+ stdio: 'inherit',
129
+ },
130
+ );
131
+
132
+ if (buildResult.status !== 0) {
133
+ console.error(
134
+ `Error: @wp-typia/project-tools build failed. Run \`${sourceProjectToolsBuildCommand}\` from the repository root, then rerun wp-typia.`,
135
+ );
136
+ process.exit(buildResult.status ?? 1);
137
+ }
138
+
139
+ if (fs.existsSync(sourceProjectToolsRuntimeProbe)) {
140
+ return true;
141
+ }
142
+
143
+ console.error(
144
+ `Error: @wp-typia/project-tools build completed but ${relativeProbe} is still missing. Run \`${sourceProjectToolsBuildCommand}\` from the repository root, then rerun wp-typia.`,
145
+ );
146
+ return false;
147
+ }
148
+
70
149
  function ensureBuiltRuntime() {
150
+ if (!ensureSourceProjectToolsRuntime()) {
151
+ return false;
152
+ }
153
+
71
154
  if (fs.existsSync(cliEntrypoint) && fs.existsSync(nodeCliEntrypoint)) {
72
155
  return true;
73
156
  }