@kamaalio/codemod-kit 0.0.3 → 0.0.5

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
- export { runCodemods, runCodemod } from './utils';
2
- export type { Codemod, Modifications } from './types';
1
+ export { runCodemods, runCodemod } from './utils.js';
2
+ export type { Codemod, Modifications } from './types.js';
@@ -1,7 +1,7 @@
1
1
  import type { SgRoot } from '@ast-grep/napi';
2
2
  import type { NapiLang } from '@ast-grep/napi/types/lang.js';
3
3
  import type { TypesMap } from '@ast-grep/napi/types/staticTypes.js';
4
- import type { Optional } from '../utils/type-utils';
4
+ import type { Optional } from '../utils/type-utils.js';
5
5
  export type Codemod = {
6
6
  name: string;
7
7
  languages: Set<NapiLang> | Array<NapiLang>;
@@ -1,5 +1,5 @@
1
1
  import { type Result } from 'neverthrow';
2
- import type { Codemod, Modifications } from './types';
2
+ import type { Codemod, Modifications } from './types.js';
3
3
  type RunCodemodHooks = {
4
4
  targetFiltering?: (filepath: string) => boolean;
5
5
  preCodemodRun?: (codemod: Codemod) => Promise<void>;
@@ -11,5 +11,5 @@ type RunCodemodOptions = {
11
11
  dry?: boolean;
12
12
  };
13
13
  export declare function runCodemods(codemods: Array<Codemod>, transformationPath: string, options?: RunCodemodOptions): Promise<Record<string, Array<Result<Modifications, Error>>>>;
14
- export declare function runCodemod(codemod: Codemod, transformationPath: string, globItems: Array<string>, options?: RunCodemodOptions): Promise<Array<Result<Modifications, Error>>>;
14
+ export declare function runCodemod(codemod: Codemod, transformationPath: string, options?: RunCodemodOptions): Promise<Array<Result<Modifications, Error>>>;
15
15
  export {};
package/dist/index.cjs CHANGED
@@ -63,17 +63,17 @@ function collectionIsEmpty(collection) {
63
63
  return 0 === getCollectionCount(collection);
64
64
  }
65
65
  async function runCodemods(codemods, transformationPath, options) {
66
+ const results = {};
67
+ for (const codemod of codemods)results[codemod.name] = await runCodemod(codemod, transformationPath, options);
68
+ return results;
69
+ }
70
+ async function runCodemod(codemod, transformationPath, options) {
71
+ const { hooks, log: enableLogging, dry: runInDryMode } = defaultedOptions(options);
66
72
  const globItems = await external_fast_glob_default().glob([
67
73
  '**/*'
68
74
  ], {
69
75
  cwd: transformationPath
70
76
  });
71
- const results = {};
72
- for (const codemod of codemods)results[codemod.name] = await runCodemod(codemod, transformationPath, globItems, options);
73
- return results;
74
- }
75
- async function runCodemod(codemod, transformationPath, globItems, options) {
76
- const { hooks, log: enableLogging, dry: runInDryMode } = defaultedOptions(options);
77
77
  const extensions = new Set(Array.from(codemod.languages).reduce((acc, language)=>{
78
78
  const mappedExtensions = LANG_TO_EXTENSIONS_MAPPING[language.toLowerCase()];
79
79
  if (null == mappedExtensions) return acc;
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { runCodemods, runCodemod, type Codemod, type Modifications } from './codemods';
1
+ export { runCodemods, runCodemod, type Codemod, type Modifications } from './codemods/index.js';
package/dist/index.js CHANGED
@@ -22,17 +22,17 @@ function collectionIsEmpty(collection) {
22
22
  return 0 === getCollectionCount(collection);
23
23
  }
24
24
  async function runCodemods(codemods, transformationPath, options) {
25
+ const results = {};
26
+ for (const codemod of codemods)results[codemod.name] = await runCodemod(codemod, transformationPath, options);
27
+ return results;
28
+ }
29
+ async function runCodemod(codemod, transformationPath, options) {
30
+ const { hooks, log: enableLogging, dry: runInDryMode } = defaultedOptions(options);
25
31
  const globItems = await fast_glob.glob([
26
32
  '**/*'
27
33
  ], {
28
34
  cwd: transformationPath
29
35
  });
30
- const results = {};
31
- for (const codemod of codemods)results[codemod.name] = await runCodemod(codemod, transformationPath, globItems, options);
32
- return results;
33
- }
34
- async function runCodemod(codemod, transformationPath, globItems, options) {
35
- const { hooks, log: enableLogging, dry: runInDryMode } = defaultedOptions(options);
36
36
  const extensions = new Set(Array.from(codemod.languages).reduce((acc, language)=>{
37
37
  const mappedExtensions = LANG_TO_EXTENSIONS_MAPPING[language.toLowerCase()];
38
38
  if (null == mappedExtensions) return acc;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kamaalio/codemod-kit",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "type": "module",
5
5
  "author": "Kamaal Farah",
6
6
  "license": "MIT",