Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: set up initial actions & docs #1

Merged
merged 31 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
60dd36d
chore: set up initial actions & docs
JakobJingleheimer Nov 21, 2024
bcbed74
fixup!: remove erroneous main field
JakobJingleheimer Nov 21, 2024
6cb3a8a
ci(test): create job matrix & rename `test:lint` → `lint`
JakobJingleheimer Nov 21, 2024
10d0692
doc: add license file
JakobJingleheimer Nov 21, 2024
c53f572
fixup!: rename jobs to be more indicative
JakobJingleheimer Nov 21, 2024
a3f83df
fixup!: correct `-test` → `--test`
JakobJingleheimer Nov 21, 2024
c29d623
fixup!: remove nonexistent "markdown" in biome config
JakobJingleheimer Nov 21, 2024
558162d
add git things
AugustinMauroy Nov 21, 2024
0d9698c
update biome things
AugustinMauroy Nov 21, 2024
a219502
Create .nvmrc
AugustinMauroy Nov 21, 2024
79b0149
add recipes dir
AugustinMauroy Nov 21, 2024
8590905
Fix typo
AugustinMauroy Nov 21, 2024
cb84d16
workflows: use `--run`
AugustinMauroy Nov 21, 2024
45bb65a
add more rules
AugustinMauroy Nov 21, 2024
bd21091
chore: alphabetise npm scripts
JakobJingleheimer Nov 23, 2024
6534d6d
test(ci): add `pre-commit` superset
JakobJingleheimer Nov 23, 2024
36af6af
chore: fix tsconfig
JakobJingleheimer Nov 23, 2024
7a72cbb
chore(ci): switch angry `node --run` → `npm run`
JakobJingleheimer Nov 23, 2024
3c81c16
chore: adjust glob pattern for angry CI
JakobJingleheimer Nov 25, 2024
d081e4b
test(ci): move coverage to only node 23.x
JakobJingleheimer Nov 25, 2024
db231d9
Revert "test(ci): move coverage to only node 23.x"
JakobJingleheimer Nov 25, 2024
741e67f
test(ci): remove 20.x
JakobJingleheimer Nov 25, 2024
bdd3b74
test(ci): switch actions from tag to SHA to avoid supply-chain vulner…
JakobJingleheimer Nov 25, 2024
30367c9
chore(dep): upgrade `typescript` to `5.7.2`
JakobJingleheimer Nov 25, 2024
3c408df
doc: update codemod registry link
JakobJingleheimer Nov 25, 2024
38df653
fixup!: remove biome bumperstickers
JakobJingleheimer Nov 25, 2024
d57d2dd
doc(license): set copyright holder & remove file extension
JakobJingleheimer Nov 27, 2024
eef8d21
[actions] use ljharb/actions/node/matrix (#3)
ljharb Nov 28, 2024
0faeabb
Revert "[actions] use ljharb/actions/node/matrix" (#4)
JakobJingleheimer Nov 28, 2024
5fc724f
ci: add dependabot
JakobJingleheimer Nov 28, 2024
80676be
fixup!: correct md block type
JakobJingleheimer Nov 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# For more information see: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow

name: CI

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
lint-and-types:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [23.x]
steps:
- uses: actions/checkout@v4
JakobJingleheimer marked this conversation as resolved.
Show resolved Hide resolved
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run lint
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be done in sub steps ? I'm no sure.
@bmuenzenmeyer is more of an expert on this than I am

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its fine as long as you think linting and types go hand in hand here 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not especially, but the have the same setup and separating them into their own jobs seemed wasteful—no need to create a fresh environment for each; they don't affect each other.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasteful for who? actions are free.

Tests run in a matrix; linting only ever needs to run once; it’s generally best to split it for CI hygiene.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Electricity? Spinning up a new environment may not cost us money, but it costs IRL resources—unless I'm misunderstanding what will happen?

- run: npm run test:types
JakobJingleheimer marked this conversation as resolved.
Show resolved Hide resolved

tests:
strategy:
fail-fast: false
matrix:
JakobJingleheimer marked this conversation as resolved.
Show resolved Hide resolved
node:
- version: 23.x
- version: 22.x
- version: 20.x
os:
- macos-latest
- ubuntu-latest
- windows-latest

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- name: Set up Node.js ${{ matrix.node.version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node.version }}
cache: 'npm'
- run: npm ci
- run: npm run test:unit
- run: npm run test:e2e
AugustinMauroy marked this conversation as resolved.
Show resolved Hide resolved
18 changes: 18 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Contributing
JakobJingleheimer marked this conversation as resolved.
Show resolved Hide resolved

A recipe generally has a few things:

* A `README.md` explaining its purpose and use (including any options, and required and optional
files).
* Tests via node's test runner (min coverage: 80%)
* unit tests (file extension: `.spec.mjs` or `.spec.mts`)
* end-to-end test(s) for accepted use-cases (file extension: `.e2e.mjs` or `.e2e.mts`)
* Code comments (js docs, etc)
* Types (either via typescript or jsdoc)

CI will run lint & type checking and all included test files against all PRs.

> [!INFO]
> snapshots will be generated with the file extension `.snap.cjs`.

New recipes are added under `./recipes` in their own folder, succinctly named for what it does. General-purpose recipes have simple names like `correct-ts-specifiers`. A suite of migrations has a name like `migrate from 18 to 20`, and more specific migrations are named like `migrate fs.readFile from 18 to 20`.
21 changes: 21 additions & 0 deletions LICENSE.txt
JakobJingleheimer marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) [year] [fullname]
JakobJingleheimer marked this conversation as resolved.
Show resolved Hide resolved

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
# Node.js userland migrations

This repository contains codemodes (automated migrations) for "userland" code. These are intended to facilitate adopting new features and upgrading source-code affected by breaking changes.

## Usage

> [!CAUTION]
> These scripts change source code. Commit any unsaved changes before running them. Failing to do so may ruin your day.

To run the transform scripts use [`codemod`](https://go.codemod.com/github) command below:

```console
$ npx codemod <transform> --target <path> [...options]
```

* `transform` - name of transform. see available transforms below.
* `path` - directory to transform. defaults to the current directory.

See the [codemod CLI doc](https://go.codemod.com/cli-docs) for a full list of available commands.

## Available codemods

All Node.js codemods are also available in the [Codemod Registry](https://codemod.com/registry?framework=node.js).
AugustinMauroy marked this conversation as resolved.
Show resolved Hide resolved
23 changes: 23 additions & 0 deletions biome.jsonc
AugustinMauroy marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"formatter": {
"indentStyle": "tab",
"lineWidth": 100
},
"javascript": {
"formatter": {
"semicolons": "always",
"quoteStyle": "single",
"trailingCommas": "all"
},
"linter": {
"style": {
"useImportType": true
}
}
},
"json": {
"formatter": {
"enabled": false
}
}
}
18 changes: 18 additions & 0 deletions build/snapshots.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { basename, dirname, extname, join } from 'node:path';
import { snapshot } from 'node:test';


snapshot.setResolveSnapshotPath(generateSnapshotPath);
/**
* @param testFilePath '/tmp/foo.test.js'
* @returns '/tmp/foo.test.snap.cjs'
*/
function generateSnapshotPath(testFilePath?: string) {
if (!testFilePath) return '';

const ext = extname(testFilePath);
const filename = basename(testFilePath, ext);
const base = dirname(testFilePath);

return join(base, `${filename}.snap.cjs`);
}
216 changes: 216 additions & 0 deletions package-lock.json

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

Loading
Loading