@reliverse/dler 1.2.0
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/LICENSE +21 -0
- package/README.md +312 -0
- package/bin/cli/args/agg/main.js +0 -0
- package/bin/cli/args/conv/README.md +3 -0
- package/bin/cli/args/conv/main.js +0 -0
- package/bin/cli/args/deps/analyzer.js +42 -0
- package/bin/cli/args/deps/filesystem.js +42 -0
- package/bin/cli/args/deps/formatter.js +65 -0
- package/bin/cli/args/deps/mod.js +48 -0
- package/bin/cli/args/deps/parser.js +59 -0
- package/bin/cli/args/deps/types.js +0 -0
- package/bin/cli/args/init/README.md +121 -0
- package/bin/cli/args/init/libs/reinit/reinit-main.js +5 -0
- package/bin/cli/args/init/libs/reinit/reint-impl/const.js +26 -0
- package/bin/cli/args/init/libs/reinit/reint-impl/mod.txt +395 -0
- package/bin/cli/args/init/libs/reinit/reint-impl/templates/t-gitignore.js +9 -0
- package/bin/cli/args/init/libs/reinit/reint-impl/templates/t-license.js +22 -0
- package/bin/cli/args/init/libs/reinit/reint-impl/templates/t-readme.js +59 -0
- package/bin/cli/args/init/libs/reinit/reint-impl/types.js +0 -0
- package/bin/cli/args/init/libs/reinit/reint-impl/utils.js +3 -0
- package/bin/cli/args/init/main.txt +121 -0
- package/bin/cli/args/init/types.js +1 -0
- package/bin/cli/args/inject/README.md +148 -0
- package/bin/cli/args/inject/arg-ts-expect-error.txt +49 -0
- package/bin/cli/args/inject/cli-mod.js +32 -0
- package/bin/cli/args/inject/main.txt +28 -0
- package/bin/cli/args/inject/reinject.config.js +4 -0
- package/bin/cli/args/inject/ts-expect-error.txt +277 -0
- package/bin/cli/args/merger/README.md +125 -0
- package/bin/cli/args/merger/main.txt +306 -0
- package/bin/cli/args/mono/main.js +0 -0
- package/bin/cli/args/spells/mod.js +44 -0
- package/bin/cli/args/split/README.md +13 -0
- package/bin/cli/args/split/split-main.js +26 -0
- package/bin/cli/args/split/split-mod.js +117 -0
- package/bin/cli/args/tools/index.js +81 -0
- package/bin/cli/args/tools/tools-impl.js +296 -0
- package/bin/cli.js +111 -0
- package/bin/init.js +157 -0
- package/bin/libs/cfg/cfg-default.js +50 -0
- package/bin/libs/cfg/cfg-main.js +1 -0
- package/bin/libs/cfg/cfg-mod.js +4 -0
- package/bin/libs/cfg/cfg-types.js +1 -0
- package/bin/libs/sdk/sdk-impl/build/build-library.js +865 -0
- package/bin/libs/sdk/sdk-impl/build/build-regular.js +373 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/auto.js +110 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.js +322 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/copy/copy.js +62 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/copy/types.js +0 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist.js +57 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/types.js +0 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/build.js +104 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/config.js +124 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/cjs.js +48 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/esbuild.js +91 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/json.js +17 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/raw.js +20 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/shebang.js +42 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/stub.js +137 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/types.js +0 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/utils.js +41 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/watch.js +33 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/types.js +6 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/untyped/index.js +125 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/untyped/types.js +0 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/utils.js +158 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/validate.js +68 -0
- package/bin/libs/sdk/sdk-impl/library-flow.js +169 -0
- package/bin/libs/sdk/sdk-impl/pub/pub-library.js +132 -0
- package/bin/libs/sdk/sdk-impl/pub/pub-regular.js +69 -0
- package/bin/libs/sdk/sdk-impl/regular-flow.js +219 -0
- package/bin/libs/sdk/sdk-impl/spells/spells-executors.js +307 -0
- package/bin/libs/sdk/sdk-impl/spells/spells-filesystem.js +72 -0
- package/bin/libs/sdk/sdk-impl/spells/spells-main.js +87 -0
- package/bin/libs/sdk/sdk-impl/spells/spells-parser.js +60 -0
- package/bin/libs/sdk/sdk-impl/spells/spells-types.js +0 -0
- package/bin/libs/sdk/sdk-impl/utils/tools/tools-agg.js +149 -0
- package/bin/libs/sdk/sdk-impl/utils/tools/tools-impl.js +21 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-build.js +102 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-bump.js +238 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-clean.js +35 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-consts.js +17 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-cwd.js +36 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-deps.js +73 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-determine.js +25 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-error.js +17 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-fs.js +202 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-info.js +42 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-jsr-json.js +51 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-paths.js +658 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-perf.js +22 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-pkg-json-libs.js +259 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-pkg-json-reg.js +207 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-tsconfig.js +44 -0
- package/bin/libs/sdk/sdk-main.js +114 -0
- package/bin/libs/sdk/sdk-types.js +1 -0
- package/bin/load.js +27 -0
- package/bin/main.js +46 -0
- package/bin/tools.txt +92 -0
- package/bin/types.js +0 -0
- package/package.json +93 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { relinka } from "@reliverse/relinka";
|
|
2
|
+
import { readPackageJSON } from "pkg-types";
|
|
3
|
+
import { glob } from "tinyglobby";
|
|
4
|
+
import { readFileSafe } from "./utils-fs.js";
|
|
5
|
+
import { extractPackageName } from "./utils-paths.js";
|
|
6
|
+
export async function filterDeps(deps, clearUnused, outDirBin, isJsr, rmDepsMode, rmDepsPatterns) {
|
|
7
|
+
relinka("verbose", `Filtering dependencies (clearUnused=${clearUnused})`);
|
|
8
|
+
if (!deps) return {};
|
|
9
|
+
const shouldExcludeByPattern = (depName) => {
|
|
10
|
+
return rmDepsPatterns.some(
|
|
11
|
+
(pattern) => depName.toLowerCase().includes(pattern.toLowerCase())
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
const originalPkg = await readPackageJSON();
|
|
15
|
+
const shouldExcludeDep = (depName, isDev) => {
|
|
16
|
+
if (rmDepsMode === "patterns-only") {
|
|
17
|
+
return shouldExcludeByPattern(depName);
|
|
18
|
+
}
|
|
19
|
+
if (rmDepsMode === "patterns-and-devdeps") {
|
|
20
|
+
return isDev || shouldExcludeByPattern(depName);
|
|
21
|
+
}
|
|
22
|
+
return shouldExcludeByPattern(depName);
|
|
23
|
+
};
|
|
24
|
+
const devDeps = deps === originalPkg.devDependencies;
|
|
25
|
+
if (!clearUnused) {
|
|
26
|
+
const filtered2 = Object.entries(deps).reduce(
|
|
27
|
+
(acc, [k, v]) => {
|
|
28
|
+
if (!shouldExcludeDep(k, devDeps)) {
|
|
29
|
+
acc[k] = v;
|
|
30
|
+
}
|
|
31
|
+
return acc;
|
|
32
|
+
},
|
|
33
|
+
{}
|
|
34
|
+
);
|
|
35
|
+
relinka(
|
|
36
|
+
"verbose",
|
|
37
|
+
`Filtered dependencies count: ${Object.keys(filtered2).length}`
|
|
38
|
+
);
|
|
39
|
+
return filtered2;
|
|
40
|
+
}
|
|
41
|
+
const files = await glob("**/*.{js,ts}", {
|
|
42
|
+
absolute: true,
|
|
43
|
+
cwd: outDirBin
|
|
44
|
+
});
|
|
45
|
+
const usedPackages = /* @__PURE__ */ new Set();
|
|
46
|
+
for (const file of files) {
|
|
47
|
+
const content = await readFileSafe(file, isJsr, "filterDeps");
|
|
48
|
+
const importMatches = content.matchAll(
|
|
49
|
+
/from\s+['"](\.|\.\/|\.\\)?src(\/|\\)/g
|
|
50
|
+
);
|
|
51
|
+
for (const match of importMatches) {
|
|
52
|
+
const importPath = match[1];
|
|
53
|
+
const pkg = extractPackageName(importPath);
|
|
54
|
+
if (pkg) {
|
|
55
|
+
usedPackages.add(pkg);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const filtered = Object.entries(deps).reduce(
|
|
60
|
+
(acc, [k, v]) => {
|
|
61
|
+
if (usedPackages.has(k) && !shouldExcludeDep(k, devDeps)) {
|
|
62
|
+
acc[k] = v;
|
|
63
|
+
}
|
|
64
|
+
return acc;
|
|
65
|
+
},
|
|
66
|
+
{}
|
|
67
|
+
);
|
|
68
|
+
relinka(
|
|
69
|
+
"verbose",
|
|
70
|
+
`Filtered dependencies count (after usage check): ${Object.keys(filtered).length}`
|
|
71
|
+
);
|
|
72
|
+
return filtered;
|
|
73
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function determineDistName(filePath, isJsr, libsList) {
|
|
2
|
+
if (isJsr === "") {
|
|
3
|
+
return "root";
|
|
4
|
+
}
|
|
5
|
+
const baseDistName = isJsr ? "dist-jsr" : "dist-npm";
|
|
6
|
+
const isLibraryPath = filePath.includes("/libs/") || filePath.includes("\\libs\\");
|
|
7
|
+
if (!isLibraryPath) {
|
|
8
|
+
return baseDistName;
|
|
9
|
+
}
|
|
10
|
+
const libPathRegex = /[/\\]libs[/\\]([^/\\]+)/;
|
|
11
|
+
const libPathResult = libPathRegex.exec(filePath);
|
|
12
|
+
const extractedLibName = libPathResult?.[1];
|
|
13
|
+
if (!extractedLibName) {
|
|
14
|
+
return baseDistName;
|
|
15
|
+
}
|
|
16
|
+
if (libsList) {
|
|
17
|
+
for (const [libName, libConfig] of Object.entries(libsList)) {
|
|
18
|
+
const simplifiedLibName = libName.startsWith("@") ? libName.split("/")[1] : libName;
|
|
19
|
+
if (simplifiedLibName === extractedLibName && libConfig.libDirName) {
|
|
20
|
+
return isJsr ? `dist-libs/${libConfig.libDirName}/jsr` : `dist-libs/${libConfig.libDirName}/npm`;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return isJsr ? `dist-libs/${extractedLibName}/jsr` : `dist-libs/${extractedLibName}/npm`;
|
|
25
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { relinka } from "@reliverse/relinka";
|
|
2
|
+
import prettyMilliseconds from "pretty-ms";
|
|
3
|
+
import { getElapsedPerfTime } from "./utils-perf.js";
|
|
4
|
+
export function handleDlerError(error, timer) {
|
|
5
|
+
const elapsedTime = getElapsedPerfTime(timer);
|
|
6
|
+
const transpileFormattedTime = prettyMilliseconds(elapsedTime, {
|
|
7
|
+
verbose: true
|
|
8
|
+
});
|
|
9
|
+
const errorStack = error instanceof Error ? error.stack : "No stack trace available";
|
|
10
|
+
relinka(
|
|
11
|
+
"error",
|
|
12
|
+
`An unexpected error occurred after ${transpileFormattedTime}:`,
|
|
13
|
+
error
|
|
14
|
+
);
|
|
15
|
+
relinka("verbose", `Error details: ${errorStack}`);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { relinka } from "@reliverse/relinka";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import pMap from "p-map";
|
|
4
|
+
import path from "pathe";
|
|
5
|
+
import { glob } from "tinyglobby";
|
|
6
|
+
import { CONCURRENCY_DEFAULT, SHOW_VERBOSE } from "./utils-consts.js";
|
|
7
|
+
import { determineDistName } from "./utils-determine.js";
|
|
8
|
+
export async function copyRootFile(outDirRoot, fileNames) {
|
|
9
|
+
if (fileNames.length === 0) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
await fs.ensureDir(outDirRoot);
|
|
14
|
+
const specialFileHandlers = {
|
|
15
|
+
LICENSE: {
|
|
16
|
+
outputName: "LICENSE",
|
|
17
|
+
variants: ["LICENSE", "LICENSE.md"]
|
|
18
|
+
},
|
|
19
|
+
"README.md": {}
|
|
20
|
+
};
|
|
21
|
+
await pMap(
|
|
22
|
+
fileNames,
|
|
23
|
+
async (fileName) => {
|
|
24
|
+
try {
|
|
25
|
+
const specialConfig = specialFileHandlers[fileName];
|
|
26
|
+
if (specialConfig?.variants) {
|
|
27
|
+
for (const variant of specialConfig.variants) {
|
|
28
|
+
const file = await findFileCaseInsensitive(variant);
|
|
29
|
+
if (file) {
|
|
30
|
+
const outputName = specialConfig.outputName || fileName;
|
|
31
|
+
await fs.copy(file, path.join(outDirRoot, outputName));
|
|
32
|
+
relinka(
|
|
33
|
+
"verbose",
|
|
34
|
+
`Copied ${file} to ${outDirRoot}/${outputName}`
|
|
35
|
+
);
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
const file = await findFileCaseInsensitive(fileName);
|
|
41
|
+
if (file) {
|
|
42
|
+
await fs.copy(file, path.join(outDirRoot, fileName));
|
|
43
|
+
relinka("verbose", `Copied ${file} to ${outDirRoot}/${fileName}`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
} catch (fileError) {
|
|
47
|
+
relinka("error", `Failed to copy ${fileName}: ${fileError}`);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
{ concurrency: CONCURRENCY_DEFAULT }
|
|
51
|
+
// Process up to CONCURRENCY_DEFAULT files simultaneously
|
|
52
|
+
);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
relinka("error", `Failed to copy files: ${error}`);
|
|
55
|
+
throw new Error(`File copying failed: ${error}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
export async function getDirectorySize(outDirRoot, isDev) {
|
|
59
|
+
if (SHOW_VERBOSE.getDirectorySize) {
|
|
60
|
+
relinka("verbose", `Calculating directory size for: ${outDirRoot}`);
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
const files = await fs.readdir(outDirRoot);
|
|
64
|
+
const sizes = await pMap(
|
|
65
|
+
files,
|
|
66
|
+
async (file) => {
|
|
67
|
+
const fp = path.join(outDirRoot, file);
|
|
68
|
+
const stats = await fs.stat(fp);
|
|
69
|
+
return stats.isDirectory() ? getDirectorySize(fp, isDev) : stats.size;
|
|
70
|
+
},
|
|
71
|
+
{ concurrency: CONCURRENCY_DEFAULT }
|
|
72
|
+
);
|
|
73
|
+
const totalSize = sizes.reduce((total, s) => total + s, 0);
|
|
74
|
+
if (SHOW_VERBOSE.getDirectorySize) {
|
|
75
|
+
relinka(
|
|
76
|
+
"verbose",
|
|
77
|
+
`Calculated directory size: ${totalSize} bytes for ${outDirRoot}`
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
return totalSize;
|
|
81
|
+
} catch (error) {
|
|
82
|
+
relinka(
|
|
83
|
+
"error",
|
|
84
|
+
`Failed to calculate directory size for ${outDirRoot}`,
|
|
85
|
+
error
|
|
86
|
+
);
|
|
87
|
+
return 0;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export async function outDirBinFilesCount(outDirBin) {
|
|
91
|
+
relinka("verbose", `Counting files in directory: ${outDirBin}`);
|
|
92
|
+
let fileCount = 0;
|
|
93
|
+
if (!await fs.pathExists(outDirBin)) {
|
|
94
|
+
relinka(
|
|
95
|
+
"error",
|
|
96
|
+
`[outDirBinFilesCount] Directory does not exist: ${outDirBin}`
|
|
97
|
+
);
|
|
98
|
+
return fileCount;
|
|
99
|
+
}
|
|
100
|
+
async function traverse(dir) {
|
|
101
|
+
const entries = await fs.readdir(dir);
|
|
102
|
+
for (const entry of entries) {
|
|
103
|
+
const fullPath = path.join(dir, entry);
|
|
104
|
+
const stats = await fs.stat(fullPath);
|
|
105
|
+
if (stats.isDirectory()) {
|
|
106
|
+
await traverse(fullPath);
|
|
107
|
+
} else if (stats.isFile()) {
|
|
108
|
+
fileCount++;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
await traverse(outDirBin);
|
|
113
|
+
relinka("verbose", `Total file count in ${outDirBin}: ${fileCount}`);
|
|
114
|
+
return fileCount;
|
|
115
|
+
}
|
|
116
|
+
async function findFileCaseInsensitive(transpileTargetFile) {
|
|
117
|
+
const files = await fs.readdir(".");
|
|
118
|
+
const found = files.find(
|
|
119
|
+
(file) => file.toLowerCase() === transpileTargetFile.toLowerCase()
|
|
120
|
+
);
|
|
121
|
+
return found || null;
|
|
122
|
+
}
|
|
123
|
+
const TEST_FILE_PATTERNS = [
|
|
124
|
+
"**/*.test.js",
|
|
125
|
+
"**/*.test.ts",
|
|
126
|
+
"**/*.test.d.ts",
|
|
127
|
+
"**/*-temp.js",
|
|
128
|
+
"**/*-temp.ts",
|
|
129
|
+
"**/*-temp.d.ts",
|
|
130
|
+
"**/__snapshots__/**"
|
|
131
|
+
];
|
|
132
|
+
export async function deleteSpecificFiles(outDirBin) {
|
|
133
|
+
relinka("verbose", `Deleting test and temporary files in: ${outDirBin}`);
|
|
134
|
+
const files = await glob(TEST_FILE_PATTERNS, {
|
|
135
|
+
absolute: true,
|
|
136
|
+
cwd: outDirBin
|
|
137
|
+
});
|
|
138
|
+
const snapshotDirs = await glob("**/__snapshots__", {
|
|
139
|
+
absolute: true,
|
|
140
|
+
cwd: outDirBin,
|
|
141
|
+
onlyDirectories: true
|
|
142
|
+
});
|
|
143
|
+
const filesToDelete = files.filter((file) => {
|
|
144
|
+
if (file.endsWith(".d.ts")) {
|
|
145
|
+
return file.includes(".test.d.ts") || file.includes("-temp.d.ts");
|
|
146
|
+
}
|
|
147
|
+
return true;
|
|
148
|
+
});
|
|
149
|
+
if (filesToDelete.length > 0) {
|
|
150
|
+
await pMap(filesToDelete, async (file) => fs.remove(file), {
|
|
151
|
+
concurrency: CONCURRENCY_DEFAULT
|
|
152
|
+
});
|
|
153
|
+
relinka("verbose", `Deleted files:
|
|
154
|
+
${filesToDelete.join("\n")}`);
|
|
155
|
+
}
|
|
156
|
+
if (snapshotDirs.length > 0) {
|
|
157
|
+
await pMap(snapshotDirs, async (dir) => fs.remove(dir), {
|
|
158
|
+
concurrency: CONCURRENCY_DEFAULT
|
|
159
|
+
});
|
|
160
|
+
relinka(
|
|
161
|
+
"info",
|
|
162
|
+
`Deleted snapshot directories:
|
|
163
|
+
${snapshotDirs.join("\n")}`
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
export async function readFileSafe(filePath, isJsr, reason) {
|
|
168
|
+
const distName = determineDistName(filePath, isJsr, void 0);
|
|
169
|
+
try {
|
|
170
|
+
const content = await fs.readFile(filePath, "utf8");
|
|
171
|
+
if (SHOW_VERBOSE.readFileSafe) {
|
|
172
|
+
relinka(
|
|
173
|
+
"verbose",
|
|
174
|
+
`[${distName}] Successfully read file: ${filePath} [Reason: ${reason}]`
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
return content;
|
|
178
|
+
} catch (error) {
|
|
179
|
+
relinka(
|
|
180
|
+
"error",
|
|
181
|
+
`[${distName}] Failed to read file: ${filePath} [Reason: ${reason}]`,
|
|
182
|
+
error
|
|
183
|
+
);
|
|
184
|
+
throw error;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
export async function writeFileSafe(filePath, content, reason) {
|
|
188
|
+
try {
|
|
189
|
+
await fs.writeFile(filePath, content, "utf8");
|
|
190
|
+
relinka(
|
|
191
|
+
"verbose",
|
|
192
|
+
`Successfully wrote file: ${filePath} [Reason: ${reason}]`
|
|
193
|
+
);
|
|
194
|
+
} catch (error) {
|
|
195
|
+
relinka(
|
|
196
|
+
"error",
|
|
197
|
+
`Failed to write file: ${filePath} [Reason: ${reason}]`,
|
|
198
|
+
error
|
|
199
|
+
);
|
|
200
|
+
throw error;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { relinka } from "@reliverse/relinka";
|
|
2
|
+
import prettyMilliseconds from "pretty-ms";
|
|
3
|
+
import { setBumpDisabled } from "./utils-bump.js";
|
|
4
|
+
import { removeDistFolders } from "./utils-clean.js";
|
|
5
|
+
import { getElapsedPerfTime } from "./utils-perf.js";
|
|
6
|
+
export async function finalizeBuild(timer, commonPubPause, libsList, distNpmDirName, distJsrDirName, libsDirDist, isDev) {
|
|
7
|
+
if (!commonPubPause) {
|
|
8
|
+
await removeDistFolders(
|
|
9
|
+
distNpmDirName,
|
|
10
|
+
distJsrDirName,
|
|
11
|
+
libsDirDist,
|
|
12
|
+
libsList
|
|
13
|
+
);
|
|
14
|
+
await setBumpDisabled(false, commonPubPause);
|
|
15
|
+
}
|
|
16
|
+
const elapsedTime = getElapsedPerfTime(timer);
|
|
17
|
+
const transpileFormattedTime = prettyMilliseconds(elapsedTime, {
|
|
18
|
+
verbose: true
|
|
19
|
+
});
|
|
20
|
+
if (!commonPubPause) {
|
|
21
|
+
relinka(
|
|
22
|
+
"success",
|
|
23
|
+
`\u{1F389} Build and publishing completed successfully (in ${transpileFormattedTime})`
|
|
24
|
+
);
|
|
25
|
+
} else {
|
|
26
|
+
relinka(
|
|
27
|
+
"success",
|
|
28
|
+
`\u{1F389} Test build completed successfully (in ${transpileFormattedTime})`
|
|
29
|
+
);
|
|
30
|
+
if (!isDev) {
|
|
31
|
+
relinka(
|
|
32
|
+
"info",
|
|
33
|
+
"\u{1F4DD} Publish process is currently paused in your config file"
|
|
34
|
+
);
|
|
35
|
+
} else {
|
|
36
|
+
relinka(
|
|
37
|
+
"info",
|
|
38
|
+
"\u{1F4DD} Publish is paused, you're in dev mode (use `bun pub` to publish)"
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { relinka } from "@reliverse/relinka";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import pMap from "p-map";
|
|
4
|
+
import path from "pathe";
|
|
5
|
+
import { readPackageJSON } from "pkg-types";
|
|
6
|
+
import { glob } from "tinyglobby";
|
|
7
|
+
import { cliDomainDocs, CONCURRENCY_DEFAULT } from "./utils-consts.js";
|
|
8
|
+
export async function createJsrJSON(outDirRoot, isLib, libName = "unknown-lib-name", libDescription = "unknown-lib-description") {
|
|
9
|
+
relinka("verbose", `Creating jsr.json configuration (isLib: ${isLib})`);
|
|
10
|
+
const originalPkg = await readPackageJSON();
|
|
11
|
+
let { description, name } = originalPkg;
|
|
12
|
+
const { author, license, version } = originalPkg;
|
|
13
|
+
if (isLib) {
|
|
14
|
+
name = libName;
|
|
15
|
+
description = libDescription;
|
|
16
|
+
}
|
|
17
|
+
const pkgHomepage = cliDomainDocs;
|
|
18
|
+
const jsrConfig = {
|
|
19
|
+
author,
|
|
20
|
+
description,
|
|
21
|
+
exports: "./bin/main.ts",
|
|
22
|
+
homepage: pkgHomepage,
|
|
23
|
+
license: license || "MIT",
|
|
24
|
+
name,
|
|
25
|
+
publish: {
|
|
26
|
+
exclude: ["!.", "node_modules/**", ".env"]
|
|
27
|
+
},
|
|
28
|
+
version
|
|
29
|
+
};
|
|
30
|
+
await fs.writeJSON(path.join(outDirRoot, "jsr.json"), jsrConfig, {
|
|
31
|
+
spaces: 2
|
|
32
|
+
});
|
|
33
|
+
relinka("verbose", `Generated jsr.json file in ${outDirRoot}/jsr.json`);
|
|
34
|
+
}
|
|
35
|
+
export async function renameTsxFiles(dir) {
|
|
36
|
+
relinka("verbose", `Renaming .tsx files in directory: ${dir}`);
|
|
37
|
+
const files = await glob(["**/*.tsx"], {
|
|
38
|
+
absolute: true,
|
|
39
|
+
cwd: dir
|
|
40
|
+
});
|
|
41
|
+
await pMap(
|
|
42
|
+
files,
|
|
43
|
+
async (filePath) => {
|
|
44
|
+
const newPath = filePath.replace(/\.tsx$/, "-tsx.txt");
|
|
45
|
+
await fs.rename(filePath, newPath);
|
|
46
|
+
relinka("verbose", `Renamed: ${filePath} -> ${newPath}`);
|
|
47
|
+
},
|
|
48
|
+
{ concurrency: CONCURRENCY_DEFAULT }
|
|
49
|
+
);
|
|
50
|
+
relinka("verbose", `Completed renaming .tsx files in ${dir}`);
|
|
51
|
+
}
|