@reliverse/dler 1.7.151 → 1.7.153
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/bin/impl/auth/impl/init.d.ts +1 -1
- package/bin/impl/build/impl.d.ts +7 -1
- package/bin/impl/build/impl.js +161 -1
- package/bin/impl/config/constants.d.ts +1 -1
- package/bin/impl/config/constants.js +1 -1
- package/bin/impl/providers/better-t-stack/types.d.ts +2 -2
- package/bin/impl/pub/impl.d.ts +6 -1
- package/bin/impl/pub/impl.js +176 -2
- package/bin/impl/schema/mod.d.ts +140 -0
- package/bin/impl/schema/mod.js +22 -0
- package/bin/impl/update/impl.d.ts +3 -5
- package/bin/impl/update/impl.js +44 -64
- package/bin/impl/utils/workspace-prompt.d.ts +9 -0
- package/bin/impl/utils/workspace-prompt.js +46 -0
- package/bin/impl/utils/workspace-utils.d.ts +28 -0
- package/bin/impl/utils/workspace-utils.js +127 -0
- package/bin/mod.d.ts +3 -10
- package/bin/mod.js +11 -25
- package/package.json +2 -1
- package/bin/impl/migrate/codemods/anything-bun.d.ts +0 -5
- package/bin/impl/migrate/codemods/anything-bun.js +0 -577
- package/bin/impl/migrate/codemods/commander-rempts.d.ts +0 -4
- package/bin/impl/migrate/codemods/commander-rempts.js +0 -250
- package/bin/impl/migrate/codemods/console-relinka.d.ts +0 -3
- package/bin/impl/migrate/codemods/console-relinka.js +0 -142
- package/bin/impl/migrate/codemods/fs-relifso.d.ts +0 -8
- package/bin/impl/migrate/codemods/fs-relifso.js +0 -156
- package/bin/impl/migrate/codemods/monorepo-catalog.d.ts +0 -96
- package/bin/impl/migrate/codemods/monorepo-catalog.js +0 -517
- package/bin/impl/migrate/codemods/nodenext-bundler.d.ts +0 -10
- package/bin/impl/migrate/codemods/nodenext-bundler.js +0 -222
- package/bin/impl/migrate/codemods/path-pathkit.d.ts +0 -8
- package/bin/impl/migrate/codemods/path-pathkit.js +0 -143
- package/bin/impl/migrate/codemods/readdir-glob.d.ts +0 -8
- package/bin/impl/migrate/codemods/readdir-glob.js +0 -133
|
@@ -165,7 +165,7 @@ export declare const optionsSchema: z.ZodObject<{
|
|
|
165
165
|
}, z.core.$strip>;
|
|
166
166
|
export declare const outroText = "\uD83E\uDD73 All Done, Happy Hacking!";
|
|
167
167
|
export declare function getLatestNpmVersion(packageName: string): Promise<string>;
|
|
168
|
-
export declare function getPackageManager(): Promise<"
|
|
168
|
+
export declare function getPackageManager(): Promise<"npm" | "yarn" | "pnpm" | "bun">;
|
|
169
169
|
export declare function getEnvFiles(cwd: string): Promise<string[]>;
|
|
170
170
|
export declare function updateEnvs({ envs, files, isCommented, }: {
|
|
171
171
|
/**
|
package/bin/impl/build/impl.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { ReliverseConfig } from "../schema/mod.js";
|
|
2
2
|
import type { PerfTimer } from "../types/mod.js";
|
|
3
|
+
import type { WorkspacePackage } from "../utils/workspace-utils.js";
|
|
3
4
|
/**
|
|
4
5
|
* Main entry point for the rse build process.
|
|
5
6
|
* Handles building for both main project and libraries.
|
|
6
7
|
* @see `src/impl/pub/impl.ts` for pub main function implementation.
|
|
7
8
|
*/
|
|
8
|
-
export declare function dlerBuild({ flow, timer, isDev, config, debugOnlyCopyNonBuildFiles, debugDontCopyNonBuildFiles, disableOwnSpinner, }: {
|
|
9
|
+
export declare function dlerBuild({ flow, timer, isDev, config, debugOnlyCopyNonBuildFiles, debugDontCopyNonBuildFiles, disableOwnSpinner, workspacePackages, enableCache, depsOnly, showGraph, cleanCacheFlag, }: {
|
|
9
10
|
flow: "build" | "pub";
|
|
10
11
|
timer: PerfTimer;
|
|
11
12
|
isDev: boolean;
|
|
@@ -13,6 +14,11 @@ export declare function dlerBuild({ flow, timer, isDev, config, debugOnlyCopyNon
|
|
|
13
14
|
debugOnlyCopyNonBuildFiles?: boolean;
|
|
14
15
|
debugDontCopyNonBuildFiles?: boolean;
|
|
15
16
|
disableOwnSpinner?: boolean;
|
|
17
|
+
workspacePackages?: WorkspacePackage[] | null;
|
|
18
|
+
enableCache?: boolean;
|
|
19
|
+
depsOnly?: boolean;
|
|
20
|
+
showGraph?: boolean;
|
|
21
|
+
cleanCacheFlag?: boolean;
|
|
16
22
|
}): Promise<{
|
|
17
23
|
timer: PerfTimer;
|
|
18
24
|
effectiveConfig: any;
|
package/bin/impl/build/impl.js
CHANGED
|
@@ -9,6 +9,17 @@ import { PROJECT_ROOT } from "../config/constants.js";
|
|
|
9
9
|
import { getConfigDler } from "../config/load.js";
|
|
10
10
|
import { removeDistFolders } from "../utils/utils-clean.js";
|
|
11
11
|
import { handleDlerError } from "../utils/utils-error-cwd.js";
|
|
12
|
+
import { sortPackagesByDependencies } from "../utils/workspace-utils.js";
|
|
13
|
+
import {
|
|
14
|
+
cachePackageOutput,
|
|
15
|
+
cleanCache,
|
|
16
|
+
DependencyGraph,
|
|
17
|
+
findMonorepo,
|
|
18
|
+
hashPackage,
|
|
19
|
+
isPackageCached,
|
|
20
|
+
readMonorepoPackageJson,
|
|
21
|
+
restorePackageCache
|
|
22
|
+
} from "../../mod.js";
|
|
12
23
|
import { createCompletionTexts } from "../utils/finish-text.js";
|
|
13
24
|
import { dlerPostBuild, wrapper_CopyNonBuildFiles } from "./postbuild.js";
|
|
14
25
|
import { dlerPreBuild } from "./prebuild.js";
|
|
@@ -19,7 +30,12 @@ export async function dlerBuild({
|
|
|
19
30
|
config,
|
|
20
31
|
debugOnlyCopyNonBuildFiles,
|
|
21
32
|
debugDontCopyNonBuildFiles,
|
|
22
|
-
disableOwnSpinner
|
|
33
|
+
disableOwnSpinner,
|
|
34
|
+
workspacePackages,
|
|
35
|
+
enableCache,
|
|
36
|
+
depsOnly,
|
|
37
|
+
showGraph,
|
|
38
|
+
cleanCacheFlag
|
|
23
39
|
}) {
|
|
24
40
|
let effectiveConfig = config;
|
|
25
41
|
let shouldShowSpinner = false;
|
|
@@ -28,6 +44,118 @@ export async function dlerBuild({
|
|
|
28
44
|
if (!effectiveConfig) {
|
|
29
45
|
effectiveConfig = await getConfigDler();
|
|
30
46
|
}
|
|
47
|
+
let monorepo = null;
|
|
48
|
+
let dependencyGraph = null;
|
|
49
|
+
if (enableCache || depsOnly || showGraph || cleanCacheFlag) {
|
|
50
|
+
monorepo = await findMonorepo();
|
|
51
|
+
if (monorepo) {
|
|
52
|
+
relinka("verbose", `Monorepo detected at: ${monorepo.root}`);
|
|
53
|
+
if (cleanCacheFlag) {
|
|
54
|
+
await cleanCache(monorepo);
|
|
55
|
+
relinka("log", "\u2713 Cache cleaned");
|
|
56
|
+
}
|
|
57
|
+
const { globby } = await import("globby");
|
|
58
|
+
const packageJsonGlobs = monorepo.packageGlobs.map((glob) => `${glob}/package.json`);
|
|
59
|
+
const matches = await globby(packageJsonGlobs, { cwd: monorepo.root, absolute: true });
|
|
60
|
+
const packages = [];
|
|
61
|
+
for (const packageJsonPath of matches) {
|
|
62
|
+
const pkg = await readMonorepoPackageJson(packageJsonPath);
|
|
63
|
+
if (pkg) {
|
|
64
|
+
packages.push(pkg);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
dependencyGraph = new DependencyGraph(packages);
|
|
68
|
+
if (showGraph) {
|
|
69
|
+
dependencyGraph.print();
|
|
70
|
+
}
|
|
71
|
+
if (depsOnly) {
|
|
72
|
+
const activePackage = dependencyGraph.findActivePackage();
|
|
73
|
+
if (activePackage) {
|
|
74
|
+
const dependencies = dependencyGraph.getPackageDependenciesBuildOrder(activePackage.name);
|
|
75
|
+
relinka("info", `Building dependencies for ${activePackage.name}: ${dependencies.map((p) => p.name).join(", ")}`);
|
|
76
|
+
for (const pkg of dependencies) {
|
|
77
|
+
await buildCachedPackage(pkg, monorepo, enableCache || false);
|
|
78
|
+
}
|
|
79
|
+
relinka("log", "\u2713 Dependencies built");
|
|
80
|
+
return;
|
|
81
|
+
} else {
|
|
82
|
+
relinka("warn", "Not in a package directory, cannot determine dependencies");
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
relinka("warn", "Monorepo features requested but no monorepo detected");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (workspacePackages && workspacePackages.length > 0) {
|
|
90
|
+
relinka("info", `Building ${workspacePackages.length} workspace package(s)`);
|
|
91
|
+
relinka("verbose", `Workspace packages: ${workspacePackages.map((p) => p.name).join(", ")}`);
|
|
92
|
+
const sortedPackages = sortPackagesByDependencies(workspacePackages);
|
|
93
|
+
for (const pkg of sortedPackages) {
|
|
94
|
+
relinka("info", `Building package: ${pkg.name}`);
|
|
95
|
+
const packageConfig = {
|
|
96
|
+
...effectiveConfig,
|
|
97
|
+
// Override package-specific settings
|
|
98
|
+
projectName: pkg.name,
|
|
99
|
+
projectAuthor: "reliverse",
|
|
100
|
+
projectDescription: "Dler plugin for code migration and modernization codemods",
|
|
101
|
+
projectLicense: "MIT",
|
|
102
|
+
coreEntrySrcDir: path.join(pkg.path, "src"),
|
|
103
|
+
// Assume src dir in package
|
|
104
|
+
coreEntryFile: "mod.ts",
|
|
105
|
+
// Default entry file for workspace packages
|
|
106
|
+
// Override dist directories to be package-specific
|
|
107
|
+
distNpmDirName: path.join("dist-workspace", pkg.name, "npm"),
|
|
108
|
+
distJsrDirName: path.join("dist-workspace", pkg.name, "jsr"),
|
|
109
|
+
libsDirDist: path.join("dist-workspace", pkg.name, "libs"),
|
|
110
|
+
// Ensure it's treated as a library, not CLI
|
|
111
|
+
coreIsCLI: { enabled: false, scripts: {} },
|
|
112
|
+
// Use ESM format for workspace packages
|
|
113
|
+
transpileFormat: "esm",
|
|
114
|
+
transpileTarget: "node",
|
|
115
|
+
// Keep readable for libraries
|
|
116
|
+
transpileMinify: false,
|
|
117
|
+
transpileSourcemap: "none",
|
|
118
|
+
// Use package-specific package.json
|
|
119
|
+
corePackageJsonPath: pkg.packageJsonPath
|
|
120
|
+
};
|
|
121
|
+
await regular_buildFlow(timer, isDev, packageConfig);
|
|
122
|
+
await library_buildFlow(timer, isDev, packageConfig);
|
|
123
|
+
await binary_buildFlow(timer, isDev, packageConfig);
|
|
124
|
+
const distPackageJsonPath = path.join(packageConfig.distNpmDirName, "package.json");
|
|
125
|
+
relinka("verbose", `Copying package.json from ${pkg.packageJsonPath} to ${distPackageJsonPath}`);
|
|
126
|
+
await fs.copy(pkg.packageJsonPath, distPackageJsonPath);
|
|
127
|
+
const packageJsonContent = await fs.readFile(distPackageJsonPath, "utf-8");
|
|
128
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
129
|
+
packageJson.main = "./bin/mod.js";
|
|
130
|
+
packageJson.types = "./bin/mod.d.ts";
|
|
131
|
+
packageJson.exports = {
|
|
132
|
+
".": {
|
|
133
|
+
"types": "./bin/mod.d.ts",
|
|
134
|
+
"default": "./bin/mod.js"
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
packageJson.files = ["bin"];
|
|
138
|
+
packageJson.module = "./bin/mod.js";
|
|
139
|
+
packageJson.publishConfig = { access: "public" };
|
|
140
|
+
if (!packageJson.homepage) {
|
|
141
|
+
packageJson.homepage = "https://docs.reliverse.org/cli";
|
|
142
|
+
}
|
|
143
|
+
if (!packageJson.bugs) {
|
|
144
|
+
packageJson.bugs = {
|
|
145
|
+
email: "blefnk@gmail.com",
|
|
146
|
+
url: `https://github.com/reliverse/dler/issues`
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
if (!packageJson.devDependencies) {
|
|
150
|
+
packageJson.devDependencies = {};
|
|
151
|
+
}
|
|
152
|
+
await fs.writeFile(distPackageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
153
|
+
relinka("verbose", `Updated package.json paths to point to bin directory`);
|
|
154
|
+
relinka("success", `Successfully built package: ${pkg.name}`);
|
|
155
|
+
}
|
|
156
|
+
relinka("success", `Successfully built all ${workspacePackages.length} workspace package(s)`);
|
|
157
|
+
relinka("info", "Building main project and libraries...");
|
|
158
|
+
}
|
|
31
159
|
shouldShowSpinner = effectiveConfig.displayBuildPubLogs === false && !disableOwnSpinner;
|
|
32
160
|
const buildSteps = [
|
|
33
161
|
"Loading configuration",
|
|
@@ -102,3 +230,35 @@ export async function dlerBuild({
|
|
|
102
230
|
handleDlerError(error);
|
|
103
231
|
}
|
|
104
232
|
}
|
|
233
|
+
async function buildCachedPackage(pkg, monorepo, enableCache) {
|
|
234
|
+
if (!pkg.buildScript) {
|
|
235
|
+
relinka("log", `\u2713 ${pkg.name}: Nothing to build`);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
relinka("log", `\u25D0 ${pkg.name}: ${pkg.buildScript}`);
|
|
239
|
+
if (enableCache) {
|
|
240
|
+
const { packageHash } = await hashPackage(pkg);
|
|
241
|
+
if (await isPackageCached(monorepo, pkg, packageHash) && pkg.config.cache) {
|
|
242
|
+
await restorePackageCache(monorepo, pkg, packageHash);
|
|
243
|
+
relinka("log", `\u2713 ${pkg.name}: Cached!`);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const { execaCommand } = await import("execa");
|
|
247
|
+
const args = [...monorepo.packageManager.runCmd, "build"];
|
|
248
|
+
await execaCommand(args.join(" "), {
|
|
249
|
+
cwd: pkg.dir,
|
|
250
|
+
env: { ...process.env, INSIDE_DLER: "true" }
|
|
251
|
+
});
|
|
252
|
+
if (pkg.config.cache) {
|
|
253
|
+
await cachePackageOutput(monorepo, pkg, packageHash);
|
|
254
|
+
}
|
|
255
|
+
} else {
|
|
256
|
+
const { execaCommand } = await import("execa");
|
|
257
|
+
const args = [...monorepo.packageManager.runCmd, "build"];
|
|
258
|
+
await execaCommand(args.join(" "), {
|
|
259
|
+
cwd: pkg.dir,
|
|
260
|
+
env: { ...process.env, INSIDE_DLER: "true" }
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
relinka("log", `\u2713 ${pkg.name}: Built`);
|
|
264
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const PROJECT_ROOT: string;
|
|
2
|
-
export declare const cliVersion = "1.7.
|
|
2
|
+
export declare const cliVersion = "1.7.153";
|
|
3
3
|
export declare const cliName = "@reliverse/rse";
|
|
4
4
|
export declare const rseName = "@reliverse/rse";
|
|
5
5
|
export declare const dlerName = "@reliverse/dler";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import os from "node:os";
|
|
2
2
|
import path from "@reliverse/pathkit";
|
|
3
3
|
export const PROJECT_ROOT = path.resolve(process.cwd());
|
|
4
|
-
const version = "1.7.
|
|
4
|
+
const version = "1.7.153";
|
|
5
5
|
export const cliVersion = version;
|
|
6
6
|
export const cliName = "@reliverse/rse";
|
|
7
7
|
export const rseName = "@reliverse/rse";
|
|
@@ -56,14 +56,14 @@ export declare const AddonsSchema: z.ZodEnum<{
|
|
|
56
56
|
export type Addons = z.infer<typeof AddonsSchema>;
|
|
57
57
|
export declare const ExamplesSchema: z.ZodEnum<{
|
|
58
58
|
none: "none";
|
|
59
|
-
ai: "ai";
|
|
60
59
|
todo: "todo";
|
|
60
|
+
ai: "ai";
|
|
61
61
|
}>;
|
|
62
62
|
export type Examples = z.infer<typeof ExamplesSchema>;
|
|
63
63
|
export declare const PackageManagerSchema: z.ZodEnum<{
|
|
64
|
-
bun: "bun";
|
|
65
64
|
npm: "npm";
|
|
66
65
|
pnpm: "pnpm";
|
|
66
|
+
bun: "bun";
|
|
67
67
|
}>;
|
|
68
68
|
export type PackageManager = z.infer<typeof PackageManagerSchema>;
|
|
69
69
|
export declare const DatabaseSetupSchema: z.ZodEnum<{
|
package/bin/impl/pub/impl.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { ReliverseConfig } from "../schema/mod.js";
|
|
2
2
|
import type { PerfTimer } from "../types/mod.js";
|
|
3
|
+
import type { WorkspacePackage } from "../utils/workspace-utils.js";
|
|
3
4
|
/**
|
|
4
5
|
* Main entry point for the rse build and publish process.
|
|
5
6
|
* Handles building and publishing for both main project and libraries.
|
|
6
7
|
* @see `src/impl/build/impl.ts` for build main function implementation.
|
|
7
8
|
*/
|
|
8
|
-
export declare function dlerPub(timer: PerfTimer, isDev: boolean, config?: ReliverseConfig
|
|
9
|
+
export declare function dlerPub(timer: PerfTimer, isDev: boolean, config?: ReliverseConfig, workspacePackages?: WorkspacePackage[] | null, options?: {
|
|
10
|
+
enableCache?: boolean;
|
|
11
|
+
showGraph?: boolean;
|
|
12
|
+
cleanCacheFlag?: boolean;
|
|
13
|
+
}): Promise<void>;
|
package/bin/impl/pub/impl.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { bumpHandler, isBumpDisabled, setBumpDisabledValueTo } from "@reliverse/bleump";
|
|
2
|
+
import path from "@reliverse/pathkit";
|
|
3
|
+
import fs from "@reliverse/relifso";
|
|
2
4
|
import { relinka } from "@reliverse/relinka";
|
|
3
5
|
import { createMultiStepSpinner } from "@reliverse/rempts";
|
|
4
6
|
import { dlerBuild } from "../build/impl.js";
|
|
@@ -7,8 +9,52 @@ import { regular_pubFlow } from "../build/regular-flow.js";
|
|
|
7
9
|
import { getConfigDler } from "../config/load.js";
|
|
8
10
|
import { finalizeBuild, finalizePub } from "../utils/finalize.js";
|
|
9
11
|
import { handleDlerError } from "../utils/utils-error-cwd.js";
|
|
12
|
+
import { sortPackagesByDependencies } from "../utils/workspace-utils.js";
|
|
13
|
+
import {
|
|
14
|
+
cleanCache,
|
|
15
|
+
DependencyGraph,
|
|
16
|
+
findMonorepo,
|
|
17
|
+
readMonorepoPackageJson
|
|
18
|
+
} from "../../mod.js";
|
|
10
19
|
import { createCompletionTexts } from "../utils/finish-text.js";
|
|
11
|
-
|
|
20
|
+
async function bumpWorkspacePackages(workspacePackages, rootVersion, bumpMode) {
|
|
21
|
+
if (!workspacePackages || workspacePackages.length === 0) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
relinka("verbose", `Checking workspace packages for version bumping (root version: ${rootVersion})`);
|
|
25
|
+
for (const pkg of workspacePackages) {
|
|
26
|
+
try {
|
|
27
|
+
const packageJsonContent = await fs.readFile(pkg.packageJsonPath, "utf-8");
|
|
28
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
29
|
+
if (packageJson.version === rootVersion) {
|
|
30
|
+
relinka("info", `Bumping version for workspace package: ${pkg.name} (${packageJson.version} -> ${getNextVersion(packageJson.version, bumpMode)})`);
|
|
31
|
+
packageJson.version = getNextVersion(packageJson.version, bumpMode);
|
|
32
|
+
await fs.writeFile(pkg.packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
33
|
+
relinka("success", `Successfully bumped ${pkg.name} to version ${packageJson.version}`);
|
|
34
|
+
} else {
|
|
35
|
+
relinka("verbose", `Skipping ${pkg.name} (version ${packageJson.version} doesn't match root version ${rootVersion})`);
|
|
36
|
+
}
|
|
37
|
+
} catch (error) {
|
|
38
|
+
relinka("warn", `Failed to bump version for ${pkg.name}: ${error}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function getNextVersion(currentVersion, bumpMode) {
|
|
43
|
+
const parts = currentVersion.split(".").map(Number);
|
|
44
|
+
const major = parts[0] || 0;
|
|
45
|
+
const minor = parts[1] || 0;
|
|
46
|
+
const patch = parts[2] || 0;
|
|
47
|
+
switch (bumpMode) {
|
|
48
|
+
case "major":
|
|
49
|
+
return `${major + 1}.0.0`;
|
|
50
|
+
case "minor":
|
|
51
|
+
return `${major}.${minor + 1}.0`;
|
|
52
|
+
case "patch":
|
|
53
|
+
default:
|
|
54
|
+
return `${major}.${minor}.${patch + 1}`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export async function dlerPub(timer, isDev, config, workspacePackages, options) {
|
|
12
58
|
let effectiveConfig = config;
|
|
13
59
|
let shouldShowSpinner = false;
|
|
14
60
|
let multiStepSpinner = null;
|
|
@@ -16,6 +62,124 @@ export async function dlerPub(timer, isDev, config) {
|
|
|
16
62
|
if (!effectiveConfig) {
|
|
17
63
|
effectiveConfig = await getConfigDler();
|
|
18
64
|
}
|
|
65
|
+
let monorepo = null;
|
|
66
|
+
let dependencyGraph = null;
|
|
67
|
+
if (options?.enableCache || options?.showGraph || options?.cleanCacheFlag) {
|
|
68
|
+
monorepo = await findMonorepo();
|
|
69
|
+
if (monorepo) {
|
|
70
|
+
relinka("verbose", `Monorepo detected at: ${monorepo.root}`);
|
|
71
|
+
if (options.cleanCacheFlag) {
|
|
72
|
+
await cleanCache(monorepo);
|
|
73
|
+
relinka("log", "\u2713 Cache cleaned");
|
|
74
|
+
}
|
|
75
|
+
const { globby } = await import("globby");
|
|
76
|
+
const packageJsonGlobs = monorepo.packageGlobs.map((glob) => `${glob}/package.json`);
|
|
77
|
+
const matches = await globby(packageJsonGlobs, { cwd: monorepo.root, absolute: true });
|
|
78
|
+
const packages = [];
|
|
79
|
+
for (const packageJsonPath of matches) {
|
|
80
|
+
const pkg = await readMonorepoPackageJson(packageJsonPath);
|
|
81
|
+
if (pkg) {
|
|
82
|
+
packages.push(pkg);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
dependencyGraph = new DependencyGraph(packages);
|
|
86
|
+
if (options.showGraph) {
|
|
87
|
+
dependencyGraph.print();
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
relinka("warn", "Monorepo features requested but no monorepo detected");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (workspacePackages && workspacePackages.length > 0) {
|
|
94
|
+
relinka("info", `Publishing ${workspacePackages.length} workspace package(s)`);
|
|
95
|
+
const sortedPackages = sortPackagesByDependencies(workspacePackages);
|
|
96
|
+
for (const pkg of sortedPackages) {
|
|
97
|
+
relinka("info", `Processing package: ${pkg.name}`);
|
|
98
|
+
const packageConfig = {
|
|
99
|
+
...effectiveConfig,
|
|
100
|
+
// Override package-specific settings
|
|
101
|
+
projectName: pkg.name,
|
|
102
|
+
projectAuthor: "reliverse",
|
|
103
|
+
projectDescription: "Dler plugin for code migration and modernization codemods",
|
|
104
|
+
projectLicense: "MIT",
|
|
105
|
+
coreEntrySrcDir: path.join(pkg.path, "src"),
|
|
106
|
+
// Assume src dir in package
|
|
107
|
+
coreEntryFile: "mod.ts",
|
|
108
|
+
// Default entry file for workspace packages
|
|
109
|
+
// Override dist directories to be package-specific
|
|
110
|
+
distNpmDirName: path.join("dist-workspace", pkg.name, "npm"),
|
|
111
|
+
distJsrDirName: path.join("dist-workspace", pkg.name, "jsr"),
|
|
112
|
+
libsDirDist: path.join("dist-workspace", pkg.name, "libs"),
|
|
113
|
+
// Ensure it's treated as a library, not CLI
|
|
114
|
+
coreIsCLI: { enabled: false, scripts: {} },
|
|
115
|
+
// Use ESM format for workspace packages
|
|
116
|
+
transpileFormat: "esm",
|
|
117
|
+
transpileTarget: "node",
|
|
118
|
+
// Keep readable for libraries
|
|
119
|
+
transpileMinify: false,
|
|
120
|
+
transpileSourcemap: "none",
|
|
121
|
+
// Use package-specific package.json
|
|
122
|
+
corePackageJsonPath: pkg.packageJsonPath
|
|
123
|
+
};
|
|
124
|
+
await dlerBuild({
|
|
125
|
+
flow: "pub",
|
|
126
|
+
timer,
|
|
127
|
+
isDev,
|
|
128
|
+
config: packageConfig,
|
|
129
|
+
debugOnlyCopyNonBuildFiles: false,
|
|
130
|
+
debugDontCopyNonBuildFiles: false,
|
|
131
|
+
disableOwnSpinner: true,
|
|
132
|
+
enableCache: options?.enableCache,
|
|
133
|
+
showGraph: false,
|
|
134
|
+
// Already shown above if requested
|
|
135
|
+
cleanCacheFlag: false
|
|
136
|
+
// Already cleaned above if requested
|
|
137
|
+
});
|
|
138
|
+
const distPackageJsonPath = path.join(packageConfig.distNpmDirName, "package.json");
|
|
139
|
+
relinka(
|
|
140
|
+
"verbose",
|
|
141
|
+
`Copying package.json from ${pkg.packageJsonPath} to ${distPackageJsonPath}`
|
|
142
|
+
);
|
|
143
|
+
await fs.copy(pkg.packageJsonPath, distPackageJsonPath);
|
|
144
|
+
const packageJsonContent = await fs.readFile(distPackageJsonPath, "utf-8");
|
|
145
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
146
|
+
packageJson.main = "./bin/mod.js";
|
|
147
|
+
packageJson.types = "./bin/mod.d.ts";
|
|
148
|
+
packageJson.exports = {
|
|
149
|
+
".": {
|
|
150
|
+
types: "./bin/mod.d.ts",
|
|
151
|
+
default: "./bin/mod.js"
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
packageJson.files = ["bin"];
|
|
155
|
+
packageJson.module = "./bin/mod.js";
|
|
156
|
+
packageJson.publishConfig = { access: "public" };
|
|
157
|
+
if (!packageJson.homepage) {
|
|
158
|
+
packageJson.homepage = "https://docs.reliverse.org/cli";
|
|
159
|
+
}
|
|
160
|
+
if (!packageJson.bugs) {
|
|
161
|
+
packageJson.bugs = {
|
|
162
|
+
email: "blefnk@gmail.com",
|
|
163
|
+
url: `https://github.com/reliverse/dler/issues`
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
if (!packageJson.devDependencies) {
|
|
167
|
+
packageJson.devDependencies = {};
|
|
168
|
+
}
|
|
169
|
+
await fs.writeFile(distPackageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
170
|
+
relinka("verbose", `Updated package.json paths to point to bin directory`);
|
|
171
|
+
if (!effectiveConfig.commonPubPause) {
|
|
172
|
+
await regular_pubFlow(timer, isDev, packageConfig);
|
|
173
|
+
await library_pubFlow(timer, isDev, packageConfig);
|
|
174
|
+
}
|
|
175
|
+
relinka("success", `Successfully published package: ${pkg.name}`);
|
|
176
|
+
}
|
|
177
|
+
relinka(
|
|
178
|
+
"success",
|
|
179
|
+
`Successfully published all ${workspacePackages.length} workspace package(s)`
|
|
180
|
+
);
|
|
181
|
+
relinka("info", "Publishing main project and libraries...");
|
|
182
|
+
}
|
|
19
183
|
shouldShowSpinner = effectiveConfig.displayBuildPubLogs === false;
|
|
20
184
|
const pubSteps = effectiveConfig.commonPubPause ? ["Loading configuration", "Version bumping", "Building project", "Finalizing"] : [
|
|
21
185
|
"Loading configuration",
|
|
@@ -29,6 +193,15 @@ export async function dlerPub(timer, isDev, config) {
|
|
|
29
193
|
const bumpIsDisabled = await isBumpDisabled();
|
|
30
194
|
if (!bumpIsDisabled && !effectiveConfig.commonPubPause) {
|
|
31
195
|
try {
|
|
196
|
+
if (workspacePackages && workspacePackages.length > 0) {
|
|
197
|
+
const rootPackageJson = await fs.readFile("package.json", "utf-8");
|
|
198
|
+
const rootPackage = JSON.parse(rootPackageJson);
|
|
199
|
+
await bumpWorkspacePackages(
|
|
200
|
+
workspacePackages,
|
|
201
|
+
rootPackage.version,
|
|
202
|
+
effectiveConfig.bumpMode
|
|
203
|
+
);
|
|
204
|
+
}
|
|
32
205
|
await bumpHandler(
|
|
33
206
|
effectiveConfig.bumpMode,
|
|
34
207
|
false,
|
|
@@ -41,7 +214,7 @@ export async function dlerPub(timer, isDev, config) {
|
|
|
41
214
|
}
|
|
42
215
|
}
|
|
43
216
|
if (multiStepSpinner) multiStepSpinner.nextStep();
|
|
44
|
-
const
|
|
217
|
+
const buildResult = await dlerBuild({
|
|
45
218
|
flow: "pub",
|
|
46
219
|
timer,
|
|
47
220
|
isDev,
|
|
@@ -51,6 +224,7 @@ export async function dlerPub(timer, isDev, config) {
|
|
|
51
224
|
disableOwnSpinner: true
|
|
52
225
|
// disable build's spinner if pub is showing one
|
|
53
226
|
});
|
|
227
|
+
const buildConfig = buildResult?.effectiveConfig || effectiveConfig;
|
|
54
228
|
if (multiStepSpinner) multiStepSpinner.nextStep();
|
|
55
229
|
if (effectiveConfig.commonPubPause) {
|
|
56
230
|
await finalizeBuild(shouldShowSpinner, timer, effectiveConfig.commonPubPause, "pub");
|
package/bin/impl/schema/mod.d.ts
CHANGED
|
@@ -99,6 +99,80 @@ export interface ReliverseConfig {
|
|
|
99
99
|
packages?: string[];
|
|
100
100
|
sharedPackages?: string[];
|
|
101
101
|
};
|
|
102
|
+
/**
|
|
103
|
+
* Configuration for workspace auto-detection and management.
|
|
104
|
+
* Enables automatic discovery and processing of workspace packages.
|
|
105
|
+
*/
|
|
106
|
+
monorepoWorkspaces?: {
|
|
107
|
+
/**
|
|
108
|
+
* When `true`, enables workspace auto-detection for build and publish commands.
|
|
109
|
+
* When `false`, workspace detection is disabled and commands work on the main project only.
|
|
110
|
+
*
|
|
111
|
+
* @default true
|
|
112
|
+
*/
|
|
113
|
+
enabled: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* When `true`, automatically discovers publishable packages from workspace configuration.
|
|
116
|
+
* When `false`, packages must be manually configured in libsList.
|
|
117
|
+
*
|
|
118
|
+
* @default true
|
|
119
|
+
*/
|
|
120
|
+
autoDiscoverPackages: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Controls the order in which packages are processed:
|
|
123
|
+
* - `dependency`: Packages are processed in dependency order (dependencies first)
|
|
124
|
+
* - `parallel`: All packages are processed in parallel (faster but may fail if dependencies aren't met)
|
|
125
|
+
*
|
|
126
|
+
* @default "dependency"
|
|
127
|
+
*/
|
|
128
|
+
buildOrder: "dependency" | "parallel";
|
|
129
|
+
/**
|
|
130
|
+
* Additional glob patterns to include packages beyond workspace configuration.
|
|
131
|
+
* These patterns are merged with the workspace patterns from package.json.
|
|
132
|
+
*
|
|
133
|
+
* @example ["examples/*", "tools/*"]
|
|
134
|
+
* @default []
|
|
135
|
+
*/
|
|
136
|
+
includePatterns: string[];
|
|
137
|
+
/**
|
|
138
|
+
* Glob patterns to exclude packages from processing.
|
|
139
|
+
* Useful for excluding test packages or development tools.
|
|
140
|
+
*
|
|
141
|
+
* @example ["examples/*", "test-*"]
|
|
142
|
+
* @default []
|
|
143
|
+
*/
|
|
144
|
+
excludePatterns: string[];
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Configuration for monorepo caching features.
|
|
148
|
+
* Enables smart caching to skip rebuilding unchanged packages.
|
|
149
|
+
*/
|
|
150
|
+
monorepoCache?: {
|
|
151
|
+
/**
|
|
152
|
+
* When `true`, enables smart caching for monorepo packages.
|
|
153
|
+
* Packages are only rebuilt if their source files have changed.
|
|
154
|
+
*
|
|
155
|
+
* @default false
|
|
156
|
+
*/
|
|
157
|
+
enabled: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Output directory for cached builds.
|
|
160
|
+
* Each package's build output is cached in a subdirectory.
|
|
161
|
+
*
|
|
162
|
+
* @default "dist"
|
|
163
|
+
*/
|
|
164
|
+
outDir: string;
|
|
165
|
+
/**
|
|
166
|
+
* Glob patterns for files to include in cache hash calculation.
|
|
167
|
+
* Only changes to these files will trigger a rebuild.
|
|
168
|
+
*/
|
|
169
|
+
include: string[];
|
|
170
|
+
/**
|
|
171
|
+
* Glob patterns for files to exclude from cache hash calculation.
|
|
172
|
+
* Changes to these files will not trigger a rebuild.
|
|
173
|
+
*/
|
|
174
|
+
exclude: string[];
|
|
175
|
+
};
|
|
102
176
|
ignoreDependencies?: string[];
|
|
103
177
|
customRules?: Record<string, unknown>;
|
|
104
178
|
multipleRepoCloneMode?: boolean;
|
|
@@ -1118,6 +1192,72 @@ export declare const defineConfig: (userConfig?: Partial<ReliverseConfig>) => {
|
|
|
1118
1192
|
packages?: string[];
|
|
1119
1193
|
sharedPackages?: string[];
|
|
1120
1194
|
};
|
|
1195
|
+
monorepoWorkspaces?: {
|
|
1196
|
+
/**
|
|
1197
|
+
* When `true`, enables workspace auto-detection for build and publish commands.
|
|
1198
|
+
* When `false`, workspace detection is disabled and commands work on the main project only.
|
|
1199
|
+
*
|
|
1200
|
+
* @default true
|
|
1201
|
+
*/
|
|
1202
|
+
enabled: boolean;
|
|
1203
|
+
/**
|
|
1204
|
+
* When `true`, automatically discovers publishable packages from workspace configuration.
|
|
1205
|
+
* When `false`, packages must be manually configured in libsList.
|
|
1206
|
+
*
|
|
1207
|
+
* @default true
|
|
1208
|
+
*/
|
|
1209
|
+
autoDiscoverPackages: boolean;
|
|
1210
|
+
/**
|
|
1211
|
+
* Controls the order in which packages are processed:
|
|
1212
|
+
* - `dependency`: Packages are processed in dependency order (dependencies first)
|
|
1213
|
+
* - `parallel`: All packages are processed in parallel (faster but may fail if dependencies aren't met)
|
|
1214
|
+
*
|
|
1215
|
+
* @default "dependency"
|
|
1216
|
+
*/
|
|
1217
|
+
buildOrder: "dependency" | "parallel";
|
|
1218
|
+
/**
|
|
1219
|
+
* Additional glob patterns to include packages beyond workspace configuration.
|
|
1220
|
+
* These patterns are merged with the workspace patterns from package.json.
|
|
1221
|
+
*
|
|
1222
|
+
* @example ["examples/*", "tools/*"]
|
|
1223
|
+
* @default []
|
|
1224
|
+
*/
|
|
1225
|
+
includePatterns: string[];
|
|
1226
|
+
/**
|
|
1227
|
+
* Glob patterns to exclude packages from processing.
|
|
1228
|
+
* Useful for excluding test packages or development tools.
|
|
1229
|
+
*
|
|
1230
|
+
* @example ["examples/*", "test-*"]
|
|
1231
|
+
* @default []
|
|
1232
|
+
*/
|
|
1233
|
+
excludePatterns: string[];
|
|
1234
|
+
};
|
|
1235
|
+
monorepoCache?: {
|
|
1236
|
+
/**
|
|
1237
|
+
* When `true`, enables smart caching for monorepo packages.
|
|
1238
|
+
* Packages are only rebuilt if their source files have changed.
|
|
1239
|
+
*
|
|
1240
|
+
* @default false
|
|
1241
|
+
*/
|
|
1242
|
+
enabled: boolean;
|
|
1243
|
+
/**
|
|
1244
|
+
* Output directory for cached builds.
|
|
1245
|
+
* Each package's build output is cached in a subdirectory.
|
|
1246
|
+
*
|
|
1247
|
+
* @default "dist"
|
|
1248
|
+
*/
|
|
1249
|
+
outDir: string;
|
|
1250
|
+
/**
|
|
1251
|
+
* Glob patterns for files to include in cache hash calculation.
|
|
1252
|
+
* Only changes to these files will trigger a rebuild.
|
|
1253
|
+
*/
|
|
1254
|
+
include: string[];
|
|
1255
|
+
/**
|
|
1256
|
+
* Glob patterns for files to exclude from cache hash calculation.
|
|
1257
|
+
* Changes to these files will not trigger a rebuild.
|
|
1258
|
+
*/
|
|
1259
|
+
exclude: string[];
|
|
1260
|
+
};
|
|
1121
1261
|
ignoreDependencies?: string[];
|
|
1122
1262
|
customRules?: Record<string, unknown>;
|
|
1123
1263
|
multipleRepoCloneMode?: boolean;
|
package/bin/impl/schema/mod.js
CHANGED
|
@@ -239,6 +239,28 @@ export const DEFAULT_CONFIG_RELIVERSE = {
|
|
|
239
239
|
packages: [],
|
|
240
240
|
sharedPackages: []
|
|
241
241
|
},
|
|
242
|
+
// Monorepo Workspaces Configuration
|
|
243
|
+
monorepoWorkspaces: {
|
|
244
|
+
enabled: true,
|
|
245
|
+
autoDiscoverPackages: true,
|
|
246
|
+
buildOrder: "dependency",
|
|
247
|
+
includePatterns: [],
|
|
248
|
+
excludePatterns: []
|
|
249
|
+
},
|
|
250
|
+
// Monorepo Cache Configuration
|
|
251
|
+
monorepoCache: {
|
|
252
|
+
enabled: false,
|
|
253
|
+
outDir: "dist",
|
|
254
|
+
include: ["src/**/*"],
|
|
255
|
+
exclude: [
|
|
256
|
+
"**/__tests__/**",
|
|
257
|
+
"**/__mocks__/**",
|
|
258
|
+
"**/*.test.*",
|
|
259
|
+
"**/e2e/**",
|
|
260
|
+
"**/dist/**",
|
|
261
|
+
"**/.output/**"
|
|
262
|
+
]
|
|
263
|
+
},
|
|
242
264
|
// List dependencies to exclude from checks
|
|
243
265
|
ignoreDependencies: [],
|
|
244
266
|
// Provide custom rules for Rse AI
|