@reliverse/dler 1.7.45 → 1.7.47

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.
@@ -53,7 +53,7 @@ export async function dlerBuild(isDev, config, debugOnlyCopyNonBuildFiles, debug
53
53
  await regular_buildFlow(timer, isDev, tempConfig);
54
54
  await library_buildFlow(timer, isDev, tempConfig);
55
55
  await dlerPostBuild(isDev, debugDontCopyNonBuildFiles);
56
- if (effectiveConfig.postBuildSettings?.cleanupTempDirs) {
56
+ if (effectiveConfig.postBuildSettings?.deleteDistTmpAfterBuild) {
57
57
  await fs.remove(path.join(PROJECT_ROOT, "dist-tmp"));
58
58
  }
59
59
  return { timer, effectiveConfig };
@@ -5,7 +5,7 @@ import { runCmd } from "@reliverse/rempts";
5
5
  import { glob } from "tinyglobby";
6
6
  import { getCheckCmd } from "../cmds.js";
7
7
  import { getConfigDler } from "../../libs/sdk/sdk-impl/config/load.js";
8
- import { applyMagicSpells } from "../../libs/sdk/sdk-impl/magic/ms-apply.js";
8
+ import { applyMagicSpells } from "../../libs/sdk/sdk-impl/magic/magic-apply.js";
9
9
  import { resolveAllCrossLibs } from "../../libs/sdk/sdk-impl/utils/resolve-cross-libs.js";
10
10
  import { PROJECT_ROOT } from "../../libs/sdk/sdk-impl/utils/utils-consts.js";
11
11
  import { directoryExists, executeDlerHooks } from "./ppb-utils.js";
@@ -1,5 +1,5 @@
1
1
  import { defineArgs, defineCommand } from "@reliverse/rempts";
2
- import { applyMagicSpells } from "../../libs/sdk/sdk-impl/magic/ms-apply.js";
2
+ import { applyMagicSpells } from "../../libs/sdk/sdk-impl/magic/magic-apply.js";
3
3
  import { formatError } from "../../libs/sdk/sdk-impl/utils/utils-error-cwd.js";
4
4
  export default defineCommand({
5
5
  meta: {
@@ -296,7 +296,7 @@ export interface Templates extends Record<string, Template> {}
296
296
  "",
297
297
  `export const ${WL}_TEMPLATES = ${WL}_TEMPLATES_OBJ as const;`,
298
298
  "",
299
- `export type ${WL}_TEMPLATE_NAMES = keyof typeof ${WL}_TEMPLATES;`,
299
+ `export interface ${WL}_TEMPLATE_NAMES extends keyof typeof ${WL}_TEMPLATES {}`,
300
300
  "",
301
301
  `export const dlerTemplatesMap: Record<string, ${WL}_TEMPLATE_NAMES> = {`,
302
302
  ...mapEntries,
@@ -51,7 +51,7 @@ export declare const defineConfigDler: (userConfig?: Partial<DlerConfig>) => {
51
51
  hooksBeforeBuild: (() => Promise<void>)[];
52
52
  hooksAfterBuild: (() => Promise<void>)[];
53
53
  postBuildSettings: {
54
- cleanupTempDirs: boolean;
54
+ deleteDistTmpAfterBuild: boolean;
55
55
  };
56
56
  transpileFailOnWarn: boolean;
57
57
  transpileEsbuild: import("./cfg-types").Esbuild;
@@ -53,7 +53,7 @@ export const DEFAULT_CONFIG_DLER = {
53
53
  // }
54
54
  ],
55
55
  postBuildSettings: {
56
- cleanupTempDirs: true
56
+ deleteDistTmpAfterBuild: true
57
57
  },
58
58
  // Build setup
59
59
  transpileFailOnWarn: false,
@@ -369,7 +369,7 @@ export interface DlerConfig {
369
369
  * @default true
370
370
  */
371
371
  postBuildSettings: {
372
- cleanupTempDirs: boolean;
372
+ deleteDistTmpAfterBuild: boolean;
373
373
  };
374
374
  /**
375
375
  * When `true`, fails the build if warnings are detected.
@@ -33,8 +33,6 @@ export declare const defineConfigRse: (userConfig?: Partial<RseConfig>) => {
33
33
  themes?: string[] | undefined;
34
34
  } | undefined;
35
35
  preferredLibraries?: {
36
- search?: "unknown" | "algolia" | undefined;
37
- cdn?: "unknown" | "cloudflare" | undefined;
38
36
  i18n?: "unknown" | "next-intl" | undefined;
39
37
  analytics?: "unknown" | "vercel" | undefined;
40
38
  authentication?: "unknown" | "better-auth" | "clerk" | "next-auth" | "supabase-auth" | "auth0" | undefined;
@@ -53,6 +51,7 @@ export declare const defineConfigRse: (userConfig?: Partial<RseConfig>) => {
53
51
  logging?: "unknown" | "axiom" | undefined;
54
52
  forms?: "unknown" | "react-hook-form" | undefined;
55
53
  notifications?: "unknown" | "sonner" | undefined;
54
+ search?: "unknown" | "algolia" | undefined;
56
55
  uploads?: "unknown" | "uploadthing" | undefined;
57
56
  validation?: "unknown" | "zod" | "typebox" | "valibot" | undefined;
58
57
  documentation?: "unknown" | "starlight" | "nextra" | undefined;
@@ -60,6 +59,7 @@ export declare const defineConfigRse: (userConfig?: Partial<RseConfig>) => {
60
59
  mail?: "unknown" | "resend" | undefined;
61
60
  cache?: "unknown" | "redis" | undefined;
62
61
  storage?: "unknown" | "cloudflare" | undefined;
62
+ cdn?: "unknown" | "cloudflare" | undefined;
63
63
  cms?: "unknown" | "contentlayer" | undefined;
64
64
  seo?: "unknown" | "next-seo" | undefined;
65
65
  motion?: "unknown" | "framer" | undefined;
@@ -51,7 +51,7 @@ export const DEFAULT_CONFIG_DLER = {
51
51
  // }
52
52
  ],
53
53
  postBuildSettings: {
54
- cleanupTempDirs: true
54
+ deleteDistTmpAfterBuild: true
55
55
  },
56
56
  // Build setup
57
57
  transpileFailOnWarn: false,
@@ -1,5 +1,5 @@
1
1
  import { endPrompt, startPrompt } from "@reliverse/rempts";
2
- const version = "1.7.45";
2
+ const version = "1.7.47";
3
3
  export async function showStartPrompt(isDev) {
4
4
  await startPrompt({
5
5
  titleColor: "inverse",
@@ -248,7 +248,7 @@ function generateConfig(isDev, pkgDescription) {
248
248
  " ],",
249
249
  "",
250
250
  " postBuildSettings: {",
251
- " cleanupTempDirs: true,",
251
+ " deleteDistTmpAfterBuild: true,",
252
252
  " },",
253
253
  "",
254
254
  " // Build setup",
@@ -369,7 +369,7 @@ export interface DlerConfig {
369
369
  * @default true
370
370
  */
371
371
  postBuildSettings: {
372
- cleanupTempDirs: boolean;
372
+ deleteDistTmpAfterBuild: boolean;
373
373
  };
374
374
  /**
375
375
  * When `true`, fails the build if warnings are detected.
@@ -25,6 +25,8 @@ export interface ApplyMagicSpellsOptions {
25
25
  export interface ApplyMagicSpellsResult {
26
26
  /** All processed files */
27
27
  processedFiles: string[];
28
+ /** Total number of magic spells processed */
29
+ totalSpellsProcessed: number;
28
30
  }
29
31
  /**
30
32
  * Processes files in specified output directories by applying magic directives
@@ -6,7 +6,7 @@ import { isBinaryExt } from "../utils/binary.js";
6
6
  import { formatError } from "../utils/utils-error-cwd.js";
7
7
  import {
8
8
  evaluateMagicDirective
9
- } from "./ms-spells.js";
9
+ } from "./magic-spells.js";
10
10
  const DEBUG_MODE = true;
11
11
  const PROCESS_DTS_FILES = true;
12
12
  const DEFAULT_OPTIONS = {
@@ -24,72 +24,60 @@ function validateTargets(targets, customOutputPaths) {
24
24
  const outputDirs = /* @__PURE__ */ new Set();
25
25
  const specificLibs = /* @__PURE__ */ new Set();
26
26
  const customTargets = /* @__PURE__ */ new Set();
27
- const validTargets = [];
28
27
  const allOutputPaths = { ...DEFAULT_OUTPUT_PATHS, ...customOutputPaths };
29
28
  for (const target of targets) {
30
29
  const [outputDir, lib] = target.split("/");
31
30
  if (!outputDir) {
32
- relinka("warn", `Skipping invalid output target: ${target}`);
33
- continue;
34
- }
35
- const outputPath = allOutputPaths[outputDir] || outputDir;
36
- const fullPath = path.isAbsolute(outputPath) ? outputPath : path.join(process.cwd(), outputPath);
37
- if (!fs.existsSync(fullPath)) {
38
- relinka("warn", `Skipping non-existent output directory: ${outputPath}`);
39
- continue;
31
+ throw new Error(`Invalid output target: ${target}`);
40
32
  }
41
33
  const isCustomTarget = !["dist-npm", "dist-jsr", "dist-libs"].includes(outputDir);
42
34
  if (isCustomTarget) {
43
35
  if (customTargets.has(outputDir)) {
44
- relinka("warn", `Skipping duplicate custom target: ${outputDir}`);
45
- continue;
36
+ throw new Error(`Duplicate custom target: ${outputDir}`);
46
37
  }
47
38
  customTargets.add(outputDir);
48
- validTargets.push(target);
39
+ const outputPath = allOutputPaths[outputDir] || outputDir;
40
+ const fullPath = path.isAbsolute(outputPath) ? outputPath : path.join(process.cwd(), outputPath);
41
+ if (!fs.existsSync(fullPath)) {
42
+ throw new Error(`Output directory does not exist: ${outputPath}`);
43
+ }
49
44
  continue;
50
45
  }
51
46
  if (outputDir === "dist-libs") {
52
47
  if (lib) {
53
48
  if (specificLibs.has(lib)) {
54
- relinka("warn", `Skipping duplicate library target: ${target}`);
55
- continue;
49
+ throw new Error(`Duplicate library target: ${target}`);
56
50
  }
57
51
  specificLibs.add(lib);
58
52
  } else {
59
53
  if (outputDirs.has("dist-libs") || specificLibs.size > 0) {
60
- relinka("warn", "Skipping 'dist-libs' as it conflicts with specific library targets");
61
- continue;
54
+ throw new Error("Cannot mix 'dist-libs' with specific library targets");
62
55
  }
63
56
  outputDirs.add("dist-libs");
64
57
  }
65
58
  } else {
66
59
  if (outputDirs.has(outputDir)) {
67
- relinka("warn", `Skipping duplicate output target: ${outputDir}`);
68
- continue;
60
+ throw new Error(`Duplicate output target: ${outputDir}`);
69
61
  }
70
62
  outputDirs.add(outputDir);
71
63
  }
72
- validTargets.push(target);
73
64
  }
74
- return validTargets;
75
65
  }
76
66
  export async function applyMagicSpells(targets, options = {}) {
77
67
  const result = {
78
- processedFiles: []
68
+ processedFiles: [],
69
+ totalSpellsProcessed: 0
79
70
  };
80
71
  try {
81
- const validTargets = validateTargets(targets, options.customOutputPaths);
82
- if (validTargets.length === 0) {
83
- relinka("warn", "No valid targets found to process");
84
- return result;
85
- }
72
+ validateTargets(targets, options.customOutputPaths);
86
73
  await pMap(
87
- validTargets,
74
+ targets,
88
75
  async (target) => {
89
76
  const [outputDir, lib] = target.split("/");
90
77
  if (outputDir && !["dist-npm", "dist-jsr", "dist-libs"].includes(outputDir)) {
91
78
  const targetResult = await processCustomTarget(outputDir, options);
92
79
  result.processedFiles.push(...targetResult.processedFiles);
80
+ result.totalSpellsProcessed += targetResult.totalSpellsProcessed;
93
81
  return;
94
82
  }
95
83
  const srcRoot = path.resolve(process.cwd(), "src");
@@ -106,25 +94,36 @@ export async function applyMagicSpells(targets, options = {}) {
106
94
  if (outputDir === "dist-libs") {
107
95
  if (!lib) {
108
96
  const distLibsPath = DEFAULT_OUTPUT_PATHS["dist-libs"] ?? "dist-libs";
109
- const libDirs = await readdir(distLibsPath, { withFileTypes: true });
110
- await pMap(
111
- libDirs,
112
- async (libDir) => {
113
- if (libDir.isDirectory()) {
114
- const targetResult = await processOutputTarget(
115
- sourceFilesWithDirectives,
116
- "dist-libs",
117
- libDir.name,
118
- options
119
- );
120
- result.processedFiles.push(...targetResult.processedFiles);
121
- }
122
- },
123
- {
124
- concurrency: options.concurrency ?? 4,
125
- stopOnError: options.stopOnError ?? true
97
+ try {
98
+ if (await fs.pathExists(distLibsPath)) {
99
+ const libDirs = await readdir(distLibsPath, { withFileTypes: true });
100
+ await pMap(
101
+ libDirs,
102
+ async (libDir) => {
103
+ if (libDir.isDirectory()) {
104
+ const targetResult = await processOutputTarget(
105
+ sourceFilesWithDirectives,
106
+ "dist-libs",
107
+ libDir.name,
108
+ options
109
+ );
110
+ result.processedFiles.push(...targetResult.processedFiles);
111
+ result.totalSpellsProcessed += targetResult.totalSpellsProcessed;
112
+ }
113
+ },
114
+ {
115
+ concurrency: options.concurrency ?? 4,
116
+ stopOnError: options.stopOnError ?? true
117
+ }
118
+ );
119
+ } else if (DEBUG_MODE) {
120
+ relinka("log", `[spells] \u2298 skipping non-existent target: ${distLibsPath}`);
126
121
  }
127
- );
122
+ } catch (error) {
123
+ if (DEBUG_MODE) {
124
+ relinka("warn", `Failed to process dist-libs: ${formatError(error)}`);
125
+ }
126
+ }
128
127
  } else {
129
128
  const targetResult = await processOutputTarget(
130
129
  sourceFilesWithDirectives,
@@ -133,6 +132,7 @@ export async function applyMagicSpells(targets, options = {}) {
133
132
  options
134
133
  );
135
134
  result.processedFiles.push(...targetResult.processedFiles);
135
+ result.totalSpellsProcessed += targetResult.totalSpellsProcessed;
136
136
  }
137
137
  } else if (outputDir) {
138
138
  const targetResult = await processOutputTarget(
@@ -142,6 +142,7 @@ export async function applyMagicSpells(targets, options = {}) {
142
142
  options
143
143
  );
144
144
  result.processedFiles.push(...targetResult.processedFiles);
145
+ result.totalSpellsProcessed += targetResult.totalSpellsProcessed;
145
146
  }
146
147
  },
147
148
  {
@@ -149,6 +150,12 @@ export async function applyMagicSpells(targets, options = {}) {
149
150
  stopOnError: options.stopOnError ?? true
150
151
  }
151
152
  );
153
+ if (DEBUG_MODE) {
154
+ relinka(
155
+ "log",
156
+ `[spells] \u2713 Processed ${result.totalSpellsProcessed} magic spells in ${result.processedFiles.length} files`
157
+ );
158
+ }
152
159
  return result;
153
160
  } catch (error) {
154
161
  throw new Error(`Failed to process output files: ${formatError(error)}`);
@@ -157,7 +164,8 @@ export async function applyMagicSpells(targets, options = {}) {
157
164
  async function processCustomTarget(outputDir, options = {}) {
158
165
  const { concurrency = DEFAULT_OPTIONS.concurrency, batchSize = DEFAULT_OPTIONS.batchSize } = options;
159
166
  const result = {
160
- processedFiles: []
167
+ processedFiles: [],
168
+ totalSpellsProcessed: 0
161
169
  };
162
170
  if (DEBUG_MODE) {
163
171
  relinka("log", `[spells] \u21D2 processing custom target: ${outputDir}`);
@@ -205,6 +213,9 @@ async function processCustomTarget(outputDir, options = {}) {
205
213
  const wasProcessed = await processSingleOutputFile(outputFilePath, options);
206
214
  if (wasProcessed) {
207
215
  result.processedFiles.push(outputFilePath);
216
+ const content = await fs.readFile(outputFilePath, "utf8");
217
+ const spellCount = (content.match(/\/\/\s*(?:@ts-expect-error\s+.*?)?<\s*(dler-[^>\s]+)(.*?)>/gi) || []).length;
218
+ result.totalSpellsProcessed += spellCount;
208
219
  }
209
220
  } catch (error) {
210
221
  const errorMessage = `Error processing ${outputFilePath}: ${formatError(error)}`;
@@ -259,8 +270,18 @@ async function scanSourceForMagicDirectives(srcRoot, options = {}) {
259
270
  async function processOutputTarget(sourceFilesWithDirectives, outputDir, libName, options = {}) {
260
271
  const { concurrency = DEFAULT_OPTIONS.concurrency, batchSize = DEFAULT_OPTIONS.batchSize } = options;
261
272
  const result = {
262
- processedFiles: []
273
+ processedFiles: [],
274
+ totalSpellsProcessed: 0
263
275
  };
276
+ const outputPath = options.customOutputPaths?.[outputDir] || outputDir;
277
+ const fullOutputPath = path.isAbsolute(outputPath) ? outputPath : path.join(process.cwd(), outputPath);
278
+ if (!await fs.pathExists(fullOutputPath)) {
279
+ if (DEBUG_MODE) {
280
+ const targetName = outputDir === "dist-libs" && libName ? `${outputDir}/${libName}` : outputDir;
281
+ relinka("log", `[spells] \u2298 skipping non-existent target: ${targetName}`);
282
+ }
283
+ return result;
284
+ }
264
285
  if (DEBUG_MODE) {
265
286
  const targetName = outputDir === "dist-libs" && libName ? `${outputDir}/${libName}` : outputDir;
266
287
  relinka("log", `[spells] \u21D2 processing target: ${targetName}`);
@@ -291,6 +312,9 @@ async function processOutputTarget(sourceFilesWithDirectives, outputDir, libName
291
312
  const wasProcessed = await processSingleOutputFile(outputFilePath, options);
292
313
  if (wasProcessed) {
293
314
  result.processedFiles.push(outputFilePath);
315
+ const content = await fs.readFile(outputFilePath, "utf8");
316
+ const spellCount = (content.match(/\/\/\s*(?:@ts-expect-error\s+.*?)?<\s*(dler-[^>\s]+)(.*?)>/gi) || []).length;
317
+ result.totalSpellsProcessed += spellCount;
294
318
  }
295
319
  } catch (error) {
296
320
  const errorMessage = `Error processing ${outputFilePath}: ${formatError(error)}`;
@@ -498,7 +522,7 @@ async function getSpellImplementationPaths() {
498
522
  }
499
523
  async function isSpellImplementationFile(projectRelPath) {
500
524
  const fileName = path.basename(projectRelPath);
501
- if (fileName === "ms-apply.ts" || fileName === "ms-apply.js" || fileName === "ms-apply.d.ts" || fileName === "ms-spells.ts" || fileName === "ms-spells.js" || fileName === "ms-spells.d.ts") {
525
+ if (fileName === "magic-apply.ts" || fileName === "magic-apply.js" || fileName === "magic-apply.d.ts" || fileName === "magic-spells.ts" || fileName === "magic-spells.js" || fileName === "magic-spells.d.ts") {
502
526
  return true;
503
527
  }
504
528
  const spellPaths = await getSpellImplementationPaths();
@@ -5,10 +5,10 @@ import pMap from "p-map";
5
5
  import { CONCURRENCY_DEFAULT, PROJECT_ROOT } from "./utils-consts.js";
6
6
  export async function removeDistFolders(distNpmDirName, distJsrDirName, libsDirDist, libsList, distTmpDirName = "") {
7
7
  const foldersToRemove = [];
8
- foldersToRemove.push(distTmpDirName);
9
8
  foldersToRemove.push(distNpmDirName);
10
- if (distJsrDirName) {
11
- foldersToRemove.push(distJsrDirName);
9
+ foldersToRemove.push(distJsrDirName);
10
+ if (distTmpDirName !== "") {
11
+ foldersToRemove.push(distTmpDirName);
12
12
  }
13
13
  if (libsList && Object.keys(libsList).length > 0) {
14
14
  foldersToRemove.push(libsDirDist);
@@ -43,10 +43,10 @@ export { getConfigDler } from "./sdk-impl/config/load.js";
43
43
  export type { DlerConfig, BumpMode, BundlerName, NpmOutExt, LibConfig, Esbuild, transpileFormat, Sourcemap, transpileTarget, } from "./sdk-impl/config/types.js";
44
44
  export { IGNORE_PATTERNS } from "./sdk-impl/constants.js";
45
45
  export { library_buildFlow, library_pubFlow, libraries_build, libraries_publish, } from "./sdk-impl/library-flow.js";
46
- export type { ApplyMagicSpellsOptions, ApplyMagicSpellsResult, FileWithSpells, } from "./sdk-impl/magic/ms-apply.js";
47
- export { applyMagicSpells, processSingleOutputFile, getAllAvailableRegistries, getFilesWithMagicSpells, } from "./sdk-impl/magic/ms-apply.js";
48
- export type { SpellEvaluationContext, SpellOutcome, SpellDirective, SpellInfo, } from "./sdk-impl/magic/ms-spells.js";
49
- export { getAvailableSpells, evaluateMagicDirective } from "./sdk-impl/magic/ms-spells.js";
46
+ export type { ApplyMagicSpellsOptions, ApplyMagicSpellsResult, FileWithSpells, } from "./sdk-impl/magic/magic-apply.js";
47
+ export { applyMagicSpells, processSingleOutputFile, getAllAvailableRegistries, getFilesWithMagicSpells, } from "./sdk-impl/magic/magic-apply.js";
48
+ export type { SpellEvaluationContext, SpellOutcome, SpellDirective, SpellInfo, } from "./sdk-impl/magic/magic-spells.js";
49
+ export { getAvailableSpells, evaluateMagicDirective } from "./sdk-impl/magic/magic-spells.js";
50
50
  export { library_publishLibrary } from "./sdk-impl/pub/pub-library.js";
51
51
  export { regular_pubToJsr, regular_pubToNpm } from "./sdk-impl/pub/pub-regular.js";
52
52
  export { regular_buildFlow, regular_pubFlow } from "./sdk-impl/regular-flow.js";
@@ -118,8 +118,8 @@ export {
118
118
  processSingleOutputFile,
119
119
  getAllAvailableRegistries,
120
120
  getFilesWithMagicSpells
121
- } from "./sdk-impl/magic/ms-apply.js";
122
- export { getAvailableSpells, evaluateMagicDirective } from "./sdk-impl/magic/ms-spells.js";
121
+ } from "./sdk-impl/magic/magic-apply.js";
122
+ export { getAvailableSpells, evaluateMagicDirective } from "./sdk-impl/magic/magic-spells.js";
123
123
  export { library_publishLibrary } from "./sdk-impl/pub/pub-library.js";
124
124
  export { regular_pubToJsr, regular_pubToNpm } from "./sdk-impl/pub/pub-regular.js";
125
125
  export { regular_buildFlow, regular_pubFlow } from "./sdk-impl/regular-flow.js";
package/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  "license": "MIT",
54
54
  "name": "@reliverse/dler",
55
55
  "type": "module",
56
- "version": "1.7.45",
56
+ "version": "1.7.47",
57
57
  "keywords": [
58
58
  "reliverse",
59
59
  "cli",