Skip to content

Commit bc3535e

Browse files
Modernize script deployment CLI (#93)
* Modernize script deployment CLI * Fix BrowserStack pnpm setup * Update BrowserStack tests for Node 24 --------- Co-authored-by: Adriaan van Rossum <1079135+adriaanvanrossum@users.noreply.github.com>
1 parent a87e9e0 commit bc3535e

12 files changed

Lines changed: 4930 additions & 9340 deletions

File tree

.github/workflows/browserstack.yml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ jobs:
99
runs-on: ubuntu-latest
1010
if: "${{ github.event.action != 'unlabeled' || github.event.label.name == 'skip: browserstack' }}"
1111

12-
strategy:
13-
matrix:
14-
node-version: [16.16]
15-
1612
steps:
1713
- name: Check BrowserStack skip label
1814
id: browserstack
@@ -40,16 +36,23 @@ jobs:
4036
ref: ${{ github.head_ref }}
4137
set-safe-directory: "/github/workspace"
4238

43-
- name: Use Node.js ${{ matrix.node-version }}
39+
- name: Set up pnpm
40+
uses: pnpm/action-setup@v4
41+
with:
42+
version: 11.17.0
43+
44+
- name: Use Node.js from .nvmrc
4445
uses: actions/setup-node@v6
4546
with:
46-
node-version: ${{ matrix.node-version }}
47+
node-version-file: .nvmrc
48+
cache: pnpm
49+
cache-dependency-path: pnpm-lock.yaml
4750

48-
- name: Run npm ci
49-
run: sudo npm ci
51+
- name: Install dependencies
52+
run: pnpm install --frozen-lockfile
5053

5154
- name: Test BrowserStack matrix selection
52-
run: npm run test:matrix
55+
run: pnpm run test:matrix
5356

5457
- name: Prettier check (report only, no writes or commits)
5558
if: always()
@@ -64,9 +67,9 @@ jobs:
6467
echo '```'
6568
} >> "$GITHUB_STEP_SUMMARY"
6669
67-
- name: Run npm test with BrowserStack Local
70+
- name: Run tests with BrowserStack Local
6871
if: steps.browserstack.outputs.skip != 'true'
69-
run: npm run build && node ./test/index.js
72+
run: pnpm run build && node ./test/index.js
7073
env:
7174
CI: true
7275
NODE_ENV: test

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16.16
1+
24.18.0

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,26 @@ If you want to contribute, you probabaly want to contribute to our [`/src/defaul
2020

2121
In `default.js` you see some weird syntax in the comments. For example, `/** if ignorepages **/` _\[some code\]_ `/** endif **/`. These comments are converted to handlebars like this: `{{#if ignorepages }}` _\[some code\]_ `{{/if}}`. In this case, [`ignorepages` is a variable](https://github.com/simpleanalytics/scripts/blob/3874b44ce5f1b0b8a7d50fb512fdcf5285a0138f/minify.js#L66) used in `minify.js` that takes care of what functionality to show in what script. Our main script is the `latest.js` script which includes all features. We also have a `light.js` script that obviously doesn't.
2222

23-
If you contribute, make sure to use `npm run build`, copy the script to a website, and check if it works correctly.
23+
If you contribute, make sure to use `pnpm run build`, copy the script to a website, and check if it works correctly.
2424

2525
## Run this locally
2626

27-
Just run `npm run watch` and every file will be validated and compiled on save. We minify our scripts with [UglifyJS](http://lisperator.net/uglifyjs/), a well-known JavaScript minifier.
27+
Install the pinned Node and pnpm versions, run `pnpm install --frozen-lockfile`, and then use `pnpm run watch`. Every file will be validated and compiled on save. We minify our scripts with [UglifyJS](http://lisperator.net/uglifyjs/), a well-known JavaScript minifier.
2828

2929
The most important file of the repository is [`/src/default.js`](src/default.js)
3030

31+
## Deploy
32+
33+
Build and commit the distribution files before deploying. The deployment command itself never builds or changes local distribution files.
34+
35+
```sh
36+
pnpm run deploy
37+
```
38+
39+
The interactive CLI starts in dry-run mode by default. It lets you select scripts and destinations, reads the deployed files, and shows every affected path plus the first-line script-header diff. Choosing a real deployment requires a clean repository and a second confirmation.
40+
41+
CDN writes use `BUNNY_SCRIPTS_ACCESS_KEY` and `BUNNY_SCRIPTS_ACCOUNT_KEY` from `.env`. Custom-domain reads and writes require SSH access to `app@external.simpleanalytics.com`.
42+
3143
## Device testing is sponsored by BrowserStack
3244

3345
We run our public script on a live, representative matrix of [browsers and real devices](https://github.com/simpleanalytics/scripts/blob/main/test/helpers/get-browsers.js). Simple Analytics supports vendor-maintained browser, OS, and device versions and continues compatibility testing for two years after published end of life. Older browser versions with more than 0.1% global usage remain covered. We get amazing sponsorship from [BrowserStack](https://www.browserstack.com/). Thanks, BrowserStack!

0 commit comments

Comments
 (0)