@getjack/jack 0.1.11 → 0.1.12
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/package.json +1 -1
- package/src/lib/build-helper.ts +16 -1
- package/src/lib/project-operations.ts +32 -2
package/package.json
CHANGED
package/src/lib/build-helper.ts
CHANGED
|
@@ -7,6 +7,19 @@ import { JackError, JackErrorCode } from "./errors.ts";
|
|
|
7
7
|
import { parseJsonc } from "./jsonc.ts";
|
|
8
8
|
import type { OperationReporter } from "./project-operations.ts";
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Get the wrangler config file path for a project
|
|
12
|
+
*/
|
|
13
|
+
function getWranglerConfigPath(projectPath: string): string | null {
|
|
14
|
+
const configs = ["wrangler.jsonc", "wrangler.toml", "wrangler.json"];
|
|
15
|
+
for (const config of configs) {
|
|
16
|
+
if (existsSync(join(projectPath, config))) {
|
|
17
|
+
return config;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
10
23
|
export interface BuildOutput {
|
|
11
24
|
outDir: string;
|
|
12
25
|
entrypoint: string;
|
|
@@ -195,7 +208,9 @@ export async function buildProject(options: BuildOptions): Promise<BuildOutput>
|
|
|
195
208
|
// Run wrangler dry-run to build without deploying
|
|
196
209
|
reporter?.start("Bundling runtime...");
|
|
197
210
|
|
|
198
|
-
const
|
|
211
|
+
const configFile = getWranglerConfigPath(projectPath);
|
|
212
|
+
const configArg = configFile ? ["--config", configFile] : [];
|
|
213
|
+
const dryRunResult = await $`wrangler deploy ${configArg} --dry-run --outdir=${outDir}`
|
|
199
214
|
.cwd(projectPath)
|
|
200
215
|
.nothrow()
|
|
201
216
|
.quiet();
|
|
@@ -168,6 +168,36 @@ const noopReporter: OperationReporter = {
|
|
|
168
168
|
box() {},
|
|
169
169
|
};
|
|
170
170
|
|
|
171
|
+
/**
|
|
172
|
+
* Get the wrangler config file path for a project
|
|
173
|
+
* Returns the first found: wrangler.jsonc, wrangler.toml, wrangler.json
|
|
174
|
+
*/
|
|
175
|
+
function getWranglerConfigPath(projectPath: string): string | null {
|
|
176
|
+
const configs = ["wrangler.jsonc", "wrangler.toml", "wrangler.json"];
|
|
177
|
+
for (const config of configs) {
|
|
178
|
+
if (existsSync(join(projectPath, config))) {
|
|
179
|
+
return config;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Run wrangler deploy with explicit config to avoid parent directory conflicts
|
|
187
|
+
*/
|
|
188
|
+
async function runWranglerDeploy(
|
|
189
|
+
projectPath: string,
|
|
190
|
+
options: { dryRun?: boolean; outDir?: string } = {},
|
|
191
|
+
) {
|
|
192
|
+
const configFile = getWranglerConfigPath(projectPath);
|
|
193
|
+
const configArg = configFile ? ["--config", configFile] : [];
|
|
194
|
+
const dryRunArgs = options.dryRun
|
|
195
|
+
? ["--dry-run", ...(options.outDir ? ["--outdir", options.outDir] : [])]
|
|
196
|
+
: [];
|
|
197
|
+
|
|
198
|
+
return await $`wrangler deploy ${configArg} ${dryRunArgs}`.cwd(projectPath).nothrow().quiet();
|
|
199
|
+
}
|
|
200
|
+
|
|
171
201
|
/**
|
|
172
202
|
* Run bun install and managed project creation in parallel.
|
|
173
203
|
* Handles partial failures with cleanup.
|
|
@@ -1072,7 +1102,7 @@ export async function createProject(
|
|
|
1072
1102
|
|
|
1073
1103
|
reporter.start("Deploying...");
|
|
1074
1104
|
|
|
1075
|
-
const deployResult = await
|
|
1105
|
+
const deployResult = await runWranglerDeploy(targetDir);
|
|
1076
1106
|
|
|
1077
1107
|
if (deployResult.exitCode !== 0) {
|
|
1078
1108
|
reporter.stop();
|
|
@@ -1357,7 +1387,7 @@ export async function deployProject(options: DeployOptions = {}): Promise<Deploy
|
|
|
1357
1387
|
}
|
|
1358
1388
|
|
|
1359
1389
|
const spin = reporter.spinner("Deploying...");
|
|
1360
|
-
const result = await
|
|
1390
|
+
const result = await runWranglerDeploy(projectPath);
|
|
1361
1391
|
|
|
1362
1392
|
if (result.exitCode !== 0) {
|
|
1363
1393
|
spin.error("Deploy failed");
|