@sasjs/cli 3.6.6 → 3.7.5

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,30 @@
1
+ # Change Log
2
+
3
+ Since March 7th, 2020, the changelog is managed by github releases. See [https://github.com/sasjs/cli/releases](https://github.com/sasjs/cli/releases).
4
+
5
+ ## Changes Prior to March 7th 2020
6
+
7
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
8
+
9
+ <a name="1.0.4"></a>
10
+ ## [1.0.4](https://gitlab.com/macropeople/sasjs-cli/compare/v1.0.3...v1.0.4) (2020-03-07)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * redo comment stripping logic ([84a1a91](https://gitlab.com/macropeople/sasjs-cli/commit/84a1a91))
16
+
17
+
18
+
19
+ <a name="1.0.3"></a>
20
+ ## [1.0.3](https://gitlab.com/macropeople/sasjs-cli/compare/v1.0.2...v1.0.3) (2020-03-07)
21
+
22
+
23
+
24
+ <a name="1.0.2"></a>
25
+ ## [1.0.2](https://gitlab.com/macropeople/sasjs-cli/compare/v1.0.1...v1.0.2) (2020-03-07)
26
+
27
+
28
+
29
+ <a name="1.0.1"></a>
30
+ ## 1.0.1 (2020-03-07)
package/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # SASjs CLI
2
+
2
3
  [![npm package][npm-image]][npm-url]
3
4
  [![Github Workflow][githubworkflow-image]][githubworkflow-url]
4
5
  [![npm](https://img.shields.io/npm/dt/@sasjs/cli)]()
@@ -9,15 +10,14 @@
9
10
  [![GitHub issues](https://img.shields.io/github/issues-raw/sasjs/cli)](https://github.com/sasjs/cli/issues)
10
11
  [![Gitpod ready-to-code](https://img.shields.io/badge/Gitpod-ready--to--code-908a85?logo=gitpod)](https://gitpod.io/#https://github.com/sasjs/cli)
11
12
 
12
-
13
- [npm-image]:https://img.shields.io/npm/v/@sasjs/cli.svg
14
- [npm-url]:http://npmjs.org/package/@sasjs/cli
15
- [githubworkflow-image]:https://github.com/sasjs/cli/actions/workflows/run-tests.yml/badge.svg
16
- [githubworkflow-url]:https://github.com/sasjs/cli/blob/main/.github/workflows/run-tests.yml
13
+ [npm-image]: https://img.shields.io/npm/v/@sasjs/cli.svg
14
+ [npm-url]: http://npmjs.org/package/@sasjs/cli
15
+ [githubworkflow-image]: https://github.com/sasjs/cli/actions/workflows/run-tests.yml/badge.svg
16
+ [githubworkflow-url]: https://github.com/sasjs/cli/blob/main/.github/workflows/run-tests.yml
17
17
 
18
18
  `@sasjs/cli` is a Command-Line Interface to assist with creating, building, and deploying Data Science projects and HTML5 Web Applications on the SAS platform (both SAS 9 and Viya). Features include:
19
19
 
20
- - Scaffold a new SAS App in seconds (`sasjs create myApp -t jobs`)
20
+ - Scaffold a new SAS App in seconds (`sasjs create myApp -t jobs`)
21
21
  - Compile / Build SAS Jobs, Services & Macros _locally_ and deploy / execute _remotely_, in isolation from other developers (`sasjs cbd`)
22
22
  - No dependency on the server filesystem
23
23
  - Trigger Viya Jobs & Flows (`sasjs job execute` / `sasjs flow execute`)
@@ -40,19 +40,18 @@ A quick demonstration of using it to compile, build and deploy a set of SAS Viya
40
40
  ```
41
41
 
42
42
  You can also use the tool without deploying through NPX as follows:
43
+
43
44
  ```
44
45
  npx @sasjs/cli <command>
45
46
  ```
46
47
 
47
48
  ## Documentation
48
49
 
49
-
50
- Additional documentation can be found on the [SASjs CLI documentation](https://cli.sasjs.io) site.
51
-
50
+ Additional documentation can be found on the [SASjs CLI documentation](https://cli.sasjs.io) site.
52
51
 
53
52
  ## Notes
54
53
 
55
- Running `npm i -g @sasjs/cli@latest` does not always upgrade properly. This is due to a known bug in npm, which is fixed in npm 7.
54
+ Running `npm i -g @sasjs/cli@latest` does not always upgrade properly. This is due to a known bug in npm, which is fixed in npm 7.
56
55
 
57
56
  If you are running NPM in version 6 or below, you can try running `npm update -g @sasjs/cli` instead, or - the sledgehammer approach - delete the files from the NPM folder and then do a fresh install.
58
57
 
@@ -62,7 +61,6 @@ If you find this library useful, please leave a star and help us grow our star g
62
61
 
63
62
  ![](https://starchart.cc/sasjs/cli.svg)
64
63
 
65
-
66
64
  ## Contributors ✨
67
65
 
68
66
  Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
@@ -294,23 +294,21 @@ function getCreateFileScript(serverType) {
294
294
  });
295
295
  });
296
296
  }
297
- function getWebServiceScriptInvocation(serverType, filePath, isSASFile, encoded) {
298
- if (filePath === void 0) { filePath = ''; }
297
+ function getWebServiceScriptInvocation(serverType, isSASFile, encoded) {
299
298
  if (isSASFile === void 0) { isSASFile = true; }
300
299
  if (encoded === void 0) { encoded = false; }
301
- var loc = filePath === '' ? 'services' : 'tests';
302
300
  var encodedParam = encoded ? ', intype=BASE64' : '';
303
301
  switch (serverType) {
304
302
  case utils_1.ServerType.SasViya:
305
303
  return isSASFile
306
- ? "%mv_createwebservice(path=&appLoc/".concat(loc, "/&path, name=&service, code=sascode ,replace=yes)")
307
- : "%mv_createfile(path=&appLoc/".concat(loc, "/&path, name=&filename, inref=filecode").concat(encodedParam, ")");
304
+ ? "%mv_createwebservice(path=&appLoc/&path, name=&service, code=sascode ,replace=yes)"
305
+ : "%mv_createfile(path=&appLoc/&path, name=&filename, inref=filecode".concat(encodedParam, ")");
308
306
  case utils_1.ServerType.Sas9:
309
- return "%mm_createwebservice(path=&appLoc/".concat(loc, "/&path, name=&service, code=sascode ,replace=yes)");
307
+ return "%mm_createwebservice(path=&appLoc/&path, name=&service, code=sascode ,replace=yes)";
310
308
  case utils_1.ServerType.Sasjs:
311
309
  return isSASFile
312
- ? "%mv_createwebservice(path=&appLoc/".concat(loc, "/&path, name=&service, code=sascode ,replace=yes)")
313
- : "%mv_createfile(path=&appLoc/".concat(loc, "/&path, name=&filename, inref=filecode").concat(encodedParam, ")");
310
+ ? "%mv_createwebservice(path=&appLoc/&path, name=&service, code=sascode ,replace=yes)"
311
+ : "%mv_createfile(path=&appLoc/&path, name=&filename, inref=filecode".concat(encodedParam, ")");
314
312
  default:
315
313
  throw new error_1.ServerTypeError();
316
314
  }
@@ -340,7 +338,7 @@ function getFolderContent(serverType) {
340
338
  var _a, content, contentJSON;
341
339
  return __generator(this, function (_b) {
342
340
  switch (_b.label) {
343
- case 0: return [4 /*yield*/, getContentFor(path_1.default.join(buildDestinationFolder, subFolder), path_1.default.join(buildDestinationFolder, subFolder), serverType)];
341
+ case 0: return [4 /*yield*/, getContentFor(buildDestinationFolder, path_1.default.join(buildDestinationFolder, subFolder), serverType)];
344
342
  case 1:
345
343
  _a = _b.sent(), content = _a.content, contentJSON = _a.contentJSON;
346
344
  folderContent += "\n".concat(content);
@@ -383,28 +381,19 @@ function getDependencies(filePaths) {
383
381
  });
384
382
  });
385
383
  }
386
- function getContentFor(rootDirectory, folderPath, serverType, testPath) {
387
- if (testPath === void 0) { testPath = undefined; }
384
+ function getContentFor(rootDirectory, folderPath, serverType) {
388
385
  return __awaiter(this, void 0, void 0, function () {
389
- var folderName, isRootDir, content, contentJSON, files, subFolders;
386
+ var folderName, content, contentJSON, files, subFolders;
390
387
  var _this = this;
391
388
  return __generator(this, function (_a) {
392
389
  switch (_a.label) {
393
390
  case 0:
394
391
  folderName = path_1.default.basename(folderPath);
395
- if (!testPath && folderName === 'tests') {
396
- testPath = '';
397
- }
398
- isRootDir = folderPath === rootDirectory;
399
- content = "\n%let path=".concat(isRootDir
400
- ? ''
401
- : testPath !== undefined
402
- ? testPath
403
- : folderPath
404
- .replace(rootDirectory, '')
405
- .substr(1)
406
- .split(path_1.default.sep)
407
- .join('/'), ";\n");
392
+ content = "\n%let path=".concat(folderPath
393
+ .replace(rootDirectory, '')
394
+ .substr(1)
395
+ .split(path_1.default.sep)
396
+ .join('/'), ";\n");
408
397
  contentJSON = {
409
398
  name: folderName,
410
399
  type: 'folder',
@@ -423,7 +412,7 @@ function getContentFor(rootDirectory, folderPath, serverType, testPath) {
423
412
  return [4 /*yield*/, (0, utils_1.readFile)(filePath)];
424
413
  case 1:
425
414
  fileContent = _a.sent();
426
- transformedContent = getServiceText(file, fileContent, serverType, testPath);
415
+ transformedContent = getServiceText(file, fileContent, serverType);
427
416
  content += "\n".concat(transformedContent, "\n");
428
417
  contentJSON.members.push({
429
418
  name: file.replace(/.sas$/, ''),
@@ -455,11 +444,7 @@ function getContentFor(rootDirectory, folderPath, serverType, testPath) {
455
444
  var _a, childContent, childContentJSON;
456
445
  return __generator(this, function (_b) {
457
446
  switch (_b.label) {
458
- case 0: return [4 /*yield*/, getContentFor(rootDirectory, path_1.default.join(folderPath, subFolder), serverType, testPath !== undefined
459
- ? testPath === ''
460
- ? subFolder
461
- : "".concat(testPath, "/").concat(subFolder)
462
- : undefined)];
447
+ case 0: return [4 /*yield*/, getContentFor(rootDirectory, path_1.default.join(folderPath, subFolder), serverType)];
463
448
  case 1:
464
449
  _a = _b.sent(), childContent = _a.content, childContentJSON = _a.contentJSON;
465
450
  contentJSON.members.push(childContentJSON);
@@ -475,7 +460,7 @@ function getContentFor(rootDirectory, folderPath, serverType, testPath) {
475
460
  });
476
461
  });
477
462
  }
478
- function getServiceText(serviceFileName, fileContent, serverType, testPath) {
463
+ function getServiceText(serviceFileName, fileContent, serverType) {
479
464
  var serviceName = serviceFileName.replace(/.sas$/, '');
480
465
  var sourceCodeLines = getLines((0, utils_2.removeComments)(fileContent));
481
466
  var content = "";
@@ -486,14 +471,14 @@ function getServiceText(serviceFileName, fileContent, serverType, testPath) {
486
471
  }
487
472
  });
488
473
  return "%let service=".concat(serviceName, ";\nfilename sascode temp lrecl=32767;\ndata _null_;\nfile sascode;\n").concat(content, "\n\nrun;\n").concat(serverType !== utils_1.ServerType.Sasjs
489
- ? getWebServiceScriptInvocation(serverType, (0, utils_1.isTestFile)(serviceFileName) && testPath ? "".concat(testPath) : '')
474
+ ? getWebServiceScriptInvocation(serverType)
490
475
  : '', "\nfilename sascode clear;\n");
491
476
  }
492
477
  function getFileText(fileName, fileContent, serverType) {
493
478
  var fileExtension = path_1.default.extname(fileName).substring(1).toUpperCase();
494
479
  var _a = getWebFileContent(fileContent, fileExtension), content = _a.content, maxLineLength = _a.maxLineLength;
495
480
  return "%let filename=".concat(fileName, ";\nfilename filecode temp lrecl=").concat(maxLineLength, ";\ndata _null_;\nfile filecode;\n").concat(content, "\n\nrun;\n").concat(serverType !== utils_1.ServerType.Sasjs
496
- ? getWebServiceScriptInvocation(serverType, undefined, false, true)
481
+ ? getWebServiceScriptInvocation(serverType, false, true)
497
482
  : '', "\nfilename filecode clear;\n");
498
483
  }
499
484
  function getWebFileContent(filecontent, type) {
@@ -90,7 +90,7 @@ function deploy(target, isLocal, sasjs) {
90
90
  buildDestinationFolder = process.sasjsConstants.buildDestinationFolder;
91
91
  logFilePath = buildDestinationFolder;
92
92
  if (!(target.serverType === utils_2.ServerType.Sasjs)) return [3 /*break*/, 5];
93
- return [4 /*yield*/, deployToSasjs(target, isLocal, sasjs)];
93
+ return [4 /*yield*/, deployToSasjs(target, sasjs)];
94
94
  case 4:
95
95
  _k.sent();
96
96
  return [3 /*break*/, 7];
@@ -323,38 +323,47 @@ function deployToSas9(deployScriptName, target, linesToExecute, logFolder, strea
323
323
  /**
324
324
  * Deploys app to `SASJS` server.
325
325
  * @param {Target} target- the target having deploy configuration.
326
- * @param {boolean} isLocal- flag indicating if specified target is
327
- * from local sasjsconfig or global sasjsconfig file.
328
326
  * @param {object} sasjs - optional configuration object of SAS adapter.
329
327
  */
330
- function deployToSasjs(target, isLocal, sasjs) {
328
+ function deployToSasjs(target, sasjs) {
331
329
  var _a, _b;
332
330
  return __awaiter(this, void 0, void 0, function () {
333
- var buildDestinationFolder, finalFilePathJSON, jsonContent, payload, authConfig, result;
334
- var _c;
335
- return __generator(this, function (_d) {
336
- switch (_d.label) {
331
+ var buildDestinationFolder, finalFilePathJSON, jsonContent, payload, authConfig, e_2, result;
332
+ return __generator(this, function (_c) {
333
+ switch (_c.label) {
337
334
  case 0:
338
335
  buildDestinationFolder = process.sasjsConstants.buildDestinationFolder;
339
336
  finalFilePathJSON = path_1.default.join(buildDestinationFolder, "".concat(target.name, ".json"));
340
337
  return [4 /*yield*/, (0, utils_2.readFile)(finalFilePathJSON)];
341
338
  case 1:
342
- jsonContent = _d.sent();
339
+ jsonContent = _c.sent();
343
340
  payload = JSON.parse(jsonContent);
344
- if (!!sasjs) return [3 /*break*/, 3];
345
- ;
346
- return [4 /*yield*/, getSASjsAndAuthConfig(target, isLocal)];
341
+ if (!!sasjs) return [3 /*break*/, 5];
342
+ sasjs = new node_1.default({
343
+ serverUrl: target.serverUrl,
344
+ appLoc: target.appLoc,
345
+ serverType: target.serverType,
346
+ httpsAgentOptions: target.httpsAgentOptions,
347
+ debug: true
348
+ });
349
+ _c.label = 2;
347
350
  case 2:
348
- (_c = _d.sent(), sasjs = _c.sasjs, authConfig = _c.authConfig);
349
- _d.label = 3;
350
- case 3: return [4 /*yield*/, sasjs
351
+ _c.trys.push([2, 4, , 5]);
352
+ return [4 /*yield*/, (0, config_1.getAuthConfig)(target)];
353
+ case 3:
354
+ authConfig = _c.sent();
355
+ return [3 /*break*/, 5];
356
+ case 4:
357
+ e_2 = _c.sent();
358
+ return [3 /*break*/, 5];
359
+ case 5: return [4 /*yield*/, sasjs
351
360
  .deployToSASjs(payload, undefined, authConfig)
352
361
  .catch(function (err) {
353
362
  var _a;
354
363
  (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error(err);
355
364
  })];
356
- case 4:
357
- result = _d.sent();
365
+ case 6:
366
+ result = _c.sent();
358
367
  if ((result === null || result === void 0 ? void 0 : result.status) === 'failure') {
359
368
  (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error(result.message);
360
369
  if (result.example) {
@@ -5,4 +5,5 @@ export declare function executeJobSasjs(sasjs: SASjs, jobPath: string, logFile:
5
5
  log?: string | undefined;
6
6
  logPath?: string | undefined;
7
7
  error?: {} | undefined;
8
+ _webout?: string | undefined;
8
9
  } | undefined>;