@signageos/cli 2.3.1 → 2.4.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.
Files changed (146) hide show
  1. package/README.md +54 -19
  2. package/dist/Applet/Build/appletBuildCommand.js +28 -72
  3. package/dist/Applet/Generate/Templates/CHANGELOG.md.template +7 -0
  4. package/dist/Applet/Generate/Templates/README.md.template +3 -0
  5. package/dist/Applet/Generate/Templates/rspack.config.mjs.template +12 -12
  6. package/dist/Applet/Generate/appletGenerateCommand.d.ts +23 -62
  7. package/dist/Applet/Generate/appletGenerateCommand.js +432 -365
  8. package/dist/Applet/Start/appletStartCommand.js +70 -132
  9. package/dist/Applet/Test/Upload/appletTestRunCommand.js +90 -178
  10. package/dist/Applet/Test/Upload/appletTestRunFacade.js +5 -29
  11. package/dist/Applet/Test/Upload/appletTestUploadCommand.js +99 -224
  12. package/dist/Applet/Test/Upload/appletTestUploadFacade.js +51 -105
  13. package/dist/Applet/Test/appletTestCommand.js +6 -36
  14. package/dist/Applet/Upload/appletUploadCommand.js +199 -305
  15. package/dist/Applet/Upload/appletUploadCommandHelper.js +129 -144
  16. package/dist/Applet/Upload/appletUploadFacade.d.ts +2 -2
  17. package/dist/Applet/Upload/appletUploadFacade.js +184 -265
  18. package/dist/Applet/Upload/appletUploadFacadeHelper.js +51 -55
  19. package/dist/Applet/appletCommand.d.ts +25 -157
  20. package/dist/Applet/appletCommand.js +9 -39
  21. package/dist/Applet/appletErrors.js +5 -24
  22. package/dist/Applet/appletFacade.js +122 -147
  23. package/dist/Applet/appletServerHelper.js +18 -55
  24. package/dist/Auth/loginCommand.d.ts +2 -2
  25. package/dist/Auth/loginCommand.js +105 -136
  26. package/dist/Cache/tmpCache.js +47 -16
  27. package/dist/Cli/helper.js +3 -5
  28. package/dist/Cli/packageVersion.js +99 -131
  29. package/dist/Command/Autocomplete/Install/installAutocompleteCommand.d.ts +10 -0
  30. package/dist/Command/Autocomplete/Install/installAutocompleteCommand.js +39 -0
  31. package/dist/Command/Autocomplete/Install/installAutocompleteCommand.ts +30 -0
  32. package/dist/Command/Autocomplete/Install/sos-completion.sh +63 -0
  33. package/dist/Command/Autocomplete/Uninstall/uninstallAutocompleteCommand.d.ts +8 -0
  34. package/dist/Command/Autocomplete/Uninstall/uninstallAutocompleteCommand.js +120 -0
  35. package/dist/Command/Autocomplete/autocompleteCommand.d.ts +22 -0
  36. package/dist/Command/Autocomplete/autocompleteCommand.js +32 -0
  37. package/dist/Command/autoComplete.d.ts +4 -0
  38. package/dist/Command/autoComplete.js +184 -0
  39. package/dist/Command/commandDefinition.d.ts +9 -9
  40. package/dist/Command/commandDefinition.js +1 -3
  41. package/dist/Command/commandProcessor.js +41 -131
  42. package/dist/Command/globalArgs.js +9 -8
  43. package/dist/CommandLine/IProgressBar.js +0 -1
  44. package/dist/CommandLine/progressBarFactory.d.ts +1 -1
  45. package/dist/CommandLine/progressBarFactory.js +42 -13
  46. package/dist/CustomScript/Generate/customScriptGenerateCommand.js +17 -56
  47. package/dist/CustomScript/Generate/customScriptGenerateFacade.js +94 -109
  48. package/dist/CustomScript/Upload/customScriptUploadCommand.js +44 -120
  49. package/dist/CustomScript/customScriptCommand.d.ts +1 -9
  50. package/dist/CustomScript/customScriptCommand.js +6 -36
  51. package/dist/CustomScript/customScriptFacade.d.ts +2 -2
  52. package/dist/CustomScript/customScriptFacade.js +187 -297
  53. package/dist/Device/Connect/connectCommand.js +73 -137
  54. package/dist/Device/Content/setContentCommand.js +33 -78
  55. package/dist/Device/PowerAction/powerActionCommand.js +22 -65
  56. package/dist/Device/deviceCommand.js +7 -37
  57. package/dist/Device/deviceFacade.js +71 -127
  58. package/dist/Emulator/IEmulator.js +0 -1
  59. package/dist/Emulator/createDomain.d.ts +0 -1
  60. package/dist/Emulator/createDomain.js +44 -14
  61. package/dist/Emulator/emulatorFacade.js +75 -133
  62. package/dist/Emulator/emulatorFactory.js +123 -126
  63. package/dist/Firmware/Upload/firmwareUploadCommand.js +133 -221
  64. package/dist/Firmware/Upload/firmwareUploadFacade.js +75 -112
  65. package/dist/Firmware/Upload/firmwareUploadHelper.js +38 -6
  66. package/dist/Firmware/firmwareCommand.js +5 -35
  67. package/dist/Lib/archive.js +56 -62
  68. package/dist/Lib/childProcess.js +37 -5
  69. package/dist/Lib/fileSystem.js +76 -87
  70. package/dist/Lib/git.d.ts +1 -1
  71. package/dist/Lib/git.js +58 -87
  72. package/dist/Organization/Get/organizationGetCommand.js +14 -50
  73. package/dist/Organization/List/organizationListCommand.js +12 -46
  74. package/dist/Organization/SetDefault/organizationSetDefaultCommand.js +18 -56
  75. package/dist/Organization/organizationCommand.js +7 -37
  76. package/dist/Organization/organizationFacade.js +102 -177
  77. package/dist/RunControl/runControlHelper.js +14 -64
  78. package/dist/Timer/wait.js +2 -3
  79. package/dist/Timing/List/timingListCommand.js +20 -62
  80. package/dist/Timing/timingCommand.js +5 -35
  81. package/dist/generalCommand.js +1 -2
  82. package/dist/helper.d.ts +4 -4
  83. package/dist/helper.js +61 -122
  84. package/dist/index.js +19 -46
  85. package/dist/parameters.js +17 -40
  86. package/package.json +52 -57
  87. package/dist/Applet/Build/appletBuildCommand.js.map +0 -1
  88. package/dist/Applet/Generate/appletGenerateCommand.js.map +0 -1
  89. package/dist/Applet/Start/appletStartCommand.js.map +0 -1
  90. package/dist/Applet/Test/Upload/appletTestRunCommand.js.map +0 -1
  91. package/dist/Applet/Test/Upload/appletTestRunFacade.js.map +0 -1
  92. package/dist/Applet/Test/Upload/appletTestUploadCommand.js.map +0 -1
  93. package/dist/Applet/Test/Upload/appletTestUploadFacade.js.map +0 -1
  94. package/dist/Applet/Test/appletTestCommand.js.map +0 -1
  95. package/dist/Applet/Upload/appletUploadCommand.js.map +0 -1
  96. package/dist/Applet/Upload/appletUploadCommandHelper.js.map +0 -1
  97. package/dist/Applet/Upload/appletUploadFacade.js.map +0 -1
  98. package/dist/Applet/Upload/appletUploadFacadeHelper.js.map +0 -1
  99. package/dist/Applet/appletCommand.js.map +0 -1
  100. package/dist/Applet/appletErrors.js.map +0 -1
  101. package/dist/Applet/appletFacade.js.map +0 -1
  102. package/dist/Applet/appletServerHelper.js.map +0 -1
  103. package/dist/Auth/loginCommand.js.map +0 -1
  104. package/dist/Cache/tmpCache.js.map +0 -1
  105. package/dist/Cli/helper.js.map +0 -1
  106. package/dist/Cli/packageVersion.js.map +0 -1
  107. package/dist/Command/commandDefinition.js.map +0 -1
  108. package/dist/Command/commandProcessor.js.map +0 -1
  109. package/dist/Command/globalArgs.js.map +0 -1
  110. package/dist/CommandLine/IProgressBar.js.map +0 -1
  111. package/dist/CommandLine/progressBarFactory.js.map +0 -1
  112. package/dist/CustomScript/Generate/customScriptGenerateCommand.js.map +0 -1
  113. package/dist/CustomScript/Generate/customScriptGenerateFacade.js.map +0 -1
  114. package/dist/CustomScript/Upload/customScriptUploadCommand.js.map +0 -1
  115. package/dist/CustomScript/customScriptCommand.js.map +0 -1
  116. package/dist/CustomScript/customScriptFacade.js.map +0 -1
  117. package/dist/Device/Connect/connectCommand.js.map +0 -1
  118. package/dist/Device/Content/setContentCommand.js.map +0 -1
  119. package/dist/Device/PowerAction/powerActionCommand.js.map +0 -1
  120. package/dist/Device/deviceCommand.js.map +0 -1
  121. package/dist/Device/deviceFacade.js.map +0 -1
  122. package/dist/Emulator/IEmulator.js.map +0 -1
  123. package/dist/Emulator/createDomain.js.map +0 -1
  124. package/dist/Emulator/emulatorFacade.js.map +0 -1
  125. package/dist/Emulator/emulatorFactory.js.map +0 -1
  126. package/dist/Firmware/Upload/firmwareUploadCommand.js.map +0 -1
  127. package/dist/Firmware/Upload/firmwareUploadFacade.js.map +0 -1
  128. package/dist/Firmware/Upload/firmwareUploadHelper.js.map +0 -1
  129. package/dist/Firmware/firmwareCommand.js.map +0 -1
  130. package/dist/Lib/archive.js.map +0 -1
  131. package/dist/Lib/childProcess.js.map +0 -1
  132. package/dist/Lib/fileSystem.js.map +0 -1
  133. package/dist/Lib/git.js.map +0 -1
  134. package/dist/Organization/Get/organizationGetCommand.js.map +0 -1
  135. package/dist/Organization/List/organizationListCommand.js.map +0 -1
  136. package/dist/Organization/SetDefault/organizationSetDefaultCommand.js.map +0 -1
  137. package/dist/Organization/organizationCommand.js.map +0 -1
  138. package/dist/Organization/organizationFacade.js.map +0 -1
  139. package/dist/RunControl/runControlHelper.js.map +0 -1
  140. package/dist/Timer/wait.js.map +0 -1
  141. package/dist/Timing/List/timingListCommand.js.map +0 -1
  142. package/dist/Timing/timingCommand.js.map +0 -1
  143. package/dist/generalCommand.js.map +0 -1
  144. package/dist/helper.js.map +0 -1
  145. package/dist/index.js.map +0 -1
  146. package/dist/parameters.js.map +0 -1
@@ -5,69 +5,29 @@ export declare const applet: {
5
5
  commands: ({
6
6
  name: "generate";
7
7
  description: string;
8
- optionList: readonly [{
9
- readonly name: "name";
10
- readonly type: StringConstructor;
11
- readonly description: `Applet name. Match RegExp: ${string}`;
12
- }, {
13
- readonly name: "applet-version";
14
- readonly type: StringConstructor;
15
- readonly description: "Applet initial version. Use semantic version";
16
- readonly defaultValue: "0.0.0";
17
- }, {
18
- readonly name: "target-dir";
19
- readonly type: StringConstructor;
20
- readonly description: "Directory where will be the applet generated to";
21
- }, {
22
- readonly name: "npm-registry";
23
- readonly type: StringConstructor;
24
- readonly description: "NPM registry URL. If you have your private npm registry";
25
- }, {
26
- readonly name: "language";
27
- readonly type: StringConstructor;
28
- readonly description: "Generate applet with \"typescript\" or \"javascript\" source code";
29
- }, {
30
- readonly name: "bundler";
31
- readonly type: StringConstructor;
32
- readonly description: "Generate applet with \"webpack\" (default) or \"rspack\"";
33
- }, {
34
- readonly name: "git";
35
- readonly type: StringConstructor;
36
- readonly description: "Init applet as git repository \"no\" (default) or \"yes\"";
37
- readonly defaultValue: "no";
38
- }];
8
+ optionList: ({
9
+ name: string;
10
+ type: StringConstructor;
11
+ description: string;
12
+ defaultValue?: undefined;
13
+ } | {
14
+ name: string;
15
+ type: StringConstructor;
16
+ description: string;
17
+ defaultValue: string;
18
+ })[];
39
19
  commands: never[];
40
- run(options: import("../Command/commandDefinition").CommandLineOptions<readonly [{
41
- readonly name: "name";
42
- readonly type: StringConstructor;
43
- readonly description: `Applet name. Match RegExp: ${string}`;
44
- }, {
45
- readonly name: "applet-version";
46
- readonly type: StringConstructor;
47
- readonly description: "Applet initial version. Use semantic version";
48
- readonly defaultValue: "0.0.0";
49
- }, {
50
- readonly name: "target-dir";
51
- readonly type: StringConstructor;
52
- readonly description: "Directory where will be the applet generated to";
53
- }, {
54
- readonly name: "npm-registry";
55
- readonly type: StringConstructor;
56
- readonly description: "NPM registry URL. If you have your private npm registry";
57
- }, {
58
- readonly name: "language";
59
- readonly type: StringConstructor;
60
- readonly description: "Generate applet with \"typescript\" or \"javascript\" source code";
61
- }, {
62
- readonly name: "bundler";
63
- readonly type: StringConstructor;
64
- readonly description: "Generate applet with \"webpack\" (default) or \"rspack\"";
65
- }, {
66
- readonly name: "git";
67
- readonly type: StringConstructor;
68
- readonly description: "Init applet as git repository \"no\" (default) or \"yes\"";
69
- readonly defaultValue: "no";
70
- }]>): Promise<void>;
20
+ run(options: import("../Command/commandDefinition").CommandLineOptions<({
21
+ name: string;
22
+ type: StringConstructor;
23
+ description: string;
24
+ defaultValue?: undefined;
25
+ } | {
26
+ name: string;
27
+ type: StringConstructor;
28
+ description: string;
29
+ defaultValue: string;
30
+ })[]>): Promise<void>;
71
31
  } | {
72
32
  name: "upload";
73
33
  description: string;
@@ -105,39 +65,7 @@ export declare const applet: {
105
65
  readonly description: "outputs all files to upload";
106
66
  }];
107
67
  commands: never[];
108
- run(options: import("../Command/commandDefinition").CommandLineOptions<readonly [{
109
- readonly name: "applet-path";
110
- readonly type: StringConstructor;
111
- readonly description: "Path to the applet file or the project folder depending on the entry file. Relative to the command or absolute.";
112
- }, {
113
- readonly name: "entry-file-path";
114
- readonly type: StringConstructor;
115
- readonly description: "Path to the applet entry file. Relative to the command or absolute.";
116
- }, {
117
- readonly name: "no-default-organization";
118
- readonly type: BooleanConstructor;
119
- readonly description: "Prevent using the defaultOrganizationUid from ~/.sosrc which were set using command sos organization set-default";
120
- }, {
121
- readonly name: "organization-uid";
122
- readonly type: StringConstructor;
123
- readonly description: "Organization UID";
124
- }, {
125
- readonly name: "applet-uid";
126
- readonly type: StringConstructor;
127
- readonly description: "Applet UID";
128
- }, {
129
- readonly name: "update-package-config";
130
- readonly type: BooleanConstructor;
131
- readonly description: string;
132
- }, {
133
- readonly name: "yes";
134
- readonly type: BooleanConstructor;
135
- readonly description: "Allow to upload new applet or override existing version without confirmation step";
136
- }, {
137
- readonly name: "verbose";
138
- readonly type: BooleanConstructor;
139
- readonly description: "outputs all files to upload";
140
- }]>): Promise<void>;
68
+ run(options: import("../Command/commandDefinition").CommandLineOptions<typeof import("./Upload/appletUploadCommand").OPTION_LIST>): Promise<void>;
141
69
  } | {
142
70
  name: "start";
143
71
  description: string;
@@ -191,55 +119,7 @@ export declare const applet: {
191
119
  readonly defaultValue: string | undefined;
192
120
  }];
193
121
  commands: never[];
194
- run(options: import("../Command/commandDefinition").CommandLineOptions<readonly [{
195
- readonly name: "no-default-organization";
196
- readonly type: BooleanConstructor;
197
- readonly description: "Prevent using the defaultOrganizationUid from ~/.sosrc which were set using command sos organization set-default";
198
- }, {
199
- readonly name: "organization-uid";
200
- readonly type: StringConstructor;
201
- readonly description: "Organization UID";
202
- }, {
203
- readonly name: "port";
204
- readonly type: NumberConstructor;
205
- readonly description: "Port where will the applet run";
206
- readonly defaultValue: 8090;
207
- }, {
208
- readonly name: "applet-path";
209
- readonly type: StringConstructor;
210
- readonly description: "Path to the applet file or the project folder depending on the entry file. Relative to the command or absolute.";
211
- }, {
212
- readonly name: "entry-file-path";
213
- readonly type: StringConstructor;
214
- readonly description: "Path to the applet entry file. Relative to the command or absolute.";
215
- }, {
216
- readonly name: "hot-reload";
217
- readonly type: BooleanConstructor;
218
- readonly description: "Enable hot reload and build of applet";
219
- readonly defaultValue: false;
220
- }, {
221
- readonly name: "server-port";
222
- readonly type: NumberConstructor;
223
- readonly description: "The custom server port for local machine server. Default is detected from currently running applet server.";
224
- }, {
225
- readonly name: "server-public-url";
226
- readonly type: StringConstructor;
227
- readonly description: "Public url of local machine server. Is useful when the local machine is behind a reverse proxy.";
228
- }, {
229
- readonly name: "force";
230
- readonly type: BooleanConstructor;
231
- readonly description: "Force start applet server even if it is already running on a different port. Kill the running server first.";
232
- }, {
233
- readonly name: "detach";
234
- readonly type: BooleanConstructor;
235
- readonly description: "Detach the applet HTTP server process from the terminal. Useful when want to run more commands reusing the same http server for current applet.";
236
- readonly defaultValue: false;
237
- }, {
238
- readonly name: "forward-server-url";
239
- readonly type: StringConstructor;
240
- readonly description: "Url of forward server to connect to the device instead of the local network (LAN).";
241
- readonly defaultValue: string | undefined;
242
- }]>): Promise<void>;
122
+ run(options: import("../Command/commandDefinition").CommandLineOptions<typeof import("./Start/appletStartCommand").OPTION_LIST>): Promise<void>;
243
123
  } | {
244
124
  name: "test";
245
125
  description: string;
@@ -365,19 +245,7 @@ export declare const applet: {
365
245
  readonly description: "Applet UID";
366
246
  }];
367
247
  commands: never[];
368
- run(options: import("../Command/commandDefinition").CommandLineOptions<readonly [{
369
- readonly name: "no-default-organization";
370
- readonly type: BooleanConstructor;
371
- readonly description: "Prevent using the defaultOrganizationUid from ~/.sosrc which were set using command sos organization set-default";
372
- }, {
373
- readonly name: "organization-uid";
374
- readonly type: StringConstructor;
375
- readonly description: "Organization UID";
376
- }, {
377
- readonly name: "applet-uid";
378
- readonly type: StringConstructor;
379
- readonly description: "Applet UID";
380
- }]>): Promise<void>;
248
+ run(options: import("../Command/commandDefinition").CommandLineOptions<typeof import("./Build/appletBuildCommand").OPTION_LIST>): Promise<void>;
381
249
  })[];
382
250
  run(): Promise<never>;
383
251
  };
@@ -8,52 +8,22 @@ 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
11
  Object.defineProperty(exports, "__esModule", { value: true });
39
12
  exports.applet = void 0;
40
- var appletGenerateCommand_1 = require("./Generate/appletGenerateCommand");
41
- var appletUploadCommand_1 = require("./Upload/appletUploadCommand");
42
- var appletStartCommand_1 = require("./Start/appletStartCommand");
43
- var appletTestCommand_1 = require("./Test/appletTestCommand");
44
- var commandDefinition_1 = require("../Command/commandDefinition");
45
- var appletBuildCommand_1 = require("./Build/appletBuildCommand");
13
+ const appletGenerateCommand_1 = require("./Generate/appletGenerateCommand");
14
+ const appletUploadCommand_1 = require("./Upload/appletUploadCommand");
15
+ const appletStartCommand_1 = require("./Start/appletStartCommand");
16
+ const appletTestCommand_1 = require("./Test/appletTestCommand");
17
+ const commandDefinition_1 = require("../Command/commandDefinition");
18
+ const appletBuildCommand_1 = require("./Build/appletBuildCommand");
46
19
  exports.applet = (0, commandDefinition_1.createCommandDefinition)({
47
20
  name: 'applet',
48
21
  description: 'Applet management',
49
22
  optionList: [],
50
23
  commands: [appletGenerateCommand_1.appletGenerate, appletUploadCommand_1.appletUpload, appletStartCommand_1.appletStart, appletTestCommand_1.appletTest, appletBuildCommand_1.appletBuild],
51
- run: function () {
52
- return __awaiter(this, void 0, void 0, function () {
53
- return __generator(this, function (_a) {
54
- throw new Error('Unknown command');
55
- });
24
+ run() {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ throw new Error('Unknown command');
56
27
  });
57
28
  },
58
29
  });
59
- //# sourceMappingURL=appletCommand.js.map
@@ -1,29 +1,10 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  Object.defineProperty(exports, "__esModule", { value: true });
18
3
  exports.AppletDoesNotExistError = void 0;
19
- var AppletDoesNotExistError = /** @class */ (function (_super) {
20
- __extends(AppletDoesNotExistError, _super);
21
- function AppletDoesNotExistError(message) {
22
- var _this = _super.call(this, message) || this;
23
- Object.setPrototypeOf(_this, AppletDoesNotExistError.prototype);
24
- return _this;
4
+ class AppletDoesNotExistError extends Error {
5
+ constructor(message) {
6
+ super(message);
7
+ Object.setPrototypeOf(this, AppletDoesNotExistError.prototype);
25
8
  }
26
- return AppletDoesNotExistError;
27
- }(Error));
9
+ }
28
10
  exports.AppletDoesNotExistError = AppletDoesNotExistError;
29
- //# sourceMappingURL=appletErrors.js.map
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,166 +41,108 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
41
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
42
  });
10
43
  };
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
- }
44
+ var __importDefault = (this && this.__importDefault) || function (mod) {
45
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
46
  };
38
47
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.getAppletVersionFromApi = exports.getAppletUid = exports.getAppletVersion = exports.getApplet = exports.APPLET_UID_OPTION = void 0;
40
- var path = require("path");
41
- var prompts = require("prompts");
42
- var chalk_1 = require("chalk");
43
- var parameters_1 = require("../parameters");
44
- var packageConfig_1 = require("@signageos/sdk/dist/FileSystem/packageConfig");
45
- var appletErrors_1 = require("./appletErrors");
48
+ exports.APPLET_UID_OPTION = void 0;
49
+ exports.getApplet = getApplet;
50
+ exports.getAppletVersion = getAppletVersion;
51
+ exports.getAppletUid = getAppletUid;
52
+ exports.getAppletVersionFromApi = getAppletVersionFromApi;
53
+ const path = __importStar(require("path"));
54
+ const prompts_1 = __importDefault(require("prompts"));
55
+ const chalk_1 = __importDefault(require("chalk"));
56
+ const parameters_1 = require("../parameters");
57
+ const packageConfig_1 = require("@signageos/sdk/dist/FileSystem/packageConfig");
58
+ const appletErrors_1 = require("./appletErrors");
46
59
  exports.APPLET_UID_OPTION = { name: 'applet-uid', type: String, description: 'Applet UID' };
47
60
  function getApplet(directoryPath) {
48
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
49
- return __awaiter(this, void 0, void 0, function () {
50
- var packageJSONPath, packageJSONObject, appletUid, appletVersion, appletName, frontAppletVersion;
51
- return __generator(this, function (_m) {
52
- switch (_m.label) {
53
- case 0:
54
- packageJSONPath = path.join(directoryPath, 'package.json');
55
- return [4 /*yield*/, (0, packageConfig_1.loadPackage)(directoryPath)];
56
- case 1:
57
- packageJSONObject = _m.sent();
58
- if (!packageJSONObject) {
59
- throw new Error("No package.json found in: ".concat(packageJSONPath));
60
- }
61
- appletUid = (_a = parameters_1.parameters.applet.uid) !== null && _a !== void 0 ? _a : (_b = packageJSONObject.sos) === null || _b === void 0 ? void 0 : _b.appletUid;
62
- appletVersion = (_c = parameters_1.parameters.applet.version) !== null && _c !== void 0 ? _c : packageJSONObject.version;
63
- appletName = (_d = parameters_1.parameters.applet.name) !== null && _d !== void 0 ? _d : packageJSONObject.name;
64
- frontAppletVersion = (_l = (_j = (_g = (_f = (_e = packageJSONObject.sos) === null || _e === void 0 ? void 0 : _e.dependencies) === null || _f === void 0 ? void 0 : _f['@signageos/front-applet']) !== null && _g !== void 0 ? _g : (_h = packageJSONObject.dependencies) === null || _h === void 0 ? void 0 : _h['@signageos/front-applet']) !== null && _j !== void 0 ? _j : (_k = packageJSONObject.devDependencies) === null || _k === void 0 ? void 0 : _k['@signageos/front-applet']) !== null && _l !== void 0 ? _l : '';
65
- if (!appletVersion) {
66
- throw new Error("No \"version\" key found in: ".concat(packageJSONPath, " nor SOS_APPLET_VERSION environment variable specified"));
67
- }
68
- if (!appletName) {
69
- throw new Error("No \"name\" key found in: ".concat(packageJSONPath, " nor SOS_APPLET_NAME environment variable specified"));
70
- }
71
- return [2 /*return*/, {
72
- uid: appletUid,
73
- name: appletName,
74
- version: appletVersion,
75
- frontAppletVersion: frontAppletVersion,
76
- }];
77
- }
78
- });
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
63
+ const packageJSONPath = path.join(directoryPath, 'package.json');
64
+ const packageJSONObject = yield (0, packageConfig_1.loadPackage)(directoryPath);
65
+ if (!packageJSONObject) {
66
+ throw new Error(`No package.json found in: ${packageJSONPath}`);
67
+ }
68
+ const appletUid = (_a = parameters_1.parameters.applet.uid) !== null && _a !== void 0 ? _a : (_b = packageJSONObject.sos) === null || _b === void 0 ? void 0 : _b.appletUid;
69
+ const appletVersion = (_c = parameters_1.parameters.applet.version) !== null && _c !== void 0 ? _c : packageJSONObject.version;
70
+ const appletName = (_d = parameters_1.parameters.applet.name) !== null && _d !== void 0 ? _d : packageJSONObject.name;
71
+ const frontAppletVersion = (_l = (_j = (_g = (_f = (_e = packageJSONObject.sos) === null || _e === void 0 ? void 0 : _e.dependencies) === null || _f === void 0 ? void 0 : _f['@signageos/front-applet']) !== null && _g !== void 0 ? _g : (_h = packageJSONObject.dependencies) === null || _h === void 0 ? void 0 : _h['@signageos/front-applet']) !== null && _j !== void 0 ? _j : (_k = packageJSONObject.devDependencies) === null || _k === void 0 ? void 0 : _k['@signageos/front-applet']) !== null && _l !== void 0 ? _l : '';
72
+ if (!appletVersion) {
73
+ throw new Error(`No "version" key found in: ${packageJSONPath} nor SOS_APPLET_VERSION environment variable specified`);
74
+ }
75
+ if (!appletName) {
76
+ throw new Error(`No "name" key found in: ${packageJSONPath} nor SOS_APPLET_NAME environment variable specified`);
77
+ }
78
+ return {
79
+ uid: appletUid,
80
+ name: appletName,
81
+ version: appletVersion,
82
+ frontAppletVersion,
83
+ };
79
84
  });
80
85
  }
81
- exports.getApplet = getApplet;
82
86
  function getAppletVersion(directoryPath) {
83
- return __awaiter(this, void 0, void 0, function () {
84
- var applet;
85
- return __generator(this, function (_a) {
86
- switch (_a.label) {
87
- case 0: return [4 /*yield*/, getApplet(directoryPath)];
88
- case 1:
89
- applet = _a.sent();
90
- return [2 /*return*/, applet.version];
91
- }
92
- });
87
+ return __awaiter(this, void 0, void 0, function* () {
88
+ const applet = yield getApplet(directoryPath);
89
+ return applet.version;
93
90
  });
94
91
  }
95
- exports.getAppletVersion = getAppletVersion;
96
92
  function getAppletUid(restApi, options) {
97
- return __awaiter(this, void 0, void 0, function () {
98
- var currentDirectory, currentApplet, appletUid, applets, candidatesOfApplets, response;
99
- return __generator(this, function (_a) {
100
- switch (_a.label) {
101
- case 0:
102
- currentDirectory = process.cwd();
103
- return [4 /*yield*/, getApplet(currentDirectory)];
104
- case 1:
105
- currentApplet = _a.sent();
106
- appletUid = options['applet-uid'] || currentApplet.uid;
107
- if (!!appletUid) return [3 /*break*/, 6];
108
- return [4 /*yield*/, restApi.applet.list()];
109
- case 2:
110
- applets = _a.sent();
111
- candidatesOfApplets = applets.filter(function (applet) { return applet.name === currentApplet.name; });
112
- if (!(candidatesOfApplets.length === 0)) return [3 /*break*/, 3];
113
- appletUid = undefined;
114
- return [3 /*break*/, 6];
115
- case 3:
116
- if (!(candidatesOfApplets.length > 1)) return [3 /*break*/, 5];
117
- return [4 /*yield*/, prompts({
118
- type: 'autocomplete',
119
- name: 'appletUid',
120
- message: "Select applet to use",
121
- choices: candidatesOfApplets.map(function (applet) { return ({
122
- title: "".concat(applet.name, " (").concat(applet.uid, ")"),
123
- value: applet.uid,
124
- }); }),
125
- })];
126
- case 4:
127
- response = _a.sent();
128
- appletUid = response.appletUid;
129
- return [3 /*break*/, 6];
130
- case 5:
131
- appletUid = candidatesOfApplets[0].uid;
132
- _a.label = 6;
133
- case 6:
134
- if (!appletUid) {
135
- throw new appletErrors_1.AppletDoesNotExistError("Applet does not exist. Please use ".concat(chalk_1.default.green('sos applet upload'), " first or specify --applet-uid argument."));
136
- }
137
- return [2 /*return*/, appletUid];
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ var _a;
95
+ const currentDirectory = process.cwd();
96
+ const currentApplet = yield getApplet(currentDirectory);
97
+ let appletUid = options['applet-uid'] || currentApplet.uid;
98
+ if (!appletUid) {
99
+ const applets = yield restApi.applet.list();
100
+ const candidatesOfApplets = applets.filter((applet) => applet.name === currentApplet.name);
101
+ if (candidatesOfApplets.length === 0) {
102
+ appletUid = undefined;
103
+ }
104
+ else if (candidatesOfApplets.length > 1) {
105
+ const response = yield (0, prompts_1.default)({
106
+ type: 'autocomplete',
107
+ name: 'appletUid',
108
+ message: `Select applet to use`,
109
+ choices: candidatesOfApplets.map((applet) => ({
110
+ title: `${applet.name} (${applet.uid})`,
111
+ value: applet.uid,
112
+ })),
113
+ });
114
+ appletUid = response.appletUid;
138
115
  }
139
- });
116
+ else {
117
+ appletUid = (_a = candidatesOfApplets[0]) === null || _a === void 0 ? void 0 : _a.uid;
118
+ }
119
+ }
120
+ if (!appletUid) {
121
+ throw new appletErrors_1.AppletDoesNotExistError(`Applet does not exist. Please use ${chalk_1.default.green('sos applet upload')} first or specify --applet-uid argument.`);
122
+ }
123
+ return appletUid;
140
124
  });
141
125
  }
142
- exports.getAppletUid = getAppletUid;
143
126
  function getAppletVersionFromApi(restApi, appletUid) {
144
- return __awaiter(this, void 0, void 0, function () {
145
- var appletVersion, appletVersions, response;
146
- return __generator(this, function (_a) {
147
- switch (_a.label) {
148
- case 0: return [4 /*yield*/, restApi.applet.version.list(appletUid)];
149
- case 1:
150
- appletVersions = _a.sent();
151
- if (!(appletVersions.length === 1)) return [3 /*break*/, 2];
152
- appletVersion = appletVersions[0].version;
153
- return [3 /*break*/, 4];
154
- case 2: return [4 /*yield*/, prompts({
155
- type: 'autocomplete',
156
- name: 'appletVersion',
157
- message: "Select applet version to use",
158
- choices: appletVersions.map(function (applet) { return ({
159
- title: applet.version,
160
- value: applet.version,
161
- }); }),
162
- })];
163
- case 3:
164
- response = _a.sent();
165
- appletVersion = response.appletVersion;
166
- _a.label = 4;
167
- case 4: return [2 /*return*/, appletVersion];
168
- }
169
- });
127
+ return __awaiter(this, void 0, void 0, function* () {
128
+ var _a;
129
+ let appletVersion;
130
+ const appletVersions = yield restApi.applet.version.list(appletUid);
131
+ if (appletVersions.length === 1 && ((_a = appletVersions[0]) === null || _a === void 0 ? void 0 : _a.version)) {
132
+ appletVersion = appletVersions[0].version;
133
+ }
134
+ else {
135
+ const response = yield (0, prompts_1.default)({
136
+ type: 'autocomplete',
137
+ name: 'appletVersion',
138
+ message: `Select applet version to use`,
139
+ choices: appletVersions.map((applet) => ({
140
+ title: applet.version,
141
+ value: applet.version,
142
+ })),
143
+ });
144
+ appletVersion = response.appletVersion;
145
+ }
146
+ return appletVersion;
170
147
  });
171
148
  }
172
- exports.getAppletVersionFromApi = getAppletVersionFromApi;
173
- //# sourceMappingURL=appletFacade.js.map