@reliverse/dler 1.7.83 → 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.
@@ -68,6 +68,16 @@ declare const _default: import("@reliverse/rempts").Command<{
68
68
  type: "boolean";
69
69
  description: string;
70
70
  };
71
+ "root-only": {
72
+ type: "boolean";
73
+ description: string;
74
+ };
75
+ recursive: {
76
+ type: "boolean";
77
+ description: string;
78
+ alias: string;
79
+ default: true;
80
+ };
71
81
  "save-prefix": {
72
82
  type: "string";
73
83
  description: string;
@@ -193,6 +193,44 @@ async function findWorkspacePackageJsons(cwd) {
193
193
  }
194
194
  return pkgJsonPaths;
195
195
  }
196
+ async function isMonorepo(cwd) {
197
+ try {
198
+ const root = await readPackageJSON(cwd);
199
+ const ws = root.workspaces;
200
+ if (Array.isArray(ws) && ws.length > 0) {
201
+ return true;
202
+ }
203
+ if (ws && Array.isArray(ws.packages) && ws.packages.length > 0) {
204
+ return true;
205
+ }
206
+ return false;
207
+ } catch {
208
+ return false;
209
+ }
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
+ }
196
234
  async function fetchVersionFromRegistry(packageName) {
197
235
  const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`);
198
236
  if (!response.ok) {
@@ -656,7 +694,7 @@ async function handleGlobalUpdates(args) {
656
694
  export default defineCommand({
657
695
  meta: {
658
696
  name: "update",
659
- 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)"
660
698
  },
661
699
  args: defineArgs({
662
700
  name: {
@@ -726,7 +764,17 @@ export default defineCommand({
726
764
  },
727
765
  "all-workspaces": {
728
766
  type: "boolean",
729
- description: "Update dependencies across all workspace packages"
767
+ description: "Update dependencies across all workspace packages (requires --no-recursive)"
768
+ },
769
+ "root-only": {
770
+ type: "boolean",
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
730
778
  },
731
779
  "save-prefix": {
732
780
  type: "string",
@@ -756,6 +804,17 @@ export default defineCommand({
756
804
  );
757
805
  return process.exit(1);
758
806
  }
807
+ if (args["all-workspaces"] && args["root-only"]) {
808
+ relinka("error", "Cannot specify both --all-workspaces and --root-only flags");
809
+ return process.exit(1);
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
+ }
759
818
  if (args.global) {
760
819
  return await handleGlobalUpdates(args);
761
820
  }
@@ -890,12 +949,59 @@ export default defineCommand({
890
949
  args["save-prefix"]
891
950
  );
892
951
  let totalUpdated = rootUpdated;
893
- if (args["all-workspaces"]) {
894
- const workspacePkgJsons = await findWorkspacePackageJsons(process.cwd());
895
- const workspaceUpdated = await updateWorkspacePackages(workspacePkgJsons, args, options);
896
- totalUpdated += workspaceUpdated;
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");
983
+ }
984
+ }
985
+ if (args.recursive) {
986
+ const allPackageJsonCount = (await findAllPackageJsons(process.cwd())).length;
987
+ relinka(
988
+ "success",
989
+ `Updated ${totalUpdated} dependencies across ${allPackageJsonCount} package.json files (recursive)`
990
+ );
991
+ } else {
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
+ }
897
1004
  }
898
- relinka("success", `Updated ${totalUpdated} dependencies across workspace`);
899
1005
  const packageManager = await detectPackageManager(process.cwd());
900
1006
  if (!args["with-install"]) {
901
1007
  const installCommand = packageManager?.command || "your package manager";
@@ -13,13 +13,13 @@ export async function mkdist(options = {}) {
13
13
  options.srcDir = resolve(options.rootDir, options.srcDir || "src");
14
14
  options.distDir = resolve(options.rootDir, options.distDir || "dist");
15
15
  if (options.cleanDist !== false) {
16
- relinka("info", "Cleaning distribution directory...");
16
+ relinka("verbose", "Cleaning distribution directory...");
17
17
  await fsp.unlink(options.distDir).catch(() => {
18
18
  });
19
19
  await fsp.rm(options.distDir, { recursive: true, force: true });
20
20
  await fsp.mkdir(options.distDir, { recursive: true });
21
21
  }
22
- relinka("info", "Scanning input files...");
22
+ relinka("verbose", "Scanning input files...");
23
23
  const filePaths = await glob(options.pattern || "**", {
24
24
  absolute: false,
25
25
  ignore: ["**/node_modules", "**/coverage", "**/.git"],
@@ -36,10 +36,10 @@ export async function mkdist(options = {}) {
36
36
  getContents: () => fsp.readFile(sourcePath, { encoding: "utf8" })
37
37
  };
38
38
  });
39
- relinka("info", `Found ${files.length} files to process`);
39
+ relinka("verbose", `Found ${files.length} files to process`);
40
40
  options.typescript ||= {};
41
41
  if (options.typescript.compilerOptions) {
42
- relinka("info", "Normalizing TypeScript compiler options...");
42
+ relinka("verbose", "Normalizing TypeScript compiler options...");
43
43
  options.typescript.compilerOptions = await normalizeCompilerOptions(
44
44
  options.typescript.compilerOptions
45
45
  );
@@ -57,9 +57,9 @@ export async function mkdist(options = {}) {
57
57
  allowNonTsExtensions: true
58
58
  }
59
59
  );
60
- relinka("info", "Creating file loaders...");
60
+ relinka("verbose", "Creating file loaders...");
61
61
  const { loadFile } = createLoader(options);
62
- relinka("info", "Processing files with loaders...");
62
+ relinka("verbose", "Processing files with loaders...");
63
63
  const outputs = [];
64
64
  let processedCount = 0;
65
65
  await Promise.all(
@@ -71,7 +71,7 @@ export async function mkdist(options = {}) {
71
71
  processedCount++;
72
72
  })
73
73
  );
74
- relinka("info", "Normalizing output extensions...");
74
+ relinka("verbose", "Normalizing output extensions...");
75
75
  const pathConflicts = [];
76
76
  for (const output of outputs.filter((o) => o.extension)) {
77
77
  const renamed = basename(output.path, extname(output.path)) + output.extension;
@@ -88,7 +88,7 @@ export async function mkdist(options = {}) {
88
88
  }
89
89
  const dtsOutputs = outputs.filter((o) => o.declaration && !o.skip);
90
90
  if (dtsOutputs.length > 0) {
91
- relinka("info", `Generating TypeScript declarations for ${dtsOutputs.length} files...`);
91
+ relinka("verbose", `Generating TypeScript declarations for ${dtsOutputs.length} files...`);
92
92
  const vfs = new Map(dtsOutputs.map((o) => [o.srcPath, o.contents || ""]));
93
93
  const declarations = /* @__PURE__ */ Object.create(null);
94
94
  for (const loader of [getVueDeclarations, getDeclarations]) {
@@ -104,7 +104,7 @@ export async function mkdist(options = {}) {
104
104
  dtsProcessed++;
105
105
  }
106
106
  }
107
- relinka("info", "Resolving relative imports...");
107
+ relinka("verbose", "Resolving relative imports...");
108
108
  const outPaths = new Set(outputs.map((o) => o.path));
109
109
  const resolveId = (from, id = "", resolveExtensions) => {
110
110
  if (!id.startsWith(".")) {
@@ -137,7 +137,7 @@ export async function mkdist(options = {}) {
137
137
  );
138
138
  }
139
139
  const outputsToWrite = outputs.filter((o) => !o.skip);
140
- relinka("info", `Writing ${outputsToWrite.length} output files...`);
140
+ relinka("verbose", `Writing ${outputsToWrite.length} output files...`);
141
141
  const writtenFiles = [];
142
142
  const errors = [];
143
143
  let writtenCount = 0;
@@ -1,5 +1,5 @@
1
1
  import { endPrompt, startPrompt } from "@reliverse/rempts";
2
- const version = "1.7.83";
2
+ const version = "1.7.85";
3
3
  export async function showStartPrompt(isDev) {
4
4
  await startPrompt({
5
5
  titleColor: "inverse",
package/package.json CHANGED
@@ -52,7 +52,7 @@
52
52
  "license": "MIT",
53
53
  "name": "@reliverse/dler",
54
54
  "type": "module",
55
- "version": "1.7.83",
55
+ "version": "1.7.85",
56
56
  "keywords": [
57
57
  "reliverse",
58
58
  "cli",