@sasjs/cli 3.1.0 → 3.2.0

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.
@@ -3,6 +3,7 @@ import { AuthConfig, Target } from '@sasjs/utils';
3
3
  import { ReturnCode } from '../../types/command';
4
4
  import { TargetCommand } from '../../types/command/targetCommand';
5
5
  export declare class JobCommand extends TargetCommand {
6
+ private jobSubCommands;
6
7
  constructor(args: string[]);
7
8
  execute(): Promise<ReturnCode>;
8
9
  executeJobSasjs(sasjs: SASjs, target: Target): Promise<ReturnCode>;
@@ -66,6 +66,7 @@ var execute_1 = require("./internal/execute");
66
66
  var JobSubCommand;
67
67
  (function (JobSubCommand) {
68
68
  JobSubCommand["Execute"] = "execute";
69
+ JobSubCommand["Exec"] = "exec";
69
70
  })(JobSubCommand || (JobSubCommand = {}));
70
71
  var syntax = 'job <subCommand> <jobPath> [options]';
71
72
  var usage = 'sasjs job <execute> <jobPath> [options]';
@@ -123,8 +124,11 @@ var JobCommand = /** @class */ (function (_super) {
123
124
  __extends(JobCommand, _super);
124
125
  function JobCommand(args) {
125
126
  var _this = this;
127
+ var jobSubCommands = Object.values(JobSubCommand);
126
128
  var subCommand = args[3];
127
- var parseOptions = subCommand === JobSubCommand.Execute ? executeParseOptions : {};
129
+ var parseOptions = jobSubCommands.includes(subCommand)
130
+ ? executeParseOptions
131
+ : {};
128
132
  _this = _super.call(this, args, {
129
133
  parseOptions: parseOptions,
130
134
  usage: usage,
@@ -132,6 +136,7 @@ var JobCommand = /** @class */ (function (_super) {
132
136
  examples: examples,
133
137
  syntax: syntax
134
138
  }) || this;
139
+ _this.jobSubCommands = jobSubCommands;
135
140
  return _this;
136
141
  }
137
142
  JobCommand.prototype.execute = function () {
@@ -166,7 +171,7 @@ var JobCommand = /** @class */ (function (_super) {
166
171
  authConfig = _e.sent();
167
172
  if (!authConfig)
168
173
  return [2 /*return*/, command_1.ReturnCode.InternalError];
169
- if (!(this.parsed.subCommand === JobSubCommand.Execute)) return [3 /*break*/, 5];
174
+ if (!this.jobSubCommands.includes(this.parsed.subCommand)) return [3 /*break*/, 5];
170
175
  return [4 /*yield*/, this.executeJobViya(target, sasjs, authConfig)];
171
176
  case 4:
172
177
  _c = _e.sent();
@@ -182,7 +187,7 @@ var JobCommand = /** @class */ (function (_super) {
182
187
  });
183
188
  if (typeof this.parsed.jobPath !== 'string')
184
189
  return [2 /*return*/, command_1.ReturnCode.InvalidCommand];
185
- if (!(this.parsed.subCommand === JobSubCommand.Execute)) return [3 /*break*/, 9];
190
+ if (!this.jobSubCommands.includes(this.parsed.subCommand)) return [3 /*break*/, 9];
186
191
  return [4 /*yield*/, this.executeJobSasjs(sasjs, target)];
187
192
  case 8:
188
193
  _d = _e.sent();
@@ -362,17 +362,24 @@ var executeCalledWith = function (_a) {
362
362
  var executeCommandWrapper = function (additionalParams, checkTarget) {
363
363
  if (checkTarget === void 0) { checkTarget = true; }
364
364
  return __awaiter(void 0, void 0, void 0, function () {
365
- var args, command, returnCode, targetInfo;
365
+ var subCommand, args, command, returnCode, targetInfo;
366
366
  return __generator(this, function (_a) {
367
367
  switch (_a.label) {
368
368
  case 0:
369
- args = __spreadArray(__spreadArray([], __read(defaultArgs)), __read(additionalParams));
369
+ subCommand = 'execute';
370
+ args = __spreadArray(__spreadArray([], __read(defaultArgs)), __read(additionalParams)).map(function (arg) {
371
+ if (arg === 'execute') {
372
+ arg = Math.random() > 0.5 ? 'exec' : arg;
373
+ subCommand = arg;
374
+ }
375
+ return arg;
376
+ });
370
377
  command = new jobCommand_1.JobCommand(args);
371
378
  return [4 /*yield*/, command.execute()];
372
379
  case 1:
373
380
  returnCode = _a.sent();
374
381
  expect(command.name).toEqual('job');
375
- expect(command.subCommand).toEqual('execute');
382
+ expect(command.subCommand).toEqual(subCommand);
376
383
  if (!checkTarget) return [3 /*break*/, 3];
377
384
  return [4 /*yield*/, command.getTargetInfo()];
378
385
  case 2:
package/package.json CHANGED
@@ -97,5 +97,5 @@
97
97
  "typescript": "4.3.5",
98
98
  "util": "0.12.4"
99
99
  },
100
- "version": "3.1.0"
100
+ "version": "3.2.0"
101
101
  }