@reliverse/dler 1.7.46 → 1.7.48

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 };
@@ -105,7 +105,10 @@ export default defineCommand({
105
105
  try {
106
106
  await fs.access(path.join(outDir, typesFile));
107
107
  } catch {
108
- const typesContent = `export interface FileContent extends string | Record<string, unknown> {}
108
+ const typesContent = `export interface FileContent {
109
+ [key: string]: unknown;
110
+ toString(): string;
111
+ }
109
112
  export interface FileMetadata {
110
113
  updatedAt?: string;
111
114
  updatedHash?: string;
@@ -249,7 +252,7 @@ export interface Templates extends Record<string, Template> {}
249
252
  ).split("\n").map((line, i) => {
250
253
  if (i === 0) return line;
251
254
  return " " + line.replace(/"([a-zA-Z0-9_]+)":/g, "$1:");
252
- }).join("\n").replace(/},?\s*$/, "},");
255
+ }).join("\n").replace(/},?\s*$/, "},").replace(/,\s*,/g, ",");
253
256
  code.push(` content: ${jsonStr}${sat},`);
254
257
  code.push(' type: "json",');
255
258
  }
@@ -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.
@@ -10,11 +10,11 @@ export declare const defineConfigRse: (userConfig?: Partial<RseConfig>) => {
10
10
  projectDomain?: string | undefined;
11
11
  projectGitService?: "none" | "github" | "gitlab" | "bitbucket" | undefined;
12
12
  projectDeployService?: "none" | "vercel" | "netlify" | "railway" | "deno" | undefined;
13
- projectPackageManager?: "npm" | "bun" | "yarn" | "pnpm" | undefined;
13
+ projectPackageManager?: "bun" | "npm" | "yarn" | "pnpm" | undefined;
14
14
  projectState?: "creating" | "created" | undefined;
15
15
  projectCategory?: "browser" | "cli" | "unknown" | "website" | "vscode" | "library" | "mobile" | undefined;
16
16
  projectSubcategory?: "unknown" | "e-commerce" | "tool" | undefined;
17
- projectFramework?: "rempts" | "npm-jsr" | "unknown" | "vscode" | "nextjs" | "vite" | "svelte" | "remix" | "astro" | "nuxt" | "solid" | "qwik" | "vue" | "wxt" | "lynx" | "react-native" | "expo" | "capacitor" | "ionic" | "electron" | "tauri" | "neutralino" | "citty" | "commander" | "cac" | "meow" | "yargs" | "webextension" | "browser-extension" | undefined;
17
+ projectFramework?: "npm-jsr" | "vue" | "rempts" | "svelte" | "unknown" | "vscode" | "nextjs" | "vite" | "remix" | "astro" | "nuxt" | "solid" | "qwik" | "wxt" | "lynx" | "react-native" | "expo" | "capacitor" | "ionic" | "electron" | "tauri" | "neutralino" | "citty" | "commander" | "cac" | "meow" | "yargs" | "webextension" | "browser-extension" | undefined;
18
18
  projectTemplate?: "unknown" | "blefnk/relivator-nextjs-template" | "blefnk/relivator-docker-template" | "blefnk/next-react-ts-src-minimal" | "blefnk/all-in-one-nextjs-template" | "blefnk/create-t3-app" | "blefnk/create-next-app" | "blefnk/astro-starlight-template" | "blefnk/versator-nextjs-template" | "blefnk/relivator-lynxjs-template" | "blefnk/relivator-react-native-template" | "reliverse/template-browser-extension" | "microsoft/vscode-extension-samples" | "microsoft/vscode-extension-template" | "rsetarter-template" | "blefnk/deno-cli-tutorial" | undefined;
19
19
  projectTemplateDate?: string | undefined;
20
20
  features?: {
@@ -34,18 +34,17 @@ export declare const defineConfigRse: (userConfig?: Partial<RseConfig>) => {
34
34
  } | undefined;
35
35
  preferredLibraries?: {
36
36
  search?: "unknown" | "algolia" | undefined;
37
- cdn?: "unknown" | "cloudflare" | undefined;
38
37
  i18n?: "unknown" | "next-intl" | undefined;
39
38
  analytics?: "unknown" | "vercel" | undefined;
40
39
  authentication?: "unknown" | "better-auth" | "clerk" | "next-auth" | "supabase-auth" | "auth0" | undefined;
41
40
  api?: "rest" | "unknown" | "hono" | "trpc" | "graphql" | undefined;
42
- testing?: "bun" | "unknown" | "vitest" | "jest" | "playwright" | "cypress" | undefined;
41
+ testing?: "bun" | "jest" | "vitest" | "unknown" | "playwright" | "cypress" | undefined;
43
42
  stateManagement?: "unknown" | "zustand" | "jotai" | "redux-toolkit" | undefined;
44
43
  formManagement?: "unknown" | "react-hook-form" | "formik" | undefined;
45
- styling?: "unknown" | "tailwind" | "styled-components" | "css-modules" | "sass" | undefined;
44
+ styling?: "sass" | "unknown" | "tailwind" | "styled-components" | "css-modules" | undefined;
46
45
  uiComponents?: "unknown" | "shadcn-ui" | "chakra-ui" | "material-ui" | undefined;
47
46
  databaseLibrary?: "unknown" | "drizzle" | "prisma" | "supabase" | undefined;
48
- databaseProvider?: "unknown" | "pg" | "mysql" | "sqlite" | "mongodb" | undefined;
47
+ databaseProvider?: "pg" | "unknown" | "mysql" | "sqlite" | "mongodb" | undefined;
49
48
  linting?: "eslint" | "unknown" | undefined;
50
49
  formatting?: "biome" | "unknown" | undefined;
51
50
  payment?: "unknown" | "stripe" | undefined;
@@ -58,8 +57,9 @@ export declare const defineConfigRse: (userConfig?: Partial<RseConfig>) => {
58
57
  documentation?: "unknown" | "starlight" | "nextra" | undefined;
59
58
  icons?: "unknown" | "lucide" | undefined;
60
59
  mail?: "unknown" | "resend" | undefined;
61
- cache?: "unknown" | "redis" | undefined;
60
+ cache?: "redis" | "unknown" | 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;
@@ -67,7 +67,7 @@ export declare const defineConfigRse: (userConfig?: Partial<RseConfig>) => {
67
67
  dates?: "unknown" | "dayjs" | undefined;
68
68
  markdown?: "unknown" | "mdx" | undefined;
69
69
  security?: "unknown" | "auth" | undefined;
70
- routing?: "unknown" | "next" | "react-router" | "tanstack-router" | undefined;
70
+ routing?: "next" | "unknown" | "react-router" | "tanstack-router" | undefined;
71
71
  } | undefined;
72
72
  codeStyle?: {
73
73
  lineWidth?: number | undefined;
@@ -75,7 +75,7 @@ export declare const defineConfigRse: (userConfig?: Partial<RseConfig>) => {
75
75
  indentStyle?: "space" | "tab" | undefined;
76
76
  quoteMark?: "single" | "double" | undefined;
77
77
  semicolons?: boolean | undefined;
78
- trailingComma?: "none" | "all" | "es5" | undefined;
78
+ trailingComma?: "all" | "none" | "es5" | undefined;
79
79
  bracketSpacing?: boolean | undefined;
80
80
  arrowParens?: "always" | "avoid" | undefined;
81
81
  tabWidth?: number | undefined;
@@ -83,7 +83,7 @@ export declare const defineConfigRse: (userConfig?: Partial<RseConfig>) => {
83
83
  dontRemoveComments?: boolean | undefined;
84
84
  shouldAddComments?: boolean | undefined;
85
85
  typeOrInterface?: "type" | "interface" | "mixed" | undefined;
86
- importOrRequire?: "mixed" | "import" | "require" | undefined;
86
+ importOrRequire?: "import" | "require" | "mixed" | undefined;
87
87
  cjsToEsm?: boolean | undefined;
88
88
  modernize?: {
89
89
  replaceFs?: boolean | undefined;
@@ -96,7 +96,7 @@ export declare const defineConfigRse: (userConfig?: Partial<RseConfig>) => {
96
96
  importSymbol?: string | undefined;
97
97
  } | undefined;
98
98
  monorepo?: {
99
- type?: "none" | "bun" | "pnpm" | "turborepo" | "nx" | undefined;
99
+ type?: "bun" | "pnpm" | "none" | "turborepo" | "nx" | undefined;
100
100
  packages?: string[] | undefined;
101
101
  sharedPackages?: string[] | undefined;
102
102
  } | undefined;
@@ -113,7 +113,7 @@ export declare const defineConfigRse: (userConfig?: Partial<RseConfig>) => {
113
113
  repoBranch?: string | undefined;
114
114
  repoPrivacy?: "unknown" | "public" | "private" | undefined;
115
115
  projectArchitecture?: "unknown" | "fullstack" | "separated" | undefined;
116
- projectRuntime?: "node" | "bun" | "deno" | undefined;
116
+ projectRuntime?: "bun" | "node" | "deno" | undefined;
117
117
  skipPromptsUseAutoBehavior?: boolean | undefined;
118
118
  deployBehavior?: "prompt" | "autoYes" | "autoNo" | undefined;
119
119
  depsBehavior?: "prompt" | "autoYes" | "autoNo" | 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.46";
2
+ const version = "1.7.48";
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.
@@ -522,7 +522,7 @@ async function getSpellImplementationPaths() {
522
522
  }
523
523
  async function isSpellImplementationFile(projectRelPath) {
524
524
  const fileName = path.basename(projectRelPath);
525
- 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") {
526
526
  return true;
527
527
  }
528
528
  const spellPaths = await getSpellImplementationPaths();
@@ -0,0 +1,143 @@
1
+ import { relinka } from "@reliverse/relinka";
2
+ const SPELL_REGEX = /\/\/\s*(?:@ts-expect-error\s+.*?)?<\s*(dler-[^>\s]+)(.*?)>/i;
3
+ const REPLACEMENT_REGEX = /`([^`]+)`/;
4
+ const IF_CONDITION_REGEX = /\bif\s+['"`]([^'"`]+)['"`]/i;
5
+ const ELSE_CONTENT_REGEX = /\belse\s+['"`]([^'"`]+)['"`]/i;
6
+ const STARTS_WITH_REGEX = /current file path starts with\s+(.+)$/i;
7
+ export function getAvailableSpells() {
8
+ return [
9
+ {
10
+ name: "dler-replace-line-to",
11
+ description: "Replaces the current line with new content, optionally based on a condition",
12
+ example: "// <dler-replace-line-to `export const version = \"1.0.0\";` if 'current file path starts with dist-npm'>",
13
+ notes: "If no condition is specified, replacement always applies. If condition is not met and else content is provided, uses else content. Otherwise keeps original line. Also supports @ts-expect-error prefix."
14
+ },
15
+ {
16
+ name: "dler-remove-line",
17
+ description: "Removes the current line from the output",
18
+ example: "// <dler-remove-line>",
19
+ notes: "Also supports @ts-expect-error prefix."
20
+ },
21
+ {
22
+ name: "dler-remove-file",
23
+ description: "Removes the entire file from the output",
24
+ example: "// <dler-remove-file>",
25
+ notes: "This directive should be placed at the top of the file for clarity. Also supports @ts-expect-error prefix."
26
+ },
27
+ {
28
+ name: "dler-remove-comment",
29
+ description: "Removes only the comment portion containing this directive from the line",
30
+ example: "console.log('debug info'); // <dler-remove-comment>",
31
+ notes: "Removes everything from '//' to the end of the line when the comment contains this directive. The code portion before the comment is preserved. Also supports @ts-expect-error prefix."
32
+ },
33
+ {
34
+ name: "dler-ignore-this-line",
35
+ description: "Prevents any magic directives on this line from being processed",
36
+ example: "// <dler-remove-line> // <dler-ignore-this-line>",
37
+ notes: "When present on a line, all magic directives on that line are ignored and the line is kept as-is. Useful for code that contains magic directive strings that shouldn't be executed."
38
+ }
39
+ ];
40
+ }
41
+ export function evaluateMagicDirective(line, ctx) {
42
+ if (line.includes("<dler-ignore-this-line>")) {
43
+ return NO_OP;
44
+ }
45
+ const match = line.match(SPELL_REGEX);
46
+ if (!match) return NO_OP;
47
+ const [, directive = "", body] = match;
48
+ if (!isValidMagicDirective(directive)) {
49
+ relinka("warn", `[spells] unknown directive: ${directive}`);
50
+ return NO_OP;
51
+ }
52
+ switch (directive) {
53
+ /* -------------------------------------------------------------- */
54
+ /* dler-remove-file */
55
+ /* -------------------------------------------------------------- */
56
+ case "dler-remove-file": {
57
+ return { removeFile: true, removeLine: true };
58
+ }
59
+ /* -------------------------------------------------------------- */
60
+ /* dler-remove-line */
61
+ /* -------------------------------------------------------------- */
62
+ case "dler-remove-line": {
63
+ return { removeLine: true, removeFile: false };
64
+ }
65
+ /* -------------------------------------------------------------- */
66
+ /* dler-remove-comment */
67
+ /* -------------------------------------------------------------- */
68
+ case "dler-remove-comment": {
69
+ const commentIndex = line.indexOf("//");
70
+ if (commentIndex !== -1) {
71
+ const codeBeforeComment = line.substring(0, commentIndex).trimEnd();
72
+ return { replacement: codeBeforeComment, removeLine: false, removeFile: false };
73
+ }
74
+ return NO_OP;
75
+ }
76
+ /* -------------------------------------------------------------- */
77
+ /* dler-replace-line-to */
78
+ /* -------------------------------------------------------------- */
79
+ case "dler-replace-line-to": {
80
+ const { replacement, elseContent, condition } = parseReplacementDirective(body ?? "");
81
+ if (!replacement) {
82
+ relinka("warn", "[spells] dler-replace-line-to missing replacement content");
83
+ return NO_OP;
84
+ }
85
+ const condMet = condition === void 0 ? true : evaluatePathCondition(condition, ctx);
86
+ if (condMet) {
87
+ return { replacement, removeLine: false, removeFile: false };
88
+ }
89
+ if (elseContent !== void 0) {
90
+ return { replacement: elseContent, removeLine: false, removeFile: false };
91
+ }
92
+ return NO_OP;
93
+ }
94
+ /* -------------------------------------------------------------- */
95
+ /* dler-ignore-this-line */
96
+ /* -------------------------------------------------------------- */
97
+ case "dler-ignore-this-line": {
98
+ return NO_OP;
99
+ }
100
+ default:
101
+ return NO_OP;
102
+ }
103
+ }
104
+ const NO_OP = { removeLine: false, removeFile: false };
105
+ function isValidMagicDirective(directive) {
106
+ return [
107
+ "dler-replace-line-to",
108
+ "dler-remove-line",
109
+ "dler-remove-file",
110
+ "dler-remove-comment",
111
+ "dler-ignore-this-line"
112
+ ].includes(directive);
113
+ }
114
+ function parseReplacementDirective(body) {
115
+ const parts = {
116
+ replacement: ""
117
+ };
118
+ const replacementMatch = body.match(REPLACEMENT_REGEX);
119
+ if (replacementMatch?.[1]) parts.replacement = replacementMatch[1].trim();
120
+ const ifMatch = body.match(IF_CONDITION_REGEX);
121
+ if (ifMatch?.[1]) {
122
+ parts.condition = ifMatch[1].trim();
123
+ }
124
+ const elseMatch = body.match(ELSE_CONTENT_REGEX);
125
+ if (elseMatch?.[1]) parts.elseContent = elseMatch[1].trim();
126
+ return parts;
127
+ }
128
+ function evaluatePathCondition(condition, ctx) {
129
+ const STARTS_WITH = STARTS_WITH_REGEX.exec(condition)?.[1];
130
+ if (STARTS_WITH) {
131
+ const prefixes = STARTS_WITH.split(/\s+or\s+/i).map(
132
+ (p) => p.replace(/['"`]/g, "").trim().replaceAll("\\", "/")
133
+ );
134
+ return prefixes.some((p) => ctx.filePath.startsWith(p));
135
+ }
136
+ if (condition.trim()) {
137
+ relinka(
138
+ "warn",
139
+ `[spells] unsupported condition "${condition}" - only "current file path starts with <prefix> [or <prefix> ...]" is supported`
140
+ );
141
+ }
142
+ return false;
143
+ }
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.46",
56
+ "version": "1.7.48",
57
57
  "keywords": [
58
58
  "reliverse",
59
59
  "cli",