@reliverse/dler 1.7.60 → 1.7.61

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 (62) hide show
  1. package/LICENSES +3 -0
  2. package/README.md +12 -7
  3. package/bin/app/build/prebuild.js +1 -2
  4. package/bin/app/{copy → fs}/cmd.d.ts +33 -2
  5. package/bin/app/fs/cmd.js +302 -0
  6. package/bin/app/x/cmd.d.ts +92 -0
  7. package/bin/app/x/cmd.js +260 -0
  8. package/bin/libs/cfg/cfg-impl/rse-config/rse-impl/rse-create.js +1 -1
  9. package/bin/libs/cfg/cfg-impl/rse-config/rse-impl/rse-define.d.ts +12 -12
  10. package/bin/libs/sdk/sdk-impl/config/info.js +1 -1
  11. package/bin/libs/sdk/sdk-impl/utils/exec/exec-enoent.d.ts +15 -0
  12. package/bin/libs/sdk/sdk-impl/utils/exec/exec-enoent.js +38 -0
  13. package/bin/libs/sdk/sdk-impl/utils/exec/exec-env.d.ts +6 -0
  14. package/bin/libs/sdk/sdk-impl/utils/exec/exec-env.js +34 -0
  15. package/bin/libs/sdk/sdk-impl/utils/exec/exec-error.d.ts +7 -0
  16. package/bin/libs/sdk/sdk-impl/utils/exec/exec-error.js +15 -0
  17. package/bin/libs/sdk/sdk-impl/utils/exec/exec-escape.d.ts +2 -0
  18. package/bin/libs/sdk/sdk-impl/utils/exec/exec-escape.js +15 -0
  19. package/bin/libs/sdk/sdk-impl/utils/exec/exec-mod.d.ts +58 -0
  20. package/bin/libs/sdk/sdk-impl/utils/exec/exec-mod.js +231 -0
  21. package/bin/libs/sdk/sdk-impl/utils/exec/exec-parse.d.ts +2 -0
  22. package/bin/libs/sdk/sdk-impl/utils/exec/exec-parse.js +56 -0
  23. package/bin/libs/sdk/sdk-impl/utils/exec/exec-resolve.d.ts +2 -0
  24. package/bin/libs/sdk/sdk-impl/utils/exec/exec-resolve.js +39 -0
  25. package/bin/libs/sdk/sdk-impl/utils/exec/exec-shebang.d.ts +1 -0
  26. package/bin/libs/sdk/sdk-impl/utils/exec/exec-shebang.js +14 -0
  27. package/bin/libs/sdk/sdk-impl/utils/exec/exec-spawn.d.ts +3 -0
  28. package/bin/libs/sdk/sdk-impl/utils/exec/exec-spawn.js +18 -0
  29. package/bin/libs/sdk/sdk-impl/utils/exec/exec-stream.d.ts +4 -0
  30. package/bin/libs/sdk/sdk-impl/utils/exec/exec-stream.js +20 -0
  31. package/bin/libs/sdk/sdk-impl/utils/exec/exec-types.d.ts +13 -0
  32. package/bin/libs/sdk/sdk-impl/utils/exec/exec-types.js +9 -0
  33. package/bin/libs/sdk/sdk-impl/utils/fs-rename.d.ts +2 -0
  34. package/bin/libs/sdk/sdk-impl/utils/fs-rename.js +108 -0
  35. package/bin/libs/sdk/sdk-impl/utils/pm/pm-api.d.ts +85 -0
  36. package/bin/libs/sdk/sdk-impl/utils/pm/pm-api.js +173 -0
  37. package/bin/libs/sdk/sdk-impl/utils/pm/pm-detect.d.ts +12 -0
  38. package/bin/libs/sdk/sdk-impl/utils/pm/pm-detect.js +99 -0
  39. package/bin/libs/sdk/sdk-impl/utils/pm/pm-parse.d.ts +8 -0
  40. package/bin/libs/sdk/sdk-impl/utils/pm/pm-parse.js +29 -0
  41. package/bin/libs/sdk/sdk-impl/utils/pm/pm-types.d.ts +43 -0
  42. package/bin/libs/sdk/sdk-impl/utils/pm/pm-types.js +0 -0
  43. package/bin/libs/sdk/sdk-impl/utils/pm/pm-utils.d.ts +12 -0
  44. package/bin/libs/sdk/sdk-impl/utils/pm/pm-utils.js +86 -0
  45. package/bin/libs/sdk/sdk-mod.d.ts +24 -0
  46. package/bin/libs/sdk/sdk-mod.js +53 -0
  47. package/package.json +9 -8
  48. package/bin/app/copy/cmd.js +0 -186
  49. package/bin/app/init/cmd.d.ts +0 -29
  50. package/bin/app/init/cmd.js +0 -82
  51. package/bin/app/rename/cmd.d.ts +0 -32
  52. package/bin/app/rename/cmd.js +0 -182
  53. package/bin/app/rm/cmd.d.ts +0 -13
  54. package/bin/app/rm/cmd.js +0 -70
  55. /package/bin/{app → libs/sdk/sdk-impl/utils}/init/init-const.d.ts +0 -0
  56. /package/bin/{app → libs/sdk/sdk-impl/utils}/init/init-const.js +0 -0
  57. /package/bin/{app → libs/sdk/sdk-impl/utils}/init/init-impl.d.ts +0 -0
  58. /package/bin/{app → libs/sdk/sdk-impl/utils}/init/init-impl.js +0 -0
  59. /package/bin/{app → libs/sdk/sdk-impl/utils}/init/init-tmpl.d.ts +0 -0
  60. /package/bin/{app → libs/sdk/sdk-impl/utils}/init/init-tmpl.js +0 -0
  61. /package/bin/{app → libs/sdk/sdk-impl/utils}/init/init-types.d.ts +0 -0
  62. /package/bin/{app → libs/sdk/sdk-impl/utils}/init/init-types.js +0 -0
@@ -0,0 +1,173 @@
1
+ import { resolve } from "@reliverse/pathkit";
2
+ import fs from "@reliverse/relifso";
3
+ import { runCmd } from "@reliverse/rempts";
4
+ import { readPackageJSON } from "pkg-types";
5
+ import { getCheckCmd } from "../../../../../app/cmds.js";
6
+ import {
7
+ executeCommand,
8
+ resolveOperationOptions,
9
+ getWorkspaceArgs,
10
+ doesDependencyExist
11
+ } from "./pm-utils.js";
12
+ export async function installDependencies(options = {}) {
13
+ const resolvedOptions = await resolveOperationOptions(options);
14
+ const pmToFrozenLockfileInstallCommand = {
15
+ npm: ["ci"],
16
+ yarn: ["install", "--immutable"],
17
+ bun: ["install", "--frozen-lockfile"],
18
+ pnpm: ["install", "--frozen-lockfile"],
19
+ deno: ["install", "--frozen"]
20
+ };
21
+ const commandArgs = options.frozenLockFile ? pmToFrozenLockfileInstallCommand[resolvedOptions.packageManager.name] : ["install"];
22
+ await executeCommand(resolvedOptions.packageManager.command, commandArgs, {
23
+ cwd: resolvedOptions.cwd,
24
+ silent: resolvedOptions.silent
25
+ });
26
+ }
27
+ export async function addDependency(name, options = {}) {
28
+ const resolvedOptions = await resolveOperationOptions(options);
29
+ const names = Array.isArray(name) ? name : [name];
30
+ if (resolvedOptions.packageManager.name === "deno") {
31
+ for (let i = 0; i < names.length; i++) {
32
+ if (!/^(npm|jsr|file):.+$/.test(names[i] || "")) {
33
+ names[i] = `npm:${names[i]}`;
34
+ }
35
+ }
36
+ }
37
+ if (names.length === 0) {
38
+ return;
39
+ }
40
+ const args = (resolvedOptions.packageManager.name === "yarn" ? [
41
+ ...getWorkspaceArgs(resolvedOptions),
42
+ // Global is not supported in berry: yarnpkg/berry#821
43
+ resolvedOptions.global && resolvedOptions.packageManager.majorVersion === "1" ? "global" : "",
44
+ "add",
45
+ resolvedOptions.dev ? "-D" : "",
46
+ ...names
47
+ ] : [
48
+ resolvedOptions.packageManager.name === "npm" ? "install" : "add",
49
+ ...getWorkspaceArgs(resolvedOptions),
50
+ resolvedOptions.dev ? "-D" : "",
51
+ resolvedOptions.global ? "-g" : "",
52
+ ...names
53
+ ]).filter(Boolean);
54
+ await executeCommand(resolvedOptions.packageManager.command, args, {
55
+ cwd: resolvedOptions.cwd,
56
+ silent: resolvedOptions.silent
57
+ });
58
+ if (options.installPeerDependencies) {
59
+ const existingPkg = await readPackageJSON(resolvedOptions.cwd);
60
+ const peerDeps = [];
61
+ const peerDevDeps = [];
62
+ for (const _name of names) {
63
+ const pkgName = _name.match(/^(.[^@]+)/)?.[0];
64
+ const pkg = await readPackageJSON(pkgName, {
65
+ url: resolvedOptions.cwd
66
+ }).catch(() => ({}));
67
+ if (!pkg.peerDependencies || pkg.name !== pkgName) {
68
+ continue;
69
+ }
70
+ for (const [peerDependency, version] of Object.entries(pkg.peerDependencies)) {
71
+ if (pkg.peerDependenciesMeta?.[peerDependency]?.optional) {
72
+ continue;
73
+ }
74
+ if (existingPkg.dependencies?.[peerDependency] || existingPkg.devDependencies?.[peerDependency]) {
75
+ continue;
76
+ }
77
+ const isDev = pkg.peerDependenciesMeta?.[peerDependency]?.dev;
78
+ (isDev ? peerDevDeps : peerDeps).push(`${peerDependency}@${version}`);
79
+ }
80
+ }
81
+ if (peerDeps.length > 0) {
82
+ await addDependency(peerDeps, { ...resolvedOptions });
83
+ }
84
+ if (peerDevDeps.length > 0) {
85
+ await addDevDependency(peerDevDeps, { ...resolvedOptions });
86
+ }
87
+ }
88
+ }
89
+ export async function addDevDependency(name, options = {}) {
90
+ await addDependency(name, { ...options, dev: true });
91
+ }
92
+ export async function removeDependency(name, options = {}) {
93
+ const resolvedOptions = await resolveOperationOptions(options);
94
+ const names = Array.isArray(name) ? name : [name];
95
+ if (names.length === 0) {
96
+ return;
97
+ }
98
+ const args = (resolvedOptions.packageManager.name === "yarn" ? [
99
+ // Global is not supported in berry: yarnpkg/berry#821
100
+ resolvedOptions.global && resolvedOptions.packageManager.majorVersion === "1" ? "global" : "",
101
+ ...getWorkspaceArgs(resolvedOptions),
102
+ "remove",
103
+ resolvedOptions.dev ? "-D" : "",
104
+ resolvedOptions.global ? "-g" : "",
105
+ ...names
106
+ ] : [
107
+ resolvedOptions.packageManager.name === "npm" ? "uninstall" : "remove",
108
+ ...getWorkspaceArgs(resolvedOptions),
109
+ resolvedOptions.dev ? "-D" : "",
110
+ resolvedOptions.global ? "-g" : "",
111
+ ...names
112
+ ]).filter(Boolean);
113
+ await executeCommand(resolvedOptions.packageManager.command, args, {
114
+ cwd: resolvedOptions.cwd,
115
+ silent: resolvedOptions.silent
116
+ });
117
+ }
118
+ export async function ensureDependencyInstalled(name, options = {}) {
119
+ const resolvedOptions = await resolveOperationOptions(options);
120
+ const dependencyExists = doesDependencyExist(name, resolvedOptions);
121
+ if (dependencyExists) {
122
+ return true;
123
+ }
124
+ await addDependency(name, resolvedOptions);
125
+ }
126
+ export async function dedupeDependencies(options = {}) {
127
+ const resolvedOptions = await resolveOperationOptions(options);
128
+ const isSupported = !["bun", "deno"].includes(resolvedOptions.packageManager.name);
129
+ const recreateLockfile = options.recreateLockfile ?? !isSupported;
130
+ if (recreateLockfile) {
131
+ const lockfiles = Array.isArray(resolvedOptions.packageManager.lockFile) ? resolvedOptions.packageManager.lockFile : [resolvedOptions.packageManager.lockFile];
132
+ for (const lockfile of lockfiles) {
133
+ if (lockfile) fs.rmSync(resolve(resolvedOptions.cwd, lockfile), { force: true });
134
+ }
135
+ await installDependencies(resolvedOptions);
136
+ return;
137
+ }
138
+ if (isSupported) {
139
+ const isyarnv1 = resolvedOptions.packageManager.name === "yarn" && resolvedOptions.packageManager.majorVersion === "1";
140
+ await executeCommand(
141
+ resolvedOptions.packageManager.command,
142
+ [isyarnv1 ? "install" : "dedupe"],
143
+ {
144
+ cwd: resolvedOptions.cwd,
145
+ silent: resolvedOptions.silent
146
+ }
147
+ );
148
+ return;
149
+ }
150
+ throw new Error(`Deduplication is not supported for ${resolvedOptions.packageManager.name}`);
151
+ }
152
+ export async function updateDependencies(latest = true, linter = false, options = {}) {
153
+ const resolvedOptions = await resolveOperationOptions(options);
154
+ await executeCommand(
155
+ resolvedOptions.packageManager.command,
156
+ latest ? ["update", "--latest"] : ["update"],
157
+ {
158
+ cwd: resolvedOptions.cwd,
159
+ silent: resolvedOptions.silent
160
+ }
161
+ );
162
+ if (linter) {
163
+ await runCmd(await getCheckCmd(), ["--no-exit", "--no-progress"]);
164
+ }
165
+ }
166
+ export async function runScript(name, options = {}) {
167
+ const resolvedOptions = await resolveOperationOptions(options);
168
+ const args = [resolvedOptions.packageManager.name === "deno" ? "task" : "run", name];
169
+ await executeCommand(resolvedOptions.packageManager.command, args, {
170
+ cwd: resolvedOptions.cwd,
171
+ silent: resolvedOptions.silent
172
+ });
173
+ }
@@ -0,0 +1,12 @@
1
+ import type { DetectPackageManagerOptions, PackageManager } from "./pm-types";
2
+ export declare const packageManagers: PackageManager[];
3
+ /**
4
+ * Detect the package manager used in a directory (and up) by checking various sources:
5
+ *
6
+ * 1. Use `packageManager` field from package.json
7
+ *
8
+ * 2. Known lock files and other files
9
+ */
10
+ export declare function detectPackageManager(cwd: string, options?: DetectPackageManagerOptions): Promise<(PackageManager & {
11
+ warnings?: string[];
12
+ }) | undefined>;
@@ -0,0 +1,99 @@
1
+ import { join, resolve } from "@reliverse/pathkit";
2
+ import { existsSync, readFile } from "@reliverse/relifso";
3
+ import { findup, parsePackageManagerField } from "./pm-parse.js";
4
+ export const packageManagers = [
5
+ {
6
+ name: "npm",
7
+ command: "npm",
8
+ lockFile: "package-lock.json"
9
+ },
10
+ {
11
+ name: "pnpm",
12
+ command: "pnpm",
13
+ lockFile: "pnpm-lock.yaml",
14
+ files: ["pnpm-workspace.yaml"]
15
+ },
16
+ {
17
+ name: "bun",
18
+ command: "bun",
19
+ lockFile: ["bun.lockb", "bun.lock"]
20
+ },
21
+ {
22
+ name: "yarn",
23
+ command: "yarn",
24
+ lockFile: "yarn.lock",
25
+ files: [".yarnrc.yml"]
26
+ },
27
+ {
28
+ name: "deno",
29
+ command: "deno",
30
+ lockFile: "deno.lock",
31
+ files: ["deno.json"]
32
+ }
33
+ ];
34
+ export async function detectPackageManager(cwd, options = {}) {
35
+ const detected = await findup(
36
+ resolve(cwd || "."),
37
+ async (path) => {
38
+ if (!options.ignorePackageJSON) {
39
+ const packageJSONPath = join(path, "package.json");
40
+ if (existsSync(packageJSONPath)) {
41
+ const packageJSON = JSON.parse(await readFile(packageJSONPath, "utf8"));
42
+ if (packageJSON?.packageManager) {
43
+ const {
44
+ name,
45
+ version = "0.0.0",
46
+ buildMeta,
47
+ warnings
48
+ } = parsePackageManagerField(packageJSON.packageManager);
49
+ if (name) {
50
+ const majorVersion = version.split(".")[0];
51
+ const packageManager = packageManagers.find(
52
+ (pm) => pm.name === name && pm.majorVersion === majorVersion
53
+ ) || packageManagers.find((pm) => pm.name === name);
54
+ return {
55
+ name,
56
+ command: name,
57
+ version,
58
+ majorVersion,
59
+ buildMeta,
60
+ warnings,
61
+ files: packageManager?.files,
62
+ lockFile: packageManager?.lockFile
63
+ };
64
+ }
65
+ }
66
+ }
67
+ const denoJSONPath = join(path, "deno.json");
68
+ if (existsSync(denoJSONPath)) {
69
+ return packageManagers.find((pm) => pm.name === "deno");
70
+ }
71
+ }
72
+ if (!options.ignoreLockFile) {
73
+ for (const packageManager of packageManagers) {
74
+ const detectionsFiles = [packageManager.lockFile, packageManager.files].flat().filter(Boolean);
75
+ if (detectionsFiles.some((file) => existsSync(resolve(path, file)))) {
76
+ return {
77
+ ...packageManager
78
+ };
79
+ }
80
+ }
81
+ }
82
+ },
83
+ {
84
+ includeParentDirs: options.includeParentDirs ?? true
85
+ }
86
+ );
87
+ if (!detected && !options.ignoreArgv) {
88
+ const scriptArg = process.argv[1];
89
+ if (scriptArg) {
90
+ for (const packageManager of packageManagers) {
91
+ const re = new RegExp(`[/\\\\]\\.?${packageManager.command}`);
92
+ if (re.test(scriptArg)) {
93
+ return packageManager;
94
+ }
95
+ }
96
+ }
97
+ }
98
+ return detected;
99
+ }
@@ -0,0 +1,8 @@
1
+ import type { DetectPackageManagerOptions, PackageManagerName } from "./pm-types";
2
+ export declare function findup<T>(cwd: string, match: (path: string) => T | Promise<T>, options?: Pick<DetectPackageManagerOptions, "includeParentDirs">): Promise<T | undefined>;
3
+ export declare function parsePackageManagerField(packageManager?: string): {
4
+ name?: PackageManagerName;
5
+ version?: string;
6
+ buildMeta?: string;
7
+ warnings?: string[];
8
+ };
@@ -0,0 +1,29 @@
1
+ import { normalize } from "@reliverse/pathkit";
2
+ export async function findup(cwd, match, options = {}) {
3
+ const segments = normalize(cwd).split("/");
4
+ while (segments.length > 0) {
5
+ const path = segments.join("/") || "/";
6
+ const result = await match(path);
7
+ if (result || !options.includeParentDirs) {
8
+ return result;
9
+ }
10
+ segments.pop();
11
+ }
12
+ }
13
+ export function parsePackageManagerField(packageManager) {
14
+ const [name, _version] = (packageManager || "").split("@");
15
+ const [version, buildMeta] = _version?.split("+") || [];
16
+ if (name && name !== "-" && /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(name)) {
17
+ return { name, version, buildMeta };
18
+ }
19
+ const sanitized = name?.replace(/\W+/g, "") || "";
20
+ const warnings = [
21
+ `Abnormal characters found in \`packageManager\` field, sanitizing from \`${name}\` to \`${sanitized}\``
22
+ ];
23
+ return {
24
+ name: sanitized,
25
+ version,
26
+ buildMeta,
27
+ warnings
28
+ };
29
+ }
@@ -0,0 +1,43 @@
1
+ export type PackageManagerName = "npm" | "yarn" | "pnpm" | "bun" | "deno";
2
+ export interface PackageManager {
3
+ name: PackageManagerName;
4
+ command: string;
5
+ version?: string;
6
+ buildMeta?: string;
7
+ majorVersion?: string;
8
+ lockFile?: string | string[];
9
+ files?: string[];
10
+ }
11
+ export interface OperationOptions {
12
+ cwd?: string;
13
+ silent?: boolean;
14
+ packageManager?: PackageManager | PackageManagerName;
15
+ installPeerDependencies?: boolean;
16
+ dev?: boolean;
17
+ workspace?: boolean | string;
18
+ global?: boolean;
19
+ }
20
+ export interface DetectPackageManagerOptions {
21
+ /**
22
+ * Whether to ignore the lock file
23
+ *
24
+ * @default false
25
+ */
26
+ ignoreLockFile?: boolean;
27
+ /**
28
+ * Whether to ignore the package.json file
29
+ *
30
+ * @default false
31
+ */
32
+ ignorePackageJSON?: boolean;
33
+ /**
34
+ * Whether to include parent directories
35
+ *
36
+ * @default false
37
+ */
38
+ includeParentDirs?: boolean;
39
+ /**
40
+ * Weather to ignore argv[1] to detect script
41
+ */
42
+ ignoreArgv?: boolean;
43
+ }
File without changes
@@ -0,0 +1,12 @@
1
+ import type { OperationOptions, PackageManager } from "./pm-types";
2
+ export declare function executeCommand(command: string, args: string[], options?: Pick<OperationOptions, "cwd" | "silent">): Promise<void>;
3
+ type NonPartial<T> = {
4
+ [P in keyof T]-?: T[P];
5
+ };
6
+ export declare const NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG = "No package manager auto-detected.";
7
+ export declare function resolveOperationOptions(options?: OperationOptions): Promise<NonPartial<Pick<OperationOptions, "cwd" | "silent" | "dev" | "global">> & Pick<OperationOptions, "workspace"> & {
8
+ packageManager: PackageManager;
9
+ }>;
10
+ export declare function getWorkspaceArgs(options: Awaited<ReturnType<typeof resolveOperationOptions>>): string[];
11
+ export declare function doesDependencyExist(name: string, options: Pick<Awaited<ReturnType<typeof resolveOperationOptions>>, "cwd" | "workspace">): boolean;
12
+ export {};
@@ -0,0 +1,86 @@
1
+ import { resolve } from "@reliverse/pathkit";
2
+ import { createRequire } from "node:module";
3
+ import { x } from "../exec/exec-mod.js";
4
+ import { detectPackageManager, packageManagers } from "./pm-detect.js";
5
+ function cached(fn) {
6
+ let v;
7
+ return () => {
8
+ if (v === void 0) {
9
+ v = fn().then((r) => {
10
+ v = r;
11
+ return v;
12
+ });
13
+ }
14
+ return v;
15
+ };
16
+ }
17
+ const hasCorepack = cached(async () => {
18
+ if (globalThis.process?.versions?.webcontainer) {
19
+ return false;
20
+ }
21
+ try {
22
+ const { exitCode } = await x("corepack", ["--version"]);
23
+ return exitCode === 0;
24
+ } catch {
25
+ return false;
26
+ }
27
+ });
28
+ export async function executeCommand(command, args, options = {}) {
29
+ const xArgs = command === "npm" || command === "bun" || command === "deno" || !await hasCorepack() ? [command, args] : ["corepack", [command, ...args]];
30
+ const { exitCode, stdout, stderr } = await x(xArgs[0], xArgs[1], {
31
+ nodeOptions: {
32
+ cwd: resolve(options.cwd || process.cwd()),
33
+ stdio: options.silent ? "pipe" : "inherit"
34
+ }
35
+ });
36
+ if (exitCode !== 0) {
37
+ throw new Error(
38
+ `\`${xArgs.flat().join(" ")}\` failed.${options.silent ? ["", stdout, stderr].join("\n") : ""}`
39
+ );
40
+ }
41
+ }
42
+ export const NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG = "No package manager auto-detected.";
43
+ export async function resolveOperationOptions(options = {}) {
44
+ const cwd = options.cwd || process.cwd();
45
+ const packageManager = (typeof options.packageManager === "string" ? packageManagers.find((pm) => pm.name === options.packageManager) : options.packageManager) || await detectPackageManager(options.cwd || process.cwd());
46
+ if (!packageManager) {
47
+ throw new Error(NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG);
48
+ }
49
+ return {
50
+ cwd,
51
+ silent: options.silent ?? false,
52
+ packageManager,
53
+ dev: options.dev ?? false,
54
+ workspace: options.workspace,
55
+ global: options.global ?? false
56
+ };
57
+ }
58
+ export function getWorkspaceArgs(options) {
59
+ if (!options.workspace) {
60
+ return [];
61
+ }
62
+ const workspacePkg = typeof options.workspace === "string" && options.workspace !== "" ? options.workspace : void 0;
63
+ if (options.packageManager.name === "pnpm") {
64
+ return workspacePkg ? ["--filter", workspacePkg] : ["--workspace-root"];
65
+ }
66
+ if (options.packageManager.name === "npm") {
67
+ return workspacePkg ? ["-w", workspacePkg] : ["--workspaces"];
68
+ }
69
+ if (options.packageManager.name === "yarn") {
70
+ if (!options.packageManager.majorVersion || options.packageManager.majorVersion === "1") {
71
+ return workspacePkg ? ["--cwd", workspacePkg] : ["-W"];
72
+ } else {
73
+ return workspacePkg ? ["workspace", workspacePkg] : [];
74
+ }
75
+ }
76
+ return [];
77
+ }
78
+ export function doesDependencyExist(name, options) {
79
+ const require = createRequire(options.cwd.endsWith("/") ? options.cwd : options.cwd + "/");
80
+ try {
81
+ const resolvedPath = require.resolve(name);
82
+ return resolvedPath.startsWith(options.cwd);
83
+ } catch {
84
+ return false;
85
+ }
86
+ }
@@ -72,8 +72,32 @@ export { BINARY_EXTS, BINARY_SET } from "./sdk-impl/utils/b-exts.js";
72
72
  export { isBinaryExt } from "./sdk-impl/utils/binary.js";
73
73
  export type { CommentStyle, FileExtension, CommentMapping } from "./sdk-impl/utils/comments.js";
74
74
  export { DEFAULT_COMMENT, COMMENT_MAP, getCommentPrefix } from "./sdk-impl/utils/comments.js";
75
+ export { notFoundError, hookChildProcess, verifyENOENT, verifyENOENTSync, } from "./sdk-impl/utils/exec/exec-enoent.js";
76
+ export type { EnvLike, EnvPathInfo } from "./sdk-impl/utils/exec/exec-env.js";
77
+ export { computeEnv } from "./sdk-impl/utils/exec/exec-env.js";
78
+ export { NonZeroExitError } from "./sdk-impl/utils/exec/exec-error.js";
79
+ export { escapeCommand, escapeArgument } from "./sdk-impl/utils/exec/exec-escape.js";
80
+ export type { Output, PipeOptions, KillSignal, OutputApi, Result, Options, XExec, } from "./sdk-impl/utils/exec/exec-mod.js";
81
+ export { ExecProcess, x, exec } from "./sdk-impl/utils/exec/exec-mod.js";
82
+ export { parse } from "./sdk-impl/utils/exec/exec-parse.js";
83
+ export { resolveCommand } from "./sdk-impl/utils/exec/exec-resolve.js";
84
+ export { readShebang } from "./sdk-impl/utils/exec/exec-shebang.js";
85
+ export { spawn, spawnSync } from "./sdk-impl/utils/exec/exec-spawn.js";
86
+ export { waitForEvent, combineStreams } from "./sdk-impl/utils/exec/exec-stream.js";
87
+ export type { ExecParseResult } from "./sdk-impl/utils/exec/exec-types.js";
88
+ export { _parse } from "./sdk-impl/utils/exec/exec-types.js";
75
89
  export { detectFileType, detectBufferType, detectStreamType, isBinary, getMimeType, } from "./sdk-impl/utils/file-type.js";
76
90
  export { finalizeBuild, finalizePub } from "./sdk-impl/utils/finalize.js";
91
+ export { safeRename, prepareCLIFiles } from "./sdk-impl/utils/fs-rename.js";
92
+ export { FILE_TYPES, INIT_BEHAVIOURS, DEST_FILE_EXISTS_BEHAVIOURS, CONTENT_CREATE_MODES, } from "./sdk-impl/utils/init/init-const.js";
93
+ export { createFileFromScratch, initFile, initFiles, escapeMarkdownCodeBlocks, } from "./sdk-impl/utils/init/init-impl.js";
94
+ export { gitignoreTemplate, readmeTemplate, licenseTemplate, } from "./sdk-impl/utils/init/init-tmpl.js";
95
+ export type { FileType, InitBehaviour, DestFileExistsBehaviour, ReinitUserConfig, InitFileRequest, InitFileOptions, InitFileResult, } from "./sdk-impl/utils/init/init-types.js";
96
+ export { installDependencies, addDependency, addDevDependency, removeDependency, ensureDependencyInstalled, dedupeDependencies, updateDependencies, runScript, } from "./sdk-impl/utils/pm/pm-api.js";
97
+ export { packageManagers, detectPackageManager } from "./sdk-impl/utils/pm/pm-detect.js";
98
+ export { findup, parsePackageManagerField } from "./sdk-impl/utils/pm/pm-parse.js";
99
+ export type { PackageManagerName, PackageManager, OperationOptions, DetectPackageManagerOptions, } from "./sdk-impl/utils/pm/pm-types.js";
100
+ export { executeCommand, NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG, resolveOperationOptions, getWorkspaceArgs, doesDependencyExist, } from "./sdk-impl/utils/pm/pm-utils.js";
77
101
  export { resolveCrossLibs, resolveAllCrossLibs } from "./sdk-impl/utils/resolve-cross-libs.js";
78
102
  export { useAggregator } from "./sdk-impl/utils/tools-agg.js";
79
103
  export { printUsage } from "./sdk-impl/utils/tools-impl.js";
@@ -155,6 +155,22 @@ export { shouldIgnoreFile, getAllFiles, getLineNumber } from "./sdk-impl/rules/r
155
155
  export { BINARY_EXTS, BINARY_SET } from "./sdk-impl/utils/b-exts.js";
156
156
  export { isBinaryExt } from "./sdk-impl/utils/binary.js";
157
157
  export { DEFAULT_COMMENT, COMMENT_MAP, getCommentPrefix } from "./sdk-impl/utils/comments.js";
158
+ export {
159
+ notFoundError,
160
+ hookChildProcess,
161
+ verifyENOENT,
162
+ verifyENOENTSync
163
+ } from "./sdk-impl/utils/exec/exec-enoent.js";
164
+ export { computeEnv } from "./sdk-impl/utils/exec/exec-env.js";
165
+ export { NonZeroExitError } from "./sdk-impl/utils/exec/exec-error.js";
166
+ export { escapeCommand, escapeArgument } from "./sdk-impl/utils/exec/exec-escape.js";
167
+ export { ExecProcess, x, exec } from "./sdk-impl/utils/exec/exec-mod.js";
168
+ export { parse } from "./sdk-impl/utils/exec/exec-parse.js";
169
+ export { resolveCommand } from "./sdk-impl/utils/exec/exec-resolve.js";
170
+ export { readShebang } from "./sdk-impl/utils/exec/exec-shebang.js";
171
+ export { spawn, spawnSync } from "./sdk-impl/utils/exec/exec-spawn.js";
172
+ export { waitForEvent, combineStreams } from "./sdk-impl/utils/exec/exec-stream.js";
173
+ export { _parse } from "./sdk-impl/utils/exec/exec-types.js";
158
174
  export {
159
175
  detectFileType,
160
176
  detectBufferType,
@@ -163,6 +179,43 @@ export {
163
179
  getMimeType
164
180
  } from "./sdk-impl/utils/file-type.js";
165
181
  export { finalizeBuild, finalizePub } from "./sdk-impl/utils/finalize.js";
182
+ export { safeRename, prepareCLIFiles } from "./sdk-impl/utils/fs-rename.js";
183
+ export {
184
+ FILE_TYPES,
185
+ INIT_BEHAVIOURS,
186
+ DEST_FILE_EXISTS_BEHAVIOURS,
187
+ CONTENT_CREATE_MODES
188
+ } from "./sdk-impl/utils/init/init-const.js";
189
+ export {
190
+ createFileFromScratch,
191
+ initFile,
192
+ initFiles,
193
+ escapeMarkdownCodeBlocks
194
+ } from "./sdk-impl/utils/init/init-impl.js";
195
+ export {
196
+ gitignoreTemplate,
197
+ readmeTemplate,
198
+ licenseTemplate
199
+ } from "./sdk-impl/utils/init/init-tmpl.js";
200
+ export {
201
+ installDependencies,
202
+ addDependency,
203
+ addDevDependency,
204
+ removeDependency,
205
+ ensureDependencyInstalled,
206
+ dedupeDependencies,
207
+ updateDependencies,
208
+ runScript
209
+ } from "./sdk-impl/utils/pm/pm-api.js";
210
+ export { packageManagers, detectPackageManager } from "./sdk-impl/utils/pm/pm-detect.js";
211
+ export { findup, parsePackageManagerField } from "./sdk-impl/utils/pm/pm-parse.js";
212
+ export {
213
+ executeCommand,
214
+ NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG,
215
+ resolveOperationOptions,
216
+ getWorkspaceArgs,
217
+ doesDependencyExist
218
+ } from "./sdk-impl/utils/pm/pm-utils.js";
166
219
  export { resolveCrossLibs, resolveAllCrossLibs } from "./sdk-impl/utils/resolve-cross-libs.js";
167
220
  export { useAggregator } from "./sdk-impl/utils/tools-agg.js";
168
221
  export { printUsage } from "./sdk-impl/utils/tools-impl.js";
package/package.json CHANGED
@@ -14,36 +14,37 @@
14
14
  "@rollup/plugin-node-resolve": "^16.0.1",
15
15
  "@rollup/plugin-replace": "^6.0.2",
16
16
  "@rollup/pluginutils": "^5.2.0",
17
- "@sinclair/typebox": "^0.34.37",
17
+ "@sinclair/typebox": "^0.34.38",
18
18
  "autoprefixer": "^10.4.21",
19
19
  "bun-plugin-tailwind": "^0.0.15",
20
- "c12": "^3.0.4",
20
+ "c12": "^3.1.0",
21
21
  "confbox": "^0.2.2",
22
- "cssnano": "^7.0.7",
22
+ "cssnano": "^7.1.0",
23
23
  "defu": "^6.1.4",
24
24
  "destr": "^2.0.5",
25
- "esbuild": "^0.25.5",
25
+ "esbuild": "^0.25.6",
26
26
  "execa": "^9.6.0",
27
27
  "file-type": "^21.0.0",
28
28
  "fix-dts-default-cjs-exports": "^1.0.1",
29
29
  "hookable": "^5.5.3",
30
30
  "jiti": "^2.4.2",
31
- "jsonrepair": "^3.12.0",
31
+ "jsonrepair": "^3.13.0",
32
32
  "lookpath": "^1.2.3",
33
33
  "magic-string": "^0.30.17",
34
34
  "mlly": "^1.7.4",
35
- "nypm": "^0.6.0",
36
35
  "p-all": "^5.0.0",
37
36
  "p-map": "^7.0.3",
37
+ "path-key": "^4.0.0",
38
38
  "pkg-types": "^2.2.0",
39
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",
43
- "rollup": "^4.44.1",
43
+ "rollup": "^4.45.1",
44
44
  "rollup-plugin-dts": "^6.2.1",
45
45
  "scule": "^1.3.0",
46
46
  "semver": "^7.7.2",
47
+ "shebang-command": "^2.0.0",
47
48
  "strip-json-comments": "^5.0.2",
48
49
  "tinyglobby": "^0.2.14",
49
50
  "ts-morph": "^26.0.0",
@@ -54,7 +55,7 @@
54
55
  "license": "MIT",
55
56
  "name": "@reliverse/dler",
56
57
  "type": "module",
57
- "version": "1.7.60",
58
+ "version": "1.7.61",
58
59
  "keywords": [
59
60
  "reliverse",
60
61
  "cli",