@kamaalio/codemod-kit 0.0.19 → 0.0.20

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, } from './utils.js';
2
- export type { Codemod, Modifications } from './types.js';
2
+ export type { Codemod, Modifications, FindAndReplaceConfig } from './types.js';
@@ -1,6 +1,6 @@
1
- import type { SgRoot } from '@ast-grep/napi';
1
+ import type { Rule, SgNode, SgRoot } from '@ast-grep/napi';
2
2
  import type { NapiLang } from '@ast-grep/napi/types/lang.js';
3
- import type { TypesMap } from '@ast-grep/napi/types/staticTypes.js';
3
+ import type { Kinds, TypesMap } from '@ast-grep/napi/types/staticTypes.js';
4
4
  import type { Optional } from '../utils/type-utils.js';
5
5
  export type Codemod = {
6
6
  name: string;
@@ -17,3 +17,7 @@ export type Modifications = {
17
17
  filename: Optional<string>;
18
18
  history: Array<SgRoot<TypesMap>>;
19
19
  };
20
+ export type FindAndReplaceConfig = {
21
+ rule: Rule<TypesMap>;
22
+ transformer: ((node: SgNode<TypesMap, Kinds<TypesMap>>) => Optional<string>) | string;
23
+ };
@@ -1,9 +1,8 @@
1
1
  import { type Result } from 'neverthrow';
2
- import { type Rule, type Edit, type SgNode, type SgRoot } from '@ast-grep/napi';
3
- import type { Kinds, TypesMap } from '@ast-grep/napi/types/staticTypes.js';
2
+ import { type Edit, type SgRoot } from '@ast-grep/napi';
3
+ import type { TypesMap } from '@ast-grep/napi/types/staticTypes.js';
4
4
  import type { NapiLang } from '@ast-grep/napi/types/lang.js';
5
- import type { Codemod, Modifications } from './types.js';
6
- import type { Optional } from '../utils/type-utils.js';
5
+ import type { Codemod, FindAndReplaceConfig, Modifications } from './types.js';
7
6
  type RunCodemodHooks<C extends Codemod> = {
8
7
  targetFiltering?: (filepath: string, codemod: C) => boolean;
9
8
  preCodemodRun?: (codemod: C) => Promise<void>;
@@ -14,10 +13,6 @@ type RunCodemodOptions<C extends Codemod> = {
14
13
  log?: boolean;
15
14
  dry?: boolean;
16
15
  };
17
- type FindAndReplaceConfig = {
18
- rule: Rule<TypesMap>;
19
- transformer: ((node: SgNode<TypesMap, Kinds<TypesMap>>) => Optional<string>) | string;
20
- };
21
16
  export declare function runCodemods<C extends Codemod>(codemods: Array<C>, transformationPath: string, options?: RunCodemodOptions<C>): Promise<Record<string, Array<Result<{
22
17
  hasChanges: boolean;
23
18
  content: string;
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { runCodemods, runCodemod, commitEditModifications, findAndReplace, findAndReplaceEdits, findAndReplaceConfig, findAndReplaceConfigModifications, type Codemod, type Modifications, } from './codemods/index.js';
1
+ export { runCodemods, runCodemod, commitEditModifications, findAndReplace, findAndReplaceEdits, findAndReplaceConfig, findAndReplaceConfigModifications, type Codemod, type Modifications, type FindAndReplaceConfig, } from './codemods/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kamaalio/codemod-kit",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "type": "module",
5
5
  "author": "Kamaal Farah",
6
6
  "license": "MIT",