-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* rename codemods, fix help, etc * changes * add test for rest syntax
- Loading branch information
Showing
23 changed files
with
160 additions
and
84 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
packages/codemods/src/codemods/v5.x.x/cellQueryResult/__testfixtures__/restSyntax.input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { FindAuthorQuery, FindAuthorQueryVariables } from 'types/graphql' | ||
|
||
import type { CellSuccessProps, CellFailureProps } from '@redwoodjs/web' | ||
|
||
import Author from 'src/components/Author' | ||
|
||
export const QUERY = gql` | ||
query FindAuthorQuery($id: Int!) { | ||
author: user(id: $id) { | ||
fullName | ||
} | ||
} | ||
` | ||
|
||
export const Loading = () => <span>Loading...</span> | ||
|
||
export const Empty = () => <span>Empty</span> | ||
|
||
export const Failure = ({ | ||
error, | ||
}: CellFailureProps<FindAuthorQueryVariables>) => ( | ||
<span style={{ color: 'red' }}>Error: {error?.message}</span> | ||
) | ||
|
||
export const Success = ({ | ||
author, | ||
...props | ||
}: CellSuccessProps<FindAuthorQuery, FindAuthorQueryVariables>) => ( | ||
<span className="author-cell"> | ||
<Author author={author} {...props} /> | ||
</span> | ||
) |
33 changes: 33 additions & 0 deletions
33
packages/codemods/src/codemods/v5.x.x/cellQueryResult/__testfixtures__/restSyntax.output.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import type { FindAuthorQuery, FindAuthorQueryVariables } from 'types/graphql' | ||
|
||
import type { CellSuccessProps, CellFailureProps } from '@redwoodjs/web' | ||
|
||
import Author from 'src/components/Author' | ||
|
||
export const QUERY = gql` | ||
query FindAuthorQuery($id: Int!) { | ||
author: user(id: $id) { | ||
fullName | ||
} | ||
} | ||
` | ||
|
||
export const Loading = () => <span>Loading...</span> | ||
|
||
export const Empty = () => <span>Empty</span> | ||
|
||
export const Failure = ({ | ||
error, | ||
}: CellFailureProps<FindAuthorQueryVariables>) => ( | ||
<span style={{ color: 'red' }}>Error: {error?.message}</span> | ||
) | ||
|
||
export const Success = ({ | ||
author, | ||
...props | ||
}: CellSuccessProps<FindAuthorQuery, FindAuthorQueryVariables>) => ( | ||
<span className="author-cell"> | ||
<Author author={author} {...props} /> | ||
</span> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 17 additions & 10 deletions
27
packages/codemods/src/codemods/v5.x.x/detectEmptyCells/detectEmptyCells.yargs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,24 @@ | ||
import task, { TaskInnerAPI } from 'tasuku' | ||
import task from 'tasuku' | ||
|
||
import detectEmptyCells from './detectEmptyCells' | ||
import { detectEmptyCells } from './detectEmptyCells' | ||
|
||
export const command = 'detect-empty-cells' | ||
export const description = '(v4.x.x->v5.0.0) Detects empty cells and warns' | ||
|
||
export const description = | ||
'(v4.x.x->v5.x.x) Detects Cells susceptible to the new Empty behavior' | ||
|
||
export const handler = () => { | ||
task('detectEmptyCells', async ({ setError }: TaskInnerAPI) => { | ||
try { | ||
await detectEmptyCells() | ||
console.log() | ||
} catch (e: any) { | ||
setError('Failed to detect empty cells in your project \n' + e?.message) | ||
task( | ||
'Detecting Cells susceptible to the new Empty behavior', | ||
async (taskContext) => { | ||
try { | ||
await detectEmptyCells(taskContext) | ||
} catch (e: any) { | ||
taskContext.setError( | ||
'Failed to detect cells susceptible to the new Empty behavior in your project \n' + | ||
e?.message | ||
) | ||
} | ||
} | ||
}) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ages/codemods/src/codemods/v5.x.x/renameValidateWith/__tests__/renameValidateWith.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
describe('renameValidateWith', () => { | ||
it('Converts validateWith to validateWithSync', async () => { | ||
it('Renames `validateWith` to `validateWithSync`', async () => { | ||
await matchTransformSnapshot('renameValidateWith', 'default') | ||
}) | ||
}) |
32 changes: 18 additions & 14 deletions
32
packages/codemods/src/codemods/v5.x.x/renameValidateWith/renameValidateWith.yargs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,33 @@ | ||
import path from 'path' | ||
|
||
import task, { TaskInnerAPI } from 'tasuku' | ||
import task from 'tasuku' | ||
|
||
import getFilesWithPattern from '../../../lib/getFilesWithPattern' | ||
import getRWPaths from '../../../lib/getRWPaths' | ||
import runTransform from '../../../lib/runTransform' | ||
|
||
export const command = 'rename-validate-with' | ||
|
||
export const description = | ||
'(v4.x.x->v5.x.x) Converts validateWith to validateWithSync' | ||
'(v4.x.x->v5.x.x) Renames validateWith to validateWithSync' | ||
|
||
export const handler = () => { | ||
task('Rename Validate With', async ({ setOutput }: TaskInnerAPI) => { | ||
const rwPaths = getRWPaths() | ||
task( | ||
'Renaming `validateWith` to `validateWithSync`', | ||
async ({ setOutput }) => { | ||
const redwoodProjectPaths = getRWPaths() | ||
|
||
const files = getFilesWithPattern({ | ||
pattern: 'validateWith', | ||
filesToSearch: [rwPaths.api.src], | ||
}) | ||
const files = getFilesWithPattern({ | ||
pattern: 'validateWith', | ||
filesToSearch: [redwoodProjectPaths.api.src], | ||
}) | ||
|
||
await runTransform({ | ||
transformPath: path.join(__dirname, 'renameValidateWith.js'), | ||
targetPaths: files, | ||
}) | ||
await runTransform({ | ||
transformPath: path.join(__dirname, 'renameValidateWith.js'), | ||
targetPaths: files, | ||
}) | ||
|
||
setOutput('All done! Run `yarn rw lint --fix` to prettify your code') | ||
}) | ||
setOutput('All done! Run `yarn rw lint --fix` to prettify your code') | ||
} | ||
) | ||
} |
5 changes: 0 additions & 5 deletions
5
packages/codemods/src/codemods/v5.x.x/updateAuth0/__tests__/updateAuth0.ts
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions
5
packages/codemods/src/codemods/v5.x.x/updateAuth0ToV2/__tests__/updateAuth0ToV2.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
describe('updateAuth0ToV2', () => { | ||
it('updates the web-side auth file to the v2 SDK', async () => { | ||
await matchTransformSnapshot('updateAuth0ToV2', 'default') | ||
}) | ||
}) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/codemods/src/codemods/v5.x.x/updateNodeEngineTo18/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Update Node Engine to 18 | ||
|
||
This codemod updates the `engines.node` key in a project's root `package.json` to `"=18.x"`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/codemods/src/codemods/v5.x.x/updateNodeEngineTo18/updateNodeEngineTo18.yargs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import task from 'tasuku' | ||
|
||
import { updateNodeEngineTo18 } from './updateNodeEngineTo18' | ||
|
||
export const command = 'update-node-engine-to-18' | ||
|
||
export const description = | ||
'(v4.x.x->v5.x.x) Updates `engines.node` to `"=18.x"` in your project\'s root package.json' | ||
|
||
export const handler = () => { | ||
task( | ||
'Updating `engines.node` to `"=18.x"` in root package.json', | ||
async ({ setError }) => { | ||
try { | ||
await updateNodeEngineTo18() | ||
} catch (e: any) { | ||
setError('Failed to codemod your project \n' + e?.message) | ||
} | ||
} | ||
) | ||
} |
4 changes: 0 additions & 4 deletions
4
packages/codemods/src/codemods/v5.x.x/updateNodeEngines/README.md
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
packages/codemods/src/codemods/v5.x.x/updateNodeEngines/updateNodeEngines.yargs.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters