The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
fix(cli): continue with a warning on Node versions newer than the app SDK's range (#27490)
Weiko4b6bb23fefc6
diff --git a/packages/twenty-cli/docs/commands.md b/packages/twenty-cli/docs/commands.mdindex 634951de533..0c05e47e3f0 100644--- a/packages/twenty-cli/docs/commands.md+++ b/packages/twenty-cli/docs/commands.md@@ -270,8 +270,10 @@ The CLI owns manifest generation, bundling and typechecking. It uses the app'sinstalled `twenty-sdk` authoring exports (`define` and `front-component`, SDK`>=1.23.0`). An app without an installed SDK fails with `SDK_NOT_INSTALLED`;missing or unsupported authoring-exports fail with `SDK_SOURCE_UNSUPPORTED`; an incompatible SDK Node requirement-fails with `NODE_VERSION_UNSUPPORTED`. The CLI never installs dependencies or+exports fail with `SDK_SOURCE_UNSUPPORTED`. A Node version below every version the SDK's+`engines.node` range accepts fails with `NODE_VERSION_UNSUPPORTED`; any other+Node version outside that range continues with a `NODE_VERSION_UNTESTED`+warning, which `doctor` also reports. The CLI never installs dependencies orsubstitutes another SDK. Yarn Plug'n'Play is not supported; use`nodeLinker: node-modules`.diff --git a/packages/twenty-cli/src/app/dev/build-dev-snapshot.ts b/packages/twenty-cli/src/app/dev/build-dev-snapshot.tsindex 53e2d76fd53..bbcaa884824 100644--- a/packages/twenty-cli/src/app/dev/build-dev-snapshot.ts+++ b/packages/twenty-cli/src/app/dev/build-dev-snapshot.ts@@ -9,18 +9,22 @@ import { resolveSourceSdk } from '@/app/project/resolve-source-sdk';import { runAppWorker } from '@/app/run-app-worker';import { toWorkerOutputDiagnostics } from '@/app/to-worker-output-diagnostics';import { CliError } from '@/output/cli-error';+import { type CliWarning } from '@/output/types/cli-warning.type';export const buildDevSnapshot = async ({appPath,signal,updateWatchInputs,+ warn,}: {appPath: string;signal: AbortSignal;updateWatchInputs: (inputs: WatchInputs, success: boolean) => Promise<void>;+ warn?: (warning: CliWarning) => void;}) => {const tooling = await resolveSourceSdk({appPath,+ warn,});const sourceFingerprints = await collectSourceFingerprints(appPath).catch(() => undefined,diff --git a/packages/twenty-cli/src/app/exec/read-exec-manifest.ts b/packages/twenty-cli/src/app/exec/read-exec-manifest.tsindex c2168c27412..197cc1235fe 100644--- a/packages/twenty-cli/src/app/exec/read-exec-manifest.ts+++ b/packages/twenty-cli/src/app/exec/read-exec-manifest.ts@@ -22,7 +22,10 @@ export const readExecManifest = async ({explicitPath: readStringOption(options, 'path'),workingDirectory: process.cwd(),});- const sdk = await resolveSourceSdk({ appPath: project.path });+ const sdk = await resolveSourceSdk({+ appPath: project.path,+ warn: output.warn,+ });output.progress(`Reading app definitions in ${project.path}…`);const worker = await runAppWorker({diff --git a/packages/twenty-cli/src/app/project/__tests__/check-node-requirement.spec.ts b/packages/twenty-cli/src/app/project/__tests__/check-node-requirement.spec.tsindex ecb82260ab3..7056f219134 100644--- a/packages/twenty-cli/src/app/project/__tests__/check-node-requirement.spec.ts+++ b/packages/twenty-cli/src/app/project/__tests__/check-node-requirement.spec.ts@@ -5,13 +5,16 @@ import { checkNodeRequirement } from '@/app/project/check-node-requirement';describe('checkNodeRequirement', () => {it.each([['24.5.0', '^24.5.0', 'satisfied'],- ['24.4.9', '^24.5.0', 'unsatisfied'],+ ['24.4.9', '^24.5.0', 'belowMinimum'],['24.5.0', '24', 'satisfied'],['24.5.0', '<=24', 'satisfied'],- ['24.5.0', '99.x', 'unsatisfied'],- ['24.5.0', '>= 99.0.0', 'unsatisfied'],+ ['24.5.0', '99.x', 'belowMinimum'],+ ['24.5.0', '>= 99.0.0', 'belowMinimum'],['24.5.0', '20 - 24', 'satisfied'],['24.5.0', '^20 || ^24', 'satisfied'],+ ['26.0.0', '^24.5.0', 'outsideRange'],+ ['25.0.0', '<=24', 'outsideRange'],+ ['23.1.0', '^22 || ^24', 'outsideRange'],['24.5.0', 'latest', 'invalid'],])('checks Node %s against %j', (version, range, expected) => {expect(checkNodeRequirement({ version, range })).toBe(expected);diff --git a/packages/twenty-cli/src/app/project/__tests__/resolve-source-sdk.spec.ts b/packages/twenty-cli/src/app/project/__tests__/resolve-source-sdk.spec.tsindex 2e8639bedf7..699c2d8ead4 100644--- a/packages/twenty-cli/src/app/project/__tests__/resolve-source-sdk.spec.ts+++ b/packages/twenty-cli/src/app/project/__tests__/resolve-source-sdk.spec.ts@@ -11,7 +11,7 @@ import { createRequire } from 'node:module';import { tmpdir } from 'node:os';import { join } from 'node:path';-import { afterEach, beforeEach, describe, expect, it } from 'vitest';+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { resolveSourceSdk } from '@/app/project/resolve-source-sdk';import { createSourceTestApp } from '@/app/source/__tests__/utils/create-source-test-app';@@ -78,6 +78,21 @@ describe('source SDK compatibility', () => {});});+ it('warns and continues when this Node is newer than the SDK declares', async () => {+ await updatePackage({ engines: { node: '^1.0.0' } });+ const warn = vi.fn();++ expect(await resolveSourceSdk({ appPath, warn })).toEqual({+ version: '2.44.0',+ packagePath: sdkPath,+ });+ expect(warn).toHaveBeenCalledTimes(1);+ expect(warn).toHaveBeenCalledWith({+ code: 'NODE_VERSION_UNTESTED',+ message: `twenty-sdk 2.44.0 declares Node ^1.0.0; continuing on Node ${process.versions.node}, which is outside that range.`,+ });+ });+it.each([{ node: '>=999.0.0', code: 'NODE_VERSION_UNSUPPORTED' },{ node: 'not-semver', code: 'SDK_SOURCE_UNSUPPORTED' },diff --git a/packages/twenty-cli/src/app/project/check-node-requirement.ts b/packages/twenty-cli/src/app/project/check-node-requirement.tsindex 401b00c7ac0..901e926e998 100644--- a/packages/twenty-cli/src/app/project/check-node-requirement.ts+++ b/packages/twenty-cli/src/app/project/check-node-requirement.ts@@ -1,8 +1,13 @@import { isNull } from '@sniptt/guards';import satisfies from 'semver/functions/satisfies';+import ltr from 'semver/ranges/ltr';import validRange from 'semver/ranges/valid';-type NodeRequirementCheck = 'satisfied' | 'unsatisfied' | 'invalid';+type NodeRequirementCheck =+ | 'satisfied'+ | 'belowMinimum'+ | 'outsideRange'+ | 'invalid';export const checkNodeRequirement = ({version,@@ -15,5 +20,9 @@ export const checkNodeRequirement = ({return 'invalid';}- return satisfies(version, range) ? 'satisfied' : 'unsatisfied';+ if (satisfies(version, range)) {+ return 'satisfied';+ }++ return ltr(version, range) ? 'belowMinimum' : 'outsideRange';};diff --git a/packages/twenty-cli/src/app/project/resolve-source-sdk.ts b/packages/twenty-cli/src/app/project/resolve-source-sdk.tsindex 162d2edd845..566a9c778be 100644--- a/packages/twenty-cli/src/app/project/resolve-source-sdk.ts+++ b/packages/twenty-cli/src/app/project/resolve-source-sdk.ts@@ -9,11 +9,18 @@ import { checkNodeRequirement } from '@/app/project/check-node-requirement';import { resolveInstalledSdk } from '@/app/project/resolve-installed-sdk';import { resolveInsideSdk } from '@/app/project/resolve-inside-sdk';import { CliError } from '@/output/cli-error';+import { type CliWarning } from '@/output/types/cli-warning.type';const SOURCE_SDK_RANGE = '>=1.23.0';const SOURCE_ENTRY_POINTS = ['twenty-sdk/define', 'twenty-sdk/front-component'];-export const resolveSourceSdk = async ({ appPath }: { appPath: string }) => {+export const resolveSourceSdk = async ({+ appPath,+ warn,+}: {+ appPath: string;+ warn?: (warning: CliWarning) => void;+}) => {const sdk = await resolveInstalledSdk(appPath);const version = isString(sdk.packageJson.version)? sdk.packageJson.version@@ -55,7 +62,12 @@ export const resolveSourceSdk = async ({ appPath }: { appPath: string }) => {}): 'invalid';- if (requirement !== 'satisfied') {+ if (requirement === 'outsideRange') {+ warn?.({+ code: 'NODE_VERSION_UNTESTED',+ message: `twenty-sdk ${version} declares Node ${String(requiredNode)}; continuing on Node ${process.versions.node}, which is outside that range.`,+ });+ } else if (requirement !== 'satisfied') {throw new CliError({code:requirement === 'invalid'diff --git a/packages/twenty-cli/src/app/read-app-identity.ts b/packages/twenty-cli/src/app/read-app-identity.tsindex 54c34a59b0b..7548d13a870 100644--- a/packages/twenty-cli/src/app/read-app-identity.ts+++ b/packages/twenty-cli/src/app/read-app-identity.ts@@ -9,6 +9,7 @@ import { type AppSourceIdentity } from '@/app/source/types/app-source-identity.timport { toWorkerOutputDiagnostics } from '@/app/to-worker-output-diagnostics';import { CliError } from '@/output/cli-error';import { createCancelledError } from '@/output/create-cancelled-error';+import { type CliWarning } from '@/output/types/cli-warning.type';const parseIdentity = (value: unknown,@@ -45,13 +46,15 @@ const parseIdentity = (export const readAppIdentity = async ({appPath,signal,+ warn,}: {appPath: string;signal: AbortSignal;+ warn?: (warning: CliWarning) => void;}) => {signal.throwIfAborted();- const sdk = await resolveSourceSdk({ appPath });+ const sdk = await resolveSourceSdk({ appPath, warn });const worker = await runAppWorker({request: { type: 'readSourceIdentity', appPath },signal,diff --git a/packages/twenty-cli/src/app/run-app-operation.ts b/packages/twenty-cli/src/app/run-app-operation.tsindex ed1cb67f72c..36964a9c9da 100644--- a/packages/twenty-cli/src/app/run-app-operation.ts+++ b/packages/twenty-cli/src/app/run-app-operation.ts@@ -66,6 +66,7 @@ const runAppOperation = async <TData>({});const sdk = await resolveSourceSdk({appPath: project.path,+ warn: output.warn,});output.progress(diff --git a/packages/twenty-cli/src/app/source/README.md b/packages/twenty-cli/src/app/source/README.mdindex 4d0e4b7e2ef..5582a4ab408 100644--- a/packages/twenty-cli/src/app/source/README.md+++ b/packages/twenty-cli/src/app/source/README.md@@ -13,7 +13,7 @@ Package boundaries are documented in the## Compatibility-- The app supplies its own `twenty-sdk`, version `>=1.23.0`, with resolvable `twenty-sdk/define` and `twenty-sdk/front-component` entry points. The installed SDK's Node requirement is checked.+- The app supplies its own `twenty-sdk`, version `>=1.23.0`, with resolvable `twenty-sdk/define` and `twenty-sdk/front-component` entry points. The installed SDK's Node requirement is checked: a Node below every version the range accepts fails, any other Node outside the range only warns.- There is no upper SDK version cap. Every evaluated definition must return the public `ValidationResult` shape: boolean `success`, object `config`, string-array `errors`, and optional string-array `warnings`. An incompatible shape fails with `SDK_SOURCE_UNSUPPORTED`. This validates the loader contract, not every future SDK behavior.- The CLI owns esbuild, its TypeScript parser and tinyglobby as runtime dependencies. These load only for source operations. The app does not need to install TypeScript for source loading. Build and typecheck use the project's compiler separately.- The pull writer separately checks the authoring exports its generated files use; this loader floor does not establish that every SDK since 1.23 supports all current manifest collections.diff --git a/packages/twenty-cli/src/commands/app/__tests__/app-build.spec.ts b/packages/twenty-cli/src/commands/app/__tests__/app-build.spec.tsindex 94604b694b3..d4ef857eb59 100644--- a/packages/twenty-cli/src/commands/app/__tests__/app-build.spec.ts+++ b/packages/twenty-cli/src/commands/app/__tests__/app-build.spec.ts@@ -309,6 +309,28 @@ describe('app build and typecheck', () => {expect(envelope.error.code).toBe('APP_NOT_FOUND');});+ it('builds with a warning when this Node is newer than the SDK declares', async () => {+ const { appPath } = await createApp();++ await writeFixture({ appPath, requiredNode: '^1.0.0' });++ const { envelope, exitCode } = await runJson([+ 'app',+ 'build',+ '--path',+ appPath,+ ]);++ expect(exitCode).toBe(0);+ expect(envelope.data).toMatchObject({ sdk: { version: '9.9.9' } });+ expect(envelope.warnings).toEqual([+ {+ code: 'NODE_VERSION_UNTESTED',+ message: `twenty-sdk 9.9.9 declares Node ^1.0.0; continuing on Node ${process.versions.node}, which is outside that range.`,+ },+ ]);+ });+describe('refuses before loading any SDK code', () => {it.each([[diff --git a/packages/twenty-cli/src/commands/app/__tests__/app-logs.spec.ts b/packages/twenty-cli/src/commands/app/__tests__/app-logs.spec.tsindex 855db622f37..3b03c42dff0 100644--- a/packages/twenty-cli/src/commands/app/__tests__/app-logs.spec.ts+++ b/packages/twenty-cli/src/commands/app/__tests__/app-logs.spec.ts@@ -218,6 +218,31 @@ describe('twenty app logs', () => {}});+ it('prints the SDK Node warning before watching starts in human output', async () => {+ const message =+ 'twenty-sdk 2.45.0 declares Node ^22.0.0; continuing on Node 26.0.0, which is outside that range.';++ vi.mocked(readAppIdentity).mockImplementation(async ({ warn }) => {+ warn?.({ code: 'NODE_VERSION_UNTESTED', message });++ return {+ application: {+ universalIdentifier: APPLICATION_IDENTIFIER,+ displayName: 'Test app',+ },+ diagnostics: [],+ };+ });++ const result = await run();+ const warningIndex = result.stderr.indexOf(message);++ expect(result.exitCode).toBe(0);+ expect(warningIndex).toBeGreaterThanOrEqual(0);+ expect(warningIndex).toBeLessThan(result.stderr.indexOf('Watching'));+ expect(result.stderr.lastIndexOf(message)).toBe(warningIndex);+ });+it.each(['http', 'sse', 'sse-without-code'])('falls back once for missing identity fields over %s, with an explicit warning',async (transport) => {diff --git a/packages/twenty-cli/src/commands/app/add/run-app-add-command.ts b/packages/twenty-cli/src/commands/app/add/run-app-add-command.tsindex af3d4967486..26219efd69f 100644--- a/packages/twenty-cli/src/commands/app/add/run-app-add-command.ts+++ b/packages/twenty-cli/src/commands/app/add/run-app-add-command.ts@@ -16,7 +16,11 @@ export const runAppAddCommand: CommandRun = async (context) => {explicitPath: readStringOption(options, 'path'),workingDirectory: process.cwd(),});- const identity = await readAppIdentity({ appPath: project.path, signal });+ const identity = await readAppIdentity({+ appPath: project.path,+ signal,+ warn: output.warn,+ });if (!isDefined(identity.application)) {throw new CliError({diff --git a/packages/twenty-cli/src/commands/app/dev/run-app-dev-command.ts b/packages/twenty-cli/src/commands/app/dev/run-app-dev-command.tsindex e6468976f62..0051cfe5896 100644--- a/packages/twenty-cli/src/commands/app/dev/run-app-dev-command.ts+++ b/packages/twenty-cli/src/commands/app/dev/run-app-dev-command.ts@@ -33,6 +33,7 @@ export const runAppDevCommand: CommandRun<TargetCommandContext> = async (const { output, emit } = createDevOutput(context);const generateClient = createDevClientGenerator({ appPath: project.path });let watcher: Awaited<ReturnType<typeof watchAppInputs>>;+ let hasWarnedAboutNode = false;await runDevLoop<BuiltDevSnapshot>({signal: context.signal,@@ -75,6 +76,12 @@ export const runAppDevCommand: CommandRun<TargetCommandContext> = async (appPath: project.path,signal,updateWatchInputs: watcher.update,+ warn: (warning) => {+ if (!hasWarnedAboutNode) {+ hasWarnedAboutNode = true;+ output.warn(warning);+ }+ },});try {diff --git a/packages/twenty-cli/src/commands/app/function-logs/run-app-logs-command.ts b/packages/twenty-cli/src/commands/app/function-logs/run-app-logs-command.tsindex f8fc86e7370..66fa13da325 100644--- a/packages/twenty-cli/src/commands/app/function-logs/run-app-logs-command.ts+++ b/packages/twenty-cli/src/commands/app/function-logs/run-app-logs-command.ts@@ -15,18 +15,30 @@ import { CliError } from '@/output/cli-error';import { EXIT_CODE } from '@/output/constants/exit-code.constant';import { colorText, dimText, formatWarningLine } from '@/output/style';import { toCliError } from '@/output/to-cli-error';+import { type CliWarning } from '@/output/types/cli-warning.type';import { toPublicTarget } from '@/target/to-public-target';export const runAppLogsCommand: CommandRun<TargetCommandContext> = async (context,) => {const { options, output, outputMode, signal, target } = context;+ const warn = (warning: CliWarning) => {+ if (outputMode === 'human') {+ output.progress(formatWarningLine(warning.message));+ } else {+ output.warn(warning);+ }+ };const filter = readLogsFilter(options);const project = await resolveAppProject({explicitPath: readStringOption(options, 'path'),workingDirectory: process.cwd(),});- const identity = await readAppIdentity({ appPath: project.path, signal });+ const identity = await readAppIdentity({+ appPath: project.path,+ signal,+ warn,+ });if (!isDefined(identity.application)) {throw new CliError({code: 'INVALID_INPUT',@@ -65,18 +77,12 @@ export const runAppLogsCommand: CommandRun<TargetCommandContext> = async (signal,onConnected: () =>output.event('progress', { kind: 'connected' }, signal),- onIdentityUnavailable: async () => {- const warning = {+ onIdentityUnavailable: async () =>+ warn({code: 'LOG_IDENTITY_UNAVAILABLE',message:'This server returns log text without function identities. Mixed logs cannot be attributed to individual functions; use --universal-identifier to isolate one, or upgrade the server.',- };- if (outputMode === 'human') {- output.progress(formatWarningLine(warning.message));- } else {- output.warn(warning);- }- },+ }),onRecord: async (record) => {if (outputMode === 'ndjson') {await output.event('record', record, signal);diff --git a/packages/twenty-cli/src/commands/app/pull/run-app-pull-command.ts b/packages/twenty-cli/src/commands/app/pull/run-app-pull-command.tsindex 86d87565b76..47b72d21fd0 100644--- a/packages/twenty-cli/src/commands/app/pull/run-app-pull-command.ts+++ b/packages/twenty-cli/src/commands/app/pull/run-app-pull-command.ts@@ -47,7 +47,11 @@ export const runAppPullCommand: CommandRun<TargetCommandContext> = async ({});}- const identity = await readAppIdentity({ appPath: project.path, signal });+ const identity = await readAppIdentity({+ appPath: project.path,+ signal,+ warn: output.warn,+ });const universalIdentifier = (explicitIdentifier ?? identity.application?.universalIdentifierdiff --git a/packages/twenty-cli/src/commands/doctor/__tests__/doctor.spec.ts b/packages/twenty-cli/src/commands/doctor/__tests__/doctor.spec.tsindex 09c7d9591a1..1631d4bf554 100644--- a/packages/twenty-cli/src/commands/doctor/__tests__/doctor.spec.ts+++ b/packages/twenty-cli/src/commands/doctor/__tests__/doctor.spec.ts@@ -308,6 +308,20 @@ describe('doctor', () => {);});+ it('warns when this Node is newer than the SDK declares', async () => {+ const { appPath } = await createApp({ engines: { node: '^1.0.0' } });+ const result = await runJson(['--offline', '--path', appPath]);++ expect(result.exitCode).toBe(0);+ expect(result.checks).toContainEqual(+ expect.objectContaining({+ id: 'sdk',+ status: 'warning',+ code: 'NODE_VERSION_UNTESTED',+ }),+ );+ });+it('still checks the workspace when an explicit app path is invalid', async () => {const server = await startWorkspace();diff --git a/packages/twenty-cli/src/doctor/get-project-doctor-checks.ts b/packages/twenty-cli/src/doctor/get-project-doctor-checks.tsindex e39f902fd45..0fbfd8e7b01 100644--- a/packages/twenty-cli/src/doctor/get-project-doctor-checks.ts+++ b/packages/twenty-cli/src/doctor/get-project-doctor-checks.ts@@ -5,6 +5,7 @@ import { resolveSourceSdk } from '@/app/project/resolve-source-sdk';import { type AppProject } from '@/app/project/types/app-project.type';import { type DoctorCheck } from '@/doctor/types/doctor-check.type';import { CliError } from '@/output/cli-error';+import { type CliWarning } from '@/output/types/cli-warning.type';export const getProjectDoctorChecks = async ({explicitPath,@@ -53,16 +54,31 @@ export const getProjectDoctorChecks = async ({try {signal.throwIfAborted();- const sdk = await resolveSourceSdk({ appPath: project.path });+ const warnings: CliWarning[] = [];+ const sdk = await resolveSourceSdk({+ appPath: project.path,+ warn: (warning) => warnings.push(warning),+ });+ const [nodeWarning] = warnings;+ const details = { version: sdk.version, path: sdk.packagePath };return [projectCheck,- {- id: 'sdk',- status: 'pass',- message: `twenty-sdk ${sdk.version} provides the authoring exports required by the CLI.`,- details: { version: sdk.version, path: sdk.packagePath },- },+ isDefined(nodeWarning)+ ? {+ id: 'sdk',+ status: 'warning',+ code: nodeWarning.code,+ message: nodeWarning.message,+ hint: 'Builds continue. If one fails, switch to a Node version in that range.',+ details,+ }+ : {+ id: 'sdk',+ status: 'pass',+ message: `twenty-sdk ${sdk.version} provides the authoring exports required by the CLI.`,+ details,+ },];} catch (error) {signal.throwIfAborted();