@signageos/cli 2.3.1 → 2.3.2
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/dist/Applet/Build/appletBuildCommand.js +28 -72
- package/dist/Applet/Generate/Templates/rspack.config.mjs.template +12 -12
- package/dist/Applet/Generate/appletGenerateCommand.d.ts +23 -62
- package/dist/Applet/Generate/appletGenerateCommand.js +398 -365
- package/dist/Applet/Start/appletStartCommand.js +69 -131
- package/dist/Applet/Test/Upload/appletTestRunCommand.js +89 -177
- package/dist/Applet/Test/Upload/appletTestRunFacade.js +4 -27
- package/dist/Applet/Test/Upload/appletTestUploadCommand.js +98 -223
- package/dist/Applet/Test/Upload/appletTestUploadFacade.js +39 -102
- package/dist/Applet/Test/appletTestCommand.js +6 -36
- package/dist/Applet/Upload/appletUploadCommand.js +199 -305
- package/dist/Applet/Upload/appletUploadCommandHelper.js +103 -138
- package/dist/Applet/Upload/appletUploadFacade.d.ts +2 -2
- package/dist/Applet/Upload/appletUploadFacade.js +172 -263
- package/dist/Applet/Upload/appletUploadFacadeHelper.js +39 -52
- package/dist/Applet/appletCommand.d.ts +22 -62
- package/dist/Applet/appletCommand.js +9 -39
- package/dist/Applet/appletErrors.js +5 -24
- package/dist/Applet/appletFacade.js +106 -141
- package/dist/Applet/appletServerHelper.js +16 -53
- package/dist/Auth/loginCommand.js +96 -137
- package/dist/Cache/tmpCache.js +35 -13
- package/dist/Cli/helper.js +1 -2
- package/dist/Cli/packageVersion.js +82 -123
- package/dist/Command/commandDefinition.js +0 -1
- package/dist/Command/commandProcessor.js +40 -129
- package/dist/Command/globalArgs.js +7 -5
- package/dist/CommandLine/IProgressBar.js +0 -1
- package/dist/CommandLine/progressBarFactory.js +31 -11
- package/dist/CustomScript/Generate/customScriptGenerateCommand.js +17 -56
- package/dist/CustomScript/Generate/customScriptGenerateFacade.js +82 -106
- package/dist/CustomScript/Upload/customScriptUploadCommand.js +44 -120
- package/dist/CustomScript/customScriptCommand.js +6 -36
- package/dist/CustomScript/customScriptFacade.js +175 -294
- package/dist/Device/Connect/connectCommand.js +72 -136
- package/dist/Device/Content/setContentCommand.js +33 -78
- package/dist/Device/PowerAction/powerActionCommand.js +22 -65
- package/dist/Device/deviceCommand.js +7 -37
- package/dist/Device/deviceFacade.js +67 -123
- package/dist/Emulator/IEmulator.js +0 -1
- package/dist/Emulator/createDomain.js +33 -12
- package/dist/Emulator/emulatorFacade.js +74 -131
- package/dist/Emulator/emulatorFactory.js +112 -124
- package/dist/Firmware/Upload/firmwareUploadCommand.js +133 -221
- package/dist/Firmware/Upload/firmwareUploadFacade.js +64 -110
- package/dist/Firmware/Upload/firmwareUploadHelper.js +27 -5
- package/dist/Firmware/firmwareCommand.js +5 -35
- package/dist/Lib/archive.js +45 -60
- package/dist/Lib/childProcess.js +27 -5
- package/dist/Lib/fileSystem.js +62 -82
- package/dist/Lib/git.d.ts +1 -1
- package/dist/Lib/git.js +44 -82
- package/dist/Organization/Get/organizationGetCommand.js +14 -50
- package/dist/Organization/List/organizationListCommand.js +12 -46
- package/dist/Organization/SetDefault/organizationSetDefaultCommand.js +18 -56
- package/dist/Organization/organizationCommand.js +7 -37
- package/dist/Organization/organizationFacade.js +97 -172
- package/dist/RunControl/runControlHelper.js +11 -60
- package/dist/Timer/wait.js +1 -2
- package/dist/Timing/List/timingListCommand.js +20 -62
- package/dist/Timing/timingCommand.js +5 -35
- package/dist/generalCommand.js +1 -2
- package/dist/helper.js +48 -109
- package/dist/index.js +15 -45
- package/dist/parameters.js +17 -40
- package/package.json +16 -18
- package/dist/Applet/Build/appletBuildCommand.js.map +0 -1
- package/dist/Applet/Generate/appletGenerateCommand.js.map +0 -1
- package/dist/Applet/Start/appletStartCommand.js.map +0 -1
- package/dist/Applet/Test/Upload/appletTestRunCommand.js.map +0 -1
- package/dist/Applet/Test/Upload/appletTestRunFacade.js.map +0 -1
- package/dist/Applet/Test/Upload/appletTestUploadCommand.js.map +0 -1
- package/dist/Applet/Test/Upload/appletTestUploadFacade.js.map +0 -1
- package/dist/Applet/Test/appletTestCommand.js.map +0 -1
- package/dist/Applet/Upload/appletUploadCommand.js.map +0 -1
- package/dist/Applet/Upload/appletUploadCommandHelper.js.map +0 -1
- package/dist/Applet/Upload/appletUploadFacade.js.map +0 -1
- package/dist/Applet/Upload/appletUploadFacadeHelper.js.map +0 -1
- package/dist/Applet/appletCommand.js.map +0 -1
- package/dist/Applet/appletErrors.js.map +0 -1
- package/dist/Applet/appletFacade.js.map +0 -1
- package/dist/Applet/appletServerHelper.js.map +0 -1
- package/dist/Auth/loginCommand.js.map +0 -1
- package/dist/Cache/tmpCache.js.map +0 -1
- package/dist/Cli/helper.js.map +0 -1
- package/dist/Cli/packageVersion.js.map +0 -1
- package/dist/Command/commandDefinition.js.map +0 -1
- package/dist/Command/commandProcessor.js.map +0 -1
- package/dist/Command/globalArgs.js.map +0 -1
- package/dist/CommandLine/IProgressBar.js.map +0 -1
- package/dist/CommandLine/progressBarFactory.js.map +0 -1
- package/dist/CustomScript/Generate/customScriptGenerateCommand.js.map +0 -1
- package/dist/CustomScript/Generate/customScriptGenerateFacade.js.map +0 -1
- package/dist/CustomScript/Upload/customScriptUploadCommand.js.map +0 -1
- package/dist/CustomScript/customScriptCommand.js.map +0 -1
- package/dist/CustomScript/customScriptFacade.js.map +0 -1
- package/dist/Device/Connect/connectCommand.js.map +0 -1
- package/dist/Device/Content/setContentCommand.js.map +0 -1
- package/dist/Device/PowerAction/powerActionCommand.js.map +0 -1
- package/dist/Device/deviceCommand.js.map +0 -1
- package/dist/Device/deviceFacade.js.map +0 -1
- package/dist/Emulator/IEmulator.js.map +0 -1
- package/dist/Emulator/createDomain.js.map +0 -1
- package/dist/Emulator/emulatorFacade.js.map +0 -1
- package/dist/Emulator/emulatorFactory.js.map +0 -1
- package/dist/Firmware/Upload/firmwareUploadCommand.js.map +0 -1
- package/dist/Firmware/Upload/firmwareUploadFacade.js.map +0 -1
- package/dist/Firmware/Upload/firmwareUploadHelper.js.map +0 -1
- package/dist/Firmware/firmwareCommand.js.map +0 -1
- package/dist/Lib/archive.js.map +0 -1
- package/dist/Lib/childProcess.js.map +0 -1
- package/dist/Lib/fileSystem.js.map +0 -1
- package/dist/Lib/git.js.map +0 -1
- package/dist/Organization/Get/organizationGetCommand.js.map +0 -1
- package/dist/Organization/List/organizationListCommand.js.map +0 -1
- package/dist/Organization/SetDefault/organizationSetDefaultCommand.js.map +0 -1
- package/dist/Organization/organizationCommand.js.map +0 -1
- package/dist/Organization/organizationFacade.js.map +0 -1
- package/dist/RunControl/runControlHelper.js.map +0 -1
- package/dist/Timer/wait.js.map +0 -1
- package/dist/Timing/List/timingListCommand.js.map +0 -1
- package/dist/Timing/timingCommand.js.map +0 -1
- package/dist/generalCommand.js.map +0 -1
- package/dist/helper.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/parameters.js.map +0 -1
|
@@ -8,51 +8,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "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 (_) 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
|
-
}
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
13
|
};
|
|
38
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
15
|
exports.appletStart = exports.OPTION_LIST = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
16
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
+
const emulatorFactory_1 = require("../../Emulator/emulatorFactory");
|
|
18
|
+
const appletUploadCommandHelper_1 = require("../Upload/appletUploadCommandHelper");
|
|
19
|
+
const emulatorFacade_1 = require("../../Emulator/emulatorFacade");
|
|
20
|
+
const commandDefinition_1 = require("../../Command/commandDefinition");
|
|
21
|
+
const organizationFacade_1 = require("../../Organization/organizationFacade");
|
|
22
|
+
const dist_1 = require("@signageos/sdk/dist");
|
|
23
|
+
const wait_1 = __importDefault(require("../../Timer/wait"));
|
|
24
|
+
const appletServerHelper_1 = require("../appletServerHelper");
|
|
25
|
+
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
26
|
+
const parameters_1 = require("../../parameters");
|
|
27
|
+
const DEFAULT_PORT = 8090;
|
|
28
|
+
const PORT_OPTION = {
|
|
53
29
|
name: 'port',
|
|
54
30
|
type: Number,
|
|
55
|
-
description:
|
|
31
|
+
description: `Port where will the applet run`,
|
|
56
32
|
defaultValue: DEFAULT_PORT,
|
|
57
33
|
};
|
|
58
34
|
exports.OPTION_LIST = [
|
|
@@ -73,99 +49,61 @@ exports.appletStart = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
73
49
|
description: 'Start applet locally',
|
|
74
50
|
optionList: exports.OPTION_LIST,
|
|
75
51
|
commands: [],
|
|
76
|
-
run
|
|
52
|
+
run(options) {
|
|
77
53
|
var _a, _b;
|
|
78
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
publicUrl: appletPublicUrl,
|
|
127
|
-
detachProcess: detachProcess,
|
|
128
|
-
forwardServerUrl: forwardServerUrl,
|
|
129
|
-
})];
|
|
130
|
-
case 10:
|
|
131
|
-
appletHotReload = _d.sent();
|
|
132
|
-
_d.label = 11;
|
|
133
|
-
case 11:
|
|
134
|
-
createEmulatorParams = {
|
|
135
|
-
emulatorUid: emulatorUid,
|
|
136
|
-
appletUid: appletUid,
|
|
137
|
-
appletVersion: appletVersion,
|
|
138
|
-
appletPath: appletPath,
|
|
139
|
-
entryFileRelativePath: entryFileRelativePath,
|
|
140
|
-
emulatorServerPort: emulatorServerPort,
|
|
141
|
-
};
|
|
142
|
-
return [4 /*yield*/, (0, emulatorFactory_1.createEmulator)(createEmulatorParams, organizationUid, dev)];
|
|
143
|
-
case 12:
|
|
144
|
-
emulator = _d.sent();
|
|
145
|
-
stopServer = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
146
|
-
return __generator(this, function (_a) {
|
|
147
|
-
switch (_a.label) {
|
|
148
|
-
case 0: return [4 /*yield*/, (appletHotReload === null || appletHotReload === void 0 ? void 0 : appletHotReload.stop())];
|
|
149
|
-
case 1:
|
|
150
|
-
_a.sent();
|
|
151
|
-
return [4 /*yield*/, emulator.stop()];
|
|
152
|
-
case 2:
|
|
153
|
-
_a.sent();
|
|
154
|
-
process.exit();
|
|
155
|
-
return [2 /*return*/];
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
}); };
|
|
159
|
-
process.on('SIGINT', stopServer);
|
|
160
|
-
process.on('SIGTERM', stopServer);
|
|
161
|
-
console.info('Press Ctrl+C to stop');
|
|
162
|
-
return [4 /*yield*/, (0, wait_1.default)(1e9)];
|
|
163
|
-
case 13:
|
|
164
|
-
_d.sent(); // Wait forever
|
|
165
|
-
return [2 /*return*/];
|
|
166
|
-
}
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const currentDirectory = process.cwd();
|
|
56
|
+
const organizationUid = yield (0, organizationFacade_1.getOrganizationUidOrDefaultOrSelect)(options);
|
|
57
|
+
const entryFileAbsolutePath = yield (0, appletUploadCommandHelper_1.getAppletEntryFileAbsolutePath)(currentDirectory, options);
|
|
58
|
+
const appletPath = yield (0, appletUploadCommandHelper_1.getAppletDirectoryAbsolutePath)(currentDirectory, options);
|
|
59
|
+
const entryFileRelativePath = (0, appletUploadCommandHelper_1.getAppletEntryFileRelativePath)(entryFileAbsolutePath, appletPath);
|
|
60
|
+
const emulatorUid = yield (0, emulatorFacade_1.loadEmulatorOrCreateNewAndReturnUid)(organizationUid);
|
|
61
|
+
const dev = (0, dist_1.createDevelopment)({
|
|
62
|
+
organizationUid,
|
|
63
|
+
});
|
|
64
|
+
const emulatorServerPort = (_a = options[PORT_OPTION.name]) !== null && _a !== void 0 ? _a : DEFAULT_PORT;
|
|
65
|
+
const hotReloadEnabled = options[appletServerHelper_1.HOT_RELOAD_OPTION.name];
|
|
66
|
+
const appletPort = options[appletServerHelper_1.SERVER_PORT_OPTION.name];
|
|
67
|
+
const appletPublicUrl = options[appletServerHelper_1.SERVER_PUBLIC_URL_OPTION.name];
|
|
68
|
+
const detachProcess = options[appletServerHelper_1.DETACH_PROCESS_OPTION.name];
|
|
69
|
+
const forwardServerUrl = (_b = options[appletServerHelper_1.FORWARD_SERVER_URL_OPTION.name]) !== null && _b !== void 0 ? _b : parameters_1.parameters.forwardServerUrl;
|
|
70
|
+
let appletUid;
|
|
71
|
+
let appletVersion;
|
|
72
|
+
try {
|
|
73
|
+
({ appletUid, appletVersion } = yield dev.applet.identification.getAppletUidAndVersion(appletPath));
|
|
74
|
+
}
|
|
75
|
+
catch (_c) {
|
|
76
|
+
(0, log_1.log)('warning', chalk_1.default.yellow('Applet is not uploaded yet. It cannot be developed on real device.'));
|
|
77
|
+
}
|
|
78
|
+
yield (0, appletServerHelper_1.killAppletServerIfRunningAndForceOption)(dev, options, appletUid, appletVersion, appletPort);
|
|
79
|
+
let appletHotReload;
|
|
80
|
+
if (hotReloadEnabled) {
|
|
81
|
+
appletHotReload = yield dev.applet.startHotReload({
|
|
82
|
+
appletPath: appletPath,
|
|
83
|
+
port: appletPort,
|
|
84
|
+
publicUrl: appletPublicUrl,
|
|
85
|
+
detachProcess,
|
|
86
|
+
forwardServerUrl,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
const createEmulatorParams = {
|
|
90
|
+
emulatorUid,
|
|
91
|
+
appletUid,
|
|
92
|
+
appletVersion,
|
|
93
|
+
appletPath,
|
|
94
|
+
entryFileRelativePath,
|
|
95
|
+
emulatorServerPort,
|
|
96
|
+
};
|
|
97
|
+
const emulator = yield (0, emulatorFactory_1.createEmulator)(createEmulatorParams, organizationUid, dev);
|
|
98
|
+
const stopServer = () => __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
yield (appletHotReload === null || appletHotReload === void 0 ? void 0 : appletHotReload.stop());
|
|
100
|
+
yield emulator.stop();
|
|
101
|
+
process.exit();
|
|
167
102
|
});
|
|
103
|
+
process.on('SIGINT', stopServer);
|
|
104
|
+
process.on('SIGTERM', stopServer);
|
|
105
|
+
console.info('Press Ctrl+C to stop');
|
|
106
|
+
yield (0, wait_1.default)(1e9); // Wait forever
|
|
168
107
|
});
|
|
169
108
|
},
|
|
170
109
|
});
|
|
171
|
-
//# sourceMappingURL=appletStartCommand.js.map
|
|
@@ -8,72 +8,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "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 (_) 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));
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
62
13
|
};
|
|
63
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
15
|
exports.appletTestRun = void 0;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
16
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
+
const prompts_1 = __importDefault(require("prompts"));
|
|
18
|
+
const helper_1 = require("../../../helper");
|
|
19
|
+
const organizationFacade_1 = require("../../../Organization/organizationFacade");
|
|
20
|
+
const appletFacade_1 = require("../../appletFacade");
|
|
21
|
+
const progressBarFactory_1 = require("../../../CommandLine/progressBarFactory");
|
|
22
|
+
const deviceFacade_1 = require("../../../Device/deviceFacade");
|
|
23
|
+
const appletTestRunFacade_1 = require("./appletTestRunFacade");
|
|
24
|
+
const wait_1 = __importDefault(require("../../../Timer/wait"));
|
|
25
|
+
const commandDefinition_1 = require("../../../Command/commandDefinition");
|
|
26
|
+
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
27
|
+
const OPTION_LIST = [
|
|
77
28
|
organizationFacade_1.NO_DEFAULT_ORGANIZATION_OPTION,
|
|
78
29
|
deviceFacade_1.DEVICE_UID_OPTION,
|
|
79
30
|
organizationFacade_1.ORGANIZATION_UID_OPTION,
|
|
@@ -82,12 +33,12 @@ var OPTION_LIST = [
|
|
|
82
33
|
name: 'test',
|
|
83
34
|
type: String,
|
|
84
35
|
multiple: true,
|
|
85
|
-
description:
|
|
36
|
+
description: `Specify the test identifiers/files to be run. If not specified, all will be run.`,
|
|
86
37
|
},
|
|
87
38
|
{
|
|
88
39
|
name: 'yes',
|
|
89
40
|
type: Boolean,
|
|
90
|
-
description:
|
|
41
|
+
description: `Allow to run applet test without confirmation step`,
|
|
91
42
|
},
|
|
92
43
|
];
|
|
93
44
|
exports.appletTestRun = (0, commandDefinition_1.createCommandDefinition)({
|
|
@@ -95,128 +46,89 @@ exports.appletTestRun = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
95
46
|
description: 'Runs applet tests',
|
|
96
47
|
optionList: OPTION_LIST,
|
|
97
48
|
commands: [],
|
|
98
|
-
run
|
|
49
|
+
run(options) {
|
|
99
50
|
var _a, _b, _c, _d;
|
|
100
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
_e.label = 13;
|
|
159
|
-
case 13:
|
|
160
|
-
_e.trys.push([13, , 20, 21]);
|
|
161
|
-
progressBar.init({
|
|
162
|
-
size: tests.length,
|
|
163
|
-
name: RUNNING_TEST_TITLE,
|
|
164
|
-
});
|
|
165
|
-
return [4 /*yield*/, restApi.device.appletTest.run(device.uid, applet.uid, appletVersion.version, tests)];
|
|
166
|
-
case 14:
|
|
167
|
-
_e.sent();
|
|
168
|
-
deviceAppletTest = void 0;
|
|
169
|
-
_e.label = 15;
|
|
170
|
-
case 15: return [4 /*yield*/, (0, wait_1.default)(1e3)];
|
|
171
|
-
case 16:
|
|
172
|
-
_e.sent();
|
|
173
|
-
lastCountFinished = ((_a = deviceAppletTest === null || deviceAppletTest === void 0 ? void 0 : deviceAppletTest.successfulTests.length) !== null && _a !== void 0 ? _a : 0) + ((_b = deviceAppletTest === null || deviceAppletTest === void 0 ? void 0 : deviceAppletTest.failedTests.length) !== null && _b !== void 0 ? _b : 0);
|
|
174
|
-
return [4 /*yield*/, restApi.device.appletTest.get(device.uid, applet.uid, appletVersion.version)];
|
|
175
|
-
case 17:
|
|
176
|
-
deviceAppletTest = _e.sent();
|
|
177
|
-
nextCountFinished = ((_c = deviceAppletTest === null || deviceAppletTest === void 0 ? void 0 : deviceAppletTest.successfulTests.length) !== null && _c !== void 0 ? _c : 0) + ((_d = deviceAppletTest === null || deviceAppletTest === void 0 ? void 0 : deviceAppletTest.failedTests.length) !== null && _d !== void 0 ? _d : 0);
|
|
178
|
-
progressName = RUNNING_TEST_TITLE +
|
|
179
|
-
' ' +
|
|
180
|
-
__spreadArray(__spreadArray(__spreadArray([], __read(deviceAppletTest.failedTests.map(function (t) { return chalk_1.default.red(t); })), false), __read(deviceAppletTest.successfulTests.map(function (t) { return chalk_1.default.green(t); })), false), __read(deviceAppletTest.pendingTests.map(function (t) { return chalk_1.default.gray(t); })), false).join(',');
|
|
181
|
-
progressBar.update({
|
|
182
|
-
add: nextCountFinished - lastCountFinished,
|
|
183
|
-
name: progressName,
|
|
184
|
-
});
|
|
185
|
-
_e.label = 18;
|
|
186
|
-
case 18:
|
|
187
|
-
if (!(deviceAppletTest === null || deviceAppletTest === void 0 ? void 0 : deviceAppletTest.finishedAt)) return [3 /*break*/, 15];
|
|
188
|
-
_e.label = 19;
|
|
189
|
-
case 19:
|
|
190
|
-
if (deviceAppletTest.failedTests.length > 0) {
|
|
191
|
-
displayFailureMessage(applet.name, appletVersion.version, deviceAppletTest);
|
|
192
|
-
throw new Error("Tests run failed");
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
displaySuccessMessage(applet.name, appletVersion.version, deviceAppletTest);
|
|
196
|
-
}
|
|
197
|
-
return [3 /*break*/, 21];
|
|
198
|
-
case 20:
|
|
199
|
-
progressBar.end();
|
|
200
|
-
return [7 /*endfinally*/];
|
|
201
|
-
case 21: return [2 /*return*/];
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
const skipConfirmation = !!options.yes;
|
|
53
|
+
let tests = options.test;
|
|
54
|
+
const currentDirectory = process.cwd();
|
|
55
|
+
const organizationUid = yield (0, organizationFacade_1.getOrganizationUidOrDefaultOrSelect)(options);
|
|
56
|
+
const organization = yield (0, organizationFacade_1.getOrganization)(organizationUid);
|
|
57
|
+
const restApi = yield (0, helper_1.createOrganizationRestApi)(organization);
|
|
58
|
+
const deviceUid = yield (0, deviceFacade_1.getDeviceUid)(restApi, options);
|
|
59
|
+
const device = yield restApi.device.get(deviceUid);
|
|
60
|
+
const version = yield (0, appletFacade_1.getAppletVersion)(currentDirectory);
|
|
61
|
+
const appletUid = yield (0, appletFacade_1.getAppletUid)(restApi, options);
|
|
62
|
+
const applet = yield restApi.applet.get(appletUid);
|
|
63
|
+
const appletVersion = yield restApi.applet.version.get(appletUid, version);
|
|
64
|
+
const testSuites = yield restApi.applet.tests.list(applet.uid, appletVersion.version);
|
|
65
|
+
if (!tests || tests.length === 0) {
|
|
66
|
+
tests = testSuites.map((testSuite) => testSuite.identifier);
|
|
67
|
+
}
|
|
68
|
+
(0, appletTestRunFacade_1.validateTestIdentifiers)(tests, testSuites);
|
|
69
|
+
printRunTests(tests);
|
|
70
|
+
if (!skipConfirmation) {
|
|
71
|
+
const response = yield (0, prompts_1.default)({
|
|
72
|
+
type: 'confirm',
|
|
73
|
+
name: 'continue',
|
|
74
|
+
message: `Do you want to start testing ${chalk_1.default.green(applet.name)} ` + `and version ${chalk_1.default.green(version)} on device ${device.name}?`,
|
|
75
|
+
});
|
|
76
|
+
if (!response.continue) {
|
|
77
|
+
throw new Error(`Applet tests canceled`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const RUNNING_TEST_TITLE = `Running applet tests`;
|
|
81
|
+
const progressBar = (0, progressBarFactory_1.createProgressBar)();
|
|
82
|
+
try {
|
|
83
|
+
progressBar.init({
|
|
84
|
+
size: tests.length,
|
|
85
|
+
name: RUNNING_TEST_TITLE,
|
|
86
|
+
});
|
|
87
|
+
yield restApi.device.appletTest.run(device.uid, applet.uid, appletVersion.version, tests);
|
|
88
|
+
let deviceAppletTest;
|
|
89
|
+
do {
|
|
90
|
+
yield (0, wait_1.default)(1e3);
|
|
91
|
+
const lastCountFinished = ((_a = deviceAppletTest === null || deviceAppletTest === void 0 ? void 0 : deviceAppletTest.successfulTests.length) !== null && _a !== void 0 ? _a : 0) + ((_b = deviceAppletTest === null || deviceAppletTest === void 0 ? void 0 : deviceAppletTest.failedTests.length) !== null && _b !== void 0 ? _b : 0);
|
|
92
|
+
deviceAppletTest = yield restApi.device.appletTest.get(device.uid, applet.uid, appletVersion.version);
|
|
93
|
+
const nextCountFinished = ((_c = deviceAppletTest === null || deviceAppletTest === void 0 ? void 0 : deviceAppletTest.successfulTests.length) !== null && _c !== void 0 ? _c : 0) + ((_d = deviceAppletTest === null || deviceAppletTest === void 0 ? void 0 : deviceAppletTest.failedTests.length) !== null && _d !== void 0 ? _d : 0);
|
|
94
|
+
const progressName = RUNNING_TEST_TITLE +
|
|
95
|
+
' ' +
|
|
96
|
+
[
|
|
97
|
+
...deviceAppletTest.failedTests.map((t) => chalk_1.default.red(t)),
|
|
98
|
+
...deviceAppletTest.successfulTests.map((t) => chalk_1.default.green(t)),
|
|
99
|
+
...deviceAppletTest.pendingTests.map((t) => chalk_1.default.gray(t)),
|
|
100
|
+
].join(',');
|
|
101
|
+
progressBar.update({
|
|
102
|
+
add: nextCountFinished - lastCountFinished,
|
|
103
|
+
name: progressName,
|
|
104
|
+
});
|
|
105
|
+
} while (!(deviceAppletTest === null || deviceAppletTest === void 0 ? void 0 : deviceAppletTest.finishedAt));
|
|
106
|
+
if (deviceAppletTest.failedTests.length > 0) {
|
|
107
|
+
displayFailureMessage(applet.name, appletVersion.version, deviceAppletTest);
|
|
108
|
+
throw new Error(`Tests run failed`);
|
|
202
109
|
}
|
|
203
|
-
|
|
110
|
+
else {
|
|
111
|
+
displaySuccessMessage(applet.name, appletVersion.version, deviceAppletTest);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
finally {
|
|
115
|
+
progressBar.end();
|
|
116
|
+
}
|
|
204
117
|
});
|
|
205
118
|
},
|
|
206
119
|
});
|
|
207
120
|
function displaySuccessMessage(appletName, appletVersion, deviceAppletTest) {
|
|
208
|
-
(0, log_1.log)('info',
|
|
209
|
-
deviceAppletTest.successfulTests.forEach(
|
|
121
|
+
(0, log_1.log)('info', `Applet ${chalk_1.default.green(appletName)} version ${chalk_1.default.green(appletVersion)} tests ${chalk_1.default.green('succeeded')}.`);
|
|
122
|
+
deviceAppletTest.successfulTests.forEach((file) => (0, log_1.log)('info', chalk_1.default.green('✓ ' + file)));
|
|
210
123
|
}
|
|
211
124
|
function displayFailureMessage(appletName, appletVersion, deviceAppletTest) {
|
|
212
|
-
(0, log_1.log)('info',
|
|
213
|
-
deviceAppletTest.failedTests.forEach(
|
|
214
|
-
deviceAppletTest.successfulTests.forEach(
|
|
125
|
+
(0, log_1.log)('info', `Applet ${chalk_1.default.green(appletName)} version ${chalk_1.default.green(appletVersion)} tests ${chalk_1.default.red('failed')}.`);
|
|
126
|
+
deviceAppletTest.failedTests.forEach((file) => (0, log_1.log)('info', chalk_1.default.red('× ' + file)));
|
|
127
|
+
deviceAppletTest.successfulTests.forEach((file) => (0, log_1.log)('info', chalk_1.default.green('✓ ' + file)));
|
|
215
128
|
}
|
|
216
129
|
function printRunTests(identifiers) {
|
|
217
130
|
if (identifiers.length > 0) {
|
|
218
|
-
(0, log_1.log)('info', chalk_1.default.yellow(
|
|
131
|
+
(0, log_1.log)('info', chalk_1.default.yellow(`Next test files are going to be run...`));
|
|
219
132
|
}
|
|
220
|
-
identifiers.forEach(
|
|
133
|
+
identifiers.forEach((file) => (0, log_1.log)('info', file));
|
|
221
134
|
}
|
|
222
|
-
//# sourceMappingURL=appletTestRunCommand.js.map
|
|
@@ -1,35 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __values = (this && this.__values) || function(o) {
|
|
3
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
-
if (m) return m.call(o);
|
|
5
|
-
if (o && typeof o.length === "number") return {
|
|
6
|
-
next: function () {
|
|
7
|
-
if (o && i >= o.length) o = void 0;
|
|
8
|
-
return { value: o && o[i++], done: !o };
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
-
};
|
|
13
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
3
|
exports.validateTestIdentifiers = void 0;
|
|
15
4
|
function validateTestIdentifiers(identifiers, suites) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var identifier = identifiers_1_1.value;
|
|
21
|
-
if (!existingIdentifiers.includes(identifier)) {
|
|
22
|
-
throw new Error("Test ".concat(identifier, " is not in currently uploaded test suites."));
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
27
|
-
finally {
|
|
28
|
-
try {
|
|
29
|
-
if (identifiers_1_1 && !identifiers_1_1.done && (_a = identifiers_1.return)) _a.call(identifiers_1);
|
|
5
|
+
const existingIdentifiers = suites.map((suite) => suite.identifier);
|
|
6
|
+
for (const identifier of identifiers) {
|
|
7
|
+
if (!existingIdentifiers.includes(identifier)) {
|
|
8
|
+
throw new Error(`Test ${identifier} is not in currently uploaded test suites.`);
|
|
30
9
|
}
|
|
31
|
-
finally { if (e_1) throw e_1.error; }
|
|
32
10
|
}
|
|
33
11
|
}
|
|
34
12
|
exports.validateTestIdentifiers = validateTestIdentifiers;
|
|
35
|
-
//# sourceMappingURL=appletTestRunFacade.js.map
|