Skip to content

Commit

Permalink
build: fix blazebuild scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
virtual-designer committed Jun 3, 2024
1 parent 7230148 commit f0ac5d5
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 43 deletions.
2 changes: 1 addition & 1 deletion blaze/wrapper/blaze_wrapper.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function getProperty(name, def) {

function determineIndexFile() {
const blazeSrcPath = getProperty("blaze.srcpath", "build_src");
return path.resolve(PROJECT_DIR, blazeSrcPath, "src/main/typescript/index.ts");
return path.resolve(PROJECT_DIR, blazeSrcPath, "src/main/typescript/cli.ts");
}


Expand Down
4 changes: 2 additions & 2 deletions blazebuild/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "blazebuild",
"main": "src/main/typescript/exports.ts",
"module": "src/main/typescript/exports.ts",
"main": "src/main/typescript/index.ts",
"module": "src/main/typescript/index.ts",
"type": "module",
"devDependencies": {
"@types/bun": "latest",
Expand Down
12 changes: 12 additions & 0 deletions blazebuild/src/main/typescript/cli.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import "reflect-metadata";

import Blaze from "./core/Blaze";

async function main() {
const blaze = Blaze.getInstance();
await blaze.boot();
await blaze.run();
await blaze.cacheManager.saveCache();
}

await main();
25 changes: 0 additions & 25 deletions blazebuild/src/main/typescript/exports.ts

This file was deleted.

32 changes: 24 additions & 8 deletions blazebuild/src/main/typescript/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
import "./types/build";
import "reflect-metadata";

import Blaze from "./core/Blaze";
import AbstractTask from "./tasks/AbstractTask";
import { Task } from "./tasks/Task";
import { TaskAction } from "./tasks/TaskAction";
import { TaskDependencyGenerator } from "./tasks/TaskDependencyGenerator";
import { TaskInputGenerator } from "./tasks/TaskInputGenerator";
import { TaskOutputGenerator } from "./tasks/TaskOutputGenerator";
import IO from "./io/IO";
import { files, glob } from "./utils/glob";

async function main() {
const blaze = Blaze.getInstance();
await blaze.boot();
await blaze.run();
await blaze.cacheManager.saveCache();
}
export {
AbstractTask,
Task,
TaskAction,
TaskDependencyGenerator,
TaskInputGenerator,
TaskOutputGenerator,
files,
glob,
IO
};

await main();
export * from "./types/file";
export * from "./types/project";
export * from "./types/task";
export * from "./types/utils";
2 changes: 1 addition & 1 deletion blazebuild/src/main/typescript/project/ProjectManager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Manager from "../core/Manager";
import type { ProjectProperties } from "../exports";
import type { ProjectProperties } from "../types/project";

class ProjectManager extends Manager {
private _properties: Partial<ProjectProperties> = {
Expand Down
8 changes: 4 additions & 4 deletions blazew
Original file line number Diff line number Diff line change
Expand Up @@ -252,22 +252,21 @@ if [ "$node" == "node" ]; then
cmd="npm"
fi

file="$blaze_srcpath/build/out/main/typescript/index.js"
file="$blaze_srcpath/build/out/main/typescript/cli.js"
if [ ! -z "$has_bun" ] || [ $setup_done -eq 1 ] || [ -x "$bun" ]; then
cmd=$bun
has_bun=1
file="$blaze_srcpath/src/main/typescript/index.ts"
file="$blaze_srcpath/src/main/typescript/cli.ts"
fi

blaze_cmd() {
node_path=$(dirname "$node")
final_path=$(readlink -f $node_path)
final_path=$(readlink -f "$node_path")
wrapper=$(readlink -f "$projectdir/blaze/wrapper/blaze_wrapper.mjs")

if [ -z "$has_bun" ]; then
print "1;31" "error " "Bun not found. Please install Bun to use BlazeBuild."
exit 1
export PATH="$final_path":$PATH:"$final_path" && bash -c "exec -a \"$argv_0\" $node $wrapper $file --- $*"
else
export PATH="$final_path":$PATH:"$final_path" && bash -c "exec -a \"$argv_0\" $cmd $wrapper $file --- $*"
fi
Expand Down Expand Up @@ -318,4 +317,5 @@ if [ $argsetup -eq 1 ]; then
exit 0
fi

# shellcheck disable=SC2068
blaze_cmd $@
3 changes: 1 addition & 2 deletions build_src/src/main/typescript/tasks/RunTask.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { AbstractTask, Task, TaskAction } from "blazebuild";
import IO from "blazebuild/src/main/typescript/io/IO";
import { AbstractTask, Task, TaskAction, IO } from "blazebuild";
import { spawnSync } from "child_process";

@Task({
Expand Down

0 comments on commit f0ac5d5

Please sign in to comment.