This repository has been archived by the owner on Mar 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.ts
76 lines (64 loc) · 1.99 KB
/
publish.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import BaseCommand from "../base-command";
import Login from './login';
import Test from "./test";
import publishApp, { isAppFailedToDeployError } from "../core/publish-app";
import { flags } from "@oclif/command";
import { packageApp, isAppFailedToPackageError } from '../core/package-app';
export default class Publish extends BaseCommand {
static description = "Packages and publishes your app to the dev server";
static examples = ["$ connect publish"];
// TODO: come up with a convention for turning off spinners if the user desires
// TODO: implement a quiet command?
static flags = {
help: flags.help({
char: "h",
description: "Show help for the publish command",
}),
"no-watch": flags.boolean({
char: "n",
description: "Does not track the status of the deployment",
}),
"skip-tests": flags.boolean({
char: "s",
description: "Skip running the test before publishing",
default: false,
}),
debug: flags.boolean({
char: "d",
description: "Show network debugging information",
default: false,
hidden: true
}),
};
async run(): Promise<void> {
// When the -h flag is present the following line haults execution
const { flags } = this.parse(Publish);
// Verify user is logged in
try {
await this.getCurrentUser(flags.debug);
} catch {
await Login.run([])
}
const apiClient = await this.apiClient(flags.debug)
// Run test in fail fast mode unless skipped
if (!flags["skip-tests"]) await Test.run(["-f"]);
try {
const tarballName = await packageApp();
await publishApp(tarballName, apiClient, {
noWatch: flags["no-watch"],
});
} catch (error) {
if (isAppFailedToPackageError(error)) {
return this.error(error.message, {
exit: 1,
});
}
if (isAppFailedToDeployError(error)) {
return this.error(error.message, {
exit: 1,
});
}
throw error;
}
}
}