@sasjs/cli 4.12.5 → 4.12.7

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.
@@ -1,4 +1,4 @@
1
1
  import { ServerType, Target } from '@sasjs/utils';
2
2
  export declare function build(target: Target): Promise<void>;
3
- export declare function getWebServiceScriptInvocation(serverType: ServerType, isSASFile?: boolean, encoded?: boolean): string;
3
+ export declare function getWebServiceScriptInvocation(serverType: ServerType, isSASFile?: boolean, encoded?: boolean, fileName?: string): string;
4
4
  export declare function getBuildVars(target: Target): Promise<string>;
@@ -211,7 +211,7 @@ function createFinalSasFiles(target) {
211
211
  }
212
212
  function getBuildInfo(target, streamWeb) {
213
213
  return __awaiter(this, void 0, void 0, function () {
214
- var buildConfig, serverType, appLoc, serverName, macroFolders, createWebServiceScript, macroCorePath, dependencyFilePaths, createFileScript, dependencyFilePathsForCreateFile, gsubScript, dependencyFilePathsForGsubScript, dependenciesContent, buildVars;
214
+ var buildConfig, serverType, appLoc, serverName, macroFolders, createWebServiceScript, macroCorePath, dependencyFilePaths, createFileScript, dependencyFilePathsForCreateFile, dependenciesContent, buildVars;
215
215
  return __generator(this, function (_a) {
216
216
  switch (_a.label) {
217
217
  case 0:
@@ -228,32 +228,21 @@ function getBuildInfo(target, streamWeb) {
228
228
  return [4 /*yield*/, (0, utils_1.getDependencyPaths)(buildConfig, macroFolders, macroCorePath)];
229
229
  case 3:
230
230
  dependencyFilePaths = _a.sent();
231
- if (!(target.serverType === utils_1.ServerType.SasViya && streamWeb)) return [3 /*break*/, 8];
231
+ if (!(target.serverType === utils_1.ServerType.SasViya && streamWeb)) return [3 /*break*/, 6];
232
232
  return [4 /*yield*/, getCreateFileScript(serverType)];
233
233
  case 4:
234
234
  createFileScript = _a.sent();
235
235
  buildConfig += "".concat(createFileScript, "\n");
236
- return [4 /*yield*/, (0, utils_1.getDependencyPaths)(createFileScript, macroFolders, macroCorePath)
237
- // The gsubScript is used to perform the replacement of the appLoc within
238
- // the deployed index.html file. This only happens when deploying using the
239
- // SAS Program (build.sas) approach.
240
- ];
236
+ return [4 /*yield*/, (0, utils_1.getDependencyPaths)(createFileScript, macroFolders, macroCorePath)];
241
237
  case 5:
242
238
  dependencyFilePathsForCreateFile = _a.sent();
243
- return [4 /*yield*/, (0, utils_1.readFile)("".concat(process.sasjsConstants.macroCorePath, "/base/mp_replace.sas"))];
244
- case 6:
245
- gsubScript = _a.sent();
246
- buildConfig += "".concat(gsubScript, "\n");
247
- return [4 /*yield*/, (0, utils_1.getDependencyPaths)(gsubScript, macroFolders, macroCorePath)];
239
+ dependencyFilePaths = __spreadArray([], __read(new Set(__spreadArray(__spreadArray([], __read(dependencyFilePaths), false), __read(dependencyFilePathsForCreateFile), false))), false);
240
+ _a.label = 6;
241
+ case 6: return [4 /*yield*/, getDepsContent(dependencyFilePaths, target, macroFolders)];
248
242
  case 7:
249
- dependencyFilePathsForGsubScript = _a.sent();
250
- dependencyFilePaths = __spreadArray([], __read(new Set(__spreadArray(__spreadArray(__spreadArray([], __read(dependencyFilePaths), false), __read(dependencyFilePathsForCreateFile), false), __read(dependencyFilePathsForGsubScript), false))), false);
251
- _a.label = 8;
252
- case 8: return [4 /*yield*/, getDepsContent(dependencyFilePaths, target, macroFolders)];
253
- case 9:
254
243
  dependenciesContent = _a.sent();
255
244
  return [4 /*yield*/, getBuildVars(target)];
256
- case 10:
245
+ case 8:
257
246
  buildVars = _a.sent();
258
247
  return [2 /*return*/, "\n/**\n * The appLoc represents the metadata or SAS Drive location of the app you\n * are about to deploy\n *\n * To set an alternative appLoc, simply populate the appLoc variable prior\n * to running this program, eg:\n *\n * %let apploc=/my/apploc;\n * %inc thisfile;\n *\n */\n\n%global appLoc;\n%let compiled_apploc=".concat(appLoc, ";\n%let appLoc=%sysfunc(coalescec(&appLoc,&compiled_apploc));\n\n\n").concat(serverType === utils_1.ServerType.Sas9
259
248
  ? "\n/**\n * The serverName represents the SAS 9 logical server context\n * There is no programmatic (SAS code) way to obtain this\n * So it is taken from the sasjsconfig file OR supplied at runtime, eg:\n * \n * %let apploc=/my/apploc;\n * %let serverName=SASAppDC;\n * %inc thisfile;\n * \n * /\n\n%global serverName;\n%let compiled_serverName=".concat(serverName, ";\n%let serverName=%sysfunc(coalescec(&serverName,&compiled_serverName));\n")
@@ -317,15 +306,23 @@ function getCreateFileScript(serverType) {
317
306
  });
318
307
  });
319
308
  }
320
- function getWebServiceScriptInvocation(serverType, isSASFile, encoded) {
309
+ function getWebServiceScriptInvocation(serverType, isSASFile, encoded, fileName) {
310
+ var _a;
321
311
  if (isSASFile === void 0) { isSASFile = true; }
322
312
  if (encoded === void 0) { encoded = false; }
323
313
  var encodedParam = encoded ? ', intype=BASE64' : '';
324
314
  switch (serverType) {
325
315
  case utils_1.ServerType.SasViya:
316
+ var swapString = '';
317
+ if (fileName) {
318
+ var extension = ((_a = fileName === null || fileName === void 0 ? void 0 : fileName.split('.').pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || '';
319
+ if (['html', 'css', 'js'].includes(extension)) {
320
+ swapString = ",swap=compiled_apploc apploc";
321
+ }
322
+ }
326
323
  return isSASFile
327
324
  ? "%mv_createwebservice(path=&appLoc/&path, name=&service, code=sascode,replace=yes)"
328
- : "%mv_createfile(path=&appLoc/&path, name=&filename, inref=filecode".concat(encodedParam, ")");
325
+ : "%mv_createfile(path=&appLoc/&path, name=&filename, inref=filecode".concat(encodedParam).concat(swapString, ")");
329
326
  case utils_1.ServerType.Sas9:
330
327
  return isSASFile
331
328
  ? "%mm_createwebservice(path=&appLoc/&path, name=&service, code=sascode, server=&serverName, replace=yes)"
@@ -478,7 +475,7 @@ function getFileText(fileName, fileContent, serverType) {
478
475
  var fileExtension = path_1.default.extname(fileName).substring(1).toUpperCase();
479
476
  var _a = getWebFileContent(fileContent, fileExtension), content = _a.content, maxLineLength = _a.maxLineLength;
480
477
  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
481
- ? getWebServiceScriptInvocation(serverType, false, true)
478
+ ? getWebServiceScriptInvocation(serverType, false, true, fileName)
482
479
  : '', "\nfilename filecode clear;\n");
483
480
  }
484
481
  function getWebFileContent(filecontent, type) {
@@ -4,7 +4,7 @@ exports.getLaunchPageCode = void 0;
4
4
  var error_1 = require("@sasjs/utils/error");
5
5
  var types_1 = require("@sasjs/utils/types");
6
6
  var SAS9Code = function (streamServiceName) { return "\noptions notes;\ndata _null_;\n format url $256.;\n rc=METADATA_GETURI(\"Stored Process Web App\",url);\n url=coalescec(url,\"localhost/SASStoredProcess\");\n urlEscaped = tranwrd(trim(url),\" \",\"%20\");\n putlog \"NOTE: SASjs Streaming App Created! Check it out here:\" ;\n putlog \"NOTE- \";putlog \"NOTE- \";putlog \"NOTE- \";putlog \"NOTE- \";\n putlog \"NOTE- \" urlEscaped +(-1) \"?_program=&appLoc/services/".concat(streamServiceName, "\" ;\n putlog \"NOTE- \";putlog \"NOTE- \";putlog \"NOTE- \";putlog \"NOTE- \";\nrun;\n"); };
7
- var SASViyaCode = function (streamServiceName) { return "\n\n/**\n * The streamService we just deployed (as a _FILE) had the compile-time appLoc\n * In this section we replace with the deploy-time appLoc\n */\n\nfilename _homein filesrvc\n folderPath=\"&apploc/services\"\n filename=\"".concat(streamServiceName, ".html\"\n recfm=v\n lrecl=1048544;\n\n%let local_file=%sysfunc(pathname(work))/service.html;\nfilename _homeout \"&local_file\";\n\ndata _null_;\n rc=fcopy('_homein','_homeout');\n put rc=;\nrun;\n\n%mp_replace(infile=\"&local_file\", findvar=compiled_apploc, replacevar=apploc)\n\ndata _null_;\n rc=fcopy('_homeout','_homein');\n put rc=;\nrun;\n\n/* Tell the user where the app was deployed so they can open it */\noptions notes;\ndata _null_;\n if symexist('_baseurl') then do;\n url=symget('_baseurl');\n if subpad(url,length(url)-9,9)='SASStudio'\n then url=substr(url,1,length(url)-11);\n else url=\"&systcpiphostname\";\n end;\n else url=\"&systcpiphostname\";\n url=cats(url,\"/SASJobExecution?_FILE=&appLoc/services/\");\n urlEscaped = tranwrd(trim(url),\" \",\"%20\");\n putlog \"NOTE: SASjs Streaming App Created! Check it out here:\" ;\n putlog \"NOTE- \";putlog \"NOTE- \";putlog \"NOTE- \";putlog \"NOTE- \";\n putlog \"NOTE- \" urlEscaped +(-1) '").concat(streamServiceName, ".html' ;\n putlog \"NOTE- \";putlog \"NOTE- \";putlog \"NOTE- \";putlog \"NOTE- \";\nrun;\n"); };
7
+ var SASViyaCode = function (streamServiceName) { return "\n/* Tell the user where the app was deployed so they can open it */\noptions notes;\ndata _null_;\n if symexist('_baseurl') then do;\n url=symget('_baseurl');\n if subpad(url,length(url)-9,9)='SASStudio'\n then url=substr(url,1,length(url)-11);\n else url=\"&systcpiphostname\";\n end;\n else url=\"&systcpiphostname\";\n url=cats(url,\"/SASJobExecution?_FILE=&appLoc/services/\");\n urlEscaped = tranwrd(trim(url),\" \",\"%20\");\n putlog \"NOTE: SASjs Streaming App Created! Check it out here:\" ;\n putlog \"NOTE- \";putlog \"NOTE- \";putlog \"NOTE- \";putlog \"NOTE- \";\n putlog \"NOTE- \" urlEscaped +(-1) '".concat(streamServiceName, ".html' ;\n putlog \"NOTE- \";putlog \"NOTE- \";putlog \"NOTE- \";putlog \"NOTE- \";\nrun;\n"); };
8
8
  var getLaunchPageCode = function (serverType, streamServiceName) {
9
9
  switch (serverType) {
10
10
  case types_1.ServerType.SasViya:
@@ -286,7 +286,9 @@ describe('deploy', function () {
286
286
  target = new utils_1.Target(__assign(__assign({}, commonTargetFields), { serverType: utils_1.ServerType.Sasjs, deployConfig: {
287
287
  deployScripts: ['script.invalid']
288
288
  } }));
289
- return [4 /*yield*/, (0, deploy_1.deploy)(target, true)];
289
+ return [4 /*yield*/, (0, deploy_1.deploy)(target, true).catch(function (err) {
290
+ // error is expected, nothing to do
291
+ })];
290
292
  case 1:
291
293
  _a.sent();
292
294
  expect(process.logger.error).toHaveBeenCalledWith("Unable to process script located at ".concat(path_1.default.join(process.projectDir, "script.invalid")));
package/package.json CHANGED
@@ -52,7 +52,7 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@sasjs/adapter": "4.11.3",
55
- "@sasjs/core": "4.57.0",
55
+ "@sasjs/core": "4.58.1",
56
56
  "@sasjs/lint": "2.4.3",
57
57
  "@sasjs/utils": "3.5.2",
58
58
  "adm-zip": "0.5.10",
@@ -101,5 +101,5 @@
101
101
  "typescript": "4.9.5",
102
102
  "util": "0.12.4"
103
103
  },
104
- "version": "4.12.5"
104
+ "version": "4.12.7"
105
105
  }