@kamaalio/codemod-kit 0.0.39 → 0.0.41

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
1
  export { runCodemods, runCodemod, commitEditModifications, findAndReplace, findAndReplaceEdits, findAndReplaceConfig, findAndReplaceConfigModifications, traverseUp, runCodemodsOnProjects, } from './utils.js';
2
- export type { Codemod, Modifications, FindAndReplaceConfig, RunCodemodOkResult, RunCodemodResult, CodemodRunnerCodemod, RepositoryToClone, } from './types.js';
2
+ export type { Codemod, Modifications, FindAndReplaceConfig, RunCodemodOkResult, RunCodemodResult, CodemodRunnerCodemod, RepositoryToClone, CodemodOptions, } from './types.js';
@@ -10,14 +10,18 @@ export type RunCodemodOkResult = {
10
10
  root: string;
11
11
  };
12
12
  export type RunCodemodResult = Result<RunCodemodOkResult, Error>;
13
+ export type CodemodOptions = {
14
+ postTransform?: Record<string, unknown>;
15
+ };
13
16
  export type Codemod = {
14
17
  name: string;
15
18
  languages: Set<NapiLang> | Array<NapiLang>;
16
- transformer: (content: string, filename?: types.Optional<string>) => Promise<string>;
19
+ options?: CodemodOptions;
20
+ transformer: (content: string, filename?: types.Optional<string>, codemod?: types.Optional<Codemod>) => Promise<string>;
17
21
  postTransform?: (results: {
18
22
  root: string;
19
23
  results: Array<RunCodemodOkResult>;
20
- }) => Promise<void>;
24
+ }, codemod: Codemod) => Promise<void>;
21
25
  targetFiltering?: (filepath: string, codemod: Codemod) => boolean;
22
26
  };
23
27
  export type CodemodRunnerCodemod<Tag = string, C extends Codemod = Codemod> = C & {
package/dist/index.cjs CHANGED
@@ -621,7 +621,7 @@ async function runCodemod(codemod, transformationPath, options) {
621
621
  root,
622
622
  results: successesGroupedByRoot[root] ?? []
623
623
  }));
624
- await Promise.all(rootPathsWithResults.map((r)=>(codemod.postTransform ?? (async ()=>{}))(r)));
624
+ await Promise.all(rootPathsWithResults.map((r)=>(codemod.postTransform ?? (async ()=>{}))(r, codemod)));
625
625
  return results;
626
626
  }
627
627
  function traverseUp(node, until) {
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { runCodemods, runCodemod, commitEditModifications, findAndReplace, findAndReplaceEdits, findAndReplaceConfig, findAndReplaceConfigModifications, traverseUp, runCodemodsOnProjects, type Codemod, type Modifications, type FindAndReplaceConfig, type RunCodemodOkResult, type RunCodemodResult, type CodemodRunnerCodemod, type RepositoryToClone, } from './codemods/index.js';
1
+ export { runCodemods, runCodemod, commitEditModifications, findAndReplace, findAndReplaceEdits, findAndReplaceConfig, findAndReplaceConfigModifications, traverseUp, runCodemodsOnProjects, type Codemod, type Modifications, type FindAndReplaceConfig, type RunCodemodOkResult, type RunCodemodResult, type CodemodRunnerCodemod, type RepositoryToClone, type CodemodOptions, } from './codemods/index.js';
package/dist/index.js CHANGED
@@ -572,7 +572,7 @@ async function runCodemod(codemod, transformationPath, options) {
572
572
  root,
573
573
  results: successesGroupedByRoot[root] ?? []
574
574
  }));
575
- await Promise.all(rootPathsWithResults.map((r)=>(codemod.postTransform ?? (async ()=>{}))(r)));
575
+ await Promise.all(rootPathsWithResults.map((r)=>(codemod.postTransform ?? (async ()=>{}))(r, codemod)));
576
576
  return results;
577
577
  }
578
578
  function traverseUp(node, until) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kamaalio/codemod-kit",
3
- "version": "0.0.39",
3
+ "version": "0.0.41",
4
4
  "type": "module",
5
5
  "author": "Kamaal Farah",
6
6
  "license": "MIT",