@reliverse/dler 1.7.37 → 1.7.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -631,7 +631,35 @@ bun dler rename ...
631
631
 
632
632
  ### 14. `magic`
633
633
 
634
- > Contributors: Please check the [docs/cmds/SPELLS.md](./docs/cmds/SPELLS.md) file for more technical details.
634
+ **programmatic usage:**
635
+
636
+ ```ts
637
+ function main() {
638
+ // may be useful when your cli is a project bootstrapper tool like @reliverse/rse
639
+ // so you can apply spells to each bootstrapped by you cli project's file
640
+ await applyMagicSpells(["my-target-dir"]);
641
+ }
642
+ await main();
643
+ ```
644
+
645
+ **or, call it from dler config's hook**:
646
+
647
+ ```ts
648
+ {
649
+ hooksAfterBuild: [
650
+ async () => {
651
+ // useful when you want to apply spells right after dler's build
652
+ await applyMagicSpells(["dist-jsr", "dist-npm", "dist-libs"]);
653
+ }
654
+ ],
655
+ }
656
+ ```
657
+
658
+ **or, use `dler magic`**:
659
+
660
+ ```bash
661
+ dler magic --targets "my-target-dir"
662
+ ```
635
663
 
636
664
  **available spell types:**
637
665
 
@@ -700,6 +728,8 @@ files: [] // means all files
700
728
 
701
729
  p.s. [see how rse cli uses hooked=true](https://github.com/reliverse/rse/blob/main/src/postbuild.ts)
702
730
 
731
+ > Contributors: Please check the [docs/cmds/SPELLS.md](./docs/cmds/SPELLS.md) file for more technical details.
732
+
703
733
  ### 15. `split`
704
734
 
705
735
  splits your code/text file into multiple files.
@@ -829,17 +859,6 @@ bun add @reliverse/dler-sdk
829
859
 
830
860
  **usage example**: [@reliverse/rse](https://github.com/reliverse/rse-website-builder) leverages this sdk to extend its functionality.
831
861
 
832
- ## todo
833
-
834
- - [x] ~~implement stable `regular` build and publish~~
835
- - [ ] implement stable `library` build and publish
836
- - [ ] achieve full drop-in replacement for `unbuild`
837
- - [ ] support auto migration from `build.config.ts`
838
- - [ ] allow plugins to extend dler's `defineconfig`
839
- - [ ] support configuration via `.config/rse.{ts,jsonc}`
840
- - [ ] make config file optional with sensible defaults
841
- - [ ] use [@reliverse/remdn](https://github.com/reliverse/remdn) to generate npm/jsr readme
842
-
843
862
  ## related
844
863
 
845
864
  special thanks to the project that inspired `@reliverse/dler`:
@@ -858,6 +877,20 @@ special thanks to the project that inspired `@reliverse/dler`:
858
877
 
859
878
  - `<src | dist-npm | dist-jsr>/libs/<lib-name>/<files live here>` === `dist-libs/<lib-name>/<jsr | npm>/bin/<files live here>`
860
879
 
880
+ ### todo
881
+
882
+ - [ ] `dist-*`-> `dist/dist-*`
883
+ - [x] implement stable `regular` build and publish
884
+ - [ ] implement stable `library` build and publish
885
+ - [ ] achieve full drop-in replacement for `unbuild`
886
+ - [ ] support auto migration from `build.config.ts`
887
+ - [ ] support configuration via `.config/rse.{ts,jsonc}` 🤔
888
+ - [ ] make config file fully optional with sensible defaults
889
+ - [ ] use `dler remdn` ([@reliverse/remdn](https://github.com/reliverse/remdn)) to generate npm/jsr specific readme and a single `docs` dir for a whole project (only readmes will be published, docs are only stored in project's source cpde and can be deployed to user's website)
890
+ - [x] allow plugins to extend dler's `defineconfig` (`hooksBeforeBuild` and `hooksAfterBuild` are now available, plugin's options can be passed directly to plugin's params, e.g. `hooksBeforeBuild: [ async () => { await myCoolPlugin({ /* plugin's options */ }); } ],`)
891
+ - [ ] at the moment any bundler like `mkdist` can be called using `bun`, but bun's own bundler is not yet fully supported
892
+ - [ ] support all well-known package managers (currently only bun is fully supported)
893
+
861
894
  ## support
862
895
 
863
896
  - if dler saves you time and effort, please consider supporting its development: [github sponsors](https://github.com/sponsors/blefnk);
@@ -43,15 +43,26 @@ async function processDistDirectories() {
43
43
  }
44
44
  async function copyNonBuildFiles(srcDir, distDir, preExtensions, templatesDir) {
45
45
  try {
46
- const templatesSrcPath = path.join(srcDir, templatesDir);
47
- if (await directoryExists(templatesSrcPath)) {
48
- const templatesDestPath = path.join(distDir, "bin", templatesDir);
46
+ const templatesDirs = await glob(`**/${templatesDir}`, {
47
+ cwd: srcDir,
48
+ onlyDirectories: true,
49
+ absolute: true
50
+ });
51
+ const topLevelTemplatesDirs = templatesDirs.filter((dir) => {
52
+ const relativePath = path.relative(srcDir, dir);
53
+ const parts = relativePath.split(path.sep);
54
+ const templatesIndex = parts.indexOf(templatesDir);
55
+ return templatesIndex === parts.length - 1;
56
+ });
57
+ for (const templateDir of topLevelTemplatesDirs) {
58
+ const relativePath = path.relative(srcDir, templateDir);
59
+ const templatesDestPath = path.join(distDir, "bin", relativePath);
49
60
  await fs.ensureDir(path.dirname(templatesDestPath));
50
- await fs.copy(templatesSrcPath, templatesDestPath);
61
+ await fs.copy(templateDir, templatesDestPath);
51
62
  }
52
63
  const files = await glob("**/*", {
53
64
  cwd: srcDir,
54
- ignore: [`${templatesDir}/**`]
65
+ ignore: [`**/${templatesDir}/**`]
55
66
  });
56
67
  for (const file of files) {
57
68
  const ext = path.extname(file).slice(1);
@@ -114,7 +125,12 @@ async function compareFileStructures(srcDir, distDir) {
114
125
  export async function dlerPostBuild(isDev, debugDontCopyNonBuildFiles) {
115
126
  relinka("info", "\u2014 \u2014 \u2014 dlerPostBuild \u2014 \u2014 \u2014");
116
127
  const config = await getConfigDler();
117
- await resolveAllCrossLibs();
128
+ await resolveAllCrossLibs(
129
+ ALIAS_TO_REPLACE,
130
+ ["npm", "jsr"],
131
+ config.buildPreExtensions,
132
+ config.buildTemplatesDir
133
+ );
118
134
  if (!debugDontCopyNonBuildFiles) {
119
135
  await wrapper_CopyNonBuildFiles(config);
120
136
  }
@@ -11,10 +11,10 @@ export declare const defineConfigRse: (userConfig?: Partial<RseConfig>) => {
11
11
  projectGitService?: "none" | "github" | "gitlab" | "bitbucket" | undefined;
12
12
  projectDeployService?: "none" | "vercel" | "netlify" | "railway" | "deno" | undefined;
13
13
  projectPackageManager?: "bun" | "npm" | "yarn" | "pnpm" | undefined;
14
- projectState?: "creating" | "created" | undefined;
14
+ projectState?: "created" | "creating" | undefined;
15
15
  projectCategory?: "browser" | "cli" | "unknown" | "website" | "vscode" | "library" | "mobile" | undefined;
16
16
  projectSubcategory?: "unknown" | "e-commerce" | "tool" | undefined;
17
- projectFramework?: "npm-jsr" | "rempts" | "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" | "unknown" | "vscode" | "nextjs" | "vite" | "svelte" | "remix" | "astro" | "nuxt" | "solid" | "qwik" | "vue" | "wxt" | "lynx" | "react-native" | "expo" | "capacitor" | "ionic" | "electron" | "tauri" | "neutralino" | "rempts" | "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?: {
@@ -33,6 +33,7 @@ export declare const defineConfigRse: (userConfig?: Partial<RseConfig>) => {
33
33
  themes?: string[] | undefined;
34
34
  } | undefined;
35
35
  preferredLibraries?: {
36
+ search?: "unknown" | "algolia" | undefined;
36
37
  i18n?: "unknown" | "next-intl" | undefined;
37
38
  analytics?: "unknown" | "vercel" | undefined;
38
39
  authentication?: "unknown" | "better-auth" | "clerk" | "next-auth" | "supabase-auth" | "auth0" | undefined;
@@ -51,7 +52,6 @@ export declare const defineConfigRse: (userConfig?: Partial<RseConfig>) => {
51
52
  logging?: "unknown" | "axiom" | undefined;
52
53
  forms?: "unknown" | "react-hook-form" | undefined;
53
54
  notifications?: "unknown" | "sonner" | undefined;
54
- search?: "unknown" | "algolia" | undefined;
55
55
  uploads?: "unknown" | "uploadthing" | undefined;
56
56
  validation?: "unknown" | "zod" | "typebox" | "valibot" | undefined;
57
57
  documentation?: "unknown" | "starlight" | "nextra" | 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;
@@ -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;
@@ -1,5 +1,5 @@
1
1
  import { endPrompt, startPrompt } from "@reliverse/rempts";
2
- const version = "1.7.37";
2
+ const version = "1.7.39";
3
3
  export async function showStartPrompt(isDev) {
4
4
  await startPrompt({
5
5
  titleColor: "inverse",
@@ -30,6 +30,28 @@ export interface ApplyMagicSpellsResult {
30
30
  * Processes files in specified output directories by applying magic directives
31
31
  * For dist targets, first scans src directory for files with magic directives, then processes corresponding output files
32
32
  * For custom targets, processes magic directives directly in the target files
33
+ *
34
+ * !! Users should call this function manually in their codebase (dler doesn't call it automatically) !!
35
+ * To call it:
36
+ * ```ts
37
+ * // may be useful when your cli is a project bootstrapper tool like @reliverse/rse
38
+ * // so you can apply spells to each bootstrapped by you cli project's file
39
+ * await applyMagicSpells(["my-target-dir"]);
40
+ * ```
41
+ * Or, in dler config's hook:
42
+ * ```ts
43
+ * hooksAfterBuild: [
44
+ * async () => {
45
+ * // useful when you want to apply spells right after dler's build
46
+ * await applyMagicSpells(["dist-jsr", "dist-npm", "dist-libs"]);
47
+ * }
48
+ * ]
49
+ * ```
50
+ * Or, use `dler magic` command:
51
+ * ```bash
52
+ * dler magic --targets "my-target-dir"
53
+ * ```
54
+ *
33
55
  * @param targets Array of output targets in format "dist-npm", "dist-jsr", "dist-libs" or "dist-libs/lib-name" or any custom path
34
56
  * @param options Configuration options for processing
35
57
  * @returns Object containing arrays of processed files and processed .d.ts files
@@ -1,3 +1,3 @@
1
- declare function resolveCrossLibs(libBinDir: string, alias?: string, subFolders?: ("npm" | "jsr")[]): Promise<string[]>;
2
- declare function resolveAllCrossLibs(alias?: string, subFolders?: ("npm" | "jsr")[]): Promise<string[]>;
1
+ declare function resolveCrossLibs(libBinDir: string, alias: string | undefined, subFolders: ("npm" | "jsr")[] | undefined, buildPreExtensions: string[], buildTemplatesDir: string): Promise<string[]>;
2
+ declare function resolveAllCrossLibs(alias: string | undefined, subFolders: ("npm" | "jsr")[] | undefined, buildPreExtensions: string[], buildTemplatesDir: string): Promise<string[]>;
3
3
  export { resolveCrossLibs, resolveAllCrossLibs };
@@ -1,8 +1,7 @@
1
1
  import { relinka } from "@reliverse/relinka";
2
2
  import { promises as fs } from "node:fs";
3
3
  import path from "node:path";
4
- const PROCESS_DTS_FILES = true;
5
- async function resolveCrossLibs(libBinDir, alias = "~", subFolders = ["npm", "jsr"]) {
4
+ async function resolveCrossLibs(libBinDir, alias = "~", subFolders = ["npm", "jsr"], buildPreExtensions, buildTemplatesDir) {
6
5
  const normalizedPath = libBinDir.replace(/\\/g, "/");
7
6
  if (!normalizedPath.startsWith("dist-libs") && !normalizedPath.startsWith("dist-jsr") && !normalizedPath.startsWith("dist-npm")) {
8
7
  throw new Error(
@@ -17,7 +16,7 @@ async function resolveCrossLibs(libBinDir, alias = "~", subFolders = ["npm", "js
17
16
  );
18
17
  }
19
18
  const currentLib = pathParts[1];
20
- const files = await findSourceFiles(libBinDir);
19
+ const files = await findSourceFiles(libBinDir, buildPreExtensions, buildTemplatesDir);
21
20
  const modifiedFiles = [];
22
21
  await Promise.all(
23
22
  files.map(async (filePath) => {
@@ -34,19 +33,30 @@ async function resolveCrossLibs(libBinDir, alias = "~", subFolders = ["npm", "js
34
33
  }
35
34
  return [];
36
35
  }
37
- async function findSourceFiles(dir) {
36
+ async function findSourceFiles(dir, buildPreExtensions, buildTemplatesDir) {
38
37
  const files = [];
39
38
  const entries = await fs.readdir(dir, { withFileTypes: true });
40
39
  await Promise.all(
41
40
  entries.map(async (entry) => {
42
41
  const fullPath = path.join(dir, entry.name);
43
42
  if (entry.isDirectory()) {
44
- const subFiles = await findSourceFiles(fullPath);
43
+ const subFiles = await findSourceFiles(fullPath, buildPreExtensions, buildTemplatesDir);
45
44
  files.push(...subFiles);
46
45
  } else if (entry.isFile()) {
47
- const ext = path.extname(entry.name);
46
+ const ext = path.extname(entry.name).slice(1);
48
47
  const isDts = entry.name.endsWith(".d.ts");
49
- if (ext === ".js" || ext === ".ts" && !isDts || PROCESS_DTS_FILES && isDts) {
48
+ const isInTemplatesDir = fullPath.includes(`/${buildTemplatesDir}/`);
49
+ if (isInTemplatesDir) {
50
+ return;
51
+ }
52
+ if (isDts) {
53
+ files.push(fullPath);
54
+ return;
55
+ }
56
+ if (!buildPreExtensions.includes(ext)) {
57
+ return;
58
+ }
59
+ if (ext === "js" || ext === "ts") {
50
60
  files.push(fullPath);
51
61
  }
52
62
  }
@@ -157,7 +167,7 @@ async function directoryExists(dirPath) {
157
167
  throw error;
158
168
  }
159
169
  }
160
- async function resolveAllCrossLibs(alias = "~", subFolders = ["npm", "jsr"]) {
170
+ async function resolveAllCrossLibs(alias = "~", subFolders = ["npm", "jsr"], buildPreExtensions, buildTemplatesDir) {
161
171
  const distLibsDir = "dist-libs";
162
172
  const allModifiedFiles = [];
163
173
  const distLibsExists = await directoryExists(distLibsDir);
@@ -171,7 +181,13 @@ async function resolveAllCrossLibs(alias = "~", subFolders = ["npm", "jsr"]) {
171
181
  const binDirExists = await directoryExists(binDir);
172
182
  if (binDirExists) {
173
183
  try {
174
- const modifiedFiles = await resolveCrossLibs(binDir, alias, subFolders);
184
+ const modifiedFiles = await resolveCrossLibs(
185
+ binDir,
186
+ alias,
187
+ subFolders,
188
+ buildPreExtensions,
189
+ buildTemplatesDir
190
+ );
175
191
  allModifiedFiles.push(...modifiedFiles);
176
192
  } catch (error) {
177
193
  const errorMessage = error instanceof Error ? error.message : String(error);
package/package.json CHANGED
@@ -36,7 +36,7 @@
36
36
  "p-all": "^5.0.0",
37
37
  "p-map": "^7.0.3",
38
38
  "pkg-types": "^2.1.0",
39
- "postcss": "^8.5.5",
39
+ "postcss": "^8.5.6",
40
40
  "postcss-nested": "^7.0.2",
41
41
  "pretty-bytes": "^7.0.0",
42
42
  "pretty-ms": "^9.2.0",
@@ -53,7 +53,7 @@
53
53
  "license": "MIT",
54
54
  "name": "@reliverse/dler",
55
55
  "type": "module",
56
- "version": "1.7.37",
56
+ "version": "1.7.39",
57
57
  "keywords": [
58
58
  "reliverse",
59
59
  "cli",