Skip to content
This repository has been archived by the owner on Jun 22, 2021. It is now read-only.

Commit

Permalink
Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
EvHaus committed May 11, 2020
1 parent 134b298 commit c993a73
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Rocketry.js
Expand Up @@ -135,14 +135,17 @@ class Rocketry {

await ensureTargetDirectoryExists(this.config, this.debug, this.server);
const sources = await getSources(this.config, this.debug, this.program);
console.log('starting zip');
const zipPath = await zipUpCurrentDirectory(sources, this.program);
console.log('finished zip, starting upload');
await uploadZipToServer({
config: this.config,
debug: this.debug,
localZipPath: zipPath,
program: this.program,
server: this.server,
});
console.log('finished upload');

await installNpmDependencies(this.config, this.debug, this.program, this.server);
await restartServices(this.program, this.config, this.debug, this.server);
Expand Down
10 changes: 10 additions & 0 deletions src/utils/server.js
Expand Up @@ -357,38 +357,48 @@ export const uploadZipToServer = async function ({
program: Command,
server: ServerType,
}) {
console.log('UPLOADING 1');
const spinner = ora(`Uploading ${chalk.yellow(localZipPath)} to server...`);
console.log('UPLOADING 2');
if (!program.debug) spinner.start();

const {target_dir} = config;
const target = `${target_dir}/rocketry.zip`;

try {
console.log('UPLOADING 3');
await server.putFile(localZipPath, target);
} catch (error) {
console.log('UPLOADING 4');
console.error(error);
spinner.fail(
`${chalk.red('[FAILURE]')} Failed to upload ZIP package to target server.`
);
throw error;
}

console.log('UPLOADING 5');
// Unzip the package once its on the server
spinner.text = (
`Deployment package uploaded to '${chalk.yellow(target)}'. Unzipping...`
);

try {
console.log('UPLOADING 6');
await serverRunMultiple([
`cd ${target_dir}`,
`unzip -ao ${target}`,
`rm -f rocketry.zip`,
], debug, server);
} catch (error) {
console.log('UPLOADING 7');
console.error(error);
spinner.fail(
`${chalk.red('[FAILURE]')} Failed to unzip uploaded package on the target server.`
);
throw error;
}

console.log('UPLOADING 8');
spinner.succeed('Package unzipped on the target server.');
};

0 comments on commit c993a73

Please sign in to comment.