Skip to content

Commit a70cd2d

Browse files
authored
Chore: Updates to modern npm and more... (#365)
- Switch from `yarn` to `npm` - Remove all benchmarks - Hone fixture down to just npm `simple` version
1 parent d7174b9 commit a70cd2d

39 files changed

+28818
-38764
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,10 @@ jobs:
1212
build:
1313
runs-on: ${{ matrix.os }}
1414

15-
# TODO(NODE16): Re-enable node16.
16-
# Presently, serverless has _huge_ zips that are way bigger than expected
17-
# on node16 (which also fails tests). We might just upgrade serverless
18-
# first, then reenable tests.
19-
# https://github.com/FormidableLabs/serverless-jetpack/issues/239
2015
strategy:
2116
matrix:
2217
os: [ubuntu-latest, windows-latest]
23-
node-version: [12.x, 14.x]
18+
node-version: [22.x, 24.x]
2419

2520
steps:
2621
# Checkout
@@ -29,27 +24,23 @@ jobs:
2924
uses: actions/setup-node@v4
3025
with:
3126
node-version: ${{ matrix.node-version }}
32-
cache: "yarn"
3327

3428
- name: Use node_modules cache
3529
id: node-modules-cache
3630
uses: actions/cache@v4
3731
with:
3832
path: node_modules
39-
key: node-modules-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('./yarn.lock') }}
33+
key: node-modules-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('./package-lock.json') }}
4034
restore-keys: |
4135
node-modules-${{ runner.os }}-${{ matrix.node-version }}-
4236
node-modules-${{ runner.os }}-
4337
4438
- name: Project installation
4539
if: steps.node-modules-cache.outputs.cache-hit != 'true'
46-
run: yarn install --prefer-offline --frozen-lockfile --non-interactive
40+
run: npm ci
4741
env:
4842
CI: true
4943

50-
- name: Checks (lint, unit tests)
51-
run: yarn run check
52-
5344
# Caching: test scenarios
5445
# **Note**: _don't_ use permissive restore-keys because we skip installs
5546
# all together.
@@ -58,22 +49,15 @@ jobs:
5849
uses: actions/cache@v4
5950
with:
6051
path: |
61-
test/packages/*/npm/node_modules
62-
test/packages/*/yarn/node_modules
63-
key: test-packages-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('test/packages/*/npm/package-lock.json', 'test/packages/*/yarn/yarn.lock') }}
52+
test/packages/*/node_modules
53+
key: test-packages-${{ runner.os }}-${{ matrix.node-version }}-${{ hashFiles('test/packages/*/package-lock.json') }}
6454

65-
# Detect if `test/packages/*/*/node_modules` exists in any form and skip
66-
# installs on a per-directory basis.
67-
- name: Benchmark installation
68-
if: steps.test-packages-cache.outputs.cache-hit != 'true'
69-
run: yarn benchmark:ci --skip-if-exists
70-
env:
71-
CI: true
55+
- name: Install test fixtures
56+
run: npm run test:install
7257

73-
- name: CLI tests
74-
run: yarn test:cli
58+
# Note: linting also catches the `test/packages/*` fixtures.
59+
- name: Checks (lint, unit tests)
60+
run: npm run check
7561

76-
- name: Benchmark
77-
run: yarn benchmark --parallel
78-
- name: Benchmark tests
79-
run: yarn benchmark:test
62+
- name: CLI tests
63+
run: npm run test:cli

.github/workflows/release.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,23 @@ jobs:
1919
- uses: actions/checkout@v4
2020
- uses: actions/setup-node@v4
2121
with:
22-
node-version: 18
22+
node-version: 24
2323

2424
- name: Install dependencies
25-
run: yarn install --frozen-lockfile
25+
run: npm ci
2626

2727
- name: Build
28-
run: yarn build
29-
30-
- name: Testing Setups
31-
run: yarn benchmark:ci
28+
run: npm run build
3229

3330
- name: Unit Tests
34-
run: yarn test:cli
31+
run: npm run test:cli
3532

3633
- name: PR or Publish
3734
id: changesets
3835
uses: changesets/action@v1
3936
with:
40-
version: yarn changeset version
41-
publish: yarn changeset publish
37+
version: npm exec changeset version
38+
publish: npm exec changeset publish
4239
env:
4340
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4441
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
node_modules
77
npm-debug.log*
88
yarn-error.log*
9-
/package-lock.json
9+
yarn.lock
1010
/all-lock-files.txt
1111

1212
aws/.service*

.nvmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

CONTRIBUTING.md

Lines changed: 14 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -5,116 +5,27 @@ Thanks for contributing!
55

66
## Development
77

8-
We primarily develop in `yarn`, but use `npm` in our benchmarks. Please make sure to have something like:
8+
We manage dependencies using `npm`. Note that for the time being, our development tools assume a Unix-like environment, which means Mac, Linux, or something like the Windows Subsystem for Linux.
99

10-
* node: `8+`
11-
* yarn: (anything modern)
12-
* npm: (anything modern)
13-
14-
available. Also note that for the time being, our development tools assume a Unix-like environment, which means Mac, Linux, or something like the Windows Subsystem for Linux.
15-
16-
Our development revolves around various fixture packages we have in `test`. Get set up with:
17-
18-
```sh
19-
$ yarn
20-
21-
# If not changing deps
22-
$ yarn benchmark:ci
23-
# If changing deps
24-
$ yarn benchmark:install
25-
```
26-
27-
to install the root project and a lot of fixture packages. (This is **meant** to take a while as we install a lot of dependencies to give us sizable app simulations to work with...) You will need to re-run `benchmark:install` whenever you update dependencies inside `test/` packages.
28-
29-
Our present fixture setup is:
30-
31-
```
32-
$ tree test/packages/ -L 2
33-
test/packages/
34-
├── complex
35-
│   ├── npm
36-
│   └── yarn
37-
└── simple
38-
├── npm
39-
└── yarn
40-
```
41-
42-
**Note**: Only **some** of the scenarios contribute to the timed benchmark results as some scenarios don't actually use either built-in Serverless or Jetpack packaging.
43-
44-
For ease of development, we want to do `yarn benchmark:ci`/`yarn benchmark:install` and install the respective yarn/npm packages **once**. However, this means we keep duplicates of source code / package.json files across the `npm`/`yarn` variant directories. To keep things in sync, we designate the `yarn` directory as "the source of truth" for everything except for `SCENARIO/npm/package-lock.json` and copy files across scenarios with:
45-
46-
```sh
47-
$ yarn benchmark:build
48-
```
49-
50-
From there you can run various packaging configurations and perform benchmarks.
51-
52-
```sh
53-
$ TEST_PKG=yarn TEST_SCENARIO=simple yarn benchmark
54-
$ TEST_PKG=yarn TEST_SCENARIO=simple,complex yarn benchmark
55-
$ TEST_PKG=yarn,npm TEST_SCENARIO=simple yarn benchmark
56-
57-
# Faster, because scenarios run in parallel, but less reliable results because
58-
# of impact on your machine. Use this for faster development, but do a normal
59-
# serial benchmark for pasting results.
60-
# ... using all CPU cores
61-
$ yarn benchmark --parallel
62-
# ... or set the level of concurrency manually
63-
$ yarn benchmark --concurrency=2
64-
```
65-
66-
After this, we can run benchmark specific QA stuff:
10+
Get set up with:
6711

6812
```sh
69-
$ yarn benchmark:test
13+
$ npm install
14+
$ npm run test:install
7015
```
7116

72-
(The `lint` needs the individual installs and `test` needs file list output from a full benchmark).
17+
to install the root project and our test fixtures.
7318

7419
## Checks
7520

76-
### Fast stuff
77-
7821
Run these often -- unit tests and lint:
7922

8023
```sh
81-
$ yarn lint
82-
$ yarn test
24+
$ npm run lint
25+
$ npm run test
8326

8427
# ... or all together ...
85-
$ yarn run check
86-
```
87-
88-
### Slow stuff
89-
90-
Run these before a PR and when changing things / kicking tires...
91-
92-
*Requirements*: For CLI and benchmark tests...
93-
94-
```sh
95-
# Install once (or on changes to dependencies or fixtures)
96-
$ yarn benchmark:ci # or yarn benchmark:install if changing deps
97-
$ yarn benchmark:build
98-
```
99-
100-
*CLI tests*: Use the fixtures
101-
102-
```sh
103-
$ yarn test:cli
104-
```
105-
106-
*Benchmark tests*: Run the benchmark to gather data and assess correctness of packages vs. real Serverless.
107-
108-
```sh
109-
$ yarn benchmark
110-
$ yarn benchmark:test
111-
```
112-
113-
*Serverless Enterprise*: Unfortunately, these tests require a login account and special `SERVERLESS_ACCESS_KEY` environment variable. The Jetpack project has two active tokens for `localdev` and `ci`. You can enable these and our `dashboard` tests with something like:
114-
115-
```sh
116-
$ SERVERLESS_ACCESS_KEY="<INSERT_HERE>" yarn benchmark
117-
$ SERVERLESS_ACCESS_KEY="<INSERT_HERE>" yarn benchmark:test
28+
$ npm run check
11829
```
11930

12031
## Before submitting a PR...
@@ -123,34 +34,14 @@ Before you go ahead and submit a PR, make sure that you have done the following:
12334

12435
```sh
12536
# Update the documentation TOCs (and commit changes).
126-
$ yarn run build
37+
$ npm run build
12738

12839
# Run lint and unit tests
129-
$ yarn run check
130-
131-
# Make sure all fixtures are updated and valid
132-
$ yarn benchmark:install
133-
$ yarn benchmark:ci
134-
$ yarn benchmark:build
40+
$ npm run check
13541

13642
# After this, you can run the CLI tests which use real fixtures in E2E scenarios
137-
# They're relatively slow (several seconds a test), but nowhere near as slow
138-
# as the benchmark.
139-
$ yarn test:cli
140-
141-
# Run a benchmark.
142-
# Then, actually generate the benchmark.
143-
# _Note_: Unfortunately, this takes some **time**. Grab a ☕
144-
$ yarn benchmark
145-
# Now, test the benchmark for correctness.
146-
$ yarn benchmark:test
147-
148-
# If the timed benchmark stats and/or usage is notably different
149-
# than what's in README.md, update relevant sections and commit your changes.
150-
$ vim README.md
151-
152-
# Run all final checks.
153-
$ yarn run check
43+
# They're relatively slow (several seconds a test).
44+
$ npm run test:cli
15445
```
15546

15647
### Using changesets
@@ -168,7 +59,7 @@ Here are more details:
16859
When you would like to add a changeset (which creates a file indicating the type of change), in your branch/PR issue this command:
16960

17061
```sh
171-
$ yarn changeset
62+
$ npm exec changeset
17263
```
17364

17465
to produce an interactive menu. Navigate the packages with arrow keys and hit `<space>` to select 1+ packages. Hit `<return>` when done. Select semver versions for packages and add appropriate messages. From there, you'll be prompted to enter a summary of the change. Some tips for this summary:
@@ -211,4 +102,4 @@ On the merge of a version packages PR, the changesets GitHub action will publish
211102
4. Run `npm publish` and publish to NPM if all is well.
212103
5. Run `git push && git push --tags`
213104

214-
</details>
105+
</details>

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2019 Formidable Labs
3+
Copyright (c) 2025 Nearform
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)