Skip to content
Open
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
26 changes: 19 additions & 7 deletions src/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,28 @@ export const deleteBySelection = async (api: APIInterface): Promise<void> => {
'Select the deployment to delete:'
);

const app = deployments.filter(
dep =>
dep.suffix === project.split(' ')[0] &&
dep.version === project.split(' ')[1]
)[0];
// Parse the selected project string
const parts = project.split(' ');
const selectedSuffix = parts[0];
const selectedVersion = parts[1];

if (!selectedSuffix || !selectedVersion) {
error('Invalid deployment selection format');
}

// Find the matching deployment
const app = deployments.find(
dep => dep.suffix === selectedSuffix && dep.version === selectedVersion
);

if (!app) {
error(
'Selected deployment not found. It may have been deleted already.'
);
}

info(await del(app.prefix, app.suffix, app.version, api));
} catch (err) {
error(String(err));
}
};

// This can be better
11 changes: 9 additions & 2 deletions src/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,19 @@ const showLogs = async (

let logsTill: string[] = [''];

let app: Deployment;
let app: Deployment | undefined;
let status: DeployStatus = 'create';

while (status !== 'ready') {
app = (await api.inspect()).filter(dep => dep.suffix === suffix)[0];
const deployments = (await api.inspect()).filter(
dep => dep.suffix === suffix
);

if (deployments.length === 0) {
error(`Deployment with suffix "${suffix}" not found`);
}

app = deployments[0];
status = app.status;
const prefix = app.prefix;

Expand Down