@signageos/cli 2.3.1 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/Applet/Build/appletBuildCommand.js +28 -72
- package/dist/Applet/Generate/Templates/rspack.config.mjs.template +12 -12
- package/dist/Applet/Generate/appletGenerateCommand.d.ts +23 -62
- package/dist/Applet/Generate/appletGenerateCommand.js +398 -365
- package/dist/Applet/Start/appletStartCommand.js +69 -131
- package/dist/Applet/Test/Upload/appletTestRunCommand.js +89 -177
- package/dist/Applet/Test/Upload/appletTestRunFacade.js +4 -27
- package/dist/Applet/Test/Upload/appletTestUploadCommand.js +98 -223
- package/dist/Applet/Test/Upload/appletTestUploadFacade.js +39 -102
- package/dist/Applet/Test/appletTestCommand.js +6 -36
- package/dist/Applet/Upload/appletUploadCommand.js +199 -305
- package/dist/Applet/Upload/appletUploadCommandHelper.js +103 -138
- package/dist/Applet/Upload/appletUploadFacade.d.ts +2 -2
- package/dist/Applet/Upload/appletUploadFacade.js +172 -263
- package/dist/Applet/Upload/appletUploadFacadeHelper.js +39 -52
- package/dist/Applet/appletCommand.d.ts +22 -62
- package/dist/Applet/appletCommand.js +9 -39
- package/dist/Applet/appletErrors.js +5 -24
- package/dist/Applet/appletFacade.js +106 -141
- package/dist/Applet/appletServerHelper.js +16 -53
- package/dist/Auth/loginCommand.js +96 -137
- package/dist/Cache/tmpCache.js +35 -13
- package/dist/Cli/helper.js +1 -2
- package/dist/Cli/packageVersion.js +82 -123
- package/dist/Command/commandDefinition.js +0 -1
- package/dist/Command/commandProcessor.js +40 -129
- package/dist/Command/globalArgs.js +7 -5
- package/dist/CommandLine/IProgressBar.js +0 -1
- package/dist/CommandLine/progressBarFactory.js +31 -11
- package/dist/CustomScript/Generate/customScriptGenerateCommand.js +17 -56
- package/dist/CustomScript/Generate/customScriptGenerateFacade.js +82 -106
- package/dist/CustomScript/Upload/customScriptUploadCommand.js +44 -120
- package/dist/CustomScript/customScriptCommand.js +6 -36
- package/dist/CustomScript/customScriptFacade.js +175 -294
- package/dist/Device/Connect/connectCommand.js +72 -136
- package/dist/Device/Content/setContentCommand.js +33 -78
- package/dist/Device/PowerAction/powerActionCommand.js +22 -65
- package/dist/Device/deviceCommand.js +7 -37
- package/dist/Device/deviceFacade.js +67 -123
- package/dist/Emulator/IEmulator.js +0 -1
- package/dist/Emulator/createDomain.js +33 -12
- package/dist/Emulator/emulatorFacade.js +74 -131
- package/dist/Emulator/emulatorFactory.js +112 -124
- package/dist/Firmware/Upload/firmwareUploadCommand.js +133 -221
- package/dist/Firmware/Upload/firmwareUploadFacade.js +64 -110
- package/dist/Firmware/Upload/firmwareUploadHelper.js +27 -5
- package/dist/Firmware/firmwareCommand.js +5 -35
- package/dist/Lib/archive.js +45 -60
- package/dist/Lib/childProcess.js +27 -5
- package/dist/Lib/fileSystem.js +62 -82
- package/dist/Lib/git.d.ts +1 -1
- package/dist/Lib/git.js +44 -82
- package/dist/Organization/Get/organizationGetCommand.js +14 -50
- package/dist/Organization/List/organizationListCommand.js +12 -46
- package/dist/Organization/SetDefault/organizationSetDefaultCommand.js +18 -56
- package/dist/Organization/organizationCommand.js +7 -37
- package/dist/Organization/organizationFacade.js +97 -172
- package/dist/RunControl/runControlHelper.js +11 -60
- package/dist/Timer/wait.js +1 -2
- package/dist/Timing/List/timingListCommand.js +20 -62
- package/dist/Timing/timingCommand.js +5 -35
- package/dist/generalCommand.js +1 -2
- package/dist/helper.js +48 -109
- package/dist/index.js +15 -45
- package/dist/parameters.js +17 -40
- package/package.json +16 -18
- package/dist/Applet/Build/appletBuildCommand.js.map +0 -1
- package/dist/Applet/Generate/appletGenerateCommand.js.map +0 -1
- package/dist/Applet/Start/appletStartCommand.js.map +0 -1
- package/dist/Applet/Test/Upload/appletTestRunCommand.js.map +0 -1
- package/dist/Applet/Test/Upload/appletTestRunFacade.js.map +0 -1
- package/dist/Applet/Test/Upload/appletTestUploadCommand.js.map +0 -1
- package/dist/Applet/Test/Upload/appletTestUploadFacade.js.map +0 -1
- package/dist/Applet/Test/appletTestCommand.js.map +0 -1
- package/dist/Applet/Upload/appletUploadCommand.js.map +0 -1
- package/dist/Applet/Upload/appletUploadCommandHelper.js.map +0 -1
- package/dist/Applet/Upload/appletUploadFacade.js.map +0 -1
- package/dist/Applet/Upload/appletUploadFacadeHelper.js.map +0 -1
- package/dist/Applet/appletCommand.js.map +0 -1
- package/dist/Applet/appletErrors.js.map +0 -1
- package/dist/Applet/appletFacade.js.map +0 -1
- package/dist/Applet/appletServerHelper.js.map +0 -1
- package/dist/Auth/loginCommand.js.map +0 -1
- package/dist/Cache/tmpCache.js.map +0 -1
- package/dist/Cli/helper.js.map +0 -1
- package/dist/Cli/packageVersion.js.map +0 -1
- package/dist/Command/commandDefinition.js.map +0 -1
- package/dist/Command/commandProcessor.js.map +0 -1
- package/dist/Command/globalArgs.js.map +0 -1
- package/dist/CommandLine/IProgressBar.js.map +0 -1
- package/dist/CommandLine/progressBarFactory.js.map +0 -1
- package/dist/CustomScript/Generate/customScriptGenerateCommand.js.map +0 -1
- package/dist/CustomScript/Generate/customScriptGenerateFacade.js.map +0 -1
- package/dist/CustomScript/Upload/customScriptUploadCommand.js.map +0 -1
- package/dist/CustomScript/customScriptCommand.js.map +0 -1
- package/dist/CustomScript/customScriptFacade.js.map +0 -1
- package/dist/Device/Connect/connectCommand.js.map +0 -1
- package/dist/Device/Content/setContentCommand.js.map +0 -1
- package/dist/Device/PowerAction/powerActionCommand.js.map +0 -1
- package/dist/Device/deviceCommand.js.map +0 -1
- package/dist/Device/deviceFacade.js.map +0 -1
- package/dist/Emulator/IEmulator.js.map +0 -1
- package/dist/Emulator/createDomain.js.map +0 -1
- package/dist/Emulator/emulatorFacade.js.map +0 -1
- package/dist/Emulator/emulatorFactory.js.map +0 -1
- package/dist/Firmware/Upload/firmwareUploadCommand.js.map +0 -1
- package/dist/Firmware/Upload/firmwareUploadFacade.js.map +0 -1
- package/dist/Firmware/Upload/firmwareUploadHelper.js.map +0 -1
- package/dist/Firmware/firmwareCommand.js.map +0 -1
- package/dist/Lib/archive.js.map +0 -1
- package/dist/Lib/childProcess.js.map +0 -1
- package/dist/Lib/fileSystem.js.map +0 -1
- package/dist/Lib/git.js.map +0 -1
- package/dist/Organization/Get/organizationGetCommand.js.map +0 -1
- package/dist/Organization/List/organizationListCommand.js.map +0 -1
- package/dist/Organization/SetDefault/organizationSetDefaultCommand.js.map +0 -1
- package/dist/Organization/organizationCommand.js.map +0 -1
- package/dist/Organization/organizationFacade.js.map +0 -1
- package/dist/RunControl/runControlHelper.js.map +0 -1
- package/dist/Timer/wait.js.map +0 -1
- package/dist/Timing/List/timingListCommand.js.map +0 -1
- package/dist/Timing/timingCommand.js.map +0 -1
- package/dist/generalCommand.js.map +0 -1
- package/dist/helper.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/parameters.js.map +0 -1
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 (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;
|
|
12
24
|
};
|
|
13
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -19,48 +31,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
32
|
});
|
|
21
33
|
};
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
29
|
-
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;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
36
|
};
|
|
49
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
38
|
exports.login = exports.getIsAuth0OrLegacyEnabled = void 0;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
39
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
40
|
+
const prompts_1 = __importDefault(require("prompts"));
|
|
41
|
+
const debug_1 = __importDefault(require("debug"));
|
|
42
|
+
const os = __importStar(require("os"));
|
|
43
|
+
const apiVersions_1 = require("@signageos/sdk/dist/RestApi/apiVersions");
|
|
44
|
+
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
45
|
+
const sosControlHelper_1 = require("@signageos/sdk/dist/SosHelper/sosControlHelper");
|
|
46
|
+
const helper_1 = require("../helper");
|
|
47
|
+
const runControlHelper_1 = require("../RunControl/runControlHelper");
|
|
48
|
+
const parameters_1 = require("../parameters");
|
|
49
|
+
const commandDefinition_1 = require("../Command/commandDefinition");
|
|
50
|
+
const Debug = (0, debug_1.default)('@signageos/cli:Auth:login');
|
|
51
|
+
const OPTION_LIST = [{ name: 'username', type: String, description: `Username or e-mail used for ${parameters_1.parameters.boxHost}` }];
|
|
64
52
|
/**
|
|
65
53
|
* To explicitly enable auth0 authentication add flag --auth0-enabled to command line options
|
|
66
54
|
* { _unknown: [ '--auth0-enabled' ], command: [ 'login' ] }
|
|
@@ -70,9 +58,9 @@ var OPTION_LIST = [{ name: 'username', type: String, description: "Username or e
|
|
|
70
58
|
*
|
|
71
59
|
* Only one from auth0 and legacy authentication can be active at the moment
|
|
72
60
|
*/
|
|
73
|
-
|
|
61
|
+
const getIsAuth0OrLegacyEnabled = (options) => {
|
|
74
62
|
var _a, _b;
|
|
75
|
-
|
|
63
|
+
const queryParams = {};
|
|
76
64
|
if ((_a = options._unknown) === null || _a === void 0 ? void 0 : _a.includes('--auth0-enabled')) {
|
|
77
65
|
queryParams.isAuth0Enabled = true;
|
|
78
66
|
}
|
|
@@ -90,97 +78,68 @@ exports.login = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
90
78
|
description: 'Login account using username & password',
|
|
91
79
|
optionList: OPTION_LIST,
|
|
92
80
|
commands: [],
|
|
93
|
-
run
|
|
94
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (!identification) {
|
|
112
|
-
throw new Error('Missing argument --username <string>');
|
|
113
|
-
}
|
|
114
|
-
return [4 /*yield*/, prompts({
|
|
115
|
-
type: 'password',
|
|
116
|
-
name: 'password',
|
|
117
|
-
message: "Type your password used for ".concat(parameters_1.parameters.boxHost),
|
|
118
|
-
})];
|
|
119
|
-
case 3:
|
|
120
|
-
password = (_b.sent()).password;
|
|
121
|
-
return [4 /*yield*/, (0, runControlHelper_1.loadConfig)()];
|
|
122
|
-
case 4:
|
|
123
|
-
config = _b.sent();
|
|
124
|
-
apiUrl = (0, helper_1.getApiUrl)(config);
|
|
125
|
-
authQueryParams = (0, exports.getIsAuth0OrLegacyEnabled)(options);
|
|
126
|
-
return [4 /*yield*/, getOrCreateApiSecurityToken(__assign({ identification: identification, password: password, apiUrl: apiUrl }, authQueryParams))];
|
|
127
|
-
case 5:
|
|
128
|
-
_a = _b.sent(), tokenId = _a.id, apiSecurityToken = _a.securityToken, name = _a.name;
|
|
129
|
-
return [4 /*yield*/, (0, runControlHelper_1.saveConfig)({
|
|
130
|
-
apiUrl: apiUrl !== parameters_1.parameters.apiUrl ? apiUrl : undefined,
|
|
131
|
-
identification: tokenId,
|
|
132
|
-
apiSecurityToken: apiSecurityToken,
|
|
133
|
-
})];
|
|
134
|
-
case 6:
|
|
135
|
-
_b.sent();
|
|
136
|
-
(0, log_1.log)('info', "User ".concat(chalk_1.default.green(identification), " has been logged in with token \"").concat(name, "\". Credentials are stored in ").concat(chalk_1.default.blue((0, sosControlHelper_1.getConfigFilePath)())));
|
|
137
|
-
return [2 /*return*/];
|
|
138
|
-
}
|
|
81
|
+
run(options) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
let identification = options.username;
|
|
84
|
+
if (!identification) {
|
|
85
|
+
const response = yield (0, prompts_1.default)({
|
|
86
|
+
type: 'text',
|
|
87
|
+
name: 'username',
|
|
88
|
+
message: `Type your username or e-mail used for ${parameters_1.parameters.boxHost}`,
|
|
89
|
+
});
|
|
90
|
+
identification = response.username;
|
|
91
|
+
}
|
|
92
|
+
if (!identification) {
|
|
93
|
+
throw new Error('Missing argument --username <string>');
|
|
94
|
+
}
|
|
95
|
+
const { password } = yield (0, prompts_1.default)({
|
|
96
|
+
type: 'password',
|
|
97
|
+
name: 'password',
|
|
98
|
+
message: `Type your password used for ${parameters_1.parameters.boxHost}`,
|
|
139
99
|
});
|
|
100
|
+
const config = yield (0, runControlHelper_1.loadConfig)();
|
|
101
|
+
const apiUrl = (0, helper_1.getApiUrl)(config);
|
|
102
|
+
const authQueryParams = (0, exports.getIsAuth0OrLegacyEnabled)(options);
|
|
103
|
+
const { id: tokenId, securityToken: apiSecurityToken, name, } = yield getOrCreateApiSecurityToken(Object.assign({ identification,
|
|
104
|
+
password,
|
|
105
|
+
apiUrl }, authQueryParams));
|
|
106
|
+
yield (0, runControlHelper_1.saveConfig)({
|
|
107
|
+
apiUrl: apiUrl !== parameters_1.parameters.apiUrl ? apiUrl : undefined,
|
|
108
|
+
identification: tokenId,
|
|
109
|
+
apiSecurityToken,
|
|
110
|
+
});
|
|
111
|
+
(0, log_1.log)('info', `User ${chalk_1.default.green(identification)} has been logged in with token "${name}". Credentials are stored in ${chalk_1.default.blue((0, sosControlHelper_1.getConfigFilePath)())}`);
|
|
140
112
|
});
|
|
141
113
|
},
|
|
142
114
|
});
|
|
143
|
-
function getOrCreateApiSecurityToken(
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if (responseOfPost.status === 201) {
|
|
167
|
-
return [2 /*return*/, bodyOfPost];
|
|
168
|
-
}
|
|
169
|
-
else if (responseOfPost.status === 403) {
|
|
170
|
-
throw new Error("Incorrect username or password");
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
throw new Error('Unknown error: ' + (bodyOfPost && bodyOfPost.message ? bodyOfPost.message : responseOfPost.status));
|
|
174
|
-
}
|
|
175
|
-
return [2 /*return*/];
|
|
176
|
-
}
|
|
177
|
-
});
|
|
115
|
+
function getOrCreateApiSecurityToken({ identification, password, apiUrl, isAuth0Enabled, isLegacyEnabled, }) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
const ACCOUNT_SECURITY_TOKEN_RESOURCE = 'account/security-token';
|
|
118
|
+
const options = {
|
|
119
|
+
url: apiUrl,
|
|
120
|
+
auth: { clientId: undefined, secret: undefined },
|
|
121
|
+
version: apiVersions_1.ApiVersions.V1,
|
|
122
|
+
};
|
|
123
|
+
const tokenName = generateTokenName();
|
|
124
|
+
const query = Object.assign(Object.assign({ identification,
|
|
125
|
+
password, name: tokenName }, (isAuth0Enabled !== undefined ? { isAuth0AuthenticationEnabled: isAuth0Enabled } : {})), (isLegacyEnabled !== undefined ? { isLegacyAuthenticationEnabled: isLegacyEnabled } : {}));
|
|
126
|
+
const responseOfPost = yield (0, helper_1.postResource)(options, ACCOUNT_SECURITY_TOKEN_RESOURCE, query);
|
|
127
|
+
const bodyOfPost = JSON.parse(yield responseOfPost.text(), helper_1.deserializeJSON);
|
|
128
|
+
Debug('POST security-token response', bodyOfPost);
|
|
129
|
+
if (responseOfPost.status === 201) {
|
|
130
|
+
return bodyOfPost;
|
|
131
|
+
}
|
|
132
|
+
else if (responseOfPost.status === 403) {
|
|
133
|
+
throw new Error(`Incorrect username or password`);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
throw new Error('Unknown error: ' + (bodyOfPost && bodyOfPost.message ? bodyOfPost.message : responseOfPost.status));
|
|
137
|
+
}
|
|
178
138
|
});
|
|
179
139
|
}
|
|
180
140
|
function generateTokenName() {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
return
|
|
141
|
+
const hostname = os.hostname();
|
|
142
|
+
const shortHostname = hostname.split('.')[0];
|
|
143
|
+
const userInfo = os.userInfo();
|
|
144
|
+
return `${userInfo.username}@${shortHostname}`;
|
|
185
145
|
}
|
|
186
|
-
//# sourceMappingURL=loginCommand.js.map
|
package/dist/Cache/tmpCache.js
CHANGED
|
@@ -1,22 +1,45 @@
|
|
|
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 (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
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.updateCacheValue = exports.getCachedValue = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
27
|
+
const os = __importStar(require("os"));
|
|
28
|
+
const fs = __importStar(require("fs-extra"));
|
|
29
|
+
const path = __importStar(require("path"));
|
|
30
|
+
const SOS_CACHE_DIR = 'sos-cache';
|
|
31
|
+
const TMP_BASE_PATH = path.join(os.tmpdir(), SOS_CACHE_DIR);
|
|
9
32
|
function getCachedValue(key) {
|
|
10
33
|
try {
|
|
11
34
|
fs.ensureDirSync(TMP_BASE_PATH);
|
|
12
|
-
|
|
13
|
-
|
|
35
|
+
const cacheValuePath = path.join(TMP_BASE_PATH, key);
|
|
36
|
+
const cachedValue = JSON.parse(fs.readFileSync(cacheValuePath).toString());
|
|
14
37
|
if (hasExpired(cachedValue.expireAt)) {
|
|
15
38
|
return null;
|
|
16
39
|
}
|
|
17
40
|
return cachedValue.value;
|
|
18
41
|
}
|
|
19
|
-
catch (
|
|
42
|
+
catch (_a) {
|
|
20
43
|
return null;
|
|
21
44
|
}
|
|
22
45
|
}
|
|
@@ -24,14 +47,14 @@ exports.getCachedValue = getCachedValue;
|
|
|
24
47
|
function updateCacheValue(key, value, options) {
|
|
25
48
|
try {
|
|
26
49
|
fs.ensureDirSync(TMP_BASE_PATH);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
value
|
|
50
|
+
const cacheValuePath = path.join(TMP_BASE_PATH, key);
|
|
51
|
+
const cachedValue = {
|
|
52
|
+
value,
|
|
30
53
|
expireAt: new Date().valueOf() + options.expireInMs,
|
|
31
54
|
};
|
|
32
55
|
fs.writeFileSync(cacheValuePath, JSON.stringify(cachedValue));
|
|
33
56
|
}
|
|
34
|
-
catch (
|
|
57
|
+
catch (_a) {
|
|
35
58
|
// skip caching
|
|
36
59
|
}
|
|
37
60
|
}
|
|
@@ -39,4 +62,3 @@ exports.updateCacheValue = updateCacheValue;
|
|
|
39
62
|
function hasExpired(expireAt) {
|
|
40
63
|
return new Date().valueOf() > expireAt;
|
|
41
64
|
}
|
|
42
|
-
//# sourceMappingURL=tmpCache.js.map
|
package/dist/Cli/helper.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getPackageVersion = exports.getPackageName = void 0;
|
|
4
|
-
|
|
4
|
+
const parameters_1 = require("../parameters");
|
|
5
5
|
function getPackageName() {
|
|
6
6
|
return parameters_1.parameters.name;
|
|
7
7
|
}
|
|
@@ -10,4 +10,3 @@ function getPackageVersion() {
|
|
|
10
10
|
return parameters_1.parameters.version;
|
|
11
11
|
}
|
|
12
12
|
exports.getPackageVersion = getPackageVersion;
|
|
13
|
-
//# sourceMappingURL=helper.js.map
|
|
@@ -1,4 +1,27 @@
|
|
|
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 (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
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,155 +31,91 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
32
|
});
|
|
10
33
|
};
|
|
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
|
-
}
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
36
|
};
|
|
38
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
38
|
exports.getUpdateVersionMessage = exports.newVersionAvailable = exports.getUpdateMessage = exports.getLatestVersion = exports.printUpdateMessage = exports.printVersion = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
40
|
+
const semver = __importStar(require("semver"));
|
|
41
|
+
const child_process_promise_1 = require("child-process-promise");
|
|
42
|
+
const helper_1 = require("./helper");
|
|
43
|
+
const tmpCache_1 = require("../Cache/tmpCache");
|
|
44
|
+
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
46
45
|
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
|
-
});
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
(0, log_1.log)('info', (0, helper_1.getPackageVersion)());
|
|
48
|
+
yield printUpdateMessage();
|
|
58
49
|
});
|
|
59
50
|
}
|
|
60
51
|
exports.printVersion = printVersion;
|
|
61
52
|
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
|
-
});
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const packageName = (0, helper_1.getPackageName)();
|
|
55
|
+
const installedVersion = (0, helper_1.getPackageVersion)();
|
|
56
|
+
(0, log_1.log)('info', 'Checking updates...');
|
|
57
|
+
const latestVersion = yield getLatestVersion(packageName);
|
|
58
|
+
const updateMessage = yield getUpdateMessage(packageName, installedVersion, latestVersion);
|
|
59
|
+
if (updateMessage) {
|
|
60
|
+
(0, log_1.log)('info', updateMessage);
|
|
61
|
+
}
|
|
82
62
|
});
|
|
83
63
|
}
|
|
84
64
|
exports.printUpdateMessage = printUpdateMessage;
|
|
85
65
|
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
|
-
});
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
try {
|
|
68
|
+
const versionCommand = yield (0, child_process_promise_1.exec)(`npm show ${packageName} version`, { timeout: 10000 });
|
|
69
|
+
const latestVersion = versionCommand.stdout.trim();
|
|
70
|
+
return latestVersion;
|
|
71
|
+
}
|
|
72
|
+
catch (_a) {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
103
75
|
});
|
|
104
76
|
}
|
|
105
77
|
exports.getLatestVersion = getLatestVersion;
|
|
106
78
|
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
|
-
});
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
const NEW_VERSION_AVAILABLE_MESSAGE = `` +
|
|
81
|
+
chalk_1.default.bold.yellow(`New version of signageOS CLI (v${latestVersion}) Tool is available.\n`) +
|
|
82
|
+
`See changelog: https://github.com/signageos/cli/blob/master/CHANGELOG.md \n` +
|
|
83
|
+
`${chalk_1.default.bold(`Update your tool using`)} npm i ${packageName}@latest -g`;
|
|
84
|
+
const INSTALLED_UP_TO_DATE_MESSAGE = chalk_1.default.bold.green(`Your tool is up to date.`);
|
|
85
|
+
const newVersionIsAvailable = latestVersion ? semver.gt(latestVersion, installedVersion) : false;
|
|
86
|
+
const installedIsUpToDate = installedVersion === latestVersion;
|
|
87
|
+
if (newVersionIsAvailable) {
|
|
88
|
+
return NEW_VERSION_AVAILABLE_MESSAGE;
|
|
89
|
+
}
|
|
90
|
+
else if (installedIsUpToDate) {
|
|
91
|
+
return INSTALLED_UP_TO_DATE_MESSAGE;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
128
96
|
});
|
|
129
97
|
}
|
|
130
98
|
exports.getUpdateMessage = getUpdateMessage;
|
|
131
|
-
|
|
132
|
-
|
|
99
|
+
const LATEST_VERSION_CACHE_KEY = 'package.latestVersion';
|
|
100
|
+
const LATEST_VERSION_CACHE_EXPIRE_IN_MS = 60 * 60e3; // 1 hour
|
|
133
101
|
function newVersionAvailable() {
|
|
134
102
|
var _a;
|
|
135
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
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];
|
|
103
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
const packageName = (0, helper_1.getPackageName)();
|
|
105
|
+
const installedVersion = (0, helper_1.getPackageVersion)();
|
|
106
|
+
let latestVersion = (_a = (0, tmpCache_1.getCachedValue)(LATEST_VERSION_CACHE_KEY)) !== null && _a !== void 0 ? _a : undefined;
|
|
107
|
+
if (!latestVersion) {
|
|
108
|
+
latestVersion = yield getLatestVersion(packageName);
|
|
109
|
+
if (latestVersion) {
|
|
110
|
+
(0, tmpCache_1.updateCacheValue)(LATEST_VERSION_CACHE_KEY, latestVersion, { expireInMs: LATEST_VERSION_CACHE_EXPIRE_IN_MS });
|
|
152
111
|
}
|
|
153
|
-
}
|
|
112
|
+
}
|
|
113
|
+
return latestVersion ? semver.gt(latestVersion, installedVersion) : false;
|
|
154
114
|
});
|
|
155
115
|
}
|
|
156
116
|
exports.newVersionAvailable = newVersionAvailable;
|
|
157
117
|
function getUpdateVersionMessage() {
|
|
158
|
-
|
|
118
|
+
const updateVersionMessage = chalk_1.default.bold.yellow(`New version of signageOS CLI Tool is available.`);
|
|
159
119
|
return updateVersionMessage;
|
|
160
120
|
}
|
|
161
121
|
exports.getUpdateVersionMessage = getUpdateVersionMessage;
|
|
162
|
-
//# sourceMappingURL=packageVersion.js.map
|