@sasjs/cli 6.4.7 → 6.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ReturnCode } from '../../types/command';
|
|
2
|
-
import {
|
|
3
|
-
export declare class DbCommand extends
|
|
2
|
+
import { TargetCommand } from '../../types/command/targetCommand';
|
|
3
|
+
export declare class DbCommand extends TargetCommand {
|
|
4
4
|
constructor(args: string[]);
|
|
5
5
|
execute(): Promise<ReturnCode>;
|
|
6
6
|
}
|
|
@@ -54,7 +54,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
54
54
|
exports.DbCommand = void 0;
|
|
55
55
|
var db_1 = require("./db");
|
|
56
56
|
var command_1 = require("../../types/command");
|
|
57
|
-
var
|
|
57
|
+
var targetCommand_1 = require("../../types/command/targetCommand");
|
|
58
58
|
var syntax = 'db';
|
|
59
59
|
var aliases = ['build-DB', 'build-db'];
|
|
60
60
|
var usage = 'sasjs db';
|
|
@@ -80,22 +80,30 @@ var DbCommand = /** @class */ (function (_super) {
|
|
|
80
80
|
return __awaiter(this, void 0, void 0, function () {
|
|
81
81
|
return __generator(this, function (_a) {
|
|
82
82
|
switch (_a.label) {
|
|
83
|
-
case 0:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
83
|
+
case 0:
|
|
84
|
+
// Resolving the target is what sets process.sasjsConstants - buildDB reads
|
|
85
|
+
// the source and destination db folders from there.
|
|
86
|
+
return [4 /*yield*/, this.getTargetInfo()];
|
|
87
|
+
case 1:
|
|
88
|
+
// Resolving the target is what sets process.sasjsConstants - buildDB reads
|
|
89
|
+
// the source and destination db folders from there.
|
|
90
|
+
_a.sent();
|
|
91
|
+
return [4 /*yield*/, (0, db_1.buildDB)()
|
|
92
|
+
.then(function () {
|
|
93
|
+
var _a;
|
|
94
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.success('DB build completed!');
|
|
95
|
+
return command_1.ReturnCode.Success;
|
|
96
|
+
})
|
|
97
|
+
.catch(function (err) {
|
|
98
|
+
var _a;
|
|
99
|
+
(_a = process.logger) === null || _a === void 0 ? void 0 : _a.error('Error building DB: ', err);
|
|
100
|
+
return command_1.ReturnCode.InternalError;
|
|
101
|
+
})];
|
|
102
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
95
103
|
}
|
|
96
104
|
});
|
|
97
105
|
});
|
|
98
106
|
};
|
|
99
107
|
return DbCommand;
|
|
100
|
-
}(
|
|
108
|
+
}(targetCommand_1.TargetCommand));
|
|
101
109
|
exports.DbCommand = DbCommand;
|
|
@@ -94,10 +94,18 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
94
94
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
95
95
|
};
|
|
96
96
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
97
|
-
var
|
|
97
|
+
var utils_1 = require("@sasjs/utils");
|
|
98
98
|
var command_1 = require("../../../types/command");
|
|
99
99
|
var dbModule = __importStar(require("../db"));
|
|
100
100
|
var dbCommand_1 = require("../dbCommand");
|
|
101
|
+
var configUtils = __importStar(require("../../../utils/config"));
|
|
102
|
+
var setConstantsUtils = __importStar(require("../../../utils/setConstants"));
|
|
103
|
+
var target = new utils_1.Target({
|
|
104
|
+
name: 'test-target',
|
|
105
|
+
serverUrl: 'https://sas.example.com',
|
|
106
|
+
serverType: utils_1.ServerType.SasViya,
|
|
107
|
+
appLoc: '/Public/app'
|
|
108
|
+
});
|
|
101
109
|
describe('DbCommand', function () {
|
|
102
110
|
var defaultArgs = ['node', 'sasjs'];
|
|
103
111
|
beforeEach(function () {
|
|
@@ -125,6 +133,32 @@ describe('DbCommand', function () {
|
|
|
125
133
|
}
|
|
126
134
|
});
|
|
127
135
|
}); });
|
|
136
|
+
it('should resolve the target - and so set the constants - before building', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
137
|
+
var calls;
|
|
138
|
+
return __generator(this, function (_a) {
|
|
139
|
+
switch (_a.label) {
|
|
140
|
+
case 0:
|
|
141
|
+
calls = [];
|
|
142
|
+
setConstantsUtils.setConstants.mockImplementation(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
143
|
+
return __generator(this, function (_a) {
|
|
144
|
+
calls.push('setConstants');
|
|
145
|
+
return [2 /*return*/];
|
|
146
|
+
});
|
|
147
|
+
}); });
|
|
148
|
+
jest.spyOn(dbModule, 'buildDB').mockImplementation(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
149
|
+
return __generator(this, function (_a) {
|
|
150
|
+
calls.push('buildDB');
|
|
151
|
+
return [2 /*return*/];
|
|
152
|
+
});
|
|
153
|
+
}); });
|
|
154
|
+
return [4 /*yield*/, new dbCommand_1.DbCommand(__spreadArray(__spreadArray([], __read(defaultArgs), false), ['db'], false)).execute()];
|
|
155
|
+
case 1:
|
|
156
|
+
_a.sent();
|
|
157
|
+
expect(calls).toEqual(['setConstants', 'buildDB']);
|
|
158
|
+
return [2 /*return*/];
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}); });
|
|
128
162
|
it('should return an error code when the execution errors out', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
129
163
|
var args, command, returnCode;
|
|
130
164
|
return __generator(this, function (_a) {
|
|
@@ -149,7 +183,16 @@ var setupMocks = function () {
|
|
|
149
183
|
jest.resetAllMocks();
|
|
150
184
|
jest.mock('../db');
|
|
151
185
|
jest.spyOn(dbModule, 'buildDB').mockImplementation(function () { return Promise.resolve(); });
|
|
152
|
-
|
|
186
|
+
jest
|
|
187
|
+
.spyOn(configUtils, 'findTargetInConfiguration')
|
|
188
|
+
.mockImplementation(function () { return Promise.resolve({ target: target, isLocal: true }); });
|
|
189
|
+
jest
|
|
190
|
+
.spyOn(configUtils, 'getLocalConfig')
|
|
191
|
+
.mockImplementation(function () { return Promise.resolve({}); });
|
|
192
|
+
jest
|
|
193
|
+
.spyOn(setConstantsUtils, 'setConstants')
|
|
194
|
+
.mockImplementation(function () { return Promise.resolve(); });
|
|
195
|
+
process.logger = new utils_1.Logger(utils_1.LogLevel.Off);
|
|
153
196
|
jest.spyOn(process.logger, 'success');
|
|
154
197
|
jest.spyOn(process.logger, 'error');
|
|
155
198
|
};
|
package/package.json
CHANGED