Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"scripts": {
"prepare": "husky || true",
"build": "npm run build -w web-local",
"dev": "sh -c 'npm run dev-runtime & npm run dev-web -- --port 3001 & wait'",
"dev": "sh -c 'npm run dev-runtime -- \"$@\" & npm run dev-web -- --port 3001 & wait' --",
"dev-web": "npm run dev -w web-local -- ",
"dev-runtime": "go run cli/main.go start dev-project --no-ui --allowed-origins '*'",
"dev-runtime": "node scripts/dev.js",
"clean": "rm -rf dev-project",
"test": "npm run test -w web-common & PLAYWRIGHT_TEST=true make cli && npm run test -w web-local",
"local-test": "cd web-local && npx playwright test --headed --project=e2e-chrome -g",
Expand Down
54 changes: 54 additions & 0 deletions scripts/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env node

import path from "node:path";
import fs from "node:fs";
import { spawn } from "node:child_process";

const projectArg = process.argv[2]?.toLowerCase();

const DEFAULT_PROJECT = "dev-project";
const testLocation = path.resolve("./web-common/tests/projects");

/** @type {Record<string, string>} */
const projectPaths = {
adbids: path.join(testLocation, "AdBids"),
openrtb: path.join(testLocation, "openrtb"),
adimpressions: path.join(testLocation, "AdImpressions"),
blank: path.join(testLocation, "Blank"),
};

/** @type {string} */
let projectDir;

if (!projectArg) {
projectDir = DEFAULT_PROJECT;
} else if (projectPaths[projectArg]) {
projectDir = projectPaths[projectArg];
} else {
const resolvedPath = path.resolve(projectArg);

if (!fs.existsSync(resolvedPath)) {
console.error("Unknown project or invalid path:", projectArg);
console.error("Valid options: adbids | openrtb | adimpressions | blank | <path>");
process.exit(1);
}

projectDir = resolvedPath;
}

console.log("Starting runtime");
console.log(`Using project dir: ${projectDir}`);

const child = spawn(
"go",
["run", "cli/main.go", "start", projectDir, "--no-ui", "--allowed-origins", "*"],
{ stdio: "inherit" }
);

child.on("exit", (code, signal) => {
if (signal) {
process.kill(process.pid, signal);
} else {
process.exit(code ?? 1);
}
});
8 changes: 7 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,11 @@
},
"outDir": "dist"
},
"include": ["**/*.d.ts", "**/*.ts", "**/*.svelte", "**/rollup.config.js"]
"include": [
"**/*.d.ts",
"**/*.ts",
"**/*.svelte",
"**/rollup.config.js",
"scripts/**.js"
]
}
Loading