@reliverse/dler 1.7.27 → 1.7.28

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
@@ -820,12 +820,16 @@ special thanks to the project that inspired `@reliverse/dler`:
820
820
 
821
821
  ## contributors
822
822
 
823
- ### scripts
823
+ ### helper scripts
824
824
 
825
825
  - `libs:pack`: Creates two templates, `cfg` and `sdk`, based on dist-libs directory structure (using **dler pack** command).
826
826
  - `libs:unpack`: Creates a project structure using all templates from the `cfg` and `sdk` templates (using **dler unpack** command).
827
827
  - `libs:example`: Since `libs:unpack`'s serves as a dist-libs mock, then `libs:example` helps easily test dler's features like `resolveAllCrossLibs()`.
828
828
 
829
+ ### notes
830
+
831
+ `<src | dist-npm | dist-jsr>/libs/<lib-name>/<files live here>` === `dist-libs/<lib-name>/<jsr | npm>/bin/<files live here>`
832
+
829
833
  ## support
830
834
 
831
835
  - if dler saves you time and effort, please consider supporting its development: [github sponsors](https://github.com/sponsors/blefnk);
@@ -26,9 +26,20 @@ export async function dlerBuild(isDev, config) {
26
26
  effectiveConfig.libsList
27
27
  );
28
28
  await dlerPreBuild(effectiveConfig);
29
- await regular_buildFlow(timer, isDev, effectiveConfig);
30
- await library_buildFlow(timer, isDev, effectiveConfig);
29
+ const tempDirs = {
30
+ npm: "dist-tmp/tmp-npm",
31
+ jsr: "dist-tmp/tmp-jsr",
32
+ libs: "dist-tmp/tmp-libs"
33
+ };
34
+ const tempConfig = {
35
+ ...effectiveConfig,
36
+ coreEntrySrcDir: tempDirs.npm,
37
+ libsDirSrc: tempDirs.libs
38
+ };
39
+ await regular_buildFlow(timer, isDev, tempConfig);
40
+ await library_buildFlow(timer, isDev, tempConfig);
31
41
  await dlerPostBuild(isDev);
42
+ await fs.remove(path.join(PROJECT_ROOT, "dist-tmp"));
32
43
  return { timer, effectiveConfig };
33
44
  } catch (error) {
34
45
  handleDlerError(error);
@@ -1,10 +1,13 @@
1
1
  import path, { convertImportsAliasToRelative } from "@reliverse/pathkit";
2
+ import fs from "@reliverse/relifso";
2
3
  import { relinka } from "@reliverse/relinka";
3
4
  import { runCmd } from "@reliverse/rempts";
5
+ import { glob } from "tinyglobby";
4
6
  import { getCheckCmd } from "../cmds.js";
5
7
  import { getConfigDler } from "../../libs/sdk/sdk-impl/config/load.js";
6
8
  import { applyMagicSpells } from "../../libs/sdk/sdk-impl/magic/ms-apply.js";
7
9
  import { resolveAllCrossLibs } from "../../libs/sdk/sdk-impl/utils/resolve-cross-libs.js";
10
+ import { PROJECT_ROOT } from "../../libs/sdk/sdk-impl/utils/utils-consts.js";
8
11
  import { directoryExists, executeDlerHooks } from "./ppb-utils.js";
9
12
  const DIST_DIRECTORIES = ["dist-npm", "dist-jsr"];
10
13
  const ALIAS_TO_REPLACE = "~";
@@ -38,13 +41,62 @@ async function processDistDirectories() {
38
41
  await processDistDirectory(dir, ALIAS_TO_REPLACE);
39
42
  }
40
43
  }
44
+ async function copyNonBuildFiles(srcDir, distDir, preExtensions, templatesDir) {
45
+ try {
46
+ const files = await glob("**/*", {
47
+ cwd: srcDir,
48
+ onlyFiles: true
49
+ });
50
+ for (const file of files) {
51
+ const ext = path.extname(file).slice(1);
52
+ const isInTemplatesDir = file.startsWith(templatesDir);
53
+ if (isInTemplatesDir || !preExtensions.includes(ext)) {
54
+ const srcPath = path.join(srcDir, file);
55
+ const destPath = path.join(distDir, file);
56
+ await fs.ensureDir(path.dirname(destPath));
57
+ await fs.copy(srcPath, destPath);
58
+ }
59
+ }
60
+ } catch (error) {
61
+ relinka(
62
+ "error",
63
+ `Error copying non-build files: ${error instanceof Error ? error.message : String(error)}`
64
+ );
65
+ throw error;
66
+ }
67
+ }
41
68
  export async function dlerPostBuild(isDev) {
69
+ relinka("info", "\u2014 \u2014 \u2014 dlerPostBuild \u2014 \u2014 \u2014");
70
+ const config = await getConfigDler();
42
71
  await resolveAllCrossLibs();
72
+ if (config.commonPubRegistry === "npm" || config.commonPubRegistry === "npm-jsr") {
73
+ await copyNonBuildFiles(
74
+ path.join(PROJECT_ROOT, config.coreEntrySrcDir),
75
+ path.join(PROJECT_ROOT, config.distNpmDirName),
76
+ config.buildPreExtensions,
77
+ config.buildTemplatesDir
78
+ );
79
+ }
80
+ if (config.commonPubRegistry === "jsr" || config.commonPubRegistry === "npm-jsr") {
81
+ await copyNonBuildFiles(
82
+ path.join(PROJECT_ROOT, config.coreEntrySrcDir),
83
+ path.join(PROJECT_ROOT, config.distJsrDirName),
84
+ config.buildPreExtensions,
85
+ config.buildTemplatesDir
86
+ );
87
+ }
88
+ if (config.libsActMode === "libs-only" || config.libsActMode === "main-and-libs") {
89
+ await copyNonBuildFiles(
90
+ path.join(PROJECT_ROOT, config.libsDirSrc),
91
+ path.join(PROJECT_ROOT, config.libsDirDist),
92
+ config.buildPreExtensions,
93
+ config.buildTemplatesDir
94
+ );
95
+ }
43
96
  if (isDev) {
44
97
  await applyMagicSpells(["dist-jsr", "dist-npm", "dist-libs"]);
45
98
  }
46
99
  await processDistDirectories();
47
- const config = await getConfigDler();
48
100
  await executeDlerHooks(config?.hooksAfterBuild ?? [], "post-build");
49
101
  if (config?.runAfterBuild?.length) {
50
102
  const tools = createPostBuildToolRunner();
@@ -1,6 +1,10 @@
1
+ import path from "@reliverse/pathkit";
2
+ import fs from "@reliverse/relifso";
1
3
  import { relinka } from "@reliverse/relinka";
2
4
  import { runCmd } from "@reliverse/rempts";
5
+ import { glob } from "tinyglobby";
3
6
  import { getCheckCmd } from "../cmds.js";
7
+ import { PROJECT_ROOT } from "../../libs/sdk/sdk-impl/utils/utils-consts.js";
4
8
  import { executeCommand, executeDlerHooks, isCommandAvailable } from "./ppb-utils.js";
5
9
  const createToolRunner = () => ({
6
10
  tsc: {
@@ -27,8 +31,66 @@ const createToolRunner = () => ({
27
31
  }
28
32
  }
29
33
  });
34
+ async function copyFilesToTempDir(srcDir, tempDir, extensions, excludeDir) {
35
+ try {
36
+ await fs.ensureDir(tempDir);
37
+ const files = await glob("**/*", {
38
+ cwd: srcDir,
39
+ ignore: [`**/${excludeDir}/**`],
40
+ onlyFiles: true
41
+ });
42
+ for (const file of files) {
43
+ const ext = path.extname(file).slice(1);
44
+ if (extensions.includes(ext)) {
45
+ const srcPath = path.join(srcDir, file);
46
+ const destPath = path.join(tempDir, file);
47
+ await fs.ensureDir(path.dirname(destPath));
48
+ await fs.copy(srcPath, destPath);
49
+ }
50
+ }
51
+ } catch (error) {
52
+ relinka(
53
+ "error",
54
+ `Error copying files to temp directory: ${error instanceof Error ? error.message : String(error)}`
55
+ );
56
+ throw error;
57
+ }
58
+ }
30
59
  export async function dlerPreBuild(config) {
60
+ relinka("info", "\u2014 \u2014 \u2014 dlerPreBuild \u2014 \u2014 \u2014");
31
61
  await executeDlerHooks(config?.hooksBeforeBuild ?? [], "pre-build");
62
+ const tempDirs = {
63
+ npm: path.join(PROJECT_ROOT, "dist-tmp", "tmp-npm"),
64
+ jsr: path.join(PROJECT_ROOT, "dist-tmp", "tmp-jsr"),
65
+ libs: path.join(PROJECT_ROOT, "dist-tmp", "tmp-libs")
66
+ };
67
+ for (const dir of Object.values(tempDirs)) {
68
+ await fs.remove(dir);
69
+ }
70
+ if (config.commonPubRegistry === "npm" || config.commonPubRegistry === "npm-jsr") {
71
+ await copyFilesToTempDir(
72
+ path.join(PROJECT_ROOT, config.coreEntrySrcDir),
73
+ tempDirs.npm,
74
+ config.buildPreExtensions,
75
+ config.buildTemplatesDir
76
+ );
77
+ }
78
+ if (config.commonPubRegistry === "jsr" || config.commonPubRegistry === "npm-jsr") {
79
+ await copyFilesToTempDir(
80
+ path.join(PROJECT_ROOT, config.coreEntrySrcDir),
81
+ tempDirs.jsr,
82
+ config.buildPreExtensions,
83
+ config.buildTemplatesDir
84
+ );
85
+ }
86
+ if (config.libsActMode === "libs-only" || config.libsActMode === "main-and-libs") {
87
+ await copyFilesToTempDir(
88
+ path.join(PROJECT_ROOT, config.libsDirSrc),
89
+ tempDirs.libs,
90
+ config.buildPreExtensions,
91
+ config.buildTemplatesDir
92
+ );
93
+ }
32
94
  if (!config?.runBeforeBuild?.length) return;
33
95
  const tools = createToolRunner();
34
96
  const availableTools = await Promise.all(
@@ -6,13 +6,13 @@ interface DirOptions {
6
6
  }
7
7
  type DirConfig = Record<string, DirOptions>;
8
8
  type ExtMap = Record<string, [string, string, string]>;
9
- interface ConfigFile {
9
+ export interface ConfigRemdn {
10
10
  title?: string;
11
11
  output?: string;
12
12
  dirs: DirConfig;
13
13
  "ext-map"?: ExtMap;
14
14
  }
15
- export declare function scanDirectories(config?: ConfigFile, configPath?: string, outputPath?: string): Promise<void>;
15
+ export declare function scanDirectories(config?: ConfigRemdn, configPath?: string, outputPath?: string): Promise<void>;
16
16
  declare const _default: import("@reliverse/rempts").Command<{
17
17
  mode: {
18
18
  type: "string";
@@ -31,13 +31,5 @@ declare const _default: import("@reliverse/rempts").Command<{
31
31
  type: "string";
32
32
  description: string;
33
33
  };
34
- processLibsOnly: {
35
- type: "boolean";
36
- description: string;
37
- };
38
- preventLibsProcessing: {
39
- type: "boolean";
40
- description: string;
41
- };
42
34
  }>;
43
35
  export default _default;