@reliverse/dler 1.7.15 → 1.7.17
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 +164 -191
- package/bin/app/agg/run.js +2 -8
- package/bin/app/build/cmd.js +4 -4
- package/bin/app/build/impl.d.ts +2 -6
- package/bin/app/build/impl.js +2 -46
- package/bin/app/conv/cmd.d.ts +8 -33
- package/bin/app/conv/cmd.js +185 -163
- package/bin/app/copy/cmd.js +1 -1
- package/bin/app/init/init-impl.js +3 -3
- package/bin/app/init/init-types.d.ts +8 -8
- package/bin/app/merge/cmd.d.ts +17 -17
- package/bin/app/merge/cmd.js +70 -310
- package/bin/app/migrate/codemods/anything-bun.js +1 -1
- package/bin/app/migrate/codemods/fs-relifso.d.ts +2 -2
- package/bin/app/migrate/codemods/fs-relifso.js +1 -1
- package/bin/app/migrate/codemods/nodenext-bundler.d.ts +2 -2
- package/bin/app/migrate/codemods/nodenext-bundler.js +1 -1
- package/bin/app/migrate/codemods/path-pathkit.d.ts +2 -2
- package/bin/app/migrate/codemods/path-pathkit.js +1 -1
- package/bin/app/migrate/codemods/readdir-glob.d.ts +2 -2
- package/bin/app/migrate/codemods/readdir-glob.js +1 -1
- package/bin/app/mkdist/cmd.js +4 -2
- package/bin/app/pack/cmd.d.ts +44 -0
- package/bin/app/pack/cmd.js +313 -0
- package/bin/app/pub/cmd.js +4 -4
- package/bin/app/pub/impl.d.ts +7 -0
- package/bin/app/pub/impl.js +97 -0
- package/bin/app/rename/cmd.js +1 -1
- package/bin/app/spell/cmd.d.ts +14 -5
- package/bin/app/spell/cmd.js +33 -33
- package/bin/app/spell/old.js +0 -0
- package/bin/app/{mock → unpack}/cmd.d.ts +10 -14
- package/bin/app/unpack/cmd.js +200 -0
- package/bin/cli.js +2 -2
- package/bin/libs/cfg/cfg-mod.d.ts +69 -0
- package/bin/libs/cfg/cfg-mod.js +61 -0
- package/bin/libs/cfg/rse/rse-impl/rse-biome.d.ts +2 -0
- package/bin/libs/cfg/rse/rse-impl/rse-biome.js +34 -0
- package/bin/libs/cfg/rse/rse-impl/rse-consts.d.ts +35 -0
- package/bin/libs/cfg/rse/rse-impl/rse-consts.js +37 -0
- package/bin/libs/cfg/rse/rse-impl/rse-content.d.ts +14 -0
- package/bin/libs/cfg/rse/rse-impl/rse-content.js +15 -0
- package/bin/libs/cfg/rse/rse-impl/rse-core.d.ts +14 -0
- package/bin/libs/cfg/rse/rse-impl/rse-core.js +63 -0
- package/bin/libs/cfg/rse/rse-impl/rse-create.d.ts +36 -0
- package/bin/libs/cfg/rse/rse-impl/rse-create.js +254 -0
- package/bin/libs/cfg/rse/rse-impl/rse-def-utils.d.ts +6 -0
- package/bin/libs/cfg/rse/rse-impl/rse-def-utils.js +225 -0
- package/bin/libs/cfg/rse/rse-impl/rse-default.d.ts +3 -0
- package/bin/libs/cfg/rse/rse-impl/rse-default.js +155 -0
- package/bin/libs/cfg/rse/rse-impl/rse-define.d.ts +125 -0
- package/bin/libs/cfg/rse/rse-impl/rse-define.js +4 -0
- package/bin/libs/cfg/rse/rse-impl/rse-detect.d.ts +23 -0
- package/bin/libs/cfg/rse/rse-impl/rse-detect.js +347 -0
- package/bin/libs/cfg/rse/rse-impl/rse-gen-cfg.d.ts +3 -0
- package/bin/libs/cfg/rse/rse-impl/rse-gen-cfg.js +186 -0
- package/bin/libs/cfg/rse/rse-impl/rse-inject.d.ts +1 -0
- package/bin/libs/cfg/rse/rse-impl/rse-inject.js +57 -0
- package/bin/libs/cfg/rse/rse-impl/rse-migrate.d.ts +5 -0
- package/bin/libs/cfg/rse/rse-impl/rse-migrate.js +56 -0
- package/bin/libs/cfg/rse/rse-impl/rse-path.d.ts +11 -0
- package/bin/libs/cfg/rse/rse-impl/rse-path.js +33 -0
- package/bin/libs/cfg/rse/rse-impl/rse-prompts.d.ts +5 -0
- package/bin/libs/cfg/rse/rse-impl/rse-prompts.js +12 -0
- package/bin/libs/cfg/rse/rse-impl/rse-read.d.ts +11 -0
- package/bin/libs/cfg/rse/rse-impl/rse-read.js +84 -0
- package/bin/libs/cfg/rse/rse-impl/rse-repair.d.ts +16 -0
- package/bin/libs/cfg/rse/rse-impl/rse-repair.js +137 -0
- package/bin/libs/cfg/rse/rse-impl/rse-schema.d.ts +130 -0
- package/bin/libs/cfg/rse/rse-impl/rse-schema.js +444 -0
- package/bin/libs/cfg/rse/rse-impl/rse-types.d.ts +75 -0
- package/bin/libs/cfg/rse/rse-impl/rse-types.js +0 -0
- package/bin/libs/cfg/rse/rse-impl/rse-unstable.d.ts +11 -0
- package/bin/libs/cfg/rse/rse-impl/rse-unstable.js +41 -0
- package/bin/libs/cfg/rse/rse-impl/rse-update.d.ts +10 -0
- package/bin/libs/cfg/rse/rse-impl/rse-update.js +152 -0
- package/bin/libs/cfg/rse/rse-impl/rse-utils.d.ts +17 -0
- package/bin/libs/cfg/rse/rse-impl/rse-utils.js +86 -0
- package/bin/libs/cfg/rse/rse-mod.d.ts +20 -0
- package/bin/libs/cfg/rse/rse-mod.js +20 -0
- package/bin/libs/cfg/types.d.ts +533 -0
- package/bin/libs/cfg/types.js +0 -0
- package/bin/libs/sdk/sdk-impl/build/build-library.d.ts +5 -5
- package/bin/libs/sdk/sdk-impl/build/build-library.js +1 -174
- package/bin/libs/sdk/sdk-impl/build/build-regular.d.ts +2 -1
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.js +287 -240
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/vue.d.ts +4 -4
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/make.d.ts +8 -5
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/make.js +199 -119
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/spinner.d.ts +99 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/spinner.js +206 -0
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-mod.js +92 -46
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/raw.d.ts +2 -2
- package/bin/libs/sdk/sdk-impl/build/bundlers/unified/utils.d.ts +2 -2
- package/bin/libs/sdk/sdk-impl/config/default.d.ts +6 -0
- package/bin/libs/sdk/sdk-impl/{cfg → config}/default.js +8 -18
- package/bin/libs/sdk/sdk-impl/{cfg → config}/info.js +1 -1
- package/bin/libs/sdk/sdk-impl/{cfg → config}/init.js +53 -43
- package/bin/libs/sdk/sdk-impl/{cfg → config}/load.d.ts +2 -2
- package/bin/libs/sdk/sdk-impl/{cfg → config}/load.js +6 -6
- package/bin/libs/sdk/sdk-impl/config/types.d.ts +533 -0
- package/bin/libs/sdk/sdk-impl/config/types.js +0 -0
- package/bin/libs/sdk/sdk-impl/library-flow.d.ts +2 -1
- package/bin/libs/sdk/sdk-impl/pub/pub-library.js +7 -0
- package/bin/libs/sdk/sdk-impl/pub/pub-regular.js +4 -8
- package/bin/libs/sdk/sdk-impl/regular-flow.d.ts +2 -1
- package/bin/libs/sdk/sdk-impl/rules/reliverse/dler-config-health/dler-config-health.js +2 -2
- package/bin/libs/sdk/sdk-impl/rules/reliverse/missing-deps/deps-types.d.ts +6 -6
- package/bin/libs/sdk/sdk-impl/rules/reliverse/missing-deps/filesystem.js +1 -1
- package/bin/libs/sdk/sdk-impl/rules/reliverse/no-index-files/no-index-files.js +1 -1
- package/bin/libs/sdk/sdk-impl/rules/reliverse/self-include/self-include.js +2 -2
- package/bin/libs/sdk/sdk-impl/spell/applyMagicSpells.d.ts +38 -0
- package/bin/libs/sdk/sdk-impl/spell/applyMagicSpells.js +474 -0
- package/bin/libs/sdk/sdk-impl/spell/spells.d.ts +31 -0
- package/bin/libs/sdk/sdk-impl/spell/spells.js +85 -0
- package/bin/libs/sdk/sdk-impl/utils/binary.js +1 -1
- package/bin/libs/sdk/sdk-impl/utils/comments.d.ts +6 -0
- package/bin/libs/sdk/sdk-impl/utils/comments.js +41 -0
- package/bin/libs/sdk/sdk-impl/utils/finalize.d.ts +2 -1
- package/bin/libs/sdk/sdk-impl/utils/finalize.js +1 -0
- package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-constants.d.ts +6 -0
- package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-constants.js +7 -0
- package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-file-utils.d.ts +5 -0
- package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-file-utils.js +40 -0
- package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-types.d.ts +24 -0
- package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-types.js +0 -0
- package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pub-json-utils.d.ts +17 -0
- package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pub-json-utils.js +46 -0
- package/bin/libs/sdk/sdk-impl/utils/replacements.d.ts +0 -0
- package/bin/libs/sdk/sdk-impl/utils/replacements.js +0 -0
- package/bin/libs/sdk/sdk-impl/utils/resolve-cross-libs.d.ts +3 -0
- package/bin/libs/sdk/sdk-impl/utils/resolve-cross-libs.js +194 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-build.d.ts +1 -2
- package/bin/libs/sdk/sdk-impl/utils/utils-clean.d.ts +1 -1
- package/bin/libs/sdk/sdk-impl/utils/utils-deps.d.ts +1 -1
- package/bin/libs/sdk/sdk-impl/utils/utils-determine.d.ts +1 -1
- package/bin/libs/sdk/sdk-impl/utils/utils-error-cwd.d.ts +4 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-error-cwd.js +1 -0
- package/bin/libs/sdk/sdk-impl/utils/utils-jsr-json.d.ts +1 -1
- package/bin/libs/sdk/sdk-impl/utils/utils-package-json-libraries.d.ts +1 -1
- package/bin/libs/sdk/sdk-impl/utils/utils-package-json-regular.d.ts +1 -1
- package/bin/libs/sdk/sdk-impl/utils/utils-security.d.ts +1 -3
- package/bin/libs/sdk/sdk-impl/utils/utils-security.js +11 -10
- package/bin/libs/sdk/sdk-mod.d.ts +1 -6
- package/bin/libs/sdk/sdk-mod.js +0 -31
- package/bin/libs/sdk/sdk-types.d.ts +39 -582
- package/bin/mod.d.ts +1 -1
- package/bin/mod.js +1 -1
- package/package.json +11 -4
- package/bin/app/mock/cmd.js +0 -284
- package/bin/app/mock/mock.d.ts +0 -11
- package/bin/app/mock/mock.js +0 -97
- package/bin/libs/sdk/sdk-impl/cfg/default.d.ts +0 -5
- package/bin/libs/sdk/sdk-impl/cfg/define.d.ts +0 -2
- package/bin/libs/sdk/sdk-impl/cfg/define.js +0 -4
- package/bin/libs/sdk/sdk-impl/spell/spell-executors.d.ts +0 -10
- package/bin/libs/sdk/sdk-impl/spell/spell-executors.js +0 -307
- package/bin/libs/sdk/sdk-impl/spell/spell-filesystem.d.ts +0 -7
- package/bin/libs/sdk/sdk-impl/spell/spell-filesystem.js +0 -74
- package/bin/libs/sdk/sdk-impl/spell/spell-mod.d.ts +0 -4
- package/bin/libs/sdk/sdk-impl/spell/spell-mod.js +0 -87
- package/bin/libs/sdk/sdk-impl/spell/spell-parser.d.ts +0 -4
- package/bin/libs/sdk/sdk-impl/spell/spell-parser.js +0 -58
- package/bin/libs/sdk/sdk-impl/spell/spell-types.d.ts +0 -60
- /package/bin/{libs/sdk/sdk-impl/spell/spell-types.js → app/spell/old.d.ts} +0 -0
- /package/bin/libs/sdk/sdk-impl/{cfg → config}/info.d.ts +0 -0
- /package/bin/libs/sdk/sdk-impl/{cfg → config}/init.d.ts +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const DEFAULT_COMMENT = "// ";
|
|
2
|
+
const createCommentMapping = (extensions, comment) => Object.fromEntries(extensions.map((ext) => [ext, comment]));
|
|
3
|
+
export const COMMENT_MAP = {
|
|
4
|
+
// Single-line comment style //
|
|
5
|
+
...createCommentMapping(
|
|
6
|
+
[
|
|
7
|
+
"js",
|
|
8
|
+
"jsx",
|
|
9
|
+
"ts",
|
|
10
|
+
"tsx",
|
|
11
|
+
"c",
|
|
12
|
+
"cpp",
|
|
13
|
+
"h",
|
|
14
|
+
"java",
|
|
15
|
+
"go",
|
|
16
|
+
"kt",
|
|
17
|
+
"swift",
|
|
18
|
+
"rs",
|
|
19
|
+
"cs",
|
|
20
|
+
"json",
|
|
21
|
+
"proto",
|
|
22
|
+
"dart",
|
|
23
|
+
"inc",
|
|
24
|
+
"pwn"
|
|
25
|
+
],
|
|
26
|
+
"// "
|
|
27
|
+
),
|
|
28
|
+
// Single-line comment style #
|
|
29
|
+
...createCommentMapping(["py", "rb", "sh", "pl", "r", "yml", "yaml"], "# "),
|
|
30
|
+
// Single-line comment style --
|
|
31
|
+
...createCommentMapping(["sql", "lua"], "-- "),
|
|
32
|
+
// Multi-line comment style /* */
|
|
33
|
+
...createCommentMapping(["css", "scss", "less"], "/* "),
|
|
34
|
+
// Multi-line comment style <!-- -->
|
|
35
|
+
...createCommentMapping(["html", "htm", "xml", "md"], "<!-- ")
|
|
36
|
+
};
|
|
37
|
+
export const getCommentPrefix = (filePath, forceComment, customComment) => {
|
|
38
|
+
if (forceComment && customComment) return customComment;
|
|
39
|
+
const ext = filePath.split(".").pop()?.toLowerCase();
|
|
40
|
+
return COMMENT_MAP[ext] ?? customComment ?? DEFAULT_COMMENT;
|
|
41
|
+
};
|
|
@@ -19,6 +19,7 @@ export async function finalizeBuildPub(timer, commonPubPause, libsList, distNpmD
|
|
|
19
19
|
if (!commonPubPause) {
|
|
20
20
|
relinka("success", `\u{1F389} Publish completed successfully (build time: ${transpileFormattedTime})`);
|
|
21
21
|
} else {
|
|
22
|
+
console.log("-".repeat(50));
|
|
22
23
|
relinka("success", `\u{1F389} Build completed successfully (done in: ${transpileFormattedTime})`);
|
|
23
24
|
relinka("info", "\u{1F4DD} Publish process is currently paused in your config file");
|
|
24
25
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const WHITELABEL_DEFAULT = "DLER";
|
|
2
|
+
export declare const JSON_EXTS: Set<string>;
|
|
3
|
+
export declare const TEMPLATE_VAR: (tpl: string, wl: string) => string;
|
|
4
|
+
export declare const TPLS_DIR = "tpls";
|
|
5
|
+
export declare const BINARIES_DIR = "binaries";
|
|
6
|
+
export declare const isJsonExt: (f: string) => boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import path from "@reliverse/pathkit";
|
|
2
|
+
export const WHITELABEL_DEFAULT = "DLER";
|
|
3
|
+
export const JSON_EXTS = /* @__PURE__ */ new Set(["json", "jsonc", "json5", "jsonl"]);
|
|
4
|
+
export const TEMPLATE_VAR = (tpl, wl) => `${tpl.toUpperCase()}_${wl.toUpperCase()}_TEMPLATE`;
|
|
5
|
+
export const TPLS_DIR = "tpls";
|
|
6
|
+
export const BINARIES_DIR = "binaries";
|
|
7
|
+
export const isJsonExt = (f) => JSON_EXTS.has(path.extname(f).slice(1).toLowerCase());
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FileType, TemplatesFileContent } from "./pu-types";
|
|
2
|
+
export declare const walkDir: (dir: string) => Promise<string[]>;
|
|
3
|
+
export declare const detectFileType: (file: string) => Promise<FileType>;
|
|
4
|
+
export declare const readFileForTemplate: (absPath: string) => Promise<TemplatesFileContent>;
|
|
5
|
+
export declare const escapeTemplateString: (src: string) => string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import path from "@reliverse/pathkit";
|
|
2
|
+
import { promises as fs } from "node:fs";
|
|
3
|
+
import { isBinaryExt } from "../binary.js";
|
|
4
|
+
import { isJsonExt } from "./pu-constants.js";
|
|
5
|
+
import { extractJsonComments, stripComments } from "./pub-json-utils.js";
|
|
6
|
+
export const walkDir = async (dir) => {
|
|
7
|
+
const entries = [];
|
|
8
|
+
for (const entry of await fs.readdir(dir, { withFileTypes: true })) {
|
|
9
|
+
const full = path.join(dir, entry.name);
|
|
10
|
+
if (entry.isDirectory()) {
|
|
11
|
+
entries.push(...await walkDir(full));
|
|
12
|
+
} else {
|
|
13
|
+
entries.push(full);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return entries;
|
|
17
|
+
};
|
|
18
|
+
export const detectFileType = async (file) => {
|
|
19
|
+
if (await isBinaryExt(file)) return "binary";
|
|
20
|
+
if (isJsonExt(file)) return "json";
|
|
21
|
+
return "text";
|
|
22
|
+
};
|
|
23
|
+
export const readFileForTemplate = async (absPath) => {
|
|
24
|
+
const type = await detectFileType(absPath);
|
|
25
|
+
try {
|
|
26
|
+
if (type === "binary") {
|
|
27
|
+
return { type, content: "" };
|
|
28
|
+
}
|
|
29
|
+
const data = await fs.readFile(absPath, "utf8");
|
|
30
|
+
if (type === "json") {
|
|
31
|
+
const jsonComments = extractJsonComments(data);
|
|
32
|
+
const json = JSON.parse(stripComments(data));
|
|
33
|
+
return { type, content: json, jsonComments };
|
|
34
|
+
}
|
|
35
|
+
return { type, content: data };
|
|
36
|
+
} catch {
|
|
37
|
+
return { type, content: "", hasError: true };
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
export const escapeTemplateString = (src) => src.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${");
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type FileContent = string | Record<string, unknown>;
|
|
2
|
+
export type FileType = "text" | "json" | "binary";
|
|
3
|
+
export interface FileMetadata {
|
|
4
|
+
updatedAt: string;
|
|
5
|
+
updatedHash: string;
|
|
6
|
+
}
|
|
7
|
+
export interface TemplatesFileContent {
|
|
8
|
+
content: FileContent;
|
|
9
|
+
type: FileType;
|
|
10
|
+
hasError?: boolean;
|
|
11
|
+
jsonComments?: Record<number, string>;
|
|
12
|
+
binaryHash?: string;
|
|
13
|
+
metadata?: FileMetadata;
|
|
14
|
+
}
|
|
15
|
+
export interface TemplateConfig {
|
|
16
|
+
files: Record<string, TemplatesFileContent>;
|
|
17
|
+
}
|
|
18
|
+
export interface Template {
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
config: TemplateConfig;
|
|
22
|
+
updatedAt: string;
|
|
23
|
+
}
|
|
24
|
+
export type Templates = Record<string, Template>;
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for reading / writing JSON-with-comments files while
|
|
3
|
+
* preserving (or later reinjecting) on–line and block comments.
|
|
4
|
+
*
|
|
5
|
+
* Supported comment styles:
|
|
6
|
+
* // single-line
|
|
7
|
+
* /* … *\/
|
|
8
|
+
* /** … *\/
|
|
9
|
+
*/
|
|
10
|
+
export declare const extractJsonComments: (raw: string) => Record<number, string> | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Very small "strip comments" helper:
|
|
13
|
+
* removes // … and /* … *\/ (including multi-line).
|
|
14
|
+
* This is intentionally simple; for complex JSONC we may want
|
|
15
|
+
* use something like `strip-json-comments` in the future.
|
|
16
|
+
*/
|
|
17
|
+
export declare const stripComments: (raw: string) => string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export const extractJsonComments = (raw) => {
|
|
2
|
+
const out = {};
|
|
3
|
+
const lines = raw.split("\n");
|
|
4
|
+
for (let i = 0; i < lines.length; ) {
|
|
5
|
+
const line = lines[i];
|
|
6
|
+
if (!line) {
|
|
7
|
+
i += 1;
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
10
|
+
const trimmed = line.trimStart();
|
|
11
|
+
const indent = line.length - trimmed.length;
|
|
12
|
+
if (trimmed.startsWith("//")) {
|
|
13
|
+
out[i + 1] = trimmed.slice(2).trimStart();
|
|
14
|
+
i += 1;
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
if (trimmed.startsWith("/*")) {
|
|
18
|
+
const isSupported = trimmed.startsWith("/**") || trimmed.startsWith("/*");
|
|
19
|
+
if (!isSupported) {
|
|
20
|
+
i += 1;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const buff = [trimmed];
|
|
24
|
+
let j = i + 1;
|
|
25
|
+
while (j < lines.length) {
|
|
26
|
+
const currentLine = lines[j];
|
|
27
|
+
if (!currentLine) {
|
|
28
|
+
j += 1;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (currentLine.trimEnd().endsWith("*/")) {
|
|
32
|
+
buff.push(currentLine.slice(indent));
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
buff.push(currentLine.slice(indent));
|
|
36
|
+
j += 1;
|
|
37
|
+
}
|
|
38
|
+
out[i + 1] = buff.join("\n");
|
|
39
|
+
i = j + 1;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
i += 1;
|
|
43
|
+
}
|
|
44
|
+
return Object.keys(out).length ? out : void 0;
|
|
45
|
+
};
|
|
46
|
+
export const stripComments = (raw) => raw.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/[^\r\n]*/g, "");
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare function resolveCrossLibs(libBinDir: string, alias?: string, subFolders?: ("npm" | "jsr")[]): Promise<string[]>;
|
|
2
|
+
declare function resolveAllCrossLibs(alias?: string, subFolders?: ("npm" | "jsr")[]): Promise<string[]>;
|
|
3
|
+
export { resolveCrossLibs, resolveAllCrossLibs };
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { relinka } from "@reliverse/relinka";
|
|
2
|
+
import { promises as fs } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
const PROCESS_DTS_FILES = true;
|
|
5
|
+
async function resolveCrossLibs(libBinDir, alias = "~", subFolders = ["npm", "jsr"]) {
|
|
6
|
+
const normalizedPath = libBinDir.replace(/\\/g, "/");
|
|
7
|
+
if (!normalizedPath.startsWith("dist-libs") && !normalizedPath.startsWith("dist-jsr") && !normalizedPath.startsWith("dist-npm")) {
|
|
8
|
+
throw new Error(
|
|
9
|
+
`[resolve-cross-libs] libBinDir must start with "dist-libs", "dist-jsr", or "dist-npm", got: ${libBinDir}`
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
if (normalizedPath.startsWith("dist-libs")) {
|
|
13
|
+
const pathParts = normalizedPath.replace(/\/$/, "").split("/");
|
|
14
|
+
if (pathParts.length < 4) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
`[resolve-cross-libs] Invalid libBinDir structure: ${libBinDir}, expected dist-libs/<lib>/<subfolder>/bin`
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
const currentLib = pathParts[1];
|
|
20
|
+
const files = await findSourceFiles(libBinDir);
|
|
21
|
+
const modifiedFiles = [];
|
|
22
|
+
await Promise.all(
|
|
23
|
+
files.map(async (filePath) => {
|
|
24
|
+
const content = await fs.readFile(filePath, "utf-8");
|
|
25
|
+
const processed = await processFile(content, currentLib, alias, subFolders, filePath);
|
|
26
|
+
if (processed !== content) {
|
|
27
|
+
relinka("log", `[resolve-cross-libs] File modified: ${filePath}`);
|
|
28
|
+
await fs.writeFile(filePath, processed, "utf-8");
|
|
29
|
+
modifiedFiles.push(path.resolve(filePath));
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
);
|
|
33
|
+
return modifiedFiles;
|
|
34
|
+
}
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
async function findSourceFiles(dir) {
|
|
38
|
+
const files = [];
|
|
39
|
+
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
40
|
+
await Promise.all(
|
|
41
|
+
entries.map(async (entry) => {
|
|
42
|
+
const fullPath = path.join(dir, entry.name);
|
|
43
|
+
if (entry.isDirectory()) {
|
|
44
|
+
const subFiles = await findSourceFiles(fullPath);
|
|
45
|
+
files.push(...subFiles);
|
|
46
|
+
} else if (entry.isFile()) {
|
|
47
|
+
const ext = path.extname(entry.name);
|
|
48
|
+
const isDts = entry.name.endsWith(".d.ts");
|
|
49
|
+
if (ext === ".js" || ext === ".ts" && !isDts || PROCESS_DTS_FILES && isDts) {
|
|
50
|
+
files.push(fullPath);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
);
|
|
55
|
+
return files;
|
|
56
|
+
}
|
|
57
|
+
function escapeRegex(str) {
|
|
58
|
+
if (!str || typeof str !== "string") {
|
|
59
|
+
return "";
|
|
60
|
+
}
|
|
61
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
62
|
+
}
|
|
63
|
+
async function processFile(content, currentLib, alias, subFolders, currentFilePath) {
|
|
64
|
+
const lines = content.split("\n");
|
|
65
|
+
const result = [];
|
|
66
|
+
let insideInlined = false;
|
|
67
|
+
for (const line of lines) {
|
|
68
|
+
if (line.includes("/* inlined-start ")) {
|
|
69
|
+
insideInlined = true;
|
|
70
|
+
relinka("log", `[resolve-cross-libs] Entering inlined block: ${line.trim()}`);
|
|
71
|
+
result.push(line);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (line.includes("/* inlined-end */")) {
|
|
75
|
+
insideInlined = false;
|
|
76
|
+
result.push(line);
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (insideInlined) {
|
|
80
|
+
result.push(line);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
const pattern = new RegExp(
|
|
84
|
+
`^(\\s*)((?:export\\s+.*?\\s+from|import\\s+.*?\\s+from)\\s+(['"])${escapeRegex(alias)}/libs/([^/]+)/([^'"]*?)\\3[^;]*;?)(\\s*//.*)?\\s*$`
|
|
85
|
+
);
|
|
86
|
+
const match = line.match(pattern);
|
|
87
|
+
if (match) {
|
|
88
|
+
const [, indentation, fullStatement, quote, libName, rest, comment] = match;
|
|
89
|
+
relinka("log", `[resolve-cross-libs] Processing import/export: ${libName}/${rest}`);
|
|
90
|
+
if (fullStatement?.includes(`${quote}./`)) {
|
|
91
|
+
result.push(line);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (libName === currentLib) {
|
|
95
|
+
const newStatement = fullStatement?.replace(`${quote}${alias}/libs/${libName}/`, `${quote}./`) ?? "";
|
|
96
|
+
result.push(`${indentation}${newStatement}${comment || ""}`);
|
|
97
|
+
} else {
|
|
98
|
+
try {
|
|
99
|
+
if (!libName || !rest) {
|
|
100
|
+
throw new Error("Library name or path is undefined");
|
|
101
|
+
}
|
|
102
|
+
relinka("log", `[resolve-cross-libs] Attempting to inline: ${libName}/${rest}`);
|
|
103
|
+
const targetPath = await resolveTargetFile(libName, rest, subFolders, currentFilePath);
|
|
104
|
+
const targetContent = await fs.readFile(targetPath, "utf-8");
|
|
105
|
+
result.push(`${indentation}/* inlined-start ${alias}/libs/${libName}/${rest} */`);
|
|
106
|
+
const targetLines = targetContent.split("\n");
|
|
107
|
+
relinka(
|
|
108
|
+
"log",
|
|
109
|
+
`[resolve-cross-libs] Inlining ${targetLines.length} lines from ${targetPath}`
|
|
110
|
+
);
|
|
111
|
+
for (const targetLine of targetLines) {
|
|
112
|
+
result.push(`${indentation}${targetLine}`);
|
|
113
|
+
}
|
|
114
|
+
result.push(`${indentation}/* inlined-end */`);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
117
|
+
relinka(
|
|
118
|
+
"error",
|
|
119
|
+
`[resolve-cross-libs] Failed to inline ${alias}/libs/${libName}/${rest}: ${errorMessage}`
|
|
120
|
+
);
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
result.push(line);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return result.join("\n");
|
|
129
|
+
}
|
|
130
|
+
async function resolveTargetFile(libName, rest, subFolders, currentFilePath) {
|
|
131
|
+
relinka("log", `[resolve-cross-libs] Resolving target file for ${libName}/${rest}`);
|
|
132
|
+
const isCurrentFileDts = currentFilePath.endsWith(".d.ts");
|
|
133
|
+
const extensions = isCurrentFileDts ? [".d.ts", ".ts", ".js"] : [".ts", ".js", ".d.ts"];
|
|
134
|
+
for (const subFolder of subFolders) {
|
|
135
|
+
const basePath = path.join("dist-libs", libName, subFolder, "bin", rest);
|
|
136
|
+
for (const ext of extensions) {
|
|
137
|
+
const fullPath = `${basePath}${ext}`;
|
|
138
|
+
try {
|
|
139
|
+
await fs.access(fullPath);
|
|
140
|
+
return fullPath;
|
|
141
|
+
} catch {
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
throw new Error(
|
|
146
|
+
`Could not resolve target file for libs/${libName}/${rest} in any subfolder: ${subFolders.join(", ")}`
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
async function directoryExists(dirPath) {
|
|
150
|
+
try {
|
|
151
|
+
const stat = await fs.stat(dirPath);
|
|
152
|
+
return stat.isDirectory();
|
|
153
|
+
} catch (error) {
|
|
154
|
+
if (error instanceof Error && error.code === "ENOENT") {
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
async function resolveAllCrossLibs(alias = "~", subFolders = ["npm", "jsr"]) {
|
|
161
|
+
const distLibsDir = "dist-libs";
|
|
162
|
+
const allModifiedFiles = [];
|
|
163
|
+
const distLibsExists = await directoryExists(distLibsDir);
|
|
164
|
+
if (distLibsExists) {
|
|
165
|
+
const entries = await fs.readdir(distLibsDir, { withFileTypes: true });
|
|
166
|
+
const libDirs = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
167
|
+
await Promise.all(
|
|
168
|
+
libDirs.map(async (libName) => {
|
|
169
|
+
for (const subFolder of subFolders) {
|
|
170
|
+
const binDir = path.join(distLibsDir, libName, subFolder, "bin");
|
|
171
|
+
const binDirExists = await directoryExists(binDir);
|
|
172
|
+
if (binDirExists) {
|
|
173
|
+
try {
|
|
174
|
+
const modifiedFiles = await resolveCrossLibs(binDir, alias, subFolders);
|
|
175
|
+
allModifiedFiles.push(...modifiedFiles);
|
|
176
|
+
} catch (error) {
|
|
177
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
178
|
+
relinka("error", `[resolveAllCrossLibs] Error processing ${binDir}: ${errorMessage}`);
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
} else {
|
|
182
|
+
relinka("error", `[resolveAllCrossLibs] Bin directory does not exist: ${binDir}`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
})
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
if (allModifiedFiles.length > 0) {
|
|
189
|
+
relinka("info", "[resolveAllCrossLibs] Cross libraries replacements done in:");
|
|
190
|
+
relinka("log", "[resolveAllCrossLibs] " + allModifiedFiles.join(", "));
|
|
191
|
+
}
|
|
192
|
+
return allModifiedFiles;
|
|
193
|
+
}
|
|
194
|
+
export { resolveCrossLibs, resolveAllCrossLibs };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { NpmOutExt, Sourcemap } from "
|
|
2
|
-
import type { DlerConfig } from "../../sdk-types.js";
|
|
1
|
+
import type { DlerConfig, NpmOutExt, Sourcemap } from "../config/types.js";
|
|
3
2
|
/**
|
|
4
3
|
* Converts the Unified build sourcemap option to a Bun-friendly value.
|
|
5
4
|
* @param transpileSourcemap - The sourcemap configuration ('none', 'inline', 'linked', 'external', true, false).
|
|
@@ -13,3 +13,7 @@ export declare function withWorkingDirectory<T>(transpileTargetDir: string, fn:
|
|
|
13
13
|
* Throws an error if the current directory does not contain any of the required paths.
|
|
14
14
|
*/
|
|
15
15
|
export declare function validateDevCwd(isDev: boolean, paths: string[], cliName: string, cliOrg?: string): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Converts unknown errors to readable strings.
|
|
18
|
+
*/
|
|
19
|
+
export declare const formatError: (error: unknown) => string;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
export declare const MAX_MERGE_SIZE: number;
|
|
1
|
+
export declare const setFileSizeLimits: (maxFileSize?: number, maxMergeSize?: number) => void;
|
|
3
2
|
export declare const ALLOWED_FILE_TYPES: Set<string>;
|
|
4
|
-
export declare const checkRateLimit: (operation: string, limit?: number) => void;
|
|
5
3
|
export declare const validatePath: (filePath: string, baseDir: string) => string;
|
|
6
4
|
export declare const validateFileType: (type: string) => void;
|
|
7
5
|
export declare const validateContent: (content: unknown, type: string) => void;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import path from "@reliverse/pathkit";
|
|
2
2
|
import fs from "@reliverse/relifso";
|
|
3
3
|
import { relinka } from "@reliverse/relinka";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
const DEFAULT_MAX_FILE_SIZE = 10 * 1024 * 1024;
|
|
5
|
+
const DEFAULT_MAX_MERGE_SIZE = DEFAULT_MAX_FILE_SIZE * 10;
|
|
6
|
+
let MAX_FILE_SIZE = DEFAULT_MAX_FILE_SIZE;
|
|
7
|
+
let MAX_MERGE_SIZE = DEFAULT_MAX_MERGE_SIZE;
|
|
8
|
+
export const setFileSizeLimits = (maxFileSize, maxMergeSize) => {
|
|
9
|
+
if (maxFileSize !== void 0) {
|
|
10
|
+
MAX_FILE_SIZE = maxFileSize;
|
|
11
|
+
}
|
|
12
|
+
if (maxMergeSize !== void 0) {
|
|
13
|
+
MAX_MERGE_SIZE = maxMergeSize;
|
|
13
14
|
}
|
|
14
|
-
rateLimiter.set(operation, now);
|
|
15
15
|
};
|
|
16
|
+
export const ALLOWED_FILE_TYPES = /* @__PURE__ */ new Set(["text", "json", "binary"]);
|
|
16
17
|
export const validatePath = (filePath, baseDir) => {
|
|
17
18
|
const normalizedPath = path.normalize(filePath);
|
|
18
19
|
const normalizedBaseDir = path.normalize(baseDir);
|
|
@@ -23,16 +23,11 @@ export { processLibraryFlow, libraries_buildPublish, } from "./sdk-impl/library-
|
|
|
23
23
|
export { library_publishLibrary } from "./sdk-impl/pub/pub-library";
|
|
24
24
|
export { regular_pubToJsr, regular_pubToNpm, } from "./sdk-impl/pub/pub-regular";
|
|
25
25
|
export { processRegularFlow } from "./sdk-impl/regular-flow";
|
|
26
|
-
export { replaceLineExecutor, renameFileExecutor, removeCommentExecutor, removeLineExecutor, removeFileExecutor, copyFileExecutor, moveFileExecutor, transformContentExecutor, insertAtExecutor, } from "./sdk-impl/spell/spell-executors";
|
|
27
|
-
export { fileExists, readFile, writeFile, removeFile, renameFile, copyFile, findFiles, } from "./sdk-impl/spell/spell-filesystem";
|
|
28
|
-
export { executeSpell, processFile, spells, } from "./sdk-impl/spell/spell-mod";
|
|
29
|
-
export { parseParams, parseSpellFromComment, extractSpellsFromFile, } from "./sdk-impl/spell/spell-parser";
|
|
30
|
-
export type { SpellType, SpellParams, Spell, SpellExecutionOptions, FileOperation, SpellResult, } from "./sdk-impl/spell/spell-types";
|
|
31
26
|
export { useAggregator } from "./sdk-impl/utils/tools-agg";
|
|
32
27
|
export { printUsage } from "./sdk-impl/utils/tools-impl";
|
|
33
28
|
export { getBunSourcemapOption, getUnifiedSourcemapOption, renameEntryFile, } from "./sdk-impl/utils/utils-build";
|
|
34
29
|
export { removeDistFolders } from "./sdk-impl/utils/utils-clean";
|
|
35
|
-
export { PROJECT_ROOT, CONCURRENCY_DEFAULT,
|
|
30
|
+
export { PROJECT_ROOT, CONCURRENCY_DEFAULT, cliDomainDocs, validExtensions, SHOW_VERBOSE, } from "./sdk-impl/utils/utils-consts";
|
|
36
31
|
export { validateDevCwd, withWorkingDirectory, } from "./sdk-impl/utils/utils-error-cwd";
|
|
37
32
|
export { filterDeps } from "./sdk-impl/utils/utils-deps";
|
|
38
33
|
export { determineDistName } from "./sdk-impl/utils/utils-determine";
|
package/bin/libs/sdk/sdk-mod.js
CHANGED
|
@@ -59,36 +59,6 @@ export {
|
|
|
59
59
|
regular_pubToNpm
|
|
60
60
|
} from "./sdk-impl/pub/pub-regular.js";
|
|
61
61
|
export { processRegularFlow } from "./sdk-impl/regular-flow.js";
|
|
62
|
-
export {
|
|
63
|
-
replaceLineExecutor,
|
|
64
|
-
renameFileExecutor,
|
|
65
|
-
removeCommentExecutor,
|
|
66
|
-
removeLineExecutor,
|
|
67
|
-
removeFileExecutor,
|
|
68
|
-
copyFileExecutor,
|
|
69
|
-
moveFileExecutor,
|
|
70
|
-
transformContentExecutor,
|
|
71
|
-
insertAtExecutor
|
|
72
|
-
} from "./sdk-impl/spell/spell-executors.js";
|
|
73
|
-
export {
|
|
74
|
-
fileExists,
|
|
75
|
-
readFile,
|
|
76
|
-
writeFile,
|
|
77
|
-
removeFile,
|
|
78
|
-
renameFile,
|
|
79
|
-
copyFile,
|
|
80
|
-
findFiles
|
|
81
|
-
} from "./sdk-impl/spell/spell-filesystem.js";
|
|
82
|
-
export {
|
|
83
|
-
executeSpell,
|
|
84
|
-
processFile,
|
|
85
|
-
spells
|
|
86
|
-
} from "./sdk-impl/spell/spell-mod.js";
|
|
87
|
-
export {
|
|
88
|
-
parseParams,
|
|
89
|
-
parseSpellFromComment,
|
|
90
|
-
extractSpellsFromFile
|
|
91
|
-
} from "./sdk-impl/spell/spell-parser.js";
|
|
92
62
|
export { useAggregator } from "./sdk-impl/utils/tools-agg.js";
|
|
93
63
|
export { printUsage } from "./sdk-impl/utils/tools-impl.js";
|
|
94
64
|
export {
|
|
@@ -100,7 +70,6 @@ export { removeDistFolders } from "./sdk-impl/utils/utils-clean.js";
|
|
|
100
70
|
export {
|
|
101
71
|
PROJECT_ROOT,
|
|
102
72
|
CONCURRENCY_DEFAULT,
|
|
103
|
-
tsconfigJson,
|
|
104
73
|
cliDomainDocs,
|
|
105
74
|
validExtensions,
|
|
106
75
|
SHOW_VERBOSE
|