-
Notifications
You must be signed in to change notification settings - Fork 1
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
Changes from all commits
60dd36d
bcbed74
6cb3a8a
10d0692
c53f572
a3f83df
c29d623
558162d
0d9698c
a219502
79b0149
8590905
cb84d16
45bb65a
bd21091
6534d6d
36af6af
7a72cbb
3c81c16
d081e4b
db231d9
741e67f
bdd3b74
30367c9
3c408df
38df653
d57d2dd
eef8d21
0faeabb
5fc724f
80676be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# To get started with Dependabot version updates, you'll need to specify which | ||
# package ecosystems to update and where the package manifests are located. | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file | ||
|
||
version: 2 | ||
|
||
updates: | ||
- package-ecosystem: github-actions | ||
directory: / | ||
schedule: | ||
interval: monthly | ||
commit-message: | ||
prefix: ci | ||
|
||
- package-ecosystem: npm # See documentation for possible values | ||
directories: | ||
- / # Location of package manifests | ||
- /recipies/* | ||
commit-message: | ||
prefix: deps | ||
schedule: | ||
interval: weekly |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# 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@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
- run: npm ci | ||
- run: npm run lint | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be done in sub steps ? I'm no sure. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 format | ||
- run: npm run test:types | ||
|
||
tests: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
JakobJingleheimer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
node: | ||
- version: 23.x | ||
- version: 22.x | ||
# glob is not backported below 22.x | ||
os: | ||
- macos-latest | ||
- ubuntu-latest | ||
- windows-latest | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 | ||
- name: Set up Node.js ${{ matrix.node.version }} | ||
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # 4.1.0 | ||
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
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# Commonly ignored Node.js files | ||
node_modules | ||
npm-debug.log | ||
.npm | ||
.env.* | ||
|
||
# OSX | ||
.DS_Store |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
23 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we recommend odd versions? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's what I was thinking. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. may be use LTS for dev and recommend it for prod (cli usage of the tool) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these would not be used in prod? @alexweej perhaps your use-case is different than what I'm imagining. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"recommendations": [ | ||
"biomejs.biome" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "biomejs.biome", | ||
"javascript.updateImportsOnFileMove.enabled": "always", | ||
"typescript.updateImportsOnFileMove.enabled": "always" | ||
Comment on lines
+4
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to set an additional property so that VS Code doesn't change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've no idea, but I think this behaviour is gone now, but not for sure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definitely not gone. It happened to me like yesterday. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# 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. | ||
|
||
> [!NOTE] | ||
> 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`. | ||
|
||
## Before pushing a commit | ||
|
||
A convenient superset of checks is available via `node --run pre-commit`, which automatically fixes formatting and linting issues, checks types, and runs unit and end-to-end tests. Changes resulting from this should be committed. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright Contributors to the Userland Migrations project. | ||
|
||
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. |
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.link/nodejs-official). |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
{ | ||
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", | ||
"formatter": { | ||
"indentStyle": "tab", | ||
"lineWidth": 100 | ||
}, | ||
// Rules for the linter | ||
"linter": { | ||
"rules": { | ||
"style": { | ||
"useImportType": "error", | ||
"useNodeAssertStrict": "error", | ||
"useNodejsImportProtocol": "error" | ||
}, | ||
"suspicious": { | ||
"noExplicitAny": "error", | ||
"noEmptyBlock": "error", | ||
"noDuplicateAtImportRules": "error", | ||
"noDuplicateObjectKeys": "error" | ||
}, | ||
"correctness": { | ||
"noUnusedVariables": "error", | ||
"useArrayLiterals": "off", | ||
"noUnknownFunction": "error" | ||
}, | ||
"nursery": { | ||
"noEnum": "error" | ||
} | ||
} | ||
}, | ||
// Language specific settings | ||
"javascript": { | ||
"formatter": { | ||
"semicolons": "always", | ||
"quoteStyle": "single", | ||
"trailingCommas": "all" | ||
}, | ||
"linter": { | ||
"enabled": true | ||
} | ||
}, | ||
"json": { | ||
"formatter": { | ||
"enabled": false | ||
} | ||
}, | ||
// VSC specific settings | ||
"vcs": { | ||
"enabled": true, | ||
"clientKind": "git" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
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`); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should have 2 separate ones then so we can differentiate between the root repo and recipes (cuz if we apply your suggestion, it will mark changes to the root repo's deps as belonging to a recipe).