@reliverse/dler 1.2.1 → 1.2.3
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/README.md +126 -61
- package/bin/app/build/cmd.js +17 -0
- package/bin/app/deps/impl/types.js +0 -0
- package/bin/{cli/args/inject → app/inject/impl}/ts-expect-error.txt +3 -3
- package/bin/app/libs/cmd.js +0 -0
- package/bin/app/mono/cmd.js +0 -0
- package/bin/app/pub/cmd.js +17 -0
- package/bin/app/relifso/cmd.js +5 -0
- package/bin/{cli/args/init/libs/reinit/reint-impl → app/relifso/impl}/reinit-mod.txt +5 -5
- package/bin/{cli/args/init/libs/reinit/reint-impl → app/relifso/impl}/templates/t-license.js +1 -1
- package/bin/app/relifso/impl/types.js +0 -0
- package/bin/app/relinka/cmd.js +0 -0
- package/bin/{cli/args/init/init-mod.txt → app/rempts/cmd.txt} +1 -1
- package/bin/{cli/args/init/cmd → app/rempts/impl}/index.js +5 -4
- package/bin/app/spell/cmd.js +0 -0
- package/bin/app/split/cmd.js +0 -0
- package/bin/{cli/args/tools/index.js → app/tools/cmd.js} +2 -2
- package/bin/{cli/args/tools/tools-impl.js → app/tools/impl.js} +15 -15
- package/bin/{tools.txt → app/tools/tools.txt} +1 -1
- package/bin/cli.js +104 -3
- package/bin/init.js +22 -6
- package/bin/libs/cfg/cfg-default.js +1 -0
- package/bin/libs/sdk/sdk-impl/build/build-library.js +68 -36
- package/bin/libs/sdk/sdk-impl/build/build-regular.js +22 -12
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/auto.js +1 -1
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.js +4 -7
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist.js +3 -1
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/watch.js +3 -3
- package/bin/libs/sdk/sdk-impl/library-flow.js +1 -1
- package/bin/libs/sdk/sdk-impl/pub/pub-library.js +9 -9
- package/bin/libs/sdk/sdk-impl/pub/pub-regular.js +4 -4
- package/bin/libs/sdk/sdk-impl/regular-flow.js +17 -11
- package/bin/libs/sdk/sdk-impl/utils/tools/tools-impl.js +6 -6
- package/bin/libs/sdk/sdk-impl/utils/utils-build.js +2 -2
- package/bin/libs/sdk/sdk-impl/utils/utils-bump.js +4 -4
- package/bin/libs/sdk/sdk-impl/utils/utils-fs.js +2 -5
- package/bin/libs/sdk/sdk-impl/utils/utils-info.js +4 -4
- package/bin/libs/sdk/sdk-impl/utils/utils-jsr-json.js +3 -1
- package/bin/libs/sdk/sdk-impl/utils/utils-paths.js +6 -6
- package/bin/libs/sdk/sdk-impl/utils/utils-pkg-json-libs.js +2 -2
- package/bin/libs/sdk/sdk-impl/utils/utils-pkg-json-reg.js +8 -5
- package/bin/load.js +1 -1
- package/bin/mod.js +7 -39
- package/package.json +7 -8
- package/bin/cli/args/deps/deps-mod.js +0 -48
- package/bin/cli/args/init/libs/reinit/reinit-mod.js +0 -5
- package/bin/cli/args/init/types.js +0 -1
- package/bin/cli/args/spell/spell-mod.js +0 -44
- package/bin/cli/args/split/split-mod.js +0 -26
- /package/bin/{cli/args/agg/agg-mod.js → app/agg/cmd.js} +0 -0
- /package/bin/{cli/args/conv/conv-mod.js → app/auth/cmd.js} +0 -0
- /package/bin/{cli/args/deps/types.js → app/cmds.js} +0 -0
- /package/bin/{cli/args → app}/conv/README.md +0 -0
- /package/bin/{cli/args/init/libs/reinit/reint-impl/types.js → app/conv/cmd.js} +0 -0
- /package/bin/{cli/args/mono/mono-mod.js → app/deps/cmd.js} +0 -0
- /package/bin/{cli/args/deps → app/deps/impl}/analyzer.js +0 -0
- /package/bin/{cli/args/deps → app/deps/impl}/filesystem.js +0 -0
- /package/bin/{cli/args/deps → app/deps/impl}/formatter.js +0 -0
- /package/bin/{cli/args/deps → app/deps/impl}/parser.js +0 -0
- /package/bin/{cli/args → app}/inject/README.md +0 -0
- /package/bin/{cli/args/inject/inject-mod.js → app/inject/cmd.js} +0 -0
- /package/bin/{cli/args/inject → app/inject/impl}/arg-ts-expect-error.txt +0 -0
- /package/bin/{cli/args/inject → app/inject/impl}/inject-mod.txt +0 -0
- /package/bin/{cli/args/inject → app/inject/impl}/reinject.config.js +0 -0
- /package/bin/{cli/args/merger → app/merge}/README.md +0 -0
- /package/bin/{cli/args/merger/merger-mod.txt → app/merge/cmd.txt} +0 -0
- /package/bin/{cli/args/init/libs/reinit/reint-impl → app/relifso/impl}/const.js +0 -0
- /package/bin/{cli/args/init/libs/reinit/reint-impl → app/relifso/impl}/templates/t-gitignore.js +0 -0
- /package/bin/{cli/args/init/libs/reinit/reint-impl → app/relifso/impl}/templates/t-readme.js +0 -0
- /package/bin/{cli/args/init/libs/reinit/reint-impl → app/relifso/impl}/utils.js +0 -0
- /package/bin/{cli/args/init → app/rempts}/README.md +0 -0
- /package/bin/{cli/args → app}/split/README.md +0 -0
- /package/bin/{cli/args/split/split-impl.js → app/split/impl.js} +0 -0
package/bin/init.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { relinka } from "@reliverse/relinka";
|
|
2
2
|
import fs from "fs-extra";
|
|
3
3
|
import path from "pathe";
|
|
4
|
+
import { readPackageJSON } from "pkg-types";
|
|
4
5
|
import { DEFAULT_CONFIG } from "./libs/cfg/cfg-default.js";
|
|
5
6
|
const CONFIG_FILENAME = ".config/dler.ts";
|
|
6
7
|
export async function initDlerConfig(isDev) {
|
|
@@ -10,15 +11,23 @@ export async function initDlerConfig(isDev) {
|
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
12
13
|
try {
|
|
13
|
-
|
|
14
|
+
let pkgDescription = void 0;
|
|
15
|
+
try {
|
|
16
|
+
const pkg = await readPackageJSON();
|
|
17
|
+
if (pkg && typeof pkg.description === "string" && pkg.description.trim()) {
|
|
18
|
+
pkgDescription = pkg.description.trim();
|
|
19
|
+
}
|
|
20
|
+
} catch {
|
|
21
|
+
}
|
|
22
|
+
const configContent = generateConfig(isDev, pkgDescription);
|
|
14
23
|
await fs.outputFile(configPath, configContent, "utf-8");
|
|
15
24
|
relinka("success", `Config was created at ${configPath}`);
|
|
16
|
-
relinka("
|
|
25
|
+
relinka("log", "Edit this file to customize build and publish settings");
|
|
17
26
|
if (!isDev) {
|
|
18
|
-
relinka("
|
|
19
|
-
relinka("
|
|
27
|
+
relinka("log", "Please note: commonPubPause is set to true by default");
|
|
28
|
+
relinka("log", "When you're ready, run `dler` to build and publish");
|
|
20
29
|
} else {
|
|
21
|
-
relinka("
|
|
30
|
+
relinka("log", "When you're ready, run `bun pub` to build and publish");
|
|
22
31
|
}
|
|
23
32
|
process.exit(0);
|
|
24
33
|
} catch (error) {
|
|
@@ -29,7 +38,7 @@ export async function initDlerConfig(isDev) {
|
|
|
29
38
|
process.exit(1);
|
|
30
39
|
}
|
|
31
40
|
}
|
|
32
|
-
function generateConfig(isDev) {
|
|
41
|
+
function generateConfig(isDev, pkgDescription) {
|
|
33
42
|
const importDefineConfigStatement = isDev ? `import { defineConfig } from "./libs/cfg/cfg-mod.js";` : `import { defineConfig } from "@reliverse/dler-cfg";`;
|
|
34
43
|
const verboseValue = getValue(isDev, true, DEFAULT_CONFIG.commonVerbose);
|
|
35
44
|
const isCLIValue = getValue(isDev, true, DEFAULT_CONFIG.coreIsCLI);
|
|
@@ -48,6 +57,12 @@ function generateConfig(isDev) {
|
|
|
48
57
|
false,
|
|
49
58
|
DEFAULT_CONFIG.coreDeclarations
|
|
50
59
|
);
|
|
60
|
+
const coreDescriptionValue = getValue(
|
|
61
|
+
isDev,
|
|
62
|
+
// TODO: remove `description` from dler's `package.json` when ensured that whole dler's codebase can optionally read dler.ts' `coreDescription`
|
|
63
|
+
"dler (prev. relidler) is a flexible, unified, and fully automated bundler for TypeScript and JavaScript projects, as well as an NPM and JSR publishing tool.",
|
|
64
|
+
pkgDescription || DEFAULT_CONFIG.coreDescription
|
|
65
|
+
);
|
|
51
66
|
const libsActModeValue = getValue(
|
|
52
67
|
isDev,
|
|
53
68
|
"main-and-libs",
|
|
@@ -100,6 +115,7 @@ export default defineConfig({
|
|
|
100
115
|
|
|
101
116
|
// Core configuration
|
|
102
117
|
coreDeclarations: ${coreDeclarationsValue},
|
|
118
|
+
coreDescription: ${JSON.stringify(coreDescriptionValue)},
|
|
103
119
|
coreEntryFile: "${DEFAULT_CONFIG.coreEntryFile}",
|
|
104
120
|
coreEntrySrcDir: "${DEFAULT_CONFIG.coreEntrySrcDir}",
|
|
105
121
|
coreIsCLI: ${isCLIValue},
|
|
@@ -51,7 +51,7 @@ export async function library_buildLibrary(options) {
|
|
|
51
51
|
replacementMarker: REPLACEMENT_MARKER
|
|
52
52
|
};
|
|
53
53
|
try {
|
|
54
|
-
relinka("
|
|
54
|
+
relinka("log", `Running pre-build replacements for ${libName}...`);
|
|
55
55
|
replacedFiles = await preBuildReplacements(replacementConfig);
|
|
56
56
|
relinka("verbose", `Pre-build: ${replacedFiles.length} files modified.`);
|
|
57
57
|
await executeBuildTasks(options);
|
|
@@ -94,7 +94,7 @@ async function executeBuildTasks(options) {
|
|
|
94
94
|
`JSR build requested for ${libName} but 'options.jsr' is missing.`
|
|
95
95
|
);
|
|
96
96
|
}
|
|
97
|
-
relinka("
|
|
97
|
+
relinka("log", `Queueing JSR build for lib ${libName}...`);
|
|
98
98
|
buildTasks.push(() => library_buildJsrDist(options));
|
|
99
99
|
}
|
|
100
100
|
if (commonPubRegistry === "npm" || commonPubRegistry === "npm-jsr") {
|
|
@@ -103,7 +103,7 @@ async function executeBuildTasks(options) {
|
|
|
103
103
|
`NPM build requested for ${libName} but 'options.npm' is missing.`
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
|
-
relinka("
|
|
106
|
+
relinka("log", `Queueing NPM build for lib ${libName}...`);
|
|
107
107
|
buildTasks.push(() => library_buildNpmDist(options));
|
|
108
108
|
}
|
|
109
109
|
if (buildTasks.length === 0) {
|
|
@@ -114,11 +114,11 @@ async function executeBuildTasks(options) {
|
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
116
|
if (buildTasks.length > 1) {
|
|
117
|
-
relinka("
|
|
117
|
+
relinka("log", `Building lib ${libName} for NPM and JSR concurrently...`);
|
|
118
118
|
await pAll(buildTasks, { concurrency: CONCURRENCY_DEFAULT });
|
|
119
119
|
} else {
|
|
120
120
|
relinka(
|
|
121
|
-
"
|
|
121
|
+
"log",
|
|
122
122
|
`Building lib ${libName} for ${options.commonPubRegistry || "single target"}...`
|
|
123
123
|
);
|
|
124
124
|
const task = buildTasks[0];
|
|
@@ -137,7 +137,7 @@ async function library_buildJsrDist(options) {
|
|
|
137
137
|
const jsrOptions = options.jsr;
|
|
138
138
|
const { jsrOutDir, distJsrBuilder, distJsrOutFilesExt } = jsrOptions;
|
|
139
139
|
const targetType = "jsr";
|
|
140
|
-
relinka("
|
|
140
|
+
relinka("log", `[JSR] Initializing JSR build for ${libName}...`);
|
|
141
141
|
const libSourceDirResolved = path.resolve(PROJECT_ROOT, options.mainDir);
|
|
142
142
|
const entryFilePathResolved = path.resolve(libSourceDirResolved, libMainFile);
|
|
143
143
|
const outputDirRootResolved = path.resolve(PROJECT_ROOT, jsrOutDir);
|
|
@@ -145,20 +145,28 @@ async function library_buildJsrDist(options) {
|
|
|
145
145
|
outputDirRootResolved,
|
|
146
146
|
BIN_DIR_NAME
|
|
147
147
|
);
|
|
148
|
-
const
|
|
148
|
+
const { libSpecificSrcDir, libDirName } = await determineNpmSourceDirectory(
|
|
149
|
+
libName,
|
|
150
|
+
libMainFile,
|
|
151
|
+
libSourceDirResolved,
|
|
152
|
+
libsList,
|
|
153
|
+
"jsr"
|
|
154
|
+
);
|
|
155
|
+
const bundlerEntryPoint = distJsrBuilder === "jsr" ? libSpecificSrcDir : entryFilePathResolved;
|
|
149
156
|
const libConfig = libsList[libName];
|
|
150
157
|
const libDeclarations = libConfig?.libDeclarations ?? false;
|
|
151
158
|
const buildParams = {
|
|
152
159
|
targetType,
|
|
153
160
|
builder: distJsrBuilder,
|
|
154
|
-
libSourceDir:
|
|
161
|
+
libSourceDir: libSpecificSrcDir,
|
|
155
162
|
entryFilePath: bundlerEntryPoint,
|
|
156
163
|
outputDirRoot: outputDirRootResolved,
|
|
157
164
|
outputDirBin: outputDirBinResolved,
|
|
158
165
|
libDeclarations,
|
|
159
166
|
distJsrOutFilesExt,
|
|
160
|
-
options
|
|
161
|
-
|
|
167
|
+
options,
|
|
168
|
+
libDirName
|
|
169
|
+
// Pass determined libDirName
|
|
162
170
|
};
|
|
163
171
|
await buildDistributionTarget(buildParams);
|
|
164
172
|
relinka(
|
|
@@ -192,7 +200,7 @@ async function library_buildNpmDist(options) {
|
|
|
192
200
|
const distJsrOutFilesExt = options.jsr?.distJsrOutFilesExt || "ts";
|
|
193
201
|
const targetType = "npm";
|
|
194
202
|
const distName = determineDistName(npmOutDir, false, libsList);
|
|
195
|
-
relinka("
|
|
203
|
+
relinka("log", `[NPM:${distName}] Initializing NPM build for ${libName}...`);
|
|
196
204
|
const coreEntrySrcDirResolved = path.resolve(PROJECT_ROOT, coreEntrySrcDir);
|
|
197
205
|
const outputDirRootResolved = path.resolve(PROJECT_ROOT, npmOutDir);
|
|
198
206
|
const outputDirBinResolved = path.resolve(
|
|
@@ -281,10 +289,10 @@ async function buildDistributionTarget(params) {
|
|
|
281
289
|
} = options;
|
|
282
290
|
const isJsr = targetType === "jsr";
|
|
283
291
|
const logPrefix = isJsr ? "[JSR]" : `[NPM:${determineDistName(path.relative(PROJECT_ROOT, outputDirRoot), false, libsList)}]`;
|
|
284
|
-
relinka("
|
|
292
|
+
relinka("log", `${logPrefix} Starting build target processing...`);
|
|
285
293
|
await ensuredir(outputDirRoot);
|
|
286
294
|
await ensuredir(outputDirBin);
|
|
287
|
-
relinka("
|
|
295
|
+
relinka("log", `${logPrefix} Using builder: ${builder}`);
|
|
288
296
|
const bundleRequest = {
|
|
289
297
|
builder,
|
|
290
298
|
entryPoint: entryFilePath,
|
|
@@ -304,22 +312,37 @@ async function buildDistributionTarget(params) {
|
|
|
304
312
|
unifiedBundlerOutExt
|
|
305
313
|
};
|
|
306
314
|
await library_bundleWithBuilder(bundleRequest);
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
315
|
+
if (await fs.pathExists(outputDirBin)) {
|
|
316
|
+
const files = await fs.readdir(outputDirBin);
|
|
317
|
+
if (files.length > 0) {
|
|
318
|
+
await library_performCommonBuildSteps({
|
|
319
|
+
coreEntryFileName: path.basename(libMainFile),
|
|
320
|
+
outDirRoot: outputDirRoot,
|
|
321
|
+
outDirBin: outputDirBin,
|
|
322
|
+
isJsr,
|
|
323
|
+
libName,
|
|
324
|
+
libsList,
|
|
325
|
+
rmDepsMode,
|
|
326
|
+
rmDepsPatterns,
|
|
327
|
+
unifiedBundlerOutExt,
|
|
328
|
+
distJsrOutFilesExt,
|
|
329
|
+
deleteFiles: isJsr,
|
|
330
|
+
// Only delete files for JSR builds
|
|
331
|
+
libDirName
|
|
332
|
+
});
|
|
333
|
+
} else {
|
|
334
|
+
relinka(
|
|
335
|
+
"warn",
|
|
336
|
+
`${logPrefix} No files found in ${outputDirBin} after bundling`
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
} else {
|
|
340
|
+
relinka(
|
|
341
|
+
"warn",
|
|
342
|
+
`${logPrefix} Output directory ${outputDirBin} does not exist after bundling`
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
relinka("log", `${logPrefix} Completed build target processing.`);
|
|
323
346
|
}
|
|
324
347
|
async function library_bundleWithBuilder(params) {
|
|
325
348
|
const { builder, ...executorParams } = params;
|
|
@@ -494,19 +517,26 @@ async function library_bundleUsingUnified(entryPoint, outDirBin, builder, source
|
|
|
494
517
|
);
|
|
495
518
|
validatedExt = "js";
|
|
496
519
|
}
|
|
497
|
-
|
|
498
|
-
const outDirRelative = path.relative(rootDir, outDirBin);
|
|
520
|
+
await ensuredir(outDirBin);
|
|
499
521
|
const unifiedBuildConfig = {
|
|
500
522
|
clean: false,
|
|
501
523
|
declaration: libDeclarations ? "compatible" : false,
|
|
502
524
|
entries: [
|
|
503
525
|
{
|
|
504
526
|
builder,
|
|
505
|
-
input:
|
|
506
|
-
outDir:
|
|
507
|
-
|
|
527
|
+
input: entryPoint,
|
|
528
|
+
outDir: outDirBin,
|
|
529
|
+
// Explicitly set the output directory
|
|
530
|
+
rootDir: sourceDirContext,
|
|
531
|
+
ext: validatedExt,
|
|
532
|
+
...builder === "mkdist" && {
|
|
533
|
+
cleanDist: true
|
|
534
|
+
// Clean the output directory before building
|
|
535
|
+
}
|
|
508
536
|
}
|
|
509
537
|
],
|
|
538
|
+
outDir: outDirBin,
|
|
539
|
+
rootDir: sourceDirContext,
|
|
510
540
|
rollup: {
|
|
511
541
|
emitCJS: false,
|
|
512
542
|
esbuild: {
|
|
@@ -519,7 +549,9 @@ async function library_bundleUsingUnified(entryPoint, outDirBin, builder, source
|
|
|
519
549
|
}
|
|
520
550
|
},
|
|
521
551
|
hooks: {},
|
|
522
|
-
stub: transpileStub
|
|
552
|
+
stub: transpileStub,
|
|
553
|
+
transpileWatch: false
|
|
554
|
+
// Not supported by mkdist
|
|
523
555
|
};
|
|
524
556
|
try {
|
|
525
557
|
await unifiedBuild(rootDir, unifiedBuildConfig, outDirBin);
|
|
@@ -777,7 +809,7 @@ async function preBuildReplacements(config) {
|
|
|
777
809
|
});
|
|
778
810
|
await fs.writeFile(filePath, updatedCode, "utf-8");
|
|
779
811
|
relinka(
|
|
780
|
-
"
|
|
812
|
+
"log",
|
|
781
813
|
`Applied pre-build replacement in ${path.relative(PROJECT_ROOT, filePath)}`
|
|
782
814
|
);
|
|
783
815
|
} else {
|
|
@@ -34,15 +34,15 @@ import {
|
|
|
34
34
|
import { regular_createPackageJSON } from "../utils/utils-pkg-json-reg.js";
|
|
35
35
|
import { createTSConfig } from "../utils/utils-tsconfig.js";
|
|
36
36
|
import { ensuredir } from "./bundlers/unified/utils.js";
|
|
37
|
-
export async function regular_buildJsrDist(isDev, isJsr, coreIsCLI, coreEntrySrcDir, distJsrDirName, distJsrBuilder, coreEntryFile, transpileTarget, transpileFormat, transpileSplitting, transpileMinify, transpileSourcemap, transpilePublicPath, unifiedBundlerOutExt, rmDepsMode, timer, transpileStub, transpileWatch, distJsrGenTsconfig, coreDeclarations) {
|
|
38
|
-
relinka("
|
|
37
|
+
export async function regular_buildJsrDist(isDev, isJsr, coreIsCLI, coreEntrySrcDir, distJsrDirName, distJsrBuilder, coreEntryFile, transpileTarget, transpileFormat, transpileSplitting, transpileMinify, transpileSourcemap, transpilePublicPath, unifiedBundlerOutExt, rmDepsMode, timer, transpileStub, transpileWatch, distJsrGenTsconfig, coreDeclarations, config) {
|
|
38
|
+
relinka("log", "Building JSR distribution...");
|
|
39
39
|
const coreEntrySrcDirResolved = path.resolve(PROJECT_ROOT, coreEntrySrcDir);
|
|
40
40
|
const coreEntryFilePath = path.join(coreEntrySrcDirResolved, coreEntryFile);
|
|
41
41
|
const distJsrDirNameResolved = path.resolve(PROJECT_ROOT, distJsrDirName);
|
|
42
42
|
const outDirBin = path.resolve(distJsrDirNameResolved, "bin");
|
|
43
43
|
await ensuredir(distJsrDirNameResolved);
|
|
44
44
|
await ensuredir(outDirBin);
|
|
45
|
-
relinka("
|
|
45
|
+
relinka("log", `Using JSR builder: ${distJsrBuilder}`);
|
|
46
46
|
await regular_bundleWithBuilder(distJsrBuilder, {
|
|
47
47
|
coreDeclarations,
|
|
48
48
|
outDir: outDirBin,
|
|
@@ -69,11 +69,18 @@ export async function regular_buildJsrDist(isDev, isJsr, coreIsCLI, coreEntrySrc
|
|
|
69
69
|
outDirBin,
|
|
70
70
|
outDirRoot: distJsrDirNameResolved,
|
|
71
71
|
rmDepsMode,
|
|
72
|
-
unifiedBundlerOutExt
|
|
72
|
+
unifiedBundlerOutExt,
|
|
73
|
+
coreDescription: config.coreDescription
|
|
73
74
|
});
|
|
74
75
|
await convertImportExtensionsJsToTs({ dirPath: outDirBin });
|
|
75
76
|
await renameTsxFiles(outDirBin);
|
|
76
|
-
await createJsrJSON(
|
|
77
|
+
await createJsrJSON(
|
|
78
|
+
distJsrDirNameResolved,
|
|
79
|
+
false,
|
|
80
|
+
void 0,
|
|
81
|
+
void 0,
|
|
82
|
+
config.coreDescription
|
|
83
|
+
);
|
|
77
84
|
if (coreIsCLI && isJsr && distJsrGenTsconfig) {
|
|
78
85
|
await createTSConfig(distJsrDirNameResolved, true);
|
|
79
86
|
}
|
|
@@ -86,15 +93,15 @@ export async function regular_buildJsrDist(isDev, isJsr, coreIsCLI, coreEntrySrc
|
|
|
86
93
|
)}))`
|
|
87
94
|
);
|
|
88
95
|
}
|
|
89
|
-
export async function regular_buildNpmDist(isDev, coreEntrySrcDir, distNpmDirName, distNpmBuilder, coreEntryFile, unifiedBundlerOutExt, rmDepsMode, coreIsCLI, transpileTarget, transpileFormat, transpileSplitting, transpileMinify, transpileSourcemap, transpilePublicPath, transpileStub, transpileWatch, timer, coreDeclarations) {
|
|
90
|
-
relinka("
|
|
96
|
+
export async function regular_buildNpmDist(isDev, coreEntrySrcDir, distNpmDirName, distNpmBuilder, coreEntryFile, unifiedBundlerOutExt, rmDepsMode, coreIsCLI, transpileTarget, transpileFormat, transpileSplitting, transpileMinify, transpileSourcemap, transpilePublicPath, transpileStub, transpileWatch, timer, coreDeclarations, config) {
|
|
97
|
+
relinka("log", "Building NPM distribution...");
|
|
91
98
|
const coreEntrySrcDirResolved = path.resolve(PROJECT_ROOT, coreEntrySrcDir);
|
|
92
99
|
const coreEntryFilePath = path.join(coreEntrySrcDirResolved, coreEntryFile);
|
|
93
100
|
const distNpmDirNameResolved = path.resolve(PROJECT_ROOT, distNpmDirName);
|
|
94
101
|
const outDirBin = path.resolve(distNpmDirNameResolved, "bin");
|
|
95
102
|
await ensuredir(distNpmDirNameResolved);
|
|
96
103
|
await ensuredir(outDirBin);
|
|
97
|
-
relinka("
|
|
104
|
+
relinka("log", `Using NPM builder: ${distNpmBuilder}`);
|
|
98
105
|
await regular_bundleWithBuilder(distNpmBuilder, {
|
|
99
106
|
coreDeclarations,
|
|
100
107
|
outDir: outDirBin,
|
|
@@ -119,7 +126,8 @@ export async function regular_buildNpmDist(isDev, coreEntrySrcDir, distNpmDirNam
|
|
|
119
126
|
outDirBin,
|
|
120
127
|
outDirRoot: distNpmDirNameResolved,
|
|
121
128
|
rmDepsMode,
|
|
122
|
-
unifiedBundlerOutExt
|
|
129
|
+
unifiedBundlerOutExt,
|
|
130
|
+
coreDescription: config.coreDescription
|
|
123
131
|
});
|
|
124
132
|
const dirSize = await getDirectorySize(distNpmDirNameResolved, isDev);
|
|
125
133
|
const filesCount = await outDirBinFilesCount(outDirBin);
|
|
@@ -197,7 +205,7 @@ async function regular_bundleUsingBun(coreEntryFile, outDirBin, transpileTarget,
|
|
|
197
205
|
}
|
|
198
206
|
}
|
|
199
207
|
async function regular_bundleUsingJsr(src, dest) {
|
|
200
|
-
relinka("
|
|
208
|
+
relinka("log", `Starting regular_bundleUsingJsr: ${src} -> ${dest}`);
|
|
201
209
|
await ensuredir(path.dirname(dest));
|
|
202
210
|
const stats = await fs.stat(src);
|
|
203
211
|
if (!stats.isDirectory()) {
|
|
@@ -340,7 +348,8 @@ async function regular_performCommonBuildSteps({
|
|
|
340
348
|
outDirBin,
|
|
341
349
|
outDirRoot,
|
|
342
350
|
rmDepsMode,
|
|
343
|
-
unifiedBundlerOutExt
|
|
351
|
+
unifiedBundlerOutExt,
|
|
352
|
+
coreDescription
|
|
344
353
|
}) {
|
|
345
354
|
await convertImportPaths({
|
|
346
355
|
aliasPrefix: "~/",
|
|
@@ -358,7 +367,8 @@ async function regular_performCommonBuildSteps({
|
|
|
358
367
|
coreIsCLI,
|
|
359
368
|
unifiedBundlerOutExt,
|
|
360
369
|
rmDepsMode,
|
|
361
|
-
[]
|
|
370
|
+
[],
|
|
371
|
+
coreDescription
|
|
362
372
|
);
|
|
363
373
|
await copyRootFile(outDirRoot, ["README.md", "LICENSE"]);
|
|
364
374
|
if (isJsr) {
|
|
@@ -23,7 +23,7 @@ export const autoPreset = definePreset(() => {
|
|
|
23
23
|
ctx.options.declaration = res.dts ? "compatible" : false;
|
|
24
24
|
}
|
|
25
25
|
relinka(
|
|
26
|
-
"
|
|
26
|
+
"log",
|
|
27
27
|
"Automatically detected entries:",
|
|
28
28
|
ctx.options.entries.map(
|
|
29
29
|
(e) => e.input.replace(`${ctx.options.rootDir}/`, "").replace(/\/$/, "/*")
|
|
@@ -202,7 +202,7 @@ async function _build(rootDir, inputConfig, buildConfig, pkg, cleanedDirs, _tran
|
|
|
202
202
|
);
|
|
203
203
|
if (process.env.DEBUG) {
|
|
204
204
|
relinka(
|
|
205
|
-
"
|
|
205
|
+
"log",
|
|
206
206
|
`Root dir: ${options.rootDir}
|
|
207
207
|
Entries:
|
|
208
208
|
${options.entries.map((entry) => ` ${dumpObject(entry)}`).join("\n ")}
|
|
@@ -218,7 +218,7 @@ ${options.entries.map((entry) => ` ${dumpObject(entry)}`).join("\n ")}
|
|
|
218
218
|
}
|
|
219
219
|
cleanedDirs.push(dir);
|
|
220
220
|
relinka(
|
|
221
|
-
"
|
|
221
|
+
"log",
|
|
222
222
|
`Cleaning dist directory: \`./${relative(process.cwd(), dir)}\``
|
|
223
223
|
);
|
|
224
224
|
await rmdir(dir);
|
|
@@ -287,7 +287,7 @@ ${entry.modules.filter((m) => m.id.includes("node_modules")).sort((a, b) => (b.b
|
|
|
287
287
|
return ` \u{1F4E6} ${rPath(m.id)}${m.bytes ? ` (${prettyBytes(m.bytes)})` : ""}`;
|
|
288
288
|
}).join("\n")}`;
|
|
289
289
|
}
|
|
290
|
-
relinka("
|
|
290
|
+
relinka("log", entry.chunk ? line : line);
|
|
291
291
|
}
|
|
292
292
|
const elapsedTime = getElapsedPerfTime(timer);
|
|
293
293
|
const transpileFormattedTime = prettyMilliseconds(elapsedTime, {
|
|
@@ -295,15 +295,12 @@ ${entry.modules.filter((m) => m.id.includes("node_modules")).sort((a, b) => (b.b
|
|
|
295
295
|
});
|
|
296
296
|
relinka(
|
|
297
297
|
"info",
|
|
298
|
-
|
|
299
|
-
prettyBytes(ctx.buildEntries.reduce((a, e) => a + (e.bytes || 0), 0)),
|
|
300
|
-
`(build time: ${transpileFormattedTime})`
|
|
298
|
+
`\u03A3 Total dist size: ${prettyBytes(ctx.buildEntries.reduce((a, e) => a + (e.bytes || 0), 0))} (build time: ${transpileFormattedTime})`
|
|
301
299
|
);
|
|
302
300
|
}
|
|
303
301
|
validateDependencies(ctx);
|
|
304
302
|
validatePackage(pkg, rootDir, ctx);
|
|
305
303
|
await ctx.hooks.callHook("build:done", ctx);
|
|
306
|
-
relinka("info", "");
|
|
307
304
|
if (ctx.warnings.size > 0) {
|
|
308
305
|
relinka(
|
|
309
306
|
"warn",
|
|
@@ -2,6 +2,7 @@ import { relinka } from "@reliverse/relinka";
|
|
|
2
2
|
import { mkdist } from "mkdist";
|
|
3
3
|
import { relative } from "pathe";
|
|
4
4
|
import {
|
|
5
|
+
ensuredir,
|
|
5
6
|
rmdir,
|
|
6
7
|
symlink,
|
|
7
8
|
warn
|
|
@@ -13,12 +14,13 @@ export async function mkdistBuild(ctx) {
|
|
|
13
14
|
await ctx.hooks.callHook("mkdist:entries", ctx, entries);
|
|
14
15
|
for (const entry of entries) {
|
|
15
16
|
const distDir = entry.outDir || entry.input;
|
|
17
|
+
await ensuredir(distDir);
|
|
16
18
|
if (ctx.options.transpileStub) {
|
|
17
19
|
await rmdir(distDir);
|
|
18
20
|
await symlink(entry.input, distDir);
|
|
19
21
|
} else {
|
|
20
22
|
const mkdistOptions = {
|
|
21
|
-
cleanDist:
|
|
23
|
+
cleanDist: true,
|
|
22
24
|
distDir,
|
|
23
25
|
rootDir: ctx.options.rootDir,
|
|
24
26
|
srcDir: entry.input,
|
|
@@ -12,7 +12,7 @@ export function rollupWatch(rollupOptions) {
|
|
|
12
12
|
inputs = Object.keys(rollupOptions.input || {});
|
|
13
13
|
}
|
|
14
14
|
relinka(
|
|
15
|
-
"
|
|
15
|
+
"log",
|
|
16
16
|
`[dler] [rollup] Starting watchers for entries: ${inputs.map((input) => `./${relative(process.cwd(), input)}`).join(", ")}`
|
|
17
17
|
);
|
|
18
18
|
relinka(
|
|
@@ -20,10 +20,10 @@ export function rollupWatch(rollupOptions) {
|
|
|
20
20
|
"[dler] [rollup] Watch mode is experimental and may be unstable"
|
|
21
21
|
);
|
|
22
22
|
transpileWatcher.on("change", (id, { event }) => {
|
|
23
|
-
relinka("
|
|
23
|
+
relinka("log", `${relative(".", id)} was ${event}d`);
|
|
24
24
|
});
|
|
25
25
|
transpileWatcher.on("restart", () => {
|
|
26
|
-
relinka("
|
|
26
|
+
relinka("log", "[dler] [rollup] Rebuilding bundle");
|
|
27
27
|
});
|
|
28
28
|
transpileWatcher.on("event", (event) => {
|
|
29
29
|
if (event.code === "END") {
|
|
@@ -57,7 +57,7 @@ function extractFolderName(libName, libConfig) {
|
|
|
57
57
|
export async function libraries_buildPublish(isDev, timer, libsList, distJsrDryRun, distJsrFailOnWarn, libsDirDist, libsDirSrc, commonPubPause, commonPubRegistry, unifiedBundlerOutExt, distNpmBuilder, coreEntrySrcDir, rmDepsMode, rmDepsPatterns, transpileEsbuild, transpileTarget, transpileFormat, transpileSplitting, transpileSourcemap, transpilePublicPath, distJsrBuilder, transpileStub, transpileWatch, distJsrOutFilesExt) {
|
|
58
58
|
relinka("verbose", "Starting libraries_buildPublish");
|
|
59
59
|
if (!libsList || Object.keys(libsList).length === 0) {
|
|
60
|
-
relinka("
|
|
60
|
+
relinka("log", "No lib configs found in config, skipping libs build.");
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
63
|
const libsEntries = Object.entries(libsList);
|
|
@@ -10,14 +10,14 @@ import {
|
|
|
10
10
|
export async function library_publishLibrary(commonPubRegistry, libName, npmOutDir, jsrOutDir, distJsrDryRun, distJsrFailOnWarn, distJsrAllowDirty, distJsrSlowTypes, isDev, timer) {
|
|
11
11
|
if (isDev) {
|
|
12
12
|
relinka(
|
|
13
|
-
"
|
|
13
|
+
"log",
|
|
14
14
|
`Skipping publishing for lib ${libName} in development mode`
|
|
15
15
|
);
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
switch (commonPubRegistry) {
|
|
19
19
|
case "jsr":
|
|
20
|
-
relinka("
|
|
20
|
+
relinka("log", `Publishing lib ${libName} to JSR only...`);
|
|
21
21
|
await library_pubToJsr(
|
|
22
22
|
jsrOutDir,
|
|
23
23
|
distJsrDryRun,
|
|
@@ -30,7 +30,7 @@ export async function library_publishLibrary(commonPubRegistry, libName, npmOutD
|
|
|
30
30
|
);
|
|
31
31
|
break;
|
|
32
32
|
case "npm":
|
|
33
|
-
relinka("
|
|
33
|
+
relinka("log", `Publishing lib ${libName} to NPM only...`);
|
|
34
34
|
await library_pubToNpm(
|
|
35
35
|
npmOutDir,
|
|
36
36
|
distJsrDryRun,
|
|
@@ -41,7 +41,7 @@ export async function library_publishLibrary(commonPubRegistry, libName, npmOutD
|
|
|
41
41
|
);
|
|
42
42
|
break;
|
|
43
43
|
case "npm-jsr": {
|
|
44
|
-
relinka("
|
|
44
|
+
relinka("log", `Publishing lib ${libName} to both NPM and JSR...`);
|
|
45
45
|
const publishTasks = [
|
|
46
46
|
() => library_pubToNpm(
|
|
47
47
|
npmOutDir,
|
|
@@ -67,7 +67,7 @@ export async function library_publishLibrary(commonPubRegistry, libName, npmOutD
|
|
|
67
67
|
}
|
|
68
68
|
default:
|
|
69
69
|
relinka(
|
|
70
|
-
"
|
|
70
|
+
"log",
|
|
71
71
|
`Registry "${commonPubRegistry}" not recognized for lib ${libName}. Skipping publishing for this lib.`
|
|
72
72
|
);
|
|
73
73
|
}
|
|
@@ -75,13 +75,13 @@ export async function library_publishLibrary(commonPubRegistry, libName, npmOutD
|
|
|
75
75
|
async function library_pubToJsr(libOutDir, distJsrDryRun, distJsrFailOnWarn, distJsrAllowDirty, distJsrSlowTypes, libName, isDev, timer) {
|
|
76
76
|
relinka("verbose", `Starting library_pubToJsr for lib: ${libName}`);
|
|
77
77
|
if (isDev) {
|
|
78
|
-
relinka("
|
|
78
|
+
relinka("log", `Skipping lib ${libName} JSR publish in development mode`);
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
81
|
try {
|
|
82
82
|
if (timer) pausePerfTimer(timer);
|
|
83
83
|
await withWorkingDirectory(libOutDir, async () => {
|
|
84
|
-
relinka("
|
|
84
|
+
relinka("log", `Publishing lib ${libName} to JSR from ${libOutDir}`);
|
|
85
85
|
const command = [
|
|
86
86
|
"bun x jsr publish",
|
|
87
87
|
distJsrDryRun ? "--dry-run" : "",
|
|
@@ -107,13 +107,13 @@ async function library_pubToJsr(libOutDir, distJsrDryRun, distJsrFailOnWarn, dis
|
|
|
107
107
|
async function library_pubToNpm(libOutDir, distJsrDryRun, distJsrFailOnWarn, libName, isDev, timer) {
|
|
108
108
|
relinka("verbose", `Starting library_pubToNpm for lib: ${libName}`);
|
|
109
109
|
if (isDev) {
|
|
110
|
-
relinka("
|
|
110
|
+
relinka("log", `Skipping lib ${libName} NPM publish in development mode`);
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
113
113
|
try {
|
|
114
114
|
if (timer) pausePerfTimer(timer);
|
|
115
115
|
await withWorkingDirectory(libOutDir, async () => {
|
|
116
|
-
relinka("
|
|
116
|
+
relinka("log", `Publishing lib ${libName} to NPM from ${libOutDir}`);
|
|
117
117
|
const command = ["bun publish", distJsrDryRun ? "--dry-run" : ""].filter(Boolean).join(" ");
|
|
118
118
|
await execaCommand(command, { stdio: "inherit" });
|
|
119
119
|
relinka(
|
|
@@ -10,11 +10,11 @@ import {
|
|
|
10
10
|
export async function regular_pubToJsr(distJsrDryRun, distJsrFailOnWarn, isDev, commonPubPause, distJsrDirName, distJsrAllowDirty, distJsrSlowTypes, timer) {
|
|
11
11
|
try {
|
|
12
12
|
if (isDev) {
|
|
13
|
-
relinka("
|
|
13
|
+
relinka("log", "Skipping JSR publish in development mode");
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
if (!commonPubPause) {
|
|
17
|
-
relinka("
|
|
17
|
+
relinka("log", "Publishing to JSR...");
|
|
18
18
|
const distJsrDirNameResolved = path.resolve(PROJECT_ROOT, distJsrDirName);
|
|
19
19
|
if (timer) pausePerfTimer(timer);
|
|
20
20
|
await withWorkingDirectory(distJsrDirNameResolved, async () => {
|
|
@@ -43,11 +43,11 @@ export async function regular_pubToJsr(distJsrDryRun, distJsrFailOnWarn, isDev,
|
|
|
43
43
|
export async function regular_pubToNpm(distJsrDryRun, isDev, commonPubPause, distNpmDirName, timer) {
|
|
44
44
|
try {
|
|
45
45
|
if (isDev) {
|
|
46
|
-
relinka("
|
|
46
|
+
relinka("log", "Skipping NPM publish in development mode");
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
if (!commonPubPause) {
|
|
50
|
-
relinka("
|
|
50
|
+
relinka("log", "Publishing to NPM...");
|
|
51
51
|
const distNpmDirNameResolved = path.resolve(PROJECT_ROOT, distNpmDirName);
|
|
52
52
|
if (timer) pausePerfTimer(timer);
|
|
53
53
|
await withWorkingDirectory(distNpmDirNameResolved, async () => {
|