@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.
Files changed (127) hide show
  1. package/README.md +1 -0
  2. package/dist/Applet/Build/appletBuildCommand.js +28 -72
  3. package/dist/Applet/Generate/Templates/rspack.config.mjs.template +12 -12
  4. package/dist/Applet/Generate/appletGenerateCommand.d.ts +23 -62
  5. package/dist/Applet/Generate/appletGenerateCommand.js +398 -365
  6. package/dist/Applet/Start/appletStartCommand.js +69 -131
  7. package/dist/Applet/Test/Upload/appletTestRunCommand.js +89 -177
  8. package/dist/Applet/Test/Upload/appletTestRunFacade.js +4 -27
  9. package/dist/Applet/Test/Upload/appletTestUploadCommand.js +98 -223
  10. package/dist/Applet/Test/Upload/appletTestUploadFacade.js +39 -102
  11. package/dist/Applet/Test/appletTestCommand.js +6 -36
  12. package/dist/Applet/Upload/appletUploadCommand.js +199 -305
  13. package/dist/Applet/Upload/appletUploadCommandHelper.js +103 -138
  14. package/dist/Applet/Upload/appletUploadFacade.d.ts +2 -2
  15. package/dist/Applet/Upload/appletUploadFacade.js +172 -263
  16. package/dist/Applet/Upload/appletUploadFacadeHelper.js +39 -52
  17. package/dist/Applet/appletCommand.d.ts +22 -62
  18. package/dist/Applet/appletCommand.js +9 -39
  19. package/dist/Applet/appletErrors.js +5 -24
  20. package/dist/Applet/appletFacade.js +106 -141
  21. package/dist/Applet/appletServerHelper.js +16 -53
  22. package/dist/Auth/loginCommand.js +96 -137
  23. package/dist/Cache/tmpCache.js +35 -13
  24. package/dist/Cli/helper.js +1 -2
  25. package/dist/Cli/packageVersion.js +82 -123
  26. package/dist/Command/commandDefinition.js +0 -1
  27. package/dist/Command/commandProcessor.js +40 -129
  28. package/dist/Command/globalArgs.js +7 -5
  29. package/dist/CommandLine/IProgressBar.js +0 -1
  30. package/dist/CommandLine/progressBarFactory.js +31 -11
  31. package/dist/CustomScript/Generate/customScriptGenerateCommand.js +17 -56
  32. package/dist/CustomScript/Generate/customScriptGenerateFacade.js +82 -106
  33. package/dist/CustomScript/Upload/customScriptUploadCommand.js +44 -120
  34. package/dist/CustomScript/customScriptCommand.js +6 -36
  35. package/dist/CustomScript/customScriptFacade.js +175 -294
  36. package/dist/Device/Connect/connectCommand.js +72 -136
  37. package/dist/Device/Content/setContentCommand.js +33 -78
  38. package/dist/Device/PowerAction/powerActionCommand.js +22 -65
  39. package/dist/Device/deviceCommand.js +7 -37
  40. package/dist/Device/deviceFacade.js +67 -123
  41. package/dist/Emulator/IEmulator.js +0 -1
  42. package/dist/Emulator/createDomain.js +33 -12
  43. package/dist/Emulator/emulatorFacade.js +74 -131
  44. package/dist/Emulator/emulatorFactory.js +112 -124
  45. package/dist/Firmware/Upload/firmwareUploadCommand.js +133 -221
  46. package/dist/Firmware/Upload/firmwareUploadFacade.js +64 -110
  47. package/dist/Firmware/Upload/firmwareUploadHelper.js +27 -5
  48. package/dist/Firmware/firmwareCommand.js +5 -35
  49. package/dist/Lib/archive.js +45 -60
  50. package/dist/Lib/childProcess.js +27 -5
  51. package/dist/Lib/fileSystem.js +62 -82
  52. package/dist/Lib/git.d.ts +1 -1
  53. package/dist/Lib/git.js +44 -82
  54. package/dist/Organization/Get/organizationGetCommand.js +14 -50
  55. package/dist/Organization/List/organizationListCommand.js +12 -46
  56. package/dist/Organization/SetDefault/organizationSetDefaultCommand.js +18 -56
  57. package/dist/Organization/organizationCommand.js +7 -37
  58. package/dist/Organization/organizationFacade.js +97 -172
  59. package/dist/RunControl/runControlHelper.js +11 -60
  60. package/dist/Timer/wait.js +1 -2
  61. package/dist/Timing/List/timingListCommand.js +20 -62
  62. package/dist/Timing/timingCommand.js +5 -35
  63. package/dist/generalCommand.js +1 -2
  64. package/dist/helper.js +48 -109
  65. package/dist/index.js +15 -45
  66. package/dist/parameters.js +17 -40
  67. package/package.json +16 -18
  68. package/dist/Applet/Build/appletBuildCommand.js.map +0 -1
  69. package/dist/Applet/Generate/appletGenerateCommand.js.map +0 -1
  70. package/dist/Applet/Start/appletStartCommand.js.map +0 -1
  71. package/dist/Applet/Test/Upload/appletTestRunCommand.js.map +0 -1
  72. package/dist/Applet/Test/Upload/appletTestRunFacade.js.map +0 -1
  73. package/dist/Applet/Test/Upload/appletTestUploadCommand.js.map +0 -1
  74. package/dist/Applet/Test/Upload/appletTestUploadFacade.js.map +0 -1
  75. package/dist/Applet/Test/appletTestCommand.js.map +0 -1
  76. package/dist/Applet/Upload/appletUploadCommand.js.map +0 -1
  77. package/dist/Applet/Upload/appletUploadCommandHelper.js.map +0 -1
  78. package/dist/Applet/Upload/appletUploadFacade.js.map +0 -1
  79. package/dist/Applet/Upload/appletUploadFacadeHelper.js.map +0 -1
  80. package/dist/Applet/appletCommand.js.map +0 -1
  81. package/dist/Applet/appletErrors.js.map +0 -1
  82. package/dist/Applet/appletFacade.js.map +0 -1
  83. package/dist/Applet/appletServerHelper.js.map +0 -1
  84. package/dist/Auth/loginCommand.js.map +0 -1
  85. package/dist/Cache/tmpCache.js.map +0 -1
  86. package/dist/Cli/helper.js.map +0 -1
  87. package/dist/Cli/packageVersion.js.map +0 -1
  88. package/dist/Command/commandDefinition.js.map +0 -1
  89. package/dist/Command/commandProcessor.js.map +0 -1
  90. package/dist/Command/globalArgs.js.map +0 -1
  91. package/dist/CommandLine/IProgressBar.js.map +0 -1
  92. package/dist/CommandLine/progressBarFactory.js.map +0 -1
  93. package/dist/CustomScript/Generate/customScriptGenerateCommand.js.map +0 -1
  94. package/dist/CustomScript/Generate/customScriptGenerateFacade.js.map +0 -1
  95. package/dist/CustomScript/Upload/customScriptUploadCommand.js.map +0 -1
  96. package/dist/CustomScript/customScriptCommand.js.map +0 -1
  97. package/dist/CustomScript/customScriptFacade.js.map +0 -1
  98. package/dist/Device/Connect/connectCommand.js.map +0 -1
  99. package/dist/Device/Content/setContentCommand.js.map +0 -1
  100. package/dist/Device/PowerAction/powerActionCommand.js.map +0 -1
  101. package/dist/Device/deviceCommand.js.map +0 -1
  102. package/dist/Device/deviceFacade.js.map +0 -1
  103. package/dist/Emulator/IEmulator.js.map +0 -1
  104. package/dist/Emulator/createDomain.js.map +0 -1
  105. package/dist/Emulator/emulatorFacade.js.map +0 -1
  106. package/dist/Emulator/emulatorFactory.js.map +0 -1
  107. package/dist/Firmware/Upload/firmwareUploadCommand.js.map +0 -1
  108. package/dist/Firmware/Upload/firmwareUploadFacade.js.map +0 -1
  109. package/dist/Firmware/Upload/firmwareUploadHelper.js.map +0 -1
  110. package/dist/Firmware/firmwareCommand.js.map +0 -1
  111. package/dist/Lib/archive.js.map +0 -1
  112. package/dist/Lib/childProcess.js.map +0 -1
  113. package/dist/Lib/fileSystem.js.map +0 -1
  114. package/dist/Lib/git.js.map +0 -1
  115. package/dist/Organization/Get/organizationGetCommand.js.map +0 -1
  116. package/dist/Organization/List/organizationListCommand.js.map +0 -1
  117. package/dist/Organization/SetDefault/organizationSetDefaultCommand.js.map +0 -1
  118. package/dist/Organization/organizationCommand.js.map +0 -1
  119. package/dist/Organization/organizationFacade.js.map +0 -1
  120. package/dist/RunControl/runControlHelper.js.map +0 -1
  121. package/dist/Timer/wait.js.map +0 -1
  122. package/dist/Timing/List/timingListCommand.js.map +0 -1
  123. package/dist/Timing/timingCommand.js.map +0 -1
  124. package/dist/generalCommand.js.map +0 -1
  125. package/dist/helper.js.map +0 -1
  126. package/dist/index.js.map +0 -1
  127. 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 __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;
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
- var chalk_1 = require("chalk");
41
- var emulatorFactory_1 = require("../../Emulator/emulatorFactory");
42
- var appletUploadCommandHelper_1 = require("../Upload/appletUploadCommandHelper");
43
- var emulatorFacade_1 = require("../../Emulator/emulatorFacade");
44
- var commandDefinition_1 = require("../../Command/commandDefinition");
45
- var organizationFacade_1 = require("../../Organization/organizationFacade");
46
- var dist_1 = require("@signageos/sdk/dist");
47
- var wait_1 = require("../../Timer/wait");
48
- var appletServerHelper_1 = require("../appletServerHelper");
49
- var log_1 = require("@signageos/sdk/dist/Console/log");
50
- var parameters_1 = require("../../parameters");
51
- var DEFAULT_PORT = 8090;
52
- var PORT_OPTION = {
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: "Port where will the applet run",
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: function (options) {
52
+ run(options) {
77
53
  var _a, _b;
78
- return __awaiter(this, void 0, void 0, function () {
79
- var currentDirectory, organizationUid, entryFileAbsolutePath, appletPath, entryFileRelativePath, emulatorUid, dev, emulatorServerPort, hotReloadEnabled, appletPort, appletPublicUrl, detachProcess, forwardServerUrl, appletUid, appletVersion, e_1, appletHotReload, createEmulatorParams, emulator, stopServer;
80
- var _c;
81
- var _this = this;
82
- return __generator(this, function (_d) {
83
- switch (_d.label) {
84
- case 0:
85
- currentDirectory = process.cwd();
86
- return [4 /*yield*/, (0, organizationFacade_1.getOrganizationUidOrDefaultOrSelect)(options)];
87
- case 1:
88
- organizationUid = _d.sent();
89
- return [4 /*yield*/, (0, appletUploadCommandHelper_1.getAppletEntryFileAbsolutePath)(currentDirectory, options)];
90
- case 2:
91
- entryFileAbsolutePath = _d.sent();
92
- return [4 /*yield*/, (0, appletUploadCommandHelper_1.getAppletDirectoryAbsolutePath)(currentDirectory, options)];
93
- case 3:
94
- appletPath = _d.sent();
95
- entryFileRelativePath = (0, appletUploadCommandHelper_1.getAppletEntryFileRelativePath)(entryFileAbsolutePath, appletPath);
96
- return [4 /*yield*/, (0, emulatorFacade_1.loadEmulatorOrCreateNewAndReturnUid)(organizationUid)];
97
- case 4:
98
- emulatorUid = _d.sent();
99
- dev = (0, dist_1.createDevelopment)({
100
- organizationUid: organizationUid,
101
- });
102
- emulatorServerPort = (_a = options[PORT_OPTION.name]) !== null && _a !== void 0 ? _a : DEFAULT_PORT;
103
- hotReloadEnabled = options[appletServerHelper_1.HOT_RELOAD_OPTION.name];
104
- appletPort = options[appletServerHelper_1.SERVER_PORT_OPTION.name];
105
- appletPublicUrl = options[appletServerHelper_1.SERVER_PUBLIC_URL_OPTION.name];
106
- detachProcess = options[appletServerHelper_1.DETACH_PROCESS_OPTION.name];
107
- forwardServerUrl = (_b = options[appletServerHelper_1.FORWARD_SERVER_URL_OPTION.name]) !== null && _b !== void 0 ? _b : parameters_1.parameters.forwardServerUrl;
108
- _d.label = 5;
109
- case 5:
110
- _d.trys.push([5, 7, , 8]);
111
- return [4 /*yield*/, dev.applet.identification.getAppletUidAndVersion(appletPath)];
112
- case 6:
113
- (_c = _d.sent(), appletUid = _c.appletUid, appletVersion = _c.appletVersion);
114
- return [3 /*break*/, 8];
115
- case 7:
116
- e_1 = _d.sent();
117
- (0, log_1.log)('warning', chalk_1.default.yellow('Applet is not uploaded yet. It cannot be developed on real device.'));
118
- return [3 /*break*/, 8];
119
- case 8: return [4 /*yield*/, (0, appletServerHelper_1.killAppletServerIfRunningAndForceOption)(dev, options, appletUid, appletVersion, appletPort)];
120
- case 9:
121
- _d.sent();
122
- if (!hotReloadEnabled) return [3 /*break*/, 11];
123
- return [4 /*yield*/, dev.applet.startHotReload({
124
- appletPath: appletPath,
125
- port: appletPort,
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 __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;
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
- var chalk_1 = require("chalk");
66
- var prompts = require("prompts");
67
- var helper_1 = require("../../../helper");
68
- var organizationFacade_1 = require("../../../Organization/organizationFacade");
69
- var appletFacade_1 = require("../../appletFacade");
70
- var progressBarFactory_1 = require("../../../CommandLine/progressBarFactory");
71
- var deviceFacade_1 = require("../../../Device/deviceFacade");
72
- var appletTestRunFacade_1 = require("./appletTestRunFacade");
73
- var wait_1 = require("../../../Timer/wait");
74
- var commandDefinition_1 = require("../../../Command/commandDefinition");
75
- var log_1 = require("@signageos/sdk/dist/Console/log");
76
- var OPTION_LIST = [
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: "Specify the test identifiers/files to be run. If not specified, all will be run.",
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: "Allow to run applet test without confirmation step",
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: function (options) {
49
+ run(options) {
99
50
  var _a, _b, _c, _d;
100
- return __awaiter(this, void 0, void 0, function () {
101
- var skipConfirmation, tests, currentDirectory, organizationUid, organization, restApi, deviceUid, device, version, appletUid, applet, appletVersion, testSuites, response, RUNNING_TEST_TITLE, progressBar, deviceAppletTest, lastCountFinished, nextCountFinished, progressName;
102
- return __generator(this, function (_e) {
103
- switch (_e.label) {
104
- case 0:
105
- skipConfirmation = !!options.yes;
106
- tests = options.test;
107
- currentDirectory = process.cwd();
108
- return [4 /*yield*/, (0, organizationFacade_1.getOrganizationUidOrDefaultOrSelect)(options)];
109
- case 1:
110
- organizationUid = _e.sent();
111
- return [4 /*yield*/, (0, organizationFacade_1.getOrganization)(organizationUid)];
112
- case 2:
113
- organization = _e.sent();
114
- return [4 /*yield*/, (0, helper_1.createOrganizationRestApi)(organization)];
115
- case 3:
116
- restApi = _e.sent();
117
- return [4 /*yield*/, (0, deviceFacade_1.getDeviceUid)(restApi, options)];
118
- case 4:
119
- deviceUid = _e.sent();
120
- return [4 /*yield*/, restApi.device.get(deviceUid)];
121
- case 5:
122
- device = _e.sent();
123
- return [4 /*yield*/, (0, appletFacade_1.getAppletVersion)(currentDirectory)];
124
- case 6:
125
- version = _e.sent();
126
- return [4 /*yield*/, (0, appletFacade_1.getAppletUid)(restApi, options)];
127
- case 7:
128
- appletUid = _e.sent();
129
- return [4 /*yield*/, restApi.applet.get(appletUid)];
130
- case 8:
131
- applet = _e.sent();
132
- return [4 /*yield*/, restApi.applet.version.get(appletUid, version)];
133
- case 9:
134
- appletVersion = _e.sent();
135
- return [4 /*yield*/, restApi.applet.tests.list(applet.uid, appletVersion.version)];
136
- case 10:
137
- testSuites = _e.sent();
138
- if (!tests || tests.length === 0) {
139
- tests = testSuites.map(function (testSuite) { return testSuite.identifier; });
140
- }
141
- (0, appletTestRunFacade_1.validateTestIdentifiers)(tests, testSuites);
142
- printRunTests(tests);
143
- if (!!skipConfirmation) return [3 /*break*/, 12];
144
- return [4 /*yield*/, prompts({
145
- type: 'confirm',
146
- name: 'continue',
147
- message: "Do you want to start testing ".concat(chalk_1.default.green(applet.name), " ") + "and version ".concat(chalk_1.default.green(version), " on device ").concat(device.name, "?"),
148
- })];
149
- case 11:
150
- response = _e.sent();
151
- if (!response.continue) {
152
- throw new Error("Applet tests canceled");
153
- }
154
- _e.label = 12;
155
- case 12:
156
- RUNNING_TEST_TITLE = "Running applet tests";
157
- progressBar = (0, progressBarFactory_1.createProgressBar)();
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', "Applet ".concat(chalk_1.default.green(appletName), " version ").concat(chalk_1.default.green(appletVersion), " tests ").concat(chalk_1.default.green('succeeded'), "."));
209
- deviceAppletTest.successfulTests.forEach(function (file) { return (0, log_1.log)('info', chalk_1.default.green('✓ ' + file)); });
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', "Applet ".concat(chalk_1.default.green(appletName), " version ").concat(chalk_1.default.green(appletVersion), " tests ").concat(chalk_1.default.red('failed'), "."));
213
- deviceAppletTest.failedTests.forEach(function (file) { return (0, log_1.log)('info', chalk_1.default.red('× ' + file)); });
214
- deviceAppletTest.successfulTests.forEach(function (file) { return (0, log_1.log)('info', chalk_1.default.green('✓ ' + file)); });
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("Next test files are going to be run..."));
131
+ (0, log_1.log)('info', chalk_1.default.yellow(`Next test files are going to be run...`));
219
132
  }
220
- identifiers.forEach(function (file) { return (0, log_1.log)('info', file); });
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
- var e_1, _a;
17
- var existingIdentifiers = suites.map(function (suite) { return suite.identifier; });
18
- try {
19
- for (var identifiers_1 = __values(identifiers), identifiers_1_1 = identifiers_1.next(); !identifiers_1_1.done; identifiers_1_1 = identifiers_1.next()) {
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