Skip to content

Commit

Permalink
feat: detect bun package manager
Browse files Browse the repository at this point in the history
  • Loading branch information
colinhacks committed Aug 15, 2023
1 parent a5222d8 commit aae8a6d
Show file tree
Hide file tree
Showing 10 changed files with 290 additions and 115 deletions.
33 changes: 17 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: create-playwright CI
on:
push:
branches: [ main ]
branches: [main]
pull_request:
branches: [ main ]
branches: [main]
jobs:
build:
runs-on: ${{ matrix.os }}
Expand All @@ -13,17 +13,18 @@ jobs:
node-version: [16.x, 18.x, 20.x]
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm i -g npm@8
- run: npm i -g yarn@1
- run: npm i -g pnpm@7
- run: npm ci
- run: npx playwright install-deps
- run: npm run build
- run: npx tsc --noEmit
- run: npm run test
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm i -g npm@8
- run: npm i -g yarn@1
- run: npm i -g pnpm@7
- run: npm i -g bun
- run: npm ci
- run: npx playwright install-deps
- run: npm run build
- run: npx tsc --noEmit
- run: npm run test
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
node_modules/
lib/
test-results/
test-results/
/test-results/
/playwright-report/
/playwright/.cache/
/test-results/
/playwright-report/
/playwright/.cache/
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ npm init playwright@latest
yarn create playwright
# Or for pnpm
pnpm dlx create-playwright
# Or for Bun
bunx create-playwright
```
61 changes: 43 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"prepublish": "npm run build"
},
"devDependencies": {
"@playwright/test": "^1.30.0",
"@playwright/test": "^1.37.0",
"@types/node": "^16.11.11",
"ansi-colors": "^4.1.1",
"enquirer": "^2.3.6",
Expand Down
24 changes: 15 additions & 9 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { defineConfig } from '@playwright/test';
import type { TestFixtures } from './tests/baseFixtures';
import {defineConfig} from '@playwright/test';
import type {TestFixtures} from './tests/baseFixtures';

export default defineConfig<TestFixtures>({
timeout: 120 * 1000,
Expand All @@ -25,20 +25,26 @@ export default defineConfig<TestFixtures>({
{
name: 'npm',
use: {
packageManager: 'npm'
}
packageManager: 'npm',
},
},
{
name: 'yarn',
use: {
packageManager: 'yarn'
}
packageManager: 'yarn',
},
},
{
name: 'pnpm',
use: {
packageManager: 'pnpm'
}
packageManager: 'pnpm',
},
},
]
{
name: 'bun',
use: {
packageManager: 'bun',
},
},
],
});
4 changes: 3 additions & 1 deletion src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@ export class Generator {
const extension = languageToFileExtension(answers.language);
if (answers.framework)
packageJSON.scripts['test-ct'] = `playwright test -c playwright-ct.config.${extension}`;

// force commonjs because playwright.config.js uses `require`
if(answers.language === 'JavaScript')
delete packageJSON.type;
const files = new Map<string, string>();
files.set('package.json', JSON.stringify(packageJSON, null, 2) + '\n'); // NPM keeps a trailing new-line
await createFiles(this.rootDir, files, true);
Expand Down
Loading

0 comments on commit aae8a6d

Please sign in to comment.