diff --git a/packages/create-playwright/assets/playwright.config.js b/packages/create-playwright/assets/playwright.config.js index 3e7e1a7eb5..987f7ea270 100644 --- a/packages/create-playwright/assets/playwright.config.js +++ b/packages/create-playwright/assets/playwright.config.js @@ -39,7 +39,6 @@ const config = { name: 'Desktop Chrome', use: { ...devices['Desktop Chrome'], - }, }, { diff --git a/packages/create-playwright/assets/playwright.config.ts b/packages/create-playwright/assets/playwright.config.ts index 52ea620832..62fa2e8f8f 100644 --- a/packages/create-playwright/assets/playwright.config.ts +++ b/packages/create-playwright/assets/playwright.config.ts @@ -35,7 +35,6 @@ const config: PlaywrightTestConfig = { name: 'Desktop Chrome', use: { ...devices['Desktop Chrome'], - }, }, { diff --git a/packages/create-playwright/package.json b/packages/create-playwright/package.json index 3b6e794d58..ebb1e20084 100644 --- a/packages/create-playwright/package.json +++ b/packages/create-playwright/package.json @@ -15,8 +15,8 @@ "license": "MIT", "scripts": { "prepublish": "npm run build", - "watch": "cd src && ncc build index.ts --watch --out ../lib && cd ..", - "build": "cd src && ncc build index.ts --minify --out ../lib && cd ..", + "watch": "cd src && ncc build cli.ts --watch --out ../lib && cd ..", + "build": "cd src && ncc build cli.ts --minify --out ../lib && cd ..", "test": "npx playwright test" }, "devDependencies": { diff --git a/packages/create-playwright/src/cli.ts b/packages/create-playwright/src/cli.ts new file mode 100644 index 0000000000..35ea11ee0e --- /dev/null +++ b/packages/create-playwright/src/cli.ts @@ -0,0 +1,27 @@ +/** + * Copyright (c) Microsoft Corporation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import path from 'path'; +import { Generator } from './generator'; + +(async () => { + const rootDir = path.resolve(process.cwd(), process.argv[2] || ''); + const generator = new Generator(rootDir); + await generator.run(); +})().catch(error => { + console.error(error); + process.exit(1); +}); diff --git a/packages/create-playwright/src/index.ts b/packages/create-playwright/src/generator.ts old mode 100755 new mode 100644 similarity index 96% rename from packages/create-playwright/src/index.ts rename to packages/create-playwright/src/generator.ts index 91359f429d..8eec48a3ff --- a/packages/create-playwright/src/index.ts +++ b/packages/create-playwright/src/generator.ts @@ -29,7 +29,7 @@ export type PromptOptions = { const PACKAGE_JSON_TEST_SCRIPT_CMD = 'test:e2e'; -class Generator { +export class Generator { packageManager: 'npm' | 'yarn'; constructor(private readonly rootDir: string) { if (!fs.existsSync(rootDir)) @@ -188,11 +188,3 @@ export function commandToRunTests(packageManager: 'npm' | 'yarn', args?: string) return `npm run ${PACKAGE_JSON_TEST_SCRIPT_CMD}${args ? (' -- ' + args) : ''}`; } -(async () => { - const rootDir = path.resolve(process.cwd(), process.argv[2] || ''); - const generator = new Generator(rootDir); - await generator.run(); -})().catch(error => { - console.error(error); - process.exit(1); -}); diff --git a/packages/create-playwright/tests/integration.spec.ts b/packages/create-playwright/tests/integration.spec.ts index db488c04f1..35207d01d5 100644 --- a/packages/create-playwright/tests/integration.spec.ts +++ b/packages/create-playwright/tests/integration.spec.ts @@ -18,7 +18,7 @@ import { spawn } from 'child_process'; import path from 'path'; import fs from 'fs'; -import type { PromptOptions } from '../src'; +import type { PromptOptions } from '../src/generator'; type TestFixtures = { packageManager: 'npm' | 'yarn'; diff --git a/packages/create-playwright/tsconfig.json b/packages/create-playwright/tsconfig.json index 56c95601fe..070b21f426 100644 --- a/packages/create-playwright/tsconfig.json +++ b/packages/create-playwright/tsconfig.json @@ -4,7 +4,5 @@ "downlevelIteration": true, "esModuleInterop": true, }, - "files": [ - "src/index.ts" - ] + "include": ["src"], } \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 551f8ad168..48952702b1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,5 +18,8 @@ }, "compileOnSave": true, "include": ["packages"], - "exclude": ["packages/*/lib"] + "exclude": [ + "packages/*/lib", + "packages/create-playwright/", + ], }