forked from hypermod-io/hypermod-community
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow providing custom runner per transform file thru Codeshift…
…Config depends on: hypermod-io#63 fixes a lot of cases for us: 1. we have a postcss codemod that we want to run, while still utilizing the @codeshift/cli. though, i don't know if these changes will work if we're using a remote package, will they? 2. we'll want to do some global pre-processing on files before running our codemod. though, there's still no way to provide the codemod as a __function__ instead of an __import path__ to jscodeshift, which will force us to do dependency injection instead of just passing the pre-processed results as an argument to a function. this is where the considerations to fork jscodeshift come into play again: - hypermod-io#67 Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
- Loading branch information
Showing
2 changed files
with
106 additions
and
14 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export interface CodeshiftConfig { | ||
target?: string[]; | ||
maintainers?: string[]; | ||
description?: string; | ||
transforms?: Record<string, string>; | ||
presets?: Record<string, string>; | ||
} | ||
|
||
export type DefaultRunner = ( | ||
jscodeshiftOptionOverrides?: object, | ||
pathsToModify?: string[], // | ||
transformerPath?: string, | ||
) => Promise<void>; | ||
|
||
export interface CustomRunnerCtx<Transform = unknown> { | ||
transform: Transform; | ||
defaultRunner: DefaultRunner; | ||
} | ||
|
||
export type CustomRunner<Transform = unknown> = ( | ||
pathsToModify: string[], // | ||
options: CustomRunnerCtx<Transform>, | ||
) => void | Promise<void>; | ||
|
||
export interface CodeshiftConfig<Transform = unknown> { | ||
runner: CustomRunner<Transform>; | ||
} |