Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 4 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,14 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x]
package:
- cli
- core
- matchers
- parser
- rebuild-matchers
- utils
node-version: [18.x]

env:
CI: true

steps:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 7
- uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0

- uses: actions/setup-node@v3
with:
Expand All @@ -34,14 +25,5 @@ jobs:
- name: Install Dependencies
run: pnpm install --frozen-lockfile

- name: Build
working-directory: packages/${{ matrix.package }}
run: pnpm build

- name: Run Linter
working-directory: packages/${{ matrix.package }}
run: pnpm lint

- name: Run Tests
working-directory: packages/${{ matrix.package }}
run: pnpm test
- name: Check
run: pnpm check
1 change: 0 additions & 1 deletion .node-version

This file was deleted.

5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ This project is written with [TypeScript](https://www.typescriptlang.org/), a su

## Developing

codemod expects at least node 16 and pnpm. You can check each of these with `node -v` and `pnpm -v`. Look for instructions on installing node [here](https://nodejs.org) and pnpm [here](https://pnpm.io/).
codemod expects at least node 18 and pnpm 10. You can check each of these with `node -v` and `pnpm -v`. Look for instructions on installing node [here](https://nodejs.org) and pnpm [here](https://pnpm.io/).
As long as you have pnpm 10 or later installed globally, pnpm will automatically run the version of pnpm specified in the `packageManager` field of `package.json`.

### Setup

Expand All @@ -22,7 +23,7 @@ $ pnpm install
Then make sure the tests pass:

```sh
$ pnpm test
$ pnpm check
```

### Running linting/testing
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
"typescript": "^4.4.4"
},
"scripts": {
"prepare": "husky install"
}
"prepare": "husky install",
"build": "pnpm run --recursive build",
"check": "pnpm build && pnpm run --parallel --recursive '/^test$|^lint$/'",
"cli": "pnpm build && packages/cli/bin/codemod"
},
"packageManager": "[email protected]+sha512.ad27a79641b49c3e481a16a805baa71817a04bbe06a38d17e60e2eaee83f6a146c6a688125f5792e48dd5ba30e7da52a5cda4c3992b9ccf333f9ce223af84748"
}
2 changes: 2 additions & 0 deletions packages/cli/__tests__/cli/dry-run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import createTemporaryFile from '../helpers/createTemporaryFile'
import plugin from '../helpers/plugin'
import { runCodemodCLI } from '../helpers/runCodemodCLI'

jest.setTimeout(10_000)

it('processes files but does not replace their contents when using --dry', async function () {
const afile = await createTemporaryFile('a-file.js', '3 + 4;')
expect(
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/__tests__/cli/extensions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import createTemporaryFile, {
import plugin from '../helpers/plugin'
import { runCodemodCLI } from '../helpers/runCodemodCLI'

jest.setTimeout(10_000)

test('can load plugins written with ES modules by default', async function () {
const afile = await createTemporaryFile('a-file.js', '3 + 4;')
expect(
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/__tests__/cli/remote-plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import plugin from '../helpers/plugin'
import { runCodemodCLI } from '../helpers/runCodemodCLI'
import { startServer } from '../helpers/TestServer'

jest.setTimeout(10_000)

test('can load and run with a remote plugin', async () => {
const afile = await createTemporaryFile('a-file.js', '3 + 4;')
const server = await startServer(async (req, res) => {
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/__tests__/cli/source-type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import createTemporaryFile, {
} from '../helpers/createTemporaryFile'
import { runCodemodCLI } from '../helpers/runCodemodCLI'

jest.setTimeout(10_000)

it('can specify the source type as "script"', async function () {
const afile = await createTemporaryFile(
'a-file.js',
Expand Down
14 changes: 1 addition & 13 deletions packages/cli/bin/codemod
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
#!/usr/bin/env node

if (process.env.CODEMOD_RUN_WITH_ESBUILD) {
require('esbuild-runner/register')
}

const run = (() => {
try {
return require('../src').default
} catch {
// ignore
}

try {
return require('../').default
} catch {
process.stderr.write(
'codemod does not seem to be built and the development files could not be loaded'
)
process.stderr.write('codemod does not seem to be built')
process.exit(1)
}
})()
Expand Down
6 changes: 0 additions & 6 deletions packages/cli/bin/codemod-dev

This file was deleted.

6 changes: 3 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepublishOnly": "pnpm clean && pnpm build",
"test": "is-ci test:coverage test:watch",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch"
"test": "is-ci test:coverage test:basic",
"test:basic": "jest",
"test:coverage": "jest --coverage"
},
"dependencies": {
"@babel/core": "^7.20.12",
Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepublishOnly": "pnpm clean && pnpm build",
"test": "is-ci test:coverage test:watch",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch"
"test": "is-ci test:coverage test:basic",
"test:basic": "jest",
"test:coverage": "jest --coverage"
},
"dependencies": {
"@babel/core": "^7.20.12",
Expand Down
6 changes: 3 additions & 3 deletions packages/matchers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepublishOnly": "pnpm clean && pnpm build",
"test": "is-ci test:coverage test:watch",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch"
"test": "is-ci test:coverage test:basic",
"test:basic": "jest",
"test:coverage": "jest --coverage"
},
"dependencies": {
"@babel/types": "^7.20.7",
Expand Down
6 changes: 3 additions & 3 deletions packages/parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepublishOnly": "pnpm clean && pnpm build",
"test": "is-ci test:coverage test:watch",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch"
"test": "is-ci test:coverage test:basic",
"test:basic": "jest",
"test:coverage": "jest --coverage"
},
"dependencies": {
"@babel/parser": "^7.20.15"
Expand Down
6 changes: 3 additions & 3 deletions packages/rebuild-matchers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepublishOnly": "pnpm clean && pnpm build",
"test": "is-ci test:coverage test:watch",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch"
"test": "is-ci test:coverage test:basic",
"test:basic": "jest",
"test:coverage": "jest --coverage"
},
"dependencies": {
"@babel/types": "^7.20.7",
Expand Down
6 changes: 3 additions & 3 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepublishOnly": "pnpm clean && pnpm build",
"test": "is-ci test:coverage test:watch",
"test:coverage": "jest --coverage",
"test:watch": "jest --watch"
"test": "is-ci test:coverage test:basic",
"test:basic": "jest",
"test:coverage": "jest --coverage"
},
"dependencies": {
"@babel/core": "^7.20.12",
Expand Down
Loading
Loading