Skip to content

Commit 7917fd2

Browse files
committed
Add codemods-cli setup
1 parent dbcc556 commit 7917fd2

File tree

9 files changed

+173
-0
lines changed

9 files changed

+173
-0
lines changed

packages/rtk-codemods2/.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
!.*
2+
__testfixtures__

packages/rtk-codemods2/.eslintrc.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
module.exports = {
2+
parserOptions: {
3+
ecmaVersion: 2018,
4+
},
5+
6+
plugins: ['prettier', 'node'],
7+
extends: ['eslint:recommended', 'plugin:prettier/recommended', 'plugin:node/recommended'],
8+
env: {
9+
node: true,
10+
},
11+
rules: {},
12+
overrides: [
13+
{
14+
files: ['__tests__/**/*.js'],
15+
env: {
16+
jest: true,
17+
},
18+
},
19+
],
20+
};
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
- 'v*' # older version branches
9+
tags:
10+
- '*'
11+
pull_request: {}
12+
schedule:
13+
- cron: '0 6 * * 0' # weekly, on sundays
14+
15+
jobs:
16+
lint:
17+
name: Linting
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v1
22+
- uses: actions/setup-node@v1
23+
with:
24+
node-version: 12.x
25+
- name: install dependencies
26+
run: yarn install --frozen-lockfile
27+
- name: linting
28+
run: yarn lint
29+
30+
test:
31+
name: Tests
32+
runs-on: ubuntu-latest
33+
34+
strategy:
35+
matrix:
36+
node: ['10', '12', '14']
37+
38+
steps:
39+
- uses: actions/checkout@v1
40+
- uses: actions/setup-node@v1
41+
with:
42+
node-version: ${{ matrix.node }}
43+
- name: install dependencies
44+
run: yarn install --frozen-lockfile
45+
- name: test
46+
run: yarn test
47+
48+
floating-test:
49+
name: Floating dependencies
50+
runs-on: ubuntu-latest
51+
52+
steps:
53+
- uses: actions/checkout@v1
54+
- uses: actions/setup-node@v1
55+
with:
56+
node-version: '12.x'
57+
- name: install dependencies
58+
run: yarn install --no-lockfile
59+
- name: test
60+
run: yarn test

packages/rtk-codemods2/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/node_modules
2+
/.eslintcache

packages/rtk-codemods2/.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "es5",
4+
"printWidth": 100
5+
}

packages/rtk-codemods2/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# rtk-codemods2
2+
3+
4+
A collection of codemods for rtk-codemods2.
5+
6+
## Usage
7+
8+
To run a specific codemod from this project, you would run the following:
9+
10+
```
11+
npx rtk-codemods2 <TRANSFORM NAME> path/of/files/ or/some**/*glob.js
12+
13+
# or
14+
15+
yarn global add rtk-codemods2
16+
rtk-codemods2 <TRANSFORM NAME> path/of/files/ or/some**/*glob.js
17+
```
18+
19+
## Local Usage
20+
```
21+
node ./bin/cli.js <TRANSFORM NAME> path/of/files/ or/some**/*glob.js
22+
```
23+
24+
## Transforms
25+
26+
<!--TRANSFORMS_START-->
27+
<!--TRANSFORMS_END-->
28+
29+
## Contributing
30+
31+
### Installation
32+
33+
* clone the repo
34+
* change into the repo directory
35+
* `yarn`
36+
37+
### Running tests
38+
39+
* `yarn test`
40+
41+
### Update Documentation
42+
43+
* `yarn update-docs`

packages/rtk-codemods2/bin/cli.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
4+
require('codemod-cli').runTransform(
5+
__dirname,
6+
process.argv[2] /* transform name */,
7+
process.argv.slice(3) /* paths or globs */
8+
);

packages/rtk-codemods2/package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "rtk-codemods2",
3+
"version": "0.1.0",
4+
"scripts": {
5+
"lint": "eslint --cache .",
6+
"test": "codemod-cli test",
7+
"test:coverage": "codemod-cli test --coverage",
8+
"update-docs": "codemod-cli update-docs",
9+
"coveralls": "cat ./coverage/lcov.info | node node_modules/.bin/coveralls"
10+
},
11+
"bin": "./bin/cli.js",
12+
"keywords": [
13+
"codemod-cli"
14+
],
15+
"dependencies": {
16+
"codemod-cli": "^3.2.0"
17+
},
18+
"devDependencies": {
19+
"coveralls": "^3.1.0",
20+
"eslint": "^8.25.0",
21+
"eslint-config-prettier": "^8.5.0",
22+
"eslint-plugin-node": "^11.1.0",
23+
"eslint-plugin-prettier": "^4.2.1",
24+
"jest": "^26.6.3",
25+
"prettier": "^2.7.1"
26+
},
27+
"engines": {
28+
"node": "10.* || 12.* || >= 14"
29+
},
30+
"jest": {
31+
"testEnvironment": "node"
32+
}
33+
}

packages/rtk-codemods2/transforms/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)