There was an error while loading. Please reload this page.
1 parent 8142a11 commit fe94700Copy full SHA for fe94700
5 files changed
apps/webapp/app/routes/_app.orgs.$organizationSlug.settings.projects/route.tsx
@@ -1,4 +1,4 @@
1
-import { NODE_RUNTIME_UPDATE_MAJOR } from "@trigger.dev/core/v3";
+import { needsNodeRuntimeUpdate } from "@trigger.dev/core/v3";
2
import { typedjson, useTypedLoaderData } from "remix-typedjson";
3
import { resolveOrgIdFromSlugForUser } from "~/models/organization.server";
4
import { listCurrentProductionProjectRuntimes } from "~/services/projectRuntimeUpdates.server";
@@ -54,7 +54,7 @@ export const loader = dashboardLoader(
54
: null,
55
};
56
57
- if (deployment?.nodeMajor === NODE_RUNTIME_UPDATE_MAJOR) {
+ if (deployment && needsNodeRuntimeUpdate(deployment.runtime, deployment.runtimeVersion)) {
58
needsUpdate.push(row);
59
} else {
60
otherProjects.push(row);
apps/webapp/app/services/projectRuntimeUpdates.server.ts
@@ -85,13 +85,6 @@ export async function listCurrentProductionProjectRuntimes(scope: Scope) {
85
);
86
}
87
88
-/**
89
- * Whether any project in the organization runs the reported Node.js major in Production.
90
- *
91
- * The SQL filter mirrors `nodeMajor(runtime, runtimeVersion) === NODE_RUNTIME_UPDATE_MAJOR`, which
92
- * the page applies in JS: keep the two in step. Scoped to the caller's membership so the side menu
93
- * cannot report on an organization the user does not belong to.
94
- */
95
export async function organizationHasProjectRuntimeUpdate({
96
organizationSlug,
97
userId,
@@ -115,8 +108,20 @@ export async function organizationHasProjectRuntimeUpdate({
115
108
some: {
116
109
label: CURRENT_DEPLOYMENT_LABEL,
117
110
deployment: {
118
- runtime: { startsWith: "node" },
119
- runtimeVersion: { startsWith: `${NODE_RUNTIME_UPDATE_MAJOR}.` },
111
+ OR: [
112
+ {
113
+ runtimeVersion: { startsWith: `${NODE_RUNTIME_UPDATE_MAJOR}.` },
114
+ OR: [{ runtime: null }, { runtime: { startsWith: "node" } }],
+ },
+ runtimeVersion: null,
+ { runtime: null },
120
+ { runtime: "node" },
121
+ { runtime: `node-${NODE_RUNTIME_UPDATE_MAJOR}` },
122
+ ],
123
124
125
},
126
127
packages/cli-v3/src/commands/projects/list.ts
@@ -1,5 +1,5 @@
import { intro, outro } from "@clack/prompts";
+import { needsNodeRuntimeUpdate, NODE_RUNTIME_UPDATE_MAJOR } from "@trigger.dev/core/v3";
import type { Command } from "commander";
import { z } from "zod";
5
import { CliApiClient } from "../../apiClient.js";
@@ -70,7 +70,11 @@ async function listProjects(options: ProjectsListCommandOptions) {
70
71
72
const projects = options.needsUpdate
73
- ? response.data.filter((project) => project.deployment?.nodeMajor === NODE_RUNTIME_UPDATE_MAJOR)
+ ? response.data.filter(
74
+ (project) =>
75
+ project.deployment &&
76
+ needsNodeRuntimeUpdate(project.deployment.runtime, project.deployment.runtimeVersion)
77
+ )
78
: response.data;
79
80
if (projects.length === 0) {
packages/core/src/v3/schemas/api-type.test.ts
@@ -2,6 +2,7 @@ import { describe, it, expect } from "vitest";
import {
BatchItemNDJSON,
InitializeDeploymentRequestBody,
+ needsNodeRuntimeUpdate,
6
nodeMajor,
7
TriggerTaskRequestBody,
8
} from "./api.js";
@@ -21,6 +22,22 @@ describe("nodeMajor", () => {
21
22
});
23
24
25
+describe("needsNodeRuntimeUpdate", () => {
26
+ it.each([
27
+ ["node", "21.7.3", true],
28
+ [null, "21.7.3", true],
29
+ ["node", null, true],
30
+ [null, null, true],
31
+ ["node-21", null, true],
32
+ ["node-22", null, false],
33
+ ["node-22", "22.16.0", false],
34
+ ["node", "unknown", false],
35
+ ["bun", "1.3.3", false],
36
+ ])("classifies %s %s", (runtime, runtimeVersion, expected) => {
37
+ expect(needsNodeRuntimeUpdate(runtime, runtimeVersion)).toBe(expected);
38
+ });
39
+});
40
+
41
describe("InitializeDeploymentRequestBody", () => {
42
const base = { contentHash: "abc123" };
43
packages/core/src/v3/schemas/api.ts
@@ -79,6 +79,24 @@ export function nodeMajor(
return match ? Number(match[1]) : undefined;
81
82
+export function needsNodeRuntimeUpdate(
83
+ runtime: string | null | undefined,
84
+ runtimeVersion: string | null | undefined
+) {
+ if (runtime && !runtime.startsWith("node")) return false;
+ const versionMatch = runtimeVersion?.match(/^(\d+)(?:\.\d+){1,2}(?:[-+].*)?$/);
+ if (versionMatch) return Number(versionMatch[1]) === NODE_RUNTIME_UPDATE_MAJOR;
+ if (runtimeVersion) return false;
+ if (!runtime || runtime === "node") return true;
+ const configuredMajorMatch = runtime.match(/^node-(\d+)$/);
+ return configuredMajorMatch
+ ? Number(configuredMajorMatch[1]) === NODE_RUNTIME_UPDATE_MAJOR
+ : false;
98
+}
99
100
export const GetProjectRuntimesResponseBody = z.array(
101
z.object({
102
organization: z.object({
0 commit comments