Skip to content

Commit b4fca5d

Browse files
authored
Improve the build of specific versions for the showcase (#659)
1 parent a306fc7 commit b4fca5d

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

packages/showcase/build-version.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,42 @@
44
// It requires a version argument, e.g. "v1.0.0-beta".
55
// This allow us to host multiple versions of the showcase in the same domain.
66
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7+
import packageJson from "@genexus/mercury/package.json" with { type: "json" };
78
import { spawn } from "child_process";
9+
import { rename } from "fs/promises";
810
import { styleText } from "util";
911

1012
const start = Date.now();
1113

12-
const VERSION = process.argv[2];
14+
const VERSION = process.argv[2] || `v${packageJson.version}`;
1315

14-
if (VERSION === undefined) {
15-
console.error(
16-
styleText("red", "error: version argument is required."),
17-
"Example:",
16+
if (process.argv[2] === undefined) {
17+
console.warn(
18+
styleText(
19+
"yellow",
20+
"warn: version argument was not provided. Using the current version from @genexus/mercury package."
21+
),
22+
"Example to customize the version:",
1823
styleText(["bold", "cyanBright"], "bun build.version v1.0.0-beta")
1924
);
20-
process.exit(1);
2125
}
2226

2327
const child = spawn(
2428
`bun compute-version && bun mercury -i=/${VERSION}/assets/icons/ -f=/${VERSION}/assets/fonts/ --outDir=.mercury/ && ng build --base-href /${VERSION}/`,
2529
{ stdio: "inherit", shell: true }
2630
);
2731

28-
child.on("close", code => {
32+
child.on("close", async code => {
2933
const duration = Date.now() - start;
3034

3135
if (code === 0) {
36+
// Rename the output folder to include the version
37+
try {
38+
await rename("dist/browser", `dist/browser-${VERSION}`);
39+
} catch (err) {
40+
console.error("Error renaming dist/browser folder:", err);
41+
}
42+
3243
console.log(styleText("green", `✓ version ${VERSION} built in ${duration}ms`));
3344
} else {
3445
console.log(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const mercuryVersion = "0.32.0";
1+
export const mercuryVersion = "0.33.0";

0 commit comments

Comments
 (0)