@optimizely/ocp-cli 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ export declare class StatusCommand {
2
+ jobId: string;
3
+ private availability;
4
+ status(): Promise<void>;
5
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.StatusCommand = void 0;
10
+ const oo_cli_1 = require("oo-cli");
11
+ const chalk = require("chalk");
12
+ const die_1 = require("../../lib/die");
13
+ const formatTimstamp_1 = require("../../lib/formatTimstamp");
14
+ const jobRuntime_1 = require("../../lib/jobRuntime");
15
+ const formatJobStatus_1 = require("../../lib/formatJobStatus");
16
+ const formatError_1 = require("../../lib/formatError");
17
+ const Rivendell_1 = require("../../lib/Rivendell");
18
+ let StatusCommand = class StatusCommand {
19
+ constructor() {
20
+ this.availability = '';
21
+ }
22
+ async status() {
23
+ if (!this.jobId) {
24
+ return (0, die_1.die)('Job ID is required');
25
+ }
26
+ try {
27
+ const job = await Rivendell_1.Rivendell.fetchJob(this.jobId, this.availability);
28
+ if (!job) {
29
+ (0, die_1.die)(chalk.yellow(`No job found with id ${this.jobId}.`));
30
+ }
31
+ console.log(`\n${chalk.cyanBright('Id')}\t\t\t${job.id}`);
32
+ console.log(`${chalk.cyanBright('Version')}\t\t\t${job.definition.version}`);
33
+ console.log(`${chalk.cyanBright('Function')}\t\t${job.definition.function}`);
34
+ console.log(`${chalk.cyanBright('TrackerId')}\t\t${job.trackerId}`);
35
+ console.log(`${chalk.cyanBright('Status')}\t\t\t${(0, formatJobStatus_1.formatJobStatus)(job.status)}`);
36
+ console.log(`${chalk.cyanBright('Triggered At')}\t\t${job.triggeredAt}`);
37
+ if (job.completedAt) {
38
+ console.log(`${chalk.cyanBright('Completed At')}\t\t${job.completedAt}`);
39
+ }
40
+ else if (job.terminatedAt) {
41
+ console.log(`${chalk.cyanBright('Terminated At')}\t\t${job.terminatedAt}`);
42
+ }
43
+ console.log(`${chalk.cyanBright('Duration')}\t\t${(0, formatTimstamp_1.timestampToDurationString)((0, jobRuntime_1.jobRuntime)(job))}`);
44
+ }
45
+ catch (e) {
46
+ (0, die_1.die)((0, formatError_1.formatError)(e));
47
+ }
48
+ }
49
+ };
50
+ __decorate([
51
+ oo_cli_1.param,
52
+ oo_cli_1.optional,
53
+ (0, oo_cli_1.help)('The Job ID to look up')
54
+ ], StatusCommand.prototype, "jobId", void 0);
55
+ __decorate([
56
+ (0, oo_cli_1.option)('a'),
57
+ (0, oo_cli_1.help)('The availability zone that will be targeted (default: us)')
58
+ ], StatusCommand.prototype, "availability", void 0);
59
+ __decorate([
60
+ oo_cli_1.command,
61
+ (0, oo_cli_1.help)('Get the status of a particular job id')
62
+ ], StatusCommand.prototype, "status", null);
63
+ StatusCommand = __decorate([
64
+ (0, oo_cli_1.namespace)('jobs')
65
+ ], StatusCommand);
66
+ exports.StatusCommand = StatusCommand;
67
+ //# sourceMappingURL=Status.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Status.js","sourceRoot":"","sources":["../../../src/commands/jobs/Status.ts"],"names":[],"mappings":";;;;;;;;;AAAA,mCAAyE;AACzE,+BAA+B;AAC/B,uCAAkC;AAClC,6DAAmE;AACnE,qDAAkD;AAClD,+DAA0D;AAC1D,uDAAkD;AAClD,mDAA8C;AAGvC,IAAM,aAAa,GAAnB,MAAM,aAAa;IA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GAAG,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,OAAO,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;aAC1E;iBAAM,IAAI,GAAG,CAAC,YAAY,EAAE;gBAC3B,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,eAAe,CAAC,OAAO,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC;aAC5E;YAED,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,IAAA,0CAAyB,EAAC,IAAA,uBAAU,EAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;SAEnG;QAAC,OAAO,CAAM,EAAE;YACf,IAAA,SAAG,EAAC,IAAA,yBAAW,EAAC,CAAC,CAAC,CAAC,CAAC;SACrB;IACH,CAAC;CACF,CAAA;AApCC;IAHC,cAAK;IACL,iBAAQ;IACR,IAAA,aAAI,EAAC,uBAAuB,CAAC;4CACR;AAItB;IAFC,IAAA,eAAM,EAAC,GAAG,CAAC;IACX,IAAA,aAAI,EAAC,2DAA2D,CAAC;mDAChC;AAIrB;IAFZ,gBAAO;IACP,IAAA,aAAI,EAAC,uCAAuC,CAAC;2CA4B7C;AAvCU,aAAa;IADzB,IAAA,kBAAS,EAAC,MAAM,CAAC;GACL,aAAa,CAwCzB;AAxCY,sCAAa"}
@@ -1159,6 +1159,37 @@
1159
1159
  }
1160
1160
  ]
1161
1161
  },
1162
+ {
1163
+ "path": "commands/jobs/Status.js",
1164
+ "className": "StatusCommand",
1165
+ "key": "status",
1166
+ "command": "status",
1167
+ "aliases": [],
1168
+ "help": "Get the status of a particular job id",
1169
+ "documentation": "TBD",
1170
+ "flags": [],
1171
+ "options": [
1172
+ {
1173
+ "name": "availability",
1174
+ "key": "availability",
1175
+ "aliases": [
1176
+ "a"
1177
+ ],
1178
+ "help": "The availability zone that will be targeted (default: us)",
1179
+ "optional": true,
1180
+ "multiple": false
1181
+ }
1182
+ ],
1183
+ "params": [
1184
+ {
1185
+ "name": "jobId",
1186
+ "key": "jobId",
1187
+ "help": "The Job ID to look up",
1188
+ "optional": true,
1189
+ "multiple": false
1190
+ }
1191
+ ]
1192
+ },
1162
1193
  {
1163
1194
  "path": "commands/jobs/Terminate.js",
1164
1195
  "className": "TerminateCommand",
@@ -1293,7 +1324,7 @@
1293
1324
  },
1294
1325
  "commands": [],
1295
1326
  "package": {
1296
- "version": "1.1.2",
1327
+ "version": "1.1.4",
1297
1328
  "name": "@optimizely/ocp-cli",
1298
1329
  "license": "Apache-2.0",
1299
1330
  "executable": "ocp"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optimizely/ocp-cli",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "Optimizely Connect Platform command line interface",
5
5
  "repository": "https://github.com/ZaiusInc/ocp-cli",
6
6
  "license": "Apache-2.0",
@@ -0,0 +1,51 @@
1
+ import {command, help, namespace, option, optional, param} from 'oo-cli';
2
+ import * as chalk from 'chalk';
3
+ import {die} from '../../lib/die';
4
+ import {timestampToDurationString} from '../../lib/formatTimstamp';
5
+ import { jobRuntime } from '../../lib/jobRuntime';
6
+ import {formatJobStatus} from '../../lib/formatJobStatus';
7
+ import {formatError} from '../../lib/formatError';
8
+ import {Rivendell} from '../../lib/Rivendell';
9
+
10
+ @namespace('jobs')
11
+ export class StatusCommand {
12
+ @param
13
+ @optional
14
+ @help('The Job ID to look up')
15
+ public jobId!: string;
16
+
17
+ @option('a')
18
+ @help('The availability zone that will be targeted (default: us)')
19
+ private availability: string = '';
20
+
21
+ @command
22
+ @help('Get the status of a particular job id')
23
+ public async status() {
24
+ if (!this.jobId) {
25
+ return die('Job ID is required');
26
+ }
27
+
28
+ try {
29
+ const job = await Rivendell.fetchJob(this.jobId, this.availability);
30
+ if (!job) {
31
+ die(chalk.yellow(`No job found with id ${this.jobId}.`));
32
+ }
33
+ console.log(`\n${chalk.cyanBright('Id')}\t\t\t${job.id}`);
34
+ console.log(`${chalk.cyanBright('Version')}\t\t\t${job.definition.version}`);
35
+ console.log(`${chalk.cyanBright('Function')}\t\t${job.definition.function}`);
36
+ console.log(`${chalk.cyanBright('TrackerId')}\t\t${job.trackerId}`);
37
+ console.log(`${chalk.cyanBright('Status')}\t\t\t${formatJobStatus(job.status)}`);
38
+ console.log(`${chalk.cyanBright('Triggered At')}\t\t${job.triggeredAt}`);
39
+ if (job.completedAt) {
40
+ console.log(`${chalk.cyanBright('Completed At')}\t\t${job.completedAt}`);
41
+ } else if (job.terminatedAt) {
42
+ console.log(`${chalk.cyanBright('Terminated At')}\t\t${job.terminatedAt}`);
43
+ }
44
+
45
+ console.log(`${chalk.cyanBright('Duration')}\t\t${timestampToDurationString(jobRuntime(job))}`);
46
+
47
+ } catch (e: any) {
48
+ die(formatError(e));
49
+ }
50
+ }
51
+ }