@sasjs/cli 6.4.8 → 6.6.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.
- package/README.md +1 -0
- package/build/commands/build/build.js +66 -29
- package/build/commands/build/buildDeployCommand.d.ts +6 -0
- package/build/commands/build/buildDeployCommand.js +120 -0
- package/build/commands/build/spec/build.spec.js +31 -1
- package/build/commands/build/spec/buildDeployCommand.spec.d.ts +1 -0
- package/build/commands/build/spec/buildDeployCommand.spec.js +234 -0
- package/build/commands/compile/compile.js +168 -33
- package/build/commands/compile/compileCommand.js +1 -1
- package/build/commands/compile/internal/checkCompileStatus.js +30 -11
- package/build/commands/compile/internal/compileFile.js +16 -7
- package/build/commands/compile/internal/compileManifest.d.ts +36 -0
- package/build/commands/compile/internal/compileManifest.js +610 -0
- package/build/commands/compile/internal/index.d.ts +2 -0
- package/build/commands/compile/internal/index.js +2 -0
- package/build/commands/compile/internal/passThrough.d.ts +12 -0
- package/build/commands/compile/internal/passThrough.js +17 -0
- package/build/commands/compile/internal/spec/compileTestFile.spec.js +9 -6
- package/build/commands/compile/spec/checkCompileStatus.spec.d.ts +1 -0
- package/build/commands/compile/spec/checkCompileStatus.spec.js +221 -0
- package/build/commands/compile/spec/compileCommand.spec.js +9 -2
- package/build/commands/compile/spec/compileManifest.spec.d.ts +1 -0
- package/build/commands/compile/spec/compileManifest.spec.js +401 -0
- package/build/commands/compile/spec/passThrough.spec.d.ts +1 -0
- package/build/commands/compile/spec/passThrough.spec.js +160 -0
- package/build/commands/deploy/spec/cbd.spec.js +11 -7
- package/build/commands/help/help.js +11 -0
- package/build/commands/testing/spec/testCommand.spec.js +12 -0
- package/build/commands/testing/spec/testing.spec.js +8 -2
- package/build/commands/testing/testCommand.js +3 -1
- package/build/types/command/commandAliases.js +2 -0
- package/build/types/command/commandFactory.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,610 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
+
if (!m) return o;
|
|
41
|
+
var i = m.call(o), r, ar = [], e;
|
|
42
|
+
try {
|
|
43
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
+
}
|
|
45
|
+
catch (error) { e = { error: error }; }
|
|
46
|
+
finally {
|
|
47
|
+
try {
|
|
48
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
+
}
|
|
50
|
+
finally { if (e) throw e.error; }
|
|
51
|
+
}
|
|
52
|
+
return ar;
|
|
53
|
+
};
|
|
54
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
55
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
56
|
+
if (ar || !(i in from)) {
|
|
57
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
58
|
+
ar[i] = from[i];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
62
|
+
};
|
|
63
|
+
var __values = (this && this.__values) || function(o) {
|
|
64
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
65
|
+
if (m) return m.call(o);
|
|
66
|
+
if (o && typeof o.length === "number") return {
|
|
67
|
+
next: function () {
|
|
68
|
+
if (o && i >= o.length) o = void 0;
|
|
69
|
+
return { value: o && o[i++], done: !o };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
73
|
+
};
|
|
74
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
75
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
76
|
+
};
|
|
77
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
78
|
+
exports.getManifestStamps = exports.getManifestFolders = exports.getChangedFiles = exports.readCompileManifest = exports.writeCompileManifest = exports.getManifestPath = void 0;
|
|
79
|
+
var path_1 = __importDefault(require("path"));
|
|
80
|
+
var crypto_1 = require("crypto");
|
|
81
|
+
var promises_1 = require("fs/promises");
|
|
82
|
+
var utils_1 = require("@sasjs/utils");
|
|
83
|
+
var config_1 = require("../../../utils/config");
|
|
84
|
+
var getAllFolders_1 = require("./getAllFolders");
|
|
85
|
+
var MANIFEST_NAME = '.compile-manifest.json';
|
|
86
|
+
var getManifestPath = function () {
|
|
87
|
+
return path_1.default.join(process.sasjsConstants.buildDestinationFolder, MANIFEST_NAME);
|
|
88
|
+
};
|
|
89
|
+
exports.getManifestPath = getManifestPath;
|
|
90
|
+
var hashFile = function (filePath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
91
|
+
var _a, _b;
|
|
92
|
+
return __generator(this, function (_c) {
|
|
93
|
+
switch (_c.label) {
|
|
94
|
+
case 0:
|
|
95
|
+
_b = (_a = (0, crypto_1.createHash)('md5'))
|
|
96
|
+
.update;
|
|
97
|
+
return [4 /*yield*/, (0, promises_1.readFile)(filePath)];
|
|
98
|
+
case 1: return [2 /*return*/, _b.apply(_a, [_c.sent()])
|
|
99
|
+
.digest('hex')
|
|
100
|
+
// A file can be listed and then be gone, or be unreadable. Reporting it as
|
|
101
|
+
// changed is safe; throwing from the middle of a compile is not.
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}); };
|
|
106
|
+
// A file can be listed and then be gone, or be unreadable. Reporting it as
|
|
107
|
+
// changed is safe; throwing from the middle of a compile is not.
|
|
108
|
+
var hashFileIfReadable = function (filePath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
109
|
+
var _1;
|
|
110
|
+
return __generator(this, function (_a) {
|
|
111
|
+
switch (_a.label) {
|
|
112
|
+
case 0:
|
|
113
|
+
_a.trys.push([0, 2, , 3]);
|
|
114
|
+
return [4 /*yield*/, hashFile(filePath)];
|
|
115
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
116
|
+
case 2:
|
|
117
|
+
_1 = _a.sent();
|
|
118
|
+
return [2 /*return*/, undefined];
|
|
119
|
+
case 3: return [2 /*return*/];
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}); };
|
|
123
|
+
var listSourceFiles = function (folder_1) {
|
|
124
|
+
var args_1 = [];
|
|
125
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
126
|
+
args_1[_i - 1] = arguments[_i];
|
|
127
|
+
}
|
|
128
|
+
return __awaiter(void 0, __spreadArray([folder_1], __read(args_1), false), void 0, function (folder, relative, files) {
|
|
129
|
+
var folderPath, _a, _b, fileName, e_1_1, _c, _d, subFolder, e_2_1;
|
|
130
|
+
var e_1, _e, e_2, _f;
|
|
131
|
+
if (relative === void 0) { relative = ''; }
|
|
132
|
+
if (files === void 0) { files = []; }
|
|
133
|
+
return __generator(this, function (_g) {
|
|
134
|
+
switch (_g.label) {
|
|
135
|
+
case 0:
|
|
136
|
+
folderPath = path_1.default.join(folder, relative);
|
|
137
|
+
_g.label = 1;
|
|
138
|
+
case 1:
|
|
139
|
+
_g.trys.push([1, 6, 7, 8]);
|
|
140
|
+
return [4 /*yield*/, (0, utils_1.listFilesInFolder)(folderPath)];
|
|
141
|
+
case 2:
|
|
142
|
+
_a = __values.apply(void 0, [_g.sent()]), _b = _a.next();
|
|
143
|
+
_g.label = 3;
|
|
144
|
+
case 3:
|
|
145
|
+
if (!!_b.done) return [3 /*break*/, 5];
|
|
146
|
+
fileName = _b.value;
|
|
147
|
+
files.push(path_1.default.join(relative, fileName));
|
|
148
|
+
_g.label = 4;
|
|
149
|
+
case 4:
|
|
150
|
+
_b = _a.next();
|
|
151
|
+
return [3 /*break*/, 3];
|
|
152
|
+
case 5: return [3 /*break*/, 8];
|
|
153
|
+
case 6:
|
|
154
|
+
e_1_1 = _g.sent();
|
|
155
|
+
e_1 = { error: e_1_1 };
|
|
156
|
+
return [3 /*break*/, 8];
|
|
157
|
+
case 7:
|
|
158
|
+
try {
|
|
159
|
+
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
160
|
+
}
|
|
161
|
+
finally { if (e_1) throw e_1.error; }
|
|
162
|
+
return [7 /*endfinally*/];
|
|
163
|
+
case 8:
|
|
164
|
+
_g.trys.push([8, 14, 15, 16]);
|
|
165
|
+
return [4 /*yield*/, (0, utils_1.listSubFoldersInFolder)(folderPath)];
|
|
166
|
+
case 9:
|
|
167
|
+
_c = __values.apply(void 0, [_g.sent()]), _d = _c.next();
|
|
168
|
+
_g.label = 10;
|
|
169
|
+
case 10:
|
|
170
|
+
if (!!_d.done) return [3 /*break*/, 13];
|
|
171
|
+
subFolder = _d.value;
|
|
172
|
+
return [4 /*yield*/, listSourceFiles(folder, path_1.default.join(relative, subFolder), files)];
|
|
173
|
+
case 11:
|
|
174
|
+
_g.sent();
|
|
175
|
+
_g.label = 12;
|
|
176
|
+
case 12:
|
|
177
|
+
_d = _c.next();
|
|
178
|
+
return [3 /*break*/, 10];
|
|
179
|
+
case 13: return [3 /*break*/, 16];
|
|
180
|
+
case 14:
|
|
181
|
+
e_2_1 = _g.sent();
|
|
182
|
+
e_2 = { error: e_2_1 };
|
|
183
|
+
return [3 /*break*/, 16];
|
|
184
|
+
case 15:
|
|
185
|
+
try {
|
|
186
|
+
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
187
|
+
}
|
|
188
|
+
finally { if (e_2) throw e_2.error; }
|
|
189
|
+
return [7 /*endfinally*/];
|
|
190
|
+
case 16: return [2 /*return*/, files];
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
// Absolute paths: the manifest lives in the build folder, which is per-machine
|
|
196
|
+
// and rebuilt, so portability buys nothing and relative paths would depend on
|
|
197
|
+
// process.projectDir being set.
|
|
198
|
+
var manifestKey = function (folder, relativePath) {
|
|
199
|
+
return path_1.default.join(folder, relativePath);
|
|
200
|
+
};
|
|
201
|
+
var writeCompileManifest = function (folders_1) {
|
|
202
|
+
var args_1 = [];
|
|
203
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
204
|
+
args_1[_i - 1] = arguments[_i];
|
|
205
|
+
}
|
|
206
|
+
return __awaiter(void 0, __spreadArray([folders_1], __read(args_1), false), void 0, function (folders, stampFiles) {
|
|
207
|
+
var manifest, folders_2, folders_2_1, folder, _a, _b, relativePath, hash, e_3_1, e_4_1, stampFiles_1, stampFiles_1_1, filePath, hash, e_5_1;
|
|
208
|
+
var e_4, _c, e_3, _d, e_5, _e;
|
|
209
|
+
if (stampFiles === void 0) { stampFiles = []; }
|
|
210
|
+
return __generator(this, function (_f) {
|
|
211
|
+
switch (_f.label) {
|
|
212
|
+
case 0:
|
|
213
|
+
manifest = {};
|
|
214
|
+
_f.label = 1;
|
|
215
|
+
case 1:
|
|
216
|
+
_f.trys.push([1, 13, 14, 15]);
|
|
217
|
+
folders_2 = __values(folders), folders_2_1 = folders_2.next();
|
|
218
|
+
_f.label = 2;
|
|
219
|
+
case 2:
|
|
220
|
+
if (!!folders_2_1.done) return [3 /*break*/, 12];
|
|
221
|
+
folder = folders_2_1.value;
|
|
222
|
+
_f.label = 3;
|
|
223
|
+
case 3:
|
|
224
|
+
_f.trys.push([3, 9, 10, 11]);
|
|
225
|
+
e_3 = void 0;
|
|
226
|
+
return [4 /*yield*/, listSourceFiles(folder)];
|
|
227
|
+
case 4:
|
|
228
|
+
_a = (__values.apply(void 0, [_f.sent()])), _b = _a.next();
|
|
229
|
+
_f.label = 5;
|
|
230
|
+
case 5:
|
|
231
|
+
if (!!_b.done) return [3 /*break*/, 8];
|
|
232
|
+
relativePath = _b.value;
|
|
233
|
+
return [4 /*yield*/, hashFileIfReadable(path_1.default.join(folder, relativePath))];
|
|
234
|
+
case 6:
|
|
235
|
+
hash = _f.sent();
|
|
236
|
+
if (hash)
|
|
237
|
+
manifest[manifestKey(folder, relativePath)] = hash;
|
|
238
|
+
_f.label = 7;
|
|
239
|
+
case 7:
|
|
240
|
+
_b = _a.next();
|
|
241
|
+
return [3 /*break*/, 5];
|
|
242
|
+
case 8: return [3 /*break*/, 11];
|
|
243
|
+
case 9:
|
|
244
|
+
e_3_1 = _f.sent();
|
|
245
|
+
e_3 = { error: e_3_1 };
|
|
246
|
+
return [3 /*break*/, 11];
|
|
247
|
+
case 10:
|
|
248
|
+
try {
|
|
249
|
+
if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
|
|
250
|
+
}
|
|
251
|
+
finally { if (e_3) throw e_3.error; }
|
|
252
|
+
return [7 /*endfinally*/];
|
|
253
|
+
case 11:
|
|
254
|
+
folders_2_1 = folders_2.next();
|
|
255
|
+
return [3 /*break*/, 2];
|
|
256
|
+
case 12: return [3 /*break*/, 15];
|
|
257
|
+
case 13:
|
|
258
|
+
e_4_1 = _f.sent();
|
|
259
|
+
e_4 = { error: e_4_1 };
|
|
260
|
+
return [3 /*break*/, 15];
|
|
261
|
+
case 14:
|
|
262
|
+
try {
|
|
263
|
+
if (folders_2_1 && !folders_2_1.done && (_c = folders_2.return)) _c.call(folders_2);
|
|
264
|
+
}
|
|
265
|
+
finally { if (e_4) throw e_4.error; }
|
|
266
|
+
return [7 /*endfinally*/];
|
|
267
|
+
case 15:
|
|
268
|
+
_f.trys.push([15, 20, 21, 22]);
|
|
269
|
+
stampFiles_1 = __values(stampFiles), stampFiles_1_1 = stampFiles_1.next();
|
|
270
|
+
_f.label = 16;
|
|
271
|
+
case 16:
|
|
272
|
+
if (!!stampFiles_1_1.done) return [3 /*break*/, 19];
|
|
273
|
+
filePath = stampFiles_1_1.value;
|
|
274
|
+
return [4 /*yield*/, hashFileIfReadable(filePath)];
|
|
275
|
+
case 17:
|
|
276
|
+
hash = _f.sent();
|
|
277
|
+
if (hash)
|
|
278
|
+
manifest[filePath] = hash;
|
|
279
|
+
_f.label = 18;
|
|
280
|
+
case 18:
|
|
281
|
+
stampFiles_1_1 = stampFiles_1.next();
|
|
282
|
+
return [3 /*break*/, 16];
|
|
283
|
+
case 19: return [3 /*break*/, 22];
|
|
284
|
+
case 20:
|
|
285
|
+
e_5_1 = _f.sent();
|
|
286
|
+
e_5 = { error: e_5_1 };
|
|
287
|
+
return [3 /*break*/, 22];
|
|
288
|
+
case 21:
|
|
289
|
+
try {
|
|
290
|
+
if (stampFiles_1_1 && !stampFiles_1_1.done && (_e = stampFiles_1.return)) _e.call(stampFiles_1);
|
|
291
|
+
}
|
|
292
|
+
finally { if (e_5) throw e_5.error; }
|
|
293
|
+
return [7 /*endfinally*/];
|
|
294
|
+
case 22:
|
|
295
|
+
// A failure here costs one extra compile next time, it does not break the
|
|
296
|
+
// build that just succeeded.
|
|
297
|
+
return [4 /*yield*/, (0, utils_1.createFile)((0, exports.getManifestPath)(), JSON.stringify(manifest, null, 2)).catch(function () { return undefined; })];
|
|
298
|
+
case 23:
|
|
299
|
+
// A failure here costs one extra compile next time, it does not break the
|
|
300
|
+
// build that just succeeded.
|
|
301
|
+
_f.sent();
|
|
302
|
+
return [2 /*return*/];
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
};
|
|
307
|
+
exports.writeCompileManifest = writeCompileManifest;
|
|
308
|
+
var readCompileManifest = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
309
|
+
var manifestPath, manifest, _a, _b, _2;
|
|
310
|
+
return __generator(this, function (_c) {
|
|
311
|
+
switch (_c.label) {
|
|
312
|
+
case 0:
|
|
313
|
+
manifestPath = (0, exports.getManifestPath)();
|
|
314
|
+
return [4 /*yield*/, (0, utils_1.fileExists)(manifestPath)];
|
|
315
|
+
case 1:
|
|
316
|
+
if (!(_c.sent()))
|
|
317
|
+
return [2 /*return*/, null];
|
|
318
|
+
_c.label = 2;
|
|
319
|
+
case 2:
|
|
320
|
+
_c.trys.push([2, 4, , 5]);
|
|
321
|
+
_b = (_a = JSON).parse;
|
|
322
|
+
return [4 /*yield*/, (0, utils_1.readFile)(manifestPath)];
|
|
323
|
+
case 3:
|
|
324
|
+
manifest = _b.apply(_a, [_c.sent()]);
|
|
325
|
+
return [2 /*return*/, manifest && typeof manifest === 'object' ? manifest : null];
|
|
326
|
+
case 4:
|
|
327
|
+
_2 = _c.sent();
|
|
328
|
+
return [2 /*return*/, null];
|
|
329
|
+
case 5: return [2 /*return*/];
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
}); };
|
|
333
|
+
exports.readCompileManifest = readCompileManifest;
|
|
334
|
+
/**
|
|
335
|
+
* Names the source files that have changed since the last successful compile:
|
|
336
|
+
* edited content, new files, and files the manifest has never seen.
|
|
337
|
+
*/
|
|
338
|
+
var getChangedFiles = function (folders_1) {
|
|
339
|
+
var args_1 = [];
|
|
340
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
341
|
+
args_1[_i - 1] = arguments[_i];
|
|
342
|
+
}
|
|
343
|
+
return __awaiter(void 0, __spreadArray([folders_1], __read(args_1), false), void 0, function (folders, stampFiles) {
|
|
344
|
+
var manifest, current, folders_3, folders_3_1, folder, _a, _b, relativePath, _c, _d, e_6_1, e_7_1, stampFiles_2, stampFiles_2_1, filePath, _e, _f, e_8_1, changed, _g, _h, _j, key, hash, _k, _l, key;
|
|
345
|
+
var e_7, _m, e_6, _o, e_8, _p, e_9, _q, e_10, _r;
|
|
346
|
+
if (stampFiles === void 0) { stampFiles = []; }
|
|
347
|
+
return __generator(this, function (_s) {
|
|
348
|
+
switch (_s.label) {
|
|
349
|
+
case 0: return [4 /*yield*/, (0, exports.readCompileManifest)()];
|
|
350
|
+
case 1:
|
|
351
|
+
manifest = _s.sent();
|
|
352
|
+
if (!manifest)
|
|
353
|
+
return [2 /*return*/, ['no compile manifest - the project has not been compiled here']
|
|
354
|
+
// The current state of everything the compile reads, keyed the same way.
|
|
355
|
+
];
|
|
356
|
+
current = {};
|
|
357
|
+
_s.label = 2;
|
|
358
|
+
case 2:
|
|
359
|
+
_s.trys.push([2, 14, 15, 16]);
|
|
360
|
+
folders_3 = __values(folders), folders_3_1 = folders_3.next();
|
|
361
|
+
_s.label = 3;
|
|
362
|
+
case 3:
|
|
363
|
+
if (!!folders_3_1.done) return [3 /*break*/, 13];
|
|
364
|
+
folder = folders_3_1.value;
|
|
365
|
+
_s.label = 4;
|
|
366
|
+
case 4:
|
|
367
|
+
_s.trys.push([4, 10, 11, 12]);
|
|
368
|
+
e_6 = void 0;
|
|
369
|
+
return [4 /*yield*/, listSourceFiles(folder)];
|
|
370
|
+
case 5:
|
|
371
|
+
_a = (__values.apply(void 0, [_s.sent()])), _b = _a.next();
|
|
372
|
+
_s.label = 6;
|
|
373
|
+
case 6:
|
|
374
|
+
if (!!_b.done) return [3 /*break*/, 9];
|
|
375
|
+
relativePath = _b.value;
|
|
376
|
+
_c = current;
|
|
377
|
+
_d = manifestKey(folder, relativePath);
|
|
378
|
+
return [4 /*yield*/, hashFileIfReadable(path_1.default.join(folder, relativePath))];
|
|
379
|
+
case 7:
|
|
380
|
+
_c[_d] = _s.sent();
|
|
381
|
+
_s.label = 8;
|
|
382
|
+
case 8:
|
|
383
|
+
_b = _a.next();
|
|
384
|
+
return [3 /*break*/, 6];
|
|
385
|
+
case 9: return [3 /*break*/, 12];
|
|
386
|
+
case 10:
|
|
387
|
+
e_6_1 = _s.sent();
|
|
388
|
+
e_6 = { error: e_6_1 };
|
|
389
|
+
return [3 /*break*/, 12];
|
|
390
|
+
case 11:
|
|
391
|
+
try {
|
|
392
|
+
if (_b && !_b.done && (_o = _a.return)) _o.call(_a);
|
|
393
|
+
}
|
|
394
|
+
finally { if (e_6) throw e_6.error; }
|
|
395
|
+
return [7 /*endfinally*/];
|
|
396
|
+
case 12:
|
|
397
|
+
folders_3_1 = folders_3.next();
|
|
398
|
+
return [3 /*break*/, 3];
|
|
399
|
+
case 13: return [3 /*break*/, 16];
|
|
400
|
+
case 14:
|
|
401
|
+
e_7_1 = _s.sent();
|
|
402
|
+
e_7 = { error: e_7_1 };
|
|
403
|
+
return [3 /*break*/, 16];
|
|
404
|
+
case 15:
|
|
405
|
+
try {
|
|
406
|
+
if (folders_3_1 && !folders_3_1.done && (_m = folders_3.return)) _m.call(folders_3);
|
|
407
|
+
}
|
|
408
|
+
finally { if (e_7) throw e_7.error; }
|
|
409
|
+
return [7 /*endfinally*/];
|
|
410
|
+
case 16:
|
|
411
|
+
_s.trys.push([16, 21, 22, 23]);
|
|
412
|
+
stampFiles_2 = __values(stampFiles), stampFiles_2_1 = stampFiles_2.next();
|
|
413
|
+
_s.label = 17;
|
|
414
|
+
case 17:
|
|
415
|
+
if (!!stampFiles_2_1.done) return [3 /*break*/, 20];
|
|
416
|
+
filePath = stampFiles_2_1.value;
|
|
417
|
+
_e = current;
|
|
418
|
+
_f = filePath;
|
|
419
|
+
return [4 /*yield*/, hashFileIfReadable(filePath)];
|
|
420
|
+
case 18:
|
|
421
|
+
_e[_f] = _s.sent();
|
|
422
|
+
_s.label = 19;
|
|
423
|
+
case 19:
|
|
424
|
+
stampFiles_2_1 = stampFiles_2.next();
|
|
425
|
+
return [3 /*break*/, 17];
|
|
426
|
+
case 20: return [3 /*break*/, 23];
|
|
427
|
+
case 21:
|
|
428
|
+
e_8_1 = _s.sent();
|
|
429
|
+
e_8 = { error: e_8_1 };
|
|
430
|
+
return [3 /*break*/, 23];
|
|
431
|
+
case 22:
|
|
432
|
+
try {
|
|
433
|
+
if (stampFiles_2_1 && !stampFiles_2_1.done && (_p = stampFiles_2.return)) _p.call(stampFiles_2);
|
|
434
|
+
}
|
|
435
|
+
finally { if (e_8) throw e_8.error; }
|
|
436
|
+
return [7 /*endfinally*/];
|
|
437
|
+
case 23:
|
|
438
|
+
changed = [];
|
|
439
|
+
try {
|
|
440
|
+
for (_g = __values(Object.entries(current)), _h = _g.next(); !_h.done; _h = _g.next()) {
|
|
441
|
+
_j = __read(_h.value, 2), key = _j[0], hash = _j[1];
|
|
442
|
+
if (hash && manifest[key] !== hash)
|
|
443
|
+
changed.push(key);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
447
|
+
finally {
|
|
448
|
+
try {
|
|
449
|
+
if (_h && !_h.done && (_q = _g.return)) _q.call(_g);
|
|
450
|
+
}
|
|
451
|
+
finally { if (e_9) throw e_9.error; }
|
|
452
|
+
}
|
|
453
|
+
try {
|
|
454
|
+
// A source the compile read last time and cannot see now is a change too:
|
|
455
|
+
// deleting a macro or a service alters the build as much as editing one.
|
|
456
|
+
for (_k = __values(Object.keys(manifest)), _l = _k.next(); !_l.done; _l = _k.next()) {
|
|
457
|
+
key = _l.value;
|
|
458
|
+
if (!(key in current))
|
|
459
|
+
changed.push(key);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
463
|
+
finally {
|
|
464
|
+
try {
|
|
465
|
+
if (_l && !_l.done && (_r = _k.return)) _r.call(_k);
|
|
466
|
+
}
|
|
467
|
+
finally { if (e_10) throw e_10.error; }
|
|
468
|
+
}
|
|
469
|
+
return [2 /*return*/, changed];
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
});
|
|
473
|
+
};
|
|
474
|
+
exports.getChangedFiles = getChangedFiles;
|
|
475
|
+
/**
|
|
476
|
+
* Every folder whose contents feed the build: the services and jobs, plus the
|
|
477
|
+
* web app and the sync folder when the target uses them. A skip is only safe if
|
|
478
|
+
* it accounts for all of them - a frontend change with an unchanged services
|
|
479
|
+
* folder must still rebuild.
|
|
480
|
+
*/
|
|
481
|
+
var getManifestFolders = function (target) { return __awaiter(void 0, void 0, void 0, function () {
|
|
482
|
+
var folders, _a, _b, _c, _d, macroCorePath, streamConfig, syncFolder, existing, folders_1, folders_1_1, folder, e_11_1;
|
|
483
|
+
var e_11, _e;
|
|
484
|
+
var _f, _g;
|
|
485
|
+
return __generator(this, function (_h) {
|
|
486
|
+
switch (_h.label) {
|
|
487
|
+
case 0:
|
|
488
|
+
_a = [[]];
|
|
489
|
+
return [4 /*yield*/, (0, getAllFolders_1.getAllFolders)(target, getAllFolders_1.SasFileType.Service)];
|
|
490
|
+
case 1:
|
|
491
|
+
_b = [__spreadArray.apply(void 0, _a.concat([__read.apply(void 0, [(_h.sent())]), false]))];
|
|
492
|
+
return [4 /*yield*/, (0, getAllFolders_1.getAllFolders)(target, getAllFolders_1.SasFileType.Job)];
|
|
493
|
+
case 2:
|
|
494
|
+
_c = [__spreadArray.apply(void 0, _b.concat([__read.apply(void 0, [(_h.sent())]), false]))];
|
|
495
|
+
return [4 /*yield*/, (0, config_1.getMacroFolders)(target)];
|
|
496
|
+
case 3:
|
|
497
|
+
_d = [__spreadArray.apply(void 0, _c.concat([__read.apply(void 0, [(_h.sent())]), false]))];
|
|
498
|
+
return [4 /*yield*/, (0, config_1.getProgramFolders)(target)];
|
|
499
|
+
case 4:
|
|
500
|
+
folders = __spreadArray.apply(void 0, _d.concat([__read.apply(void 0, [(_h.sent())]), false]));
|
|
501
|
+
macroCorePath = (_f = process.sasjsConstants) === null || _f === void 0 ? void 0 : _f.macroCorePath;
|
|
502
|
+
if (macroCorePath &&
|
|
503
|
+
!macroCorePath.includes("".concat(path_1.default.sep, "node_modules").concat(path_1.default.sep)))
|
|
504
|
+
folders.push(macroCorePath);
|
|
505
|
+
return [4 /*yield*/, (0, config_1.getStreamConfig)(target)];
|
|
506
|
+
case 5:
|
|
507
|
+
streamConfig = _h.sent();
|
|
508
|
+
if ((streamConfig === null || streamConfig === void 0 ? void 0 : streamConfig.streamWeb) && streamConfig.webSourcePath) {
|
|
509
|
+
folders.push((0, utils_1.getAbsolutePath)(streamConfig.webSourcePath, process.projectDir));
|
|
510
|
+
}
|
|
511
|
+
syncFolder = (_g = process.sasjsConfig) === null || _g === void 0 ? void 0 : _g.syncFolder;
|
|
512
|
+
if (syncFolder)
|
|
513
|
+
folders.push((0, utils_1.getAbsolutePath)(syncFolder, process.projectDir));
|
|
514
|
+
existing = [];
|
|
515
|
+
_h.label = 6;
|
|
516
|
+
case 6:
|
|
517
|
+
_h.trys.push([6, 11, 12, 13]);
|
|
518
|
+
folders_1 = __values(folders), folders_1_1 = folders_1.next();
|
|
519
|
+
_h.label = 7;
|
|
520
|
+
case 7:
|
|
521
|
+
if (!!folders_1_1.done) return [3 /*break*/, 10];
|
|
522
|
+
folder = folders_1_1.value;
|
|
523
|
+
return [4 /*yield*/, (0, utils_1.folderExists)(folder)];
|
|
524
|
+
case 8:
|
|
525
|
+
if (_h.sent())
|
|
526
|
+
existing.push(folder);
|
|
527
|
+
_h.label = 9;
|
|
528
|
+
case 9:
|
|
529
|
+
folders_1_1 = folders_1.next();
|
|
530
|
+
return [3 /*break*/, 7];
|
|
531
|
+
case 10: return [3 /*break*/, 13];
|
|
532
|
+
case 11:
|
|
533
|
+
e_11_1 = _h.sent();
|
|
534
|
+
e_11 = { error: e_11_1 };
|
|
535
|
+
return [3 /*break*/, 13];
|
|
536
|
+
case 12:
|
|
537
|
+
try {
|
|
538
|
+
if (folders_1_1 && !folders_1_1.done && (_e = folders_1.return)) _e.call(folders_1);
|
|
539
|
+
}
|
|
540
|
+
finally { if (e_11) throw e_11.error; }
|
|
541
|
+
return [7 /*endfinally*/];
|
|
542
|
+
case 13: return [2 /*return*/, existing];
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
}); };
|
|
546
|
+
exports.getManifestFolders = getManifestFolders;
|
|
547
|
+
/**
|
|
548
|
+
* Individual files whose change invalidates the whole build.
|
|
549
|
+
*
|
|
550
|
+
* The test programs are not inside a service folder, and the dependency
|
|
551
|
+
* manifests are the record of which @sasjs/core a build used: a core bump
|
|
552
|
+
* arrives as an install, so the version in `node_modules/@sasjs/core` and the
|
|
553
|
+
* lockfile are the signals - walking every macro of the library would cost
|
|
554
|
+
* more than it catches.
|
|
555
|
+
*/
|
|
556
|
+
var getManifestStamps = function (target) { return __awaiter(void 0, void 0, void 0, function () {
|
|
557
|
+
var stamps, _a, _b, existing, stamps_1, stamps_1_1, stamp, _c, e_12_1;
|
|
558
|
+
var e_12, _d;
|
|
559
|
+
return __generator(this, function (_e) {
|
|
560
|
+
switch (_e.label) {
|
|
561
|
+
case 0:
|
|
562
|
+
_a = [[
|
|
563
|
+
path_1.default.join(process.projectDir, 'package.json'),
|
|
564
|
+
path_1.default.join(process.projectDir, 'package-lock.json'),
|
|
565
|
+
path_1.default.join(process.projectDir, 'node_modules', '@sasjs', 'core', 'package.json')
|
|
566
|
+
]];
|
|
567
|
+
return [4 /*yield*/, (0, config_1.getTestSetUp)(target)];
|
|
568
|
+
case 1:
|
|
569
|
+
_b = [_e.sent()];
|
|
570
|
+
return [4 /*yield*/, (0, config_1.getTestTearDown)(target)];
|
|
571
|
+
case 2:
|
|
572
|
+
stamps = __spreadArray.apply(void 0, _a.concat([__read.apply(void 0, [_b.concat([_e.sent()]).map(function (stamp) { return (stamp ? (0, utils_1.getAbsolutePath)(stamp, process.projectDir) : ''); })]), false])).filter(function (stamp) { return !!stamp; });
|
|
573
|
+
existing = [];
|
|
574
|
+
_e.label = 3;
|
|
575
|
+
case 3:
|
|
576
|
+
_e.trys.push([3, 9, 10, 11]);
|
|
577
|
+
stamps_1 = __values(stamps), stamps_1_1 = stamps_1.next();
|
|
578
|
+
_e.label = 4;
|
|
579
|
+
case 4:
|
|
580
|
+
if (!!stamps_1_1.done) return [3 /*break*/, 8];
|
|
581
|
+
stamp = stamps_1_1.value;
|
|
582
|
+
_c = stamp;
|
|
583
|
+
if (!_c) return [3 /*break*/, 6];
|
|
584
|
+
return [4 /*yield*/, (0, utils_1.fileExists)(stamp)];
|
|
585
|
+
case 5:
|
|
586
|
+
_c = (_e.sent());
|
|
587
|
+
_e.label = 6;
|
|
588
|
+
case 6:
|
|
589
|
+
if (_c)
|
|
590
|
+
existing.push(stamp);
|
|
591
|
+
_e.label = 7;
|
|
592
|
+
case 7:
|
|
593
|
+
stamps_1_1 = stamps_1.next();
|
|
594
|
+
return [3 /*break*/, 4];
|
|
595
|
+
case 8: return [3 /*break*/, 11];
|
|
596
|
+
case 9:
|
|
597
|
+
e_12_1 = _e.sent();
|
|
598
|
+
e_12 = { error: e_12_1 };
|
|
599
|
+
return [3 /*break*/, 11];
|
|
600
|
+
case 10:
|
|
601
|
+
try {
|
|
602
|
+
if (stamps_1_1 && !stamps_1_1.done && (_d = stamps_1.return)) _d.call(stamps_1);
|
|
603
|
+
}
|
|
604
|
+
finally { if (e_12) throw e_12.error; }
|
|
605
|
+
return [7 /*endfinally*/];
|
|
606
|
+
case 11: return [2 /*return*/, existing];
|
|
607
|
+
}
|
|
608
|
+
});
|
|
609
|
+
}); };
|
|
610
|
+
exports.getManifestStamps = getManifestStamps;
|
|
@@ -14,6 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./compileManifest"), exports);
|
|
18
|
+
__exportStar(require("./passThrough"), exports);
|
|
17
19
|
__exportStar(require("./checkCompileStatus"), exports);
|
|
18
20
|
__exportStar(require("./compareFolders"), exports);
|
|
19
21
|
__exportStar(require("./compileFile"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a file in a service or job folder is deployed as written.
|
|
3
|
+
*
|
|
4
|
+
* Anything that is not a `.sas` program is copied into the build folder
|
|
5
|
+
* untouched and travels in the pack as a file member under its own name - a
|
|
6
|
+
* `.js` stored program for a SASjs server, web assets, a payload the deployment
|
|
7
|
+
* script needs. Compiling it as SAS would corrupt it, and deciding that per
|
|
8
|
+
* server type would mean the same project produced different packs depending on
|
|
9
|
+
* the target. The server picks a runtime from the extension, or ignores the
|
|
10
|
+
* file; either way the CLI's job is to ship it intact.
|
|
11
|
+
*/
|
|
12
|
+
export declare const shouldPassThrough: (fileName: string) => boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.shouldPassThrough = void 0;
|
|
4
|
+
var file_1 = require("../../../utils/file");
|
|
5
|
+
/**
|
|
6
|
+
* Whether a file in a service or job folder is deployed as written.
|
|
7
|
+
*
|
|
8
|
+
* Anything that is not a `.sas` program is copied into the build folder
|
|
9
|
+
* untouched and travels in the pack as a file member under its own name - a
|
|
10
|
+
* `.js` stored program for a SASjs server, web assets, a payload the deployment
|
|
11
|
+
* script needs. Compiling it as SAS would corrupt it, and deciding that per
|
|
12
|
+
* server type would mean the same project produced different packs depending on
|
|
13
|
+
* the target. The server picks a runtime from the extension, or ignores the
|
|
14
|
+
* file; either way the CLI's job is to ship it intact.
|
|
15
|
+
*/
|
|
16
|
+
var shouldPassThrough = function (fileName) { return !(0, file_1.isSasFile)(fileName); };
|
|
17
|
+
exports.shouldPassThrough = shouldPassThrough;
|