The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Deprecate the SDK CLI and create-twenty-app (#27862)
Weikoaad189f88464
diff --git a/packages/create-twenty-app/src/cli.ts b/packages/create-twenty-app/src/cli.tsindex f040706d52f..8c8e01b58c4 100644--- a/packages/create-twenty-app/src/cli.ts+++ b/packages/create-twenty-app/src/cli.ts@@ -8,7 +8,7 @@ import {import packageJson from '../package.json';const program = new Command(packageJson.name)- .description('CLI tool to initialize a new Twenty application')+ .description('Deprecated CLI tool to initialize a new Twenty application').version(packageJson.version,'-v, --version',@@ -84,6 +84,15 @@ const program = new Command(packageJson.name)program.exitOverride();+console.warn(+ chalk.yellow(+ [+ 'Warning: create-twenty-app is deprecated. Use twenty app init instead.',+ 'Install: npm install -g twenty',+ ].join('\n'),+ ),+);+try {program.parse();} catch (error) {diff --git a/packages/twenty-sdk/src/cli/__tests__/bundle/__integration__/cli-esm-bundle-startup.integration.spec.ts b/packages/twenty-sdk/src/cli/__tests__/bundle/__integration__/cli-esm-bundle-startup.integration.spec.tsindex 946710d27ba..8d2bb0c9fc3 100644--- a/packages/twenty-sdk/src/cli/__tests__/bundle/__integration__/cli-esm-bundle-startup.integration.spec.ts+++ b/packages/twenty-sdk/src/cli/__tests__/bundle/__integration__/cli-esm-bundle-startup.integration.spec.ts@@ -1,36 +1,92 @@import { spawnSync } from 'node:child_process';import { existsSync } from 'node:fs';import { dirname, resolve } from 'node:path';-import { fileURLToPath } from 'node:url';+import { fileURLToPath, pathToFileURL } from 'node:url';++import packageJson from '../../../../../package.json';const currentDir = dirname(fileURLToPath(import.meta.url));const packageRoot = resolve(currentDir, '../../../../..');-const bundledCliEntry = resolve(packageRoot, 'dist/cli.mjs');-const isBundleBuilt = existsSync(bundledCliEntry);-describe('CLI ESM bundle startup', () => {+describe.each(['cjs', 'mjs'])('SDK CLI %s bundle startup', (extension) => {+ const bundledCliEntry = resolve(packageRoot, `dist/cli.${extension}`);+ const isBundleBuilt = existsSync(bundledCliEntry);const runOrSkip = isBundleBuilt || process.env.CI ? it : it.skip;+ const runCli = (args: string[]) => {+ if (!isBundleBuilt) {+ throw new Error(+ `Expected the built entry at ${bundledCliEntry}. Build twenty-sdk before this test.`,+ );+ }++ return spawnSync(process.execPath, [bundledCliEntry, ...args], {+ encoding: 'utf8',+ timeout: 30_000,+ });+ };++ runOrSkip('shows migration guidance on stderr while help still works', () => {+ const result = runCli(['--help']);+ const combinedOutput = `${result.stdout}\n${result.stderr}`;++ expect(combinedOutput).not.toMatch(/Calling `require` for/);+ expect(combinedOutput).not.toMatch(/is not defined in ES module scope/);+ expect(result.status).toBe(0);+ expect(result.stdout).toContain('Usage: twenty');+ expect(result.stderr).toContain(+ 'CLI bundled with twenty-sdk is deprecated',+ );+ expect(result.stderr).toContain('npm install -g twenty');+ expect(result.stdout).not.toContain('Warning:');+ });++ runOrSkip('preserves machine-readable version output', () => {+ const result = runCli(['--version']);++ expect(result.status).toBe(0);+ expect(result.stdout).toBe(`${packageJson.version}\n`);+ expect(result.stderr).toContain(+ 'CLI bundled with twenty-sdk is deprecated',+ );+ });++ runOrSkip('keeps SDK publishing commands available', () => {+ const result = runCli(['app:publish', '--help']);++ expect(result.status).toBe(0);+ expect(result.stdout).toContain('Usage: twenty app:publish');+ expect(result.stdout).toContain('--private');+ });- runOrSkip(- 'runs `--help` from the bundled .mjs entry without a CJS-in-ESM crash',- () => {- if (!isBundleBuilt) {- throw new Error(- `Expected the built ESM entry at ${bundledCliEntry}. Run \`npx nx build twenty-sdk\` before this test.`,- );- }+ runOrSkip('preserves failures for unknown commands', () => {+ const result = runCli(['unknown-command']);- const result = spawnSync('node', [bundledCliEntry, '--help'], {- encoding: 'utf8',- timeout: 30_000,- });+ expect(result.status).toBe(1);+ expect(result.stderr).toContain("unknown command 'unknown-command'");+ expect(result.stderr).toContain(+ 'CLI bundled with twenty-sdk is deprecated',+ );+ });- const combinedOutput = `${result.stdout ?? ''}\n${result.stderr ?? ''}`;+ runOrSkip.each(['build', 'operations', 'define/index'])(+ 'does not print the CLI warning when importing %s',+ (entry) => {+ const entryUrl = pathToFileURL(+ resolve(packageRoot, `dist/${entry}.${extension}`),+ ).href;+ const result = spawnSync(+ process.execPath,+ [+ '--input-type=module',+ '--eval',+ `await import(${JSON.stringify(entryUrl)})`,+ ],+ { encoding: 'utf8', timeout: 30_000 },+ );- expect(combinedOutput).not.toMatch(/Calling `require` for/);- expect(combinedOutput).not.toMatch(/is not defined in ES module scope/);+ expect(result.stderr).toBe('');+ expect(result.stdout).toBe('');expect(result.status).toBe(0);- expect(result.stdout).toContain('Usage: twenty');},);});diff --git a/packages/twenty-sdk/src/cli/cli.ts b/packages/twenty-sdk/src/cli/cli.tsindex 3968d7fc48f..4c3ab254826 100644--- a/packages/twenty-sdk/src/cli/cli.ts+++ b/packages/twenty-sdk/src/cli/cli.ts@@ -12,7 +12,7 @@ const program = new Command();program.name('twenty')- .description('CLI for Twenty application development')+ .description('Deprecated CLI bundled with twenty-sdk').version(packageJson.version);program.option(@@ -40,6 +40,15 @@ registerCommands(program);program.exitOverride();+console.warn(+ chalk.yellow(+ [+ 'Warning: The CLI bundled with twenty-sdk is deprecated. Use the standalone twenty package instead.',+ 'Install: npm install -g twenty',+ ].join('\n'),+ ),+);+try {program.parse();} catch (error) {