@sasjs/cli 3.20.0 → 3.20.1

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.
@@ -243,7 +243,8 @@ describe('sasjs compile', function () {
243
243
  newTarget = new utils_1.Target(__assign(__assign({}, target.toJson()), { serviceConfig: {
244
244
  serviceFolders: ['../services']
245
245
  } }));
246
- errorMessage = 'The following files were listed under SAS Programs but could not be found:\n' +
246
+ errorMessage = "Unable to load dependencies for: ".concat(path_1.default.join(__dirname, 'services/example.sas'), "\n") +
247
+ 'The following files were listed under SAS Includes but could not be found:\n' +
247
248
  "1. 'doesnotexist.sas' with fileRef 'SOMEREF'\n" +
248
249
  'Please check that they exist in the folder(s) listed in the `programFolders` array in your sasjsconfig.json file.\n' +
249
250
  'Program Folders:\n' +
@@ -86,23 +86,23 @@ var FsSubCommand;
86
86
  var syntax = 'fs <subCommand> [options]';
87
87
  var usage = 'Usage: sasjs fs <subCommand> [options]';
88
88
  // TODO: update
89
- var description = 'generate a SAS program that contains the contents of a local directory';
89
+ var description = 'Handles operations around file system synchronisation';
90
90
  var compileCommandSyntax = 'fs <subCommand> <localFolder> [options]';
91
91
  var compileCommandUsage = 'Usage: sasjs fs compile <localFolder> [options]';
92
- var compileCommandDescription = 'generate a SAS program that contains the contents of a local directory';
92
+ var compileCommandDescription = 'Compiles a SAS program with the contents of a local directory';
93
93
  var compileCommandExamples = [
94
94
  {
95
- command: 'sasjs fs compile <path/of/folder> <path/of/outputProgram>',
96
- description: 'generate a SAS program that contains the contents of a local directory'
95
+ command: 'sasjs fs compile <path/of/folder> --output <path/of/outputProgram>',
96
+ description: 'Compiles a SAS program with the contents of a local directory'
97
97
  }
98
98
  ];
99
99
  var syncCommandSyntax = 'fs <subCommand> <localFolder> <remoteFolder>';
100
100
  var syncCommandUsage = 'Usage: sasjs fs sync <localFolder> <remoteFolder>';
101
- var syncCommandDescription = 'generate a SAS program that will synchronize the remote folder with local';
101
+ var syncCommandDescription = 'Synchronise the remote SAS file system with the local project folder according to the target `syncDirectories` array';
102
102
  var syncCommandExamples = [
103
103
  {
104
104
  command: 'sasjs fs sync <path/of/folder> <path/of/remote/folder>',
105
- description: 'generate a SAS program that will synchronize the remote folder with local'
105
+ description: 'Synchronise the remote SAS file system with the local project folder according to the target `syncDirectories` array'
106
106
  }
107
107
  ];
108
108
  var parseOptions = {
@@ -246,6 +246,20 @@ function printHelpText() {
246
246
  "[2spaces]command example: sasjs folder move /Public/sourceFolder /Public/targetFolder --target targetName"
247
247
  ]
248
248
  },
249
+ {
250
+ name: 'fs',
251
+ title: 'fs <command>',
252
+ description: [
253
+ "Handles operations around file system synchronisation.",
254
+ "* ".concat(chalk_1.default.cyanBright('sync'), " - Synchronise the remote SAS file system with the local project folder according to the target 'syncDirectories' array."),
255
+ "[2spaces]command example: sasjs fs sync /Public/localFolder /Public/remoteFolder",
256
+ "",
257
+ "* ".concat(chalk_1.default.cyanBright('compile'), " - Compiles a SAS program with the contents of a local directory."),
258
+ "[2spaces]command example: sasjs fs compile /Public/folder --output ./outputProgram",
259
+ "",
260
+ "[2spaces]NOTE: If output flag (-o or --output) is not provided, output will be stored in './fs-compile/{timestamp}' directory relative to working directory."
261
+ ]
262
+ },
249
263
  {
250
264
  name: 'job',
251
265
  title: 'job <command>',
@@ -233,9 +233,15 @@ var JobCommand = /** @class */ (function (_super) {
233
233
  ? this.parsed.output
234
234
  : undefined;
235
235
  source = this.parsed.source;
236
- return [4 /*yield*/, (0, utils_2.getSASjsAndAuthConfig)(target)];
236
+ return [4 /*yield*/, (0, utils_2.getSASjsAndAuthConfig)(target).catch(function (err) {
237
+ var _a;
238
+ (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Unable to execute job. Error fetching auth config: ', err);
239
+ return { sasjs: (0, utils_2.getSASjs)(target), authConfigSas9: undefined };
240
+ })];
237
241
  case 1:
238
242
  _b = _c.sent(), sasjs = _b.sasjs, authConfigSas9 = _b.authConfigSas9;
243
+ if (!authConfigSas9)
244
+ return [2 /*return*/, command_1.ReturnCode.InternalError];
239
245
  userName = authConfigSas9.userName;
240
246
  password = (0, utils_1.decodeFromBase64)(authConfigSas9.password);
241
247
  return [4 /*yield*/, (0, execute_1.executeJobSas9)(sasjs, { userName: userName, password: password }, jobPath, log, output, source)
@@ -255,11 +261,11 @@ var JobCommand = /** @class */ (function (_super) {
255
261
  });
256
262
  };
257
263
  JobCommand.prototype.executeJobViya = function (target) {
258
- var _a, _b, _c, _d;
264
+ var _a, _b, _c;
259
265
  return __awaiter(this, void 0, void 0, function () {
260
- var jobPath, log, wait, output, statusFile, returnStatusOnly, ignoreWarnings, source, streamLog, _e, sasjs, authConfig, returnCode;
261
- return __generator(this, function (_f) {
262
- switch (_f.label) {
266
+ var jobPath, log, wait, output, statusFile, returnStatusOnly, ignoreWarnings, source, streamLog, _d, sasjs, authConfig, returnCode;
267
+ return __generator(this, function (_e) {
268
+ switch (_e.label) {
263
269
  case 0:
264
270
  jobPath = (0, prefixAppLoc_1.prefixAppLoc)(target.appLoc, this.parsed.jobPath);
265
271
  log = (0, getLogFilePath_1.getLogFilePath)(this.parsed.log, jobPath);
@@ -279,13 +285,15 @@ var JobCommand = /** @class */ (function (_super) {
279
285
  if (ignoreWarnings && !returnStatusOnly) {
280
286
  (_c = process.logger) === null || _c === void 0 ? void 0 : _c.warn("Using the 'ignoreWarnings' flag without 'returnStatusOnly' flag will not affect the sasjs job execute command.");
281
287
  }
282
- return [4 /*yield*/, (0, utils_2.getSASjsAndAuthConfig)(target)];
288
+ return [4 /*yield*/, (0, utils_2.getSASjsAndAuthConfig)(target).catch(function (err) {
289
+ var _a;
290
+ (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Unable to execute job. Error fetching auth config: ', err);
291
+ return { sasjs: (0, utils_2.getSASjs)(target), authConfig: undefined };
292
+ })];
283
293
  case 1:
284
- _e = _f.sent(), sasjs = _e.sasjs, authConfig = _e.authConfig;
285
- if (!authConfig) {
286
- (_d = process.logger) === null || _d === void 0 ? void 0 : _d.error('Unable to execute job. Error fetching auth config.');
294
+ _d = _e.sent(), sasjs = _d.sasjs, authConfig = _d.authConfig;
295
+ if (!authConfig)
287
296
  return [2 /*return*/, command_1.ReturnCode.InternalError];
288
- }
289
297
  return [4 /*yield*/, (0, execute_1.executeJobViya)(sasjs, authConfig, jobPath, target, wait, output, log, statusFile, returnStatusOnly, ignoreWarnings, source, streamLog)
290
298
  .then(function () {
291
299
  return command_1.ReturnCode.Success;
@@ -296,7 +304,7 @@ var JobCommand = /** @class */ (function (_super) {
296
304
  return command_1.ReturnCode.InternalError;
297
305
  })];
298
306
  case 2:
299
- returnCode = _f.sent();
307
+ returnCode = _e.sent();
300
308
  return [2 /*return*/, returnCode];
301
309
  }
302
310
  });
@@ -289,7 +289,7 @@ describe('JobCommand', function () {
289
289
  switch (_a.label) {
290
290
  case 0:
291
291
  jest
292
- .spyOn(configUtils, 'getAuthConfig')
292
+ .spyOn(configUtils, 'getSASjsAndAuthConfig')
293
293
  .mockImplementation(function () { return Promise.reject(new Error('Test Error')); });
294
294
  return [4 /*yield*/, executeCommandWrapper([jobPath])];
295
295
  case 1:
@@ -488,8 +488,13 @@ var setupMocksForViya = function () {
488
488
  return Promise.resolve({ target: targetViya, isLocal: true });
489
489
  });
490
490
  jest
491
- .spyOn(configUtils, 'getAuthConfig')
492
- .mockImplementation(function () { return Promise.resolve(authConfig); });
491
+ .spyOn(configUtils, 'getSASjsAndAuthConfig')
492
+ .mockImplementation(function (target) {
493
+ return Promise.resolve({
494
+ sasjs: configUtils.getSASjs(target),
495
+ authConfig: authConfig
496
+ });
497
+ });
493
498
  process.logger = new utils_1.Logger(utils_1.LogLevel.Off);
494
499
  jest.spyOn(process.logger, 'error');
495
500
  };
package/package.json CHANGED
@@ -8,6 +8,7 @@
8
8
  "scripts": {
9
9
  "nodeVersionMessage": "echo \u001b[33m make sure you are running node lts version \u001b[0m",
10
10
  "checkNodeVersion": "node -e \"console.log('\u001b[36m', 'Checking your Node.js version...'); if (!process.versions || !process.versions.node) { console.log('\u001b[31m', 'Error determining Node.js version. Exiting...') } if (parseInt(process.versions.node) < 14) { console.log('\u001b[31m', '❌ You must be running at least Node.js 14 to install SASjs CLI.\\nYour current version is ' + process.versions.node + '.\\nPlease install a more recent version and try again.'); process.exit(1); } else { console.log('\u001b[32m', '✅ Node.js version check passed. Continuing...'); } console.log('\u001b[0m', '');\"",
11
+ "start:ci": "npm run build && npm run set:permissions",
11
12
  "start": "nodemon --watch \"src/**/*\" --exec \"npm run build && npm run set:permissions\"",
12
13
  "set:permissions": "node -e \"require('fs').chmodSync('build/index.js', '755')\"",
13
14
  "build": "rimraf build && tsc -p . && npm run copy:files",
@@ -21,7 +22,7 @@
21
22
  "preinstall": "npm run nodeVersionMessage",
22
23
  "prepare": "git rev-parse --git-dir && git config core.hooksPath ./.git-hooks || true"
23
24
  },
24
- "testServerTypes": "viya,sas9,sasjs",
25
+ "testServerTypes": "sasjs,sas9",
25
26
  "release": {
26
27
  "branches": [
27
28
  "main"
@@ -50,8 +51,8 @@
50
51
  },
51
52
  "dependencies": {
52
53
  "@sasjs/adapter": "4.0.1",
53
- "@sasjs/core": "4.43.0",
54
- "@sasjs/lint": "1.12.0",
54
+ "@sasjs/core": "4.43.1",
55
+ "@sasjs/lint": "1.13.0",
55
56
  "@sasjs/utils": "2.49.2",
56
57
  "adm-zip": "0.5.9",
57
58
  "chalk": "4.1.2",
@@ -78,7 +79,7 @@
78
79
  "@types/adm-zip": "0.5.0",
79
80
  "@types/find": "0.2.1",
80
81
  "@types/jest": "27.0.2",
81
- "@types/jsdom": "16.2.13",
82
+ "@types/jsdom": "16.2.15",
82
83
  "@types/lodash.groupby": "4.6.6",
83
84
  "@types/lodash.uniqby": "4.7.6",
84
85
  "@types/node": "17.0.8",
@@ -98,5 +99,5 @@
98
99
  "typescript": "4.5.4",
99
100
  "util": "0.12.4"
100
101
  },
101
- "version": "3.20.0"
102
+ "version": "3.20.1"
102
103
  }