@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.
Files changed (167) hide show
  1. package/README.md +164 -191
  2. package/bin/app/agg/run.js +2 -8
  3. package/bin/app/build/cmd.js +4 -4
  4. package/bin/app/build/impl.d.ts +2 -6
  5. package/bin/app/build/impl.js +2 -46
  6. package/bin/app/conv/cmd.d.ts +8 -33
  7. package/bin/app/conv/cmd.js +185 -163
  8. package/bin/app/copy/cmd.js +1 -1
  9. package/bin/app/init/init-impl.js +3 -3
  10. package/bin/app/init/init-types.d.ts +8 -8
  11. package/bin/app/merge/cmd.d.ts +17 -17
  12. package/bin/app/merge/cmd.js +70 -310
  13. package/bin/app/migrate/codemods/anything-bun.js +1 -1
  14. package/bin/app/migrate/codemods/fs-relifso.d.ts +2 -2
  15. package/bin/app/migrate/codemods/fs-relifso.js +1 -1
  16. package/bin/app/migrate/codemods/nodenext-bundler.d.ts +2 -2
  17. package/bin/app/migrate/codemods/nodenext-bundler.js +1 -1
  18. package/bin/app/migrate/codemods/path-pathkit.d.ts +2 -2
  19. package/bin/app/migrate/codemods/path-pathkit.js +1 -1
  20. package/bin/app/migrate/codemods/readdir-glob.d.ts +2 -2
  21. package/bin/app/migrate/codemods/readdir-glob.js +1 -1
  22. package/bin/app/mkdist/cmd.js +4 -2
  23. package/bin/app/pack/cmd.d.ts +44 -0
  24. package/bin/app/pack/cmd.js +313 -0
  25. package/bin/app/pub/cmd.js +4 -4
  26. package/bin/app/pub/impl.d.ts +7 -0
  27. package/bin/app/pub/impl.js +97 -0
  28. package/bin/app/rename/cmd.js +1 -1
  29. package/bin/app/spell/cmd.d.ts +14 -5
  30. package/bin/app/spell/cmd.js +33 -33
  31. package/bin/app/spell/old.js +0 -0
  32. package/bin/app/{mock → unpack}/cmd.d.ts +10 -14
  33. package/bin/app/unpack/cmd.js +200 -0
  34. package/bin/cli.js +2 -2
  35. package/bin/libs/cfg/cfg-mod.d.ts +69 -0
  36. package/bin/libs/cfg/cfg-mod.js +61 -0
  37. package/bin/libs/cfg/rse/rse-impl/rse-biome.d.ts +2 -0
  38. package/bin/libs/cfg/rse/rse-impl/rse-biome.js +34 -0
  39. package/bin/libs/cfg/rse/rse-impl/rse-consts.d.ts +35 -0
  40. package/bin/libs/cfg/rse/rse-impl/rse-consts.js +37 -0
  41. package/bin/libs/cfg/rse/rse-impl/rse-content.d.ts +14 -0
  42. package/bin/libs/cfg/rse/rse-impl/rse-content.js +15 -0
  43. package/bin/libs/cfg/rse/rse-impl/rse-core.d.ts +14 -0
  44. package/bin/libs/cfg/rse/rse-impl/rse-core.js +63 -0
  45. package/bin/libs/cfg/rse/rse-impl/rse-create.d.ts +36 -0
  46. package/bin/libs/cfg/rse/rse-impl/rse-create.js +254 -0
  47. package/bin/libs/cfg/rse/rse-impl/rse-def-utils.d.ts +6 -0
  48. package/bin/libs/cfg/rse/rse-impl/rse-def-utils.js +225 -0
  49. package/bin/libs/cfg/rse/rse-impl/rse-default.d.ts +3 -0
  50. package/bin/libs/cfg/rse/rse-impl/rse-default.js +155 -0
  51. package/bin/libs/cfg/rse/rse-impl/rse-define.d.ts +125 -0
  52. package/bin/libs/cfg/rse/rse-impl/rse-define.js +4 -0
  53. package/bin/libs/cfg/rse/rse-impl/rse-detect.d.ts +23 -0
  54. package/bin/libs/cfg/rse/rse-impl/rse-detect.js +347 -0
  55. package/bin/libs/cfg/rse/rse-impl/rse-gen-cfg.d.ts +3 -0
  56. package/bin/libs/cfg/rse/rse-impl/rse-gen-cfg.js +186 -0
  57. package/bin/libs/cfg/rse/rse-impl/rse-inject.d.ts +1 -0
  58. package/bin/libs/cfg/rse/rse-impl/rse-inject.js +57 -0
  59. package/bin/libs/cfg/rse/rse-impl/rse-migrate.d.ts +5 -0
  60. package/bin/libs/cfg/rse/rse-impl/rse-migrate.js +56 -0
  61. package/bin/libs/cfg/rse/rse-impl/rse-path.d.ts +11 -0
  62. package/bin/libs/cfg/rse/rse-impl/rse-path.js +33 -0
  63. package/bin/libs/cfg/rse/rse-impl/rse-prompts.d.ts +5 -0
  64. package/bin/libs/cfg/rse/rse-impl/rse-prompts.js +12 -0
  65. package/bin/libs/cfg/rse/rse-impl/rse-read.d.ts +11 -0
  66. package/bin/libs/cfg/rse/rse-impl/rse-read.js +84 -0
  67. package/bin/libs/cfg/rse/rse-impl/rse-repair.d.ts +16 -0
  68. package/bin/libs/cfg/rse/rse-impl/rse-repair.js +137 -0
  69. package/bin/libs/cfg/rse/rse-impl/rse-schema.d.ts +130 -0
  70. package/bin/libs/cfg/rse/rse-impl/rse-schema.js +444 -0
  71. package/bin/libs/cfg/rse/rse-impl/rse-types.d.ts +75 -0
  72. package/bin/libs/cfg/rse/rse-impl/rse-types.js +0 -0
  73. package/bin/libs/cfg/rse/rse-impl/rse-unstable.d.ts +11 -0
  74. package/bin/libs/cfg/rse/rse-impl/rse-unstable.js +41 -0
  75. package/bin/libs/cfg/rse/rse-impl/rse-update.d.ts +10 -0
  76. package/bin/libs/cfg/rse/rse-impl/rse-update.js +152 -0
  77. package/bin/libs/cfg/rse/rse-impl/rse-utils.d.ts +17 -0
  78. package/bin/libs/cfg/rse/rse-impl/rse-utils.js +86 -0
  79. package/bin/libs/cfg/rse/rse-mod.d.ts +20 -0
  80. package/bin/libs/cfg/rse/rse-mod.js +20 -0
  81. package/bin/libs/cfg/types.d.ts +533 -0
  82. package/bin/libs/cfg/types.js +0 -0
  83. package/bin/libs/sdk/sdk-impl/build/build-library.d.ts +5 -5
  84. package/bin/libs/sdk/sdk-impl/build/build-library.js +1 -174
  85. package/bin/libs/sdk/sdk-impl/build/build-regular.d.ts +2 -1
  86. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.js +287 -240
  87. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/vue.d.ts +4 -4
  88. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/make.d.ts +8 -5
  89. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/make.js +199 -119
  90. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/spinner.d.ts +99 -0
  91. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/spinner.js +206 -0
  92. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-mod.js +92 -46
  93. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/rollup/plugins/raw.d.ts +2 -2
  94. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/utils.d.ts +2 -2
  95. package/bin/libs/sdk/sdk-impl/config/default.d.ts +6 -0
  96. package/bin/libs/sdk/sdk-impl/{cfg → config}/default.js +8 -18
  97. package/bin/libs/sdk/sdk-impl/{cfg → config}/info.js +1 -1
  98. package/bin/libs/sdk/sdk-impl/{cfg → config}/init.js +53 -43
  99. package/bin/libs/sdk/sdk-impl/{cfg → config}/load.d.ts +2 -2
  100. package/bin/libs/sdk/sdk-impl/{cfg → config}/load.js +6 -6
  101. package/bin/libs/sdk/sdk-impl/config/types.d.ts +533 -0
  102. package/bin/libs/sdk/sdk-impl/config/types.js +0 -0
  103. package/bin/libs/sdk/sdk-impl/library-flow.d.ts +2 -1
  104. package/bin/libs/sdk/sdk-impl/pub/pub-library.js +7 -0
  105. package/bin/libs/sdk/sdk-impl/pub/pub-regular.js +4 -8
  106. package/bin/libs/sdk/sdk-impl/regular-flow.d.ts +2 -1
  107. package/bin/libs/sdk/sdk-impl/rules/reliverse/dler-config-health/dler-config-health.js +2 -2
  108. package/bin/libs/sdk/sdk-impl/rules/reliverse/missing-deps/deps-types.d.ts +6 -6
  109. package/bin/libs/sdk/sdk-impl/rules/reliverse/missing-deps/filesystem.js +1 -1
  110. package/bin/libs/sdk/sdk-impl/rules/reliverse/no-index-files/no-index-files.js +1 -1
  111. package/bin/libs/sdk/sdk-impl/rules/reliverse/self-include/self-include.js +2 -2
  112. package/bin/libs/sdk/sdk-impl/spell/applyMagicSpells.d.ts +38 -0
  113. package/bin/libs/sdk/sdk-impl/spell/applyMagicSpells.js +474 -0
  114. package/bin/libs/sdk/sdk-impl/spell/spells.d.ts +31 -0
  115. package/bin/libs/sdk/sdk-impl/spell/spells.js +85 -0
  116. package/bin/libs/sdk/sdk-impl/utils/binary.js +1 -1
  117. package/bin/libs/sdk/sdk-impl/utils/comments.d.ts +6 -0
  118. package/bin/libs/sdk/sdk-impl/utils/comments.js +41 -0
  119. package/bin/libs/sdk/sdk-impl/utils/finalize.d.ts +2 -1
  120. package/bin/libs/sdk/sdk-impl/utils/finalize.js +1 -0
  121. package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-constants.d.ts +6 -0
  122. package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-constants.js +7 -0
  123. package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-file-utils.d.ts +5 -0
  124. package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-file-utils.js +40 -0
  125. package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-types.d.ts +24 -0
  126. package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pu-types.js +0 -0
  127. package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pub-json-utils.d.ts +17 -0
  128. package/bin/libs/sdk/sdk-impl/utils/pack-unpack/pub-json-utils.js +46 -0
  129. package/bin/libs/sdk/sdk-impl/utils/replacements.d.ts +0 -0
  130. package/bin/libs/sdk/sdk-impl/utils/replacements.js +0 -0
  131. package/bin/libs/sdk/sdk-impl/utils/resolve-cross-libs.d.ts +3 -0
  132. package/bin/libs/sdk/sdk-impl/utils/resolve-cross-libs.js +194 -0
  133. package/bin/libs/sdk/sdk-impl/utils/utils-build.d.ts +1 -2
  134. package/bin/libs/sdk/sdk-impl/utils/utils-clean.d.ts +1 -1
  135. package/bin/libs/sdk/sdk-impl/utils/utils-deps.d.ts +1 -1
  136. package/bin/libs/sdk/sdk-impl/utils/utils-determine.d.ts +1 -1
  137. package/bin/libs/sdk/sdk-impl/utils/utils-error-cwd.d.ts +4 -0
  138. package/bin/libs/sdk/sdk-impl/utils/utils-error-cwd.js +1 -0
  139. package/bin/libs/sdk/sdk-impl/utils/utils-jsr-json.d.ts +1 -1
  140. package/bin/libs/sdk/sdk-impl/utils/utils-package-json-libraries.d.ts +1 -1
  141. package/bin/libs/sdk/sdk-impl/utils/utils-package-json-regular.d.ts +1 -1
  142. package/bin/libs/sdk/sdk-impl/utils/utils-security.d.ts +1 -3
  143. package/bin/libs/sdk/sdk-impl/utils/utils-security.js +11 -10
  144. package/bin/libs/sdk/sdk-mod.d.ts +1 -6
  145. package/bin/libs/sdk/sdk-mod.js +0 -31
  146. package/bin/libs/sdk/sdk-types.d.ts +39 -582
  147. package/bin/mod.d.ts +1 -1
  148. package/bin/mod.js +1 -1
  149. package/package.json +11 -4
  150. package/bin/app/mock/cmd.js +0 -284
  151. package/bin/app/mock/mock.d.ts +0 -11
  152. package/bin/app/mock/mock.js +0 -97
  153. package/bin/libs/sdk/sdk-impl/cfg/default.d.ts +0 -5
  154. package/bin/libs/sdk/sdk-impl/cfg/define.d.ts +0 -2
  155. package/bin/libs/sdk/sdk-impl/cfg/define.js +0 -4
  156. package/bin/libs/sdk/sdk-impl/spell/spell-executors.d.ts +0 -10
  157. package/bin/libs/sdk/sdk-impl/spell/spell-executors.js +0 -307
  158. package/bin/libs/sdk/sdk-impl/spell/spell-filesystem.d.ts +0 -7
  159. package/bin/libs/sdk/sdk-impl/spell/spell-filesystem.js +0 -74
  160. package/bin/libs/sdk/sdk-impl/spell/spell-mod.d.ts +0 -4
  161. package/bin/libs/sdk/sdk-impl/spell/spell-mod.js +0 -87
  162. package/bin/libs/sdk/sdk-impl/spell/spell-parser.d.ts +0 -4
  163. package/bin/libs/sdk/sdk-impl/spell/spell-parser.js +0 -58
  164. package/bin/libs/sdk/sdk-impl/spell/spell-types.d.ts +0 -60
  165. /package/bin/{libs/sdk/sdk-impl/spell/spell-types.js → app/spell/old.d.ts} +0 -0
  166. /package/bin/libs/sdk/sdk-impl/{cfg → config}/info.d.ts +0 -0
  167. /package/bin/libs/sdk/sdk-impl/{cfg → config}/init.d.ts +0 -0
@@ -0,0 +1,200 @@
1
+ import path from "@reliverse/pathkit";
2
+ import { relinka } from "@reliverse/relinka";
3
+ import { defineArgs, defineCommand } from "@reliverse/rempts";
4
+ import { createJiti } from "jiti";
5
+ import { promises as fs } from "node:fs";
6
+ import { TPLS_DIR, BINARIES_DIR } from "../../libs/sdk/sdk-impl/utils/pack-unpack/pu-constants.js";
7
+ const jiti = createJiti(import.meta.url);
8
+ async function removeEmptyDirs(dirPath) {
9
+ if (!await fs.access(dirPath).then(() => true).catch(() => false))
10
+ return;
11
+ const entries = await fs.readdir(dirPath);
12
+ if (entries.length === 0) {
13
+ await fs.rmdir(dirPath);
14
+ const parentDir = path.dirname(dirPath);
15
+ if (parentDir !== dirPath) {
16
+ await removeEmptyDirs(parentDir);
17
+ }
18
+ }
19
+ }
20
+ async function deleteTemplates(templatesDir, templatesDirName, dryRun) {
21
+ const modFile = `${templatesDirName}-mod.ts`;
22
+ const typesFile = `${templatesDirName}-types.ts`;
23
+ const implDir = path.join(templatesDir, TPLS_DIR);
24
+ const binariesDir = path.join(implDir, BINARIES_DIR);
25
+ const filesToRemove = [path.join(templatesDir, modFile), path.join(templatesDir, typesFile)];
26
+ try {
27
+ const templateFiles = await fs.readdir(implDir);
28
+ for (const file of templateFiles) {
29
+ if (file.endsWith(".ts")) {
30
+ filesToRemove.push(path.join(implDir, file));
31
+ }
32
+ }
33
+ } catch (error) {
34
+ if (error.code !== "ENOENT") {
35
+ throw error;
36
+ }
37
+ }
38
+ for (const file of filesToRemove) {
39
+ if (dryRun) {
40
+ relinka("log", `[DRY RUN] Would remove: ${file}`);
41
+ continue;
42
+ }
43
+ try {
44
+ await fs.unlink(file);
45
+ relinka("log", `Removed: ${file}`);
46
+ } catch (error) {
47
+ if (error.code !== "ENOENT") {
48
+ relinka("warn", `Failed to remove ${file}: ${error.message}`);
49
+ }
50
+ }
51
+ }
52
+ try {
53
+ if (await fs.access(binariesDir).then(() => true).catch(() => false)) {
54
+ if (dryRun) {
55
+ relinka("log", `[DRY RUN] Would remove directory: ${binariesDir}`);
56
+ } else {
57
+ await fs.rm(binariesDir, { recursive: true });
58
+ relinka("log", `Removed directory: ${binariesDir}`);
59
+ }
60
+ }
61
+ } catch (error) {
62
+ relinka("warn", `Failed to remove binaries directory: ${error.message}`);
63
+ }
64
+ await removeEmptyDirs(implDir);
65
+ await removeEmptyDirs(templatesDir);
66
+ }
67
+ export default defineCommand({
68
+ meta: {
69
+ name: "unpack",
70
+ version: "1.1.0",
71
+ description: "Creates file structure from packed templates"
72
+ },
73
+ args: defineArgs({
74
+ templatesDir: { type: "positional", required: true, description: "Dir containing *-mod.ts" },
75
+ output: { type: "string", default: "unpacked", description: "Where to write files" },
76
+ cdn: {
77
+ type: "string",
78
+ description: "Remote CDN base for binary assets download (not yet implemented)"
79
+ },
80
+ deleteTemplates: {
81
+ type: "boolean",
82
+ description: "Delete template implementation files (*-mod.ts, *-types.ts, etc.)",
83
+ default: false
84
+ },
85
+ "dry-run": {
86
+ type: "boolean",
87
+ description: "Preview changes without applying them",
88
+ default: false
89
+ },
90
+ force: {
91
+ type: "boolean",
92
+ description: "Force overwrite existing files",
93
+ default: false
94
+ },
95
+ cleanup: {
96
+ type: "boolean",
97
+ description: "Delete output directory before unpacking",
98
+ default: false
99
+ }
100
+ }),
101
+ async run({ args }) {
102
+ if (args.cdn) throw new Error("Remote CDN support is not implemented yet.");
103
+ const templatesDir = path.resolve(args.templatesDir);
104
+ const templatesDirName = path.basename(templatesDir);
105
+ const modFile = `${templatesDirName}-mod.ts`;
106
+ const modPath = path.join(templatesDir, modFile);
107
+ if (args.deleteTemplates) {
108
+ await deleteTemplates(templatesDir, templatesDirName, args["dry-run"]);
109
+ if (args["dry-run"]) {
110
+ relinka("log", "[DRY RUN] Templates deletion completed");
111
+ } else {
112
+ relinka("log", "Templates deletion completed");
113
+ }
114
+ return;
115
+ }
116
+ if (args.cleanup) {
117
+ try {
118
+ await fs.rm(args.output, { recursive: true, force: true });
119
+ await fs.mkdir(args.output, { recursive: true });
120
+ relinka("log", `Cleaned output directory: ${args.output}`);
121
+ } catch (error) {
122
+ if (error.code !== "ENOENT") {
123
+ throw error;
124
+ }
125
+ }
126
+ }
127
+ const mod = await jiti.import(modPath);
128
+ const templatesObj = mod?.DLER_TEMPLATES || mod?.default || (() => {
129
+ throw new Error(`Invalid ${modFile}`);
130
+ })();
131
+ for (const tpl of Object.values(templatesObj)) {
132
+ await restoreTemplate(tpl, templatesDir, args.output, args.force);
133
+ }
134
+ const relativeOutput = path.relative(process.cwd(), args.output);
135
+ relinka(
136
+ "log",
137
+ `Unpacked ${Object.keys(templatesObj).length} templates from ${modFile} into ${relativeOutput}${args.force ? " (--force is true, dir was overwritten)" : ""}`
138
+ );
139
+ }
140
+ });
141
+ const restoreTemplate = async (tpl, templatesRoot, outRoot, force) => {
142
+ const existingFiles = [];
143
+ for (const [rel, meta] of Object.entries(tpl.config.files)) {
144
+ const destAbs = path.join(outRoot, rel);
145
+ if (!force) {
146
+ try {
147
+ await fs.access(destAbs);
148
+ existingFiles.push(rel);
149
+ continue;
150
+ } catch {
151
+ }
152
+ }
153
+ await fs.mkdir(path.dirname(destAbs), { recursive: true });
154
+ switch (meta.type) {
155
+ case "binary": {
156
+ if (!meta.binaryHash) {
157
+ await fs.writeFile(destAbs, "");
158
+ break;
159
+ }
160
+ const ext = path.extname(rel);
161
+ const binPath = path.join(
162
+ templatesRoot,
163
+ TPLS_DIR,
164
+ BINARIES_DIR,
165
+ `${meta.binaryHash}${ext}`
166
+ );
167
+ await fs.copyFile(binPath, destAbs);
168
+ break;
169
+ }
170
+ case "text": {
171
+ await fs.writeFile(destAbs, meta.content, "utf8");
172
+ break;
173
+ }
174
+ case "json": {
175
+ const txt = JSON.stringify(meta.content, null, 2);
176
+ const withComments = meta.jsonComments ? injectComments(txt, meta.jsonComments) : txt;
177
+ await fs.writeFile(destAbs, withComments, "utf8");
178
+ break;
179
+ }
180
+ }
181
+ }
182
+ if (existingFiles.length > 0) {
183
+ throw new Error(
184
+ `Cannot unpack: ${existingFiles.length} file(s) already exist. Use --force to overwrite existing files`
185
+ );
186
+ }
187
+ };
188
+ const injectComments = (json, comments) => {
189
+ const lines = json.split("\n");
190
+ const entries = Object.entries(comments).map(([k, v]) => [Number(k), v]).sort((a, b) => a[0] - b[0]);
191
+ let offset = 0;
192
+ for (const [ln, comment] of entries) {
193
+ const idx = ln - 1 + offset;
194
+ const indent = lines[idx]?.match(/^\s*/)?.[0] ?? "";
195
+ const block = comment.split("\n").map((l) => indent + l);
196
+ lines.splice(idx, 0, ...block);
197
+ offset += block.length;
198
+ }
199
+ return lines.join("\n") + "\n";
200
+ };
package/bin/cli.js CHANGED
@@ -10,8 +10,8 @@ import {
10
10
  } from "@reliverse/rempts";
11
11
  import { promptAggCommand } from "./app/agg/run.js";
12
12
  import { getBuildCmd, getPubCmd, getInitCmd, getRenameCmd } from "./app/cmds.js";
13
- import { showEndPrompt, showStartPrompt } from "./libs/sdk/sdk-impl/cfg/info.js";
14
- import { ensureDlerConfig } from "./libs/sdk/sdk-impl/cfg/init.js";
13
+ import { showEndPrompt, showStartPrompt } from "./libs/sdk/sdk-impl/config/info.js";
14
+ import { ensureDlerConfig } from "./libs/sdk/sdk-impl/config/init.js";
15
15
  const INTERACTIVE_CMDS = ["agg", "build", "pub"];
16
16
  async function runCmd(cmdPromise, args) {
17
17
  const cmd = await cmdPromise;
@@ -0,0 +1,69 @@
1
+ import type { DlerConfig } from "./types";
2
+ /**
3
+ * Default configuration for the build and publish logic.
4
+ */
5
+ export declare const DEFAULT_CONFIG_DLER: DlerConfig;
6
+ export declare const defineConfigDler: (userConfig?: Partial<DlerConfig>) => {
7
+ bumpDisable: boolean;
8
+ bumpFilter: string[];
9
+ bumpMode: import("./types").BumpMode;
10
+ bumpSet: string;
11
+ commonPubPause: boolean;
12
+ commonPubRegistry: "jsr" | "npm" | "npm-jsr";
13
+ commonVerbose: boolean;
14
+ coreDeclarations: boolean;
15
+ coreEntryFile: string;
16
+ coreEntrySrcDir: string;
17
+ coreBuildOutDir: string;
18
+ coreIsCLI: {
19
+ enabled: boolean;
20
+ scripts: Record<string, string>;
21
+ };
22
+ coreDescription: string;
23
+ distJsrAllowDirty: boolean;
24
+ distJsrBuilder: import("./types").BundlerName;
25
+ distJsrDirName: string;
26
+ distJsrDryRun: boolean;
27
+ distJsrFailOnWarn: boolean;
28
+ distJsrGenTsconfig: boolean;
29
+ distJsrOutFilesExt: import("./types").NpmOutExt;
30
+ distJsrSlowTypes: boolean;
31
+ distNpmBuilder: import("./types").BundlerName;
32
+ distNpmDirName: string;
33
+ distNpmOutFilesExt: import("./types").NpmOutExt;
34
+ libsActMode: "libs-only" | "main-and-libs" | "main-project-only";
35
+ libsDirDist: string;
36
+ libsDirSrc: string;
37
+ libsList: Record<string, import("./types").LibConfig>;
38
+ logsFileName: string;
39
+ logsFreshFile: boolean;
40
+ filterDepsPatterns: {
41
+ global: string[];
42
+ "dist-npm": string[];
43
+ "dist-jsr": string[];
44
+ "dist-libs": Record<string, {
45
+ npm: string[];
46
+ jsr: string[];
47
+ }>;
48
+ };
49
+ transpileFailOnWarn: boolean;
50
+ transpileEsbuild: import("./types").Esbuild;
51
+ transpileFormat: import("./types").transpileFormat;
52
+ transpileMinify: boolean;
53
+ transpilePublicPath: string;
54
+ transpileSourcemap: import("./types").Sourcemap;
55
+ transpileSplitting: boolean;
56
+ transpileStub: boolean;
57
+ transpileTarget: import("./types").transpileTarget;
58
+ transpileWatch: boolean;
59
+ publishArtifacts?: {
60
+ global: string[];
61
+ "dist-jsr": string[];
62
+ "dist-npm": string[];
63
+ "dist-libs": Record<string, {
64
+ jsr: string[];
65
+ npm: string[];
66
+ }>;
67
+ };
68
+ };
69
+ export * from "./rse/rse-mod";
@@ -0,0 +1,61 @@
1
+ export const DEFAULT_CONFIG_DLER = {
2
+ bumpDisable: false,
3
+ bumpFilter: ["package.json", ".config/rse.ts"],
4
+ bumpMode: "patch",
5
+ bumpSet: "",
6
+ commonPubPause: true,
7
+ commonPubRegistry: "npm",
8
+ commonVerbose: false,
9
+ coreDeclarations: true,
10
+ coreDescription: "",
11
+ coreEntryFile: "mod.ts",
12
+ coreEntrySrcDir: "src",
13
+ coreBuildOutDir: "bin",
14
+ coreIsCLI: { enabled: false, scripts: {} },
15
+ distJsrAllowDirty: true,
16
+ distJsrBuilder: "jsr",
17
+ distJsrDirName: "dist-jsr",
18
+ distJsrDryRun: false,
19
+ distJsrFailOnWarn: false,
20
+ distJsrGenTsconfig: false,
21
+ distJsrOutFilesExt: "ts",
22
+ distJsrSlowTypes: true,
23
+ distNpmBuilder: "mkdist",
24
+ distNpmDirName: "dist-npm",
25
+ distNpmOutFilesExt: "js",
26
+ libsActMode: "main-project-only",
27
+ libsDirDist: "dist-libs",
28
+ libsDirSrc: "src/libs",
29
+ libsList: {},
30
+ logsFileName: ".logs/relinka.log",
31
+ logsFreshFile: true,
32
+ // Dependency filtering
33
+ filterDepsPatterns: {
34
+ global: ["@types", "biome", "eslint", "knip", "prettier", "typescript", "@reliverse/dler"],
35
+ "dist-npm": [],
36
+ "dist-jsr": [],
37
+ "dist-libs": {}
38
+ },
39
+ // Build setup
40
+ transpileFailOnWarn: false,
41
+ transpileEsbuild: "es2023",
42
+ transpileFormat: "esm",
43
+ transpileMinify: true,
44
+ transpilePublicPath: "/",
45
+ transpileSourcemap: "none",
46
+ transpileSplitting: false,
47
+ transpileStub: false,
48
+ transpileTarget: "node",
49
+ transpileWatch: false,
50
+ // Publish artifacts configuration
51
+ publishArtifacts: {
52
+ global: ["package.json", "README.md", "LICENSE"],
53
+ "dist-jsr": [],
54
+ "dist-npm": [],
55
+ "dist-libs": {}
56
+ }
57
+ };
58
+ export const defineConfigDler = (userConfig = {}) => {
59
+ return { ...DEFAULT_CONFIG_DLER, ...userConfig };
60
+ };
61
+ export * from "./rse/rse-mod.js";
@@ -0,0 +1,2 @@
1
+ import type { BiomeConfigResult } from "./rse-types";
2
+ export declare function getBiomeConfig(projectPath: string): Promise<BiomeConfigResult>;
@@ -0,0 +1,34 @@
1
+ import path from "@reliverse/pathkit";
2
+ import fs from "@reliverse/relifso";
3
+ import { relinka } from "@reliverse/relinka";
4
+ import { parseJSONC } from "confbox";
5
+ let cachedBiomeConfig = null;
6
+ export async function getBiomeConfig(projectPath) {
7
+ if (cachedBiomeConfig !== null) {
8
+ return cachedBiomeConfig;
9
+ }
10
+ try {
11
+ const biomePath = path.join(projectPath, "biome.jsonc");
12
+ if (await fs.pathExists(biomePath)) {
13
+ const content = await fs.readFile(biomePath, "utf-8");
14
+ const config = parseJSONC(content);
15
+ cachedBiomeConfig = {
16
+ lineWidth: config.formatter?.lineWidth ?? 80,
17
+ indentStyle: config.formatter?.indentStyle ?? "space",
18
+ indentWidth: config.formatter?.indentWidth ?? 2,
19
+ quoteMark: config.javascript?.formatter?.quoteStyle ?? "double",
20
+ semicolons: config.javascript?.formatter?.semicolons === "always",
21
+ trailingComma: config.javascript?.formatter?.trailingComma === "all"
22
+ };
23
+ return cachedBiomeConfig;
24
+ }
25
+ } catch (error) {
26
+ relinka(
27
+ "verbose",
28
+ "Error reading biome config:",
29
+ error instanceof Error ? error.message : String(error)
30
+ );
31
+ }
32
+ cachedBiomeConfig = null;
33
+ return null;
34
+ }
@@ -0,0 +1,35 @@
1
+ export declare const PROJECT_ROOT: string;
2
+ export declare const rseVersion = "1.7.4";
3
+ export declare const rseName = "@reliverse/rse";
4
+ export declare const tsconfigJson = "tsconfig.json";
5
+ export declare const cliConfigJsonc = ".config/rse.jsonc";
6
+ export declare const cliConfigJsoncTmp = ".config/rse.jsonc.tmp";
7
+ export declare const cliConfigJsoncBak = "rse.jsonc.bak";
8
+ export declare const cliConfigTs = ".config/rse.ts";
9
+ export declare const cliConfigTsTmp = ".config/rse.ts.tmp";
10
+ export declare const cliConfigTsBak = "rse.ts.bak";
11
+ export declare const rseOrg = "https://reliverse.org";
12
+ export declare const rseOrgBase = "reliverse.org";
13
+ export declare const cliDomainRoot = "https://docs.reliverse.org";
14
+ export declare const cliDomainDocs = "https://docs.reliverse.org/cli";
15
+ export declare const cliDomainEnv = "https://docs.reliverse.org/env";
16
+ export declare const homeDir: any;
17
+ export declare const cliHomeDir: string;
18
+ export declare const cliHomeTmp: string;
19
+ export declare const cliHomeRepos: string;
20
+ export declare const memoryPath: string;
21
+ export declare const cliJsrPath: string;
22
+ export declare const useLocalhost = false;
23
+ export declare const DEFAULT_CLI_USERNAME = "johnny911";
24
+ export declare const endTitle = "\uD83D\uDCDA Check the docs to learn more: https://docs.reliverse.org/cli";
25
+ export declare const UNKNOWN_VALUE = "unknown";
26
+ export declare const DEFAULT_DOMAIN = "https://example.com";
27
+ export declare const RSE_SCHEMA_DEV = "./schema.json";
28
+ export declare const RSE_SCHEMA_URL = "https://reliverse.org/schema.json";
29
+ export declare const FALLBACK_ENV_EXAMPLE_URL = "https://raw.githubusercontent.com/blefnk/relivator/main/.env.example";
30
+ export declare const CONFIG_CATEGORIES: {
31
+ readonly core: readonly [".config/rse.jsonc", ".config/rse.ts"];
32
+ readonly linting: readonly ["biome.json"];
33
+ readonly ide: readonly [".vscode/settings.json"];
34
+ readonly git: readonly [".gitignore"];
35
+ };
@@ -0,0 +1,37 @@
1
+ import path from "@reliverse/pathkit";
2
+ import os from "node:os";
3
+ export const PROJECT_ROOT = path.resolve(process.cwd());
4
+ export const rseVersion = "1.7.4";
5
+ export const rseName = "@reliverse/rse";
6
+ export const tsconfigJson = "tsconfig.json";
7
+ export const cliConfigJsonc = ".config/rse.jsonc";
8
+ export const cliConfigJsoncTmp = ".config/rse.jsonc.tmp";
9
+ export const cliConfigJsoncBak = "rse.jsonc.bak";
10
+ export const cliConfigTs = ".config/rse.ts";
11
+ export const cliConfigTsTmp = ".config/rse.ts.tmp";
12
+ export const cliConfigTsBak = "rse.ts.bak";
13
+ export const rseOrg = "https://reliverse.org";
14
+ export const rseOrgBase = "reliverse.org";
15
+ export const cliDomainRoot = "https://docs.reliverse.org";
16
+ export const cliDomainDocs = "https://docs.reliverse.org/cli";
17
+ export const cliDomainEnv = "https://docs.reliverse.org/env";
18
+ export const homeDir = os.homedir();
19
+ export const cliHomeDir = path.join(homeDir, ".reliverse");
20
+ export const cliHomeTmp = path.join(cliHomeDir, "temp");
21
+ export const cliHomeRepos = path.join(cliHomeDir, "repos");
22
+ export const memoryPath = path.join(cliHomeDir, "memory.db");
23
+ export const cliJsrPath = path.join(cliHomeDir, "cli");
24
+ export const useLocalhost = false;
25
+ export const DEFAULT_CLI_USERNAME = "johnny911";
26
+ export const endTitle = `\u{1F4DA} Check the docs to learn more: ${cliDomainDocs}`;
27
+ export const UNKNOWN_VALUE = "unknown";
28
+ export const DEFAULT_DOMAIN = "https://example.com";
29
+ export const RSE_SCHEMA_DEV = "./schema.json";
30
+ export const RSE_SCHEMA_URL = `${rseOrg}/schema.json`;
31
+ export const FALLBACK_ENV_EXAMPLE_URL = "https://raw.githubusercontent.com/blefnk/relivator/main/.env.example";
32
+ export const CONFIG_CATEGORIES = {
33
+ core: [cliConfigJsonc, cliConfigTs],
34
+ linting: ["biome.json"],
35
+ ide: [".vscode/settings.json"],
36
+ git: [".gitignore"]
37
+ };
@@ -0,0 +1,14 @@
1
+ export interface RequiredProjectContent {
2
+ fileRseConfig: boolean;
3
+ filePackageJson: boolean;
4
+ }
5
+ /**
6
+ * Gets information about the project content, separating required and optional elements.
7
+ */
8
+ export declare function getProjectContent(projectPath: string): Promise<{
9
+ requiredContent: RequiredProjectContent;
10
+ optionalContent: {
11
+ dirNodeModules: boolean;
12
+ dirGit: boolean;
13
+ };
14
+ }>;
@@ -0,0 +1,15 @@
1
+ import path from "@reliverse/pathkit";
2
+ import fs from "@reliverse/relifso";
3
+ import { cliConfigJsonc, cliConfigTs } from "./rse-consts.js";
4
+ export async function getProjectContent(projectPath) {
5
+ const configJSONC = path.join(projectPath, cliConfigJsonc);
6
+ const configTS = path.join(projectPath, cliConfigTs);
7
+ const fileRseConfig = await fs.pathExists(configJSONC) || await fs.pathExists(configTS);
8
+ const filePackageJson = await fs.pathExists(path.join(projectPath, "package.json"));
9
+ const dirNodeModules = await fs.pathExists(path.join(projectPath, "node_modules"));
10
+ const dirGit = await fs.pathExists(path.join(projectPath, ".git"));
11
+ return {
12
+ requiredContent: { fileRseConfig, filePackageJson },
13
+ optionalContent: { dirNodeModules, dirGit }
14
+ };
15
+ }
@@ -0,0 +1,14 @@
1
+ import type { RseConfig } from "./rse-types";
2
+ /**
3
+ * Retrieves or creates the main rseg (and any 'mrse' configs).
4
+ * Allows an optional custom path to the TS config file.
5
+ */
6
+ export declare function getOrCreateRseConfig({ projectPath, isDev, overrides, customTsconfigPath, }: {
7
+ projectPath: string;
8
+ isDev: boolean;
9
+ overrides: Partial<RseConfig>;
10
+ customTsconfigPath?: string;
11
+ }): Promise<{
12
+ config: RseConfig;
13
+ mrse: RseConfig[];
14
+ }>;
@@ -0,0 +1,63 @@
1
+ import path from "@reliverse/pathkit";
2
+ import fs from "@reliverse/relifso";
3
+ import { relinka } from "@reliverse/relinka";
4
+ import { UNKNOWN_VALUE, RSE_SCHEMA_DEV, cliConfigJsonc, cliConfigTs } from "./rse-consts.js";
5
+ import { createRseConfig } from "./rse-create.js";
6
+ import { DEFAULT_CONFIG_RSE } from "./rse-default.js";
7
+ import { getRseConfigPath } from "./rse-path.js";
8
+ import { readRseConfig } from "./rse-read.js";
9
+ import { parseAndFixRseConfig } from "./rse-repair.js";
10
+ export async function getOrCreateRseConfig({
11
+ projectPath,
12
+ isDev,
13
+ overrides,
14
+ customTsconfigPath
15
+ }) {
16
+ const githubUsername = UNKNOWN_VALUE;
17
+ const mrseFolderPath = path.join(projectPath, ".config", "mrse");
18
+ const results = [];
19
+ if (await fs.pathExists(mrseFolderPath)) {
20
+ const dirItems = await fs.readdir(mrseFolderPath);
21
+ const rseFiles = dirItems.filter((item) => item === cliConfigJsonc || item === cliConfigTs);
22
+ const configs = await Promise.all(
23
+ rseFiles.map(async (file) => {
24
+ const filePath = path.join(mrseFolderPath, file);
25
+ let foundConfig = await readRseConfig(filePath, isDev);
26
+ if (!foundConfig) {
27
+ foundConfig = await parseAndFixRseConfig(filePath, isDev);
28
+ }
29
+ if (!foundConfig) {
30
+ relinka("warn", `Skipping invalid config file: ${filePath}`);
31
+ }
32
+ return foundConfig;
33
+ })
34
+ );
35
+ results.push(...configs.filter((cfg) => cfg !== null));
36
+ }
37
+ const { configPath } = await getRseConfigPath(projectPath, isDev, false, customTsconfigPath);
38
+ if (!await fs.pathExists(configPath)) {
39
+ await createRseConfig(projectPath, githubUsername, isDev, overrides);
40
+ } else {
41
+ const content = (await fs.readFile(configPath, "utf-8")).trim();
42
+ if (!content || content === "{}") {
43
+ await createRseConfig(projectPath, githubUsername, isDev, overrides);
44
+ } else {
45
+ const validConfig = await readRseConfig(configPath, isDev);
46
+ if (!validConfig) {
47
+ const fixed = await parseAndFixRseConfig(configPath, isDev);
48
+ if (!fixed) {
49
+ relinka("warn", "Could not fix existing config. Using fallback defaults.");
50
+ }
51
+ }
52
+ }
53
+ }
54
+ const mainConfig = await readRseConfig(configPath, isDev);
55
+ if (!mainConfig) {
56
+ relinka("warn", "Using fallback default config due to validation failure.");
57
+ return { config: { ...DEFAULT_CONFIG_RSE }, mrse: results };
58
+ }
59
+ if (isDev) {
60
+ mainConfig.$schema = RSE_SCHEMA_DEV;
61
+ }
62
+ return { config: mainConfig, mrse: results };
63
+ }
@@ -0,0 +1,36 @@
1
+ import type { DeploymentService } from "./rse-types";
2
+ import type { RseConfig } from "./rse-types";
3
+ /**
4
+ * Writes the given rseConfig to the specified config file (TypeScript or JSONC).
5
+ * Performs an atomic write (using a temp file) and creates a backup of any existing config.
6
+ * In dev mode, automatically builds a relative path to `sdk-mod.ts`.
7
+ */
8
+ export declare function writeRseConfig(configPath: string, config: RseConfig, isDev: boolean, skipInstallPrompt?: boolean, customPathToTypes?: string): Promise<void>;
9
+ /**
10
+ * rse Config Creation (wrapper around config generator and fixer)
11
+ */
12
+ export declare function createRseConfig(projectPath: string, githubUsername: string, isDev: boolean, overrides: Partial<RseConfig>): Promise<void>;
13
+ /**
14
+ * Generates a rse config (rseConfig) by merging defaults, existing config, and overrides.
15
+ * Writes the resulting config to disk (TypeScript or JSONC), optionally skipping install prompts in non-dev mode.
16
+ */
17
+ export declare function generateRseConfig({ projectName, frontendUsername, deployService, primaryDomain, projectPath, githubUsername, enableI18n, overwrite, isDev, configInfo, customOutputPath, customFilename, skipInstallPrompt, customPathToTypes, overrides, }: {
18
+ projectName: string;
19
+ frontendUsername: string;
20
+ deployService: DeploymentService;
21
+ primaryDomain: string;
22
+ projectPath: string;
23
+ githubUsername: string;
24
+ enableI18n?: boolean;
25
+ overwrite?: boolean;
26
+ isDev: boolean;
27
+ configInfo?: {
28
+ configPath: string;
29
+ isTS: boolean;
30
+ };
31
+ customOutputPath?: string;
32
+ customFilename?: string;
33
+ skipInstallPrompt?: boolean;
34
+ customPathToTypes?: string;
35
+ overrides: Partial<RseConfig>;
36
+ }): Promise<void>;