@reliverse/dler 1.7.6 → 1.7.8
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/LICENSES +1 -0
- package/README.md +1 -1
- package/bin/app/agg/impl.js +9 -25
- package/bin/app/agg/run.js +1 -6
- package/bin/app/build/impl.js +3 -17
- package/bin/app/check/cmd.js +3 -12
- package/bin/app/conv/cmd.js +7 -25
- package/bin/app/copy/cmd.js +2 -7
- package/bin/app/init/cmd.js +1 -5
- package/bin/app/init/init-const.js +2 -11
- package/bin/app/init/init-impl.js +9 -30
- package/bin/app/init/{templates/t-readme.d.ts → init-tmpl.d.ts} +2 -0
- package/bin/app/init/{templates/t-readme.js → init-tmpl.js} +27 -0
- package/bin/app/inject/impl.js +4 -7
- package/bin/app/libs/cmd.js +4 -13
- package/bin/app/merge/cmd.js +8 -28
- package/bin/app/migrate/cmd.js +11 -44
- package/bin/app/migrate/codemods/anything-bun.js +13 -34
- package/bin/app/migrate/codemods/commander-rempts.js +4 -12
- package/bin/app/migrate/codemods/console-relinka.js +12 -27
- package/bin/app/migrate/codemods/fs-relifso.js +20 -43
- package/bin/app/migrate/codemods/nodenext-bundler.js +6 -14
- package/bin/app/migrate/codemods/path-pathkit.js +16 -42
- package/bin/app/migrate/codemods/readdir-glob.js +11 -22
- package/bin/app/mkdist/cmd.d.ts +83 -0
- package/bin/app/mkdist/cmd.js +121 -0
- package/bin/app/rempts/cmd.js +13 -35
- package/bin/app/rename/cmd.js +6 -15
- package/bin/app/spell/cmd.js +1 -3
- package/bin/app/split/cmd.js +1 -5
- package/bin/app/split/impl.js +1 -6
- package/bin/libs/sdk/sdk-impl/build/build-library.js +36 -123
- package/bin/libs/sdk/sdk-impl/build/build-regular.d.ts +2 -2
- package/bin/libs/sdk/sdk-impl/build/build-regular.js +28 -66
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/auto.js +4 -16
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.d.ts +1 -1
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.js +97 -89
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/copy/{copy.js → copy-mod.js} +4 -18
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loader.d.ts +4 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loader.js +26 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/js.d.ts +2 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/js.js +49 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/loaders-mod.d.ts +12 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/loaders-mod.js +30 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/postcss.d.ts +3 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/postcss.js +28 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/sass.d.ts +2 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/sass.js +31 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/vue.d.ts +17 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/vue.js +145 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/make.d.ts +8 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/make.js +133 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/dts.d.ts +11 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/dts.js +94 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/fs.d.ts +1 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/fs.js +15 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/vue-dts.d.ts +3 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/vue-dts.js +175 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/{mkdist.js → mkdist-mod.js} +5 -19
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/build.js +2 -7
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/config.js +2 -9
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/stub.js +8 -26
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/utils.js +1 -4
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/watch.js +1 -4
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/untyped/{index.js → untyped-mod.js} +8 -22
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/utils.js +3 -11
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/validate.js +4 -15
- package/bin/libs/sdk/sdk-impl/cfg/default.js +1 -9
- package/bin/libs/sdk/sdk-impl/cfg/info.js +1 -1
- package/bin/libs/sdk/sdk-impl/cfg/init.js +101 -102
- package/bin/libs/sdk/sdk-impl/cfg/load.js +1 -4
- package/bin/libs/sdk/sdk-impl/library-flow.js +3 -11
- package/bin/libs/sdk/sdk-impl/pub/pub-library.js +5 -22
- package/bin/libs/sdk/sdk-impl/pub/pub-regular.d.ts +2 -2
- package/bin/libs/sdk/sdk-impl/pub/pub-regular.js +3 -6
- package/bin/libs/sdk/sdk-impl/regular-flow.js +8 -26
- package/bin/libs/sdk/sdk-impl/rules/reliverse/file-extensions/file-extensions.js +1 -5
- package/bin/libs/sdk/sdk-impl/rules/reliverse/missing-deps/analyzer.js +2 -9
- package/bin/libs/sdk/sdk-impl/rules/reliverse/missing-deps/formatter.js +8 -20
- package/bin/libs/sdk/sdk-impl/rules/reliverse/package-json-health/package-json-health.js +1 -7
- package/bin/libs/sdk/sdk-impl/rules/reliverse/path-extensions/path-extensions.js +2 -5
- package/bin/libs/sdk/sdk-impl/rules/reliverse/self-include/self-include.js +3 -8
- package/bin/libs/sdk/sdk-impl/rules/rules-mod.js +4 -14
- package/bin/libs/sdk/sdk-impl/spell/spell-filesystem.js +4 -8
- package/bin/libs/sdk/sdk-impl/spell/spell-parser.js +1 -3
- package/bin/libs/sdk/sdk-impl/utils/finalize.js +3 -14
- package/bin/libs/sdk/sdk-impl/utils/tools/tools-agg.js +5 -16
- package/bin/libs/sdk/sdk-impl/utils/utils-build.js +3 -11
- package/bin/libs/sdk/sdk-impl/utils/utils-clean.js +2 -5
- package/bin/libs/sdk/sdk-impl/utils/utils-consts.js +1 -8
- package/bin/libs/sdk/sdk-impl/utils/utils-cwd.js +1 -4
- package/bin/libs/sdk/sdk-impl/utils/utils-deps.js +14 -25
- package/bin/libs/sdk/sdk-impl/utils/utils-error.js +1 -5
- package/bin/libs/sdk/sdk-impl/utils/utils-fs.d.ts +14 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-fs.js +100 -37
- package/bin/libs/sdk/sdk-impl/utils/utils-jsr-json.js +2 -7
- package/bin/libs/sdk/sdk-impl/utils/utils-package-json-libraries.js +32 -86
- package/bin/libs/sdk/sdk-impl/utils/utils-package-json-regular.js +13 -61
- package/bin/libs/sdk/sdk-mod.d.ts +3 -3
- package/bin/libs/sdk/sdk-mod.js +3 -3
- package/bin/libs/sdk/sdk-types.d.ts +76 -12
- package/package.json +8 -3
- package/bin/app/init/templates/t-gitignore.d.ts +0 -1
- package/bin/app/init/templates/t-gitignore.js +0 -9
- package/bin/app/init/templates/t-license.d.ts +0 -1
- package/bin/app/init/templates/t-license.js +0 -18
- /package/bin/libs/sdk/sdk-impl/build/bundlers/unified/copy/{copy.d.ts → copy-mod.d.ts} +0 -0
- /package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/{mkdist.d.ts → mkdist-mod.d.ts} +0 -0
- /package/bin/libs/sdk/sdk-impl/build/bundlers/unified/untyped/{index.d.ts → untyped-mod.d.ts} +0 -0
package/LICENSES
CHANGED
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
- 🎯 optimized for speed and modern workflows
|
|
16
16
|
- ✨ packed with powerful features under the hood
|
|
17
17
|
- 🛠️ converts typescript aliases to relative paths
|
|
18
|
-
- 🔌
|
|
18
|
+
- 🔌 15 built-in helper [dler commands](#-commands) included
|
|
19
19
|
- 📝 highly configurable flow via a configuration file
|
|
20
20
|
- 🔜 `libraries` plugin —> dler monorepo implementation
|
|
21
21
|
- 🧼 cleans up your internal logs from the build dist
|
package/bin/app/agg/impl.js
CHANGED
|
@@ -31,11 +31,8 @@ export async function useAggregator({
|
|
|
31
31
|
try {
|
|
32
32
|
await fs.ensureDir(outDir);
|
|
33
33
|
} catch (error) {
|
|
34
|
-
relinka(
|
|
35
|
-
|
|
36
|
-
`Error: Cannot create output directory: ${outDir}
|
|
37
|
-
${error}`
|
|
38
|
-
);
|
|
34
|
+
relinka("error", `Error: Cannot create output directory: ${outDir}
|
|
35
|
+
${error}`);
|
|
39
36
|
process.exit(1);
|
|
40
37
|
}
|
|
41
38
|
if (separateTypesFile && typesOutFile) {
|
|
@@ -43,11 +40,8 @@ ${error}`
|
|
|
43
40
|
try {
|
|
44
41
|
await fs.ensureDir(typesOutDir);
|
|
45
42
|
} catch (error) {
|
|
46
|
-
relinka(
|
|
47
|
-
|
|
48
|
-
`Error: Cannot create types output directory: ${typesOutDir}
|
|
49
|
-
${error}`
|
|
50
|
-
);
|
|
43
|
+
relinka("error", `Error: Cannot create types output directory: ${typesOutDir}
|
|
44
|
+
${error}`);
|
|
51
45
|
process.exit(1);
|
|
52
46
|
}
|
|
53
47
|
}
|
|
@@ -61,19 +55,14 @@ ${error}`
|
|
|
61
55
|
if (stripPrefix) {
|
|
62
56
|
const stripSt = await fs.stat(stripPrefix).catch(() => null);
|
|
63
57
|
if (!stripSt?.isDirectory()) {
|
|
64
|
-
relinka(
|
|
65
|
-
"error",
|
|
66
|
-
`Error: --strip is not a valid directory: ${stripPrefix}`
|
|
67
|
-
);
|
|
58
|
+
relinka("error", `Error: --strip is not a valid directory: ${stripPrefix}`);
|
|
68
59
|
process.exit(1);
|
|
69
60
|
}
|
|
70
61
|
}
|
|
71
62
|
if (verbose)
|
|
72
63
|
relinka(
|
|
73
64
|
"log",
|
|
74
|
-
`Scanning directory ${inputDir} for files with extensions: ${fileExtensions.join(
|
|
75
|
-
", "
|
|
76
|
-
)}`
|
|
65
|
+
`Scanning directory ${inputDir} for files with extensions: ${fileExtensions.join(", ")}`
|
|
77
66
|
);
|
|
78
67
|
const filePaths = await collectFiles(
|
|
79
68
|
inputDir,
|
|
@@ -149,10 +138,7 @@ ${AGGREGATOR_END}
|
|
|
149
138
|
const aggregatorBlock = buildAggregatorBlock(allLines);
|
|
150
139
|
await fs.ensureFile(outFile);
|
|
151
140
|
await fs.writeFile(outFile, aggregatorBlock, "utf8");
|
|
152
|
-
relinka(
|
|
153
|
-
"success",
|
|
154
|
-
`Aggregator done: processed ${allLines.length} lines in: ${outFile}`
|
|
155
|
-
);
|
|
141
|
+
relinka("success", `Aggregator done: processed ${allLines.length} lines in: ${outFile}`);
|
|
156
142
|
}
|
|
157
143
|
} catch (error) {
|
|
158
144
|
relinka("error", `Aggregator failed: ${error}`);
|
|
@@ -253,9 +239,7 @@ async function generateAggregatorLines(filePath, inputDir, stripPrefix, useImpor
|
|
|
253
239
|
if (useImport) {
|
|
254
240
|
const lines2 = [];
|
|
255
241
|
if (typeNames.length > 0) {
|
|
256
|
-
lines2.push(
|
|
257
|
-
`import type { ${typeNames.join(", ")} } from "${importPath}";`
|
|
258
|
-
);
|
|
242
|
+
lines2.push(`import type { ${typeNames.join(", ")} } from "${importPath}";`);
|
|
259
243
|
}
|
|
260
244
|
if (valueNames.length > 0) {
|
|
261
245
|
lines2.push(`import { ${valueNames.join(", ")} } from "${importPath}";`);
|
|
@@ -273,7 +257,7 @@ async function generateAggregatorLines(filePath, inputDir, stripPrefix, useImpor
|
|
|
273
257
|
}
|
|
274
258
|
async function getNamedExports(filePath) {
|
|
275
259
|
try {
|
|
276
|
-
const code = await fs.readFile(filePath, "
|
|
260
|
+
const code = await fs.readFile(filePath, "utf8");
|
|
277
261
|
const typeNamesSet = /* @__PURE__ */ new Set();
|
|
278
262
|
const valueNamesSet = /* @__PURE__ */ new Set();
|
|
279
263
|
const patterns = [
|
package/bin/app/agg/run.js
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
selectPrompt,
|
|
3
|
-
runCmd,
|
|
4
|
-
confirmPrompt,
|
|
5
|
-
inputPrompt
|
|
6
|
-
} from "@reliverse/rempts";
|
|
1
|
+
import { selectPrompt, runCmd, confirmPrompt, inputPrompt } from "@reliverse/rempts";
|
|
7
2
|
import { existsSync } from "node:fs";
|
|
8
3
|
import { resolve } from "node:path";
|
|
9
4
|
import { getAggCmd } from "../cmds.js";
|
package/bin/app/build/impl.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
bumpHandler,
|
|
3
|
-
isBumpDisabled,
|
|
4
|
-
setBumpDisabledValueTo
|
|
5
|
-
} from "@reliverse/bleump";
|
|
1
|
+
import { bumpHandler, isBumpDisabled, setBumpDisabledValueTo } from "@reliverse/bleump";
|
|
6
2
|
import path from "@reliverse/pathkit";
|
|
7
3
|
import fs from "@reliverse/relifso";
|
|
8
4
|
import { loadConfig } from "../../libs/sdk/sdk-impl/cfg/load.js";
|
|
@@ -29,12 +25,7 @@ export async function dlerBuild(isDev) {
|
|
|
29
25
|
try {
|
|
30
26
|
const bumpIsDisabled = await isBumpDisabled();
|
|
31
27
|
if (!bumpIsDisabled && !config.commonPubPause) {
|
|
32
|
-
await bumpHandler(
|
|
33
|
-
config.bumpMode,
|
|
34
|
-
false,
|
|
35
|
-
config.bumpFilter,
|
|
36
|
-
config.bumpSet
|
|
37
|
-
);
|
|
28
|
+
await bumpHandler(config.bumpMode, false, config.bumpFilter, config.bumpSet);
|
|
38
29
|
await setBumpDisabledValueTo(true);
|
|
39
30
|
}
|
|
40
31
|
} catch {
|
|
@@ -70,12 +61,7 @@ export async function dlerPub(isDev) {
|
|
|
70
61
|
const bumpIsDisabled = await isBumpDisabled();
|
|
71
62
|
if (!bumpIsDisabled && !config.commonPubPause) {
|
|
72
63
|
try {
|
|
73
|
-
await bumpHandler(
|
|
74
|
-
config.bumpMode,
|
|
75
|
-
false,
|
|
76
|
-
config.bumpFilter,
|
|
77
|
-
config.bumpSet
|
|
78
|
-
);
|
|
64
|
+
await bumpHandler(config.bumpMode, false, config.bumpFilter, config.bumpSet);
|
|
79
65
|
await setBumpDisabledValueTo(true);
|
|
80
66
|
} catch {
|
|
81
67
|
throw new Error("[.config/dler.ts] Failed to set bumpDisable to true");
|
package/bin/app/check/cmd.js
CHANGED
|
@@ -112,18 +112,9 @@ export default defineCommand({
|
|
|
112
112
|
}
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
|
-
relinka(
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
);
|
|
119
|
-
relinka(
|
|
120
|
-
"info",
|
|
121
|
-
"\u{1F4C1} file rules: .ts files allowed in src/jsr dirs, .js files in npm dirs"
|
|
122
|
-
);
|
|
123
|
-
relinka(
|
|
124
|
-
"info",
|
|
125
|
-
"\u{1F4E6} import rules: use .js imports in src/npm dirs, .ts imports in jsr dirs"
|
|
126
|
-
);
|
|
115
|
+
relinka("info", "this command checks your codebase for extension and dependency issues.");
|
|
116
|
+
relinka("info", "\u{1F4C1} file rules: .ts files allowed in src/jsr dirs, .js files in npm dirs");
|
|
117
|
+
relinka("info", "\u{1F4E6} import rules: use .js imports in src/npm dirs, .ts imports in jsr dirs");
|
|
127
118
|
relinka(
|
|
128
119
|
"info",
|
|
129
120
|
"\u{1F504} self-include rules: no importing from main package or self-imports in libs"
|
package/bin/app/conv/cmd.js
CHANGED
|
@@ -50,10 +50,7 @@ export default defineCommand({
|
|
|
50
50
|
switch (type) {
|
|
51
51
|
case "replace":
|
|
52
52
|
if (!pattern || !replacement) {
|
|
53
|
-
relinka(
|
|
54
|
-
"error",
|
|
55
|
-
"\u274C Pattern and replacement are required for replace operation"
|
|
56
|
-
);
|
|
53
|
+
relinka("error", "\u274C Pattern and replacement are required for replace operation");
|
|
57
54
|
return;
|
|
58
55
|
}
|
|
59
56
|
spell = {
|
|
@@ -76,10 +73,7 @@ export default defineCommand({
|
|
|
76
73
|
break;
|
|
77
74
|
case "remove-comment":
|
|
78
75
|
if (!pattern) {
|
|
79
|
-
relinka(
|
|
80
|
-
"error",
|
|
81
|
-
"\u274C Pattern is required for remove-comment operation"
|
|
82
|
-
);
|
|
76
|
+
relinka("error", "\u274C Pattern is required for remove-comment operation");
|
|
83
77
|
return;
|
|
84
78
|
}
|
|
85
79
|
spell = {
|
|
@@ -129,10 +123,7 @@ export default defineCommand({
|
|
|
129
123
|
break;
|
|
130
124
|
case "transform":
|
|
131
125
|
if (!transform) {
|
|
132
|
-
relinka(
|
|
133
|
-
"error",
|
|
134
|
-
"\u274C Transform function name is required for transform operation"
|
|
135
|
-
);
|
|
126
|
+
relinka("error", "\u274C Transform function name is required for transform operation");
|
|
136
127
|
return;
|
|
137
128
|
}
|
|
138
129
|
spell = {
|
|
@@ -143,10 +134,7 @@ export default defineCommand({
|
|
|
143
134
|
break;
|
|
144
135
|
case "insert":
|
|
145
136
|
if (!line || !replacement) {
|
|
146
|
-
relinka(
|
|
147
|
-
"error",
|
|
148
|
-
"\u274C Line number and replacement are required for insert operation"
|
|
149
|
-
);
|
|
137
|
+
relinka("error", "\u274C Line number and replacement are required for insert operation");
|
|
150
138
|
return;
|
|
151
139
|
}
|
|
152
140
|
spell = {
|
|
@@ -161,13 +149,10 @@ export default defineCommand({
|
|
|
161
149
|
return;
|
|
162
150
|
}
|
|
163
151
|
try {
|
|
164
|
-
const content = await fs.readFile(input, "
|
|
152
|
+
const content = await fs.readFile(input, "utf8");
|
|
165
153
|
const result = await executeSpell(spell, input, content);
|
|
166
154
|
if (result.success) {
|
|
167
|
-
relinka(
|
|
168
|
-
"log",
|
|
169
|
-
`\u2705 Successfully performed ${type} operation on ${input}`
|
|
170
|
-
);
|
|
155
|
+
relinka("log", `\u2705 Successfully performed ${type} operation on ${input}`);
|
|
171
156
|
if (result.changes) {
|
|
172
157
|
relinka(
|
|
173
158
|
"log",
|
|
@@ -177,10 +162,7 @@ After: ${result.changes.after}`
|
|
|
177
162
|
);
|
|
178
163
|
}
|
|
179
164
|
} else {
|
|
180
|
-
relinka(
|
|
181
|
-
"error",
|
|
182
|
-
`\u274C Failed to perform ${type} operation: ${result.message}`
|
|
183
|
-
);
|
|
165
|
+
relinka("error", `\u274C Failed to perform ${type} operation: ${result.message}`);
|
|
184
166
|
}
|
|
185
167
|
} catch (error) {
|
|
186
168
|
relinka("error", `\u274C Error during conversion: ${error}`);
|
package/bin/app/copy/cmd.js
CHANGED
|
@@ -5,10 +5,7 @@ import { join, dirname, basename } from "node:path";
|
|
|
5
5
|
import pMap from "p-map";
|
|
6
6
|
import prettyMilliseconds from "pretty-ms";
|
|
7
7
|
import { glob } from "tinyglobby";
|
|
8
|
-
import {
|
|
9
|
-
createPerfTimer,
|
|
10
|
-
getElapsedPerfTime
|
|
11
|
-
} from "../../libs/sdk/sdk-impl/utils/utils-perf.js";
|
|
8
|
+
import { createPerfTimer, getElapsedPerfTime } from "../../libs/sdk/sdk-impl/utils/utils-perf.js";
|
|
12
9
|
async function fileExists(path) {
|
|
13
10
|
try {
|
|
14
11
|
await access(path);
|
|
@@ -160,9 +157,7 @@ export default defineCommand({
|
|
|
160
157
|
const elapsed = getElapsedPerfTime(timer);
|
|
161
158
|
relinka(
|
|
162
159
|
"log",
|
|
163
|
-
`Successfully copied ${files.length} file(s) in ${prettyMilliseconds(
|
|
164
|
-
elapsed
|
|
165
|
-
)}`
|
|
160
|
+
`Successfully copied ${files.length} file(s) in ${prettyMilliseconds(elapsed)}`
|
|
166
161
|
);
|
|
167
162
|
} catch (error) {
|
|
168
163
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
package/bin/app/init/cmd.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { relinka } from "@reliverse/relinka";
|
|
2
|
-
import {
|
|
3
|
-
defineCommand,
|
|
4
|
-
multiselectPrompt,
|
|
5
|
-
selectPrompt
|
|
6
|
-
} from "@reliverse/rempts";
|
|
2
|
+
import { defineCommand, multiselectPrompt, selectPrompt } from "@reliverse/rempts";
|
|
7
3
|
import { FILE_TYPES } from "./init-const.js";
|
|
8
4
|
import { initFile, initFiles } from "./init-impl.js";
|
|
9
5
|
export default defineCommand({
|
|
@@ -12,15 +12,6 @@ export const FILE_TYPES = [
|
|
|
12
12
|
{ type: "md:LICENSE", variations: ["LICENSE.md", "LICENSE"] },
|
|
13
13
|
{ type: "md:README", variations: ["README.md", "README"] }
|
|
14
14
|
];
|
|
15
|
-
export const INIT_BEHAVIOURS = [
|
|
16
|
-
|
|
17
|
-
"copy",
|
|
18
|
-
"create-if-copy-failed"
|
|
19
|
-
];
|
|
20
|
-
export const DEST_FILE_EXISTS_BEHAVIOURS = [
|
|
21
|
-
"rewrite",
|
|
22
|
-
"skip",
|
|
23
|
-
"attach-index",
|
|
24
|
-
"prompt"
|
|
25
|
-
];
|
|
15
|
+
export const INIT_BEHAVIOURS = ["create", "copy", "create-if-copy-failed"];
|
|
16
|
+
export const DEST_FILE_EXISTS_BEHAVIOURS = ["rewrite", "skip", "attach-index", "prompt"];
|
|
26
17
|
export const CONTENT_CREATE_MODES = ["license-basic", "simple-readme"];
|
|
@@ -4,9 +4,7 @@ import { relinka } from "@reliverse/relinka";
|
|
|
4
4
|
import { selectPrompt } from "@reliverse/rempts";
|
|
5
5
|
import pMap from "p-map";
|
|
6
6
|
import { FILE_TYPES } from "./init-const.js";
|
|
7
|
-
import { gitignoreTemplate } from "./
|
|
8
|
-
import { licenseTemplate } from "./templates/t-license.js";
|
|
9
|
-
import { readmeTemplate } from "./templates/t-readme.js";
|
|
7
|
+
import { gitignoreTemplate, licenseTemplate, readmeTemplate } from "./init-tmpl.js";
|
|
10
8
|
const DEFAULT_CONFIG = {
|
|
11
9
|
defaultInitBehaviour: "create",
|
|
12
10
|
defaultDestFileExistsBehaviour: "prompt",
|
|
@@ -36,7 +34,7 @@ export async function createFileFromScratch(destPath, fileType, contentCreateMod
|
|
|
36
34
|
content = contentCreateMode;
|
|
37
35
|
relinka("verbose", `Using custom content for file ${destPath}`);
|
|
38
36
|
}
|
|
39
|
-
await fs.outputFile(destPath, content, { encoding: "
|
|
37
|
+
await fs.outputFile(destPath, content, { encoding: "utf8" });
|
|
40
38
|
} catch (error) {
|
|
41
39
|
relinka("error", `Failed to create file ${destPath}: ${error}`);
|
|
42
40
|
throw error;
|
|
@@ -85,9 +83,7 @@ async function checkFileExists(filePath) {
|
|
|
85
83
|
async function doInitFile(req, initBehaviour, destFileExistsBehaviour) {
|
|
86
84
|
const { fileType, destDir, options } = req;
|
|
87
85
|
const { destFileName } = options ?? {};
|
|
88
|
-
const knownType = FILE_TYPES.find(
|
|
89
|
-
(f) => f.type.toLowerCase() === fileType.toLowerCase()
|
|
90
|
-
);
|
|
86
|
+
const knownType = FILE_TYPES.find((f) => f.type.toLowerCase() === fileType.toLowerCase());
|
|
91
87
|
if (!knownType) {
|
|
92
88
|
throw new Error(`Unknown file type: ${fileType}`);
|
|
93
89
|
}
|
|
@@ -110,10 +106,7 @@ async function doInitFile(req, initBehaviour, destFileExistsBehaviour) {
|
|
|
110
106
|
);
|
|
111
107
|
const alreadyExists = await checkFileExists(resolvedDestPath);
|
|
112
108
|
if (alreadyExists) {
|
|
113
|
-
const maybeNewDest = await handleExistingFile(
|
|
114
|
-
resolvedDestPath,
|
|
115
|
-
destFileExistsBehaviour
|
|
116
|
-
);
|
|
109
|
+
const maybeNewDest = await handleExistingFile(resolvedDestPath, destFileExistsBehaviour);
|
|
117
110
|
if (!maybeNewDest) {
|
|
118
111
|
return { requested: req, status: "skipped" };
|
|
119
112
|
}
|
|
@@ -135,10 +128,7 @@ async function finalizeInit(req, initBehaviour, chosenVariation, resolvedDestPat
|
|
|
135
128
|
try {
|
|
136
129
|
return await runCopy(req, chosenVariation, resolvedDestPath);
|
|
137
130
|
} catch {
|
|
138
|
-
relinka(
|
|
139
|
-
"warn",
|
|
140
|
-
`Copy failed for ${chosenVariation}, falling back to create...`
|
|
141
|
-
);
|
|
131
|
+
relinka("warn", `Copy failed for ${chosenVariation}, falling back to create...`);
|
|
142
132
|
return await runCreate(req, resolvedDestPath);
|
|
143
133
|
}
|
|
144
134
|
}
|
|
@@ -164,10 +154,7 @@ async function runCopy(req, chosenVariation, resolvedDestPath) {
|
|
|
164
154
|
};
|
|
165
155
|
}
|
|
166
156
|
if (fallbackSource) {
|
|
167
|
-
const fallbackPath = path.join(
|
|
168
|
-
path.resolve(process.cwd(), fallbackSource),
|
|
169
|
-
chosenVariation
|
|
170
|
-
);
|
|
157
|
+
const fallbackPath = path.join(path.resolve(process.cwd(), fallbackSource), chosenVariation);
|
|
171
158
|
if (await checkFileExists(fallbackPath)) {
|
|
172
159
|
await fs.copy(fallbackPath, resolvedDestPath);
|
|
173
160
|
return {
|
|
@@ -179,28 +166,20 @@ async function runCopy(req, chosenVariation, resolvedDestPath) {
|
|
|
179
166
|
}
|
|
180
167
|
throw new Error(`Source file not found: ${chosenVariation}`);
|
|
181
168
|
} catch (error) {
|
|
182
|
-
throw new Error(
|
|
183
|
-
`Copy failed: ${error instanceof Error ? error.message : String(error)}`
|
|
184
|
-
);
|
|
169
|
+
throw new Error(`Copy failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
185
170
|
}
|
|
186
171
|
}
|
|
187
172
|
async function runCreate(req, resolvedDestPath) {
|
|
188
173
|
try {
|
|
189
174
|
const { contentCreateMode } = req.options ?? {};
|
|
190
|
-
await createFileFromScratch(
|
|
191
|
-
resolvedDestPath,
|
|
192
|
-
req.fileType,
|
|
193
|
-
contentCreateMode
|
|
194
|
-
);
|
|
175
|
+
await createFileFromScratch(resolvedDestPath, req.fileType, contentCreateMode);
|
|
195
176
|
return {
|
|
196
177
|
requested: req,
|
|
197
178
|
finalPath: resolvedDestPath,
|
|
198
179
|
status: "created"
|
|
199
180
|
};
|
|
200
181
|
} catch (error) {
|
|
201
|
-
throw new Error(
|
|
202
|
-
`Create failed: ${error instanceof Error ? error.message : String(error)}`
|
|
203
|
-
);
|
|
182
|
+
throw new Error(`Create failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
204
183
|
}
|
|
205
184
|
}
|
|
206
185
|
async function handleExistingFile(destPath, behaviour) {
|
|
@@ -1 +1,3 @@
|
|
|
1
|
+
export declare const gitignoreTemplate = "*.log\n.env\n.DS_Store\n.eslintcache\nnode_modules\ndist-jsr\ndist-libs\ndist-npm\n";
|
|
1
2
|
export declare const readmeTemplate = "# \uD83D\uDE80 Project Name\n\nWelcome! This project was bootstrapped with [@reliverse/reinit](https://www.npmjs.com/package/@reliverse/reinit). \nIt's already got the basics \u2014 now it's your turn to make it awesome \u2728\n\n## \uD83D\uDD27 Tech Stack\n\n- \u2699\uFE0F Framework: _<Add your framework here>_\n- \uD83D\uDEE0\uFE0F Tools: _<Add your tooling, CLIs, etc>_\n- \uD83E\uDDEA Tests: _<Vitest, Jest, or something else?>_\n- \uD83E\uDDE0 Linting: _ESLint, Biome, etc_\n- \uD83C\uDF10 Deployment: _<Vercel, Netlify, Railway?>_\n\n## \uD83D\uDE80 Getting Started\n\nClone the repo and install dependencies:\n\n'''bash\nbun install\nbun dev\n'''\n\nOr if you're using another package manager:\n\n'''bash\nnpm install && npm run dev\n# or\npnpm i && pnpm dev\n'''\n\n## \uD83D\uDDC2\uFE0F Project Structure\n\n'''bash\nsrc/\n\u251C\u2500\u2500 components/\n\u251C\u2500\u2500 pages/\n\u251C\u2500\u2500 lib/\n\u2514\u2500\u2500 styles/\n'''\n\nFeel free to tweak the structure to your liking.\n\n## \uD83E\uDDE9 Customize it\n\nThis project is just a starting point. You can add:\n\n- \uD83E\uDDD9\u200D\u2642\uFE0F Your own components and UI\n- \uD83D\uDCE6 APIs, auth, i18n, analytics, whatever you need\n- \uD83E\uDD16 AI integrations using [Reliverse CLI](https://www.npmjs.com/package/@reliverse/rse)\n\n## \uD83E\uDEF6 Credits\n\nMade with \u2764\uFE0F using [@reliverse/reinit](https://reliverse.org) \nNeed help? [Join the Discord](https://discord.gg/Pb8uKbwpsJ)\n\n## \uD83D\uDCC4 License\n\nMIT \u00A9 YourNameHere\n";
|
|
3
|
+
export declare const licenseTemplate = "# MIT License\n\nCopyright (c) Nazar Kornienko (blefnk), Reliverse\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n";
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
export const gitignoreTemplate = `*.log
|
|
2
|
+
.env
|
|
3
|
+
.DS_Store
|
|
4
|
+
.eslintcache
|
|
5
|
+
node_modules
|
|
6
|
+
dist-jsr
|
|
7
|
+
dist-libs
|
|
8
|
+
dist-npm
|
|
9
|
+
`;
|
|
1
10
|
export const readmeTemplate = `# \u{1F680} Project Name
|
|
2
11
|
Welcome! This project was bootstrapped with [@reliverse/reinit](https://www.npmjs.com/package/@reliverse/reinit).
|
|
3
12
|
It's already got the basics \u2014 now it's your turn to make it awesome \u2728
|
|
@@ -39,3 +48,21 @@ Need help? [Join the Discord](https://discord.gg/Pb8uKbwpsJ)
|
|
|
39
48
|
## \u{1F4C4} License
|
|
40
49
|
MIT \xA9 YourNameHere
|
|
41
50
|
`;
|
|
51
|
+
export const licenseTemplate = `# MIT License
|
|
52
|
+
Copyright (c) Nazar Kornienko (blefnk), Reliverse
|
|
53
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
54
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
55
|
+
in the Software without restriction, including without limitation the rights
|
|
56
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
57
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
58
|
+
furnished to do so, subject to the following conditions:
|
|
59
|
+
The above copyright notice and this permission notice shall be included in all
|
|
60
|
+
copies or substantial portions of the Software.
|
|
61
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
62
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
63
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
64
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
65
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
66
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
67
|
+
SOFTWARE.
|
|
68
|
+
`;
|
package/bin/app/inject/impl.js
CHANGED
|
@@ -19,7 +19,7 @@ function parseCommand(command) {
|
|
|
19
19
|
return { cmd, args };
|
|
20
20
|
}
|
|
21
21
|
async function parseLinesFile(linesFile) {
|
|
22
|
-
const fileContents = await fs.readFile(linesFile, "
|
|
22
|
+
const fileContents = await fs.readFile(linesFile, "utf8");
|
|
23
23
|
const splitted = fileContents.split(/\r?\n/);
|
|
24
24
|
const results = [];
|
|
25
25
|
for (const rawLine of splitted) {
|
|
@@ -100,12 +100,9 @@ async function injectCommentIntoFiles(linesRecords, commentText) {
|
|
|
100
100
|
for (const [filePath, lineNums] of byFile.entries()) {
|
|
101
101
|
lineNums.sort((a, b) => b - a);
|
|
102
102
|
const absPath = path.resolve(filePath);
|
|
103
|
-
relinka(
|
|
104
|
-
"log",
|
|
105
|
-
`Injecting into ${absPath} at lines: ${lineNums.join(", ")}`
|
|
106
|
-
);
|
|
103
|
+
relinka("log", `Injecting into ${absPath} at lines: ${lineNums.join(", ")}`);
|
|
107
104
|
try {
|
|
108
|
-
const original = await fs.readFile(absPath, "
|
|
105
|
+
const original = await fs.readFile(absPath, "utf8");
|
|
109
106
|
const splitted = original.split(/\r?\n/);
|
|
110
107
|
for (const ln of lineNums) {
|
|
111
108
|
if (ln <= splitted.length) {
|
|
@@ -115,7 +112,7 @@ async function injectCommentIntoFiles(linesRecords, commentText) {
|
|
|
115
112
|
}
|
|
116
113
|
}
|
|
117
114
|
const newContent = splitted.join("\n");
|
|
118
|
-
await fs.writeFile(absPath, newContent, "
|
|
115
|
+
await fs.writeFile(absPath, newContent, "utf8");
|
|
119
116
|
} catch (error) {
|
|
120
117
|
relinka("error", `Failed editing ${filePath}: ${error}`);
|
|
121
118
|
}
|
package/bin/app/libs/cmd.js
CHANGED
|
@@ -66,10 +66,7 @@ export default defineCommand({
|
|
|
66
66
|
relinka("error", "\u274C Missing libsDirSrc or libsList in dler config");
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
|
-
relinka(
|
|
70
|
-
"info",
|
|
71
|
-
`\u{1F680} Processing ${libNames.length} library(s): ${libNames.join(", ")}`
|
|
72
|
-
);
|
|
69
|
+
relinka("info", `\u{1F680} Processing ${libNames.length} library(s): ${libNames.join(", ")}`);
|
|
73
70
|
for (const libName of libNames) {
|
|
74
71
|
const libConfig = libsList[libName];
|
|
75
72
|
if (!libConfig) {
|
|
@@ -78,10 +75,7 @@ export default defineCommand({
|
|
|
78
75
|
}
|
|
79
76
|
const { libDirName, libMainFile } = libConfig;
|
|
80
77
|
if (!libDirName || !libMainFile) {
|
|
81
|
-
relinka(
|
|
82
|
-
"warn",
|
|
83
|
-
`\u274C Missing libDirName or libMainFile for "${libName}"`
|
|
84
|
-
);
|
|
78
|
+
relinka("warn", `\u274C Missing libDirName or libMainFile for "${libName}"`);
|
|
85
79
|
continue;
|
|
86
80
|
}
|
|
87
81
|
const libDirPath = path.join(libsDirSrc, libDirName);
|
|
@@ -95,13 +89,10 @@ export default defineCommand({
|
|
|
95
89
|
export * from "./${libDirName}";
|
|
96
90
|
`;
|
|
97
91
|
await fs.ensureDir(path.dirname(mainFilePath));
|
|
98
|
-
await fs.writeFile(mainFilePath, mainFileContent, "
|
|
92
|
+
await fs.writeFile(mainFilePath, mainFileContent, "utf8");
|
|
99
93
|
relinka("log", `\u2705 Created/Updated main file: ${mainFilePath}`);
|
|
100
94
|
} else {
|
|
101
|
-
relinka(
|
|
102
|
-
"warn",
|
|
103
|
-
`\u26A0\uFE0F Main file already exists: ${mainFilePath}. Use --overwrite to update.`
|
|
104
|
-
);
|
|
95
|
+
relinka("warn", `\u26A0\uFE0F Main file already exists: ${mainFilePath}. Use --overwrite to update.`);
|
|
105
96
|
}
|
|
106
97
|
}
|
|
107
98
|
}
|
package/bin/app/merge/cmd.js
CHANGED
|
@@ -2,18 +2,10 @@ import path from "@reliverse/pathkit";
|
|
|
2
2
|
import { glob } from "@reliverse/reglob";
|
|
3
3
|
import fs from "@reliverse/relifso";
|
|
4
4
|
import { relinka } from "@reliverse/relinka";
|
|
5
|
-
import {
|
|
6
|
-
defineCommand,
|
|
7
|
-
inputPrompt,
|
|
8
|
-
confirmPrompt,
|
|
9
|
-
multiselectPrompt
|
|
10
|
-
} from "@reliverse/rempts";
|
|
5
|
+
import { defineCommand, inputPrompt, confirmPrompt, multiselectPrompt } from "@reliverse/rempts";
|
|
11
6
|
import pMap from "p-map";
|
|
12
7
|
import prettyMilliseconds from "pretty-ms";
|
|
13
|
-
import {
|
|
14
|
-
createPerfTimer,
|
|
15
|
-
getElapsedPerfTime
|
|
16
|
-
} from "../../libs/sdk/sdk-impl/utils/utils-perf.js";
|
|
8
|
+
import { createPerfTimer, getElapsedPerfTime } from "../../libs/sdk/sdk-impl/utils/utils-perf.js";
|
|
17
9
|
const DEFAULT_IGNORES = ["**/.git/**", "**/node_modules/**"];
|
|
18
10
|
const BINARY_EXTS = [
|
|
19
11
|
"png",
|
|
@@ -110,11 +102,9 @@ const collectFiles = async (include, extraIgnore, recursive, sortBy) => {
|
|
|
110
102
|
} else if (sortBy === "path") {
|
|
111
103
|
filtered.sort();
|
|
112
104
|
} else if (sortBy === "mtime") {
|
|
113
|
-
filtered = await pMap(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
{ concurrency: 8 }
|
|
117
|
-
).then((arr) => arr.sort((a, b) => a.mtime - b.mtime).map((x) => x.f));
|
|
105
|
+
filtered = await pMap(filtered, async (f) => ({ f, mtime: (await fs.stat(f)).mtimeMs }), {
|
|
106
|
+
concurrency: 8
|
|
107
|
+
}).then((arr) => arr.sort((a, b) => a.mtime - b.mtime).map((x) => x.f));
|
|
118
108
|
}
|
|
119
109
|
return filtered;
|
|
120
110
|
};
|
|
@@ -286,8 +276,7 @@ export default defineCommand({
|
|
|
286
276
|
);
|
|
287
277
|
if (raw) include = parseCSV(raw);
|
|
288
278
|
}
|
|
289
|
-
if (include.length === 0)
|
|
290
|
-
throw new Error("No input patterns supplied and prompts disabled");
|
|
279
|
+
if (include.length === 0) throw new Error("No input patterns supplied and prompts disabled");
|
|
291
280
|
let ignore = args.ignore ?? [];
|
|
292
281
|
if (ignore.length === 0) {
|
|
293
282
|
const raw = await maybePrompt(
|
|
@@ -363,9 +352,7 @@ export default defineCommand({
|
|
|
363
352
|
const interactive = args.interactive ?? false;
|
|
364
353
|
let files = await collectFiles(include, ignore, recursive, sortBy);
|
|
365
354
|
if (files.length === 0) {
|
|
366
|
-
throw new Error(
|
|
367
|
-
"No text files matched given patterns (binary/media files are skipped)"
|
|
368
|
-
);
|
|
355
|
+
throw new Error("No text files matched given patterns (binary/media files are skipped)");
|
|
369
356
|
}
|
|
370
357
|
if (interactive && !batch) {
|
|
371
358
|
const selected = await multiselectPrompt({
|
|
@@ -425,14 +412,7 @@ ${section}`;
|
|
|
425
412
|
const filteredSections = sections.filter(Boolean);
|
|
426
413
|
if (header) filteredSections.unshift(header);
|
|
427
414
|
if (footer) filteredSections.push(footer);
|
|
428
|
-
await writeResult(
|
|
429
|
-
filteredSections,
|
|
430
|
-
separator,
|
|
431
|
-
outFile,
|
|
432
|
-
stdoutFlag,
|
|
433
|
-
dryRun,
|
|
434
|
-
backup
|
|
435
|
-
);
|
|
415
|
+
await writeResult(filteredSections, separator, outFile, stdoutFlag, dryRun, backup);
|
|
436
416
|
const elapsed = getElapsedPerfTime(timer);
|
|
437
417
|
relinka("success", `Merge completed in ${prettyMilliseconds(elapsed)}`);
|
|
438
418
|
}
|