Fix bun detection, dev flushing, and init command (#1914)
* update nypm to support text-based bun lockfiles * add nypm changeset * handle dev flushing failures gracefully * fix path normalization for init.ts * add changesets * chore: remove pre.json after exiting pre mode * init command to install v4-beta packages * Revert "chore: remove pre.json after exiting pre mode" This reverts commit f5694fde9314114c74a220c2213d19667bca1a6c. * make init default to cli version for all packages
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"trigger.dev": patch
|
||||
---
|
||||
|
||||
Fix init.ts in custom trigger dirs
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"trigger.dev": patch
|
||||
---
|
||||
|
||||
Init command will now correctly install v4-beta packages
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"trigger.dev": patch
|
||||
---
|
||||
|
||||
Update nypm package to support test-based bun.lock files
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"trigger.dev": patch
|
||||
---
|
||||
|
||||
Handle flush errors gracefully in dev
|
||||
@@ -109,7 +109,7 @@
|
||||
"magicast": "^0.3.4",
|
||||
"minimatch": "^10.0.1",
|
||||
"mlly": "^1.7.1",
|
||||
"nypm": "^0.3.9",
|
||||
"nypm": "^0.5.4",
|
||||
"object-hash": "^3.0.0",
|
||||
"open": "^10.0.3",
|
||||
"p-limit": "^6.2.0",
|
||||
|
||||
@@ -3,7 +3,7 @@ import { DEFAULT_RUNTIME, ResolvedConfig } from "@trigger.dev/core/v3/build";
|
||||
import { BuildManifest, BuildTarget, TaskFile } from "@trigger.dev/core/v3/schemas";
|
||||
import * as esbuild from "esbuild";
|
||||
import { createHash } from "node:crypto";
|
||||
import { join, relative, resolve } from "node:path";
|
||||
import { basename, dirname, join, relative, resolve } from "node:path";
|
||||
import { createFile } from "../utilities/fileSystem.js";
|
||||
import { logger } from "../utilities/logger.js";
|
||||
import { resolveFileSources } from "../utilities/sourceFiles.js";
|
||||
@@ -239,15 +239,18 @@ export async function getBundleResultFromBuild(
|
||||
|
||||
// Check if the entry point is an init.ts file at the root of a trigger directory
|
||||
function isInitEntryPoint(entryPoint: string): boolean {
|
||||
const normalizedEntryPoint = entryPoint.replace(/\\/g, "/"); // Normalize path separators
|
||||
const initFileNames = ["init.ts", "init.mts", "init.cts", "init.js", "init.mjs", "init.cjs"];
|
||||
|
||||
// Check if it's directly in one of the trigger directories
|
||||
return resolvedConfig.dirs.some((dir) => {
|
||||
const normalizedDir = dir.replace(/\\/g, "/");
|
||||
return initFileNames.some(
|
||||
(fileName) => normalizedEntryPoint === `${normalizedDir}/${fileName}`
|
||||
);
|
||||
const normalizedDir = resolve(dir);
|
||||
const normalizedEntryDir = resolve(dirname(entryPoint));
|
||||
|
||||
if (normalizedDir !== normalizedEntryDir) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return initFileNames.includes(basename(entryPoint));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -32,11 +32,15 @@ import { printStandloneInitialBanner } from "../utilities/initialBanner.js";
|
||||
import { logger } from "../utilities/logger.js";
|
||||
import { spinner } from "../utilities/windows.js";
|
||||
import { login } from "./login.js";
|
||||
import { VERSION } from "../version.js";
|
||||
|
||||
const cliVersion = VERSION as string;
|
||||
const cliTag = cliVersion.includes("v4-beta") ? "v4-beta" : "latest";
|
||||
|
||||
const InitCommandOptions = CommonCommandOptions.extend({
|
||||
projectRef: z.string().optional(),
|
||||
overrideConfig: z.boolean().default(false),
|
||||
tag: z.string().default("latest"),
|
||||
tag: z.string().default(cliVersion),
|
||||
skipPackageInstall: z.boolean().default(false),
|
||||
runtime: z.string().default("node"),
|
||||
pkgArgs: z.string().optional(),
|
||||
@@ -60,7 +64,7 @@ export function configureInitCommand(program: Command) {
|
||||
.option(
|
||||
"-t, --tag <package tag>",
|
||||
"The version of the @trigger.dev/sdk package to install",
|
||||
"latest"
|
||||
cliVersion
|
||||
)
|
||||
.option(
|
||||
"-r, --runtime <runtime>",
|
||||
@@ -193,7 +197,7 @@ async function _initCommand(dir: string, options: InitCommandOptions) {
|
||||
log.info("Next steps:");
|
||||
log.info(
|
||||
` 1. To start developing, run ${chalk.green(
|
||||
`npx trigger.dev@${options.tag} dev${options.profile ? "" : ` --profile ${options.profile}`}`
|
||||
`npx trigger.dev@${cliTag} dev${options.profile ? "" : ` --profile ${options.profile}`}`
|
||||
)} in your project directory`
|
||||
);
|
||||
log.info(` 2. Visit your ${projectDashboard} to view your newly created tasks.`);
|
||||
|
||||
@@ -472,7 +472,34 @@ const zodIpc = new ZodIpcConnection({
|
||||
async function flushAll(timeoutInMs: number = 10_000) {
|
||||
const now = performance.now();
|
||||
|
||||
await Promise.all([flushTracingSDK(timeoutInMs), flushMetadata(timeoutInMs)]);
|
||||
const results = await Promise.allSettled([
|
||||
flushTracingSDK(timeoutInMs),
|
||||
flushMetadata(timeoutInMs),
|
||||
]);
|
||||
|
||||
const successfulFlushes = results
|
||||
.filter((result) => result.status === "fulfilled")
|
||||
.map((result) => result.value.flushed);
|
||||
|
||||
const failedFlushes = ["tracingSDK", "runMetadata"].filter(
|
||||
(flushed) => !successfulFlushes.includes(flushed)
|
||||
);
|
||||
|
||||
if (failedFlushes.length > 0) {
|
||||
logError(`Failed to flush ${failedFlushes.join(", ")}`);
|
||||
}
|
||||
|
||||
const errorMessages = results
|
||||
.filter((result) => result.status === "rejected")
|
||||
.map((result) => result.reason);
|
||||
|
||||
if (errorMessages.length > 0) {
|
||||
logError(errorMessages.join("\n"));
|
||||
}
|
||||
|
||||
for (const flushed of successfulFlushes) {
|
||||
log(`Flushed ${flushed} successfully`);
|
||||
}
|
||||
|
||||
const duration = performance.now() - now;
|
||||
|
||||
@@ -487,6 +514,11 @@ async function flushTracingSDK(timeoutInMs: number = 10_000) {
|
||||
const duration = performance.now() - now;
|
||||
|
||||
log(`Flushed tracingSDK in ${duration}ms`);
|
||||
|
||||
return {
|
||||
flushed: "tracingSDK",
|
||||
durationMs: duration,
|
||||
};
|
||||
}
|
||||
|
||||
async function flushMetadata(timeoutInMs: number = 10_000) {
|
||||
@@ -497,6 +529,11 @@ async function flushMetadata(timeoutInMs: number = 10_000) {
|
||||
const duration = performance.now() - now;
|
||||
|
||||
log(`Flushed runMetadata in ${duration}ms`);
|
||||
|
||||
return {
|
||||
flushed: "runMetadata",
|
||||
durationMs: duration,
|
||||
};
|
||||
}
|
||||
|
||||
const managedWorkerRuntime = new ManagedRuntimeManager(zodIpc, showInternalLogs);
|
||||
|
||||
Generated
+44
-5
@@ -1216,8 +1216,8 @@ importers:
|
||||
specifier: ^1.7.1
|
||||
version: 1.7.1
|
||||
nypm:
|
||||
specifier: ^0.3.9
|
||||
version: 0.3.9
|
||||
specifier: ^0.5.4
|
||||
version: 0.5.4
|
||||
object-hash:
|
||||
specifier: ^3.0.0
|
||||
version: 3.0.0
|
||||
@@ -19483,6 +19483,12 @@ packages:
|
||||
engines: {node: '>=0.4.0'}
|
||||
hasBin: true
|
||||
|
||||
/acorn@8.14.1:
|
||||
resolution: {integrity: sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg==}
|
||||
engines: {node: '>=0.4.0'}
|
||||
hasBin: true
|
||||
dev: false
|
||||
|
||||
/acorn@8.8.1:
|
||||
resolution: {integrity: sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==}
|
||||
engines: {node: '>=0.4.0'}
|
||||
@@ -21004,7 +21010,7 @@ packages:
|
||||
/citty@0.1.6:
|
||||
resolution: {integrity: sha512-tskPPKEs8D2KPafUypv2gxwJP8h/OaJmC82QQGGDQcHvXX43xF2VDACcJVmZ0EuSxkpO9Kc4MlrA3q0+FG58AQ==}
|
||||
dependencies:
|
||||
consola: 3.2.3
|
||||
consola: 3.4.2
|
||||
dev: false
|
||||
|
||||
/cjs-module-lexer@1.2.3:
|
||||
@@ -21334,6 +21340,10 @@ packages:
|
||||
/confbox@0.1.7:
|
||||
resolution: {integrity: sha512-uJcB/FKZtBMCJpK8MQji6bJHgu1tixKPxRLeGkNzBoOZzpnZUJm0jm2/sBDWcuBx1dYgxV4JU+g5hmNxCyAmdA==}
|
||||
|
||||
/confbox@0.1.8:
|
||||
resolution: {integrity: sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==}
|
||||
dev: false
|
||||
|
||||
/config-chain@1.1.13:
|
||||
resolution: {integrity: sha512-qj+f8APARXHrM0hraqXYb2/bOVSV4PvJQlNZ/DVj0QrmNM2q2euizkeuVckQ57J+W0mRH6Hvi+k50M4Jul2VRQ==}
|
||||
dependencies:
|
||||
@@ -27925,6 +27935,15 @@ packages:
|
||||
pkg-types: 1.1.3
|
||||
ufo: 1.5.4
|
||||
|
||||
/mlly@1.7.4:
|
||||
resolution: {integrity: sha512-qmdSIPC4bDJXgZTCR7XosJiNKySV7O215tsPtDN9iEO/7q/76b/ijtgRu/+epFXSJhijtTCCGp3DWS549P3xKw==}
|
||||
dependencies:
|
||||
acorn: 8.14.1
|
||||
pathe: 2.0.3
|
||||
pkg-types: 1.3.1
|
||||
ufo: 1.5.4
|
||||
dev: false
|
||||
|
||||
/module-details-from-path@1.0.3:
|
||||
resolution: {integrity: sha512-ySViT69/76t8VhE1xXHK6Ch4NcDd26gx0MzKXLO+F7NOtnqH68d9zF94nT8ZWSxXh8ELOERsnJO/sWt1xZYw5A==}
|
||||
|
||||
@@ -28528,13 +28547,26 @@ packages:
|
||||
hasBin: true
|
||||
dependencies:
|
||||
citty: 0.1.6
|
||||
consola: 3.2.3
|
||||
consola: 3.4.2
|
||||
execa: 8.0.1
|
||||
pathe: 1.1.2
|
||||
pkg-types: 1.1.3
|
||||
ufo: 1.5.4
|
||||
dev: false
|
||||
|
||||
/nypm@0.5.4:
|
||||
resolution: {integrity: sha512-X0SNNrZiGU8/e/zAB7sCTtdxWTMSIO73q+xuKgglm2Yvzwlo8UoC5FNySQFCvl84uPaeADkqHUZUkWy4aH4xOA==}
|
||||
engines: {node: ^14.16.0 || >=16.10.0}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
citty: 0.1.6
|
||||
consola: 3.4.2
|
||||
pathe: 2.0.3
|
||||
pkg-types: 1.3.1
|
||||
tinyexec: 0.3.2
|
||||
ufo: 1.5.4
|
||||
dev: false
|
||||
|
||||
/oauth-sign@0.9.0:
|
||||
resolution: {integrity: sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==}
|
||||
dev: false
|
||||
@@ -29260,7 +29292,6 @@ packages:
|
||||
|
||||
/pathe@2.0.3:
|
||||
resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==}
|
||||
dev: true
|
||||
|
||||
/pathval@1.1.1:
|
||||
resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==}
|
||||
@@ -29456,6 +29487,14 @@ packages:
|
||||
mlly: 1.7.1
|
||||
pathe: 1.1.2
|
||||
|
||||
/pkg-types@1.3.1:
|
||||
resolution: {integrity: sha512-/Jm5M4RvtBFVkKWRu2BLUTNP8/M2a+UwuAX+ae4770q1qVGtfjG+WTCupoZixokjmHiry8uI+dlY8KXYV5HVVQ==}
|
||||
dependencies:
|
||||
confbox: 0.1.8
|
||||
mlly: 1.7.4
|
||||
pathe: 2.0.3
|
||||
dev: false
|
||||
|
||||
/platform@1.3.6:
|
||||
resolution: {integrity: sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==}
|
||||
dev: false
|
||||
|
||||
Reference in New Issue
Block a user