- Add docker-compose.yml following trading web pattern - Update web Dockerfile to use multi-stage build with metadata - Add build metadata (commit SHA, branch, timestamp, author, message) - Rewrite deploy.sh to use docker compose with build metadata - Add hotcopy deployment script for quick updates - Add comprehensive backend API with deployment orchestration - Add health checks, service management, and monitoring endpoints - Add CI/CD workflow configuration - Add deployment documentation and guides Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
92 lines
2.5 KiB
JavaScript
92 lines
2.5 KiB
JavaScript
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const PACKAGE_SCOPE = '@bytelyst/';
|
|
const PACKAGE_SOURCE = process.env.BYTELYST_PACKAGE_SOURCE || 'common-plat';
|
|
const COMMON_PLAT_ROOT = process.env.BYTELYST_COMMON_PLAT_ROOT || path.resolve(__dirname, '..', 'learning_ai_common_plat');
|
|
const COMMON_PLAT_PACKAGES_ROOT = path.join(COMMON_PLAT_ROOT, 'packages');
|
|
const VERSION_CACHE = new Map();
|
|
let loggedSource = false;
|
|
|
|
function packageDirFor(name) {
|
|
return name.startsWith(PACKAGE_SCOPE) ? name.slice(PACKAGE_SCOPE.length) : null;
|
|
}
|
|
|
|
function pathIfPackageExists(rootDir, name) {
|
|
const packageDir = packageDirFor(name);
|
|
if (!packageDir) return null;
|
|
|
|
const candidate = path.join(rootDir, packageDir);
|
|
return fs.existsSync(path.join(candidate, 'package.json')) ? candidate : null;
|
|
}
|
|
|
|
function readPackageVersion(packagePath) {
|
|
if (VERSION_CACHE.has(packagePath)) {
|
|
return VERSION_CACHE.get(packagePath);
|
|
}
|
|
|
|
try {
|
|
const packageJson = JSON.parse(fs.readFileSync(path.join(packagePath, 'package.json'), 'utf8'));
|
|
const version = packageJson.version || null;
|
|
VERSION_CACHE.set(packagePath, version);
|
|
return version;
|
|
} catch {
|
|
VERSION_CACHE.set(packagePath, null);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
function resolveSpecifier(name) {
|
|
if (!name.startsWith(PACKAGE_SCOPE)) {
|
|
return null;
|
|
}
|
|
|
|
const commonPlatPath = pathIfPackageExists(COMMON_PLAT_PACKAGES_ROOT, name);
|
|
|
|
if (PACKAGE_SOURCE === 'common-plat') {
|
|
return commonPlatPath ? 'workspace:*' : null;
|
|
}
|
|
|
|
if (PACKAGE_SOURCE === 'gitea') {
|
|
return commonPlatPath ? readPackageVersion(commonPlatPath) : null;
|
|
}
|
|
|
|
return commonPlatPath ? 'workspace:*' : null;
|
|
}
|
|
|
|
function rewriteDependencySet(dependencies = {}) {
|
|
for (const dependencyName of Object.keys(dependencies)) {
|
|
const rewrittenSpecifier = resolveSpecifier(dependencyName);
|
|
if (rewrittenSpecifier) {
|
|
dependencies[dependencyName] = rewrittenSpecifier;
|
|
}
|
|
}
|
|
}
|
|
|
|
function logSourceOnce() {
|
|
if (loggedSource) {
|
|
return;
|
|
}
|
|
|
|
loggedSource = true;
|
|
process.stderr.write(
|
|
`[bytelyst] pnpm package source=${PACKAGE_SOURCE} commonPlatRoot=${COMMON_PLAT_ROOT}\n`,
|
|
);
|
|
}
|
|
|
|
module.exports = {
|
|
hooks: {
|
|
readPackage(packageJson) {
|
|
logSourceOnce();
|
|
if (packageJson.name?.startsWith(PACKAGE_SCOPE)) {
|
|
return packageJson;
|
|
}
|
|
|
|
rewriteDependencySet(packageJson.dependencies);
|
|
rewriteDependencySet(packageJson.devDependencies);
|
|
rewriteDependencySet(packageJson.optionalDependencies);
|
|
return packageJson;
|
|
},
|
|
},
|
|
};
|