Skip to content

Commit

Permalink
fix(cli): restore support for ARCHIVE argument (#896)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwcz authored Nov 5, 2020
1 parent e5f6b9e commit 763f4a0
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 27 deletions.
6 changes: 3 additions & 3 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $ npm install -g @spaship/cli
$ spaship COMMAND
running command...
$ spaship (-v|--version|version)
@spaship/cli/0.12.0 linux-x64 node-v12.18.3
@spaship/cli/0.13.0 linux-x64 node-v12.18.3
$ spaship --help [COMMAND]
USAGE
$ spaship COMMAND
Expand Down Expand Up @@ -70,7 +70,7 @@ EXAMPLES
$ spaship deploy # deploying a buildDir directory
```

_See code: [src/commands/deploy.js](https://github.com/spaship/spaship/blob/v0.12.0/src/commands/deploy.js)_
_See code: [src/commands/deploy.js](https://github.com/spaship/spaship/blob/v0.13.0/src/commands/deploy.js)_

## `spaship help [COMMAND]`

Expand Down Expand Up @@ -108,7 +108,7 @@ DESCRIPTION
passed in as CLI options.
```

_See code: [src/commands/init.js](https://github.com/spaship/spaship/blob/v0.12.0/src/commands/init.js)_
_See code: [src/commands/init.js](https://github.com/spaship/spaship/blob/v0.13.0/src/commands/init.js)_

<!-- commandsstop -->

Expand Down
145 changes: 139 additions & 6 deletions packages/cli/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 17 additions & 15 deletions packages/cli/src/commands/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,24 @@ class DeployCommand extends Command {
this.error(`An API key must be provided, either in your spashiprc file or in a --apikey option.`);
}

if (!args.archive && buildDir) {
// No archive path specified in the commandline as argument and buildDir is specified in the spaship.yaml
const buildDirPath = nodePath.join(process.cwd(), buildDir);
const rawSpashipYml = await common.config.readRaw("spaship.yaml");
this.log("Creating a zip archive...");
try {
args.archive = await zipDirectory(buildDirPath, rawSpashipYml);
this.log("Done creating the archive...");
} catch (e) {
this.error(e);
if (!args.archive) {
if (buildDir) {
// No archive path specified in the commandline as argument and buildDir is specified in the spaship.yaml
const buildDirPath = nodePath.join(process.cwd(), buildDir);
const rawSpashipYml = await common.config.readRaw("spaship.yaml");
this.log("Creating a zip archive...");
try {
args.archive = await zipDirectory(buildDirPath, rawSpashipYml);
this.log("Done creating the archive...");
} catch (e) {
this.error(e);
}
} else {
// No buildDir is specified in the spaship.yaml
this.error(
"You should specify the build artifact path as `buildDir` in the spaship.yaml to run `spaship deploy` without the archive path."
);
}
} else {
// No buildDir is specified in the spaship.yaml
this.error(
"You should specify the build artifact path as `buildDir` in the spaship.yaml to run `spaship deploy` without the archive path."
);
}
const spinner = ora(`Start deploying SPA`);
this.log(`Deploying SPA to ${flags.env}${envIsURL ? "" : ` (${host})`}`);
Expand Down
10 changes: 7 additions & 3 deletions packages/cli/src/services/deployService.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ const upload = (url, data, apiKey, onUploadProgress) => {
const options = {
method: "POST",
rejectUnauthorized: false,
ciphers: "ALL",
secureProtocol: "TLSv1_1_method",
agentOptions: {
ciphers: "ALL",
secureProtocol: "TLSv1_1_method",
},
headers: Object.assign({}, defaultHeaders, data.getHeaders()),
};

Expand Down Expand Up @@ -63,7 +65,9 @@ const upload = (url, data, apiKey, onUploadProgress) => {
} else if (res.statusCode >= 500 && res.statusCode < 600) {
switch (res.statusCode) {
case 500:
reject(`Error: The SPAship server has encountered a mysterious problem; someone call Richard Feynman! [500]`);
reject(
`Error: The SPAship server has encountered a mysterious problem; someone call Richard Feynman! [500]`
);
break;
case 501:
reject(
Expand Down

0 comments on commit 763f4a0

Please sign in to comment.