Skip to content

Commit

Permalink
feat: switch to bun (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
danadajian committed May 19, 2024
1 parent 4d652a1 commit c7fe315
Show file tree
Hide file tree
Showing 32 changed files with 142 additions and 8,363 deletions.
35 changes: 15 additions & 20 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
name: Publish

on:
release:
types:
- created
push:
branches:
- main

jobs:
publish:
name: Semantic Release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v3
- name: Setup Bun
uses: oven-sh/setup-bun@v1

- name: Setup node and pnpm cache
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: pnpm
node-version: latest

- name: Install
run: pnpm install
- name: Install Dependencies
run: bun install

- name: Set Version Environment Variable
run: |
VERSION_TAG=$(echo "${GITHUB_REF}" | cut -d "/" -f3)
echo NEW_VERSION="${VERSION_TAG:1}" >> $GITHUB_ENV
- name: Publish
run: |
echo //registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }} >> .npmrc
pnpm --filter cypress-codegen bump-version
pnpm --filter cypress-codegen publish --no-git-checks
- name: Create Release
run: bunx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
33 changes: 0 additions & 33 deletions .github/workflows/release.yaml

This file was deleted.

52 changes: 20 additions & 32 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,40 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v3

- name: Setup node and pnpm cache
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: pnpm
- name: Setup Bun
uses: oven-sh/setup-bun@v1

- name: Install
run: pnpm install
run: bun install

- name: Lint
run: pnpm lint
run: bun lint

- name: Type Check
run: bun tsc

- name: Unit Tests
run: pnpm test
run: bun run test
cli:
name: CLI
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v3
- name: Setup Bun
uses: oven-sh/setup-bun@v1

- name: Setup node and pnpm cache
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: pnpm
- name: Install
run: bun install

- name: Install and setup bin
run: pnpm setup-cli
- name: Build
run: bun run build

- name: Run cypress-codegen
run: |
pnpm cypress-codegen --testingType component
pnpm cypress-codegen --testingType e2e
bun src/cli.ts --testingType component
bun src/cli.ts --testingType e2e
- name: Check generated types match git
run: |
Expand All @@ -76,22 +70,16 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v3

- name: Setup node and pnpm cache
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: pnpm
- name: Setup Bun
uses: oven-sh/setup-bun@v1

- name: Install
run: pnpm install && pnpm cypress install
run: bun install

- name: Integration Tests
uses: cypress-io/github-action@v6
with:
install: false
build: pnpm build
build: bun run build
browser: chrome
component: ${{ matrix.component }}
5 changes: 1 addition & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

pnpm lint && pnpm format && git add .
bun lint && bun format && git add .
2 changes: 0 additions & 2 deletions .npmrc

This file was deleted.

1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules
pnpm-lock.yaml
bun.lockb
cypress
3 changes: 2 additions & 1 deletion .releaserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ plugins:
release: patch
- scope: no-release
release: false
- "@semantic-release/release-notes-generator"
- "@semantic-release/github"
- "@semantic-release/npm"
- "@semantic-release/release-notes-generator"
branches:
- main
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ npm i --save-dev cypress-codegen

## Plugin Usage

Model your Cypress project exactly like [the one in this repository](https://github.com/ExpediaGroup/cypress-codegen/blob/main/cypress.config.ts)!

1. Add the required plugin code to `cypress.config.ts` like so:

```ts
Expand Down
Binary file added bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cypressCodegen } from "cypress-codegen";
import { cypressCodegen } from "./src";
import { defineConfig } from "cypress";

export default defineConfig({
Expand Down
2 changes: 1 addition & 1 deletion cypress/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/** Generated by cypress-codegen **/
export * from "./example";
export * from "./custom-mount";
export * from "./example";
export * from "./nested/nested-example";
31 changes: 31 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* eslint-disable @typescript-eslint/no-var-requires */

const typescriptEslint = require("typescript-eslint");
const cypressEslintPlugin = require("eslint-plugin-cypress");

module.exports = [
...typescriptEslint.configs.recommended,
{
files: ["**/*.ts", "**/*.tsx"],
languageOptions: {
parser: typescriptEslint.parser,
parserOptions: {
project: true,
},
},
plugins: {
"@typescript-eslint": typescriptEslint.plugin,
"sort-annotation": cypressEslintPlugin,
},
rules: {
"no-console": "error",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-non-null-assertion": "error",
"@typescript-eslint/no-unsafe-argument": "error",
"@typescript-eslint/no-unsafe-call": "error",
},
},
{
ignores: ["dist", "node_modules"],
},
];
70 changes: 53 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,73 @@
{
"name": "cypress-codegen",
"packageManager": "[email protected]",
"packageManager": "[email protected]",
"main": "dist/index.cjs",
"types": "dist/index.d.cts",
"bin": {
"cypress-codegen": "dist/cli.cjs"
},
"files": [
"dist",
"README.md"
],
"repository": {
"type": "git",
"url": "https://github.com/ExpediaGroup/cypress-codegen.git"
},
"bugs": {
"url": "https://github.com/ExpediaGroup/cypress-codegen/issues"
},
"license": "Apache-2.0",
"dependencies": {
"@babel/core": "7.24.5",
"@babel/parser": "7.24.5",
"@babel/types": "7.24.5",
"@babel/generator": "7.24.5",
"@types/babel__generator": "7.6.8",
"chalk": "5.3.0",
"commander": "12.1.0",
"glob": "10.3.15",
"prettier": "3.2.5"
},
"peerDependencies": {
"cypress": ">=12"
},
"devDependencies": {
"@swc/jest": "0.2.36",
"@total-typescript/ts-reset": "0.5.1",
"@types/glob": "8.1.0",
"@types/react": "18.3.2",
"@typescript-eslint/eslint-plugin": "7.9.0",
"@types/jest": "29.5.12",
"@types/node": "20.12.12",
"cypress": "13.9.0",
"cypress-codegen": "workspace:*",
"eslint": "8.57.0",
"eslint-plugin-cypress": "3.2.0",
"eslint-plugin-eslint-comments": "3.2.0",
"eslint-plugin-filenames": "1.3.2",
"eslint-plugin-github": "4.10.2",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-jest": "28.5.0",
"eslint-plugin-prettier": "5.1.3",
"husky": "9.0.11",
"jest": "29.7.0",
"eslint": "9.3.0",
"eslint-plugin-cypress": "3.2.0",
"react": "18.3.1",
"react-dom": "18.3.1",
"semantic-release": "23.1.1",
"tsup": "8.0.2",
"typescript": "5.4.5",
"typescript-eslint": "7.9.0",
"vite": "5.2.11"
},
"scripts": {
"build": "pnpm --filter cypress-codegen build",
"build": "tsup src/index.ts src/cli.ts --clean --dts",
"cypress:open": "cypress open",
"cypress:component": "cypress run --component",
"cypress:e2e": "cypress run",
"format": "prettier --write .",
"format-check": "prettier .",
"lint": "pnpm --filter cypress-codegen lint",
"prepare": "husky install",
"setup-cli": "pnpm i && pnpm build && pnpm i",
"test": "pnpm --filter cypress-codegen test"
"lint": "eslint .",
"prepack": "bun run build",
"prepare": "husky",
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
},
"jest": {
"transform": {
"^.+\\.(j|t)sx?$": "@swc/jest"
},
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
"clearMocks": true
}
}
2 changes: 0 additions & 2 deletions packages/cypress-codegen/.eslintignore

This file was deleted.

Loading

0 comments on commit c7fe315

Please sign in to comment.