mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
refactor(tools): support an explicit project directory
This commit is contained in:
1 parent
844c25212c
commit
6d5478ffa9
15 files changed
+169
-16
No files matched your search
@@ -1,7 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
SOURCE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
ROOT_DIR="$(cd "${GEV_PROJECT_ROOT:-$SOURCE_ROOT}" && pwd)"
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
PORT="${PORT:-4173}"
|
||||
@@ -75,7 +76,7 @@ read_dotenv_value() {
|
||||
echo "warning: node not found; cannot parse dotenv files" >&2
|
||||
return
|
||||
fi
|
||||
node scripts/read-dotenv-value.mjs "${variable_name}"
|
||||
node "$SOURCE_ROOT/scripts/read-dotenv-value.mjs" "${variable_name}"
|
||||
}
|
||||
|
||||
# Vite loads .env for browser build-time configuration, but this launcher needs
|
||||
@@ -240,12 +241,12 @@ CESIUM_ION_TOKEN="${CESIUM_ION_TOKEN:-$(read_keychain_secret "cesium-ion" "token
|
||||
TOMTOM_API_KEY="${TOMTOM_API_KEY:-$(read_keychain_secret "tomtom-api" "api-key")}"
|
||||
FIRMS_MAP_KEY="${FIRMS_MAP_KEY:-$(read_keychain_secret "firms-map" "map-key")}"
|
||||
|
||||
if [[ ! -f "src/data/cctv.js" ]]; then
|
||||
if [[ ! -f "$SOURCE_ROOT/src/data/cctv.js" ]]; then
|
||||
echo "error: expected CCTV layer file missing: src/data/cctv.js"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -q "dataManager.register(cctvLayer)" src/app/data.js; then
|
||||
if ! grep -q "dataManager.register(cctvLayer)" "$SOURCE_ROOT/src/app/data.js"; then
|
||||
echo "error: CCTV layer not wired in src/app/data.js"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
SOURCE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
ROOT_DIR="$(cd "${GEV_PROJECT_ROOT:-$SOURCE_ROOT}" && pwd)"
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
PORT="${PORT:-4173}"
|
||||
|
||||
@@ -553,5 +553,7 @@
|
||||
"src/app/data.js",
|
||||
"src/app/tools.js",
|
||||
"src/app/startupChrome.js",
|
||||
"src/app/errors.js"
|
||||
"src/app/errors.js",
|
||||
"scripts/project-root.mjs",
|
||||
"src/toolProjectRoot.test.mjs"
|
||||
]
|
||||
@@ -1,7 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
SOURCE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
ROOT_DIR="$(cd "${GEV_PROJECT_ROOT:-$SOURCE_ROOT}" && pwd)"
|
||||
cd "${ROOT_DIR}"
|
||||
|
||||
if ! command -v security >/dev/null 2>&1; then
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
/** Resolve the explicit CLI project directory, defaulting to the tool's repository. */
|
||||
export function projectRoot(moduleUrl, environment = process.env) {
|
||||
return path.resolve(
|
||||
environment.GEV_PROJECT_ROOT ||
|
||||
path.join(path.dirname(fileURLToPath(moduleUrl)), '..'),
|
||||
);
|
||||
}
|
||||
@@ -4,9 +4,10 @@ import { spawnSync } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
import { parseEnv } from 'node:util';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { projectRoot } from './project-root.mjs';
|
||||
import { selectMapStartupRoute } from '../src/mapStartup.js';
|
||||
|
||||
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const ROOT = projectRoot(import.meta.url);
|
||||
|
||||
export const CREDENTIALS = Object.freeze([
|
||||
{ name: 'GOOGLE_MAPS_API_KEY', label: 'Google Maps', keychain: [['google-maps-api', 'api-key'], ['google-maps-api', 'default'], ['google-maps-api', 'key']] },
|
||||
@@ -152,7 +153,7 @@ export function buildCapabilitySummary(credentials) {
|
||||
};
|
||||
}
|
||||
|
||||
export function inspectSetup({ includeKeychain = true, authoritativeEnvironment = false } = {}) {
|
||||
export function inspectSetup({ includeKeychain = true, authoritativeEnvironment = false, rootDir = ROOT } = {}) {
|
||||
const node = classifyNodeVersion();
|
||||
const npm = npmProcessSpec();
|
||||
const npmResult = spawnSync(npm.command, ['--version'], {
|
||||
@@ -161,9 +162,9 @@ export function inspectSetup({ includeKeychain = true, authoritativeEnvironment
|
||||
});
|
||||
const credentials = Object.fromEntries(CREDENTIALS.map((spec) => [
|
||||
spec.name,
|
||||
resolveCredential(spec, { includeKeychain, authoritativeEnvironment }),
|
||||
resolveCredential(spec, { includeKeychain, authoritativeEnvironment, rootDir }),
|
||||
]));
|
||||
const dependenciesInstalled = hasRequiredDependencies();
|
||||
const dependenciesInstalled = hasRequiredDependencies(rootDir);
|
||||
return {
|
||||
ready: node.level !== 'error' && npmResult.status === 0 && dependenciesInstalled,
|
||||
node: { version: process.versions.node, ...node },
|
||||
|
||||
Reference in new issue
Block a user