Improve apps (#19120)
fixes https://discord.com/channels/1130383047699738754/1488094970241089586
This commit is contained in:
@@ -40,6 +40,9 @@ registerCommands(program);
|
||||
|
||||
program.exitOverride();
|
||||
|
||||
const isExitPromptError = (error: unknown): boolean =>
|
||||
error instanceof Error && error.name === 'ExitPromptError';
|
||||
|
||||
try {
|
||||
program.parse();
|
||||
} catch (error) {
|
||||
|
||||
@@ -108,7 +108,7 @@ export const registerRemoteCommands = (program: Command): void => {
|
||||
if (!detectedUrl) {
|
||||
console.error(
|
||||
chalk.red(
|
||||
'No local Twenty server found on ports 2020 or 3000.\n' +
|
||||
'No local Twenty server found.\n' +
|
||||
'Start one with: yarn twenty server start',
|
||||
),
|
||||
);
|
||||
|
||||
@@ -37,10 +37,6 @@ export const registerServerCommands = (program: Command): void => {
|
||||
console.error(chalk.red(result.error.message));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(
|
||||
chalk.green(`\nLocal remote configured → ${result.data.url}`),
|
||||
);
|
||||
});
|
||||
|
||||
server
|
||||
|
||||
@@ -25,6 +25,7 @@ export type { FunctionExecuteOptions } from './execute';
|
||||
// Server
|
||||
export { serverStart } from './server-start';
|
||||
export type { ServerStartOptions, ServerStartResult } from './server-start';
|
||||
export { detectLocalServer } from '@/cli/utilities/server/detect-local-server';
|
||||
|
||||
// Shared types and error codes
|
||||
export {
|
||||
|
||||
@@ -126,6 +126,8 @@ const innerServerStart = async (
|
||||
} else {
|
||||
onProgress?.('Starting Twenty container...');
|
||||
|
||||
const serverUrl = `http://localhost:${port}`;
|
||||
|
||||
const runResult = spawnSync(
|
||||
'docker',
|
||||
[
|
||||
@@ -133,6 +135,8 @@ const innerServerStart = async (
|
||||
'-d',
|
||||
'--name',
|
||||
CONTAINER_NAME,
|
||||
'-e',
|
||||
`SERVER_URL=${serverUrl}`,
|
||||
'-p',
|
||||
`${port}:3000`,
|
||||
'-v',
|
||||
|
||||
@@ -51,7 +51,7 @@ export class ApiClient {
|
||||
if (error.response?.status === 401) {
|
||||
console.error(
|
||||
chalk.red(
|
||||
'Authentication failed. Run `twenty remote add` to authenticate.',
|
||||
'Authentication failed. Run `yarn twenty remote add` to authenticate.',
|
||||
),
|
||||
);
|
||||
} else if (error.response?.status === 403) {
|
||||
|
||||
+16
-1
@@ -1,5 +1,7 @@
|
||||
import { type ApiService } from '@/cli/utilities/api/api-service';
|
||||
import { ConfigService } from '@/cli/utilities/config/config-service';
|
||||
import { type OrchestratorState } from '@/cli/utilities/dev/orchestrator/dev-mode-orchestrator-state';
|
||||
import { detectLocalServer } from '@/cli/utilities/server/detect-local-server';
|
||||
|
||||
export type CheckServerOrchestratorStepOutput = {
|
||||
isReady: boolean;
|
||||
@@ -25,11 +27,24 @@ export class CheckServerOrchestratorStep {
|
||||
this.notify = notify;
|
||||
}
|
||||
|
||||
private hasRetried = false;
|
||||
|
||||
async execute(): Promise<boolean> {
|
||||
const step = this.state.steps.checkServer;
|
||||
const validateAuth = await this.apiService.validateAuth();
|
||||
|
||||
if (!validateAuth.serverUp) {
|
||||
const detectedUrl = await detectLocalServer();
|
||||
|
||||
if (detectedUrl && !this.hasRetried) {
|
||||
this.hasRetried = true;
|
||||
const configService = new ConfigService();
|
||||
|
||||
await configService.setConfig({ apiUrl: detectedUrl });
|
||||
|
||||
return this.execute();
|
||||
}
|
||||
|
||||
if (!step.output.errorLogged) {
|
||||
step.output = { isReady: false, errorLogged: true };
|
||||
step.status = 'error';
|
||||
@@ -58,7 +73,7 @@ export class CheckServerOrchestratorStep {
|
||||
this.state.applyStepEvents([
|
||||
{
|
||||
message:
|
||||
'Authentication failed. Run `twenty remote add <url>` to authenticate.',
|
||||
'Authentication failed. Run `yarn twenty remote add` to authenticate.',
|
||||
status: 'error',
|
||||
},
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user