Skip to content

Commit

Permalink
Simplify and improve the js environment by using bun
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Jun 3, 2024
1 parent dcc70e7 commit e1a6aa4
Show file tree
Hide file tree
Showing 25 changed files with 261 additions and 11,474 deletions.
8 changes: 2 additions & 6 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ Here are a few useful information for contributors:
the [locales readme instructions here](https://github.com/ddnexus/pagy/blob/master/gem/locales/README.md).
3. **Pagy repo setup**
- Clone pagy: `git clone https://github.com/ddnexus/pagy && cd pagy`
- Install the gems: `bundle install`
- Install node if not present...
- Optional: install pnpm. It's better if you use corepack to get the right version from package.json
([instructions](https://pnpm.io/installation#using-corepack))
- Install modules: `npm install` (or `pnpm install`)
4. **Development**
- Please create your own branch out of `master` and use it for you development and PR
- Ensure you are basing your PR on the `master` branch and keep rebasing it on `master` when it changes
Expand All @@ -25,7 +20,8 @@ Here are a few useful information for contributors:
with the [Pagy::Console](https://ddnexus.github.io/pagy/docs/api/console/) directly from the repo
- **Docs**
- `cd` in the pagy root directory
- Run `npm install` or (`pnpm install` if pnpm is installed).
- Install [bun](https://bun.sh/docs/installation)
- Run `bun install`
- Run `retype start`
- Point your browser at `http://localhost:5000/pagy` for real-time feedback
5. **Testing**
Expand Down
17 changes: 7 additions & 10 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
"gem/**",
"e2e/**",
"Gemfile.lock",
"pnpm.lock.yaml"
"bun.lockb"
]'
paths_ignore: '[
"gem/config/**",
Expand All @@ -51,20 +51,17 @@ jobs:
with:
ruby-version: '3.3'
bundler-cache: true
- name: Install Pnpm
uses: pnpm/action-setup@v4
- name: Install Node / Setup Pnpm Cache
uses: actions/setup-node@v4
- name: Install bun
uses: oven-sh/setup-bun@v1
with:
node-version: 20
cache: 'pnpm'
bun-version: latest
- name: Install Dependencies
run: bun install --frozen-lockfile
- name: Setup Cypress Cache
uses: actions/cache@v4
with:
path: /home/runner/.cache/Cypress
key: ${{ runner.os }}-cypress-cache-${{ hashFiles('pnpm-lock.yaml') }}
- name: Install Dependencies
run: pnpm install --frozen-lockfile
key: ${{ runner.os }}-cypress-cache-${{ hashFiles('bun.lockb') }}
- name: Cypress [${{ matrix.app }}] Test
uses: cypress-io/github-action@v6
with:
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@
/coverage/
/gem/pkg/
node_modules/
pnpm/
tmp/
/retype.manifest
.pnpm-debug.log
8 changes: 5 additions & 3 deletions .idea/runConfigurations/npm_check.xml

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

2 changes: 0 additions & 2 deletions .npmrc

This file was deleted.

1 change: 0 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ AllCops:
- gem/lib/pagy/extras/materialize.rb
- gem/lib/pagy/extras/semantic.rb
- gem/lib/pagy/extras/uikit.rb
- pnpm/**/*
- src/**/*
- vendor/**/* # fix the problem with github ruby

Expand Down
Binary file added bun.lockb
Binary file not shown.
38 changes: 0 additions & 38 deletions docs/api/javascript/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,44 +65,6 @@ Your app needs standard script or old browser compatibility
script_path = Pagy.root.join('javascripts', 'pagy.js')
```

<details>
<summary> Browser compatibility list: </summary>

- and_chr 103
- and_ff 101
- and_qq 10.4
- and_uc 12.12
- android 103
- chrome 103
- chrome 102
- chrome 101
- edge 103
- edge 102
- firefox 102
- firefox 101
- firefox 91
- ios_saf 15.5
- ios_saf 15.4
- ios_saf 15.2-15.3
- ios_saf 14.5-14.8
- ios_saf 14.0-14.4
- ios_saf 12.2-12.5
- kaios 2.5
- op_mini all
- op_mob 64
- opera 87
- opera 86
- opera 85
- safari 15.5

!!! info
You can generate custom targeted `pagy.js` files for the browsers you want to support by changing
the [browserslist](https://github.com/browserslist/browserslist) query in `src/package.json`, then compile it
with `cd src && npm run build`.
!!!

</details>

+++ `pagy-dev.js`

!!! success
Expand Down
5 changes: 4 additions & 1 deletion e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ enabled ASAP.

## 2. Run E2E Tests On Your System

Run `npm install` or (`pnpm install` if `pnpm` is installed).
The test environment uses [bun](https://bun.sh) ([cypress still needs node ATM](https://github.com/cypress-io/cypress/issues/28962) )
- Install [bun](https://bun.sh/docs/installation)
- Optional for updating: install `npm-check`: `bun install -g npm-check`.
- Install modules: `bun install`

### Run the test for all the apps

Expand Down
6 changes: 3 additions & 3 deletions e2e/cy-test
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ cd -- "$(dirname "$0")"

test () {
NODE_NO_WARNINGS=1 \
pnpm exec start-test "bundle exec pagy $app -p $port -q > /dev/null" http://0.0.0.0:$port \
"pnpm exec cypress run --quiet --config baseUrl=http://0.0.0.0:$port --spec cypress/e2e/$app.cy.ts"
start-test "bundle exec pagy $app -p $port -q > /dev/null" "http://0.0.0.0:$port" \
"cypress run --quiet --config baseUrl=http://0.0.0.0:$port --spec cypress/e2e/$app.cy.ts"
}

if [[ -z $app ]]
then
for app in demo repro rails calendar
do
port=$[port+1]
port=$((port+1))
test &
done
for p in $(jobs -p)
Expand Down
37 changes: 17 additions & 20 deletions e2e/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
{
"name": "pagy.e2e",
"description": "Pagy E2E Testing",
"private": true,
"type": "module",
"engines": {
"node": ">=20.9.0"
},
"devDependencies": {
"@cypress/snapshot": "^2.1.7",
"@types/node": "20.13.0",
"cypress": "13.10.0",
"cypress-html-validate": "6.1.0",
"eslint-plugin-cypress": "3.3.0",
"eslint-plugin-promise": "6.2.0",
"html-validate": "8.19.1",
"start-server-and-test": "2.0.3"
},
"scripts": {
"lint-fix": "eslint --fix cypress --ext .ts"
}
"name": "pagy.e2e",
"description": "Pagy E2E Testing",
"private": true,
"type": "module",
"devDependencies": {
"@cypress/snapshot": "^2.1.7",
"@types/node": "20.14.0",
"cypress": "13.10.0",
"cypress-html-validate": "6.1.0",
"eslint-plugin-cypress": "3.3.0",
"eslint-plugin-promise": "6.2.0",
"html-validate": "8.20.0",
"start-server-and-test": "2.0.3"
},
"scripts": {
"lint-fix": "eslint --fix cypress --ext .ts"
}
}
Loading

0 comments on commit e1a6aa4

Please sign in to comment.