🚀 Add functionality to transfer backend server files and directories during deployment
This commit is contained in:
@@ -361,11 +361,60 @@ async function deploy() {
|
|||||||
}
|
}
|
||||||
console.log(` ✅ Transferred ${transferred} files from dist/`);
|
console.log(` ✅ Transferred ${transferred} files from dist/`);
|
||||||
|
|
||||||
|
// Transfer backend server files
|
||||||
|
console.log(' 📦 Transferring backend server files...');
|
||||||
|
const serverDir = path.join(SOURCE_DIR, 'server');
|
||||||
|
await ssh.execCommand(`mkdir -p ${REMOTE_PATH}/server`);
|
||||||
|
|
||||||
|
// Transfer server package files
|
||||||
|
const serverFiles = [
|
||||||
|
'package.json',
|
||||||
|
'oauth-proxy.js',
|
||||||
|
'gamemaster-api.js',
|
||||||
|
'.env.example'
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const file of serverFiles) {
|
||||||
|
const localPath = path.join(serverDir, file);
|
||||||
|
const remotePath = `${REMOTE_PATH}/server/${file}`;
|
||||||
|
if (fs.existsSync(localPath)) {
|
||||||
|
await ssh.putFile(localPath, remotePath);
|
||||||
|
console.log(` ✅ server/${file}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transfer server subdirectories
|
||||||
|
const serverDirs = ['middleware', 'routes', 'utils', 'data'];
|
||||||
|
for (const dir of serverDirs) {
|
||||||
|
const localDir = path.join(serverDir, dir);
|
||||||
|
if (fs.existsSync(localDir)) {
|
||||||
|
await ssh.execCommand(`mkdir -p ${REMOTE_PATH}/server/${dir}`);
|
||||||
|
const files = fs.readdirSync(localDir, { withFileTypes: true });
|
||||||
|
for (const file of files) {
|
||||||
|
if (file.isFile()) {
|
||||||
|
const localFile = path.join(localDir, file.name);
|
||||||
|
const remoteFile = `${REMOTE_PATH}/server/${dir}/${file.name}`;
|
||||||
|
await ssh.putFile(localFile, remoteFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(` ✅ server/${dir}/ (${files.length} files)`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(` ✅ Backend files transferred`);
|
||||||
|
|
||||||
// Now transfer config files
|
// Now transfer config files
|
||||||
const filesToTransfer = [
|
const filesToTransfer = [
|
||||||
{
|
{
|
||||||
local: path.join(SOURCE_DIR, 'Dockerfile'),
|
local: path.join(SOURCE_DIR, 'Dockerfile.frontend'),
|
||||||
remote: `${REMOTE_PATH}/Dockerfile`
|
remote: `${REMOTE_PATH}/Dockerfile.frontend`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
local: path.join(SOURCE_DIR, 'server', 'Dockerfile'),
|
||||||
|
remote: `${REMOTE_PATH}/server/Dockerfile`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
local: path.join(SOURCE_DIR, 'nginx.conf'),
|
||||||
|
remote: `${REMOTE_PATH}/nginx.conf`
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
local: tempDockerComposePath,
|
local: tempDockerComposePath,
|
||||||
|
|||||||
Reference in New Issue
Block a user