@kamaalio/codemod-kit 0.0.28 → 0.0.30

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, } from './utils.js';
2
- export type { Codemod, Modifications, FindAndReplaceConfig } from './types.js';
2
+ export type { Codemod, Modifications, FindAndReplaceConfig, RunCodemodOkResult, RunCodemodResult } from './types.js';
@@ -2,17 +2,19 @@ import type { Edit, Rule, SgNode, SgRoot } from '@ast-grep/napi';
2
2
  import type { NapiLang } from '@ast-grep/napi/types/lang.js';
3
3
  import type { Kinds, TypesMap } from '@ast-grep/napi/types/staticTypes.js';
4
4
  import type { types } from '@kamaalio/kamaal';
5
+ import type { Result } from 'neverthrow';
5
6
  export type RunCodemodOkResult = {
6
7
  hasChanges: boolean;
7
8
  content: string;
8
9
  fullPath: string;
9
10
  root: string;
10
11
  };
12
+ export type RunCodemodResult = Result<RunCodemodOkResult, Error>;
11
13
  export type Codemod = {
12
14
  name: string;
13
15
  languages: Set<NapiLang> | Array<NapiLang>;
14
16
  transformer: (content: string, filename?: types.Optional<string>) => Promise<string>;
15
- postTransform?: (rootPath: {
17
+ postTransform?: (results: {
16
18
  root: string;
17
19
  results: Array<RunCodemodOkResult>;
18
20
  }) => Promise<void>;
@@ -1,9 +1,8 @@
1
- import { type Result } from 'neverthrow';
2
1
  import { type Edit, type SgRoot, type SgNode } from '@ast-grep/napi';
3
2
  import type { Kinds, TypesMap } from '@ast-grep/napi/types/staticTypes.js';
4
3
  import type { NapiLang } from '@ast-grep/napi/types/lang.js';
5
4
  import { type types } from '@kamaalio/kamaal';
6
- import type { Codemod, FindAndReplaceConfig, Modifications, RunCodemodOkResult } from './types.js';
5
+ import type { Codemod, FindAndReplaceConfig, Modifications, RunCodemodResult } 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>;
@@ -15,7 +14,6 @@ type RunCodemodOptions<C extends Codemod> = {
15
14
  dry?: boolean;
16
15
  rootPaths?: Array<string>;
17
16
  };
18
- type RunCodemodResult = Result<RunCodemodOkResult, Error>;
19
17
  export declare function runCodemods<C extends Codemod>(codemods: Array<C>, transformationPath: string, options?: RunCodemodOptions<C>): Promise<Record<string, Array<RunCodemodResult>>>;
20
18
  export declare function runCodemod<C extends Codemod>(codemod: C, transformationPath: string, options?: RunCodemodOptions<C>): Promise<Array<RunCodemodResult>>;
21
19
  export declare function traverseUp(node: SgNode<TypesMap, Kinds<TypesMap>>, until: (node: SgNode<TypesMap, Kinds<TypesMap>>) => boolean): types.Optional<SgNode<TypesMap, Kinds<TypesMap>>>;
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { runCodemods, runCodemod, commitEditModifications, findAndReplace, findAndReplaceEdits, findAndReplaceConfig, findAndReplaceConfigModifications, traverseUp, type Codemod, type Modifications, type FindAndReplaceConfig, } from './codemods/index.js';
1
+ export { runCodemods, runCodemod, commitEditModifications, findAndReplace, findAndReplaceEdits, findAndReplaceConfig, findAndReplaceConfigModifications, traverseUp, type Codemod, type Modifications, type FindAndReplaceConfig, type RunCodemodOkResult, type RunCodemodResult, } from './codemods/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kamaalio/codemod-kit",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "type": "module",
5
5
  "author": "Kamaal Farah",
6
6
  "license": "MIT",