@sasjs/cli 3.23.5 → 3.23.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/commands/fs/fsCommand.js +10 -7
- package/build/commands/fs/spec/fsCommand.spec.js +3 -10
- package/package.json +2 -2
- package/build/commands/fs/internal/extractHashArray.d.ts +0 -1
- package/build/commands/fs/internal/extractHashArray.js +0 -20
- package/build/commands/fs/spec/extractHashArray.spec.d.ts +0 -1
- package/build/commands/fs/spec/extractHashArray.spec.js +0 -14
|
@@ -108,7 +108,6 @@ var utils_1 = require("../../utils");
|
|
|
108
108
|
var path_1 = __importDefault(require("path"));
|
|
109
109
|
var utils_2 = require("@sasjs/utils");
|
|
110
110
|
var executeCode_1 = require("./internal/executeCode");
|
|
111
|
-
var extractHashArray_1 = require("./internal/extractHashArray");
|
|
112
111
|
var FsSubCommand;
|
|
113
112
|
(function (FsSubCommand) {
|
|
114
113
|
FsSubCommand["Compile"] = "compile";
|
|
@@ -120,7 +119,7 @@ var description = 'Handles operations around file system synchronisation';
|
|
|
120
119
|
var parseOptions = {
|
|
121
120
|
output: { type: 'string', alias: 'o' }
|
|
122
121
|
};
|
|
123
|
-
var compileCommandSyntax = 'fs <subCommand> <
|
|
122
|
+
var compileCommandSyntax = 'fs <subCommand> <local> [options]';
|
|
124
123
|
var compileCommandUsage = 'sasjs fs compile <localFolder> [options]';
|
|
125
124
|
var compileCommandDescription = 'Compiles a SAS program with the contents of a local directory';
|
|
126
125
|
var compileCommandExamples = [
|
|
@@ -319,16 +318,18 @@ var FSCommand = /** @class */ (function (_super) {
|
|
|
319
318
|
case 6:
|
|
320
319
|
_v.sent();
|
|
321
320
|
(_d = process.logger) === null || _d === void 0 ? void 0 : _d.info('extracting hashes from log');
|
|
322
|
-
remoteHashes = (0,
|
|
321
|
+
remoteHashes = (0, utils_2.extractHashArray)(log);
|
|
323
322
|
return [4 /*yield*/, createHashFile(JSON.stringify(remoteHashes, null, 2), path_1.default.join(outputFolder, 'hashesBeforeSync.json'))];
|
|
324
323
|
case 7:
|
|
325
324
|
_v.sent();
|
|
326
325
|
(_e = process.logger) === null || _e === void 0 ? void 0 : _e.info('creating the hash of local folder');
|
|
327
|
-
return [4 /*yield*/, (0, utils_2.getHash)(obj.local)];
|
|
326
|
+
return [4 /*yield*/, (0, utils_2.getHash)((0, utils_2.getAbsolutePath)(obj.local, process.projectDir))];
|
|
328
327
|
case 8:
|
|
329
328
|
localHash = _v.sent();
|
|
330
329
|
remoteHashMap_1 = remoteHashes.reduce(function (map, item) {
|
|
331
|
-
var
|
|
330
|
+
var from = obj.remote.replace(/\//g, path_1.default.sep);
|
|
331
|
+
var to = item.FILE_PATH.replace(/\//g, path_1.default.sep);
|
|
332
|
+
var relativePath = (0, utils_2.getRelativePath)(from, to);
|
|
332
333
|
map[relativePath] = item.FILE_HASH;
|
|
333
334
|
return map;
|
|
334
335
|
}, {});
|
|
@@ -355,12 +356,14 @@ var FSCommand = /** @class */ (function (_super) {
|
|
|
355
356
|
return [4 /*yield*/, (0, utils_1.saveLog)(syncLog, path_1.default.join(outputFolder, 'sync.log'), '', false)];
|
|
356
357
|
case 13:
|
|
357
358
|
_v.sent();
|
|
358
|
-
syncedHash = (0,
|
|
359
|
+
syncedHash = (0, utils_2.extractHashArray)(syncLog);
|
|
359
360
|
return [4 /*yield*/, createHashFile(JSON.stringify(syncedHash, null, 2), path_1.default.join(outputFolder, 'hashesAfterSync.json'))];
|
|
360
361
|
case 14:
|
|
361
362
|
_v.sent();
|
|
362
363
|
syncedHashMap = syncedHash.reduce(function (map, item) {
|
|
363
|
-
var
|
|
364
|
+
var from = obj.remote.replace(/\//g, path_1.default.sep);
|
|
365
|
+
var to = item.FILE_PATH.replace(/\//g, path_1.default.sep);
|
|
366
|
+
var relativePath = (0, utils_2.getRelativePath)(from, to);
|
|
364
367
|
map[relativePath] = item.FILE_HASH;
|
|
365
368
|
return map;
|
|
366
369
|
}, {});
|
|
@@ -88,7 +88,6 @@ var FSModule = __importStar(require("@sasjs/utils/fs"));
|
|
|
88
88
|
var FileModule = __importStar(require("@sasjs/utils/file"));
|
|
89
89
|
var configUtils = __importStar(require("../../../utils/config"));
|
|
90
90
|
var executeCodeModule = __importStar(require("../internal/executeCode"));
|
|
91
|
-
var extractHashArrayModule = __importStar(require("../internal/extractHashArray"));
|
|
92
91
|
var defaultArgs = ['node', 'sasjs', 'fs'];
|
|
93
92
|
var target = new utils_1.Target({
|
|
94
93
|
name: 'test',
|
|
@@ -197,17 +196,13 @@ describe('FSCommand', function () {
|
|
|
197
196
|
return __generator(this, function (_a) {
|
|
198
197
|
switch (_a.label) {
|
|
199
198
|
case 0:
|
|
200
|
-
jest
|
|
201
|
-
.spyOn(extractHashArrayModule, 'extractHashArray')
|
|
202
|
-
.mockImplementationOnce(function () { return [
|
|
199
|
+
jest.spyOn(FSModule, 'extractHashArray').mockImplementationOnce(function () { return [
|
|
203
200
|
{
|
|
204
201
|
FILE_PATH: 'mocked-file',
|
|
205
202
|
FILE_HASH: 'hashOfMockedFile'
|
|
206
203
|
}
|
|
207
204
|
]; });
|
|
208
|
-
jest
|
|
209
|
-
.spyOn(extractHashArrayModule, 'extractHashArray')
|
|
210
|
-
.mockImplementationOnce(function () { return [
|
|
205
|
+
jest.spyOn(FSModule, 'extractHashArray').mockImplementationOnce(function () { return [
|
|
211
206
|
{
|
|
212
207
|
FILE_PATH: 'synced-file',
|
|
213
208
|
FILE_HASH: 'hashOfSyncedFile'
|
|
@@ -239,9 +234,7 @@ describe('FSCommand', function () {
|
|
|
239
234
|
return __generator(this, function (_a) {
|
|
240
235
|
switch (_a.label) {
|
|
241
236
|
case 0:
|
|
242
|
-
jest
|
|
243
|
-
.spyOn(extractHashArrayModule, 'extractHashArray')
|
|
244
|
-
.mockImplementation(function () { return [
|
|
237
|
+
jest.spyOn(FSModule, 'extractHashArray').mockImplementation(function () { return [
|
|
245
238
|
{
|
|
246
239
|
FILE_PATH: 'mocked-file',
|
|
247
240
|
FILE_HASH: 'hashOfMockedFile'
|
package/package.json
CHANGED
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@sasjs/adapter": "4.1.0",
|
|
54
54
|
"@sasjs/core": "4.45.4",
|
|
55
55
|
"@sasjs/lint": "2.0.1",
|
|
56
|
-
"@sasjs/utils": "2.51.
|
|
56
|
+
"@sasjs/utils": "2.51.5",
|
|
57
57
|
"adm-zip": "0.5.9",
|
|
58
58
|
"chalk": "4.1.2",
|
|
59
59
|
"csv-stringify": "5.6.5",
|
|
@@ -101,5 +101,5 @@
|
|
|
101
101
|
"typescript": "4.5.4",
|
|
102
102
|
"util": "0.12.4"
|
|
103
103
|
},
|
|
104
|
-
"version": "3.23.
|
|
104
|
+
"version": "3.23.7"
|
|
105
105
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const extractHashArray: (log: string) => any;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractHashArray = void 0;
|
|
4
|
-
var utils_1 = require("../../../utils");
|
|
5
|
-
var extractHashArray = function (log) {
|
|
6
|
-
if (log.includes('>>weboutBEGIN<<')) {
|
|
7
|
-
try {
|
|
8
|
-
var webout = log
|
|
9
|
-
.split(/>>weboutBEGIN<<\n/)[1]
|
|
10
|
-
.split(/>>weboutEND<<\n/)[0];
|
|
11
|
-
var jsonWebout = JSON.parse(webout);
|
|
12
|
-
return jsonWebout.hashes;
|
|
13
|
-
}
|
|
14
|
-
catch (err) {
|
|
15
|
-
(0, utils_1.displayError)(err, 'An error occurred while extracting hashes array from webout.');
|
|
16
|
-
throw new Error('An error occurred while extracting hashes array from webout.');
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
exports.extractHashArray = extractHashArray;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var extractHashArray_1 = require("../internal/extractHashArray");
|
|
4
|
-
var log = "\n>>weboutBEGIN<<\n{\n \"hashes\": [{\n \"FILE_HASH\": \"someCharacters\",\n \"FILE_PATH\": \"path/to/folder/file\"\n }]\n}\n>>weboutEND<<\n";
|
|
5
|
-
var logWithInvalidJsonInWebout = "\n>>weboutBEGIN<<\n{\n \"invalid Json\"\n}\n>>weboutEND<<\n";
|
|
6
|
-
describe('extractHashArray', function () {
|
|
7
|
-
it('should extract hashed array from webout', function () {
|
|
8
|
-
var hashes = (0, extractHashArray_1.extractHashArray)(log);
|
|
9
|
-
expect(hashes).toBeArrayOfSize(1);
|
|
10
|
-
});
|
|
11
|
-
it('should throw error when log does not contain webout', function () {
|
|
12
|
-
expect(function () { return (0, extractHashArray_1.extractHashArray)(logWithInvalidJsonInWebout); }).toThrow('An error occurred while extracting hashes array from webout.');
|
|
13
|
-
});
|
|
14
|
-
});
|