@kamaalio/codemod-kit 0.0.34 → 0.0.36
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/index.cjs +12 -3
- package/dist/index.js +12 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -47,6 +47,7 @@ const external_node_path_namespaceObject = require("node:path");
|
|
|
47
47
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
48
48
|
const promises_namespaceObject = require("node:fs/promises");
|
|
49
49
|
var promises_default = /*#__PURE__*/ __webpack_require__.n(promises_namespaceObject);
|
|
50
|
+
const external_execa_namespaceObject = require("execa");
|
|
50
51
|
const external_fast_glob_namespaceObject = require("fast-glob");
|
|
51
52
|
var external_fast_glob_default = /*#__PURE__*/ __webpack_require__.n(external_fast_glob_namespaceObject);
|
|
52
53
|
const external_neverthrow_namespaceObject = require("neverthrow");
|
|
@@ -110,7 +111,6 @@ function groupByFlat(array, key) {
|
|
|
110
111
|
return acc;
|
|
111
112
|
}, {});
|
|
112
113
|
}
|
|
113
|
-
const external_execa_namespaceObject = require("execa");
|
|
114
114
|
class GitError extends Error {
|
|
115
115
|
cause;
|
|
116
116
|
repository;
|
|
@@ -518,8 +518,9 @@ async function runCodemodRunner(codemods, repositories, workingDirectory) {
|
|
|
518
518
|
const results = Object.fromEntries(await Promise.all(codemods.map(async (codemod)=>{
|
|
519
519
|
const codemodRepositories = codemodRepositoriesMappedByCodemodName[codemod.name];
|
|
520
520
|
kamaal_namespaceObject.asserts.invariant(null != codemodRepositories, 'Codemod repositories should be present');
|
|
521
|
+
const codemodWorkingDirectory = external_node_path_default().resolve(workingDirectory, codemod.name.replace(/\//g, '-'));
|
|
521
522
|
const failedRepositoryAddressesMappedByCodemodNames = {};
|
|
522
|
-
const result = await runCodemod(codemod,
|
|
523
|
+
const result = await runCodemod(codemod, codemodWorkingDirectory, {
|
|
523
524
|
rootPaths: codemodRepositories.map((repository)=>repository.path),
|
|
524
525
|
hooks: {
|
|
525
526
|
preCodemodRun: async (codemod)=>{
|
|
@@ -550,8 +551,16 @@ async function prepareRepositoriesForCodemods(repositories, codemods, workingDir
|
|
|
550
551
|
if (prepareResult.isErr()) throw prepareResult.error;
|
|
551
552
|
return prepareResult.value;
|
|
552
553
|
}));
|
|
554
|
+
console.log(`\u{1F4CB} prepared the following repos for codemods!
|
|
555
|
+
${updatedRepositories.map((repo)=>repo.address).join('\n')}`);
|
|
553
556
|
return Object.fromEntries(await Promise.all(codemods.map(async (codemod)=>{
|
|
554
|
-
const
|
|
557
|
+
const codemodWorkingDirectory = external_node_path_default().resolve(workingDirectory, codemod.name.replace(/\//g, '-'));
|
|
558
|
+
await (0, external_execa_namespaceObject.$)`mkdir -p ${codemodWorkingDirectory}`;
|
|
559
|
+
const codeRepositories = await Promise.all(updatedRepositories.map((repo)=>{
|
|
560
|
+
const newPath = external_node_path_default().join(codemodWorkingDirectory, repo.name);
|
|
561
|
+
console.log(`\xa9\u{FE0F} copying ${repo.name} -> ${newPath}`);
|
|
562
|
+
return repo.copy(newPath);
|
|
563
|
+
}));
|
|
555
564
|
return [
|
|
556
565
|
codemod.name,
|
|
557
566
|
codeRepositories
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import node_path from "node:path";
|
|
2
2
|
import promises from "node:fs/promises";
|
|
3
|
+
import { $ } from "execa";
|
|
3
4
|
import fast_glob from "fast-glob";
|
|
4
5
|
import { ResultAsync, err, ok } from "neverthrow";
|
|
5
6
|
import { Lang, parseAsync } from "@ast-grep/napi";
|
|
6
7
|
import { arrays, asserts, objects } from "@kamaalio/kamaal";
|
|
7
|
-
import { $ } from "execa";
|
|
8
8
|
import zod from "zod";
|
|
9
9
|
const JAVASCRIPT_EXTENSIONS = [
|
|
10
10
|
'.js',
|
|
@@ -469,8 +469,9 @@ async function runCodemodRunner(codemods, repositories, workingDirectory) {
|
|
|
469
469
|
const results = Object.fromEntries(await Promise.all(codemods.map(async (codemod)=>{
|
|
470
470
|
const codemodRepositories = codemodRepositoriesMappedByCodemodName[codemod.name];
|
|
471
471
|
asserts.invariant(null != codemodRepositories, 'Codemod repositories should be present');
|
|
472
|
+
const codemodWorkingDirectory = node_path.resolve(workingDirectory, codemod.name.replace(/\//g, '-'));
|
|
472
473
|
const failedRepositoryAddressesMappedByCodemodNames = {};
|
|
473
|
-
const result = await runCodemod(codemod,
|
|
474
|
+
const result = await runCodemod(codemod, codemodWorkingDirectory, {
|
|
474
475
|
rootPaths: codemodRepositories.map((repository)=>repository.path),
|
|
475
476
|
hooks: {
|
|
476
477
|
preCodemodRun: async (codemod)=>{
|
|
@@ -501,8 +502,16 @@ async function prepareRepositoriesForCodemods(repositories, codemods, workingDir
|
|
|
501
502
|
if (prepareResult.isErr()) throw prepareResult.error;
|
|
502
503
|
return prepareResult.value;
|
|
503
504
|
}));
|
|
505
|
+
console.log(`\u{1F4CB} prepared the following repos for codemods!
|
|
506
|
+
${updatedRepositories.map((repo)=>repo.address).join('\n')}`);
|
|
504
507
|
return Object.fromEntries(await Promise.all(codemods.map(async (codemod)=>{
|
|
505
|
-
const
|
|
508
|
+
const codemodWorkingDirectory = node_path.resolve(workingDirectory, codemod.name.replace(/\//g, '-'));
|
|
509
|
+
await $`mkdir -p ${codemodWorkingDirectory}`;
|
|
510
|
+
const codeRepositories = await Promise.all(updatedRepositories.map((repo)=>{
|
|
511
|
+
const newPath = node_path.join(codemodWorkingDirectory, repo.name);
|
|
512
|
+
console.log(`\xa9\u{FE0F} copying ${repo.name} -> ${newPath}`);
|
|
513
|
+
return repo.copy(newPath);
|
|
514
|
+
}));
|
|
506
515
|
return [
|
|
507
516
|
codemod.name,
|
|
508
517
|
codeRepositories
|