@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,259 @@
|
|
|
1
|
+
import { relinka } from "@reliverse/relinka";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import path from "pathe";
|
|
4
|
+
import {
|
|
5
|
+
definePackageJSON,
|
|
6
|
+
readPackageJSON
|
|
7
|
+
} from "pkg-types";
|
|
8
|
+
import { filterDeps } from "./utils-deps.js";
|
|
9
|
+
export async function library_createPackageJSON(libName, outDirRoot, isJsr, libsList, rmDepsMode, rmDepsPatterns, unifiedBundlerOutExt) {
|
|
10
|
+
relinka(
|
|
11
|
+
"verbose",
|
|
12
|
+
`Generating package.json for lib ${libName} (isJsr=${isJsr})...`
|
|
13
|
+
);
|
|
14
|
+
if (!libsList) {
|
|
15
|
+
throw new Error("libsList is empty or not provided");
|
|
16
|
+
}
|
|
17
|
+
const originalPkg = await readPackageJSON();
|
|
18
|
+
let { description } = originalPkg;
|
|
19
|
+
const { author, keywords, license, version } = originalPkg;
|
|
20
|
+
if (libsList?.[libName]?.libDescription) {
|
|
21
|
+
description = libsList[libName].libDescription;
|
|
22
|
+
relinka(
|
|
23
|
+
"verbose",
|
|
24
|
+
`Using ${libName}'s description from config: "${description}"`
|
|
25
|
+
);
|
|
26
|
+
} else {
|
|
27
|
+
description = description || `${libName} is a helper library.`;
|
|
28
|
+
relinka(
|
|
29
|
+
"verbose",
|
|
30
|
+
`Using default helper library description: "${description}"`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
const commonPkg = {
|
|
34
|
+
description,
|
|
35
|
+
license: license || "MIT",
|
|
36
|
+
name: libName,
|
|
37
|
+
type: "module",
|
|
38
|
+
version
|
|
39
|
+
};
|
|
40
|
+
if (author) {
|
|
41
|
+
const repoOwner = typeof author === "string" ? author : author.name;
|
|
42
|
+
const repoName = originalPkg.name ? originalPkg.name.startsWith("@") ? originalPkg.name.split("/").pop() || originalPkg.name : originalPkg.name : "";
|
|
43
|
+
Object.assign(commonPkg, {
|
|
44
|
+
author,
|
|
45
|
+
bugs: {
|
|
46
|
+
email: "blefnk@gmail.com",
|
|
47
|
+
url: `https://github.com/${repoOwner}/${repoName}/issues`
|
|
48
|
+
},
|
|
49
|
+
keywords: [.../* @__PURE__ */ new Set([author, ...keywords || []])],
|
|
50
|
+
repository: {
|
|
51
|
+
type: "git",
|
|
52
|
+
url: `git+https://github.com/${repoOwner}/${repoName}.git`
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
} else if (keywords && keywords.length > 0 && !commonPkg.keywords) {
|
|
56
|
+
commonPkg.keywords = keywords;
|
|
57
|
+
}
|
|
58
|
+
const outDirBin = path.join(outDirRoot, "bin");
|
|
59
|
+
if (isJsr) {
|
|
60
|
+
relinka("verbose", `Creating JSR package.json for lib ${libName}...`);
|
|
61
|
+
await library_writeJsrPackageJSON(
|
|
62
|
+
libName,
|
|
63
|
+
outDirBin,
|
|
64
|
+
outDirRoot,
|
|
65
|
+
originalPkg,
|
|
66
|
+
commonPkg,
|
|
67
|
+
libsList,
|
|
68
|
+
rmDepsMode,
|
|
69
|
+
rmDepsPatterns
|
|
70
|
+
);
|
|
71
|
+
} else {
|
|
72
|
+
relinka("verbose", `Creating NPM package.json for lib ${libName}...`);
|
|
73
|
+
await library_writeNpmLibPackageJSON(
|
|
74
|
+
libName,
|
|
75
|
+
outDirBin,
|
|
76
|
+
outDirRoot,
|
|
77
|
+
originalPkg,
|
|
78
|
+
commonPkg,
|
|
79
|
+
libsList,
|
|
80
|
+
rmDepsMode,
|
|
81
|
+
rmDepsPatterns,
|
|
82
|
+
unifiedBundlerOutExt
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
relinka("verbose", `Completed creation of package.json for lib: ${libName}`);
|
|
86
|
+
}
|
|
87
|
+
async function library_getlibPkgKeepDeps(libName, originalDeps, outDirBin, isJsr, libConfig, rmDepsMode, rmDepsPatterns) {
|
|
88
|
+
relinka("verbose", `Getting lib dependencies for: ${libName}`);
|
|
89
|
+
if (!originalDeps) return {};
|
|
90
|
+
if (!libConfig) {
|
|
91
|
+
const result2 = await filterDeps(
|
|
92
|
+
originalDeps,
|
|
93
|
+
true,
|
|
94
|
+
outDirBin,
|
|
95
|
+
isJsr,
|
|
96
|
+
rmDepsMode,
|
|
97
|
+
rmDepsPatterns
|
|
98
|
+
);
|
|
99
|
+
relinka(
|
|
100
|
+
"verbose",
|
|
101
|
+
`Lib ${libName} dependencies filtered by usage, count: ${Object.keys(result2).length}`
|
|
102
|
+
);
|
|
103
|
+
return result2;
|
|
104
|
+
}
|
|
105
|
+
if (libConfig.libPkgKeepDeps === true) {
|
|
106
|
+
relinka("info", `Preserving all dependencies for lib ${libName}`);
|
|
107
|
+
const originalPkg = await readPackageJSON();
|
|
108
|
+
const devDeps = originalDeps === originalPkg.devDependencies;
|
|
109
|
+
const result2 = Object.entries(originalDeps).reduce(
|
|
110
|
+
(acc, [k, v]) => {
|
|
111
|
+
let shouldExclude = false;
|
|
112
|
+
if (rmDepsMode === "patterns-only") {
|
|
113
|
+
shouldExclude = rmDepsPatterns.some(
|
|
114
|
+
(pattern) => k.toLowerCase().includes(pattern.toLowerCase())
|
|
115
|
+
);
|
|
116
|
+
} else if (rmDepsMode === "patterns-and-devdeps") {
|
|
117
|
+
shouldExclude = devDeps || rmDepsPatterns.some(
|
|
118
|
+
(pattern) => k.toLowerCase().includes(pattern.toLowerCase())
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
if (!shouldExclude) {
|
|
122
|
+
acc[k] = v;
|
|
123
|
+
}
|
|
124
|
+
return acc;
|
|
125
|
+
},
|
|
126
|
+
{}
|
|
127
|
+
);
|
|
128
|
+
return result2;
|
|
129
|
+
}
|
|
130
|
+
if (Array.isArray(libConfig.libPkgKeepDeps)) {
|
|
131
|
+
relinka(
|
|
132
|
+
"info",
|
|
133
|
+
`Including specific dependencies for lib ${libName}: ${libConfig.libPkgKeepDeps.join(", ")}`
|
|
134
|
+
);
|
|
135
|
+
const result2 = Object.entries(originalDeps).reduce(
|
|
136
|
+
(acc, [k, v]) => {
|
|
137
|
+
if (Array.isArray(libConfig.libPkgKeepDeps) && libConfig.libPkgKeepDeps.includes(k)) {
|
|
138
|
+
acc[k] = v;
|
|
139
|
+
}
|
|
140
|
+
return acc;
|
|
141
|
+
},
|
|
142
|
+
{}
|
|
143
|
+
);
|
|
144
|
+
return result2;
|
|
145
|
+
}
|
|
146
|
+
const result = await filterDeps(
|
|
147
|
+
originalDeps,
|
|
148
|
+
true,
|
|
149
|
+
outDirBin,
|
|
150
|
+
isJsr,
|
|
151
|
+
rmDepsMode,
|
|
152
|
+
rmDepsPatterns
|
|
153
|
+
);
|
|
154
|
+
relinka(
|
|
155
|
+
"verbose",
|
|
156
|
+
`Default filtering for lib ${libName} done, count: ${Object.keys(result).length}`
|
|
157
|
+
);
|
|
158
|
+
return result;
|
|
159
|
+
}
|
|
160
|
+
async function library_writeJsrPackageJSON(libName, outDirBin, outDirRoot, originalPkg, commonPkg, libsList, rmDepsMode, rmDepsPatterns) {
|
|
161
|
+
relinka("verbose", `Writing package.json for JSR lib: ${libName}`);
|
|
162
|
+
if (!libsList) {
|
|
163
|
+
throw new Error("libsList is empty or not provided");
|
|
164
|
+
}
|
|
165
|
+
const binEntry = commonPkg.bin;
|
|
166
|
+
if (binEntry) {
|
|
167
|
+
relinka(
|
|
168
|
+
"verbose",
|
|
169
|
+
`Found bin entry in commonPkg: ${JSON.stringify(binEntry)}`
|
|
170
|
+
);
|
|
171
|
+
const updatedBin = {};
|
|
172
|
+
for (const [key, value] of Object.entries(binEntry)) {
|
|
173
|
+
updatedBin[key] = value.replace(/\.js$/, ".ts");
|
|
174
|
+
}
|
|
175
|
+
commonPkg.bin = updatedBin;
|
|
176
|
+
relinka(
|
|
177
|
+
"verbose",
|
|
178
|
+
`Updated bin entry for JSR: ${JSON.stringify(updatedBin)}`
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
const jsrPkg = definePackageJSON({
|
|
182
|
+
...commonPkg,
|
|
183
|
+
dependencies: await library_getlibPkgKeepDeps(
|
|
184
|
+
libName,
|
|
185
|
+
originalPkg.dependencies,
|
|
186
|
+
outDirBin,
|
|
187
|
+
true,
|
|
188
|
+
libsList?.[libName] ?? {
|
|
189
|
+
libDeclarations: false,
|
|
190
|
+
libDescription: "",
|
|
191
|
+
libDirName: libName,
|
|
192
|
+
libMainFile: "src/libs/libName/libName-main.ts",
|
|
193
|
+
libPkgKeepDeps: false,
|
|
194
|
+
libTranspileMinify: true
|
|
195
|
+
},
|
|
196
|
+
rmDepsMode,
|
|
197
|
+
rmDepsPatterns
|
|
198
|
+
),
|
|
199
|
+
devDependencies: await filterDeps(
|
|
200
|
+
originalPkg.devDependencies,
|
|
201
|
+
true,
|
|
202
|
+
outDirBin,
|
|
203
|
+
true,
|
|
204
|
+
rmDepsMode,
|
|
205
|
+
rmDepsPatterns
|
|
206
|
+
),
|
|
207
|
+
exports: {
|
|
208
|
+
".": "./bin/main.ts"
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
await fs.writeJSON(path.join(outDirRoot, "package.json"), jsrPkg, {
|
|
212
|
+
spaces: 2
|
|
213
|
+
});
|
|
214
|
+
relinka("verbose", `Completed writing package.json for JSR lib: ${libName}`);
|
|
215
|
+
}
|
|
216
|
+
async function library_writeNpmLibPackageJSON(libName, outDirBin, outDirRoot, originalPkg, commonPkg, libsList, rmDepsMode, rmDepsPatterns, unifiedBundlerOutExt) {
|
|
217
|
+
relinka("verbose", `Writing package.json for NPM lib: ${libName}`);
|
|
218
|
+
if (!libsList) {
|
|
219
|
+
throw new Error("libsList is empty or not provided");
|
|
220
|
+
}
|
|
221
|
+
const npmPkg = definePackageJSON({
|
|
222
|
+
...commonPkg,
|
|
223
|
+
dependencies: await library_getlibPkgKeepDeps(
|
|
224
|
+
libName,
|
|
225
|
+
originalPkg.dependencies,
|
|
226
|
+
outDirBin,
|
|
227
|
+
false,
|
|
228
|
+
libsList?.[libName] ?? {
|
|
229
|
+
libDeclarations: true,
|
|
230
|
+
libDescription: "",
|
|
231
|
+
libDirName: libName,
|
|
232
|
+
libMainFile: "src/libs/libName/libName-main.ts",
|
|
233
|
+
libPkgKeepDeps: true,
|
|
234
|
+
libTranspileMinify: true
|
|
235
|
+
},
|
|
236
|
+
rmDepsMode,
|
|
237
|
+
rmDepsPatterns
|
|
238
|
+
),
|
|
239
|
+
devDependencies: await filterDeps(
|
|
240
|
+
originalPkg.devDependencies,
|
|
241
|
+
true,
|
|
242
|
+
outDirBin,
|
|
243
|
+
false,
|
|
244
|
+
rmDepsMode,
|
|
245
|
+
rmDepsPatterns
|
|
246
|
+
),
|
|
247
|
+
exports: {
|
|
248
|
+
".": `./bin/main.${unifiedBundlerOutExt}`
|
|
249
|
+
},
|
|
250
|
+
files: ["bin", "package.json", "README.md", "LICENSE"],
|
|
251
|
+
main: `./bin/main.${unifiedBundlerOutExt}`,
|
|
252
|
+
module: `./bin/main.${unifiedBundlerOutExt}`,
|
|
253
|
+
publishConfig: { access: "public" }
|
|
254
|
+
});
|
|
255
|
+
await fs.writeJSON(path.join(outDirRoot, "package.json"), npmPkg, {
|
|
256
|
+
spaces: 2
|
|
257
|
+
});
|
|
258
|
+
relinka("verbose", `Completed writing package.json for NPM lib: ${libName}`);
|
|
259
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { relinka } from "@reliverse/relinka";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import path from "pathe";
|
|
4
|
+
import {
|
|
5
|
+
definePackageJSON,
|
|
6
|
+
readPackageJSON
|
|
7
|
+
} from "pkg-types";
|
|
8
|
+
import { cliDomainDocs } from "./utils-consts.js";
|
|
9
|
+
export async function regular_createPackageJSON(outDirRoot, isJsr, coreIsCLI, unifiedBundlerOutExt, rmDepsMode, rmDepsPatterns) {
|
|
10
|
+
relinka(
|
|
11
|
+
"info",
|
|
12
|
+
`Generating distribution package.json and tsconfig.json (isJsr=${isJsr})...`
|
|
13
|
+
);
|
|
14
|
+
const commonPkg = await regular_createCommonPackageFields(coreIsCLI);
|
|
15
|
+
const originalPkg = await readPackageJSON();
|
|
16
|
+
const packageName = originalPkg.name || "";
|
|
17
|
+
const cliCommandName = packageName.startsWith("@") ? packageName.split("/").pop() || "cli" : packageName;
|
|
18
|
+
relinka(
|
|
19
|
+
"verbose",
|
|
20
|
+
`Package name: "${packageName}", CLI command name: "${cliCommandName}", coreIsCLI: ${coreIsCLI}`
|
|
21
|
+
);
|
|
22
|
+
const outDirBin = path.join(outDirRoot, "bin");
|
|
23
|
+
const outExt = unifiedBundlerOutExt || "js";
|
|
24
|
+
if (isJsr) {
|
|
25
|
+
const binEntry = coreIsCLI ? { [cliCommandName]: "bin/main.ts" } : void 0;
|
|
26
|
+
if (coreIsCLI) {
|
|
27
|
+
relinka(
|
|
28
|
+
"verbose",
|
|
29
|
+
`Adding CLI bin entry for JSR: { "${cliCommandName}": "bin/main.ts" }`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
const jsrPkg = definePackageJSON({
|
|
33
|
+
...commonPkg,
|
|
34
|
+
bin: binEntry,
|
|
35
|
+
dependencies: await regular_getPkgKeepDeps(
|
|
36
|
+
originalPkg.dependencies,
|
|
37
|
+
outDirBin,
|
|
38
|
+
isJsr,
|
|
39
|
+
rmDepsMode,
|
|
40
|
+
rmDepsPatterns
|
|
41
|
+
),
|
|
42
|
+
devDependencies: await regular_getPkgKeepDeps(
|
|
43
|
+
originalPkg.devDependencies,
|
|
44
|
+
outDirBin,
|
|
45
|
+
isJsr,
|
|
46
|
+
rmDepsMode,
|
|
47
|
+
rmDepsPatterns
|
|
48
|
+
),
|
|
49
|
+
exports: {
|
|
50
|
+
".": "./bin/main.ts"
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
await fs.writeJSON(path.join(outDirRoot, "package.json"), jsrPkg, {
|
|
54
|
+
spaces: 2
|
|
55
|
+
});
|
|
56
|
+
if (coreIsCLI) {
|
|
57
|
+
relinka(
|
|
58
|
+
"verbose",
|
|
59
|
+
`JSR package.json created with CLI bin entry: ${JSON.stringify(jsrPkg.bin)}`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
const binEntry = coreIsCLI ? { [cliCommandName]: `bin/main.${outExt}` } : void 0;
|
|
64
|
+
if (coreIsCLI) {
|
|
65
|
+
relinka(
|
|
66
|
+
"verbose",
|
|
67
|
+
`Adding CLI bin entry for NPM: { "${cliCommandName}": "bin/main.${outExt}" }`
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
const npmPkg = definePackageJSON({
|
|
71
|
+
...commonPkg,
|
|
72
|
+
bin: binEntry,
|
|
73
|
+
dependencies: await regular_getPkgKeepDeps(
|
|
74
|
+
originalPkg.dependencies,
|
|
75
|
+
outDirBin,
|
|
76
|
+
isJsr,
|
|
77
|
+
rmDepsMode,
|
|
78
|
+
rmDepsPatterns
|
|
79
|
+
),
|
|
80
|
+
devDependencies: await regular_getPkgKeepDeps(
|
|
81
|
+
originalPkg.devDependencies,
|
|
82
|
+
outDirBin,
|
|
83
|
+
isJsr,
|
|
84
|
+
rmDepsMode,
|
|
85
|
+
rmDepsPatterns
|
|
86
|
+
),
|
|
87
|
+
exports: {
|
|
88
|
+
".": `./bin/main.${outExt}`
|
|
89
|
+
},
|
|
90
|
+
files: ["bin", "package.json", "README.md", "LICENSE"],
|
|
91
|
+
main: `./bin/main.${outExt}`,
|
|
92
|
+
module: `./bin/main.${outExt}`,
|
|
93
|
+
publishConfig: { access: "public" }
|
|
94
|
+
});
|
|
95
|
+
await fs.writeJSON(path.join(outDirRoot, "package.json"), npmPkg, {
|
|
96
|
+
spaces: 2
|
|
97
|
+
});
|
|
98
|
+
if (coreIsCLI) {
|
|
99
|
+
relinka(
|
|
100
|
+
"verbose",
|
|
101
|
+
`NPM package.json created with CLI bin entry: ${JSON.stringify(npmPkg.bin)}`
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
relinka("verbose", `Created package.json in ${outDirRoot}`);
|
|
106
|
+
}
|
|
107
|
+
async function regular_createCommonPackageFields(coreIsCLI) {
|
|
108
|
+
relinka("verbose", "Generating common package fields");
|
|
109
|
+
const originalPkg = await readPackageJSON();
|
|
110
|
+
const { author, description, keywords, license, name, version } = originalPkg;
|
|
111
|
+
relinka("verbose", `Original package name: "${name}", version: "${version}"`);
|
|
112
|
+
const pkgHomepage = cliDomainDocs;
|
|
113
|
+
const commonPkg = {
|
|
114
|
+
dependencies: originalPkg.dependencies || {},
|
|
115
|
+
description,
|
|
116
|
+
homepage: pkgHomepage,
|
|
117
|
+
license: license || "MIT",
|
|
118
|
+
name,
|
|
119
|
+
type: "module",
|
|
120
|
+
version
|
|
121
|
+
};
|
|
122
|
+
if (coreIsCLI) {
|
|
123
|
+
relinka(
|
|
124
|
+
"verbose",
|
|
125
|
+
"coreIsCLI is true, adding CLI-specific fields to common package fields"
|
|
126
|
+
);
|
|
127
|
+
if (commonPkg.keywords) {
|
|
128
|
+
const cliCommandName = name?.startsWith("@") ? name.split("/").pop() || "cli" : name || "dler";
|
|
129
|
+
relinka(
|
|
130
|
+
"verbose",
|
|
131
|
+
`Adding CLI keywords to existing keywords, CLI command name: "${cliCommandName}"`
|
|
132
|
+
);
|
|
133
|
+
commonPkg.keywords = [
|
|
134
|
+
.../* @__PURE__ */ new Set([
|
|
135
|
+
"cli",
|
|
136
|
+
cliCommandName,
|
|
137
|
+
"command-line",
|
|
138
|
+
...commonPkg.keywords
|
|
139
|
+
])
|
|
140
|
+
];
|
|
141
|
+
relinka(
|
|
142
|
+
"verbose",
|
|
143
|
+
`Updated keywords: ${JSON.stringify(commonPkg.keywords)}`
|
|
144
|
+
);
|
|
145
|
+
} else if (name) {
|
|
146
|
+
const cliCommandName = name.startsWith("@") ? name.split("/").pop() || "cli" : name;
|
|
147
|
+
relinka(
|
|
148
|
+
"verbose",
|
|
149
|
+
`Setting new CLI keywords, CLI command name: "${cliCommandName}"`
|
|
150
|
+
);
|
|
151
|
+
commonPkg.keywords = ["cli", "command-line", cliCommandName];
|
|
152
|
+
relinka("verbose", `Set keywords: ${JSON.stringify(commonPkg.keywords)}`);
|
|
153
|
+
}
|
|
154
|
+
} else {
|
|
155
|
+
relinka("verbose", "coreIsCLI is false, skipping CLI-specific fields");
|
|
156
|
+
}
|
|
157
|
+
if (author) {
|
|
158
|
+
const repoOwner = typeof author === "string" ? author : author.name;
|
|
159
|
+
const repoName = name ? name.startsWith("@") ? name.split("/").pop() || name : name : "";
|
|
160
|
+
Object.assign(commonPkg, {
|
|
161
|
+
author,
|
|
162
|
+
bugs: {
|
|
163
|
+
email: "blefnk@gmail.com",
|
|
164
|
+
url: `https://github.com/${repoOwner}/${repoName}/issues`
|
|
165
|
+
},
|
|
166
|
+
keywords: [.../* @__PURE__ */ new Set([repoOwner, ...commonPkg.keywords || []])],
|
|
167
|
+
repository: {
|
|
168
|
+
type: "git",
|
|
169
|
+
url: `git+https://github.com/${repoOwner}/${repoName}.git`
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
} else if (keywords && keywords.length > 0 && !commonPkg.keywords) {
|
|
173
|
+
commonPkg.keywords = keywords;
|
|
174
|
+
}
|
|
175
|
+
relinka("verbose", "Common package fields generated");
|
|
176
|
+
return commonPkg;
|
|
177
|
+
}
|
|
178
|
+
async function regular_getPkgKeepDeps(originalDeps, outDirBin, isJsr, rmDepsMode, rmDepsPatterns) {
|
|
179
|
+
relinka("verbose", "Getting main package dependencies");
|
|
180
|
+
if (!originalDeps) return {};
|
|
181
|
+
const originalPkg = await readPackageJSON();
|
|
182
|
+
const devDeps = originalDeps === originalPkg.devDependencies;
|
|
183
|
+
const result = Object.entries(originalDeps).reduce(
|
|
184
|
+
(acc, [k, v]) => {
|
|
185
|
+
let shouldExclude = false;
|
|
186
|
+
if (rmDepsMode === "patterns-only") {
|
|
187
|
+
shouldExclude = rmDepsPatterns.some(
|
|
188
|
+
(pattern) => k.toLowerCase().includes(pattern.toLowerCase())
|
|
189
|
+
);
|
|
190
|
+
} else if (rmDepsMode === "patterns-and-devdeps") {
|
|
191
|
+
shouldExclude = devDeps || rmDepsPatterns.some(
|
|
192
|
+
(pattern) => k.toLowerCase().includes(pattern.toLowerCase())
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
if (!shouldExclude) {
|
|
196
|
+
acc[k] = v;
|
|
197
|
+
}
|
|
198
|
+
return acc;
|
|
199
|
+
},
|
|
200
|
+
{}
|
|
201
|
+
);
|
|
202
|
+
relinka(
|
|
203
|
+
"verbose",
|
|
204
|
+
`Main package dependencies filtered, count: ${Object.keys(result).length}`
|
|
205
|
+
);
|
|
206
|
+
return result;
|
|
207
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { relinka } from "@reliverse/relinka";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import path from "pathe";
|
|
4
|
+
import { defineTSConfig } from "pkg-types";
|
|
5
|
+
import { tsconfigJson } from "./utils-consts.js";
|
|
6
|
+
export async function createTSConfig(outDirRoot, allowImportingTsExtensions) {
|
|
7
|
+
relinka(
|
|
8
|
+
"verbose",
|
|
9
|
+
`Creating tsconfig.json in ${outDirRoot} (allowImportingTsExtensions=${allowImportingTsExtensions})`
|
|
10
|
+
);
|
|
11
|
+
const tsConfig = defineTSConfig({
|
|
12
|
+
compilerOptions: {
|
|
13
|
+
allowImportingTsExtensions,
|
|
14
|
+
allowJs: true,
|
|
15
|
+
esModuleInterop: true,
|
|
16
|
+
exactOptionalPropertyTypes: false,
|
|
17
|
+
isolatedModules: true,
|
|
18
|
+
lib: ["ESNext"],
|
|
19
|
+
module: "NodeNext",
|
|
20
|
+
moduleDetection: "force",
|
|
21
|
+
moduleResolution: "nodenext",
|
|
22
|
+
noEmit: true,
|
|
23
|
+
noFallthroughCasesInSwitch: false,
|
|
24
|
+
noImplicitAny: false,
|
|
25
|
+
noImplicitOverride: true,
|
|
26
|
+
noImplicitReturns: false,
|
|
27
|
+
noUncheckedIndexedAccess: true,
|
|
28
|
+
noUnusedLocals: false,
|
|
29
|
+
noUnusedParameters: false,
|
|
30
|
+
resolveJsonModule: true,
|
|
31
|
+
skipLibCheck: true,
|
|
32
|
+
strict: true,
|
|
33
|
+
strictNullChecks: false,
|
|
34
|
+
transpileTarget: "ESNext",
|
|
35
|
+
verbatimModuleSyntax: true
|
|
36
|
+
},
|
|
37
|
+
exclude: ["**/node_modules"],
|
|
38
|
+
include: ["./bin/**/*.ts"]
|
|
39
|
+
});
|
|
40
|
+
await fs.writeJSON(path.join(outDirRoot, tsconfigJson), tsConfig, {
|
|
41
|
+
spaces: 2
|
|
42
|
+
});
|
|
43
|
+
relinka("verbose", `Created tsconfig.json in ${outDirRoot}`);
|
|
44
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
export { library_buildLibrary } from "./sdk-impl/build/build-library.js";
|
|
2
|
+
export {
|
|
3
|
+
regular_buildJsrDist,
|
|
4
|
+
regular_buildNpmDist
|
|
5
|
+
} from "./sdk-impl/build/build-regular.js";
|
|
6
|
+
export { autoPreset } from "./sdk-impl/build/bundlers/unified/auto.js";
|
|
7
|
+
export { build } from "./sdk-impl/build/bundlers/unified/build.js";
|
|
8
|
+
export { copyBuild } from "./sdk-impl/build/bundlers/unified/copy/copy.js";
|
|
9
|
+
export { mkdistBuild } from "./sdk-impl/build/bundlers/unified/mkdist/mkdist.js";
|
|
10
|
+
export { rollupBuild } from "./sdk-impl/build/bundlers/unified/rollup/build.js";
|
|
11
|
+
export { getRollupOptions } from "./sdk-impl/build/bundlers/unified/rollup/config.js";
|
|
12
|
+
export {
|
|
13
|
+
cjsPlugin,
|
|
14
|
+
fixCJSExportTypePlugin
|
|
15
|
+
} from "./sdk-impl/build/bundlers/unified/rollup/plugins/cjs.js";
|
|
16
|
+
export { esbuild } from "./sdk-impl/build/bundlers/unified/rollup/plugins/esbuild.js";
|
|
17
|
+
export { JSONPlugin } from "./sdk-impl/build/bundlers/unified/rollup/plugins/json.js";
|
|
18
|
+
export { rawPlugin } from "./sdk-impl/build/bundlers/unified/rollup/plugins/raw.js";
|
|
19
|
+
export {
|
|
20
|
+
getShebang,
|
|
21
|
+
makeExecutable,
|
|
22
|
+
removeShebangPlugin,
|
|
23
|
+
shebangPlugin
|
|
24
|
+
} from "./sdk-impl/build/bundlers/unified/rollup/plugins/shebang.js";
|
|
25
|
+
export { rollupStub } from "./sdk-impl/build/bundlers/unified/rollup/stub.js";
|
|
26
|
+
export {
|
|
27
|
+
DEFAULT_EXTENSIONS,
|
|
28
|
+
getChunkFilename,
|
|
29
|
+
resolveAliases
|
|
30
|
+
} from "./sdk-impl/build/bundlers/unified/rollup/utils.js";
|
|
31
|
+
export { rollupWatch } from "./sdk-impl/build/bundlers/unified/rollup/watch.js";
|
|
32
|
+
export {
|
|
33
|
+
defineBuildConfig,
|
|
34
|
+
definePreset
|
|
35
|
+
} from "./sdk-impl/build/bundlers/unified/types.js";
|
|
36
|
+
export { typesBuild } from "./sdk-impl/build/bundlers/unified/untyped/index.js";
|
|
37
|
+
export {
|
|
38
|
+
arrayIncludes,
|
|
39
|
+
dumpObject,
|
|
40
|
+
ensuredir,
|
|
41
|
+
extractExportFilenames,
|
|
42
|
+
getpkg,
|
|
43
|
+
inferPkgExternals,
|
|
44
|
+
listRecursively,
|
|
45
|
+
removeExtension,
|
|
46
|
+
resolvePreset,
|
|
47
|
+
rmdir,
|
|
48
|
+
symlink,
|
|
49
|
+
warn,
|
|
50
|
+
withTrailingSlash
|
|
51
|
+
} from "./sdk-impl/build/bundlers/unified/utils.js";
|
|
52
|
+
export {
|
|
53
|
+
validateDependencies,
|
|
54
|
+
validatePackage
|
|
55
|
+
} from "./sdk-impl/build/bundlers/unified/validate.js";
|
|
56
|
+
export { processLibraryFlow } from "./sdk-impl/library-flow.js";
|
|
57
|
+
export { library_publishLibrary } from "./sdk-impl/pub/pub-library.js";
|
|
58
|
+
export {
|
|
59
|
+
regular_pubToJsr,
|
|
60
|
+
regular_pubToNpm
|
|
61
|
+
} from "./sdk-impl/pub/pub-regular.js";
|
|
62
|
+
export { processRegularFlow } from "./sdk-impl/regular-flow.js";
|
|
63
|
+
export { useAggregator } from "./sdk-impl/utils/tools/tools-agg.js";
|
|
64
|
+
export { printUsage } from "./sdk-impl/utils/tools/tools-impl.js";
|
|
65
|
+
export {
|
|
66
|
+
getBunSourcemapOption,
|
|
67
|
+
getUnifiedSourcemapOption,
|
|
68
|
+
renameEntryFile
|
|
69
|
+
} from "./sdk-impl/utils/utils-build.js";
|
|
70
|
+
export { bumpHandler, setBumpDisabled } from "./sdk-impl/utils/utils-bump.js";
|
|
71
|
+
export { removeDistFolders } from "./sdk-impl/utils/utils-clean.js";
|
|
72
|
+
export {
|
|
73
|
+
cliDomainDocs,
|
|
74
|
+
CONCURRENCY_DEFAULT,
|
|
75
|
+
PROJECT_ROOT,
|
|
76
|
+
SHOW_VERBOSE,
|
|
77
|
+
tsconfigJson,
|
|
78
|
+
validExtensions
|
|
79
|
+
} from "./sdk-impl/utils/utils-consts.js";
|
|
80
|
+
export {
|
|
81
|
+
validateDevCwd,
|
|
82
|
+
withWorkingDirectory
|
|
83
|
+
} from "./sdk-impl/utils/utils-cwd.js";
|
|
84
|
+
export { filterDeps } from "./sdk-impl/utils/utils-deps.js";
|
|
85
|
+
export { determineDistName } from "./sdk-impl/utils/utils-determine.js";
|
|
86
|
+
export { handleDlerError } from "./sdk-impl/utils/utils-error.js";
|
|
87
|
+
export {
|
|
88
|
+
copyRootFile,
|
|
89
|
+
deleteSpecificFiles,
|
|
90
|
+
getDirectorySize,
|
|
91
|
+
outDirBinFilesCount,
|
|
92
|
+
readFileSafe,
|
|
93
|
+
writeFileSafe
|
|
94
|
+
} from "./sdk-impl/utils/utils-fs.js";
|
|
95
|
+
export { finalizeBuild } from "./sdk-impl/utils/utils-info.js";
|
|
96
|
+
export {
|
|
97
|
+
createJsrJSON,
|
|
98
|
+
renameTsxFiles
|
|
99
|
+
} from "./sdk-impl/utils/utils-jsr-json.js";
|
|
100
|
+
export {
|
|
101
|
+
convertImportExtensionsJsToTs,
|
|
102
|
+
convertImportPaths,
|
|
103
|
+
extractPackageName,
|
|
104
|
+
normalizeQuotes
|
|
105
|
+
} from "./sdk-impl/utils/utils-paths.js";
|
|
106
|
+
export {
|
|
107
|
+
createPerfTimer,
|
|
108
|
+
getElapsedPerfTime,
|
|
109
|
+
pausePerfTimer,
|
|
110
|
+
resumePerfTimer
|
|
111
|
+
} from "./sdk-impl/utils/utils-perf.js";
|
|
112
|
+
export { library_createPackageJSON } from "./sdk-impl/utils/utils-pkg-json-libs.js";
|
|
113
|
+
export { regular_createPackageJSON } from "./sdk-impl/utils/utils-pkg-json-reg.js";
|
|
114
|
+
export { createTSConfig } from "./sdk-impl/utils/utils-tsconfig.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../types.js";
|
package/bin/load.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { relinka } from "@reliverse/relinka";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
import { defineConfig } from "./libs/cfg/cfg-mod.js";
|
|
5
|
+
const CONFIG_FILENAME = ".config/dler.ts";
|
|
6
|
+
export async function loadConfig() {
|
|
7
|
+
const cwd = process.cwd();
|
|
8
|
+
const configPath = resolve(cwd, CONFIG_FILENAME);
|
|
9
|
+
if (await fs.pathExists(configPath)) {
|
|
10
|
+
try {
|
|
11
|
+
const configModule = await import(`file://${configPath}`);
|
|
12
|
+
const config = configModule.default || configModule;
|
|
13
|
+
if (typeof config === "function") {
|
|
14
|
+
return defineConfig(config());
|
|
15
|
+
}
|
|
16
|
+
return defineConfig(config);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
relinka("error", `Error loading config from ${configPath}:`, error);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
relinka(
|
|
22
|
+
"info",
|
|
23
|
+
`Config file not found at ${configPath}. Using default configuration.`
|
|
24
|
+
// Inform user about fallback
|
|
25
|
+
);
|
|
26
|
+
return defineConfig();
|
|
27
|
+
}
|
package/bin/main.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { defineCommand, runMain } from "@reliverse/rempts";
|
|
2
|
+
import { dler } from "./cli.js";
|
|
3
|
+
import { initDlerConfig } from "./init.js";
|
|
4
|
+
import { validateDevCwd } from "./libs/sdk/sdk-impl/utils/utils-cwd.js";
|
|
5
|
+
const mainCommand = defineCommand({
|
|
6
|
+
meta: {
|
|
7
|
+
name: "dler",
|
|
8
|
+
version: "1.2.0",
|
|
9
|
+
description: "dler CLI https://docs.reliverse.org"
|
|
10
|
+
},
|
|
11
|
+
args: {
|
|
12
|
+
dev: {
|
|
13
|
+
type: "boolean",
|
|
14
|
+
description: "Runs the CLI in dev mode"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
async run({ args }) {
|
|
18
|
+
const isDev = args.dev;
|
|
19
|
+
await validateDevCwd(isDev, ["dler"], "dler", "reliverse");
|
|
20
|
+
await initDlerConfig(isDev);
|
|
21
|
+
await dler(isDev);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
await runMain(mainCommand, {
|
|
25
|
+
fileBasedCmds: {
|
|
26
|
+
enable: true,
|
|
27
|
+
// Enables file-based subcommand detection.
|
|
28
|
+
cmdsRootPath: "src/cli/args"
|
|
29
|
+
// Directory to scan for subcommands.
|
|
30
|
+
},
|
|
31
|
+
alias: {
|
|
32
|
+
v: "verbose"
|
|
33
|
+
// Maps shorthand flag -v to --verbose.
|
|
34
|
+
},
|
|
35
|
+
strict: false,
|
|
36
|
+
// Do not throw errors for unknown flags.
|
|
37
|
+
warnOnUnknown: false,
|
|
38
|
+
// Warn when encountering unknown flags.
|
|
39
|
+
negatedBoolean: true
|
|
40
|
+
// Support for negated booleans (e.g., --no-verbose).
|
|
41
|
+
// unknown: (flagName) => {
|
|
42
|
+
// relinka("warn", "Unknown flag encountered:", flagName);
|
|
43
|
+
// return false;
|
|
44
|
+
// },
|
|
45
|
+
// TODO: unknownErrorMsg: "An unhandled error occurred, please report it at https://github.com/reliverse/dler"
|
|
46
|
+
});
|