@sasjs/cli 3.10.1 → 3.12.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.
@@ -126,6 +126,11 @@ exports.angularAppFiles = {
126
126
  subFolders: []
127
127
  }
128
128
  ]
129
+ },
130
+ {
131
+ folderName: 'docs',
132
+ files: [{ fileName: 'index.html' }],
133
+ subFolders: []
129
134
  }
130
135
  ]
131
136
  };
@@ -140,6 +140,9 @@ describe('sasjs create', function () {
140
140
  _a.sent();
141
141
  return [4 /*yield*/, verifyCreateWeb('.', 'react')];
142
142
  case 4:
143
+ _a.sent();
144
+ return [4 /*yield*/, (0, test_1.verifyGitNotPresent)(process.projectDir)];
145
+ case 5:
143
146
  _a.sent();
144
147
  return [2 /*return*/];
145
148
  }
@@ -164,6 +167,9 @@ describe('sasjs create', function () {
164
167
  _a.sent();
165
168
  return [4 /*yield*/, verifyCreateWeb('test-react-app', 'react')];
166
169
  case 4:
170
+ _a.sent();
171
+ return [4 /*yield*/, (0, test_1.verifyGitNotPresent)(process.projectDir)];
172
+ case 5:
167
173
  _a.sent();
168
174
  return [2 /*return*/];
169
175
  }
@@ -212,6 +218,9 @@ describe('sasjs create', function () {
212
218
  _a.sent();
213
219
  return [4 /*yield*/, verifyCreateWeb('test-angular-app', 'angular')];
214
220
  case 4:
221
+ _a.sent();
222
+ return [4 /*yield*/, (0, test_1.verifyGitNotPresent)(process.projectDir)];
223
+ case 5:
215
224
  _a.sent();
216
225
  return [2 /*return*/];
217
226
  }
@@ -77,6 +77,17 @@ exports.reactAppFiles = {
77
77
  subFolders: []
78
78
  }
79
79
  ]
80
+ },
81
+ {
82
+ folderName: 'public',
83
+ files: [],
84
+ subFolders: [
85
+ {
86
+ folderName: 'docs',
87
+ files: [{ fileName: 'index.html' }],
88
+ subFolders: []
89
+ }
90
+ ]
80
91
  }
81
92
  ]
82
93
  };
@@ -330,11 +330,12 @@ function deployToSas9(deployScriptName, target, linesToExecute, logFolder, strea
330
330
  * Deploys app to `SASJS` server.
331
331
  * @param {Target} target- the target having deploy configuration.
332
332
  * @param {object} sasjs - optional configuration object of SAS adapter.
333
+ * @param {object} streamConfig - optional config for deploying streaming app.
333
334
  */
334
335
  function deployToSasjs(target, sasjs, streamConfig) {
335
336
  var _a, _b, _c;
336
337
  return __awaiter(this, void 0, void 0, function () {
337
- var buildDestinationFolder, finalFilePathJSON, jsonContent, payload, authConfig, e_2, result, appLoc, webAppStreamUrl;
338
+ var buildDestinationFolder, finalFilePathJSON, jsonContent, payload, authConfig, e_2, result, webAppStreamUrl;
338
339
  return __generator(this, function (_d) {
339
340
  switch (_d.label) {
340
341
  case 0:
@@ -363,7 +364,7 @@ function deployToSasjs(target, sasjs, streamConfig) {
363
364
  e_2 = _d.sent();
364
365
  return [3 /*break*/, 5];
365
366
  case 5: return [4 /*yield*/, sasjs
366
- .deployToSASjs(payload, undefined, authConfig)
367
+ .deployToSASjs(payload, undefined, streamConfig, authConfig)
367
368
  .catch(function (err) {
368
369
  var _a;
369
370
  (_a = process.logger) === null || _a === void 0 ? void 0 : _a.error(err);
@@ -376,9 +377,8 @@ function deployToSasjs(target, sasjs, streamConfig) {
376
377
  (_b = process.logger) === null || _b === void 0 ? void 0 : _b.info("Payload example:\n".concat(JSON.stringify(result.example, null, 2)));
377
378
  }
378
379
  }
379
- if (streamConfig === null || streamConfig === void 0 ? void 0 : streamConfig.streamWeb) {
380
- appLoc = encodeURI(target.appLoc);
381
- webAppStreamUrl = "".concat(target.serverUrl, "/AppStream").concat(appLoc);
380
+ if ((streamConfig === null || streamConfig === void 0 ? void 0 : streamConfig.streamWeb) && (result === null || result === void 0 ? void 0 : result.streamServiceName)) {
381
+ webAppStreamUrl = "".concat(target.serverUrl, "/AppStream/").concat(result.streamServiceName);
382
382
  (_c = process.logger) === null || _c === void 0 ? void 0 : _c.info("Web app is available at ".concat(webAppStreamUrl));
383
383
  }
384
384
  return [2 /*return*/];
@@ -78,7 +78,7 @@ describe('sasjs cbd with server type SASJS', function () {
78
78
  });
79
79
  }); });
80
80
  it("should deploy compile and build to sasjs/server", function () { return __awaiter(void 0, void 0, void 0, function () {
81
- var sasjs, customTarget, macroCorePath, mf_getuser, mp_jsonout, ms_webout, webout;
81
+ var sasjs, customTarget, macroCorePath, mf_getuser, mp_jsonout, ms_webout, webout, streamConfig;
82
82
  return __generator(this, function (_a) {
83
83
  switch (_a.label) {
84
84
  case 0:
@@ -125,6 +125,13 @@ describe('sasjs cbd with server type SASJS', function () {
125
125
  ' ,showmeta=&showmeta\n' +
126
126
  ' )' +
127
127
  ' %mend;\n';
128
+ streamConfig = {
129
+ assetPaths: [],
130
+ streamServiceName: 'clickme',
131
+ streamWeb: false,
132
+ streamWebFolder: '',
133
+ webSourcePath: ''
134
+ };
128
135
  expect(sasjs.deployToSASjs).toHaveBeenCalledWith({
129
136
  members: [
130
137
  {
@@ -152,7 +159,7 @@ describe('sasjs cbd with server type SASJS', function () {
152
159
  ]
153
160
  }
154
161
  ]
155
- }, undefined, undefined);
162
+ }, undefined, streamConfig, undefined);
156
163
  return [2 /*return*/];
157
164
  }
158
165
  });
@@ -223,8 +223,8 @@ function printHelpText() {
223
223
  "the user run a SAS job against a specified target.",
224
224
  "The target can exist either in the local project configuration or in the global .sasjsrc file.",
225
225
  "<sasProgramPath> - if this has a leading slash (eg /Public/app/folder/servicename) then it must be the full path. If it is a relative path (eg path/servicename) then it will be pre-pended with the appLoc - which must then be defined in the sasjs config.",
226
- "<path/to/log> - Location in which to store the log file. If not provided AND an error occurs, the log will be stored in the execution path.",
227
- "<path/to/output> - Location to store the output file. If not provided, a file named output.json will be saved in the execution path."
226
+ "<path/to/log> - Location in which to store the log file. If not provided AND current directory is a sasjs project, it will be saved in sasjsresults else in the current directory",
227
+ "<path/to/output> - Location to store the output file. If not provided AND current directory is a sasjs project, an output file will be saved in the sasjsresults folder else in current directory."
228
228
  ]
229
229
  },
230
230
  {
@@ -47,7 +47,6 @@ var displayResult_1 = require("../../utils/displayResult");
47
47
  var types_1 = require("@sasjs/utils/types");
48
48
  var utils_2 = require("../../utils/utils");
49
49
  var saveLog_1 = require("../../utils/saveLog");
50
- var getLogFilePath_1 = require("../../utils/getLogFilePath");
51
50
  function runSasJob(target, isLocal, sasJobLocation, dataFilePath, configFilePath, authConfig, logFile, jobPath, outputPathParam) {
52
51
  return __awaiter(this, void 0, void 0, function () {
53
52
  var dataJson, configJson, dataFile, configFile, sas9CredentialsError, sasjs, result;
@@ -150,7 +149,7 @@ function runSasJob(target, isLocal, sasJobLocation, dataFilePath, configFilePath
150
149
  output = res;
151
150
  }
152
151
  if (!!!output) return [3 /*break*/, 4];
153
- return [4 /*yield*/, writeOutput(outputPathParam, output, isLocal)];
152
+ return [4 /*yield*/, writeOutput(outputPathParam, output, sasJobLocation)];
154
153
  case 3:
155
154
  _a.sent();
156
155
  _a.label = 4;
@@ -193,20 +192,28 @@ function runSasJob(target, isLocal, sasJobLocation, dataFilePath, configFilePath
193
192
  }
194
193
  exports.runSasJob = runSasJob;
195
194
  var saveLogFile = function (sasjs, sasJobLocation, logFile, jobPath) { return __awaiter(void 0, void 0, void 0, function () {
196
- var sasRequests, currentRequestLog;
195
+ var sasRequests, currentRequestLog, logPath, timestamp, filename;
197
196
  return __generator(this, function (_a) {
198
197
  switch (_a.label) {
199
198
  case 0:
200
199
  sasRequests = sasjs.getSasRequests();
201
200
  currentRequestLog = sasRequests.find(function (x) { return x.serviceLink === sasJobLocation; });
202
- if (!(currentRequestLog && jobPath)) return [3 /*break*/, 2];
203
- if (!logFile)
204
- logFile = (0, getLogFilePath_1.getLogFilePath)('', jobPath || '');
205
- return [4 /*yield*/, (0, saveLog_1.saveLog)(currentRequestLog.logFile, logFile, jobPath || '', false)];
201
+ if (!(currentRequestLog && jobPath)) return [3 /*break*/, 4];
202
+ if (!!logFile) return [3 /*break*/, 2];
203
+ return [4 /*yield*/, (0, utils_2.isSASjsProject)()];
206
204
  case 1:
207
- _a.sent();
205
+ logPath = (_a.sent())
206
+ ? path_1.default.join(process.sasjsConstants.buildDestinationResultsFolder, 'requests')
207
+ : process.projectDir;
208
+ timestamp = (0, utils_1.generateTimestamp)();
209
+ filename = sasJobLocation.split(path_1.default.sep).pop();
210
+ logFile = path_1.default.join(logPath, "".concat(filename, "-").concat(timestamp, ".log"));
208
211
  _a.label = 2;
209
- case 2: return [2 /*return*/];
212
+ case 2: return [4 /*yield*/, (0, saveLog_1.saveLog)(currentRequestLog.logFile, logFile, jobPath || '', false)];
213
+ case 3:
214
+ _a.sent();
215
+ _a.label = 4;
216
+ case 4: return [2 /*return*/];
210
217
  }
211
218
  });
212
219
  }); };
@@ -214,15 +221,18 @@ var saveLogFile = function (sasjs, sasJobLocation, logFile, jobPath) { return __
214
221
  * Writes output to the file
215
222
  * @param outputPathParam path to output file
216
223
  * @param output data to be written to output file
217
- * @param isLocal is local target, othervise it is global
224
+ * @param sasJobLocation is used for output file name when outputPathParam is undefined
218
225
  * @returns output path for the file created
219
226
  */
220
- var writeOutput = function (outputPathParam, output, isLocal) { return __awaiter(void 0, void 0, void 0, function () {
221
- var outputPath, outputFilename, outputPathArr, outputString;
227
+ var writeOutput = function (outputPathParam, output, sasJobLocation) { return __awaiter(void 0, void 0, void 0, function () {
228
+ var outputPath, outputFilename, outputPathArr, timestamp, filename, outputString;
222
229
  return __generator(this, function (_a) {
223
230
  switch (_a.label) {
224
- case 0:
225
- outputPath = path_1.default.join(process.projectDir, isLocal ? '' : '');
231
+ case 0: return [4 /*yield*/, (0, utils_2.isSASjsProject)()];
232
+ case 1:
233
+ outputPath = (_a.sent())
234
+ ? path_1.default.join(process.sasjsConstants.buildDestinationResultsFolder, 'requests')
235
+ : process.projectDir;
226
236
  if (outputPathParam && typeof outputPathParam === 'string') {
227
237
  outputPathParam = path_1.default.join(process.projectDir, outputPathParam || '');
228
238
  outputPathArr = outputPathParam.split(path_1.default.sep);
@@ -230,18 +240,20 @@ var writeOutput = function (outputPathParam, output, isLocal) { return __awaiter
230
240
  outputPath = outputPathArr.join(path_1.default.sep);
231
241
  }
232
242
  return [4 /*yield*/, (0, utils_1.folderExists)(outputPath)];
233
- case 1:
234
- if (!!(_a.sent())) return [3 /*break*/, 3];
235
- return [4 /*yield*/, (0, utils_1.createFolder)(outputPath)];
236
243
  case 2:
237
- _a.sent();
238
- _a.label = 3;
244
+ if (!!(_a.sent())) return [3 /*break*/, 4];
245
+ return [4 /*yield*/, (0, utils_1.createFolder)(outputPath)];
239
246
  case 3:
247
+ _a.sent();
248
+ _a.label = 4;
249
+ case 4:
240
250
  if (outputFilename) {
241
251
  outputPath += "".concat(path_1.default.sep).concat(outputFilename);
242
252
  }
243
253
  else {
244
- outputPath += "".concat(path_1.default.sep, "output.json");
254
+ timestamp = (0, utils_1.generateTimestamp)();
255
+ filename = sasJobLocation.split(path_1.default.sep).pop();
256
+ outputPath += "".concat(path_1.default.sep).concat(filename, "-").concat(timestamp, ".json");
245
257
  }
246
258
  outputString = '';
247
259
  if (typeof output === 'object') {
@@ -256,16 +268,16 @@ var writeOutput = function (outputPathParam, output, isLocal) { return __awaiter
256
268
  else {
257
269
  outputString = output;
258
270
  }
259
- if (!outputString) return [3 /*break*/, 5];
271
+ if (!outputString) return [3 /*break*/, 6];
260
272
  return [4 /*yield*/, (0, utils_1.createFile)(outputPath, outputString)];
261
- case 4:
273
+ case 5:
262
274
  _a.sent();
263
275
  (0, displayResult_1.displaySuccess)("Request finished. Output is stored at '".concat(outputPath, "'"));
264
- return [3 /*break*/, 6];
265
- case 5:
276
+ return [3 /*break*/, 7];
277
+ case 6:
266
278
  (0, displayResult_1.displayError)("There was a problem with writing output file. Data not present.");
267
- _a.label = 6;
268
- case 6: return [2 /*return*/];
279
+ _a.label = 7;
280
+ case 7: return [2 /*return*/];
269
281
  }
270
282
  });
271
283
  }); };
@@ -10,6 +10,25 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || function (mod) {
26
+ if (mod && mod.__esModule) return mod;
27
+ var result = {};
28
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
+ __setModuleDefault(result, mod);
30
+ return result;
31
+ };
13
32
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
33
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
34
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -54,6 +73,7 @@ var path_1 = __importDefault(require("path"));
54
73
  var utils_1 = require("@sasjs/utils");
55
74
  var utils_2 = require("@sasjs/utils");
56
75
  var test_1 = require("../../../utils/test");
76
+ var timeStampUtils = __importStar(require("@sasjs/utils/time"));
57
77
  var config_1 = require("../../../utils/config");
58
78
  var request_1 = require("../request");
59
79
  var build_1 = require("../../build/build");
@@ -92,14 +112,17 @@ var expectedDataObj = {
92
112
  }
93
113
  ]
94
114
  };
95
- var getOutputJson = function () { return __awaiter(void 0, void 0, void 0, function () { var _a, _b; return __generator(this, function (_c) {
96
- switch (_c.label) {
97
- case 0:
98
- _b = (_a = JSON).parse;
99
- return [4 /*yield*/, (0, utils_1.readFile)(path_1.default.join(process.projectDir, 'output.json'))];
100
- case 1: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
101
- }
102
- }); }); };
115
+ var getOutputJson = function (fileName) { return __awaiter(void 0, void 0, void 0, function () {
116
+ var _a, _b;
117
+ return __generator(this, function (_c) {
118
+ switch (_c.label) {
119
+ case 0:
120
+ _b = (_a = JSON).parse;
121
+ return [4 /*yield*/, (0, utils_1.readFile)(path_1.default.join(process.sasjsConstants.buildDestinationResultsFolder, 'requests', fileName))];
122
+ case 1: return [2 /*return*/, _b.apply(_a, [_c.sent()])];
123
+ }
124
+ });
125
+ }); };
103
126
  describe('sasjs request without compute API', function () {
104
127
  var appName = 'cli-tests-request-' + (0, utils_2.generateTimestamp)();
105
128
  var target = (0, test_1.generateTestTarget)(appName, "/Public/app/cli-tests/".concat(appName), {
@@ -165,18 +188,24 @@ describe('sasjs request without compute API', function () {
165
188
  });
166
189
  }); });
167
190
  it("should execute service 'sendArr' with absolute path", function () { return __awaiter(void 0, void 0, void 0, function () {
168
- var _a, _b;
191
+ var timestamp, outputFilename, _a, _b;
169
192
  return __generator(this, function (_c) {
170
193
  switch (_c.label) {
171
- case 0: return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, "/Public/app/cli-tests/".concat(target.name, "/services/runRequest/sendArr"), dataPathRel, undefined, authConfig)).toResolve()];
194
+ case 0:
195
+ timestamp = (0, utils_2.generateTimestamp)();
196
+ jest
197
+ .spyOn(timeStampUtils, 'generateTimestamp')
198
+ .mockImplementationOnce(function () { return timestamp; });
199
+ outputFilename = "sendArr-".concat(timestamp, ".json");
200
+ return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, "/Public/app/cli-tests/".concat(target.name, "/services/runRequest/sendArr"), dataPathRel, undefined, authConfig)).toResolve()];
172
201
  case 1:
173
202
  _c.sent();
174
203
  _a = expect;
175
- return [4 /*yield*/, getOutputJson()];
204
+ return [4 /*yield*/, getOutputJson(outputFilename)];
176
205
  case 2:
177
206
  _a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataArr.table1);
178
207
  _b = expect;
179
- return [4 /*yield*/, getOutputJson()];
208
+ return [4 /*yield*/, getOutputJson(outputFilename)];
180
209
  case 3:
181
210
  _b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataArr.table2);
182
211
  return [2 /*return*/];
@@ -184,18 +213,24 @@ describe('sasjs request without compute API', function () {
184
213
  });
185
214
  }); });
186
215
  it("should execute service 'sendObj' with absolute path", function () { return __awaiter(void 0, void 0, void 0, function () {
187
- var _a, _b;
216
+ var timestamp, outputFilename, _a, _b;
188
217
  return __generator(this, function (_c) {
189
218
  switch (_c.label) {
190
- case 0: return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, "/Public/app/cli-tests/".concat(target.name, "/services/runRequest/sendObj"), dataPathRel, undefined, authConfig)).toResolve()];
219
+ case 0:
220
+ timestamp = (0, utils_2.generateTimestamp)();
221
+ jest
222
+ .spyOn(timeStampUtils, 'generateTimestamp')
223
+ .mockImplementationOnce(function () { return timestamp; });
224
+ outputFilename = "sendObj-".concat(timestamp, ".json");
225
+ return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, "/Public/app/cli-tests/".concat(target.name, "/services/runRequest/sendObj"), dataPathRel, undefined, authConfig)).toResolve()];
191
226
  case 1:
192
227
  _c.sent();
193
228
  _a = expect;
194
- return [4 /*yield*/, getOutputJson()];
229
+ return [4 /*yield*/, getOutputJson(outputFilename)];
195
230
  case 2:
196
231
  _a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataObj.table1);
197
232
  _b = expect;
198
- return [4 /*yield*/, getOutputJson()];
233
+ return [4 /*yield*/, getOutputJson(outputFilename)];
199
234
  case 3:
200
235
  _b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataObj.table2);
201
236
  return [2 /*return*/];
@@ -203,18 +238,24 @@ describe('sasjs request without compute API', function () {
203
238
  });
204
239
  }); });
205
240
  it("should execute service 'sendArr' with relative path", function () { return __awaiter(void 0, void 0, void 0, function () {
206
- var _a, _b;
241
+ var timestamp, outputFilename, _a, _b;
207
242
  return __generator(this, function (_c) {
208
243
  switch (_c.label) {
209
- case 0: return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, 'services/runRequest/sendArr', dataPathRel, undefined, authConfig)).toResolve()];
244
+ case 0:
245
+ timestamp = (0, utils_2.generateTimestamp)();
246
+ jest
247
+ .spyOn(timeStampUtils, 'generateTimestamp')
248
+ .mockImplementationOnce(function () { return timestamp; });
249
+ outputFilename = "sendArr-".concat(timestamp, ".json");
250
+ return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, 'services/runRequest/sendArr', dataPathRel, undefined, authConfig)).toResolve()];
210
251
  case 1:
211
252
  _c.sent();
212
253
  _a = expect;
213
- return [4 /*yield*/, getOutputJson()];
254
+ return [4 /*yield*/, getOutputJson(outputFilename)];
214
255
  case 2:
215
256
  _a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataArr.table1);
216
257
  _b = expect;
217
- return [4 /*yield*/, getOutputJson()];
258
+ return [4 /*yield*/, getOutputJson(outputFilename)];
218
259
  case 3:
219
260
  _b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataArr.table2);
220
261
  return [2 /*return*/];
@@ -222,18 +263,24 @@ describe('sasjs request without compute API', function () {
222
263
  });
223
264
  }); });
224
265
  it("should execute service 'sendObj' with relative path", function () { return __awaiter(void 0, void 0, void 0, function () {
225
- var _a, _b;
266
+ var timestamp, outputFilename, _a, _b;
226
267
  return __generator(this, function (_c) {
227
268
  switch (_c.label) {
228
- case 0: return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, 'services/runRequest/sendObj', dataPathRel, undefined, authConfig)).toResolve()];
269
+ case 0:
270
+ timestamp = (0, utils_2.generateTimestamp)();
271
+ jest
272
+ .spyOn(timeStampUtils, 'generateTimestamp')
273
+ .mockImplementationOnce(function () { return timestamp; });
274
+ outputFilename = "sendObj-".concat(timestamp, ".json");
275
+ return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, 'services/runRequest/sendObj', dataPathRel, undefined, authConfig)).toResolve()];
229
276
  case 1:
230
277
  _c.sent();
231
278
  _a = expect;
232
- return [4 /*yield*/, getOutputJson()];
279
+ return [4 /*yield*/, getOutputJson(outputFilename)];
233
280
  case 2:
234
281
  _a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataObj.table1);
235
282
  _b = expect;
236
- return [4 /*yield*/, getOutputJson()];
283
+ return [4 /*yield*/, getOutputJson(outputFilename)];
237
284
  case 3:
238
285
  _b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataObj.table2);
239
286
  return [2 /*return*/];
@@ -258,7 +305,7 @@ describe('sasjs request without compute API', function () {
258
305
  });
259
306
  }); });
260
307
  it("should execute service 'err' with absolute path with log path", function () { return __awaiter(void 0, void 0, void 0, function () {
261
- var jobPath, log, rawLogDataStats, rawDataStats;
308
+ var jobPath, log, rawLogDataStats;
262
309
  return __generator(this, function (_a) {
263
310
  switch (_a.label) {
264
311
  case 0:
@@ -268,15 +315,13 @@ describe('sasjs request without compute API', function () {
268
315
  case 1:
269
316
  _a.sent();
270
317
  rawLogDataStats = (0, fs_1.statSync)(log);
271
- rawDataStats = (0, fs_1.statSync)(path_1.default.join(process.projectDir, 'output.json'));
272
318
  expect(rawLogDataStats.size).toBeGreaterThan(10);
273
- expect(rawDataStats.size).toBeGreaterThan(10);
274
319
  return [2 /*return*/];
275
320
  }
276
321
  });
277
322
  }); });
278
323
  it("should execute service 'err' with absolute path with default log path", function () { return __awaiter(void 0, void 0, void 0, function () {
279
- var jobPath, log, rawLogDataStats, rawDataStats;
324
+ var jobPath, log, rawLogDataStats;
280
325
  return __generator(this, function (_a) {
281
326
  switch (_a.label) {
282
327
  case 0:
@@ -286,9 +331,7 @@ describe('sasjs request without compute API', function () {
286
331
  case 1:
287
332
  _a.sent();
288
333
  rawLogDataStats = (0, fs_1.statSync)(log);
289
- rawDataStats = (0, fs_1.statSync)(path_1.default.join(process.projectDir, 'output.json'));
290
334
  expect(rawLogDataStats.size).toBeGreaterThan(10);
291
- expect(rawDataStats.size).toBeGreaterThan(10);
292
335
  return [2 /*return*/];
293
336
  }
294
337
  });
@@ -355,18 +398,24 @@ describe('sasjs request with SAS9', function () {
355
398
  });
356
399
  }); });
357
400
  it("should execute service 'sendArr' with absolute path", function () { return __awaiter(void 0, void 0, void 0, function () {
358
- var _a, _b;
401
+ var timestamp, outputFilename, _a, _b;
359
402
  return __generator(this, function (_c) {
360
403
  switch (_c.label) {
361
- case 0: return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, "/Public/app/cli-tests/".concat(target.name, "/services/runRequest/sendArr"), dataPathRel)).toResolve()];
404
+ case 0:
405
+ timestamp = (0, utils_2.generateTimestamp)();
406
+ jest
407
+ .spyOn(timeStampUtils, 'generateTimestamp')
408
+ .mockImplementationOnce(function () { return timestamp; });
409
+ outputFilename = "sendArr-".concat(timestamp, ".json");
410
+ return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, "/Public/app/cli-tests/".concat(target.name, "/services/runRequest/sendArr"), dataPathRel)).toResolve()];
362
411
  case 1:
363
412
  _c.sent();
364
413
  _a = expect;
365
- return [4 /*yield*/, getOutputJson()];
414
+ return [4 /*yield*/, getOutputJson(outputFilename)];
366
415
  case 2:
367
416
  _a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataArr.table1);
368
417
  _b = expect;
369
- return [4 /*yield*/, getOutputJson()];
418
+ return [4 /*yield*/, getOutputJson(outputFilename)];
370
419
  case 3:
371
420
  _b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataArr.table2);
372
421
  return [2 /*return*/];
@@ -374,18 +423,24 @@ describe('sasjs request with SAS9', function () {
374
423
  });
375
424
  }); });
376
425
  it("should execute service 'sendObj' with absolute path", function () { return __awaiter(void 0, void 0, void 0, function () {
377
- var _a, _b;
426
+ var timestamp, outputFilename, _a, _b;
378
427
  return __generator(this, function (_c) {
379
428
  switch (_c.label) {
380
- case 0: return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, "/Public/app/cli-tests/".concat(target.name, "/services/runRequest/sendObj"), dataPathRel)).toResolve()];
429
+ case 0:
430
+ timestamp = (0, utils_2.generateTimestamp)();
431
+ jest
432
+ .spyOn(timeStampUtils, 'generateTimestamp')
433
+ .mockImplementationOnce(function () { return timestamp; });
434
+ outputFilename = "sendObj-".concat(timestamp, ".json");
435
+ return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, "/Public/app/cli-tests/".concat(target.name, "/services/runRequest/sendObj"), dataPathRel)).toResolve()];
381
436
  case 1:
382
437
  _c.sent();
383
438
  _a = expect;
384
- return [4 /*yield*/, getOutputJson()];
439
+ return [4 /*yield*/, getOutputJson(outputFilename)];
385
440
  case 2:
386
441
  _a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataObj.table1);
387
442
  _b = expect;
388
- return [4 /*yield*/, getOutputJson()];
443
+ return [4 /*yield*/, getOutputJson(outputFilename)];
389
444
  case 3:
390
445
  _b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataObj.table2);
391
446
  return [2 /*return*/];
@@ -393,18 +448,24 @@ describe('sasjs request with SAS9', function () {
393
448
  });
394
449
  }); });
395
450
  it("should execute service 'sendArr' with relative path", function () { return __awaiter(void 0, void 0, void 0, function () {
396
- var _a, _b;
451
+ var timestamp, outputFilename, _a, _b;
397
452
  return __generator(this, function (_c) {
398
453
  switch (_c.label) {
399
- case 0: return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, 'services/runRequest/sendArr', dataPathRel)).toResolve()];
454
+ case 0:
455
+ timestamp = (0, utils_2.generateTimestamp)();
456
+ jest
457
+ .spyOn(timeStampUtils, 'generateTimestamp')
458
+ .mockImplementationOnce(function () { return timestamp; });
459
+ outputFilename = "sendArr-".concat(timestamp, ".json");
460
+ return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, 'services/runRequest/sendArr', dataPathRel)).toResolve()];
400
461
  case 1:
401
462
  _c.sent();
402
463
  _a = expect;
403
- return [4 /*yield*/, getOutputJson()];
464
+ return [4 /*yield*/, getOutputJson(outputFilename)];
404
465
  case 2:
405
466
  _a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataArr.table1);
406
467
  _b = expect;
407
- return [4 /*yield*/, getOutputJson()];
468
+ return [4 /*yield*/, getOutputJson(outputFilename)];
408
469
  case 3:
409
470
  _b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataArr.table2);
410
471
  return [2 /*return*/];
@@ -412,18 +473,24 @@ describe('sasjs request with SAS9', function () {
412
473
  });
413
474
  }); });
414
475
  it("should execute service 'sendObj' with relative path", function () { return __awaiter(void 0, void 0, void 0, function () {
415
- var _a, _b;
476
+ var timestamp, outputFilename, _a, _b;
416
477
  return __generator(this, function (_c) {
417
478
  switch (_c.label) {
418
- case 0: return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, 'services/runRequest/sendObj', dataPathRel)).toResolve()];
479
+ case 0:
480
+ timestamp = (0, utils_2.generateTimestamp)();
481
+ jest
482
+ .spyOn(timeStampUtils, 'generateTimestamp')
483
+ .mockImplementationOnce(function () { return timestamp; });
484
+ outputFilename = "sendObj-".concat(timestamp, ".json");
485
+ return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, 'services/runRequest/sendObj', dataPathRel)).toResolve()];
419
486
  case 1:
420
487
  _c.sent();
421
488
  _a = expect;
422
- return [4 /*yield*/, getOutputJson()];
489
+ return [4 /*yield*/, getOutputJson(outputFilename)];
423
490
  case 2:
424
491
  _a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataObj.table1);
425
492
  _b = expect;
426
- return [4 /*yield*/, getOutputJson()];
493
+ return [4 /*yield*/, getOutputJson(outputFilename)];
427
494
  case 3:
428
495
  _b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataObj.table2);
429
496
  return [2 /*return*/];
@@ -448,7 +515,7 @@ describe('sasjs request with SAS9', function () {
448
515
  });
449
516
  }); });
450
517
  it("should execute service 'err' with absolute path with log path", function () { return __awaiter(void 0, void 0, void 0, function () {
451
- var jobPath, log, rawLogDataStats, rawDataStats;
518
+ var jobPath, log, rawLogDataStats;
452
519
  return __generator(this, function (_a) {
453
520
  switch (_a.label) {
454
521
  case 0:
@@ -458,15 +525,13 @@ describe('sasjs request with SAS9', function () {
458
525
  case 1:
459
526
  _a.sent();
460
527
  rawLogDataStats = (0, fs_1.statSync)(log);
461
- rawDataStats = (0, fs_1.statSync)(path_1.default.join(process.projectDir, 'output.json'));
462
528
  expect(rawLogDataStats.size).toBeGreaterThan(10);
463
- expect(rawDataStats.size).toBeGreaterThan(10);
464
529
  return [2 /*return*/];
465
530
  }
466
531
  });
467
532
  }); });
468
533
  it("should execute service 'err' with absolute path with default log path", function () { return __awaiter(void 0, void 0, void 0, function () {
469
- var jobPath, log, rawLogDataStats, rawDataStats;
534
+ var jobPath, log, rawLogDataStats;
470
535
  return __generator(this, function (_a) {
471
536
  switch (_a.label) {
472
537
  case 0:
@@ -476,9 +541,7 @@ describe('sasjs request with SAS9', function () {
476
541
  case 1:
477
542
  _a.sent();
478
543
  rawLogDataStats = (0, fs_1.statSync)(log);
479
- rawDataStats = (0, fs_1.statSync)(path_1.default.join(process.projectDir, 'output.json'));
480
544
  expect(rawLogDataStats.size).toBeGreaterThan(10);
481
- expect(rawDataStats.size).toBeGreaterThan(10);
482
545
  return [2 /*return*/];
483
546
  }
484
547
  });
@@ -544,18 +607,24 @@ describe("sasjs request with compute API", function () {
544
607
  });
545
608
  }); });
546
609
  it("should execute service 'sendArr' with absolute path", function () { return __awaiter(void 0, void 0, void 0, function () {
547
- var _a, _b;
610
+ var timestamp, outputFilename, _a, _b;
548
611
  return __generator(this, function (_c) {
549
612
  switch (_c.label) {
550
- case 0: return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, "/Public/app/cli-tests/".concat(target.name, "/services/runRequest/sendArr"), dataPathRel, configPathRel, authConfig)).toResolve()];
613
+ case 0:
614
+ timestamp = (0, utils_2.generateTimestamp)();
615
+ jest
616
+ .spyOn(timeStampUtils, 'generateTimestamp')
617
+ .mockImplementationOnce(function () { return timestamp; });
618
+ outputFilename = "sendArr-".concat(timestamp, ".json");
619
+ return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, "/Public/app/cli-tests/".concat(target.name, "/services/runRequest/sendArr"), dataPathRel, configPathRel, authConfig)).toResolve()];
551
620
  case 1:
552
621
  _c.sent();
553
622
  _a = expect;
554
- return [4 /*yield*/, getOutputJson()];
623
+ return [4 /*yield*/, getOutputJson(outputFilename)];
555
624
  case 2:
556
625
  _a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataArr.table1);
557
626
  _b = expect;
558
- return [4 /*yield*/, getOutputJson()];
627
+ return [4 /*yield*/, getOutputJson(outputFilename)];
559
628
  case 3:
560
629
  _b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataArr.table2);
561
630
  return [2 /*return*/];
@@ -563,18 +632,24 @@ describe("sasjs request with compute API", function () {
563
632
  });
564
633
  }); });
565
634
  it("should execute service 'sendObj' with absolute path", function () { return __awaiter(void 0, void 0, void 0, function () {
566
- var _a, _b;
635
+ var timestamp, outputFilename, _a, _b;
567
636
  return __generator(this, function (_c) {
568
637
  switch (_c.label) {
569
- case 0: return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, "/Public/app/cli-tests/".concat(target.name, "/services/runRequest/sendObj"), dataPathRel, configPathRel, authConfig)).toResolve()];
638
+ case 0:
639
+ timestamp = (0, utils_2.generateTimestamp)();
640
+ jest
641
+ .spyOn(timeStampUtils, 'generateTimestamp')
642
+ .mockImplementationOnce(function () { return timestamp; });
643
+ outputFilename = "sendObj-".concat(timestamp, ".json");
644
+ return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, "/Public/app/cli-tests/".concat(target.name, "/services/runRequest/sendObj"), dataPathRel, configPathRel, authConfig)).toResolve()];
570
645
  case 1:
571
646
  _c.sent();
572
647
  _a = expect;
573
- return [4 /*yield*/, getOutputJson()];
648
+ return [4 /*yield*/, getOutputJson(outputFilename)];
574
649
  case 2:
575
650
  _a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataObj.table1);
576
651
  _b = expect;
577
- return [4 /*yield*/, getOutputJson()];
652
+ return [4 /*yield*/, getOutputJson(outputFilename)];
578
653
  case 3:
579
654
  _b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataObj.table2);
580
655
  return [2 /*return*/];
@@ -582,18 +657,24 @@ describe("sasjs request with compute API", function () {
582
657
  });
583
658
  }); });
584
659
  it("should execute service 'sendArr' with relative path", function () { return __awaiter(void 0, void 0, void 0, function () {
585
- var _a, _b;
660
+ var timestamp, outputFilename, _a, _b;
586
661
  return __generator(this, function (_c) {
587
662
  switch (_c.label) {
588
- case 0: return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, 'services/runRequest/sendArr', dataPathRel, undefined, authConfig)).toResolve()];
663
+ case 0:
664
+ timestamp = (0, utils_2.generateTimestamp)();
665
+ jest
666
+ .spyOn(timeStampUtils, 'generateTimestamp')
667
+ .mockImplementationOnce(function () { return timestamp; });
668
+ outputFilename = "sendArr-".concat(timestamp, ".json");
669
+ return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, 'services/runRequest/sendArr', dataPathRel, undefined, authConfig)).toResolve()];
589
670
  case 1:
590
671
  _c.sent();
591
672
  _a = expect;
592
- return [4 /*yield*/, getOutputJson()];
673
+ return [4 /*yield*/, getOutputJson(outputFilename)];
593
674
  case 2:
594
675
  _a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataArr.table1);
595
676
  _b = expect;
596
- return [4 /*yield*/, getOutputJson()];
677
+ return [4 /*yield*/, getOutputJson(outputFilename)];
597
678
  case 3:
598
679
  _b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataArr.table2);
599
680
  return [2 /*return*/];
@@ -601,18 +682,24 @@ describe("sasjs request with compute API", function () {
601
682
  });
602
683
  }); });
603
684
  it("should execute service 'sendObj' with relative path", function () { return __awaiter(void 0, void 0, void 0, function () {
604
- var _a, _b;
685
+ var timestamp, outputFilename, _a, _b;
605
686
  return __generator(this, function (_c) {
606
687
  switch (_c.label) {
607
- case 0: return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, 'services/runRequest/sendObj', dataPathRel, undefined, authConfig)).toResolve()];
688
+ case 0:
689
+ timestamp = (0, utils_2.generateTimestamp)();
690
+ jest
691
+ .spyOn(timeStampUtils, 'generateTimestamp')
692
+ .mockImplementationOnce(function () { return timestamp; });
693
+ outputFilename = "sendObj-".concat(timestamp, ".json");
694
+ return [4 /*yield*/, expect((0, request_1.runSasJob)(target, false, 'services/runRequest/sendObj', dataPathRel, undefined, authConfig)).toResolve()];
608
695
  case 1:
609
696
  _c.sent();
610
697
  _a = expect;
611
- return [4 /*yield*/, getOutputJson()];
698
+ return [4 /*yield*/, getOutputJson(outputFilename)];
612
699
  case 2:
613
700
  _a.apply(void 0, [(_c.sent()).table1]).toEqual(expectedDataObj.table1);
614
701
  _b = expect;
615
- return [4 /*yield*/, getOutputJson()];
702
+ return [4 /*yield*/, getOutputJson(outputFilename)];
616
703
  case 3:
617
704
  _b.apply(void 0, [(_c.sent()).table2]).toEqual(expectedDataObj.table2);
618
705
  return [2 /*return*/];
@@ -122,7 +122,7 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
122
122
  flow = [];
123
123
  if (testFlow.testSetUp)
124
124
  flow.push(testFlow.testSetUp);
125
- if (testFlow.tests)
125
+ if (testFlow.tests) {
126
126
  flow = __spreadArray(__spreadArray([], __read(flow), false), __read(testFlow.tests.filter(function (test) {
127
127
  var e_2, _a;
128
128
  if (!testRegExps.length)
@@ -144,6 +144,7 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
144
144
  }
145
145
  return match;
146
146
  })), false);
147
+ }
147
148
  if (testFlow.testTearDown)
148
149
  flow.push(testFlow.testTearDown);
149
150
  sasjs = (0, createSASjsInstance_1.createSASjsInstance)({
@@ -190,7 +191,8 @@ function runTest(target, testRegExps, outDirectory, flowSourcePath) {
190
191
  case 7:
191
192
  e_1 = _e.sent();
192
193
  return [3 /*break*/, 8];
193
- case 8: return [3 /*break*/, 9];
194
+ case 8: // FIXME: handle error properly
195
+ return [3 /*break*/, 9];
194
196
  case 9:
195
197
  result = {
196
198
  sasjs_test_meta: []
@@ -686,11 +686,10 @@ function getMacroFolders(target) {
686
686
  return [4 /*yield*/, getLocalOrGlobalConfig()];
687
687
  case 1:
688
688
  localConfig = (_a.sent()).configuration;
689
+ if (target === null || target === void 0 ? void 0 : target.macroFolders)
690
+ macroFolders = target.macroFolders;
689
691
  if (localConfig === null || localConfig === void 0 ? void 0 : localConfig.macroFolders) {
690
- macroFolders = localConfig.macroFolders;
691
- }
692
- if (target === null || target === void 0 ? void 0 : target.macroFolders) {
693
- macroFolders = target.macroFolders.concat(macroFolders);
692
+ macroFolders = localConfig.macroFolders.concat(macroFolders);
694
693
  }
695
694
  buildSourceFolder = process.sasjsConstants.buildSourceFolder;
696
695
  macroFolders = macroFolders.map(function (macroFolder) {
@@ -21,3 +21,4 @@ export declare const verifyDotFiles: (docsFolder: string) => Promise<void>;
21
21
  export declare const verifyDotFilesNotGenerated: (docsFolder: string) => Promise<void>;
22
22
  export declare const verifyCompiledService: (compiledContent: string, macrosToTest: string[], checkInit?: boolean, checkTerm?: boolean) => Promise<void>;
23
23
  export declare const verifyCompiledJob: (compiledContent: string, macrosToTest: string[], checkInit?: boolean, checkTerm?: boolean) => Promise<void>;
24
+ export declare const verifyGitNotPresent: (folder: string) => Promise<void>;
@@ -50,7 +50,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
50
50
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
51
  };
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
- exports.verifyCompiledJob = exports.verifyCompiledService = exports.verifyDotFilesNotGenerated = exports.verifyDotFiles = exports.verifyDocs = exports.updateConfig = exports.updateTarget = exports.removeAllTargetsFromConfigs = exports.verifyPackageJsonContent = exports.verifyFolder = exports.mockProcessExit = exports.verifyStep = exports.createTestGlobalTarget = exports.generateTestTarget = exports.removeTestServerFolder = exports.removeTestApp = exports.createTestMinimalApp = exports.createTestJobsApp = exports.createTestApp = void 0;
53
+ exports.verifyGitNotPresent = exports.verifyCompiledJob = exports.verifyCompiledService = exports.verifyDotFilesNotGenerated = exports.verifyDotFiles = exports.verifyDocs = exports.updateConfig = exports.updateTarget = exports.removeAllTargetsFromConfigs = exports.verifyPackageJsonContent = exports.verifyFolder = exports.mockProcessExit = exports.verifyStep = exports.createTestGlobalTarget = exports.generateTestTarget = exports.removeTestServerFolder = exports.removeTestApp = exports.createTestMinimalApp = exports.createTestJobsApp = exports.createTestApp = void 0;
54
54
  var path_1 = __importDefault(require("path"));
55
55
  var dotenv_1 = __importDefault(require("dotenv"));
56
56
  var utils_1 = require("@sasjs/utils");
@@ -629,3 +629,20 @@ var verifyCompile = function (compiledContent, macrosToTest, checkInit, checkTer
629
629
  return [2 /*return*/];
630
630
  });
631
631
  }); };
632
+ var verifyGitNotPresent = function (folder) { return __awaiter(void 0, void 0, void 0, function () {
633
+ var gitFolderOrModules;
634
+ return __generator(this, function (_a) {
635
+ switch (_a.label) {
636
+ case 0: return [4 /*yield*/, (0, utils_1.listFilesAndSubFoldersInFolder)(folder, true)];
637
+ case 1:
638
+ gitFolderOrModules = (_a.sent()).filter(function (sub) {
639
+ return /\.git$/.test(sub) ||
640
+ new RegExp(".git".concat(utils_1.pathSepEscaped)).test(sub) ||
641
+ /\.gitmodules/.test(sub);
642
+ });
643
+ expect(gitFolderOrModules.length).toEqual(0);
644
+ return [2 /*return*/];
645
+ }
646
+ });
647
+ }); };
648
+ exports.verifyGitNotPresent = verifyGitNotPresent;
@@ -35,3 +35,11 @@ export declare function displaySasjsRunnerError(username: string): void;
35
35
  export declare const loadEnvVariables: (fileName: string) => Promise<void>;
36
36
  export declare function prefixAppLoc(appLoc?: string, path?: string): string | null;
37
37
  export declare const terminateProcess: (status: number) => never;
38
+ /**
39
+ * This function checks whether the current directory, or any of the parent
40
+ * directories, are part of a SASjs project. This is done by testing for
41
+ * the existence of a ./sasjs/sasjsconfig.json file.
42
+ *
43
+ * @returns boolean
44
+ */
45
+ export declare const isSASjsProject: () => Promise<boolean>;
@@ -86,7 +86,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
86
86
  return (mod && mod.__esModule) ? mod : { "default": mod };
87
87
  };
88
88
  Object.defineProperty(exports, "__esModule", { value: true });
89
- exports.terminateProcess = exports.prefixAppLoc = exports.loadEnvVariables = exports.displaySasjsRunnerError = exports.getAdapterInstance = exports.checkNodeVersion = exports.millisecondsToDdHhMmSs = exports.arrToObj = exports.parseLogLines = exports.executeShellScript = exports.getUniqServicesObj = exports.removeComments = exports.setupDoxygen = exports.setupGhooks = exports.setupGitIgnore = exports.setupNpmProject = exports.createTemplateApp = exports.createMinimalApp = exports.createAngularApp = exports.createReactApp = exports.diff = exports.inExistingProject = void 0;
89
+ exports.isSASjsProject = exports.terminateProcess = exports.prefixAppLoc = exports.loadEnvVariables = exports.displaySasjsRunnerError = exports.getAdapterInstance = exports.checkNodeVersion = exports.millisecondsToDdHhMmSs = exports.arrToObj = exports.parseLogLines = exports.executeShellScript = exports.getUniqServicesObj = exports.removeComments = exports.setupDoxygen = exports.setupGhooks = exports.setupGitIgnore = exports.setupNpmProject = exports.createTemplateApp = exports.createMinimalApp = exports.createAngularApp = exports.createReactApp = exports.diff = exports.inExistingProject = void 0;
90
90
  var shelljs_1 = __importDefault(require("shelljs"));
91
91
  var path_1 = __importDefault(require("path"));
92
92
  var ora_1 = __importDefault(require("ora"));
@@ -191,8 +191,19 @@ function createApp(folderPath, repoUrl, installDependencies) {
191
191
  var spinner = (0, ora_1.default)("Creating SASjs project in ".concat(folderPath, "."));
192
192
  spinner.start();
193
193
  var gitBranch = repoUrl.includes('template_sasonly') ? 'master' : 'main';
194
- shelljs_1.default.exec("cd \"".concat(folderPath, "\" && git clone --depth 1 -b ").concat(gitBranch, " ").concat(repoUrl, " ."), { silent: true });
195
- shelljs_1.default.rm('-rf', path_1.default.join(folderPath, '.git'));
194
+ var gitVersion = (shelljs_1.default
195
+ .exec("git version", { silent: true })
196
+ .stdout.match(/(?<!git version)\d+\.\d+\.\d+/) || '')[0].replace(/\./g, '');
197
+ // NOTE: git version 2.13 and greater are using '--recurse-submodules' instead of '--recurse' attribute to clone submodules
198
+ shelljs_1.default.exec("cd \"".concat(folderPath, "\" && git clone --recurse").concat(parseInt(gitVersion) > 2130 ? '-submodules' : '', " --depth 1 -b ").concat(gitBranch, " ").concat(repoUrl, " ."), { silent: true });
199
+ deleteGitFolder(folderPath);
200
+ shelljs_1.default.rm('-f', [path_1.default.join(folderPath, '.gitmodules')]);
201
+ if (repoUrl.includes('react-seed-app')) {
202
+ deleteGitFolder(path_1.default.join(folderPath, 'public', 'docs'));
203
+ }
204
+ else if (repoUrl.includes('angular-seed-app')) {
205
+ deleteGitFolder(path_1.default.join(folderPath, 'docs'));
206
+ }
196
207
  spinner.stop();
197
208
  if (installDependencies) {
198
209
  spinner.text = 'Installing dependencies...';
@@ -203,6 +214,9 @@ function createApp(folderPath, repoUrl, installDependencies) {
203
214
  spinner.stop();
204
215
  }
205
216
  }
217
+ var deleteGitFolder = function (folderPath) {
218
+ return shelljs_1.default.rm('-rf', path_1.default.join(folderPath, '.git'));
219
+ };
206
220
  function setupNpmProject(folderName) {
207
221
  return __awaiter(this, void 0, void 0, function () {
208
222
  var folderPath;
@@ -241,7 +255,7 @@ exports.setupNpmProject = setupNpmProject;
241
255
  function setupGitIgnore(folderName) {
242
256
  var _a, _b;
243
257
  return __awaiter(this, void 0, void 0, function () {
244
- var gitIgnoreFilePath, gitIgnoreExists, gitIgnoreContent, newgitIgnoreContent, regExpSasjsBuild, regExpSasjsResults, regExpNodeModules, folderPath, gitDirectoryExists;
258
+ var gitIgnoreFilePath, gitIgnoreExists, gitIgnoreContent, newgitIgnoreContent, regExpSasjsBuild, regExpSasjsResults, regExpNodeModules;
245
259
  return __generator(this, function (_c) {
246
260
  switch (_c.label) {
247
261
  case 0:
@@ -278,17 +292,7 @@ function setupGitIgnore(folderName) {
278
292
  _c.sent();
279
293
  (_b = process.logger) === null || _b === void 0 ? void 0 : _b.success('.gitignore file has been created.');
280
294
  _c.label = 7;
281
- case 7:
282
- folderPath = path_1.default.join(process.projectDir, folderName);
283
- return [4 /*yield*/, (0, utils_1.folderExists)(path_1.default.join(folderPath, '.git'))];
284
- case 8:
285
- gitDirectoryExists = _c.sent();
286
- if (!gitDirectoryExists) {
287
- shelljs_1.default.exec("cd ".concat(folderName, " && git init"), {
288
- silent: true
289
- });
290
- }
291
- return [2 /*return*/];
295
+ case 7: return [2 /*return*/];
292
296
  }
293
297
  });
294
298
  });
@@ -561,3 +565,43 @@ var terminateProcess = function (status) {
561
565
  process.exit(status);
562
566
  };
563
567
  exports.terminateProcess = terminateProcess;
568
+ /**
569
+ * This function checks whether the current directory, or any of the parent
570
+ * directories, are part of a SASjs project. This is done by testing for
571
+ * the existence of a ./sasjs/sasjsconfig.json file.
572
+ *
573
+ * @returns boolean
574
+ */
575
+ var isSASjsProject = function () { return __awaiter(void 0, void 0, void 0, function () {
576
+ var i, currentLocation, maxLevels, _a;
577
+ return __generator(this, function (_b) {
578
+ switch (_b.label) {
579
+ case 0:
580
+ i = 1;
581
+ currentLocation = process.projectDir;
582
+ maxLevels = currentLocation.split(path_1.default.sep).length;
583
+ _b.label = 1;
584
+ case 1:
585
+ if (!(i <= maxLevels)) return [3 /*break*/, 5];
586
+ return [4 /*yield*/, (0, utils_1.folderExists)(path_1.default.join(currentLocation, 'sasjs'))];
587
+ case 2:
588
+ _a = (_b.sent());
589
+ if (!_a) return [3 /*break*/, 4];
590
+ return [4 /*yield*/, (0, utils_1.fileExists)(path_1.default.join(currentLocation, 'sasjs', 'sasjsconfig.json'))];
591
+ case 3:
592
+ _a = (_b.sent());
593
+ _b.label = 4;
594
+ case 4:
595
+ if (_a) {
596
+ return [2 /*return*/, true];
597
+ }
598
+ else {
599
+ currentLocation = path_1.default.join(currentLocation, '..');
600
+ i++;
601
+ }
602
+ return [3 /*break*/, 1];
603
+ case 5: return [2 /*return*/, false];
604
+ }
605
+ });
606
+ }); };
607
+ exports.isSASjsProject = isSASjsProject;
package/package.json CHANGED
@@ -47,10 +47,10 @@
47
47
  "access": "public"
48
48
  },
49
49
  "dependencies": {
50
- "@sasjs/adapter": "^3.7.14",
50
+ "@sasjs/adapter": "3.8.0",
51
51
  "@sasjs/core": "4.15.3",
52
52
  "@sasjs/lint": "1.11.2",
53
- "@sasjs/utils": "2.39.0",
53
+ "@sasjs/utils": "2.40.0",
54
54
  "chalk": "4.1.2",
55
55
  "csv-stringify": "5.6.5",
56
56
  "dotenv": "10.0.0",
@@ -94,5 +94,5 @@
94
94
  "typescript": "4.5.4",
95
95
  "util": "0.12.4"
96
96
  },
97
- "version": "3.10.1"
97
+ "version": "3.12.0"
98
98
  }