@reliverse/dler 1.7.63 → 1.7.65

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.
Files changed (93) hide show
  1. package/README.md +43 -3
  2. package/bin/app/agg/cmd.d.ts +0 -4
  3. package/bin/app/agg/cmd.js +0 -4
  4. package/bin/app/build/binary/cmd.d.ts +106 -0
  5. package/bin/app/build/binary/cmd.js +201 -0
  6. package/bin/app/build/cmd.js +3 -2
  7. package/bin/app/check/cmd.d.ts +4 -4
  8. package/bin/app/check/cmd.js +9 -6
  9. package/bin/app/cmds.d.ts +1 -0
  10. package/bin/app/cmds.js +1 -0
  11. package/bin/app/mkdist/cmd.js +4 -3
  12. package/bin/app/pub/cmd.js +3 -2
  13. package/bin/app/update/cmd.d.ts +31 -0
  14. package/bin/app/update/cmd.js +240 -0
  15. package/bin/app/x/cmd.d.ts +0 -5
  16. package/bin/app/x/cmd.js +5 -7
  17. package/bin/cli.js +33 -50
  18. package/bin/libs/cfg/cfg-impl/rse-config/rse-impl/rse-define.d.ts +13 -13
  19. package/bin/libs/sdk/sdk-impl/build/build-library.js +1 -1
  20. package/bin/libs/sdk/sdk-impl/build/build-regular.js +1 -1
  21. package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/auto.d.ts +1 -1
  22. package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/build.d.ts +1 -1
  23. package/bin/libs/sdk/sdk-impl/build/providers/build.js +351 -0
  24. package/bin/libs/sdk/sdk-impl/build/providers/bun/bun-build.d.ts +0 -0
  25. package/bin/libs/sdk/sdk-impl/build/providers/bun/bun-build.js +0 -0
  26. package/bin/libs/sdk/sdk-impl/build/providers/bun/single-file.d.ts +25 -0
  27. package/bin/libs/sdk/sdk-impl/build/providers/bun/single-file.js +133 -0
  28. package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/copy/copy-mod.d.ts +1 -1
  29. package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/mkdist/mkdist-impl/loader.d.ts +1 -1
  30. package/bin/libs/sdk/sdk-impl/build/providers/mkdist/mkdist-impl/loaders/js.d.ts +2 -0
  31. package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/mkdist/mkdist-impl/loaders/loaders-mod.d.ts +1 -1
  32. package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/mkdist/mkdist-impl/loaders/postcss.d.ts +1 -1
  33. package/bin/libs/sdk/sdk-impl/build/providers/mkdist/mkdist-impl/loaders/sass.d.ts +2 -0
  34. package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/mkdist/mkdist-impl/loaders/vue.d.ts +1 -1
  35. package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/mkdist/mkdist-impl/make.d.ts +1 -1
  36. package/bin/libs/sdk/sdk-impl/build/providers/mkdist/mkdist-impl/make.js +203 -0
  37. package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/mkdist/mkdist-impl/utils/dts.d.ts +1 -1
  38. package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/mkdist/mkdist-impl/utils/vue-dts.d.ts +1 -1
  39. package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/mkdist/mkdist-impl/utils/vue-dts.js +1 -2
  40. package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/mkdist/mkdist-mod.d.ts +1 -1
  41. package/bin/libs/sdk/sdk-impl/build/providers/mkdist/mkdist-mod.js +92 -0
  42. package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/rollup/build.d.ts +1 -1
  43. package/bin/libs/sdk/sdk-impl/build/providers/rollup/config.d.ts +2 -0
  44. package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/rollup/plugins/cjs.d.ts +1 -1
  45. package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/rollup/plugins/esbuild.d.ts +1 -1
  46. package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/rollup/stub.d.ts +1 -1
  47. package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/rollup/utils.d.ts +1 -1
  48. package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/rollup/watch.d.ts +1 -1
  49. package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/untyped/untyped-mod.d.ts +1 -1
  50. package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/utils.d.ts +1 -1
  51. package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/validate.d.ts +1 -1
  52. package/bin/libs/sdk/sdk-impl/config/info.js +1 -1
  53. package/bin/libs/sdk/sdk-impl/utils/exec/exec-mod.js +9 -7
  54. package/bin/libs/sdk/sdk-impl/utils/exec/exec-parse.js +15 -0
  55. package/bin/libs/sdk/sdk-impl/utils/pm/pm-meta.d.ts +27 -0
  56. package/bin/libs/sdk/sdk-impl/utils/pm/pm-meta.js +86 -0
  57. package/bin/libs/sdk/sdk-impl/utils/pm/pm-utils.js +19 -0
  58. package/bin/libs/sdk/sdk-mod.d.ts +30 -30
  59. package/bin/libs/sdk/sdk-mod.js +27 -27
  60. package/package.json +4 -1
  61. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.js +0 -377
  62. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/js.d.ts +0 -2
  63. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/sass.d.ts +0 -2
  64. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/make.js +0 -213
  65. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-mod.js +0 -107
  66. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/config.d.ts +0 -2
  67. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/auto.js +0 -0
  68. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/copy/copy-mod.js +0 -0
  69. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/mkdist/mkdist-impl/loader.js +0 -0
  70. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/mkdist/mkdist-impl/loaders/js.js +0 -0
  71. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/mkdist/mkdist-impl/loaders/loaders-mod.js +0 -0
  72. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/mkdist/mkdist-impl/loaders/postcss.js +0 -0
  73. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/mkdist/mkdist-impl/loaders/sass.js +0 -0
  74. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/mkdist/mkdist-impl/loaders/vue.js +0 -0
  75. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/mkdist/mkdist-impl/utils/dts.js +0 -0
  76. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/mkdist/mkdist-impl/utils/fs.d.ts +0 -0
  77. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/mkdist/mkdist-impl/utils/fs.js +0 -0
  78. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/rollup/build.js +0 -0
  79. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/rollup/config.js +0 -0
  80. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/rollup/plugins/cjs.js +0 -0
  81. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/rollup/plugins/esbuild.js +0 -0
  82. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/rollup/plugins/json.d.ts +0 -0
  83. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/rollup/plugins/json.js +0 -0
  84. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/rollup/plugins/raw.d.ts +0 -0
  85. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/rollup/plugins/raw.js +0 -0
  86. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/rollup/plugins/shebang.d.ts +0 -0
  87. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/rollup/plugins/shebang.js +0 -0
  88. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/rollup/stub.js +0 -0
  89. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/rollup/utils.js +0 -0
  90. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/rollup/watch.js +0 -0
  91. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/untyped/untyped-mod.js +0 -0
  92. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/utils.js +0 -0
  93. /package/bin/libs/sdk/sdk-impl/build/{bundlers/unified → providers}/validate.js +0 -0
@@ -0,0 +1,203 @@
1
+ import { resolve, extname, join, basename, dirname } from "@reliverse/pathkit";
2
+ import { relinka } from "@reliverse/relinka";
3
+ import defu from "defu";
4
+ import fsp from "node:fs/promises";
5
+ import { glob } from "tinyglobby";
6
+ import { createLoader } from "./loader.js";
7
+ import { getDeclarations, normalizeCompilerOptions } from "./utils/dts.js";
8
+ import { copyFileWithStream } from "./utils/fs.js";
9
+ import { getVueDeclarations } from "./utils/vue-dts.js";
10
+ export async function mkdist(options = {}) {
11
+ const startTime = Date.now();
12
+ options.rootDir = resolve(process.cwd(), options.rootDir || ".");
13
+ options.srcDir = resolve(options.rootDir, options.srcDir || "src");
14
+ options.distDir = resolve(options.rootDir, options.distDir || "dist");
15
+ if (options.cleanDist !== false) {
16
+ relinka("info", "Cleaning distribution directory...");
17
+ await fsp.unlink(options.distDir).catch(() => {
18
+ });
19
+ await fsp.rm(options.distDir, { recursive: true, force: true });
20
+ await fsp.mkdir(options.distDir, { recursive: true });
21
+ }
22
+ relinka("info", "Scanning input files...");
23
+ const filePaths = await glob(options.pattern || "**", {
24
+ absolute: false,
25
+ ignore: ["**/node_modules", "**/coverage", "**/.git"],
26
+ cwd: options.srcDir,
27
+ dot: true,
28
+ ...options.globOptions
29
+ });
30
+ const files = filePaths.map((path) => {
31
+ const sourcePath = resolve(options.srcDir, path);
32
+ return {
33
+ path,
34
+ srcPath: sourcePath,
35
+ extension: extname(path),
36
+ getContents: () => fsp.readFile(sourcePath, { encoding: "utf8" })
37
+ };
38
+ });
39
+ relinka("info", `Found ${files.length} files to process`);
40
+ options.typescript ||= {};
41
+ if (options.typescript.compilerOptions) {
42
+ relinka("info", "Normalizing TypeScript compiler options...");
43
+ options.typescript.compilerOptions = await normalizeCompilerOptions(
44
+ options.typescript.compilerOptions
45
+ );
46
+ }
47
+ options.typescript.compilerOptions = defu(
48
+ { noEmit: false },
49
+ options.typescript.compilerOptions,
50
+ {
51
+ allowJs: true,
52
+ declaration: true,
53
+ skipLibCheck: true,
54
+ strictNullChecks: true,
55
+ emitDeclarationOnly: true,
56
+ allowImportingTsExtensions: true,
57
+ allowNonTsExtensions: true
58
+ }
59
+ );
60
+ relinka("info", "Creating file loaders...");
61
+ const { loadFile } = createLoader(options);
62
+ relinka("info", "Processing files with loaders...");
63
+ const outputs = [];
64
+ let processedCount = 0;
65
+ await Promise.all(
66
+ files.map(async (file) => {
67
+ const result = await loadFile(file);
68
+ if (result) {
69
+ outputs.push(...result);
70
+ }
71
+ processedCount++;
72
+ const shouldUpdate = processedCount % Math.max(1, Math.floor(files.length / 10)) === 0 || processedCount === files.length;
73
+ if (shouldUpdate) {
74
+ relinka("verbose", `Processing files: ${file.path} (${processedCount}/${files.length})`);
75
+ }
76
+ })
77
+ );
78
+ relinka("info", "Normalizing output extensions...");
79
+ const pathConflicts = [];
80
+ for (const output of outputs.filter((o) => o.extension)) {
81
+ const renamed = basename(output.path, extname(output.path)) + output.extension;
82
+ output.path = join(dirname(output.path), renamed);
83
+ const conflictingOutput = outputs.find((o) => o !== output && o.path === output.path);
84
+ if (conflictingOutput) {
85
+ pathConflicts.push(output.path);
86
+ }
87
+ }
88
+ if (pathConflicts.length > 0) {
89
+ const errorMessage = `Output path conflict detected for paths: ${pathConflicts.join(", ")}. Multiple files would write to the same output path.`;
90
+ relinka("error", errorMessage);
91
+ throw new Error(errorMessage);
92
+ }
93
+ const dtsOutputs = outputs.filter((o) => o.declaration && !o.skip);
94
+ if (dtsOutputs.length > 0) {
95
+ relinka("info", `Generating TypeScript declarations for ${dtsOutputs.length} files...`);
96
+ const vfs = new Map(dtsOutputs.map((o) => [o.srcPath, o.contents || ""]));
97
+ const declarations = /* @__PURE__ */ Object.create(null);
98
+ for (const loader of [getVueDeclarations, getDeclarations]) {
99
+ Object.assign(declarations, await loader(vfs, options));
100
+ }
101
+ let dtsProcessed = 0;
102
+ for (const output of dtsOutputs) {
103
+ const result = declarations[output.srcPath];
104
+ output.contents = result?.contents || "";
105
+ if (result.errors) {
106
+ output.errors = result.errors;
107
+ }
108
+ dtsProcessed++;
109
+ if (dtsProcessed % Math.max(1, Math.floor(dtsOutputs.length / 5)) === 0) {
110
+ relinka("verbose", `Generated declarations for ${dtsProcessed}/${dtsOutputs.length} files`);
111
+ }
112
+ }
113
+ }
114
+ relinka("info", "Resolving relative imports...");
115
+ const outPaths = new Set(outputs.map((o) => o.path));
116
+ const resolveId = (from, id = "", resolveExtensions) => {
117
+ if (!id.startsWith(".")) {
118
+ return id;
119
+ }
120
+ for (const extension of resolveExtensions) {
121
+ if (outPaths.has(join(dirname(from), id + extension))) {
122
+ return id + extension;
123
+ }
124
+ }
125
+ return id;
126
+ };
127
+ const esmResolveExtensions = ["", "/index.mjs", "/index.js", ".mjs", ".ts", ".js"];
128
+ const esmOutputs = outputs.filter((o) => o.extension === ".mjs" || o.extension === ".js");
129
+ for (const output of esmOutputs) {
130
+ output.contents = output.contents.replace(
131
+ /(import|export)(\s+(?:.+|{[\s\w,]+})\s+from\s+["'])(.*)(["'])/g,
132
+ (_, type, head, id, tail) => type + head + resolveId(output.path, id, esmResolveExtensions) + tail
133
+ ).replace(
134
+ /import\((["'])(.*)(["'])\)/g,
135
+ (_, head, id, tail) => "import(" + head + resolveId(output.path, id, esmResolveExtensions) + tail + ")"
136
+ );
137
+ }
138
+ const cjsResolveExtensions = ["", "/index.cjs", ".cjs"];
139
+ const cjsOutputs = outputs.filter((o) => o.extension === ".cjs");
140
+ for (const output of cjsOutputs) {
141
+ output.contents = output.contents.replace(
142
+ /require\((["'])(.*)(["'])\)/g,
143
+ (_, head, id, tail) => "require(" + head + resolveId(output.path, id, cjsResolveExtensions) + tail + ")"
144
+ );
145
+ }
146
+ const outputsToWrite = outputs.filter((o) => !o.skip);
147
+ relinka("info", `Writing ${outputsToWrite.length} output files...`);
148
+ const writtenFiles = [];
149
+ const errors = [];
150
+ let writtenCount = 0;
151
+ await Promise.all(
152
+ outputsToWrite.map(async (output) => {
153
+ try {
154
+ const outFile = join(options.distDir, output.path);
155
+ await fsp.mkdir(dirname(outFile), { recursive: true });
156
+ await (output.raw ? (
157
+ // @ts-expect-error TODO: fix ts
158
+ copyFileWithStream(output.srcPath, outFile)
159
+ ) : (
160
+ // @ts-expect-error TODO: fix ts
161
+ fsp.writeFile(outFile, output.contents, "utf8")
162
+ ));
163
+ writtenFiles.push(outFile);
164
+ if (output.errors) {
165
+ errors.push({ filename: outFile, errors: output.errors });
166
+ }
167
+ } catch (error) {
168
+ const errorMessage = `Failed to write file ${output.path}: ${error instanceof Error ? error.message : "Unknown error"}`;
169
+ errors.push({
170
+ filename: output.path,
171
+ errors: [new TypeError(errorMessage)]
172
+ });
173
+ }
174
+ writtenCount++;
175
+ const progressUpdateInterval = Math.max(10, Math.floor(outputsToWrite.length / 10));
176
+ if (writtenCount % progressUpdateInterval === 0 || writtenCount === outputsToWrite.length) {
177
+ relinka("verbose", `Written ${writtenCount}/${outputsToWrite.length} files`);
178
+ }
179
+ })
180
+ );
181
+ const duration = Date.now() - startTime;
182
+ if (errors.length > 0) {
183
+ relinka("warn", `Build completed with ${errors.length} errors`);
184
+ for (const error of errors.slice(0, 5)) {
185
+ relinka(
186
+ "error",
187
+ `Error in ${error.filename}: ${error.errors[0]?.message || "Unknown error"}`
188
+ );
189
+ }
190
+ if (errors.length > 5) {
191
+ relinka("error", `... and ${errors.length - 5} more errors`);
192
+ }
193
+ } else {
194
+ relinka("success", "Build completed successfully!");
195
+ }
196
+ return {
197
+ result: {
198
+ errors,
199
+ writtenFiles
200
+ },
201
+ duration
202
+ };
203
+ }
@@ -1,6 +1,6 @@
1
1
  import type { TSConfig } from "pkg-types";
2
2
  import type { CompilerHost, EmitResult } from "typescript";
3
- import type { MkdistOptions } from "../../../../../../sdk-types.js";
3
+ import type { MkdistOptions } from "../../../../../sdk-types.js";
4
4
  export declare function normalizeCompilerOptions(_options: TSConfig["compilerOptions"]): Promise<any>;
5
5
  export type DeclarationOutput = Record<string, {
6
6
  contents: string;
@@ -1,3 +1,3 @@
1
- import type { MkdistOptions } from "../../../../../../sdk-types.js";
1
+ import type { MkdistOptions } from "../../../../../sdk-types.js";
2
2
  import type { DeclarationOutput } from "./dts";
3
3
  export declare function getVueDeclarations(vfs: Map<string, string>, opts?: MkdistOptions): Promise<DeclarationOutput>;
@@ -108,7 +108,6 @@ async function emitVueTscV2(vfs, inputFiles, originFiles, opts) {
108
108
  const createProgram = volarTs.proxyCreateProgram(ts, ts.createProgram, (ts2, options) => {
109
109
  const vueLanguagePlugin = vueLanguageCore.createVueLanguagePlugin(
110
110
  ts2,
111
- // @ts-expect-error TODO: fix ts
112
111
  (id) => id,
113
112
  () => "",
114
113
  (fileName) => {
@@ -118,8 +117,8 @@ async function emitVueTscV2(vfs, inputFiles, originFiles, opts) {
118
117
  }
119
118
  return fileMap.has(fileName);
120
119
  },
121
- // @ts-expect-error TODO: fix ts
122
120
  options.options,
121
+ // @ts-expect-error TODO: fix ts
123
122
  {}
124
123
  );
125
124
  return [vueLanguagePlugin];
@@ -1,2 +1,2 @@
1
- import type { BuildContext } from "../../../../sdk-types.js";
1
+ import type { BuildContext } from "../../../sdk-types.js";
2
2
  export declare function mkdistBuild(ctx: BuildContext): Promise<void>;
@@ -0,0 +1,92 @@
1
+ import { relative, dirname as pathDirname } from "@reliverse/pathkit";
2
+ import { relinka } from "@reliverse/relinka";
3
+ import { rmdir, symlink, warn } from "../utils.js";
4
+ import { mkdist } from "./mkdist-impl/make.js";
5
+ export async function mkdistBuild(ctx) {
6
+ const entries = ctx.options.entries.filter((e) => e.builder === "mkdist");
7
+ if (entries.length === 0) {
8
+ return;
9
+ }
10
+ await ctx.hooks.callHook("mkdist:entries", ctx, entries);
11
+ let processedEntries = 0;
12
+ let totalWrittenFiles = 0;
13
+ let totalErrors = 0;
14
+ relinka("info", `Processing ${entries.length} mkdist entries...`);
15
+ for (const entry of entries) {
16
+ processedEntries++;
17
+ relinka("info", `Processing entry ${processedEntries}/${entries.length}: ${entry.input}`);
18
+ const distDir = entry.outDir || entry.input;
19
+ if (ctx.options.transpileStub) {
20
+ await rmdir(distDir);
21
+ await symlink(entry.input, distDir);
22
+ continue;
23
+ }
24
+ let srcDir;
25
+ if (typeof entry.input === "string" && !entry.input.endsWith("/")) {
26
+ srcDir = ctx.options.isLib ? pathDirname(entry.input) : entry.input;
27
+ relinka(
28
+ "verbose",
29
+ `[mkdist] Using directory from file path: ${srcDir} (from: ${entry.input})`
30
+ );
31
+ } else {
32
+ srcDir = entry.input;
33
+ relinka("verbose", `[mkdist] Using directory directly: ${srcDir}`);
34
+ }
35
+ const mkdistOptions = {
36
+ cleanDist: false,
37
+ distDir,
38
+ rootDir: ctx.options.rootDir,
39
+ srcDir,
40
+ format: "esm",
41
+ ext: entry.ext || "js",
42
+ ...entry
43
+ };
44
+ relinka(
45
+ "info",
46
+ `[mkdist] Building with options: srcDir=${mkdistOptions.srcDir}, distDir=${mkdistOptions.distDir}, rootDir=${mkdistOptions.rootDir}`
47
+ );
48
+ await ctx.hooks.callHook("mkdist:entry:options", ctx, entry, mkdistOptions);
49
+ try {
50
+ const { result: output, duration } = await mkdist(mkdistOptions);
51
+ relinka("verbose", `[mkdist] Entry ${processedEntries} completed in ${duration}ms`);
52
+ totalWrittenFiles += output.writtenFiles.length;
53
+ ctx.buildEntries.push({
54
+ chunks: output.writtenFiles.map((p) => relative(ctx.options.outDir, p)),
55
+ path: distDir,
56
+ isLib: ctx.options.isLib
57
+ });
58
+ await ctx.hooks.callHook("mkdist:entry:build", ctx, entry, output);
59
+ if (output.errors && output.errors.length > 0) {
60
+ totalErrors += output.errors.length;
61
+ for (const error of output.errors) {
62
+ warn(
63
+ ctx,
64
+ `mkdist build failed for \`${relative(ctx.options.rootDir, error.filename)}\`:
65
+ ${error.errors.map((e) => ` - ${e}`).join("\n")}`
66
+ );
67
+ }
68
+ }
69
+ } catch (error) {
70
+ totalErrors++;
71
+ warn(
72
+ ctx,
73
+ `mkdist build failed for entry ${entry.input}: ${error instanceof Error ? error.message : "Unknown error"}`
74
+ );
75
+ }
76
+ }
77
+ await ctx.hooks.callHook("mkdist:done", ctx);
78
+ if (entries.length > 0 && ctx.options.transpileWatch) {
79
+ relinka("warn", "`mkdist` builder does not support transpileWatch mode yet.");
80
+ }
81
+ if (totalErrors > 0) {
82
+ relinka(
83
+ "warn",
84
+ `Processed ${entries.length} entries with ${totalErrors} errors. ${totalWrittenFiles} files written.`
85
+ );
86
+ } else {
87
+ relinka(
88
+ "success",
89
+ `Successfully processed ${entries.length} entries. ${totalWrittenFiles} files written.`
90
+ );
91
+ }
92
+ }
@@ -1,2 +1,2 @@
1
- import type { BuildContext } from "../../../../sdk-types.js";
1
+ import type { BuildContext } from "../../../sdk-types.js";
2
2
  export declare function rollupBuild(ctx: BuildContext): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import type { BuildContext, RollupOptions } from "../../../sdk-types.js";
2
+ export declare function getRollupOptions(ctx: BuildContext): RollupOptions;
@@ -1,4 +1,4 @@
1
1
  import type { Plugin } from "rollup";
2
- import type { BuildContext } from "../../../../../sdk-types.js";
2
+ import type { BuildContext } from "../../../../sdk-types.js";
3
3
  export declare function cjsPlugin(): Plugin;
4
4
  export declare function fixCJSExportTypePlugin(ctx: BuildContext): Plugin;
@@ -1,3 +1,3 @@
1
1
  import type { Plugin } from "rollup";
2
- import type { EsbuildOptions } from "../../../../../sdk-types.js";
2
+ import type { EsbuildOptions } from "../../../../sdk-types.js";
3
3
  export declare function esbuild(options: EsbuildOptions): Plugin;
@@ -1,2 +1,2 @@
1
- import type { BuildContext } from "../../../../sdk-types.js";
1
+ import type { BuildContext } from "../../../sdk-types.js";
2
2
  export declare function rollupStub(ctx: BuildContext): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import type { PreRenderedChunk } from "rollup";
2
- import type { BuildContext } from "../../../../sdk-types.js";
2
+ import type { BuildContext } from "../../../sdk-types.js";
3
3
  export declare const DEFAULT_EXTENSIONS: string[];
4
4
  export declare function getChunkFilename(ctx: BuildContext, chunk: PreRenderedChunk, ext: string): string;
5
5
  export declare function resolveAliases(ctx: BuildContext): Record<string, string>;
@@ -1,2 +1,2 @@
1
- import type { RollupOptions } from "../../../../sdk-types.js";
1
+ import type { RollupOptions } from "../../../sdk-types.js";
2
2
  export declare function rollupWatch(rollupOptions: RollupOptions): void;
@@ -1,2 +1,2 @@
1
- import type { BuildContext } from "../../../../sdk-types.js";
1
+ import type { BuildContext } from "../../../sdk-types.js";
2
2
  export declare function typesBuild(ctx: BuildContext): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import type { PackageJson } from "pkg-types";
2
- import type { BuildContext, BuildPreset, UnifiedBuildConfig } from "../../../sdk-types.js";
2
+ import type { BuildContext, BuildPreset, UnifiedBuildConfig } from "../../sdk-types.js";
3
3
  interface OutputDescriptor {
4
4
  file: string;
5
5
  type?: "cjs" | "esm";
@@ -1,4 +1,4 @@
1
1
  import type { PackageJson } from "pkg-types";
2
- import type { BuildContext } from "../../../sdk-types.js";
2
+ import type { BuildContext } from "../../sdk-types.js";
3
3
  export declare function validateDependencies(ctx: BuildContext): void;
4
4
  export declare function validatePackage(pkg: PackageJson, rootDir: string, ctx: BuildContext): void;
@@ -1,5 +1,5 @@
1
1
  import { endPrompt, startPrompt } from "@reliverse/rempts";
2
- const version = "1.7.63";
2
+ const version = "1.7.65";
3
3
  export async function showStartPrompt(isDev) {
4
4
  await startPrompt({
5
5
  titleColor: "inverse",
@@ -180,13 +180,15 @@ export class ExecProcess {
180
180
  this._args
181
181
  );
182
182
  const crossResult = _parse(normalisedCommand, normalisedArgs, nodeOptions);
183
- let handle;
184
- if (process.versions.bun) {
185
- const bunSpawn = Bun.spawn;
186
- handle = bunSpawn(crossResult.command, crossResult.args, crossResult.options);
187
- } else {
188
- handle = spawn(crossResult.command, crossResult.args, crossResult.options);
189
- }
183
+ console.log("DEBUG: spawn parameters:", {
184
+ command: crossResult.command,
185
+ args: crossResult.args,
186
+ commandType: typeof crossResult.command,
187
+ argsType: typeof crossResult.args,
188
+ isArgsArray: Array.isArray(crossResult.args),
189
+ bunVersion: process.versions.bun
190
+ });
191
+ const handle = spawn(crossResult.command, crossResult.args, crossResult.options);
190
192
  if (handle.stderr) {
191
193
  this._streamErr = handle.stderr;
192
194
  }
@@ -34,6 +34,14 @@ async function parseNonShell(parsed) {
34
34
  return parsed;
35
35
  }
36
36
  export async function parse(command, args, options) {
37
+ console.log("DEBUG: parse function called with:", {
38
+ command,
39
+ args,
40
+ options,
41
+ commandType: typeof command,
42
+ argsType: typeof args,
43
+ isArgsArray: Array.isArray(args)
44
+ });
37
45
  let actualArgs = args;
38
46
  let actualOptions = options;
39
47
  if (actualArgs && !Array.isArray(actualArgs)) {
@@ -52,5 +60,12 @@ export async function parse(command, args, options) {
52
60
  args: actualArgs
53
61
  }
54
62
  };
63
+ console.log("DEBUG: parse function returning:", {
64
+ command: parsed.command,
65
+ args: parsed.args,
66
+ commandType: typeof parsed.command,
67
+ argsType: typeof parsed.args,
68
+ isArgsArray: Array.isArray(parsed.args)
69
+ });
55
70
  return actualOptions.shell ? parsed : await parseNonShell(parsed);
56
71
  }
@@ -0,0 +1,27 @@
1
+ interface PackageJsonOptions {
2
+ version?: string;
3
+ omitDeprecated?: boolean;
4
+ registryUrl?: string;
5
+ fullMetadata?: boolean;
6
+ allVersions?: boolean;
7
+ }
8
+ interface PackageData {
9
+ "dist-tags": Record<string, string>;
10
+ versions: Record<string, PackageVersion>;
11
+ time?: Record<string, string>;
12
+ }
13
+ interface PackageVersion {
14
+ version: string;
15
+ deprecated?: boolean;
16
+ time?: Record<string, string>;
17
+ [key: string]: any;
18
+ }
19
+ export declare class PackageNotFoundError extends Error {
20
+ constructor(packageName: string);
21
+ }
22
+ export declare class VersionNotFoundError extends Error {
23
+ constructor(packageName: string, version: string);
24
+ }
25
+ export default function packageJson(packageName: string, options?: PackageJsonOptions): Promise<PackageData | PackageVersion>;
26
+ export declare function latestVersion(packageName: string, options?: PackageJsonOptions): Promise<string>;
27
+ export {};
@@ -0,0 +1,86 @@
1
+ import ky from "ky";
2
+ import registryAuthToken from "registry-auth-token";
3
+ import registryUrl from "registry-url";
4
+ import semver from "semver";
5
+ export class PackageNotFoundError extends Error {
6
+ constructor(packageName) {
7
+ super(`Package \`${packageName}\` could not be found`);
8
+ this.name = "PackageNotFoundError";
9
+ }
10
+ }
11
+ export class VersionNotFoundError extends Error {
12
+ constructor(packageName, version) {
13
+ super(`Version \`${version}\` for package \`${packageName}\` could not be found`);
14
+ this.name = "VersionNotFoundError";
15
+ }
16
+ }
17
+ export default async function packageJson(packageName, options = {}) {
18
+ let { version = "latest" } = options;
19
+ const { omitDeprecated = true } = options;
20
+ const scope = packageName.split("/")[0];
21
+ const registryUrl_ = options.registryUrl ?? registryUrl(scope);
22
+ const packageUrl = new URL(encodeURIComponent(packageName).replace(/^%40/, "@"), registryUrl_);
23
+ const authInfo = registryAuthToken(registryUrl_.toString(), { recursive: true });
24
+ const headers = {
25
+ accept: "application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*"
26
+ };
27
+ if (options.fullMetadata) {
28
+ delete headers.accept;
29
+ }
30
+ if (authInfo) {
31
+ headers.authorization = `${authInfo.type} ${authInfo.token}`;
32
+ }
33
+ let data;
34
+ try {
35
+ data = await ky(packageUrl, { headers, keepalive: true }).json();
36
+ } catch (error) {
37
+ if (error?.response?.status === 404) {
38
+ throw new PackageNotFoundError(packageName);
39
+ }
40
+ throw error;
41
+ }
42
+ if (options.allVersions) {
43
+ return data;
44
+ }
45
+ const versionError = new VersionNotFoundError(packageName, version);
46
+ if (version && data["dist-tags"][version]) {
47
+ const { time } = data;
48
+ const versionTag = data["dist-tags"][version];
49
+ if (versionTag) {
50
+ const packageVersion = data.versions[versionTag];
51
+ if (packageVersion) {
52
+ packageVersion.time = time;
53
+ return packageVersion;
54
+ }
55
+ }
56
+ } else if (version) {
57
+ const versionExists = Boolean(data.versions[version]);
58
+ if (omitDeprecated && !versionExists) {
59
+ for (const [metadataVersion, metadata] of Object.entries(data.versions)) {
60
+ if (metadata.deprecated) {
61
+ delete data.versions[metadataVersion];
62
+ }
63
+ }
64
+ }
65
+ if (!versionExists) {
66
+ const versions = Object.keys(data.versions);
67
+ const resolvedVersion = semver.maxSatisfying(versions, version);
68
+ if (!resolvedVersion) {
69
+ throw versionError;
70
+ }
71
+ version = resolvedVersion;
72
+ }
73
+ const { time } = data;
74
+ const packageVersion = data.versions[version];
75
+ if (!packageVersion) {
76
+ throw versionError;
77
+ }
78
+ packageVersion.time = time;
79
+ return packageVersion;
80
+ }
81
+ throw versionError;
82
+ }
83
+ export async function latestVersion(packageName, options = {}) {
84
+ const { version } = await packageJson(packageName.toLowerCase(), options);
85
+ return version;
86
+ }
@@ -26,7 +26,26 @@ const hasCorepack = cached(async () => {
26
26
  }
27
27
  });
28
28
  export async function executeCommand(command, args, options = {}) {
29
+ console.log("DEBUG: executeCommand called with:", {
30
+ command,
31
+ args,
32
+ options,
33
+ commandType: typeof command,
34
+ argsType: typeof args,
35
+ isArgsArray: Array.isArray(args)
36
+ });
37
+ if (!Array.isArray(args)) {
38
+ throw new Error(`executeCommand: args must be an array, got ${typeof args}: ${args}`);
39
+ }
29
40
  const xArgs = command === "npm" || command === "bun" || command === "deno" || !await hasCorepack() ? [command, args] : ["corepack", [command, ...args]];
41
+ console.log("DEBUG: executeCommand xArgs:", {
42
+ xArgs,
43
+ command: xArgs[0],
44
+ args: xArgs[1],
45
+ commandType: typeof xArgs[0],
46
+ argsType: typeof xArgs[1],
47
+ isArgsArray: Array.isArray(xArgs[1])
48
+ });
30
49
  const { exitCode, stdout, stderr } = await x(xArgs[0], xArgs[1], {
31
50
  nodeOptions: {
32
51
  cwd: resolve(options.cwd || process.cwd()),