@reliverse/dler 1.7.84 → 1.7.85
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/bin/app/update/cmd.d.ts
CHANGED
|
@@ -72,6 +72,12 @@ declare const _default: import("@reliverse/rempts").Command<{
|
|
|
72
72
|
type: "boolean";
|
|
73
73
|
description: string;
|
|
74
74
|
};
|
|
75
|
+
recursive: {
|
|
76
|
+
type: "boolean";
|
|
77
|
+
description: string;
|
|
78
|
+
alias: string;
|
|
79
|
+
default: true;
|
|
80
|
+
};
|
|
75
81
|
"save-prefix": {
|
|
76
82
|
type: "string";
|
|
77
83
|
description: string;
|
package/bin/app/update/cmd.js
CHANGED
|
@@ -208,6 +208,29 @@ async function isMonorepo(cwd) {
|
|
|
208
208
|
return false;
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
+
async function findAllPackageJsons(cwd) {
|
|
212
|
+
const packageJsonFiles = await glob("**/package.json", {
|
|
213
|
+
cwd,
|
|
214
|
+
absolute: true,
|
|
215
|
+
ignore: [
|
|
216
|
+
"**/node_modules/**",
|
|
217
|
+
"**/dist/**",
|
|
218
|
+
"**/build/**",
|
|
219
|
+
"**/.git/**",
|
|
220
|
+
"**/coverage/**",
|
|
221
|
+
"**/.next/**",
|
|
222
|
+
"**/.nuxt/**",
|
|
223
|
+
"**/out/**"
|
|
224
|
+
]
|
|
225
|
+
});
|
|
226
|
+
const existingFiles = [];
|
|
227
|
+
for (const file of packageJsonFiles) {
|
|
228
|
+
if (await fs.pathExists(file)) {
|
|
229
|
+
existingFiles.push(file);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return existingFiles;
|
|
233
|
+
}
|
|
211
234
|
async function fetchVersionFromRegistry(packageName) {
|
|
212
235
|
const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`);
|
|
213
236
|
if (!response.ok) {
|
|
@@ -671,7 +694,7 @@ async function handleGlobalUpdates(args) {
|
|
|
671
694
|
export default defineCommand({
|
|
672
695
|
meta: {
|
|
673
696
|
name: "update",
|
|
674
|
-
description: "Update all dependencies and catalogs to their latest available versions (
|
|
697
|
+
description: "Update all dependencies and catalogs to their latest available versions (recursively finds all package.json files by default)"
|
|
675
698
|
},
|
|
676
699
|
args: defineArgs({
|
|
677
700
|
name: {
|
|
@@ -741,11 +764,17 @@ export default defineCommand({
|
|
|
741
764
|
},
|
|
742
765
|
"all-workspaces": {
|
|
743
766
|
type: "boolean",
|
|
744
|
-
description: "Update dependencies across all workspace packages (
|
|
767
|
+
description: "Update dependencies across all workspace packages (requires --no-recursive)"
|
|
745
768
|
},
|
|
746
769
|
"root-only": {
|
|
747
770
|
type: "boolean",
|
|
748
|
-
description: "Update only the root package.json (
|
|
771
|
+
description: "Update only the root package.json (requires --no-recursive)"
|
|
772
|
+
},
|
|
773
|
+
recursive: {
|
|
774
|
+
type: "boolean",
|
|
775
|
+
description: "Recursively find and update ALL package.json files in current directory tree (default: true, use --no-recursive to disable)",
|
|
776
|
+
alias: "r",
|
|
777
|
+
default: true
|
|
749
778
|
},
|
|
750
779
|
"save-prefix": {
|
|
751
780
|
type: "string",
|
|
@@ -779,6 +808,13 @@ export default defineCommand({
|
|
|
779
808
|
relinka("error", "Cannot specify both --all-workspaces and --root-only flags");
|
|
780
809
|
return process.exit(1);
|
|
781
810
|
}
|
|
811
|
+
if (args.recursive && (args["all-workspaces"] || args["root-only"])) {
|
|
812
|
+
relinka(
|
|
813
|
+
"error",
|
|
814
|
+
"Cannot use --recursive with --all-workspaces or --root-only flags. Use --no-recursive to disable recursive mode."
|
|
815
|
+
);
|
|
816
|
+
return process.exit(1);
|
|
817
|
+
}
|
|
782
818
|
if (args.global) {
|
|
783
819
|
return await handleGlobalUpdates(args);
|
|
784
820
|
}
|
|
@@ -913,29 +949,58 @@ export default defineCommand({
|
|
|
913
949
|
args["save-prefix"]
|
|
914
950
|
);
|
|
915
951
|
let totalUpdated = rootUpdated;
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
const
|
|
920
|
-
if (
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
952
|
+
if (args.recursive) {
|
|
953
|
+
const allPackageJsons = await findAllPackageJsons(process.cwd());
|
|
954
|
+
const rootPackageJsonPath = path.resolve(process.cwd(), "package.json");
|
|
955
|
+
const otherPackageJsons = allPackageJsons.filter((p) => p !== rootPackageJsonPath);
|
|
956
|
+
if (otherPackageJsons.length > 0) {
|
|
957
|
+
relinka(
|
|
958
|
+
"info",
|
|
959
|
+
`Found ${otherPackageJsons.length} additional package.json files to update recursively`
|
|
960
|
+
);
|
|
961
|
+
const recursiveUpdated = await updateWorkspacePackages(otherPackageJsons, args, options);
|
|
962
|
+
totalUpdated += recursiveUpdated;
|
|
963
|
+
} else {
|
|
964
|
+
relinka("info", "No additional package.json files found for recursive update");
|
|
965
|
+
}
|
|
966
|
+
} else {
|
|
967
|
+
const isMonorepoProject = await isMonorepo(process.cwd());
|
|
968
|
+
const shouldUpdateWorkspaces = args["all-workspaces"] || !args["root-only"] && isMonorepoProject;
|
|
969
|
+
if (shouldUpdateWorkspaces) {
|
|
970
|
+
const workspacePkgJsons = await findWorkspacePackageJsons(process.cwd());
|
|
971
|
+
if (workspacePkgJsons.length > 0) {
|
|
972
|
+
const workspaceUpdated = await updateWorkspacePackages(
|
|
973
|
+
workspacePkgJsons,
|
|
974
|
+
args,
|
|
975
|
+
options
|
|
976
|
+
);
|
|
977
|
+
totalUpdated += workspaceUpdated;
|
|
978
|
+
} else if (args["all-workspaces"]) {
|
|
979
|
+
relinka("warn", "No workspace packages found but --all-workspaces flag was provided");
|
|
980
|
+
}
|
|
981
|
+
} else if (isMonorepoProject) {
|
|
982
|
+
relinka("info", "Skipping workspace packages due to --root-only flag");
|
|
925
983
|
}
|
|
926
|
-
} else if (await isMonorepo(process.cwd())) {
|
|
927
|
-
relinka("info", "Skipping workspace packages due to --root-only flag");
|
|
928
984
|
}
|
|
929
|
-
|
|
930
|
-
|
|
985
|
+
if (args.recursive) {
|
|
986
|
+
const allPackageJsonCount = (await findAllPackageJsons(process.cwd())).length;
|
|
931
987
|
relinka(
|
|
932
988
|
"success",
|
|
933
|
-
`Updated ${totalUpdated} dependencies across
|
|
989
|
+
`Updated ${totalUpdated} dependencies across ${allPackageJsonCount} package.json files (recursive)`
|
|
934
990
|
);
|
|
935
|
-
} else if (isMonorepoProject && !shouldUpdateWorkspaces) {
|
|
936
|
-
relinka("success", `Updated ${totalUpdated} dependencies in root package.json only`);
|
|
937
991
|
} else {
|
|
938
|
-
|
|
992
|
+
const isMonorepoProject = await isMonorepo(process.cwd());
|
|
993
|
+
const shouldUpdateWorkspaces = args["all-workspaces"] || !args["root-only"] && isMonorepoProject;
|
|
994
|
+
if (isMonorepoProject && shouldUpdateWorkspaces) {
|
|
995
|
+
relinka(
|
|
996
|
+
"success",
|
|
997
|
+
`Updated ${totalUpdated} dependencies across workspace (root + workspaces)`
|
|
998
|
+
);
|
|
999
|
+
} else if (isMonorepoProject) {
|
|
1000
|
+
relinka("success", `Updated ${totalUpdated} dependencies in root package.json only`);
|
|
1001
|
+
} else {
|
|
1002
|
+
relinka("success", `Updated ${totalUpdated} dependencies`);
|
|
1003
|
+
}
|
|
939
1004
|
}
|
|
940
1005
|
const packageManager = await detectPackageManager(process.cwd());
|
|
941
1006
|
if (!args["with-install"]) {
|