@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.
- package/README.md +54 -19
- package/dist/Applet/Build/appletBuildCommand.js +28 -72
- package/dist/Applet/Generate/Templates/CHANGELOG.md.template +7 -0
- package/dist/Applet/Generate/Templates/README.md.template +3 -0
- package/dist/Applet/Generate/Templates/rspack.config.mjs.template +12 -12
- package/dist/Applet/Generate/appletGenerateCommand.d.ts +23 -62
- package/dist/Applet/Generate/appletGenerateCommand.js +432 -365
- package/dist/Applet/Start/appletStartCommand.js +70 -132
- package/dist/Applet/Test/Upload/appletTestRunCommand.js +90 -178
- package/dist/Applet/Test/Upload/appletTestRunFacade.js +5 -29
- package/dist/Applet/Test/Upload/appletTestUploadCommand.js +99 -224
- package/dist/Applet/Test/Upload/appletTestUploadFacade.js +51 -105
- package/dist/Applet/Test/appletTestCommand.js +6 -36
- package/dist/Applet/Upload/appletUploadCommand.js +199 -305
- package/dist/Applet/Upload/appletUploadCommandHelper.js +129 -144
- package/dist/Applet/Upload/appletUploadFacade.d.ts +2 -2
- package/dist/Applet/Upload/appletUploadFacade.js +184 -265
- package/dist/Applet/Upload/appletUploadFacadeHelper.js +51 -55
- package/dist/Applet/appletCommand.d.ts +25 -157
- package/dist/Applet/appletCommand.js +9 -39
- package/dist/Applet/appletErrors.js +5 -24
- package/dist/Applet/appletFacade.js +122 -147
- package/dist/Applet/appletServerHelper.js +18 -55
- package/dist/Auth/loginCommand.d.ts +2 -2
- package/dist/Auth/loginCommand.js +105 -136
- package/dist/Cache/tmpCache.js +47 -16
- package/dist/Cli/helper.js +3 -5
- package/dist/Cli/packageVersion.js +99 -131
- package/dist/Command/Autocomplete/Install/installAutocompleteCommand.d.ts +10 -0
- package/dist/Command/Autocomplete/Install/installAutocompleteCommand.js +39 -0
- package/dist/Command/Autocomplete/Install/installAutocompleteCommand.ts +30 -0
- package/dist/Command/Autocomplete/Install/sos-completion.sh +63 -0
- package/dist/Command/Autocomplete/Uninstall/uninstallAutocompleteCommand.d.ts +8 -0
- package/dist/Command/Autocomplete/Uninstall/uninstallAutocompleteCommand.js +120 -0
- package/dist/Command/Autocomplete/autocompleteCommand.d.ts +22 -0
- package/dist/Command/Autocomplete/autocompleteCommand.js +32 -0
- package/dist/Command/autoComplete.d.ts +4 -0
- package/dist/Command/autoComplete.js +184 -0
- package/dist/Command/commandDefinition.d.ts +9 -9
- package/dist/Command/commandDefinition.js +1 -3
- package/dist/Command/commandProcessor.js +41 -131
- package/dist/Command/globalArgs.js +9 -8
- package/dist/CommandLine/IProgressBar.js +0 -1
- package/dist/CommandLine/progressBarFactory.d.ts +1 -1
- package/dist/CommandLine/progressBarFactory.js +42 -13
- package/dist/CustomScript/Generate/customScriptGenerateCommand.js +17 -56
- package/dist/CustomScript/Generate/customScriptGenerateFacade.js +94 -109
- package/dist/CustomScript/Upload/customScriptUploadCommand.js +44 -120
- package/dist/CustomScript/customScriptCommand.d.ts +1 -9
- package/dist/CustomScript/customScriptCommand.js +6 -36
- package/dist/CustomScript/customScriptFacade.d.ts +2 -2
- package/dist/CustomScript/customScriptFacade.js +187 -297
- package/dist/Device/Connect/connectCommand.js +73 -137
- package/dist/Device/Content/setContentCommand.js +33 -78
- package/dist/Device/PowerAction/powerActionCommand.js +22 -65
- package/dist/Device/deviceCommand.js +7 -37
- package/dist/Device/deviceFacade.js +71 -127
- package/dist/Emulator/IEmulator.js +0 -1
- package/dist/Emulator/createDomain.d.ts +0 -1
- package/dist/Emulator/createDomain.js +44 -14
- package/dist/Emulator/emulatorFacade.js +75 -133
- package/dist/Emulator/emulatorFactory.js +123 -126
- package/dist/Firmware/Upload/firmwareUploadCommand.js +133 -221
- package/dist/Firmware/Upload/firmwareUploadFacade.js +75 -112
- package/dist/Firmware/Upload/firmwareUploadHelper.js +38 -6
- package/dist/Firmware/firmwareCommand.js +5 -35
- package/dist/Lib/archive.js +56 -62
- package/dist/Lib/childProcess.js +37 -5
- package/dist/Lib/fileSystem.js +76 -87
- package/dist/Lib/git.d.ts +1 -1
- package/dist/Lib/git.js +58 -87
- package/dist/Organization/Get/organizationGetCommand.js +14 -50
- package/dist/Organization/List/organizationListCommand.js +12 -46
- package/dist/Organization/SetDefault/organizationSetDefaultCommand.js +18 -56
- package/dist/Organization/organizationCommand.js +7 -37
- package/dist/Organization/organizationFacade.js +102 -177
- package/dist/RunControl/runControlHelper.js +14 -64
- package/dist/Timer/wait.js +2 -3
- package/dist/Timing/List/timingListCommand.js +20 -62
- package/dist/Timing/timingCommand.js +5 -35
- package/dist/generalCommand.js +1 -2
- package/dist/helper.d.ts +4 -4
- package/dist/helper.js +61 -122
- package/dist/index.js +19 -46
- package/dist/parameters.js +17 -40
- package/package.json +52 -57
- package/dist/Applet/Build/appletBuildCommand.js.map +0 -1
- package/dist/Applet/Generate/appletGenerateCommand.js.map +0 -1
- package/dist/Applet/Start/appletStartCommand.js.map +0 -1
- package/dist/Applet/Test/Upload/appletTestRunCommand.js.map +0 -1
- package/dist/Applet/Test/Upload/appletTestRunFacade.js.map +0 -1
- package/dist/Applet/Test/Upload/appletTestUploadCommand.js.map +0 -1
- package/dist/Applet/Test/Upload/appletTestUploadFacade.js.map +0 -1
- package/dist/Applet/Test/appletTestCommand.js.map +0 -1
- package/dist/Applet/Upload/appletUploadCommand.js.map +0 -1
- package/dist/Applet/Upload/appletUploadCommandHelper.js.map +0 -1
- package/dist/Applet/Upload/appletUploadFacade.js.map +0 -1
- package/dist/Applet/Upload/appletUploadFacadeHelper.js.map +0 -1
- package/dist/Applet/appletCommand.js.map +0 -1
- package/dist/Applet/appletErrors.js.map +0 -1
- package/dist/Applet/appletFacade.js.map +0 -1
- package/dist/Applet/appletServerHelper.js.map +0 -1
- package/dist/Auth/loginCommand.js.map +0 -1
- package/dist/Cache/tmpCache.js.map +0 -1
- package/dist/Cli/helper.js.map +0 -1
- package/dist/Cli/packageVersion.js.map +0 -1
- package/dist/Command/commandDefinition.js.map +0 -1
- package/dist/Command/commandProcessor.js.map +0 -1
- package/dist/Command/globalArgs.js.map +0 -1
- package/dist/CommandLine/IProgressBar.js.map +0 -1
- package/dist/CommandLine/progressBarFactory.js.map +0 -1
- package/dist/CustomScript/Generate/customScriptGenerateCommand.js.map +0 -1
- package/dist/CustomScript/Generate/customScriptGenerateFacade.js.map +0 -1
- package/dist/CustomScript/Upload/customScriptUploadCommand.js.map +0 -1
- package/dist/CustomScript/customScriptCommand.js.map +0 -1
- package/dist/CustomScript/customScriptFacade.js.map +0 -1
- package/dist/Device/Connect/connectCommand.js.map +0 -1
- package/dist/Device/Content/setContentCommand.js.map +0 -1
- package/dist/Device/PowerAction/powerActionCommand.js.map +0 -1
- package/dist/Device/deviceCommand.js.map +0 -1
- package/dist/Device/deviceFacade.js.map +0 -1
- package/dist/Emulator/IEmulator.js.map +0 -1
- package/dist/Emulator/createDomain.js.map +0 -1
- package/dist/Emulator/emulatorFacade.js.map +0 -1
- package/dist/Emulator/emulatorFactory.js.map +0 -1
- package/dist/Firmware/Upload/firmwareUploadCommand.js.map +0 -1
- package/dist/Firmware/Upload/firmwareUploadFacade.js.map +0 -1
- package/dist/Firmware/Upload/firmwareUploadHelper.js.map +0 -1
- package/dist/Firmware/firmwareCommand.js.map +0 -1
- package/dist/Lib/archive.js.map +0 -1
- package/dist/Lib/childProcess.js.map +0 -1
- package/dist/Lib/fileSystem.js.map +0 -1
- package/dist/Lib/git.js.map +0 -1
- package/dist/Organization/Get/organizationGetCommand.js.map +0 -1
- package/dist/Organization/List/organizationListCommand.js.map +0 -1
- package/dist/Organization/SetDefault/organizationSetDefaultCommand.js.map +0 -1
- package/dist/Organization/organizationCommand.js.map +0 -1
- package/dist/Organization/organizationFacade.js.map +0 -1
- package/dist/RunControl/runControlHelper.js.map +0 -1
- package/dist/Timer/wait.js.map +0 -1
- package/dist/Timing/List/timingListCommand.js.map +0 -1
- package/dist/Timing/timingCommand.js.map +0 -1
- package/dist/generalCommand.js.map +0 -1
- package/dist/helper.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/parameters.js.map +0 -1
|
@@ -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,155 +41,90 @@ 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
|
|
12
|
-
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
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.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
exports.printVersion = printVersion;
|
|
49
|
+
exports.printUpdateMessage = printUpdateMessage;
|
|
50
|
+
exports.getLatestVersion = getLatestVersion;
|
|
51
|
+
exports.getUpdateMessage = getUpdateMessage;
|
|
52
|
+
exports.newVersionAvailable = newVersionAvailable;
|
|
53
|
+
exports.getUpdateVersionMessage = getUpdateVersionMessage;
|
|
54
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
55
|
+
const semver = __importStar(require("semver"));
|
|
56
|
+
const child_process_promise_1 = require("child-process-promise");
|
|
57
|
+
const helper_1 = require("./helper");
|
|
58
|
+
const tmpCache_1 = require("../Cache/tmpCache");
|
|
59
|
+
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
46
60
|
function printVersion() {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
case 0:
|
|
51
|
-
(0, log_1.log)('info', (0, helper_1.getPackageVersion)());
|
|
52
|
-
return [4 /*yield*/, printUpdateMessage()];
|
|
53
|
-
case 1:
|
|
54
|
-
_a.sent();
|
|
55
|
-
return [2 /*return*/];
|
|
56
|
-
}
|
|
57
|
-
});
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
(0, log_1.log)('info', (0, helper_1.getPackageVersion)());
|
|
63
|
+
yield printUpdateMessage();
|
|
58
64
|
});
|
|
59
65
|
}
|
|
60
|
-
exports.printVersion = printVersion;
|
|
61
66
|
function printUpdateMessage() {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
case 1:
|
|
72
|
-
latestVersion = _a.sent();
|
|
73
|
-
return [4 /*yield*/, getUpdateMessage(packageName, installedVersion, latestVersion)];
|
|
74
|
-
case 2:
|
|
75
|
-
updateMessage = _a.sent();
|
|
76
|
-
if (updateMessage) {
|
|
77
|
-
(0, log_1.log)('info', updateMessage);
|
|
78
|
-
}
|
|
79
|
-
return [2 /*return*/];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const packageName = (0, helper_1.getPackageName)();
|
|
69
|
+
const installedVersion = (0, helper_1.getPackageVersion)();
|
|
70
|
+
(0, log_1.log)('info', 'Checking updates...');
|
|
71
|
+
const latestVersion = yield getLatestVersion(packageName);
|
|
72
|
+
const updateMessage = yield getUpdateMessage(packageName, installedVersion, latestVersion);
|
|
73
|
+
if (updateMessage) {
|
|
74
|
+
(0, log_1.log)('info', updateMessage);
|
|
75
|
+
}
|
|
82
76
|
});
|
|
83
77
|
}
|
|
84
|
-
exports.printUpdateMessage = printUpdateMessage;
|
|
85
78
|
function getLatestVersion(packageName) {
|
|
86
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
latestVersion = versionCommand.stdout.trim();
|
|
96
|
-
return [2 /*return*/, latestVersion];
|
|
97
|
-
case 2:
|
|
98
|
-
e_1 = _a.sent();
|
|
99
|
-
return [2 /*return*/, undefined];
|
|
100
|
-
case 3: return [2 /*return*/];
|
|
101
|
-
}
|
|
102
|
-
});
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
try {
|
|
81
|
+
const versionCommand = yield (0, child_process_promise_1.exec)(`npm show ${packageName} version`, { timeout: 10000 });
|
|
82
|
+
const latestVersion = versionCommand.stdout.trim();
|
|
83
|
+
return latestVersion;
|
|
84
|
+
}
|
|
85
|
+
catch (_a) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
103
88
|
});
|
|
104
89
|
}
|
|
105
|
-
exports.getLatestVersion = getLatestVersion;
|
|
106
90
|
function getUpdateMessage(packageName, installedVersion, latestVersion) {
|
|
107
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return [2 /*return*/, undefined];
|
|
125
|
-
}
|
|
126
|
-
return [2 /*return*/];
|
|
127
|
-
});
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
const NEW_VERSION_AVAILABLE_MESSAGE = `` +
|
|
93
|
+
chalk_1.default.bold.yellow(`New version of signageOS CLI (v${latestVersion}) Tool is available.\n`) +
|
|
94
|
+
`See changelog: https://github.com/signageos/cli/blob/master/CHANGELOG.md \n` +
|
|
95
|
+
`${chalk_1.default.bold(`Update your tool using`)} npm i ${packageName}@latest -g`;
|
|
96
|
+
const INSTALLED_UP_TO_DATE_MESSAGE = chalk_1.default.bold.green(`Your tool is up to date.`);
|
|
97
|
+
const newVersionIsAvailable = latestVersion ? semver.gt(latestVersion, installedVersion) : false;
|
|
98
|
+
const installedIsUpToDate = installedVersion === latestVersion;
|
|
99
|
+
if (newVersionIsAvailable) {
|
|
100
|
+
return NEW_VERSION_AVAILABLE_MESSAGE;
|
|
101
|
+
}
|
|
102
|
+
else if (installedIsUpToDate) {
|
|
103
|
+
return INSTALLED_UP_TO_DATE_MESSAGE;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
128
108
|
});
|
|
129
109
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
var LATEST_VERSION_CACHE_EXPIRE_IN_MS = 60 * 60e3; // 1 hour
|
|
110
|
+
const LATEST_VERSION_CACHE_KEY = 'package.latestVersion';
|
|
111
|
+
const LATEST_VERSION_CACHE_EXPIRE_IN_MS = 60 * 60e3; // 1 hour
|
|
133
112
|
function newVersionAvailable() {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (!!latestVersion) return [3 /*break*/, 2];
|
|
144
|
-
return [4 /*yield*/, getLatestVersion(packageName)];
|
|
145
|
-
case 1:
|
|
146
|
-
latestVersion = _b.sent();
|
|
147
|
-
if (latestVersion) {
|
|
148
|
-
(0, tmpCache_1.updateCacheValue)(LATEST_VERSION_CACHE_KEY, latestVersion, { expireInMs: LATEST_VERSION_CACHE_EXPIRE_IN_MS });
|
|
149
|
-
}
|
|
150
|
-
_b.label = 2;
|
|
151
|
-
case 2: return [2 /*return*/, latestVersion ? semver.gt(latestVersion, installedVersion) : false];
|
|
113
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
var _a;
|
|
115
|
+
const packageName = (0, helper_1.getPackageName)();
|
|
116
|
+
const installedVersion = (0, helper_1.getPackageVersion)();
|
|
117
|
+
let latestVersion = (_a = (0, tmpCache_1.getCachedValue)(LATEST_VERSION_CACHE_KEY)) !== null && _a !== void 0 ? _a : undefined;
|
|
118
|
+
if (!latestVersion) {
|
|
119
|
+
latestVersion = yield getLatestVersion(packageName);
|
|
120
|
+
if (latestVersion) {
|
|
121
|
+
(0, tmpCache_1.updateCacheValue)(LATEST_VERSION_CACHE_KEY, latestVersion, { expireInMs: LATEST_VERSION_CACHE_EXPIRE_IN_MS });
|
|
152
122
|
}
|
|
153
|
-
}
|
|
123
|
+
}
|
|
124
|
+
return latestVersion ? semver.gt(latestVersion, installedVersion) : false;
|
|
154
125
|
});
|
|
155
126
|
}
|
|
156
|
-
exports.newVersionAvailable = newVersionAvailable;
|
|
157
127
|
function getUpdateVersionMessage() {
|
|
158
|
-
|
|
128
|
+
const updateVersionMessage = chalk_1.default.bold.yellow(`New version of signageOS CLI Tool is available.`);
|
|
159
129
|
return updateVersionMessage;
|
|
160
130
|
}
|
|
161
|
-
exports.getUpdateVersionMessage = getUpdateVersionMessage;
|
|
162
|
-
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -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,120 @@
|
|
|
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
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.uninstallAutocomplete = exports.OPTION_LIST = void 0;
|
|
46
|
+
const fs = __importStar(require("fs"));
|
|
47
|
+
const path = __importStar(require("path"));
|
|
48
|
+
const commandDefinition_1 = require("../../commandDefinition");
|
|
49
|
+
exports.OPTION_LIST = [];
|
|
50
|
+
exports.uninstallAutocomplete = (0, commandDefinition_1.createCommandDefinition)({
|
|
51
|
+
name: 'uninstall',
|
|
52
|
+
description: 'Uninstall command auto-completion for bash/zsh shells',
|
|
53
|
+
optionList: exports.OPTION_LIST,
|
|
54
|
+
commands: [],
|
|
55
|
+
run() {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
try {
|
|
58
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || '';
|
|
59
|
+
if (!homeDir) {
|
|
60
|
+
console.error('Could not determine home directory for auto-completion uninstallation.');
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
// Path to the completion script
|
|
64
|
+
const completionFilePath = path.join(homeDir, '.sos-completion.sh');
|
|
65
|
+
// Remove completion script if it exists
|
|
66
|
+
try {
|
|
67
|
+
yield fs.promises.access(completionFilePath);
|
|
68
|
+
yield fs.promises.unlink(completionFilePath);
|
|
69
|
+
console.log(`✅ Removed completion script: ${completionFilePath}`);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
if (error.code === 'ENOENT') {
|
|
73
|
+
console.log(`ℹ️ Completion script not found at: ${completionFilePath}`);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Check shell config files and remove the source line
|
|
80
|
+
const shellConfigFiles = ['.zshrc', '.bashrc', '.bash_profile'];
|
|
81
|
+
const sourceLine = `source ${completionFilePath}`;
|
|
82
|
+
let configModified = false;
|
|
83
|
+
for (const configFile of shellConfigFiles) {
|
|
84
|
+
const configFilePath = path.join(homeDir, configFile);
|
|
85
|
+
if (fs.existsSync(configFilePath)) {
|
|
86
|
+
try {
|
|
87
|
+
let content = fs.readFileSync(configFilePath, 'utf8');
|
|
88
|
+
const originalContent = content;
|
|
89
|
+
// Remove the source line and the comment above it
|
|
90
|
+
const sourceLineWithComment = `# Added by signageOS CLI for tab completion\n${sourceLine}\n`;
|
|
91
|
+
content = content.replace(sourceLineWithComment, '');
|
|
92
|
+
// If the comment and source line pattern doesn't match exactly, try just the source line
|
|
93
|
+
if (content === originalContent) {
|
|
94
|
+
content = content.replace(new RegExp(`${sourceLine}\\n?`, 'g'), '');
|
|
95
|
+
}
|
|
96
|
+
if (content !== originalContent) {
|
|
97
|
+
fs.writeFileSync(configFilePath, content, 'utf8');
|
|
98
|
+
console.log(`✅ Removed source line from ${configFile}`);
|
|
99
|
+
configModified = true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
104
|
+
console.error(`Failed to modify ${configFile}:`, errorMessage);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
if (!configModified) {
|
|
109
|
+
console.info(`ℹ️ No shell configuration files were modified`);
|
|
110
|
+
}
|
|
111
|
+
console.log('\nAuto-completion for signageOS CLI has been uninstalled.');
|
|
112
|
+
console.log('You may need to restart your terminal or run "source ~/.bashrc" (or equivalent) for changes to take effect.');
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
116
|
+
console.error('Error uninstalling auto-completion:', errorMessage);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ICommand, OptionList } from '../commandDefinition';
|
|
2
|
+
export declare const OPTION_LIST: readonly [];
|
|
3
|
+
export declare const initializeAutocomplete: (rootCommand: ICommand<string, OptionList>) => void;
|
|
4
|
+
export declare const autocomplete: {
|
|
5
|
+
name: "autocomplete";
|
|
6
|
+
description: string;
|
|
7
|
+
optionList: readonly [];
|
|
8
|
+
commands: ({
|
|
9
|
+
name: "install";
|
|
10
|
+
description: string;
|
|
11
|
+
optionList: readonly [];
|
|
12
|
+
commands: never[];
|
|
13
|
+
run(): Promise<void>;
|
|
14
|
+
} | {
|
|
15
|
+
name: "uninstall";
|
|
16
|
+
description: string;
|
|
17
|
+
optionList: readonly [];
|
|
18
|
+
commands: never[];
|
|
19
|
+
run(): Promise<void>;
|
|
20
|
+
})[];
|
|
21
|
+
run(): Promise<never>;
|
|
22
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
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.autocomplete = exports.initializeAutocomplete = exports.OPTION_LIST = void 0;
|
|
13
|
+
const commandDefinition_1 = require("../commandDefinition");
|
|
14
|
+
const installAutocompleteCommand_1 = require("./Install/installAutocompleteCommand");
|
|
15
|
+
const uninstallAutocompleteCommand_1 = require("./Uninstall/uninstallAutocompleteCommand");
|
|
16
|
+
exports.OPTION_LIST = [];
|
|
17
|
+
// Function to initialize the autocomplete command with the root command reference
|
|
18
|
+
const initializeAutocomplete = (rootCommand) => {
|
|
19
|
+
(0, installAutocompleteCommand_1.setRootCommand)(rootCommand);
|
|
20
|
+
};
|
|
21
|
+
exports.initializeAutocomplete = initializeAutocomplete;
|
|
22
|
+
exports.autocomplete = (0, commandDefinition_1.createCommandDefinition)({
|
|
23
|
+
name: 'autocomplete',
|
|
24
|
+
description: 'Commands for managing CLI auto-completion',
|
|
25
|
+
optionList: exports.OPTION_LIST,
|
|
26
|
+
commands: [installAutocompleteCommand_1.installAutocomplete, uninstallAutocompleteCommand_1.uninstallAutocomplete],
|
|
27
|
+
run() {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
throw new Error('Please use a subcommand: install, uninstall');
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ICommand, OptionList } from './commandDefinition';
|
|
2
|
+
export declare function generateCompletionScript(rootCommand: ICommand<string, OptionList>): string;
|
|
3
|
+
export declare function installAutoCompletion(rootCommand: ICommand<string, OptionList>): boolean;
|
|
4
|
+
export declare function setupCompletion(rootCommand: ICommand<string, OptionList>): boolean;
|