@oliasoft-open-source/node-json-migrator 5.6.2 → 5.6.3-beta-1
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.mjs +25 -8
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -15,6 +15,16 @@ import os from "node:os";
|
|
|
15
15
|
import tty from "node:tty";
|
|
16
16
|
import process$2 from "process";
|
|
17
17
|
import { execSync, spawn } from "child_process";
|
|
18
|
+
//#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/array/compact.mjs
|
|
19
|
+
function compact(arr) {
|
|
20
|
+
const result = [];
|
|
21
|
+
for (let i = 0; i < arr.length; i++) {
|
|
22
|
+
const item = arr[i];
|
|
23
|
+
if (item) result.push(item);
|
|
24
|
+
}
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
18
28
|
//#region node_modules/.pnpm/es-toolkit@1.45.1/node_modules/es-toolkit/dist/array/difference.mjs
|
|
19
29
|
function difference(firstArr, secondArr) {
|
|
20
30
|
const secondSet = new Set(secondArr);
|
|
@@ -4731,19 +4741,26 @@ const getPlanRevisionsFromGit = async (planFilePath, terminal) => {
|
|
|
4731
4741
|
const getPlanFromGit = async (planFilePath, revision, terminal) => {
|
|
4732
4742
|
return exec(`git show ${revision}:${planFilePath}`, terminal);
|
|
4733
4743
|
};
|
|
4744
|
+
const parseHistoricalPlan = (rawPlan, revision) => {
|
|
4745
|
+
try {
|
|
4746
|
+
const plan = formatJSON(rawPlan);
|
|
4747
|
+
return {
|
|
4748
|
+
revision,
|
|
4749
|
+
version: hash(plan),
|
|
4750
|
+
plan
|
|
4751
|
+
};
|
|
4752
|
+
} catch {
|
|
4753
|
+
return null;
|
|
4754
|
+
}
|
|
4755
|
+
};
|
|
4734
4756
|
const getHistoricalPlansFromGit = async (planFilePath) => {
|
|
4735
4757
|
try {
|
|
4736
4758
|
if (!gitAvailable()) throw new Error("git must be installed and in PATH");
|
|
4737
4759
|
const terminal = getTerminal();
|
|
4738
4760
|
const revisions = await getPlanRevisionsFromGit(planFilePath, terminal);
|
|
4739
|
-
return { historicalPlans: await Promise.all(revisions.map(async (revision) => {
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
revision,
|
|
4743
|
-
version: hash(plan),
|
|
4744
|
-
plan
|
|
4745
|
-
};
|
|
4746
|
-
})) };
|
|
4761
|
+
return { historicalPlans: compact(await Promise.all(revisions.map(async (revision) => {
|
|
4762
|
+
return parseHistoricalPlan(await getPlanFromGit(planFilePath, revision.version, terminal), revision);
|
|
4763
|
+
}))) };
|
|
4747
4764
|
} catch (error) {
|
|
4748
4765
|
console.error(chalk.red(error));
|
|
4749
4766
|
throw new Error("Unable to fetch plan.json history from git");
|
package/package.json
CHANGED