@reliverse/dler 1.7.16 → 1.7.18
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 +134 -206
- 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 +10 -24
- package/bin/app/merge/cmd.js +47 -464
- 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/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 +12 -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
package/bin/mod.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { defineConfigDler } from "./libs/sdk/sdk-impl/config/default";
|
package/bin/mod.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { defineConfigDler } from "./libs/sdk/sdk-impl/config/default.js";
|
package/package.json
CHANGED
|
@@ -1,29 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
3
|
"@reliverse/bleump": "^1.1.4",
|
|
4
|
-
"@reliverse/pathkit": "^1.2
|
|
4
|
+
"@reliverse/pathkit": "^1.3.2",
|
|
5
5
|
"@reliverse/reglob": "^1.0.0",
|
|
6
6
|
"@reliverse/relico": "^1.1.2",
|
|
7
7
|
"@reliverse/relifso": "^1.4.5",
|
|
8
8
|
"@reliverse/relinka": "^1.4.7",
|
|
9
|
-
"@reliverse/rempts": "^1.7.
|
|
9
|
+
"@reliverse/rempts": "^1.7.24",
|
|
10
|
+
"@reliverse/runtime": "^1.0.3",
|
|
10
11
|
"@rollup/plugin-alias": "^5.1.1",
|
|
11
12
|
"@rollup/plugin-commonjs": "^28.0.3",
|
|
12
13
|
"@rollup/plugin-json": "^6.1.0",
|
|
13
14
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
14
15
|
"@rollup/plugin-replace": "^6.0.2",
|
|
15
16
|
"@rollup/pluginutils": "^5.1.4",
|
|
17
|
+
"@sinclair/typebox": "^0.34.33",
|
|
16
18
|
"autoprefixer": "^10.4.21",
|
|
19
|
+
"c12": "^3.0.4",
|
|
20
|
+
"confbox": "^0.2.2",
|
|
17
21
|
"cssnano": "^7.0.7",
|
|
18
22
|
"defu": "^6.1.4",
|
|
23
|
+
"destr": "^2.0.5",
|
|
19
24
|
"esbuild": "^0.25.5",
|
|
20
25
|
"execa": "^9.6.0",
|
|
21
26
|
"file-type": "^21.0.0",
|
|
22
27
|
"fix-dts-default-cjs-exports": "^1.0.1",
|
|
23
28
|
"hookable": "^5.5.3",
|
|
24
29
|
"jiti": "^2.4.2",
|
|
30
|
+
"jsonrepair": "^3.12.0",
|
|
25
31
|
"magic-string": "^0.30.17",
|
|
26
32
|
"mlly": "^1.7.4",
|
|
33
|
+
"nypm": "^0.6.0",
|
|
34
|
+
"ora": "^8.2.0",
|
|
27
35
|
"p-all": "^5.0.0",
|
|
28
36
|
"p-map": "^7.0.3",
|
|
29
37
|
"pkg-types": "^2.1.0",
|
|
@@ -31,7 +39,7 @@
|
|
|
31
39
|
"postcss-nested": "^7.0.2",
|
|
32
40
|
"pretty-bytes": "^7.0.0",
|
|
33
41
|
"pretty-ms": "^9.2.0",
|
|
34
|
-
"rollup": "^4.
|
|
42
|
+
"rollup": "^4.42.0",
|
|
35
43
|
"rollup-plugin-dts": "^6.2.1",
|
|
36
44
|
"scule": "^1.3.0",
|
|
37
45
|
"semver": "^7.7.2",
|
|
@@ -44,7 +52,7 @@
|
|
|
44
52
|
"license": "MIT",
|
|
45
53
|
"name": "@reliverse/dler",
|
|
46
54
|
"type": "module",
|
|
47
|
-
"version": "1.7.
|
|
55
|
+
"version": "1.7.18",
|
|
48
56
|
"keywords": [
|
|
49
57
|
"reliverse",
|
|
50
58
|
"cli",
|
package/bin/app/mock/cmd.js
DELETED
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
import path from "@reliverse/pathkit";
|
|
2
|
-
import fs from "@reliverse/relifso";
|
|
3
|
-
import { relinka } from "@reliverse/relinka";
|
|
4
|
-
import { defineCommand } from "@reliverse/rempts";
|
|
5
|
-
import { createJiti } from "jiti";
|
|
6
|
-
import prettyMilliseconds from "pretty-ms";
|
|
7
|
-
import { isBinaryExt } from "../../libs/sdk/sdk-impl/utils/binary.js";
|
|
8
|
-
import { createPerfTimer, getElapsedPerfTime } from "../../libs/sdk/sdk-impl/utils/utils-perf.js";
|
|
9
|
-
import {
|
|
10
|
-
validatePath,
|
|
11
|
-
validateFileType,
|
|
12
|
-
validateContent,
|
|
13
|
-
checkPermissions,
|
|
14
|
-
handleError,
|
|
15
|
-
validateTemplate,
|
|
16
|
-
checkRateLimit,
|
|
17
|
-
sanitizeInput
|
|
18
|
-
} from "../../libs/sdk/sdk-impl/utils/utils-security.js";
|
|
19
|
-
import { DLER_TEMPLATES, dlerTemplatesMap } from "./mock.js";
|
|
20
|
-
const jiti = createJiti(import.meta.url);
|
|
21
|
-
async function writeFile(filePath, file, dryRun) {
|
|
22
|
-
try {
|
|
23
|
-
const { content, type } = file;
|
|
24
|
-
validateFileType(type);
|
|
25
|
-
validateContent(content, type);
|
|
26
|
-
const sanitizedPath = sanitizeInput(filePath);
|
|
27
|
-
checkRateLimit(`write_${sanitizedPath}`);
|
|
28
|
-
if (dryRun) {
|
|
29
|
-
relinka("log", `[DRY RUN] Would write file: ${sanitizedPath}`);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const isBinary = await isBinaryExt(sanitizedPath);
|
|
33
|
-
if (isBinary && type !== "binary") {
|
|
34
|
-
relinka(
|
|
35
|
-
"warn",
|
|
36
|
-
`Warning: File ${sanitizedPath} appears to be binary but is not marked as such in template`
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
await checkPermissions(sanitizedPath, "write");
|
|
40
|
-
if (type === "json") {
|
|
41
|
-
await fs.writeJson(sanitizedPath, content, { spaces: 2 });
|
|
42
|
-
} else {
|
|
43
|
-
await fs.writeFile(sanitizedPath, content, "utf8");
|
|
44
|
-
}
|
|
45
|
-
} catch (error) {
|
|
46
|
-
handleError(error, `writeFile(${filePath})`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
async function createMockStructure(template, dryRun) {
|
|
50
|
-
try {
|
|
51
|
-
validateTemplate(template);
|
|
52
|
-
const normalizePath = (filePath) => {
|
|
53
|
-
return validatePath(filePath, process.cwd());
|
|
54
|
-
};
|
|
55
|
-
await Promise.all(
|
|
56
|
-
Object.entries(template.config.files).map(async ([filePath, file]) => {
|
|
57
|
-
const normalizedPath = normalizePath(filePath);
|
|
58
|
-
if (!dryRun) {
|
|
59
|
-
await fs.ensureDir(path.dirname(normalizedPath));
|
|
60
|
-
}
|
|
61
|
-
await writeFile(normalizedPath, file, dryRun);
|
|
62
|
-
})
|
|
63
|
-
);
|
|
64
|
-
if (!dryRun) {
|
|
65
|
-
relinka(
|
|
66
|
-
"success",
|
|
67
|
-
"Mock structure created successfully (used template: " + template.name + ")"
|
|
68
|
-
);
|
|
69
|
-
} else {
|
|
70
|
-
relinka("success", "[DRY RUN] Mock structure would be created successfully");
|
|
71
|
-
}
|
|
72
|
-
} catch (error) {
|
|
73
|
-
handleError(error, "createMockStructure");
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
async function cleanupMockStructure(template, dryRun) {
|
|
77
|
-
try {
|
|
78
|
-
validateTemplate(template);
|
|
79
|
-
const paths = Object.keys(template.config.files);
|
|
80
|
-
let filesRemoved = 0;
|
|
81
|
-
for (const filePath of paths) {
|
|
82
|
-
const normalizedPath = validatePath(filePath, process.cwd());
|
|
83
|
-
if (dryRun) {
|
|
84
|
-
relinka("log", `[DRY RUN] Would remove: ${normalizedPath}`);
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
try {
|
|
88
|
-
if (await fs.pathExists(normalizedPath)) {
|
|
89
|
-
await fs.remove(normalizedPath);
|
|
90
|
-
filesRemoved++;
|
|
91
|
-
const parentDir = path.dirname(normalizedPath);
|
|
92
|
-
if (await fs.pathExists(parentDir)) {
|
|
93
|
-
const files = await fs.readdir(parentDir);
|
|
94
|
-
if (files.length === 0) {
|
|
95
|
-
await fs.remove(parentDir);
|
|
96
|
-
relinka("log", `Removed empty directory: ${parentDir}`);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
} catch (error) {
|
|
101
|
-
relinka(
|
|
102
|
-
"warn",
|
|
103
|
-
`Failed to remove ${normalizedPath}: ${error instanceof Error ? error.message : String(error)}`
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if (dryRun) {
|
|
108
|
-
relinka("success", "[DRY RUN] Mock structure would be cleaned up successfully");
|
|
109
|
-
} else {
|
|
110
|
-
relinka("success", `Mock structure cleaned up successfully (removed ${filesRemoved} files)`);
|
|
111
|
-
}
|
|
112
|
-
} catch (error) {
|
|
113
|
-
handleError(error, "cleanupMockStructure");
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
async function handleExistingPaths(template, force) {
|
|
117
|
-
try {
|
|
118
|
-
validateTemplate(template);
|
|
119
|
-
const paths = Object.keys(template.config.files);
|
|
120
|
-
const existingPaths = await Promise.all(
|
|
121
|
-
paths.map(async (filePath) => {
|
|
122
|
-
const normalizedPath = validatePath(filePath, process.cwd());
|
|
123
|
-
return { path: normalizedPath, exists: await fs.pathExists(normalizedPath) };
|
|
124
|
-
})
|
|
125
|
-
);
|
|
126
|
-
const conflicts = existingPaths.filter((p) => p.exists);
|
|
127
|
-
if (conflicts.length > 0) {
|
|
128
|
-
if (!force) {
|
|
129
|
-
throw new Error(
|
|
130
|
-
`Path conflicts detected. Cannot proceed with the following existing paths:
|
|
131
|
-
${conflicts.map((c) => c.path).join("\n")}`
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
for (const conflict of conflicts) {
|
|
135
|
-
await checkPermissions(conflict.path, "write");
|
|
136
|
-
await fs.remove(conflict.path);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return true;
|
|
140
|
-
} catch (error) {
|
|
141
|
-
handleError(error, "handleExistingPaths");
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
export default defineCommand({
|
|
146
|
-
meta: {
|
|
147
|
-
name: "mock",
|
|
148
|
-
version: "1.0.0",
|
|
149
|
-
description: "Bootstraps file structure based on the specified mock template. Pro tip: Run e.g. 'dler merge --s src/templates --d templates/my-template.ts --as-template' (glob supported) to create mock template based on your own file structure."
|
|
150
|
-
},
|
|
151
|
-
args: {
|
|
152
|
-
template: {
|
|
153
|
-
type: "string",
|
|
154
|
-
description: "Mock template to use (default: react) (available: " + Object.keys(DLER_TEMPLATES).join(", ") + ")",
|
|
155
|
-
default: "react"
|
|
156
|
-
},
|
|
157
|
-
"template-file": {
|
|
158
|
-
type: "string",
|
|
159
|
-
description: "Custom template file to use instead of default dler's src/app/template/mock-template.ts"
|
|
160
|
-
},
|
|
161
|
-
"template-consts": {
|
|
162
|
-
type: "string",
|
|
163
|
-
description: "Space-separated list of template constants to target (e.g., BASIC_DLER_TEMPLATE REACT_DLER_TEMPLATE)"
|
|
164
|
-
},
|
|
165
|
-
cleanup: {
|
|
166
|
-
type: "boolean",
|
|
167
|
-
description: "Clean up existing mock",
|
|
168
|
-
default: false
|
|
169
|
-
},
|
|
170
|
-
"dry-run": {
|
|
171
|
-
type: "boolean",
|
|
172
|
-
description: "Preview changes without applying them",
|
|
173
|
-
default: false
|
|
174
|
-
},
|
|
175
|
-
verbose: {
|
|
176
|
-
type: "boolean",
|
|
177
|
-
description: "Enable verbose logging",
|
|
178
|
-
default: false
|
|
179
|
-
},
|
|
180
|
-
whitelabel: {
|
|
181
|
-
type: "string",
|
|
182
|
-
description: "Custom prefix to use instead of 'DLER' in template handling",
|
|
183
|
-
default: "DLER"
|
|
184
|
-
},
|
|
185
|
-
force: {
|
|
186
|
-
type: "boolean",
|
|
187
|
-
description: "Clean existing paths before proceeding (default: true)",
|
|
188
|
-
default: true
|
|
189
|
-
}
|
|
190
|
-
},
|
|
191
|
-
async run({ args }) {
|
|
192
|
-
try {
|
|
193
|
-
const {
|
|
194
|
-
template,
|
|
195
|
-
"template-file": templateFile,
|
|
196
|
-
"template-consts": templateConsts,
|
|
197
|
-
cleanup,
|
|
198
|
-
"dry-run": dryRun,
|
|
199
|
-
verbose,
|
|
200
|
-
whitelabel = "DLER",
|
|
201
|
-
force
|
|
202
|
-
} = args;
|
|
203
|
-
if (verbose) {
|
|
204
|
-
relinka("log", "Verbose logging enabled");
|
|
205
|
-
}
|
|
206
|
-
let templates;
|
|
207
|
-
if (templateFile) {
|
|
208
|
-
try {
|
|
209
|
-
const module = await jiti.import(templateFile);
|
|
210
|
-
const templatesKey = `${whitelabel}_TEMPLATES`;
|
|
211
|
-
const loadedTemplates = module[templatesKey];
|
|
212
|
-
if (!loadedTemplates) {
|
|
213
|
-
throw new Error(`No templates found with prefix: ${whitelabel}`);
|
|
214
|
-
}
|
|
215
|
-
templates = loadedTemplates;
|
|
216
|
-
} catch (error) {
|
|
217
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
218
|
-
relinka("error", `Failed to load template file: ${errorMessage}`);
|
|
219
|
-
process.exit(1);
|
|
220
|
-
}
|
|
221
|
-
} else {
|
|
222
|
-
templates = DLER_TEMPLATES;
|
|
223
|
-
}
|
|
224
|
-
if (templateConsts) {
|
|
225
|
-
const requestedConsts = templateConsts.split(" ").map((c) => c.trim());
|
|
226
|
-
const filteredTemplates = {};
|
|
227
|
-
for (const constName of requestedConsts) {
|
|
228
|
-
let templateConst;
|
|
229
|
-
try {
|
|
230
|
-
if (templateFile) {
|
|
231
|
-
const module = await jiti.import(templateFile);
|
|
232
|
-
templateConst = module[constName];
|
|
233
|
-
} else {
|
|
234
|
-
const templateKey = dlerTemplatesMap[constName];
|
|
235
|
-
if (!templateKey) {
|
|
236
|
-
throw new Error(
|
|
237
|
-
`Invalid template constant: ${constName}. Available constants: ${Object.keys(dlerTemplatesMap).join(", ")}`
|
|
238
|
-
);
|
|
239
|
-
}
|
|
240
|
-
templateConst = DLER_TEMPLATES[templateKey];
|
|
241
|
-
}
|
|
242
|
-
if (!templateConst) {
|
|
243
|
-
throw new Error(`Template constant not found: ${constName}`);
|
|
244
|
-
}
|
|
245
|
-
filteredTemplates[templateConst.name.toLowerCase()] = templateConst;
|
|
246
|
-
} catch (error) {
|
|
247
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
248
|
-
relinka("error", errorMessage);
|
|
249
|
-
process.exit(1);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
templates = filteredTemplates;
|
|
253
|
-
}
|
|
254
|
-
if (!templates[template]) {
|
|
255
|
-
throw new Error(
|
|
256
|
-
`Invalid template: ${template}. Available templates: ${Object.keys(templates).join(", ")}`
|
|
257
|
-
);
|
|
258
|
-
}
|
|
259
|
-
const timer = createPerfTimer();
|
|
260
|
-
if (cleanup) {
|
|
261
|
-
await cleanupMockStructure(templates[template], dryRun);
|
|
262
|
-
const elapsed2 = getElapsedPerfTime(timer);
|
|
263
|
-
relinka(
|
|
264
|
-
"success",
|
|
265
|
-
`Successfully ${dryRun ? "would clean up" : "cleaned up"} template structure in ${prettyMilliseconds(elapsed2)}`
|
|
266
|
-
);
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
if (!await handleExistingPaths(templates[template], force)) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
await createMockStructure(templates[template], dryRun);
|
|
273
|
-
const elapsed = getElapsedPerfTime(timer);
|
|
274
|
-
relinka(
|
|
275
|
-
"success",
|
|
276
|
-
`Successfully ${dryRun ? "would create" : "created"} mock structure in ${prettyMilliseconds(elapsed)}`
|
|
277
|
-
);
|
|
278
|
-
} catch (error) {
|
|
279
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
280
|
-
relinka("error", `Error during mock creation: ${errorMessage}`);
|
|
281
|
-
process.exit(1);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
});
|
package/bin/app/mock/mock.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Template } from "../../libs/sdk/sdk-types.js";
|
|
2
|
-
export declare const BASIC_DLER_TEMPLATE: Template;
|
|
3
|
-
export declare const API_DLER_TEMPLATE: Template;
|
|
4
|
-
export declare const REACT_DLER_TEMPLATE: Template;
|
|
5
|
-
export declare const DLER_TEMPLATES: {
|
|
6
|
-
readonly basic: Template;
|
|
7
|
-
readonly api: Template;
|
|
8
|
-
readonly react: Template;
|
|
9
|
-
};
|
|
10
|
-
export type DLER_TEMPLATE_NAMES = keyof typeof DLER_TEMPLATES;
|
|
11
|
-
export declare const dlerTemplatesMap: Record<string, DLER_TEMPLATE_NAMES>;
|
package/bin/app/mock/mock.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
export const BASIC_DLER_TEMPLATE = {
|
|
2
|
-
name: "basic",
|
|
3
|
-
description: "Template generated from 4 files",
|
|
4
|
-
config: {
|
|
5
|
-
files: {
|
|
6
|
-
"src/templates/README.md": {
|
|
7
|
-
content: "# Mock Project\n\nThis is a mock project created for testing purposes.",
|
|
8
|
-
type: "text"
|
|
9
|
-
},
|
|
10
|
-
"src/templates/config.json": {
|
|
11
|
-
content: {
|
|
12
|
-
name: "mock-project",
|
|
13
|
-
version: "1.0.0",
|
|
14
|
-
dependencies: {
|
|
15
|
-
"@reliverse/relifso": "^latest",
|
|
16
|
-
"@reliverse/relinka": "^latest"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
type: "json"
|
|
20
|
-
},
|
|
21
|
-
"src/templates/index.ts": {
|
|
22
|
-
content: "export const mock = () => console.log('Hello from mock!');",
|
|
23
|
-
type: "text"
|
|
24
|
-
},
|
|
25
|
-
"src/templates/utils/helper.ts": {
|
|
26
|
-
content: "export const helper = () => 'Helper function';",
|
|
27
|
-
type: "text"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
export const API_DLER_TEMPLATE = {
|
|
33
|
-
name: "api",
|
|
34
|
-
description: "Template generated from 3 files",
|
|
35
|
-
config: {
|
|
36
|
-
files: {
|
|
37
|
-
"src/templates/README.md": {
|
|
38
|
-
content: "# Mock Project\n\nThis is a mock project created for testing purposes.\n",
|
|
39
|
-
type: "text"
|
|
40
|
-
},
|
|
41
|
-
"src/templates/index.ts": {
|
|
42
|
-
content: '// @ts-expect-error this is a mock file\nimport express from "express";\n\nconst app = express();\napp.listen(3000);\n',
|
|
43
|
-
type: "text"
|
|
44
|
-
},
|
|
45
|
-
"src/templates/routes/index.ts": {
|
|
46
|
-
content: '// @ts-expect-error this is a mock file\nimport { Router } from "express";\n\nexport const router = Router();\n',
|
|
47
|
-
type: "text"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
export const REACT_DLER_TEMPLATE = {
|
|
53
|
-
name: "react",
|
|
54
|
-
description: "Template generated from 7 files",
|
|
55
|
-
config: {
|
|
56
|
-
files: {
|
|
57
|
-
"src/templates/App.css": {
|
|
58
|
-
content: "#root {\n max-width: 1280px;\n margin: 0 auto;\n padding: 2rem;\n text-align: center;\n}\n\n.card {\n padding: 2em;\n}\n\nbutton {\n border-radius: 8px;\n border: 1px solid transparent;\n padding: 0.6em 1.2em;\n font-size: 1em;\n font-weight: 500;\n font-family: inherit;\n background-color: #1a1a1a;\n cursor: pointer;\n transition: border-color 0.25s;\n}\n\nbutton:hover {\n border-color: #646cff;\n}\n\nbutton:focus,\nbutton:focus-visible {\n outline: 4px auto -webkit-focus-ring-color;\n}",
|
|
59
|
-
type: "text"
|
|
60
|
-
},
|
|
61
|
-
"src/templates/App.tsx": {
|
|
62
|
-
content: 'import { useState } from "react";\nimport "./App.css";\n\nfunction App() {\n const [count, setCount] = useState(0);\n\n return (\n // @ts-expect-error mock\n <div className="App">\n {/* @ts-expect-error mock */}\n <h1>React TSX App</h1>\n {/* @ts-expect-error mock */}\n <div className="card">\n {/* @ts-expect-error mock */}\n <button onClick={() => setCount((count: number) => count + 1)}>count is {count}</button>\n </div>\n </div>\n );\n}\n\nexport default App;\n',
|
|
63
|
-
type: "text"
|
|
64
|
-
},
|
|
65
|
-
"src/templates/DOCS.md": {
|
|
66
|
-
content: "# React TSX Project\n\nA modern React project with TypeScript and Vite.\n\n## Features\n\n- React 19 with TypeScript\n- Vite for fast development and building\n- Modern CSS with CSS modules support\n- Hot Module Replacement (HMR)\n- ESLint and Prettier configuration\n\n## Getting Started\n\n1. Install dependencies:\n\n ```bash\n npm install\n ```\n\n2. Start development server:\n\n ```bash\n npm run dev\n ```\n\n3. Build for production:\n\n ```bash\n npm run build\n ```\n",
|
|
67
|
-
type: "text"
|
|
68
|
-
},
|
|
69
|
-
"src/templates/globals.css": {
|
|
70
|
-
content: ":root {\n font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;\n line-height: 1.5;\n font-weight: 400;\n\n color-scheme: light dark;\n color: rgba(255, 255, 255, 0.87);\n background-color: #242424;\n\n font-synthesis: none;\n text-rendering: optimizeLegibility;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n}\n\nbody {\n margin: 0;\n display: flex;\n place-items: center;\n min-width: 320px;\n min-height: 100vh;\n}\n\nh1 {\n font-size: 3.2em;\n line-height: 1.1;\n}",
|
|
71
|
-
type: "text"
|
|
72
|
-
},
|
|
73
|
-
"src/templates/hello/world.ts": {
|
|
74
|
-
content: 'console.log("Hello, world!");\r\n',
|
|
75
|
-
type: "text"
|
|
76
|
-
},
|
|
77
|
-
"src/templates/index.html": {
|
|
78
|
-
content: '<!DOCTYPE html>\n<html lang="en">\n <head>\n <meta charset="UTF-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1.0" />\n <title>React TSX App</title>\n </head>\n <body>\n <div id="root"></div>\n <script type="module" src="/src/main.tsx"><\/script>\n </body>\n</html>',
|
|
79
|
-
type: "text"
|
|
80
|
-
},
|
|
81
|
-
"src/templates/main.tsx": {
|
|
82
|
-
content: 'import React from "react";\n// @ts-expect-error mock\nimport ReactDOM from "react-dom/client";\nimport App from "./App";\nimport "./index.css";\n\nReactDOM.createRoot(document.getElementById("root")!).render(\n <React.StrictMode>\n <App />\n </React.StrictMode>,\n);\n',
|
|
83
|
-
type: "text"
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
export const DLER_TEMPLATES = {
|
|
89
|
-
basic: BASIC_DLER_TEMPLATE,
|
|
90
|
-
api: API_DLER_TEMPLATE,
|
|
91
|
-
react: REACT_DLER_TEMPLATE
|
|
92
|
-
};
|
|
93
|
-
export const dlerTemplatesMap = {
|
|
94
|
-
BASIC_DLER_TEMPLATE: "basic",
|
|
95
|
-
API_DLER_TEMPLATE: "api",
|
|
96
|
-
REACT_DLER_TEMPLATE: "react"
|
|
97
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Spell, SpellResult } from "./spell-types";
|
|
2
|
-
export declare const replaceLineExecutor: (spell: Spell, filePath: string, content: string) => Promise<SpellResult>;
|
|
3
|
-
export declare const renameFileExecutor: (spell: Spell, filePath: string) => Promise<SpellResult>;
|
|
4
|
-
export declare const removeCommentExecutor: (spell: Spell, filePath: string, content: string) => Promise<SpellResult>;
|
|
5
|
-
export declare const removeLineExecutor: (spell: Spell, filePath: string, content: string) => Promise<SpellResult>;
|
|
6
|
-
export declare const removeFileExecutor: (spell: Spell, filePath: string) => Promise<SpellResult>;
|
|
7
|
-
export declare const copyFileExecutor: (spell: Spell, filePath: string) => Promise<SpellResult>;
|
|
8
|
-
export declare const moveFileExecutor: (spell: Spell, filePath: string) => Promise<SpellResult>;
|
|
9
|
-
export declare const transformContentExecutor: (spell: Spell, filePath: string, content: string) => Promise<SpellResult>;
|
|
10
|
-
export declare const insertAtExecutor: (spell: Spell, filePath: string, content: string) => Promise<SpellResult>;
|