@kamaalio/codemod-kit 0.0.32 → 0.0.33
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.
- package/dist/codemods/types.d.ts +1 -0
- package/dist/index.cjs +4 -2
- package/dist/index.js +4 -2
- package/package.json +1 -1
package/dist/codemods/types.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export type Codemod = {
|
|
|
18
18
|
root: string;
|
|
19
19
|
results: Array<RunCodemodOkResult>;
|
|
20
20
|
}) => Promise<void>;
|
|
21
|
+
targetFiltering?: (filepath: string, codemod: Codemod) => boolean;
|
|
21
22
|
};
|
|
22
23
|
export type CodemodRunnerCodemod<Tag = string, C extends Codemod = Codemod> = C & {
|
|
23
24
|
tags: Set<Tag> | Array<Tag>;
|
package/dist/index.cjs
CHANGED
|
@@ -473,7 +473,7 @@ async function runCodemodsOnProjects(repositoriesToClone, codemods, options) {
|
|
|
473
473
|
const codemodResults = await runCodemodRunner(codemods, clonedRepositories, mappingsByName, options.workingDirectory);
|
|
474
474
|
if (options.pushChanges) await makePullRequestsForCodemodResults(codemods, codemodResults, clonedRepositories);
|
|
475
475
|
}
|
|
476
|
-
function
|
|
476
|
+
function utils_codemodTargetFiltering(mappingsByName, failedRepositoryAddressesMappedByCodemodNames) {
|
|
477
477
|
return (filepath, codemod)=>{
|
|
478
478
|
const projectName = filepath.split('/')[0];
|
|
479
479
|
kamaal_namespaceObject.asserts.invariant(null != projectName, 'project name should be present');
|
|
@@ -505,7 +505,7 @@ async function runCodemodRunner(codemods, repositories, mappingsByName, workingD
|
|
|
505
505
|
preCodemodRun: async (codemod)=>{
|
|
506
506
|
failedRepositoryAddressesMappedByCodemodNames[codemod.name] = await codemodPreCodemodRun(repositories, codemod);
|
|
507
507
|
},
|
|
508
|
-
targetFiltering:
|
|
508
|
+
targetFiltering: utils_codemodTargetFiltering(mappingsByName, failedRepositoryAddressesMappedByCodemodNames),
|
|
509
509
|
postTransform: codemodPostTransform
|
|
510
510
|
}
|
|
511
511
|
});
|
|
@@ -528,8 +528,10 @@ async function runCodemod(codemod, transformationPath, options) {
|
|
|
528
528
|
if (null == mappedExtensions) return acc;
|
|
529
529
|
return acc.concat(Array.from(mappedExtensions));
|
|
530
530
|
}, []));
|
|
531
|
+
const codemodTargetFiltering = codemod.targetFiltering ?? (()=>true);
|
|
531
532
|
const targets = globItems.filter((filepath)=>{
|
|
532
533
|
if (!hooks.targetFiltering(filepath, codemod)) return false;
|
|
534
|
+
if (!codemodTargetFiltering(filepath, codemod)) return false;
|
|
533
535
|
return collectionIsEmpty(extensions) || extensions.has(external_node_path_default().extname(filepath));
|
|
534
536
|
});
|
|
535
537
|
if (0 === targets.length) return [];
|
package/dist/index.js
CHANGED
|
@@ -424,7 +424,7 @@ async function runCodemodsOnProjects(repositoriesToClone, codemods, options) {
|
|
|
424
424
|
const codemodResults = await runCodemodRunner(codemods, clonedRepositories, mappingsByName, options.workingDirectory);
|
|
425
425
|
if (options.pushChanges) await makePullRequestsForCodemodResults(codemods, codemodResults, clonedRepositories);
|
|
426
426
|
}
|
|
427
|
-
function
|
|
427
|
+
function utils_codemodTargetFiltering(mappingsByName, failedRepositoryAddressesMappedByCodemodNames) {
|
|
428
428
|
return (filepath, codemod)=>{
|
|
429
429
|
const projectName = filepath.split('/')[0];
|
|
430
430
|
asserts.invariant(null != projectName, 'project name should be present');
|
|
@@ -456,7 +456,7 @@ async function runCodemodRunner(codemods, repositories, mappingsByName, workingD
|
|
|
456
456
|
preCodemodRun: async (codemod)=>{
|
|
457
457
|
failedRepositoryAddressesMappedByCodemodNames[codemod.name] = await codemodPreCodemodRun(repositories, codemod);
|
|
458
458
|
},
|
|
459
|
-
targetFiltering:
|
|
459
|
+
targetFiltering: utils_codemodTargetFiltering(mappingsByName, failedRepositoryAddressesMappedByCodemodNames),
|
|
460
460
|
postTransform: codemodPostTransform
|
|
461
461
|
}
|
|
462
462
|
});
|
|
@@ -479,8 +479,10 @@ async function runCodemod(codemod, transformationPath, options) {
|
|
|
479
479
|
if (null == mappedExtensions) return acc;
|
|
480
480
|
return acc.concat(Array.from(mappedExtensions));
|
|
481
481
|
}, []));
|
|
482
|
+
const codemodTargetFiltering = codemod.targetFiltering ?? (()=>true);
|
|
482
483
|
const targets = globItems.filter((filepath)=>{
|
|
483
484
|
if (!hooks.targetFiltering(filepath, codemod)) return false;
|
|
485
|
+
if (!codemodTargetFiltering(filepath, codemod)) return false;
|
|
484
486
|
return collectionIsEmpty(extensions) || extensions.has(node_path.extname(filepath));
|
|
485
487
|
});
|
|
486
488
|
if (0 === targets.length) return [];
|