@reliverse/dler 1.7.10 → 1.7.11

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 (48) hide show
  1. package/README.md +216 -10
  2. package/bin/app/build/cmd.js +11 -2
  3. package/bin/app/build/impl.d.ts +3 -2
  4. package/bin/app/build/impl.js +50 -34
  5. package/bin/app/merge/cmd.d.ts +32 -0
  6. package/bin/app/merge/cmd.js +563 -246
  7. package/bin/app/mkdist/cmd.d.ts +0 -4
  8. package/bin/app/mkdist/cmd.js +0 -4
  9. package/bin/app/mock/cmd.d.ts +41 -0
  10. package/bin/app/mock/cmd.js +284 -0
  11. package/bin/app/mock/mock.d.ts +11 -0
  12. package/bin/app/mock/mock.js +97 -0
  13. package/bin/app/pub/cmd.js +10 -1
  14. package/bin/libs/sdk/sdk-impl/build/build-library.js +9 -2
  15. package/bin/libs/sdk/sdk-impl/build/build-regular.js +25 -12
  16. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.d.ts +4 -1
  17. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/build.js +6 -7
  18. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/loaders/sass.js +1 -1
  19. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/make.js +1 -1
  20. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/dts.js +1 -1
  21. package/bin/libs/sdk/sdk-impl/build/bundlers/unified/mkdist/mkdist-impl/utils/vue-dts.js +1 -1
  22. package/bin/libs/sdk/sdk-impl/cfg/info.js +1 -1
  23. package/bin/libs/sdk/sdk-impl/spell/spell-parser.d.ts +1 -1
  24. package/bin/libs/sdk/sdk-impl/spell/spell-parser.js +2 -2
  25. package/bin/libs/sdk/sdk-impl/spell/spell-types.d.ts +27 -1
  26. package/bin/libs/sdk/sdk-impl/utils/b-exts.d.ts +5 -0
  27. package/bin/libs/sdk/sdk-impl/utils/b-exts.js +406 -0
  28. package/bin/libs/sdk/sdk-impl/utils/binary.d.ts +4 -0
  29. package/bin/libs/sdk/sdk-impl/utils/binary.js +11 -0
  30. package/bin/libs/sdk/sdk-impl/utils/file-type.d.ts +21 -0
  31. package/bin/libs/sdk/sdk-impl/utils/file-type.js +78 -0
  32. package/bin/libs/sdk/sdk-impl/utils/utils-clean.js +0 -1
  33. package/bin/libs/sdk/sdk-impl/utils/utils-fs.d.ts +28 -6
  34. package/bin/libs/sdk/sdk-impl/utils/utils-fs.js +73 -124
  35. package/bin/libs/sdk/sdk-impl/utils/utils-jsr-json.js +20 -2
  36. package/bin/libs/sdk/sdk-impl/utils/utils-security.d.ts +15 -0
  37. package/bin/libs/sdk/sdk-impl/utils/utils-security.js +102 -0
  38. package/bin/libs/sdk/sdk-mod.d.ts +3 -3
  39. package/bin/libs/sdk/sdk-mod.js +3 -2
  40. package/bin/libs/sdk/sdk-types.d.ts +15 -4
  41. package/package.json +2 -2
  42. package/bin/app/conv/README.md +0 -3
  43. package/bin/app/merge/README.md +0 -125
  44. package/bin/app/split/README.md +0 -13
  45. /package/bin/libs/sdk/sdk-impl/utils/{tools/tools-agg.d.ts → tools-agg.d.ts} +0 -0
  46. /package/bin/libs/sdk/sdk-impl/utils/{tools/tools-agg.js → tools-agg.js} +0 -0
  47. /package/bin/libs/sdk/sdk-impl/utils/{tools/tools-impl.d.ts → tools-impl.d.ts} +0 -0
  48. /package/bin/libs/sdk/sdk-impl/utils/{tools/tools-impl.js → tools-impl.js} +0 -0
@@ -75,9 +75,5 @@ declare const _default: import("@reliverse/rempts").Command<{
75
75
  type: "string";
76
76
  description: string;
77
77
  };
78
- dontBuildCopyInstead: {
79
- type: "string";
80
- description: string;
81
- };
82
78
  }>;
83
79
  export default _default;
@@ -86,10 +86,6 @@ export default defineCommand({
86
86
  target: {
87
87
  type: "string",
88
88
  description: "Target environment (esbuild)"
89
- },
90
- dontBuildCopyInstead: {
91
- type: "string",
92
- description: "Don't build copy instead of (glob patterns, e.g. '**/*.json') (default: ['**/templates'])"
93
89
  }
94
90
  }),
95
91
  async run({ args }) {
@@ -0,0 +1,41 @@
1
+ declare const _default: import("@reliverse/rempts").Command<{
2
+ template: {
3
+ type: "string";
4
+ description: string;
5
+ default: string;
6
+ };
7
+ "template-file": {
8
+ type: "string";
9
+ description: string;
10
+ };
11
+ "template-consts": {
12
+ type: "string";
13
+ description: string;
14
+ };
15
+ cleanup: {
16
+ type: "boolean";
17
+ description: string;
18
+ default: false;
19
+ };
20
+ "dry-run": {
21
+ type: "boolean";
22
+ description: string;
23
+ default: false;
24
+ };
25
+ verbose: {
26
+ type: "boolean";
27
+ description: string;
28
+ default: false;
29
+ };
30
+ whitelabel: {
31
+ type: "string";
32
+ description: string;
33
+ default: string;
34
+ };
35
+ force: {
36
+ type: "boolean";
37
+ description: string;
38
+ default: true;
39
+ };
40
+ }>;
41
+ export default _default;
@@ -0,0 +1,284 @@
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
+ });
@@ -0,0 +1,11 @@
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>;
@@ -0,0 +1,97 @@
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) => 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,6 +1,8 @@
1
1
  import { defineArgs, defineCommand } from "@reliverse/rempts";
2
2
  import { dlerPub } from "../build/impl.js";
3
3
  import { ensureDlerConfig } from "../../libs/sdk/sdk-impl/cfg/init.js";
4
+ import { loadConfig } from "../../libs/sdk/sdk-impl/cfg/load.js";
5
+ import { removeDistFolders } from "../../libs/sdk/sdk-mod.js";
4
6
  export default defineCommand({
5
7
  meta: {
6
8
  name: "build",
@@ -14,6 +16,13 @@ export default defineCommand({
14
16
  }),
15
17
  async run({ args }) {
16
18
  await ensureDlerConfig(args.dev);
17
- await dlerPub(args.dev);
19
+ const config = await loadConfig();
20
+ await removeDistFolders(
21
+ config.distNpmDirName,
22
+ config.distJsrDirName,
23
+ config.libsDirDist,
24
+ config.libsList
25
+ );
26
+ await dlerPub(args.dev, config);
18
27
  }
19
28
  });
@@ -140,7 +140,6 @@ async function library_buildJsrDist(options) {
140
140
  };
141
141
  await library_buildDistributionTarget(buildParams);
142
142
  relinka("verbose", `[JSR] Performing JSR-specific transformations in ${outputDirBinResolved}`);
143
- await renameTsxFiles(outputDirBinResolved);
144
143
  await createJsrJSON(
145
144
  outputDirRootResolved,
146
145
  true,
@@ -149,6 +148,7 @@ async function library_buildJsrDist(options) {
149
148
  libName,
150
149
  libConfig?.libDescription ?? ""
151
150
  );
151
+ await renameTsxFiles(outputDirBinResolved);
152
152
  const dirSize = await getDirectorySize(outputDirRootResolved, options.isDev);
153
153
  const filesCount = await outDirBinFilesCount(outputDirBinResolved);
154
154
  relinka(
@@ -485,7 +485,14 @@ async function library_bundleUsingUnified(entryPoint, outDirBin, builder, _sourc
485
485
  stub: transpileStub
486
486
  };
487
487
  try {
488
- await unifiedBuild(entryPoint, false, true, rootDir, unifiedBuildConfig, outDirBin);
488
+ await unifiedBuild(
489
+ entryPoint,
490
+ { enabled: false, scripts: {} },
491
+ true,
492
+ rootDir,
493
+ unifiedBuildConfig,
494
+ outDirBin
495
+ );
489
496
  const duration = getElapsedPerfTime(timer);
490
497
  relinka(
491
498
  "success",
@@ -14,13 +14,16 @@ import {
14
14
  PROJECT_ROOT,
15
15
  validExtensions
16
16
  } from "../utils/utils-consts.js";
17
- import { copyRootFile, deleteSpecificFiles } from "../utils/utils-fs.js";
17
+ import {
18
+ copyInsteadOfBuild,
19
+ copyRootFile,
20
+ deleteSpecificFiles
21
+ } from "../utils/utils-fs.js";
18
22
  import { createJsrJSON, renameTsxFiles } from "../utils/utils-jsr-json.js";
19
23
  import { regular_createPackageJSON } from "../utils/utils-package-json-regular.js";
20
24
  import { getElapsedPerfTime } from "../utils/utils-perf.js";
21
25
  const ALIAS_PREFIX_TO_CONVERT = "~";
22
26
  export async function regular_buildJsrDist(isDev, isJsr, coreIsCLI, coreEntrySrcDir, distJsrDirName, distJsrBuilder, coreEntryFile, transpileTarget, transpileFormat, transpileSplitting, transpileMinify, transpileSourcemap, transpilePublicPath, unifiedBundlerOutExt, config, timer, transpileStub, transpileWatch, distJsrGenTsconfig, coreDeclarations) {
23
- const isCLI = coreIsCLI.enabled;
24
27
  const outDirRoot = path.join(process.cwd(), distJsrDirName);
25
28
  const outDirBin = path.join(outDirRoot, config.coreBuildOutDir || "bin");
26
29
  const singleFile = path.join(process.cwd(), coreEntrySrcDir, coreEntryFile);
@@ -29,7 +32,7 @@ export async function regular_buildJsrDist(isDev, isJsr, coreIsCLI, coreEntrySrc
29
32
  try {
30
33
  await fs.ensureDir(outDirBin);
31
34
  await regular_bundleWithBuilder(distJsrBuilder, {
32
- isCLI,
35
+ coreIsCLI: { enabled: coreIsCLI.enabled, scripts: coreIsCLI.scripts },
33
36
  coreDeclarations,
34
37
  outDir: outDirBin,
35
38
  singleFile,
@@ -59,7 +62,6 @@ export async function regular_buildJsrDist(isDev, isJsr, coreIsCLI, coreEntrySrc
59
62
  await regular_createTsconfig(outDirRoot);
60
63
  }
61
64
  relinka("verbose", `Performing JSR-specific transformations in ${outDirBin}`);
62
- await renameTsxFiles(outDirBin);
63
65
  await createJsrJSON(
64
66
  outDirRoot,
65
67
  false,
@@ -71,6 +73,13 @@ export async function regular_buildJsrDist(isDev, isJsr, coreIsCLI, coreEntrySrc
71
73
  // libName (not needed for regular builds)
72
74
  config.coreDescription
73
75
  );
76
+ if (coreIsCLI.enabled) {
77
+ await copyInsteadOfBuild(path.join(PROJECT_ROOT, coreEntrySrcDir), outDirBin, [
78
+ `${config.distNpmDirName}/**/templates`,
79
+ `${config.distJsrDirName}/**/templates`
80
+ ]);
81
+ }
82
+ await renameTsxFiles(outDirBin);
74
83
  const duration = getElapsedPerfTime(timer);
75
84
  const transpileFormattedDuration = prettyMilliseconds(duration, {
76
85
  verbose: true
@@ -87,7 +96,6 @@ export async function regular_buildJsrDist(isDev, isJsr, coreIsCLI, coreEntrySrc
87
96
  }
88
97
  }
89
98
  export async function regular_buildNpmDist(isDev, coreIsCLI, coreEntrySrcDir, distNpmDirName, distNpmBuilder, coreEntryFile, unifiedBundlerOutExt, config, transpileTarget, transpileFormat, transpileSplitting, transpileMinify, transpileSourcemap, transpilePublicPath, transpileStub, transpileWatch, timer, coreDeclarations) {
90
- const isCLI = coreIsCLI.enabled;
91
99
  const outDirRoot = path.join(process.cwd(), distNpmDirName);
92
100
  const outDirBin = path.join(outDirRoot, config.coreBuildOutDir || "bin");
93
101
  const singleFile = path.join(process.cwd(), coreEntrySrcDir, coreEntryFile);
@@ -96,7 +104,7 @@ export async function regular_buildNpmDist(isDev, coreIsCLI, coreEntrySrcDir, di
96
104
  try {
97
105
  await fs.ensureDir(outDirBin);
98
106
  await regular_bundleWithBuilder(distNpmBuilder, {
99
- isCLI,
107
+ coreIsCLI: { enabled: coreIsCLI.enabled, scripts: coreIsCLI.scripts },
100
108
  coreDeclarations,
101
109
  outDir: outDirBin,
102
110
  singleFile,
@@ -122,6 +130,12 @@ export async function regular_buildNpmDist(isDev, coreIsCLI, coreEntrySrcDir, di
122
130
  coreDescription: config.coreDescription,
123
131
  coreBuildOutDir: config.coreBuildOutDir
124
132
  });
133
+ if (coreIsCLI.enabled) {
134
+ await copyInsteadOfBuild(path.join(PROJECT_ROOT, coreEntrySrcDir), outDirBin, [
135
+ `${config.distNpmDirName}/**/templates`,
136
+ `${config.distJsrDirName}/**/templates`
137
+ ]);
138
+ }
125
139
  const duration = getElapsedPerfTime(timer);
126
140
  const transpileFormattedDuration = prettyMilliseconds(duration, {
127
141
  verbose: true
@@ -214,7 +228,7 @@ async function regular_bundleUsingJsr(src, dest) {
214
228
  throw new Error(errorMessage);
215
229
  }
216
230
  }
217
- async function regular_bundleUsingUnified(isCLI, coreEntryFile, outDirBin, builder, unifiedBundlerOutExt, coreEntrySrcDir, transpileStub, transpileWatch, transpileTarget, transpileMinify, transpileSourcemap, timer, coreDeclarations) {
231
+ async function regular_bundleUsingUnified(coreIsCLI, coreEntryFile, outDirBin, builder, unifiedBundlerOutExt, coreEntrySrcDir, transpileStub, transpileWatch, transpileTarget, transpileMinify, transpileSourcemap, timer, coreDeclarations) {
218
232
  if (builder === "jsr" || builder === "bun") {
219
233
  throw new Error("'jsr'/'bun' builder not supported for regular_bundleUsingUnified");
220
234
  }
@@ -256,10 +270,9 @@ async function regular_bundleUsingUnified(isCLI, coreEntryFile, outDirBin, build
256
270
  },
257
271
  showOutLog: true,
258
272
  transpileStub,
259
- transpileWatch: transpileWatch ?? false,
260
- dontBuildCopyInstead: ["**/templates"]
273
+ transpileWatch: transpileWatch ?? false
261
274
  };
262
- await unifiedBuild(coreEntrySrcDir, isCLI, false, rootDir, unifiedBuildConfig, outDirBin);
275
+ await unifiedBuild(coreEntrySrcDir, coreIsCLI, false, rootDir, unifiedBuildConfig, outDirBin);
263
276
  const duration = getElapsedPerfTime(timer);
264
277
  const transpileFormattedDuration = prettyMilliseconds(duration, {
265
278
  verbose: true
@@ -280,7 +293,7 @@ async function regular_bundleUsingUnified(isCLI, coreEntryFile, outDirBin, build
280
293
  }
281
294
  async function regular_bundleWithBuilder(builder, params) {
282
295
  const {
283
- isCLI,
296
+ coreIsCLI,
284
297
  coreDeclarations,
285
298
  outDir,
286
299
  singleFile,
@@ -315,7 +328,7 @@ async function regular_bundleWithBuilder(builder, params) {
315
328
  return;
316
329
  }
317
330
  await regular_bundleUsingUnified(
318
- isCLI,
331
+ coreIsCLI,
319
332
  singleFile,
320
333
  outDir,
321
334
  builder,
@@ -1,5 +1,8 @@
1
1
  import type { UnifiedBuildConfig } from "../../../../sdk-types.js";
2
- export declare function unifiedBuild(inputSourceDir: string, isCLI: boolean, isLib: boolean, rootDir: string, inputConfig: UnifiedBuildConfig & {
2
+ export declare function unifiedBuild(inputSourceDir: string, coreIsCLI: {
3
+ enabled: boolean;
4
+ scripts: Record<string, string>;
5
+ }, isLib: boolean, rootDir: string, inputConfig: UnifiedBuildConfig & {
3
6
  config?: string;
4
7
  showOutLog?: boolean;
5
8
  }, outDir: string, transpileStub?: boolean): Promise<void>;