Skip to content

Commit 10aa1db

Browse files
Merge pull request #909 from appwrite/fix-cli-qa
Fix cli qa
2 parents 279bc6d + 8475292 commit 10aa1db

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

templates/cli/lib/commands/generic.js.twig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ const logout = new Command("logout")
188188
const sessions = globalConfig.getSessions();
189189
const current = globalConfig.getCurrentSession();
190190

191-
if (current === '') {
191+
if (current === '' || !sessions.length) {
192+
log('No active sessions found.');
192193
return;
193194
}
194195
if (sessions.length === 1) {

templates/cli/lib/commands/pull.js.twig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const pullResources = async () => {
2727
if (cliConfig.all) {
2828
for (let action of Object.values(actions)) {
2929
cliConfig.all = true;
30-
await action();
30+
await action({});
3131
}
3232
} else {
3333
const answers = await inquirer.prompt(questionsPullResources[0]);
@@ -92,7 +92,7 @@ const pullFunctions = async ({ code }) => {
9292
if (!fs.existsSync(func['path'])) {
9393
fs.mkdirSync(func['path'], { recursive: true });
9494
}
95-
95+
9696
if(code === false) {
9797
warn("Source code download skipped.");
9898
} else if(!func['deployment']) {
@@ -114,14 +114,14 @@ const pullFunctions = async ({ code }) => {
114114
overrideForCli: true,
115115
parseOutput: false
116116
});
117-
117+
118118
tar.extract({
119119
sync: true,
120120
cwd: func['path'],
121121
file: compressedFileName,
122122
strict: false,
123123
});
124-
124+
125125
fs.rmSync(compressedFileName);
126126
}
127127
}

templates/cli/lib/commands/push.js.twig

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ const pushResources = async () => {
750750
};
751751

752752
const pushSettings = async () => {
753+
checkDeployConditions(localConfig);
754+
753755
try {
754756
log("Pushing project settings ...");
755757

@@ -810,8 +812,6 @@ const pushSettings = async () => {
810812
}
811813

812814
const pushFunction = async ({ functionId, async, returnOnZero } = { returnOnZero: false }) => {
813-
let response = {};
814-
815815
const functionIds = [];
816816

817817
if (functionId) {
@@ -865,14 +865,15 @@ const pushFunction = async ({ functionId, async, returnOnZero } = { returnOnZero
865865
const failedDeployments = [];
866866

867867
await Promise.all(functions.map(async (func) => {
868+
let response = {};
869+
868870
const ignore = func.ignore ? 'appwrite.json' : '.gitignore';
869871
let functionExists = false;
870872
let deploymentCreated = false;
871873

872874
const updaterRow = new Spinner({ status: '', resource: func.name, id: func['$id'], end: `Ignoring using: ${ignore}` });
873875

874876
updaterRow.update({ status: 'Getting' }).startSpinner(SPINNER_DOTS);
875-
876877
try {
877878
response = await functionsGet({
878879
functionId: func['$id'],
@@ -974,11 +975,6 @@ const pushFunction = async ({ functionId, async, returnOnZero } = { returnOnZero
974975
let pollChecks = 0;
975976

976977
while (true) {
977-
if (pollChecks >= POLL_MAX_DEBOUNCE) {
978-
updaterRow.update({ end: 'Deployment is taking too long. Please check the console for more details.' })
979-
break;
980-
}
981-
982978
response = await functionsGetDeployment({
983979
functionId: func['$id'],
984980
deploymentId: deploymentId,
@@ -1017,7 +1013,7 @@ const pushFunction = async ({ functionId, async, returnOnZero } = { returnOnZero
10171013
}
10181014

10191015
pollChecks++;
1020-
await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE));
1016+
await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE * 1.5));
10211017
}
10221018
} catch (e) {
10231019
updaterRow.fail({ errorMessage: e.message ?? 'Unknown error occurred. Please try again' })
@@ -1031,7 +1027,7 @@ const pushFunction = async ({ functionId, async, returnOnZero } = { returnOnZero
10311027

10321028
failedDeployments.forEach((failed) => {
10331029
const { name, deployment, $id } = failed;
1034-
const failUrl = `${globalConfig.getEndpoint().replace('/v1', '')}/console/project-${localConfig.getProject().projectId}/functions/function-${$id}/deployment-${deployment}`;
1030+
const failUrl = `${globalConfig.getEndpoint().slice(0, -3)}/console/project-${localConfig.getProject().projectId}/functions/function-${$id}/deployment-${deployment}`;
10351031

10361032
error(`Deployment of ${name} has failed. Check at ${failUrl} for more details\n`);
10371033
});

templates/cli/lib/spinner.js.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class Spinner {
2222
hideCursor,
2323
clearOnComplete,
2424
stopOnComplete: true,
25+
linewrap: true,
2526
noTTYOutput: true
2627
});
2728
}

0 commit comments

Comments
 (0)