Merge branch 'canary' into feat/stack-env-support

This commit is contained in:
Mauricio Siu
2025-01-30 23:39:54 -06:00
614 changed files with 71918 additions and 18508 deletions

View File

@@ -49,6 +49,7 @@ Compose Type: ${composeType} ✅`;
writeStream.write(`\n${logBox}\n`);
const projectPath = join(COMPOSE_PATH, compose.appName, "code");
await spawnAsync(
"docker",
[...command.split(" ")],
@@ -68,7 +69,7 @@ Compose Type: ${composeType} ✅`;
writeStream.write("Docker Compose Deployed: ✅");
} catch (error) {
writeStream.write("Error ❌");
writeStream.write(`Error ❌ ${(error as Error).message}`);
throw error;
} finally {
writeStream.end();
@@ -148,6 +149,10 @@ const sanitizeCommand = (command: string) => {
export const createCommand = (compose: ComposeNested) => {
const { composeType, appName, sourceType } = compose;
if (compose.command) {
return `${sanitizeCommand(compose.command)}`;
}
const path =
sourceType === "raw"
? composeType === "stack"
@@ -161,7 +166,6 @@ export const createCommand = (compose: ComposeNested) => {
composeType === "docker-compose"
? `compose -p ${appName} -f ${path} up -d --build --remove-orphans`
: `stack deploy -c ${path} ${appName} --prune`;
const customCommand = sanitizeCommand(compose.command);
return customCommand ? `${baseCommand} ${customCommand}` : baseCommand;
};

View File

@@ -27,7 +27,9 @@ export const unzipDrop = async (zipFile: File, application: Application) => {
const buffer = Buffer.from(arrayBuffer);
const zip = new AdmZip(buffer);
const zipEntries = zip.getEntries();
const zipEntries = zip
.getEntries()
.filter((entry) => !entry.entryName.startsWith("__MACOSX"));
const rootEntries = zipEntries.filter(
(entry) =>
@@ -59,14 +61,22 @@ export const unzipDrop = async (zipFile: File, application: Application) => {
if (!filePath) continue;
const fullPath = path.join(outputPath, filePath);
const fullPath = path.join(outputPath, filePath).replace(/\\/g, "/");
if (application.serverId) {
if (entry.isDirectory) {
await execAsyncRemote(application.serverId, `mkdir -p ${fullPath}`);
} else {
if (!entry.isDirectory) {
if (sftp === null) throw new Error("No SFTP connection available");
await uploadFileToServer(sftp, entry.getData(), fullPath);
try {
const dirPath = path.dirname(fullPath);
await execAsyncRemote(
application.serverId,
`mkdir -p "${dirPath}"`,
);
await uploadFileToServer(sftp, entry.getData(), fullPath);
} catch (err) {
console.error(`Error uploading file ${fullPath}:`, err);
throw err;
}
}
} else {
if (entry.isDirectory) {
@@ -103,7 +113,6 @@ const getSFTPConnection = async (serverId: string): Promise<SFTPWrapper> => {
port: server.port,
username: server.username,
privateKey: server.sshKey?.privateKey,
timeout: 99999,
});
});
};
@@ -115,7 +124,10 @@ const uploadFileToServer = (
): Promise<void> => {
return new Promise((resolve, reject) => {
sftp.writeFile(remotePath, data, (err) => {
if (err) return reject(err);
if (err) {
console.error(`SFTP write error for ${remotePath}:`, err);
return reject(err);
}
resolve();
});
});

View File

@@ -17,7 +17,6 @@ import { buildHeroku, getHerokuCommand } from "./heroku";
import { buildNixpacks, getNixpacksCommand } from "./nixpacks";
import { buildPaketo, getPaketoCommand } from "./paketo";
import { buildStatic, getStaticCommand } from "./static";
import { nanoid } from "nanoid";
// NIXPACKS codeDirectory = where is the path of the code directory
// HEROKU codeDirectory = where is the path of the code directory
@@ -211,21 +210,21 @@ const getImageName = (application: ApplicationNested) => {
}
if (registry) {
return join(registry.imagePrefix || "", appName);
return join(registry.registryUrl, registry.imagePrefix || "", appName);
}
return `${appName}:latest`;
};
const getAuthConfig = (application: ApplicationNested) => {
const { registry, username, password, sourceType } = application;
const { registry, username, password, sourceType, registryUrl } = application;
if (sourceType === "docker") {
if (username && password) {
return {
password,
username,
serveraddress: "https://index.docker.io/v1/",
serveraddress: registryUrl || "",
};
}
} else if (registry) {