@signageos/cli 2.3.2 → 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 (59) hide show
  1. package/README.md +53 -19
  2. package/dist/Applet/Generate/Templates/CHANGELOG.md.template +7 -0
  3. package/dist/Applet/Generate/Templates/README.md.template +3 -0
  4. package/dist/Applet/Generate/appletGenerateCommand.js +47 -13
  5. package/dist/Applet/Start/appletStartCommand.js +1 -1
  6. package/dist/Applet/Test/Upload/appletTestRunCommand.js +1 -1
  7. package/dist/Applet/Test/Upload/appletTestRunFacade.js +1 -2
  8. package/dist/Applet/Test/Upload/appletTestUploadCommand.js +5 -5
  9. package/dist/Applet/Test/Upload/appletTestUploadFacade.js +19 -10
  10. package/dist/Applet/Upload/appletUploadCommandHelper.js +36 -16
  11. package/dist/Applet/Upload/appletUploadFacade.js +19 -9
  12. package/dist/Applet/Upload/appletUploadFacadeHelper.js +19 -10
  13. package/dist/Applet/appletCommand.d.ts +3 -95
  14. package/dist/Applet/appletFacade.js +25 -15
  15. package/dist/Applet/appletServerHelper.js +2 -2
  16. package/dist/Auth/loginCommand.d.ts +2 -2
  17. package/dist/Auth/loginCommand.js +19 -9
  18. package/dist/Cache/tmpCache.js +19 -10
  19. package/dist/Cli/helper.js +2 -3
  20. package/dist/Cli/packageVersion.js +24 -15
  21. package/dist/Command/Autocomplete/Install/installAutocompleteCommand.d.ts +10 -0
  22. package/dist/Command/Autocomplete/Install/installAutocompleteCommand.js +39 -0
  23. package/dist/Command/Autocomplete/Install/installAutocompleteCommand.ts +30 -0
  24. package/dist/Command/Autocomplete/Install/sos-completion.sh +63 -0
  25. package/dist/Command/Autocomplete/Uninstall/uninstallAutocompleteCommand.d.ts +8 -0
  26. package/dist/Command/Autocomplete/Uninstall/uninstallAutocompleteCommand.js +120 -0
  27. package/dist/Command/Autocomplete/autocompleteCommand.d.ts +22 -0
  28. package/dist/Command/Autocomplete/autocompleteCommand.js +32 -0
  29. package/dist/Command/autoComplete.d.ts +4 -0
  30. package/dist/Command/autoComplete.js +184 -0
  31. package/dist/Command/commandDefinition.d.ts +9 -9
  32. package/dist/Command/commandDefinition.js +1 -2
  33. package/dist/Command/commandProcessor.js +3 -4
  34. package/dist/Command/globalArgs.js +2 -3
  35. package/dist/CommandLine/progressBarFactory.d.ts +1 -1
  36. package/dist/CommandLine/progressBarFactory.js +18 -9
  37. package/dist/CustomScript/Generate/customScriptGenerateFacade.js +19 -10
  38. package/dist/CustomScript/customScriptCommand.d.ts +1 -9
  39. package/dist/CustomScript/customScriptFacade.d.ts +2 -2
  40. package/dist/CustomScript/customScriptFacade.js +27 -18
  41. package/dist/Device/Connect/connectCommand.js +1 -1
  42. package/dist/Device/deviceFacade.js +4 -4
  43. package/dist/Emulator/createDomain.d.ts +0 -1
  44. package/dist/Emulator/createDomain.js +18 -9
  45. package/dist/Emulator/emulatorFacade.js +2 -3
  46. package/dist/Emulator/emulatorFactory.js +19 -10
  47. package/dist/Firmware/Upload/firmwareUploadFacade.js +18 -9
  48. package/dist/Firmware/Upload/firmwareUploadHelper.js +18 -8
  49. package/dist/Lib/archive.js +18 -9
  50. package/dist/Lib/childProcess.js +17 -7
  51. package/dist/Lib/fileSystem.js +21 -12
  52. package/dist/Lib/git.js +23 -14
  53. package/dist/Organization/organizationFacade.js +6 -6
  54. package/dist/RunControl/runControlHelper.js +3 -4
  55. package/dist/Timer/wait.js +1 -1
  56. package/dist/helper.d.ts +4 -4
  57. package/dist/helper.js +13 -13
  58. package/dist/index.js +4 -1
  59. package/package.json +43 -46
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
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
+ })();
25
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -32,7 +42,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
32
42
  });
33
43
  };
34
44
  Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.getAppletFilesDictionary = exports.getAppletFileRelativePath = void 0;
45
+ exports.getAppletFileRelativePath = getAppletFileRelativePath;
46
+ exports.getAppletFilesDictionary = getAppletFilesDictionary;
36
47
  const path = __importStar(require("path"));
37
48
  function getAppletFileRelativePath(fileAbsolutePath, directoryAbsolutePath) {
38
49
  const directoryAbsolutePathNormalized = path.normalize(directoryAbsolutePath);
@@ -52,7 +63,6 @@ function getAppletFileRelativePath(fileAbsolutePath, directoryAbsolutePath) {
52
63
  const fileRelativePath = fileAbsolutePathNormalized.substring(directoryAbsolutePathNormalized.length + 1);
53
64
  return fileRelativePath;
54
65
  }
55
- exports.getAppletFileRelativePath = getAppletFileRelativePath;
56
66
  function getAppletFilesDictionary(restApi, appletUid, appletVersion) {
57
67
  return __awaiter(this, void 0, void 0, function* () {
58
68
  const filesDictionary = {};
@@ -63,4 +73,3 @@ function getAppletFilesDictionary(restApi, appletUid, appletVersion) {
63
73
  return filesDictionary;
64
74
  });
65
75
  }
66
- exports.getAppletFilesDictionary = getAppletFilesDictionary;
@@ -65,39 +65,7 @@ export declare const applet: {
65
65
  readonly description: "outputs all files to upload";
66
66
  }];
67
67
  commands: never[];
68
- run(options: import("../Command/commandDefinition").CommandLineOptions<readonly [{
69
- readonly name: "applet-path";
70
- readonly type: StringConstructor;
71
- readonly description: "Path to the applet file or the project folder depending on the entry file. Relative to the command or absolute.";
72
- }, {
73
- readonly name: "entry-file-path";
74
- readonly type: StringConstructor;
75
- readonly description: "Path to the applet entry file. Relative to the command or absolute.";
76
- }, {
77
- readonly name: "no-default-organization";
78
- readonly type: BooleanConstructor;
79
- readonly description: "Prevent using the defaultOrganizationUid from ~/.sosrc which were set using command sos organization set-default";
80
- }, {
81
- readonly name: "organization-uid";
82
- readonly type: StringConstructor;
83
- readonly description: "Organization UID";
84
- }, {
85
- readonly name: "applet-uid";
86
- readonly type: StringConstructor;
87
- readonly description: "Applet UID";
88
- }, {
89
- readonly name: "update-package-config";
90
- readonly type: BooleanConstructor;
91
- readonly description: string;
92
- }, {
93
- readonly name: "yes";
94
- readonly type: BooleanConstructor;
95
- readonly description: "Allow to upload new applet or override existing version without confirmation step";
96
- }, {
97
- readonly name: "verbose";
98
- readonly type: BooleanConstructor;
99
- readonly description: "outputs all files to upload";
100
- }]>): Promise<void>;
68
+ run(options: import("../Command/commandDefinition").CommandLineOptions<typeof import("./Upload/appletUploadCommand").OPTION_LIST>): Promise<void>;
101
69
  } | {
102
70
  name: "start";
103
71
  description: string;
@@ -151,55 +119,7 @@ export declare const applet: {
151
119
  readonly defaultValue: string | undefined;
152
120
  }];
153
121
  commands: never[];
154
- run(options: import("../Command/commandDefinition").CommandLineOptions<readonly [{
155
- readonly name: "no-default-organization";
156
- readonly type: BooleanConstructor;
157
- readonly description: "Prevent using the defaultOrganizationUid from ~/.sosrc which were set using command sos organization set-default";
158
- }, {
159
- readonly name: "organization-uid";
160
- readonly type: StringConstructor;
161
- readonly description: "Organization UID";
162
- }, {
163
- readonly name: "port";
164
- readonly type: NumberConstructor;
165
- readonly description: "Port where will the applet run";
166
- readonly defaultValue: 8090;
167
- }, {
168
- readonly name: "applet-path";
169
- readonly type: StringConstructor;
170
- readonly description: "Path to the applet file or the project folder depending on the entry file. Relative to the command or absolute.";
171
- }, {
172
- readonly name: "entry-file-path";
173
- readonly type: StringConstructor;
174
- readonly description: "Path to the applet entry file. Relative to the command or absolute.";
175
- }, {
176
- readonly name: "hot-reload";
177
- readonly type: BooleanConstructor;
178
- readonly description: "Enable hot reload and build of applet";
179
- readonly defaultValue: false;
180
- }, {
181
- readonly name: "server-port";
182
- readonly type: NumberConstructor;
183
- readonly description: "The custom server port for local machine server. Default is detected from currently running applet server.";
184
- }, {
185
- readonly name: "server-public-url";
186
- readonly type: StringConstructor;
187
- readonly description: "Public url of local machine server. Is useful when the local machine is behind a reverse proxy.";
188
- }, {
189
- readonly name: "force";
190
- readonly type: BooleanConstructor;
191
- readonly description: "Force start applet server even if it is already running on a different port. Kill the running server first.";
192
- }, {
193
- readonly name: "detach";
194
- readonly type: BooleanConstructor;
195
- 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.";
196
- readonly defaultValue: false;
197
- }, {
198
- readonly name: "forward-server-url";
199
- readonly type: StringConstructor;
200
- readonly description: "Url of forward server to connect to the device instead of the local network (LAN).";
201
- readonly defaultValue: string | undefined;
202
- }]>): Promise<void>;
122
+ run(options: import("../Command/commandDefinition").CommandLineOptions<typeof import("./Start/appletStartCommand").OPTION_LIST>): Promise<void>;
203
123
  } | {
204
124
  name: "test";
205
125
  description: string;
@@ -325,19 +245,7 @@ export declare const applet: {
325
245
  readonly description: "Applet UID";
326
246
  }];
327
247
  commands: never[];
328
- run(options: import("../Command/commandDefinition").CommandLineOptions<readonly [{
329
- readonly name: "no-default-organization";
330
- readonly type: BooleanConstructor;
331
- readonly description: "Prevent using the defaultOrganizationUid from ~/.sosrc which were set using command sos organization set-default";
332
- }, {
333
- readonly name: "organization-uid";
334
- readonly type: StringConstructor;
335
- readonly description: "Organization UID";
336
- }, {
337
- readonly name: "applet-uid";
338
- readonly type: StringConstructor;
339
- readonly description: "Applet UID";
340
- }]>): Promise<void>;
248
+ run(options: import("../Command/commandDefinition").CommandLineOptions<typeof import("./Build/appletBuildCommand").OPTION_LIST>): Promise<void>;
341
249
  })[];
342
250
  run(): Promise<never>;
343
251
  };
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
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
+ })();
25
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -35,7 +45,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
45
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
46
  };
37
47
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.getAppletVersionFromApi = exports.getAppletUid = exports.getAppletVersion = exports.getApplet = exports.APPLET_UID_OPTION = void 0;
48
+ exports.APPLET_UID_OPTION = void 0;
49
+ exports.getApplet = getApplet;
50
+ exports.getAppletVersion = getAppletVersion;
51
+ exports.getAppletUid = getAppletUid;
52
+ exports.getAppletVersionFromApi = getAppletVersionFromApi;
39
53
  const path = __importStar(require("path"));
40
54
  const prompts_1 = __importDefault(require("prompts"));
41
55
  const chalk_1 = __importDefault(require("chalk"));
@@ -44,8 +58,8 @@ const packageConfig_1 = require("@signageos/sdk/dist/FileSystem/packageConfig");
44
58
  const appletErrors_1 = require("./appletErrors");
45
59
  exports.APPLET_UID_OPTION = { name: 'applet-uid', type: String, description: 'Applet UID' };
46
60
  function getApplet(directoryPath) {
47
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
48
61
  return __awaiter(this, void 0, void 0, function* () {
62
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
49
63
  const packageJSONPath = path.join(directoryPath, 'package.json');
50
64
  const packageJSONObject = yield (0, packageConfig_1.loadPackage)(directoryPath);
51
65
  if (!packageJSONObject) {
@@ -69,17 +83,15 @@ function getApplet(directoryPath) {
69
83
  };
70
84
  });
71
85
  }
72
- exports.getApplet = getApplet;
73
86
  function getAppletVersion(directoryPath) {
74
87
  return __awaiter(this, void 0, void 0, function* () {
75
88
  const applet = yield getApplet(directoryPath);
76
89
  return applet.version;
77
90
  });
78
91
  }
79
- exports.getAppletVersion = getAppletVersion;
80
92
  function getAppletUid(restApi, options) {
81
- var _a;
82
93
  return __awaiter(this, void 0, void 0, function* () {
94
+ var _a;
83
95
  const currentDirectory = process.cwd();
84
96
  const currentApplet = yield getApplet(currentDirectory);
85
97
  let appletUid = options['applet-uid'] || currentApplet.uid;
@@ -111,10 +123,9 @@ function getAppletUid(restApi, options) {
111
123
  return appletUid;
112
124
  });
113
125
  }
114
- exports.getAppletUid = getAppletUid;
115
126
  function getAppletVersionFromApi(restApi, appletUid) {
116
- var _a;
117
127
  return __awaiter(this, void 0, void 0, function* () {
128
+ var _a;
118
129
  let appletVersion;
119
130
  const appletVersions = yield restApi.applet.version.list(appletUid);
120
131
  if (appletVersions.length === 1 && ((_a = appletVersions[0]) === null || _a === void 0 ? void 0 : _a.version)) {
@@ -135,4 +146,3 @@ function getAppletVersionFromApi(restApi, appletUid) {
135
146
  return appletVersion;
136
147
  });
137
148
  }
138
- exports.getAppletVersionFromApi = getAppletVersionFromApi;
@@ -9,7 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.killAppletServerIfRunningAndForceOption = exports.HOT_RELOAD_OPTION = exports.FORWARD_SERVER_URL_OPTION = exports.DETACH_PROCESS_OPTION = exports.SERVER_FORCE_OPTION = exports.SERVER_PORT_OPTION = exports.SERVER_PUBLIC_URL_OPTION = void 0;
12
+ exports.HOT_RELOAD_OPTION = exports.FORWARD_SERVER_URL_OPTION = exports.DETACH_PROCESS_OPTION = exports.SERVER_FORCE_OPTION = exports.SERVER_PORT_OPTION = exports.SERVER_PUBLIC_URL_OPTION = void 0;
13
+ exports.killAppletServerIfRunningAndForceOption = killAppletServerIfRunningAndForceOption;
13
14
  const log_1 = require("@signageos/sdk/dist/Console/log");
14
15
  const parameters_1 = require("../parameters");
15
16
  exports.SERVER_PUBLIC_URL_OPTION = {
@@ -62,4 +63,3 @@ function killAppletServerIfRunningAndForceOption(dev, options, appletUid, applet
62
63
  }
63
64
  });
64
65
  }
65
- exports.killAppletServerIfRunningAndForceOption = killAppletServerIfRunningAndForceOption;
@@ -14,8 +14,8 @@ declare const OPTION_LIST: readonly [{
14
14
  * Only one from auth0 and legacy authentication can be active at the moment
15
15
  */
16
16
  export declare const getIsAuth0OrLegacyEnabled: (options: any) => {
17
- isAuth0Enabled?: boolean | undefined;
18
- isLegacyEnabled?: boolean | undefined;
17
+ isAuth0Enabled?: boolean;
18
+ isLegacyEnabled?: boolean;
19
19
  };
20
20
  export declare const login: {
21
21
  name: "login";
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
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
+ })();
25
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -112,8 +122,8 @@ exports.login = (0, commandDefinition_1.createCommandDefinition)({
112
122
  });
113
123
  },
114
124
  });
115
- function getOrCreateApiSecurityToken({ identification, password, apiUrl, isAuth0Enabled, isLegacyEnabled, }) {
116
- return __awaiter(this, void 0, void 0, function* () {
125
+ function getOrCreateApiSecurityToken(_a) {
126
+ return __awaiter(this, arguments, void 0, function* ({ identification, password, apiUrl, isAuth0Enabled, isLegacyEnabled, }) {
117
127
  const ACCOUNT_SECURITY_TOKEN_RESOURCE = 'account/security-token';
118
128
  const options = {
119
129
  url: apiUrl,
@@ -15,15 +15,26 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
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
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.updateCacheValue = exports.getCachedValue = void 0;
36
+ exports.getCachedValue = getCachedValue;
37
+ exports.updateCacheValue = updateCacheValue;
27
38
  const os = __importStar(require("os"));
28
39
  const fs = __importStar(require("fs-extra"));
29
40
  const path = __importStar(require("path"));
@@ -43,7 +54,6 @@ function getCachedValue(key) {
43
54
  return null;
44
55
  }
45
56
  }
46
- exports.getCachedValue = getCachedValue;
47
57
  function updateCacheValue(key, value, options) {
48
58
  try {
49
59
  fs.ensureDirSync(TMP_BASE_PATH);
@@ -58,7 +68,6 @@ function updateCacheValue(key, value, options) {
58
68
  // skip caching
59
69
  }
60
70
  }
61
- exports.updateCacheValue = updateCacheValue;
62
71
  function hasExpired(expireAt) {
63
72
  return new Date().valueOf() > expireAt;
64
73
  }
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPackageVersion = exports.getPackageName = void 0;
3
+ exports.getPackageName = getPackageName;
4
+ exports.getPackageVersion = getPackageVersion;
4
5
  const parameters_1 = require("../parameters");
5
6
  function getPackageName() {
6
7
  return parameters_1.parameters.name;
7
8
  }
8
- exports.getPackageName = getPackageName;
9
9
  function getPackageVersion() {
10
10
  return parameters_1.parameters.version;
11
11
  }
12
- exports.getPackageVersion = getPackageVersion;
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
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
+ })();
25
35
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
36
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
37
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -35,7 +45,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
35
45
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
46
  };
37
47
  Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.getUpdateVersionMessage = exports.newVersionAvailable = exports.getUpdateMessage = exports.getLatestVersion = exports.printUpdateMessage = exports.printVersion = void 0;
48
+ exports.printVersion = printVersion;
49
+ exports.printUpdateMessage = printUpdateMessage;
50
+ exports.getLatestVersion = getLatestVersion;
51
+ exports.getUpdateMessage = getUpdateMessage;
52
+ exports.newVersionAvailable = newVersionAvailable;
53
+ exports.getUpdateVersionMessage = getUpdateVersionMessage;
39
54
  const chalk_1 = __importDefault(require("chalk"));
40
55
  const semver = __importStar(require("semver"));
41
56
  const child_process_promise_1 = require("child-process-promise");
@@ -48,7 +63,6 @@ function printVersion() {
48
63
  yield printUpdateMessage();
49
64
  });
50
65
  }
51
- exports.printVersion = printVersion;
52
66
  function printUpdateMessage() {
53
67
  return __awaiter(this, void 0, void 0, function* () {
54
68
  const packageName = (0, helper_1.getPackageName)();
@@ -61,7 +75,6 @@ function printUpdateMessage() {
61
75
  }
62
76
  });
63
77
  }
64
- exports.printUpdateMessage = printUpdateMessage;
65
78
  function getLatestVersion(packageName) {
66
79
  return __awaiter(this, void 0, void 0, function* () {
67
80
  try {
@@ -74,7 +87,6 @@ function getLatestVersion(packageName) {
74
87
  }
75
88
  });
76
89
  }
77
- exports.getLatestVersion = getLatestVersion;
78
90
  function getUpdateMessage(packageName, installedVersion, latestVersion) {
79
91
  return __awaiter(this, void 0, void 0, function* () {
80
92
  const NEW_VERSION_AVAILABLE_MESSAGE = `` +
@@ -95,12 +107,11 @@ function getUpdateMessage(packageName, installedVersion, latestVersion) {
95
107
  }
96
108
  });
97
109
  }
98
- exports.getUpdateMessage = getUpdateMessage;
99
110
  const LATEST_VERSION_CACHE_KEY = 'package.latestVersion';
100
111
  const LATEST_VERSION_CACHE_EXPIRE_IN_MS = 60 * 60e3; // 1 hour
101
112
  function newVersionAvailable() {
102
- var _a;
103
113
  return __awaiter(this, void 0, void 0, function* () {
114
+ var _a;
104
115
  const packageName = (0, helper_1.getPackageName)();
105
116
  const installedVersion = (0, helper_1.getPackageVersion)();
106
117
  let latestVersion = (_a = (0, tmpCache_1.getCachedValue)(LATEST_VERSION_CACHE_KEY)) !== null && _a !== void 0 ? _a : undefined;
@@ -113,9 +124,7 @@ function newVersionAvailable() {
113
124
  return latestVersion ? semver.gt(latestVersion, installedVersion) : false;
114
125
  });
115
126
  }
116
- exports.newVersionAvailable = newVersionAvailable;
117
127
  function getUpdateVersionMessage() {
118
128
  const updateVersionMessage = chalk_1.default.bold.yellow(`New version of signageOS CLI Tool is available.`);
119
129
  return updateVersionMessage;
120
130
  }
121
- exports.getUpdateVersionMessage = getUpdateVersionMessage;
@@ -0,0 +1,10 @@
1
+ import { ICommand, OptionList } from '../../commandDefinition';
2
+ export declare const OPTION_LIST: readonly [];
3
+ export declare const setRootCommand: (rootCommand: ICommand<string, OptionList>) => void;
4
+ export declare const installAutocomplete: {
5
+ name: "install";
6
+ description: string;
7
+ optionList: readonly [];
8
+ commands: never[];
9
+ run(): Promise<void>;
10
+ };
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.installAutocomplete = exports.setRootCommand = exports.OPTION_LIST = void 0;
13
+ const commandDefinition_1 = require("../../commandDefinition");
14
+ const autoComplete_1 = require("../../autoComplete");
15
+ exports.OPTION_LIST = [];
16
+ // Root command reference that will be populated when the command is registered
17
+ let rootCommandRef = null;
18
+ // Setter function to provide the root command reference
19
+ const setRootCommand = (rootCommand) => {
20
+ rootCommandRef = rootCommand;
21
+ };
22
+ exports.setRootCommand = setRootCommand;
23
+ exports.installAutocomplete = (0, commandDefinition_1.createCommandDefinition)({
24
+ name: 'install',
25
+ description: 'Install command auto-completion for bash/zsh shells',
26
+ optionList: exports.OPTION_LIST,
27
+ commands: [],
28
+ run() {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ // Get the root command from the reference set during initialization
31
+ const rootCommand = rootCommandRef;
32
+ if (!rootCommand) {
33
+ throw new Error('Root command not found. Please make sure the CLI is properly initialized.');
34
+ }
35
+ // Install the auto-completion script
36
+ (0, autoComplete_1.installAutoCompletion)(rootCommand);
37
+ });
38
+ },
39
+ });
@@ -0,0 +1,30 @@
1
+ import { createCommandDefinition, ICommand, OptionList } from '../../commandDefinition';
2
+ import { installAutoCompletion } from '../../autoComplete';
3
+
4
+ export const OPTION_LIST = [] as const;
5
+
6
+ // Root command reference that will be populated when the command is registered
7
+ let rootCommandRef: ICommand<string, OptionList> | null = null;
8
+
9
+ // Setter function to provide the root command reference
10
+ export const setRootCommand = (rootCommand: ICommand<string, OptionList>): void => {
11
+ rootCommandRef = rootCommand;
12
+ };
13
+
14
+ export const installAutocomplete = createCommandDefinition({
15
+ name: 'install',
16
+ description: 'Install command auto-completion for bash/zsh shells',
17
+ optionList: OPTION_LIST,
18
+ commands: [],
19
+ async run() {
20
+ // Get the root command from the reference set during initialization
21
+ const rootCommand = rootCommandRef;
22
+
23
+ if (!rootCommand) {
24
+ throw new Error('Root command not found. Please make sure the CLI is properly initialized.');
25
+ }
26
+
27
+ // Install the auto-completion script
28
+ installAutoCompletion(rootCommand);
29
+ },
30
+ });
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Extract command path from completion words array
4
+ _sos_extract_cmd_path() {
5
+ local result=""
6
+ for ((i=1; i<$1; i++)); do
7
+ if [[ ${COMP_WORDS[i]} != -* ]]; then
8
+ if [[ -n "$result" ]]; then
9
+ result="${result} ${COMP_WORDS[i]}"
10
+ else
11
+ result="${COMP_WORDS[i]}"
12
+ fi
13
+ fi
14
+ done
15
+ echo "$result"
16
+ }
17
+
18
+ # Common completion logic
19
+ _sos_completion_impl() {
20
+ local cur="$1"
21
+ local prev="$2"
22
+ local cmd_path="$3"
23
+
24
+ # Handle direct command completion or empty command path
25
+ if [[ "${cur}" == *sos* || -z "$cmd_path" ]]; then
26
+ COMPREPLY=( $(compgen -W "${TOPLEVEL_COMMANDS}" -- "$cur") )
27
+ return 0
28
+ fi
29
+
30
+ # We need to find the subcommands for the current command path
31
+ # This will be added by the generateCompletionScript function
32
+ # with specific command paths and their subcommands
33
+ case "$cmd_path" in
34
+ # COMMAND_SCHEMA_CASES will be replaced with actual cases during generation
35
+ *)
36
+ # Default to top-level commands
37
+ COMPREPLY=( $(compgen -W "${TOPLEVEL_COMMANDS}" -- "$cur") )
38
+ ;;
39
+ esac
40
+ }
41
+
42
+ # Completion function with bash-completion
43
+ _sos_completion() {
44
+ local cur prev words cword split
45
+ _init_completion -s || return
46
+
47
+ cmd_path=$(_sos_extract_cmd_path $COMP_CWORD)
48
+ _sos_completion_impl "${COMP_WORDS[COMP_CWORD]}" "${COMP_WORDS[COMP_CWORD-1]}" "$cmd_path"
49
+ }
50
+
51
+ # Fallback completion for systems without bash-completion
52
+ _sos_completion_fallback() {
53
+ COMPREPLY=()
54
+ cmd_path=$(_sos_extract_cmd_path $COMP_CWORD)
55
+ _sos_completion_impl "${COMP_WORDS[COMP_CWORD]}" "${COMP_WORDS[COMP_CWORD-1]}" "$cmd_path"
56
+ }
57
+
58
+ # Register the appropriate completion function
59
+ if command -v _init_completion >/dev/null 2>&1; then
60
+ complete -F _sos_completion sos
61
+ else
62
+ complete -F _sos_completion_fallback sos
63
+ fi
@@ -0,0 +1,8 @@
1
+ export declare const OPTION_LIST: readonly [];
2
+ export declare const uninstallAutocomplete: {
3
+ name: "uninstall";
4
+ description: string;
5
+ optionList: readonly [];
6
+ commands: never[];
7
+ run(): Promise<void>;
8
+ };