@sasjs/cli 3.0.0 → 3.0.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.
Files changed (75) hide show
  1. package/build/commands/add/addCredential.d.ts +6 -2
  2. package/build/commands/add/addCredential.js +79 -47
  3. package/build/commands/add/addTarget.js +32 -20
  4. package/build/commands/add/internal/input.d.ts +7 -0
  5. package/build/commands/add/internal/input.js +53 -8
  6. package/build/commands/add/spec/addTarget.spec.js +78 -0
  7. package/build/commands/build/build.js +11 -11
  8. package/build/commands/build/internal/config.d.ts +1 -1
  9. package/build/commands/build/internal/config.js +5 -6
  10. package/build/commands/compile/compile.js +4 -4
  11. package/build/commands/compile/compileCommand.js +2 -1
  12. package/build/commands/compile/compileSingleFile.d.ts +1 -1
  13. package/build/commands/compile/compileSingleFile.js +6 -7
  14. package/build/commands/compile/internal/compareFolders.js +1 -2
  15. package/build/commands/compile/internal/compileJobFile.js +1 -1
  16. package/build/commands/compile/internal/compileServiceFile.js +32 -15
  17. package/build/commands/compile/internal/compileTestFile.d.ts +0 -2
  18. package/build/commands/compile/internal/compileTestFile.js +11 -15
  19. package/build/commands/compile/internal/getAllJobFolders.js +1 -1
  20. package/build/commands/compile/internal/getAllServiceFolders.js +1 -1
  21. package/build/commands/compile/internal/loadDependencies.d.ts +2 -3
  22. package/build/commands/compile/internal/loadDependencies.js +43 -230
  23. package/build/commands/compile/internal/spec/compileTestFile.spec.js +24 -12
  24. package/build/commands/compile/spec/compile.spec.js +30 -0
  25. package/build/commands/compile/spec/compileJobFile.spec.js +3 -3
  26. package/build/commands/compile/spec/compileServiceFile.spec.js +3 -3
  27. package/build/commands/compile/spec/loadDependencies.spec.js +37 -37
  28. package/build/commands/create/spec/reactAppFiles.js +5 -5
  29. package/build/commands/deploy/deploy.js +1 -1
  30. package/build/commands/deploy/spec/cbd.spec.js +19 -3
  31. package/build/commands/docs/generateDocs.js +4 -5
  32. package/build/commands/docs/internal/getFileInputs.d.ts +1 -1
  33. package/build/commands/docs/internal/getFileInputs.js +2 -2
  34. package/build/commands/docs/internal/getFileOutputs.d.ts +1 -1
  35. package/build/commands/docs/internal/getFileOutputs.js +2 -2
  36. package/build/commands/docs/internal/getFoldersForDocs.d.ts +1 -1
  37. package/build/commands/docs/internal/getFoldersForDocs.js +1 -1
  38. package/build/commands/request/request.js +2 -2
  39. package/build/commands/run/run.js +1 -1
  40. package/build/commands/servicepack/deploy.js +1 -1
  41. package/build/commands/web/internal/getTags.d.ts +2 -1
  42. package/build/commands/web/internal/getTags.js +10 -12
  43. package/build/commands/web/internal/getWebServiceContent.js +1 -2
  44. package/build/commands/web/internal/sasjsout.d.ts +1 -1
  45. package/build/commands/web/internal/sasjsout.js +1 -1
  46. package/build/commands/web/internal/spec/updateLinkTag.spec.d.ts +4 -0
  47. package/build/commands/web/internal/spec/updateLinkTag.spec.js +32 -0
  48. package/build/commands/web/internal/updateAllTags.js +33 -8
  49. package/build/commands/web/internal/updateLinkTag.d.ts +4 -0
  50. package/build/commands/web/internal/updateLinkTag.js +24 -0
  51. package/build/commands/web/web.js +12 -13
  52. package/build/utils/auth.d.ts +10 -4
  53. package/build/utils/auth.js +17 -15
  54. package/build/utils/config.d.ts +2 -3
  55. package/build/utils/config.js +14 -16
  56. package/build/utils/file.d.ts +0 -6
  57. package/build/utils/file.js +1 -43
  58. package/build/utils/setConstants.js +1 -1
  59. package/build/utils/spec/utils.spec.js +31 -5
  60. package/build/utils/utils.d.ts +0 -2
  61. package/build/utils/utils.js +1 -16
  62. package/package.json +7 -13
  63. package/CHANGELOG.md +0 -30
  64. package/build/commands/compile/internal/config.d.ts +0 -25
  65. package/build/commands/compile/internal/config.js +0 -259
  66. package/build/commands/compile/spec/getDependencyPaths.spec.d.ts +0 -1
  67. package/build/commands/compile/spec/getDependencyPaths.spec.js +0 -263
  68. package/build/commands/compile/spec/getProgramDependencies.spec.d.ts +0 -1
  69. package/build/commands/compile/spec/getProgramDependencies.spec.js +0 -403
  70. package/build/commands/shared/dependencies.d.ts +0 -12
  71. package/build/commands/shared/dependencies.js +0 -332
  72. package/build/commands/web/internal/updateLinkHref.d.ts +0 -4
  73. package/build/commands/web/internal/updateLinkHref.js +0 -18
  74. package/build/utils/spec/utils.spec.server.d.ts +0 -1
  75. package/build/utils/spec/utils.spec.server.js +0 -72
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -46,243 +35,67 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
46
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
36
  }
48
37
  };
49
- var __read = (this && this.__read) || function (o, n) {
50
- var m = typeof Symbol === "function" && o[Symbol.iterator];
51
- if (!m) return o;
52
- var i = m.call(o), r, ar = [], e;
53
- try {
54
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
55
- }
56
- catch (error) { e = { error: error }; }
57
- finally {
58
- try {
59
- if (r && !r.done && (m = i["return"])) m.call(i);
60
- }
61
- finally { if (e) throw e.error; }
62
- }
63
- return ar;
64
- };
65
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
66
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
67
- to[j] = from[i];
68
- return to;
69
- };
70
- var __values = (this && this.__values) || function(o) {
71
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
72
- if (m) return m.call(o);
73
- if (o && typeof o.length === "number") return {
74
- next: function () {
75
- if (o && i >= o.length) o = void 0;
76
- return { value: o && o[i++], done: !o };
77
- }
78
- };
79
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
80
- };
81
38
  Object.defineProperty(exports, "__esModule", { value: true });
82
- exports.getVars = exports.loadDependencies = void 0;
39
+ exports.loadDependencies = void 0;
83
40
  var utils_1 = require("@sasjs/utils");
84
41
  var config_1 = require("../../../utils/config");
85
- var utils_2 = require("../../../utils/utils");
86
- var dependencies_1 = require("../../shared/dependencies");
87
- var config_2 = require("./config");
88
- var compileTestFile_1 = require("./compileTestFile");
89
42
  function loadDependencies(target, filePath, macroFolders, programFolders, type) {
90
- var _a, _b, _c, _d;
91
- if (type === void 0) { type = 'service'; }
43
+ var _a;
92
44
  return __awaiter(this, void 0, void 0, function () {
93
- var fileContent, deprecationDate, today, deprecationDate, warningDate, today, message, init, initPath, term, termPath, serviceVars, jobVars, testVars, fileDependencyPaths, initDependencyPaths, termDependencyPaths, allDependencyPaths, initProgramDependencies, termProgramDependencies, programDependencies, dependenciesContent;
94
- var _e, _f, _g, _h, _j, _k;
95
- return __generator(this, function (_l) {
96
- switch (_l.label) {
45
+ var fileContent, configuration, _b, buildSourceFolder, macroCorePath;
46
+ return __generator(this, function (_c) {
47
+ switch (_c.label) {
97
48
  case 0:
98
49
  (_a = process.logger) === null || _a === void 0 ? void 0 : _a.info("Loading dependencies for " + filePath);
99
50
  return [4 /*yield*/, utils_1.readFile(filePath)];
100
51
  case 1:
101
- fileContent = _l.sent();
102
- if (fileContent.includes('<h4> Dependencies </h4>')) {
103
- deprecationDate = new Date(2021, 10, 2);
104
- today = new Date();
105
- if (today < deprecationDate) {
106
- (_b = process.logger) === null || _b === void 0 ? void 0 : _b.warn("Please use <h4> SAS Macros </h4> syntax to specify dependencies. Specifying dependencies with a <h4> Dependencies </h4> syntax will not be supported starting from November 1, 2021.");
107
- }
108
- else {
109
- throw new Error('Using <h4> Dependencies </h4> syntax is deprecated. Please use <h4> SAS Macros </h4> instead.');
110
- }
111
- }
112
- if (fileContent.includes('<h4> SAS Programs </h4>')) {
113
- deprecationDate = new Date(2022, 4, 2);
114
- warningDate = new Date(2022, 10, 2);
115
- today = new Date();
116
- message = "Please use <h4> SAS Includes </h4> syntax to specify programs. Specifying programs with a <h4> SAS Programs </h4> syntax will not be supported starting from April 1, 2022.";
117
- if (today < warningDate)
118
- (_c = process.logger) === null || _c === void 0 ? void 0 : _c.info(message);
119
- else if (today < deprecationDate)
120
- (_d = process.logger) === null || _d === void 0 ? void 0 : _d.warn(message);
121
- else
122
- throw new Error('Using <h4> SAS Programs </h4> syntax is deprecated. Please use <h4> SAS Includes </h4> instead.');
123
- }
124
- serviceVars = '';
125
- jobVars = '';
126
- testVars = '';
127
- if (!(type === 'service' && !compileTestFile_1.isTestFile(filePath))) return [3 /*break*/, 5];
128
- return [4 /*yield*/, exports.getVars('service', target)];
52
+ fileContent = _c.sent();
53
+ return [4 /*yield*/, config_1.getLocalOrGlobalConfig()];
129
54
  case 2:
130
- serviceVars = _l.sent();
131
- return [4 /*yield*/, config_2.getServiceInit(target)];
132
- case 3:
133
- (_e = _l.sent(), init = _e.content, initPath = _e.filePath);
134
- return [4 /*yield*/, config_2.getServiceTerm(target)];
135
- case 4:
136
- (_f = _l.sent(), term = _f.content, termPath = _f.filePath);
137
- fileContent = fileContent
138
- ? "\n* Service start;\n" + fileContent + "\n* Service end;"
139
- : '';
140
- return [3 /*break*/, 13];
141
- case 5:
142
- if (!(type === 'job' && !compileTestFile_1.isTestFile(filePath))) return [3 /*break*/, 9];
143
- return [4 /*yield*/, exports.getVars('job', target)];
144
- case 6:
145
- jobVars = _l.sent();
146
- return [4 /*yield*/, config_2.getJobInit(target)];
147
- case 7:
148
- (_g = _l.sent(), init = _g.content, initPath = _g.filePath);
149
- return [4 /*yield*/, config_2.getJobTerm(target)];
150
- case 8:
151
- (_h = _l.sent(), term = _h.content, termPath = _h.filePath);
152
- fileContent = fileContent
153
- ? "\n* Job start;\n" + fileContent + "\n* Job end;"
154
- : '';
155
- return [3 /*break*/, 13];
156
- case 9: return [4 /*yield*/, exports.getVars('test', target)];
157
- case 10:
158
- testVars = _l.sent();
159
- return [4 /*yield*/, config_2.getTestInit(target)];
160
- case 11:
161
- (_j = _l.sent(), init = _j.content, initPath = _j.filePath);
162
- return [4 /*yield*/, config_2.getTestTerm(target)];
163
- case 12:
164
- (_k = _l.sent(), term = _k.content, termPath = _k.filePath);
165
- fileContent = fileContent
166
- ? "\n* Test start;\n" + fileContent + "\n* Test end;"
167
- : '';
168
- _l.label = 13;
169
- case 13:
170
- init = init || '';
171
- initPath = initPath || '';
172
- term = term || '';
173
- termPath = termPath || '';
174
- return [4 /*yield*/, dependencies_1.getDependencyPaths(fileContent + "\n" + init + "\n" + term, macroFolders)];
175
- case 14:
176
- fileDependencyPaths = _l.sent();
177
- return [4 /*yield*/, dependencies_1.getDependencyPaths(init, macroFolders)];
178
- case 15:
179
- initDependencyPaths = _l.sent();
180
- return [4 /*yield*/, dependencies_1.getDependencyPaths(term, macroFolders)];
181
- case 16:
182
- termDependencyPaths = _l.sent();
183
- allDependencyPaths = __spreadArray(__spreadArray(__spreadArray([], __read(initDependencyPaths)), __read(fileDependencyPaths)), __read(termDependencyPaths));
184
- return [4 /*yield*/, dependencies_1.getProgramDependencies(init, programFolders, initPath)];
185
- case 17:
186
- initProgramDependencies = _l.sent();
187
- return [4 /*yield*/, dependencies_1.getProgramDependencies(term, programFolders, termPath)];
188
- case 18:
189
- termProgramDependencies = _l.sent();
190
- return [4 /*yield*/, dependencies_1.getProgramDependencies(fileContent, programFolders, filePath)];
191
- case 19:
192
- programDependencies = _l.sent();
193
- return [4 /*yield*/, getDependencies(allDependencyPaths)];
194
- case 20:
195
- dependenciesContent = _l.sent();
196
- fileContent = "* Dependencies start;\n" + initProgramDependencies + "\n" + termProgramDependencies + "\n" + dependenciesContent + "\n* Dependencies end;\n* Programs start;\n" + programDependencies + "\n*Programs end;" + init + fileContent + term;
197
- switch (type) {
198
- case 'service':
199
- fileContent = "* Service Variables start;\n" + serviceVars + "\n*Service Variables end;\n" + fileContent;
200
- break;
201
- case 'job':
202
- fileContent = "* Job Variables start;\n" + jobVars + "\n*Job Variables end;\n" + fileContent;
203
- break;
204
- case 'test':
205
- fileContent = "* Test Variables start;\n" + testVars + "\n*Test Variables end;\n" + fileContent;
206
- break;
207
- default:
208
- break;
209
- }
210
- return [2 /*return*/, fileContent];
55
+ configuration = (_c.sent()).configuration;
56
+ _b = process.sasjsConstants, buildSourceFolder = _b.buildSourceFolder, macroCorePath = _b.macroCorePath;
57
+ headerSyntaxNotices(fileContent);
58
+ return [4 /*yield*/, utils_1.loadDependenciesFile({
59
+ fileContent: fileContent,
60
+ filePath: filePath,
61
+ configuration: configuration,
62
+ target: target,
63
+ type: type,
64
+ macroFolders: macroFolders,
65
+ programFolders: programFolders,
66
+ buildSourceFolder: buildSourceFolder,
67
+ macroCorePath: macroCorePath
68
+ })];
69
+ case 3: return [2 /*return*/, _c.sent()];
211
70
  }
212
71
  });
213
72
  });
214
73
  }
215
74
  exports.loadDependencies = loadDependencies;
216
- function getDependencies(filePaths) {
217
- return __awaiter(this, void 0, void 0, function () {
218
- var dependenciesContent;
219
- var _this = this;
220
- return __generator(this, function (_a) {
221
- switch (_a.label) {
222
- case 0:
223
- dependenciesContent = [];
224
- return [4 /*yield*/, utils_1.asyncForEach(__spreadArray([], __read(new Set(filePaths))), function (filePath) { return __awaiter(_this, void 0, void 0, function () {
225
- var depFileContent;
226
- return __generator(this, function (_a) {
227
- switch (_a.label) {
228
- case 0: return [4 /*yield*/, utils_1.readFile(filePath)];
229
- case 1:
230
- depFileContent = _a.sent();
231
- dependenciesContent.push(depFileContent);
232
- return [2 /*return*/];
233
- }
234
- });
235
- }); })];
236
- case 1:
237
- _a.sent();
238
- return [2 /*return*/, dependenciesContent.join('\n')];
239
- }
240
- });
241
- });
242
- }
243
- var getVars = function (varType, target) { return __awaiter(void 0, void 0, void 0, function () {
244
- var getInternalVars, targetVars, configuration, commonServiceVars;
245
- return __generator(this, function (_a) {
246
- switch (_a.label) {
247
- case 0:
248
- getInternalVars = function (config) {
249
- var _a, _b, _c;
250
- return varType === 'service'
251
- ? (_a = config === null || config === void 0 ? void 0 : config.serviceConfig) === null || _a === void 0 ? void 0 : _a.macroVars
252
- : varType === 'job'
253
- ? (_b = config === null || config === void 0 ? void 0 : config.jobConfig) === null || _b === void 0 ? void 0 : _b.macroVars
254
- : varType === 'test'
255
- ? (_c = config === null || config === void 0 ? void 0 : config.testConfig) === null || _c === void 0 ? void 0 : _c.macroVars
256
- : {};
257
- };
258
- targetVars = getInternalVars(target);
259
- return [4 /*yield*/, config_1.getLocalOrGlobalConfig()];
260
- case 1:
261
- configuration = (_a.sent()).configuration;
262
- commonServiceVars = getInternalVars(configuration);
263
- return [2 /*return*/, convertVarsToSasFormat(__assign(__assign({}, commonServiceVars), targetVars))];
75
+ var headerSyntaxNotices = function (fileContent) {
76
+ var _a, _b, _c;
77
+ if (fileContent.includes('<h4> Dependencies </h4>')) {
78
+ var deprecationDate = new Date(2021, 10, 2);
79
+ var today = new Date();
80
+ if (today < deprecationDate) {
81
+ (_a = process.logger) === null || _a === void 0 ? void 0 : _a.warn("Please use <h4> SAS Macros </h4> syntax to specify dependencies. Specifying dependencies with a <h4> Dependencies </h4> syntax will not be supported starting from November 1, 2021.");
264
82
  }
265
- });
266
- }); };
267
- exports.getVars = getVars;
268
- var convertVarsToSasFormat = function (vars) {
269
- var e_1, _a;
270
- var entries = Object.entries(vars);
271
- var varsContent = '\n';
272
- try {
273
- for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
274
- var _b = __read(entries_1_1.value, 2), name_1 = _b[0], value = _b[1];
275
- var chunks = utils_2.chunk(value);
276
- var chunkedString = chunks.join('%trim(\n)');
277
- varsContent += "%let " + name_1 + "=" + chunkedString + ";\n";
83
+ else {
84
+ throw new Error('Using <h4> Dependencies </h4> syntax is deprecated. Please use <h4> SAS Macros </h4> instead.');
278
85
  }
279
86
  }
280
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
281
- finally {
282
- try {
283
- if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
87
+ if (fileContent.includes('<h4> SAS Programs </h4>')) {
88
+ var deprecationDate = new Date(2022, 4, 2);
89
+ var warningDate = new Date(2022, 10, 2);
90
+ var today = new Date();
91
+ var message = "Please use <h4> SAS Includes </h4> syntax to specify programs. Specifying programs with a <h4> SAS Programs </h4> syntax will not be supported starting from April 1, 2022.";
92
+ if (today < warningDate) {
93
+ (_b = process.logger) === null || _b === void 0 ? void 0 : _b.info(message);
94
+ }
95
+ else if (today < deprecationDate) {
96
+ (_c = process.logger) === null || _c === void 0 ? void 0 : _c.warn(message);
284
97
  }
285
- finally { if (e_1) throw e_1.error; }
98
+ else
99
+ throw new Error('Using <h4> SAS Programs </h4> syntax is deprecated. Please use <h4> SAS Includes </h4> instead.');
286
100
  }
287
- return varsContent;
288
101
  };
@@ -66,7 +66,7 @@ describe('compileTestFile', function () {
66
66
  }, utils_1.ServerType.SasViya);
67
67
  var target = new utils_1.Target(__assign(__assign({}, temp.toJson()), { jobConfig: {
68
68
  jobFolders: [path_1.default.join('sasjs', 'jobs')]
69
- } }));
69
+ }, macroFolders: ['sasjs/macros'] }));
70
70
  var sasjsPath;
71
71
  var testBody;
72
72
  var buildPath;
@@ -151,6 +151,9 @@ describe('compileTestFile', function () {
151
151
  _a.sent();
152
152
  return [4 /*yield*/, testContent(path_1.default.join('testteardown.sas'))];
153
153
  case 5:
154
+ _a.sent();
155
+ return [4 /*yield*/, testContent(path_1.default.join('macros', 'testMacro.test.sas'))];
156
+ case 6:
154
157
  _a.sent();
155
158
  return [2 /*return*/];
156
159
  }
@@ -236,6 +239,7 @@ describe('compileTestFile', function () {
236
239
  expectedTestFlow = {
237
240
  tests: [
238
241
  ['tests', 'jobs', 'jobs', 'testJob.test.sas'].join('/'),
242
+ ['tests', 'macros', 'testMacro.test.sas'].join('/'),
239
243
  ['tests', 'services', 'services', 'admin', 'random.test.sas'].join('/'),
240
244
  ['tests', 'services', 'services', 'admin', 'random.test.0.sas'].join('/')
241
245
  ].sort(),
@@ -290,6 +294,11 @@ describe('compileTestFile', function () {
290
294
  'test',
291
295
  'standalone'
292
296
  ],
297
+ [
298
+ ['tests', 'macros', 'testMacro.test.sas'].join('/'),
299
+ 'test',
300
+ 'standalone'
301
+ ],
293
302
  [
294
303
  ['tests', 'services', 'services', 'admin', 'random.test.sas'].join('/'),
295
304
  'test',
@@ -313,9 +322,9 @@ describe('compileTestFile', function () {
313
322
  return [4 /*yield*/, compile_1.compile(target)];
314
323
  case 1:
315
324
  _a.sent();
316
- expect(process.logger.info).toHaveBeenCalledTimes(14);
317
- expect(process.logger.info).toHaveBeenNthCalledWith(12, "Test coverage:");
318
- expect(process.logger.info).toHaveBeenNthCalledWith(13, "Services coverage: 0/4 (" + chalk_1.default.greenBright('0%') + ")");
325
+ expect(process.logger.info).toHaveBeenCalledTimes(15);
326
+ expect(process.logger.info).toHaveBeenNthCalledWith(13, "Test coverage:");
327
+ expect(process.logger.info).toHaveBeenNthCalledWith(14, "Services coverage: 0/4 (" + chalk_1.default.greenBright('0%') + ")");
319
328
  expect(process.logger.info).toHaveBeenLastCalledWith("Overall coverage: 0/4 (" + chalk_1.default.greenBright('0%') + ")");
320
329
  return [2 /*return*/];
321
330
  }
@@ -325,16 +334,16 @@ describe('compileTestFile', function () {
325
334
  });
326
335
  describe('isTestFile', function () {
327
336
  it('should return true if test SAS file', function () {
328
- expect(compileTestFile_1.isTestFile('random.test.sas')).toEqual(true);
329
- expect(compileTestFile_1.isTestFile('random.test.SAS')).toEqual(true);
330
- expect(compileTestFile_1.isTestFile('random.test.0.sas')).toEqual(true);
331
- expect(compileTestFile_1.isTestFile('random.test.10.sas')).toEqual(true);
337
+ expect(utils_1.isTestFile('random.test.sas')).toEqual(true);
338
+ expect(utils_1.isTestFile('random.test.SAS')).toEqual(true);
339
+ expect(utils_1.isTestFile('random.test.0.sas')).toEqual(true);
340
+ expect(utils_1.isTestFile('random.test.10.sas')).toEqual(true);
332
341
  });
333
342
  it('should return false if not a test SAS file', function () {
334
- expect(compileTestFile_1.isTestFile('random.test.txt')).toEqual(false);
335
- expect(compileTestFile_1.isTestFile('random.sas')).toEqual(false);
336
- expect(compileTestFile_1.isTestFile('random.0.sas')).toEqual(false);
337
- expect(compileTestFile_1.isTestFile('random.tests.sas')).toEqual(false);
343
+ expect(utils_1.isTestFile('random.test.txt')).toEqual(false);
344
+ expect(utils_1.isTestFile('random.sas')).toEqual(false);
345
+ expect(utils_1.isTestFile('random.0.sas')).toEqual(false);
346
+ expect(utils_1.isTestFile('random.tests.sas')).toEqual(false);
338
347
  });
339
348
  });
340
349
  var copyTestFiles = function (appName) { return __awaiter(void 0, void 0, void 0, function () {
@@ -348,6 +357,9 @@ var copyTestFiles = function (appName) { return __awaiter(void 0, void 0, void 0
348
357
  _a.sent();
349
358
  return [4 /*yield*/, utils_1.copy(path_1.default.join(__dirname, 'testFiles', 'jobs'), path_1.default.join(__dirname, appName, 'sasjs', 'jobs'))];
350
359
  case 3:
360
+ _a.sent();
361
+ return [4 /*yield*/, utils_1.copy(path_1.default.join(__dirname, 'testFiles', 'macros'), path_1.default.join(__dirname, appName, 'sasjs', 'macros'))];
362
+ case 4:
351
363
  _a.sent();
352
364
  return [2 /*return*/];
353
365
  }
@@ -133,6 +133,36 @@ describe('sasjs compile', function () {
133
133
  }
134
134
  });
135
135
  }); });
136
+ it('it should compile project from sub folder', function () { return __awaiter(void 0, void 0, void 0, function () {
137
+ var serviceFolder, testFile, wrongSasjsBuildFolder, correctSasjsBuildFolder, correctBuildFile;
138
+ return __generator(this, function (_a) {
139
+ switch (_a.label) {
140
+ case 0:
141
+ serviceFolder = path_1.default.join(process.projectDir, 'sasjs', 'services', 'admin');
142
+ testFile = 'dostuff.test.sas';
143
+ wrongSasjsBuildFolder = path_1.default.join(serviceFolder, 'sasjsbuild');
144
+ correctSasjsBuildFolder = path_1.default.join(process.currentDir, 'sasjsbuild');
145
+ correctBuildFile = path_1.default.join(correctSasjsBuildFolder, 'tests', 'services', 'admin', testFile);
146
+ return [4 /*yield*/, utils_1.createFile(path_1.default.join(serviceFolder, testFile), '')];
147
+ case 1:
148
+ _a.sent();
149
+ process.currentDir = serviceFolder;
150
+ return [4 /*yield*/, expect(compileModule.compile(target)).toResolve()];
151
+ case 2:
152
+ _a.sent();
153
+ return [4 /*yield*/, expect(utils_1.folderExists(wrongSasjsBuildFolder)).resolves.toEqual(false)];
154
+ case 3:
155
+ _a.sent();
156
+ return [4 /*yield*/, expect(utils_1.folderExists(correctSasjsBuildFolder)).resolves.toEqual(true)];
157
+ case 4:
158
+ _a.sent();
159
+ return [4 /*yield*/, expect(utils_1.fileExists(correctBuildFile)).resolves.toEqual(true)];
160
+ case 5:
161
+ _a.sent();
162
+ return [2 /*return*/];
163
+ }
164
+ });
165
+ }); });
136
166
  it('should compile an uncompiled project', function () { return __awaiter(void 0, void 0, void 0, function () {
137
167
  return __generator(this, function (_a) {
138
168
  switch (_a.label) {
@@ -60,7 +60,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
60
60
  Object.defineProperty(exports, "__esModule", { value: true });
61
61
  var path_1 = __importDefault(require("path"));
62
62
  var utils_1 = require("@sasjs/utils");
63
- var internalModule = __importStar(require("../internal/config"));
63
+ var internalModule = __importStar(require("@sasjs/utils/sasjsCli/getInitTerm"));
64
64
  var test_1 = require("../../../utils/test");
65
65
  var compileJobFile_1 = require("../internal/compileJobFile");
66
66
  var utils_2 = require("@sasjs/utils");
@@ -106,13 +106,13 @@ describe('compileJobFile', function () {
106
106
  return __generator(this, function (_a) {
107
107
  switch (_a.label) {
108
108
  case 0:
109
- jest.spyOn(internalModule, 'getJobInit').mockImplementation(function () {
109
+ jest.spyOn(internalModule, 'getInit').mockImplementation(function () {
110
110
  return Promise.resolve({
111
111
  content: "\n* JobInit start;\n" + fakeJobInit + "\n* JobInit end;",
112
112
  filePath: ''
113
113
  });
114
114
  });
115
- jest.spyOn(internalModule, 'getJobTerm').mockImplementation(function () {
115
+ jest.spyOn(internalModule, 'getTerm').mockImplementation(function () {
116
116
  return Promise.resolve({
117
117
  content: "\n* JobTerm start;\n" + fakeJobTerm + "\n* JobTerm end;",
118
118
  filePath: ''
@@ -60,7 +60,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
60
60
  Object.defineProperty(exports, "__esModule", { value: true });
61
61
  var path_1 = __importDefault(require("path"));
62
62
  var utils_1 = require("@sasjs/utils");
63
- var internalModule = __importStar(require("../internal/config"));
63
+ var internalModule = __importStar(require("@sasjs/utils/sasjsCli/getInitTerm"));
64
64
  var test_1 = require("../../../utils/test");
65
65
  var compileServiceFile_1 = require("../internal/compileServiceFile");
66
66
  var utils_2 = require("@sasjs/utils");
@@ -107,13 +107,13 @@ describe('compileServiceFile', function () {
107
107
  return __generator(this, function (_a) {
108
108
  switch (_a.label) {
109
109
  case 0:
110
- jest.spyOn(internalModule, 'getServiceInit').mockImplementation(function () {
110
+ jest.spyOn(internalModule, 'getInit').mockImplementation(function () {
111
111
  return Promise.resolve({
112
112
  content: "\n* ServiceInit start;\n" + fakeJobInit + "\n* ServiceInit end;",
113
113
  filePath: ''
114
114
  });
115
115
  });
116
- jest.spyOn(internalModule, 'getServiceTerm').mockImplementation(function () {
116
+ jest.spyOn(internalModule, 'getTerm').mockImplementation(function () {
117
117
  return Promise.resolve({
118
118
  content: "\n* ServiceTerm start;\n" + fakeJobTerm + "\n* ServiceTerm end;",
119
119
  filePath: ''