Skip to content

Commit

Permalink
Remove --create option from toolpad CLI (#2899)
Browse files Browse the repository at this point in the history
  • Loading branch information
Janpot authored Nov 20, 2023
1 parent e098e3b commit 90a0918
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 32 deletions.
8 changes: 4 additions & 4 deletions packages/create-toolpad-app/tests/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ test(
cwd: currentDirectory,
});
cp.stdout?.pipe(process.stdout);
cp.stderr?.pipe(process.stdout);
cp.stderr?.pipe(process.stderr);
const result = await cp;
expect(result.stdout).toMatch('Run the following to get started');
const packageJsonContent = await fs.readFile(path.resolve(testDir, './package.json'), {
Expand Down Expand Up @@ -77,10 +77,10 @@ test(
BROWSER: 'none',
},
});
const { stdout: toolpadDevOutput } = toolpadProcess;
toolpadProcess.stdout?.pipe(process.stdout);
toolpadProcess.stderr?.pipe(process.stderr);

expect(toolpadDevOutput).toBeTruthy();
const match = await waitForMatch(toolpadDevOutput!, /http:\/\/localhost:(\d+)/);
const match = await waitForMatch(toolpadProcess.stdout!, /http:\/\/localhost:(\d+)/);

expect(match).toBeTruthy();

Expand Down
9 changes: 1 addition & 8 deletions packages/toolpad-app/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ export interface RunOptions {
port?: number;
dev?: boolean;
base: string;
create: boolean;
}

async function runCommand(
cmd: 'dev' | 'start',
{ dir, dev: toolpadDevMode, create: createIfNotExists, ...args }: Omit<RunOptions, 'cmd'>,
{ dir, dev: toolpadDevMode, ...args }: Omit<RunOptions, 'cmd'>,
) {
const projectDir = path.resolve(process.cwd(), dir);

Expand All @@ -25,7 +24,6 @@ async function runCommand(
dir: projectDir,
dev: cmd !== 'start',
toolpadDevMode,
createIfNotExists,
});

process.once('SIGINT', () => {
Expand Down Expand Up @@ -94,11 +92,6 @@ export default async function cli(argv: string[]) {
describe: 'Public base path of the Toolpad application',
default: '/prod',
},
create: {
type: 'boolean',
describe: "Create the application directory if it doesn't exist",
default: false,
},
} as const;

const sharedRunOptions = {
Expand Down
12 changes: 0 additions & 12 deletions packages/toolpad-app/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { WebSocket, WebSocketServer } from 'ws';
import { listen } from '@mui/toolpad-utils/http';
// eslint-disable-next-line import/extensions
import openBrowser from 'react-dev-utils/openBrowser.js';
import { folderExists } from '@mui/toolpad-utils/fs';
import chalk from 'chalk';
import { serveRpc } from '@mui/toolpad-utils/workerRpc';
import * as url from 'node:url';
Expand Down Expand Up @@ -425,7 +424,6 @@ export interface RunAppOptions {
dir?: string;
base?: string;
toolpadDevMode?: boolean;
createIfNotExists?: boolean;
}

export async function runApp({
Expand All @@ -434,19 +432,9 @@ export async function runApp({
base = '/prod',
port = 3000,
toolpadDevMode = false,
createIfNotExists,
}: RunAppOptions) {
const projectDir = resolveProjectDir(dir);

if (!(await folderExists(projectDir)) && !createIfNotExists) {
console.error(
`${chalk.red('error')} - No project found at ${chalk.cyan(
`"${projectDir}"`,
)}. Use the --create option to initialize a new Toolpad project in this folder.`,
);
process.exit(1);
}

if (!port) {
port = dev ? await getPort({ port: getPreferredPorts(DEFAULT_PORT) }) : DEFAULT_PORT;
} else {
Expand Down
1 change: 0 additions & 1 deletion test/integration/editor/deleteLast.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { ToolpadEditor } from '../../models/ToolpadEditor';
test.use({
localAppConfig: {
cmd: 'dev',
create: true,
},
});

Expand Down
1 change: 0 additions & 1 deletion test/integration/editor/new.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { ToolpadEditor } from '../../models/ToolpadEditor';
test.use({
localAppConfig: {
cmd: 'dev',
create: true,
},
});

Expand Down
7 changes: 1 addition & 6 deletions test/playwright/localTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ interface LocalAppConfig {
// Extra environment variables when running Toolpad
env?: Record<string, string>;
base?: string;
create?: boolean;
}

interface LocalServerConfig {
Expand Down Expand Up @@ -156,7 +155,7 @@ export async function runCustomServer(
}

export async function runApp(projectDir: string, options: LocalAppConfig) {
const { cmd = 'start', env, base, create } = options;
const { cmd = 'start', env, base } = options;

if (cmd === 'start') {
await buildApp(projectDir, { base, env });
Expand All @@ -167,10 +166,6 @@ export async function runApp(projectDir: string, options: LocalAppConfig) {
args.push('--dev');
}

if (create) {
args.push('--create');
}

// Run each test on its own port to avoid race conditions when running tests in parallel.
args.push('--port', String(await getPort()));

Expand Down

0 comments on commit 90a0918

Please sign in to comment.