@signageos/cli 2.9.0 → 3.0.0-rc.1
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/dist/Applet/Generate/appletGenerateCommand.js +50 -58
- package/dist/Applet/Test/Upload/appletTestRunCommand.js +2 -1
- package/dist/Applet/Test/Upload/appletTestUploadCommand.js +2 -1
- package/dist/Applet/Upload/appletUploadFacadeHelper.js +2 -1
- package/dist/Applet/appletFacade.js +4 -2
- package/dist/CustomScript/Generate/customScriptGenerateCommand.js +6 -0
- package/dist/CustomScript/customScriptFacade.d.ts +17 -1
- package/dist/CustomScript/customScriptFacade.js +16 -5
- package/dist/Device/deviceFacade.js +2 -1
- package/dist/Emulator/emulatorFacade.js +7 -1
- package/dist/Lib/fileSystem.d.ts +5 -0
- package/dist/Lib/fileSystem.js +23 -0
- package/dist/Plugin/Generate/pluginGenerateCommand.js +6 -0
- package/dist/Plugin/Upload/pluginUploadCommand.js +1 -2
- package/dist/Plugin/pluginFacade.d.ts +14 -0
- package/dist/Plugin/pluginFacade.js +25 -2
- package/dist/Runner/Generate/runnerGenerateCommand.js +6 -0
- package/dist/Runner/Upload/runnerUploadCommand.js +6 -6
- package/dist/Runner/{runnerFacede.js → runnerFacade.js} +3 -1
- package/dist/helper/paginationHelper.d.ts +7 -0
- package/dist/helper/paginationHelper.js +32 -0
- package/dist/helper.d.ts +0 -1
- package/dist/helper.js +0 -20
- package/dist/index.js +1 -2
- package/docs/applet/generate/index.md +1 -1
- package/package.json +3 -6
- package/.env +0 -3
- package/dist/Firmware/Upload/firmwareUploadCommand.d.ts +0 -90
- package/dist/Firmware/Upload/firmwareUploadCommand.js +0 -207
- package/dist/Firmware/Upload/firmwareUploadFacade.d.ts +0 -10
- package/dist/Firmware/Upload/firmwareUploadFacade.js +0 -99
- package/dist/Firmware/Upload/firmwareUploadHelper.d.ts +0 -1
- package/dist/Firmware/Upload/firmwareUploadHelper.js +0 -48
- package/dist/Firmware/firmwareCommand.d.ts +0 -76
- package/dist/Firmware/firmwareCommand.js +0 -42
- /package/dist/Runner/{runnerFacede.d.ts → runnerFacade.d.ts} +0 -0
|
@@ -49,20 +49,22 @@ exports.ConfigSchema = void 0;
|
|
|
49
49
|
exports.ensurePluginVersion = ensurePluginVersion;
|
|
50
50
|
exports.uploadCode = uploadCode;
|
|
51
51
|
exports.loadSchemas = loadSchemas;
|
|
52
|
+
exports.getSosConfig = getSosConfig;
|
|
52
53
|
const path = __importStar(require("path"));
|
|
53
54
|
const os = __importStar(require("os"));
|
|
54
55
|
const fs = __importStar(require("fs-extra"));
|
|
55
56
|
const zod_1 = __importDefault(require("zod"));
|
|
57
|
+
const fileSystem_1 = require("../Lib/fileSystem");
|
|
56
58
|
const prompts_1 = __importDefault(require("prompts"));
|
|
57
59
|
const chalk_1 = __importDefault(require("chalk"));
|
|
58
60
|
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
59
61
|
const archive_1 = require("../Lib/archive");
|
|
60
|
-
const fileSystem_1 = require("../Lib/fileSystem");
|
|
61
62
|
const runtimeFileSystem_1 = require("@signageos/sdk/dist/Development/runtimeFileSystem");
|
|
62
63
|
const customScriptFacade_1 = require("../CustomScript/customScriptFacade");
|
|
63
64
|
const PLUGIN_BUILDS_DIRNAME = 'plugin_builds';
|
|
64
65
|
function ensurePluginVersion(restApi, config, schema, skipConfirmation) {
|
|
65
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
var _a;
|
|
66
68
|
const plugin = yield ensurePlugin(restApi, config, skipConfirmation);
|
|
67
69
|
const pluginVersion = yield restApi.plugin.version.get({
|
|
68
70
|
pluginUid: plugin.uid,
|
|
@@ -91,6 +93,7 @@ function ensurePluginVersion(restApi, config, schema, skipConfirmation) {
|
|
|
91
93
|
description: config.description,
|
|
92
94
|
schema: schema.schema,
|
|
93
95
|
configDefinition: config.configDefinition,
|
|
96
|
+
jsApiVersion: (_a = config.sos) === null || _a === void 0 ? void 0 : _a['@signageos/front-applet'],
|
|
94
97
|
});
|
|
95
98
|
});
|
|
96
99
|
}
|
|
@@ -238,7 +241,7 @@ function loadSchemas(workDir) {
|
|
|
238
241
|
if (!(yield fs.pathExists(filePath))) {
|
|
239
242
|
throw new Error(`Config file schema.json not found`);
|
|
240
243
|
}
|
|
241
|
-
const fileContent = fs.
|
|
244
|
+
const fileContent = yield fs.readFile(filePath, 'utf-8');
|
|
242
245
|
return JSON.parse(fileContent);
|
|
243
246
|
});
|
|
244
247
|
}
|
|
@@ -250,6 +253,11 @@ exports.ConfigSchema = zod_1.default.object({
|
|
|
250
253
|
name: zod_1.default.string(),
|
|
251
254
|
version: zod_1.default.string(),
|
|
252
255
|
description: zod_1.default.string().optional(),
|
|
256
|
+
sos: zod_1.default
|
|
257
|
+
.object({
|
|
258
|
+
'@signageos/front-applet': zod_1.default.string().optional(),
|
|
259
|
+
})
|
|
260
|
+
.optional(),
|
|
253
261
|
/**
|
|
254
262
|
* Config of individual plugin script implementations for each target platform.
|
|
255
263
|
*
|
|
@@ -259,3 +267,18 @@ exports.ConfigSchema = zod_1.default.object({
|
|
|
259
267
|
platforms: zod_1.default.record(zod_1.default.string(), customScriptFacade_1.PlatformSchema),
|
|
260
268
|
configDefinition: zod_1.default.array(zod_1.default.object({}).passthrough()), // outsource validation to API because it's a bit complex
|
|
261
269
|
});
|
|
270
|
+
function getSosConfig(workDir) {
|
|
271
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
272
|
+
const filePath = path.join(workDir, fileSystem_1.SOS_CONFIG_FILE_NAME);
|
|
273
|
+
if (!(yield fs.pathExists(filePath))) {
|
|
274
|
+
throw new Error(`Config file ${fileSystem_1.SOS_CONFIG_FILE_NAME} not found`);
|
|
275
|
+
}
|
|
276
|
+
const fileContent = yield fs.readFile(filePath, 'utf-8');
|
|
277
|
+
try {
|
|
278
|
+
return exports.ConfigSchema.parse(JSON.parse(fileContent));
|
|
279
|
+
}
|
|
280
|
+
catch (error) {
|
|
281
|
+
throw new Error(`Invalid JSON in ${fileSystem_1.SOS_CONFIG_FILE_NAME}: ${error instanceof Error ? error.message : String(error)}`);
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
}
|
|
@@ -19,7 +19,9 @@ const commandDefinition_1 = require("../../Command/commandDefinition");
|
|
|
19
19
|
const git_1 = require("../../Lib/git");
|
|
20
20
|
const customScriptFacade_1 = require("../../CustomScript/customScriptFacade");
|
|
21
21
|
const runnerGenerateFacade_1 = require("./runnerGenerateFacade");
|
|
22
|
+
const fileSystem_1 = require("../../Lib/fileSystem");
|
|
22
23
|
const runnerGenerateOptions_1 = require("./runnerGenerateOptions");
|
|
24
|
+
const packageVersion_1 = require("../../Cli/packageVersion");
|
|
23
25
|
/**
|
|
24
26
|
* Generates a local repository for developing a Runner with boilerplate code and configuration files.
|
|
25
27
|
* Sets up complete development environment with necessary dependencies and project structure.
|
|
@@ -52,6 +54,10 @@ exports.runnerGenerate = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
52
54
|
const { targetDir, name, description } = yield (0, runnerGenerateFacade_1.askForParameters)(options, skipConfirmation);
|
|
53
55
|
yield (0, runnerGenerateFacade_1.downloadBoilerplateCode)(targetDir);
|
|
54
56
|
yield (0, customScriptFacade_1.addToConfigFile)(targetDir, { name, description });
|
|
57
|
+
const frontAppletVersion = yield (0, packageVersion_1.getLatestVersion)('@signageos/front-applet');
|
|
58
|
+
if (frontAppletVersion) {
|
|
59
|
+
yield (0, fileSystem_1.addFrontAppletVersionToConfigFile)(targetDir, frontAppletVersion);
|
|
60
|
+
}
|
|
55
61
|
(0, log_1.log)('info', `Runner ${chalk_1.default.green(name)} has been generated in ${chalk_1.default.green(targetDir)}.`);
|
|
56
62
|
(0, log_1.log)('info', 'Next steps:');
|
|
57
63
|
(0, log_1.log)('info', ` - Open the folder ${chalk_1.default.green(targetDir)} and read the ${chalk_1.default.green('README.md')} file.`);
|
|
@@ -20,8 +20,8 @@ const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
|
20
20
|
const commandDefinition_1 = require("../../Command/commandDefinition");
|
|
21
21
|
const helper_1 = require("../../helper");
|
|
22
22
|
const organizationFacade_1 = require("../../Organization/organizationFacade");
|
|
23
|
-
const
|
|
24
|
-
const
|
|
23
|
+
const runnerFacade_1 = require("../runnerFacade");
|
|
24
|
+
const pluginFacade_1 = require("../../Plugin/pluginFacade");
|
|
25
25
|
const Debug = (0, debug_1.default)('@signageos/cli:Runner:Upload:Command');
|
|
26
26
|
exports.OPTION_LIST = [
|
|
27
27
|
organizationFacade_1.NO_DEFAULT_ORGANIZATION_OPTION,
|
|
@@ -64,17 +64,17 @@ exports.runnerUpload = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
64
64
|
const organizationUid = yield (0, organizationFacade_1.getOrganizationUidOrDefaultOrSelect)(options, skipPrompts);
|
|
65
65
|
const organization = yield (0, organizationFacade_1.getOrganization)(organizationUid);
|
|
66
66
|
const restApi = yield (0, helper_1.createOrganizationRestApi)(organization);
|
|
67
|
-
const config = yield (0,
|
|
68
|
-
const schema = yield (0,
|
|
67
|
+
const config = yield (0, pluginFacade_1.getSosConfig)(currentDirectory);
|
|
68
|
+
const schema = yield (0, runnerFacade_1.loadSchemas)(currentDirectory);
|
|
69
69
|
const skipConfirmation = !!options.yes;
|
|
70
|
-
const runnerVersion = yield (0,
|
|
70
|
+
const runnerVersion = yield (0, runnerFacade_1.ensureRunnerVersion)(restApi, config, schema, skipConfirmation);
|
|
71
71
|
for (const platform of Object.keys(config.platforms)) {
|
|
72
72
|
const platformConfig = config.platforms[platform];
|
|
73
73
|
if (!platformConfig) {
|
|
74
74
|
console.warn(`Skipping platform ${platform} due to missing configuration`);
|
|
75
75
|
continue;
|
|
76
76
|
}
|
|
77
|
-
yield (0,
|
|
77
|
+
yield (0, runnerFacade_1.uploadCode)({
|
|
78
78
|
restApi,
|
|
79
79
|
workDir: currentDirectory,
|
|
80
80
|
platform,
|
|
@@ -61,6 +61,7 @@ const customScriptFacade_1 = require("../CustomScript/customScriptFacade");
|
|
|
61
61
|
const PLUGIN_BUILDS_DIRNAME = 'plugin_builds';
|
|
62
62
|
function ensureRunnerVersion(restApi, config, schema, skipConfirmation) {
|
|
63
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
var _a;
|
|
64
65
|
const runner = yield ensureRunner(restApi, config, skipConfirmation);
|
|
65
66
|
const runnerVersion = yield restApi.runner.version.get({ runnerUid: runner.uid, version: config.version });
|
|
66
67
|
if (runnerVersion) {
|
|
@@ -88,6 +89,7 @@ function ensureRunnerVersion(restApi, config, schema, skipConfirmation) {
|
|
|
88
89
|
output: schema.output,
|
|
89
90
|
telemetry: schema.telemetry,
|
|
90
91
|
configDefinition: config.configDefinition,
|
|
92
|
+
jsApiVersion: (_a = config.sos) === null || _a === void 0 ? void 0 : _a['@signageos/front-applet'],
|
|
91
93
|
});
|
|
92
94
|
});
|
|
93
95
|
}
|
|
@@ -235,7 +237,7 @@ function loadSchemas(workDir) {
|
|
|
235
237
|
if (!(yield fs.pathExists(filePath))) {
|
|
236
238
|
throw new Error(`Config file schema.json not found`);
|
|
237
239
|
}
|
|
238
|
-
const fileContent = fs.
|
|
240
|
+
const fileContent = yield fs.readFile(filePath, 'utf-8');
|
|
239
241
|
return JSON.parse(fileContent);
|
|
240
242
|
});
|
|
241
243
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IPaginatedList } from '@signageos/sdk';
|
|
2
|
+
/**
|
|
3
|
+
* Fetches all pages from a paginated list.
|
|
4
|
+
* @param firstPage The first page returned from a list() method
|
|
5
|
+
* @returns Array containing all items from all pages
|
|
6
|
+
*/
|
|
7
|
+
export declare function getAllPages<T>(firstPage: IPaginatedList<T>): Promise<T[]>;
|
|
@@ -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.getAllPages = getAllPages;
|
|
13
|
+
/**
|
|
14
|
+
* Fetches all pages from a paginated list.
|
|
15
|
+
* @param firstPage The first page returned from a list() method
|
|
16
|
+
* @returns Array containing all items from all pages
|
|
17
|
+
*/
|
|
18
|
+
function getAllPages(firstPage) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const allItems = [...firstPage];
|
|
21
|
+
let currentPage = firstPage;
|
|
22
|
+
while (true) {
|
|
23
|
+
const nextPage = yield currentPage.getNextPage();
|
|
24
|
+
if (!nextPage) {
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
allItems.push(...nextPage);
|
|
28
|
+
currentPage = nextPage;
|
|
29
|
+
}
|
|
30
|
+
return allItems;
|
|
31
|
+
});
|
|
32
|
+
}
|
package/dist/helper.d.ts
CHANGED
|
@@ -13,7 +13,6 @@ export declare function createClientVersions(): {
|
|
|
13
13
|
signageOS_CLI: any;
|
|
14
14
|
};
|
|
15
15
|
export declare function createOrganizationRestApi(credentials: ICredentials): Promise<RestApi>;
|
|
16
|
-
export declare function createFirmwareVersionRestApi(): Promise<RestApi>;
|
|
17
16
|
export declare const AUTH_HEADER = "X-Auth";
|
|
18
17
|
export interface IOptions {
|
|
19
18
|
url: string;
|
package/dist/helper.js
CHANGED
|
@@ -17,7 +17,6 @@ exports.loadApiUrl = loadApiUrl;
|
|
|
17
17
|
exports.getApiUrl = getApiUrl;
|
|
18
18
|
exports.createClientVersions = createClientVersions;
|
|
19
19
|
exports.createOrganizationRestApi = createOrganizationRestApi;
|
|
20
|
-
exports.createFirmwareVersionRestApi = createFirmwareVersionRestApi;
|
|
21
20
|
exports.createOptions = createOptions;
|
|
22
21
|
exports.createUri = createUri;
|
|
23
22
|
exports.getResource = getResource;
|
|
@@ -73,25 +72,6 @@ function createOrganizationRestApi(credentials) {
|
|
|
73
72
|
return new RestApi_1.default(options, accountOptions);
|
|
74
73
|
});
|
|
75
74
|
}
|
|
76
|
-
function createFirmwareVersionRestApi() {
|
|
77
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
const config = yield (0, runControlHelper_1.loadConfig)();
|
|
79
|
-
if (!config.identification || !config.apiSecurityToken) {
|
|
80
|
-
throw new Error('Identification or token is missing.');
|
|
81
|
-
}
|
|
82
|
-
const options = {
|
|
83
|
-
url: getApiUrl(config),
|
|
84
|
-
auth: {
|
|
85
|
-
clientId: config.identification,
|
|
86
|
-
secret: config.apiSecurityToken,
|
|
87
|
-
},
|
|
88
|
-
version: apiVersions_1.ApiVersions.V1,
|
|
89
|
-
clientVersions: createClientVersions(),
|
|
90
|
-
};
|
|
91
|
-
const accountOptions = Object.assign({}, options);
|
|
92
|
-
return new RestApi_1.default(options, accountOptions);
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
75
|
exports.AUTH_HEADER = 'X-Auth';
|
|
96
76
|
function createOptions(method, options, data) {
|
|
97
77
|
return {
|
package/dist/index.js
CHANGED
|
@@ -15,7 +15,6 @@ const loginCommand_1 = require("./Auth/loginCommand");
|
|
|
15
15
|
const organizationCommand_1 = require("./Organization/organizationCommand");
|
|
16
16
|
const timingCommand_1 = require("./Timing/timingCommand");
|
|
17
17
|
const commandProcessor_1 = require("./Command/commandProcessor");
|
|
18
|
-
const firmwareCommand_1 = require("./Firmware/firmwareCommand");
|
|
19
18
|
const deviceCommand_1 = require("./Device/deviceCommand");
|
|
20
19
|
const generalCommand_1 = require("./generalCommand");
|
|
21
20
|
const commandDefinition_1 = require("./Command/commandDefinition");
|
|
@@ -49,7 +48,7 @@ const index = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
49
48
|
name: 'sos',
|
|
50
49
|
description: 'SignageOS CLI - The central command-line tool for deploying, managing, and debugging signageOS projects and devices',
|
|
51
50
|
optionList: generalCommand_1.GENERAL_OPTION_LIST,
|
|
52
|
-
commands: [appletCommand_1.applet, loginCommand_1.login, organizationCommand_1.organization, timingCommand_1.timing,
|
|
51
|
+
commands: [appletCommand_1.applet, loginCommand_1.login, organizationCommand_1.organization, timingCommand_1.timing, deviceCommand_1.device, customScriptCommand_1.customScript, pluginCommand_1.plugin, runnerCommand_1.runner, autocompleteCommand_1.autocomplete],
|
|
53
52
|
run() {
|
|
54
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
54
|
throw new Error('Unknown command');
|
|
@@ -25,7 +25,7 @@ sos applet generate [options]
|
|
|
25
25
|
|
|
26
26
|
| Option | Description | Default |
|
|
27
27
|
| ------------------ | ------------------------------------------------------------------------------- | ------- |
|
|
28
|
-
| `--name` |
|
|
28
|
+
| `--name` | (string) | |
|
|
29
29
|
| `--applet-version` | Applet initial version. Use semantic version (string) | `0.0.0` |
|
|
30
30
|
| `--target-dir` | Directory where will be the applet generated to (string) | |
|
|
31
31
|
| `--git` | Init applet as git repository "no" (default) or "yes" (string) | |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signageos/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-rc.1",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"author": "signageOS.io <dev@signageos.io>",
|
|
6
6
|
"files": [
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"lint:prettier": "prettier \"(src|tests|tools)/**/*.+(ts|tsx|json|js)\" --check",
|
|
27
27
|
"lint:prettier:fix": "prettier \"(src|tests|tools)/**/*.+(ts|tsx|json|js)\" --write",
|
|
28
28
|
"test": "npm run test:unit && npm run test:integration",
|
|
29
|
+
"test:all": "npm run test:unit",
|
|
29
30
|
"test:coverage": "c8 npm run test:all",
|
|
30
31
|
"test:unit": "env NODE_ENV=test mocha",
|
|
31
32
|
"test:unit:windows": "cross-env NODE_ENV=test mocha",
|
|
@@ -85,7 +86,7 @@
|
|
|
85
86
|
},
|
|
86
87
|
"dependencies": {
|
|
87
88
|
"@signageos/file": "2.0.1",
|
|
88
|
-
"@signageos/sdk": "2.
|
|
89
|
+
"@signageos/sdk": "2.5.0",
|
|
89
90
|
"archiver": "7.0.1",
|
|
90
91
|
"chalk": "2.4.2",
|
|
91
92
|
"child-process-promise": "2.1.3",
|
|
@@ -105,9 +106,5 @@
|
|
|
105
106
|
"serve-static": "2.2.0",
|
|
106
107
|
"which": "5.0.0",
|
|
107
108
|
"zod": "3.24.4"
|
|
108
|
-
},
|
|
109
|
-
"publishConfig": {
|
|
110
|
-
"registry": "https://registry.npmjs.org/",
|
|
111
|
-
"access": "public"
|
|
112
109
|
}
|
|
113
110
|
}
|
package/.env
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { CommandLineOptions } from '../../Command/commandDefinition';
|
|
2
|
-
declare const OPTION_LIST: readonly [{
|
|
3
|
-
readonly name: "application-type";
|
|
4
|
-
readonly alias: "a";
|
|
5
|
-
readonly type: StringConstructor;
|
|
6
|
-
readonly description: "Application type for the firmware (e.g., linux, android, webos)";
|
|
7
|
-
}, {
|
|
8
|
-
readonly name: "firmware-version";
|
|
9
|
-
readonly alias: "f";
|
|
10
|
-
readonly type: StringConstructor;
|
|
11
|
-
readonly description: "Version identifier for the firmware package";
|
|
12
|
-
}, {
|
|
13
|
-
readonly name: "firmware-type";
|
|
14
|
-
readonly type: StringConstructor;
|
|
15
|
-
readonly description: "Device model prefixed with brand (e.g., \"benq_sl550\", \"rpi4\", \"rpi\")";
|
|
16
|
-
}, {
|
|
17
|
-
readonly name: "src";
|
|
18
|
-
readonly type: StringConstructor;
|
|
19
|
-
readonly multiple: true;
|
|
20
|
-
readonly description: "Path(s) to firmware file(s) to upload";
|
|
21
|
-
}, {
|
|
22
|
-
readonly name: "force";
|
|
23
|
-
readonly type: BooleanConstructor;
|
|
24
|
-
readonly description: "When firmware cannot be uploaded due to invalid firmware \"type\", do it anyways.";
|
|
25
|
-
}];
|
|
26
|
-
/**
|
|
27
|
-
* Uploads firmware files for specific device types and application platforms.
|
|
28
|
-
* Supports various device architectures including Linux, Android, WebOS, and others.
|
|
29
|
-
* The command validates firmware files and creates versioned firmware packages
|
|
30
|
-
* that can be deployed to compatible devices.
|
|
31
|
-
*
|
|
32
|
-
* @group Private
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```bash
|
|
36
|
-
* # Upload firmware interactively
|
|
37
|
-
* sos firmware upload
|
|
38
|
-
*
|
|
39
|
-
* # Upload firmware with command line options
|
|
40
|
-
* sos firmware upload --application-type linux --firmware-version 1.2.3 --src /path/to/firmware.tar.gz
|
|
41
|
-
*
|
|
42
|
-
* # Upload Android firmware with type specification
|
|
43
|
-
* sos firmware upload --application-type android --firmware-type rpi4 --firmware-version 1.0.0 --src /path/to/firmware.apk
|
|
44
|
-
*
|
|
45
|
-
* # Force upload when type validation fails
|
|
46
|
-
* sos firmware upload --application-type linux --firmware-type custom_device --firmware-version 1.0.0 --src /path/to/firmware.tar.gz --force
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* @throws {Error} When required parameters are missing
|
|
50
|
-
* @throws {Error} When firmware files cannot be found or validated
|
|
51
|
-
* @throws {RequestError} When firmware type is invalid for the platform
|
|
52
|
-
* @throws {Error} When upload confirmation is denied
|
|
53
|
-
*
|
|
54
|
-
* @see {@link ../ Firmware upload command}
|
|
55
|
-
*
|
|
56
|
-
* @see {@link ../../ Firmware management commands}
|
|
57
|
-
*
|
|
58
|
-
* @since 0.6.0
|
|
59
|
-
*/
|
|
60
|
-
export declare const firmwareUpload: {
|
|
61
|
-
name: "upload";
|
|
62
|
-
description: string;
|
|
63
|
-
optionList: readonly [{
|
|
64
|
-
readonly name: "application-type";
|
|
65
|
-
readonly alias: "a";
|
|
66
|
-
readonly type: StringConstructor;
|
|
67
|
-
readonly description: "Application type for the firmware (e.g., linux, android, webos)";
|
|
68
|
-
}, {
|
|
69
|
-
readonly name: "firmware-version";
|
|
70
|
-
readonly alias: "f";
|
|
71
|
-
readonly type: StringConstructor;
|
|
72
|
-
readonly description: "Version identifier for the firmware package";
|
|
73
|
-
}, {
|
|
74
|
-
readonly name: "firmware-type";
|
|
75
|
-
readonly type: StringConstructor;
|
|
76
|
-
readonly description: "Device model prefixed with brand (e.g., \"benq_sl550\", \"rpi4\", \"rpi\")";
|
|
77
|
-
}, {
|
|
78
|
-
readonly name: "src";
|
|
79
|
-
readonly type: StringConstructor;
|
|
80
|
-
readonly multiple: true;
|
|
81
|
-
readonly description: "Path(s) to firmware file(s) to upload";
|
|
82
|
-
}, {
|
|
83
|
-
readonly name: "force";
|
|
84
|
-
readonly type: BooleanConstructor;
|
|
85
|
-
readonly description: "When firmware cannot be uploaded due to invalid firmware \"type\", do it anyways.";
|
|
86
|
-
}];
|
|
87
|
-
commands: never[];
|
|
88
|
-
run(options: CommandLineOptions<typeof OPTION_LIST>): Promise<void>;
|
|
89
|
-
};
|
|
90
|
-
export {};
|
|
@@ -1,207 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.firmwareUpload = void 0;
|
|
16
|
-
const helper_1 = require("../../helper");
|
|
17
|
-
const prompts_1 = __importDefault(require("prompts"));
|
|
18
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
19
|
-
const firmwareUploadFacade_1 = require("./firmwareUploadFacade");
|
|
20
|
-
const progressBarFactory_1 = require("../../CommandLine/progressBarFactory");
|
|
21
|
-
const firmwareUploadHelper_1 = __importDefault(require("./firmwareUploadHelper"));
|
|
22
|
-
const RequestError_1 = __importDefault(require("@signageos/sdk/dist/RestApi/Error/RequestError"));
|
|
23
|
-
const commandDefinition_1 = require("../../Command/commandDefinition");
|
|
24
|
-
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
25
|
-
const questions = [
|
|
26
|
-
{
|
|
27
|
-
type: 'text',
|
|
28
|
-
name: 'applicationType',
|
|
29
|
-
message: `Application type`,
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
type: 'text',
|
|
33
|
-
name: 'version',
|
|
34
|
-
message: `Firmware version`,
|
|
35
|
-
},
|
|
36
|
-
];
|
|
37
|
-
const fwTypeQuestion = [
|
|
38
|
-
{
|
|
39
|
-
type: 'text',
|
|
40
|
-
name: 'firmwareType',
|
|
41
|
-
message: `Model prefixed with brand. E.g.: "benq_sl550", "rpi4", "rpi"`,
|
|
42
|
-
},
|
|
43
|
-
];
|
|
44
|
-
const applicationTypesRequiringType = ['linux', 'android'];
|
|
45
|
-
const OPTION_LIST = [
|
|
46
|
-
{ name: 'application-type', alias: 'a', type: String, description: 'Application type for the firmware (e.g., linux, android, webos)' },
|
|
47
|
-
{ name: 'firmware-version', alias: 'f', type: String, description: 'Version identifier for the firmware package' },
|
|
48
|
-
{ name: 'firmware-type', type: String, description: 'Device model prefixed with brand (e.g., "benq_sl550", "rpi4", "rpi")' },
|
|
49
|
-
{ name: 'src', type: String, multiple: true, description: 'Path(s) to firmware file(s) to upload' },
|
|
50
|
-
{ name: 'force', type: Boolean, description: 'When firmware cannot be uploaded due to invalid firmware "type", do it anyways.' },
|
|
51
|
-
];
|
|
52
|
-
/**
|
|
53
|
-
* Uploads firmware files for specific device types and application platforms.
|
|
54
|
-
* Supports various device architectures including Linux, Android, WebOS, and others.
|
|
55
|
-
* The command validates firmware files and creates versioned firmware packages
|
|
56
|
-
* that can be deployed to compatible devices.
|
|
57
|
-
*
|
|
58
|
-
* @group Private
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
* ```bash
|
|
62
|
-
* # Upload firmware interactively
|
|
63
|
-
* sos firmware upload
|
|
64
|
-
*
|
|
65
|
-
* # Upload firmware with command line options
|
|
66
|
-
* sos firmware upload --application-type linux --firmware-version 1.2.3 --src /path/to/firmware.tar.gz
|
|
67
|
-
*
|
|
68
|
-
* # Upload Android firmware with type specification
|
|
69
|
-
* sos firmware upload --application-type android --firmware-type rpi4 --firmware-version 1.0.0 --src /path/to/firmware.apk
|
|
70
|
-
*
|
|
71
|
-
* # Force upload when type validation fails
|
|
72
|
-
* sos firmware upload --application-type linux --firmware-type custom_device --firmware-version 1.0.0 --src /path/to/firmware.tar.gz --force
|
|
73
|
-
* ```
|
|
74
|
-
*
|
|
75
|
-
* @throws {Error} When required parameters are missing
|
|
76
|
-
* @throws {Error} When firmware files cannot be found or validated
|
|
77
|
-
* @throws {RequestError} When firmware type is invalid for the platform
|
|
78
|
-
* @throws {Error} When upload confirmation is denied
|
|
79
|
-
*
|
|
80
|
-
* @see {@link ../ Firmware upload command}
|
|
81
|
-
*
|
|
82
|
-
* @see {@link ../../ Firmware management commands}
|
|
83
|
-
*
|
|
84
|
-
* @since 0.6.0
|
|
85
|
-
*/
|
|
86
|
-
exports.firmwareUpload = (0, commandDefinition_1.createCommandDefinition)({
|
|
87
|
-
name: 'upload',
|
|
88
|
-
description: 'Upload firmware version to the signageOS platform',
|
|
89
|
-
optionList: OPTION_LIST,
|
|
90
|
-
commands: [],
|
|
91
|
-
run(options) {
|
|
92
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
const optionsProvided = !!(options['application-type'] && options['firmware-version'] && options.src && options.src.length > 0);
|
|
94
|
-
const restApi = yield (0, helper_1.createFirmwareVersionRestApi)();
|
|
95
|
-
const data = {
|
|
96
|
-
applicationType: '',
|
|
97
|
-
version: '',
|
|
98
|
-
files: [],
|
|
99
|
-
};
|
|
100
|
-
const pathSet = new Set();
|
|
101
|
-
if (!optionsProvided) {
|
|
102
|
-
const answers = yield (0, prompts_1.default)(questions);
|
|
103
|
-
data.applicationType = answers.applicationType;
|
|
104
|
-
data.version = answers.version;
|
|
105
|
-
if (applicationTypesRequiringType.includes(data.applicationType)) {
|
|
106
|
-
const typeAnswers = yield (0, prompts_1.default)(fwTypeQuestion);
|
|
107
|
-
data.type = typeAnswers.firmwareType;
|
|
108
|
-
if (!data.type) {
|
|
109
|
-
(0, log_1.log)('error', `You must input firmware type`);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (!data.applicationType || !data.version) {
|
|
114
|
-
(0, log_1.log)('error', `You must input application type and version`);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
while (true) {
|
|
118
|
-
// ask for files
|
|
119
|
-
const answer = yield (0, prompts_1.default)({
|
|
120
|
-
type: 'text',
|
|
121
|
-
name: 'fileFsPath',
|
|
122
|
-
message: 'Absolute path to the file, type `stop` to stop.',
|
|
123
|
-
});
|
|
124
|
-
if (answer.fileFsPath === undefined || answer.fileFsPath === 'stop') {
|
|
125
|
-
// EOF or stop
|
|
126
|
-
break;
|
|
127
|
-
}
|
|
128
|
-
const path = answer.fileFsPath;
|
|
129
|
-
try {
|
|
130
|
-
(0, firmwareUploadHelper_1.default)(path);
|
|
131
|
-
pathSet.add(path);
|
|
132
|
-
(0, log_1.log)('info', `${chalk_1.default.green('File added to upload list')}`);
|
|
133
|
-
}
|
|
134
|
-
catch (e) {
|
|
135
|
-
(0, log_1.log)('error', e.message);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
if (pathSet.size > 0) {
|
|
139
|
-
(0, log_1.log)('info', 'Application type: ', chalk_1.default.green(data.applicationType));
|
|
140
|
-
(0, log_1.log)('info', 'Version: ', chalk_1.default.green(data.version));
|
|
141
|
-
if (data.type) {
|
|
142
|
-
(0, log_1.log)('info', 'Firmware type: ', chalk_1.default.green(data.type));
|
|
143
|
-
}
|
|
144
|
-
(0, log_1.log)('info', 'List of files: ', ...Array.from(pathSet));
|
|
145
|
-
const confirmation = yield (0, prompts_1.default)({
|
|
146
|
-
type: 'confirm',
|
|
147
|
-
name: 'confirmed',
|
|
148
|
-
message: 'Is this ok?',
|
|
149
|
-
});
|
|
150
|
-
if (!confirmation.confirmed) {
|
|
151
|
-
throw new Error(`You must confirm your action.`);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
// data is given cli args
|
|
157
|
-
if (!options['application-type']) {
|
|
158
|
-
throw new Error('Argument --application-type is required');
|
|
159
|
-
}
|
|
160
|
-
if (!options['firmware-version']) {
|
|
161
|
-
throw new Error('Argument --firmware-version is required');
|
|
162
|
-
}
|
|
163
|
-
data.applicationType = options['application-type'];
|
|
164
|
-
data.version = options['firmware-version'];
|
|
165
|
-
if (applicationTypesRequiringType.includes(data.applicationType) && !options['firmware-type']) {
|
|
166
|
-
(0, log_1.log)('error', 'You must input firmware type');
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
data.type = options['firmware-type'];
|
|
170
|
-
const pathArr = options.src;
|
|
171
|
-
pathArr === null || pathArr === void 0 ? void 0 : pathArr.forEach((path) => {
|
|
172
|
-
(0, firmwareUploadHelper_1.default)(path);
|
|
173
|
-
pathSet.add(path);
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
yield (0, firmwareUploadFacade_1.uploadFirmwareVersion)({
|
|
177
|
-
restApi,
|
|
178
|
-
firmware: data,
|
|
179
|
-
pathArr: Array.from(pathSet),
|
|
180
|
-
progressBar: (0, progressBarFactory_1.createProgressBar)(),
|
|
181
|
-
}).catch((error) => __awaiter(this, void 0, void 0, function* () {
|
|
182
|
-
if (error instanceof RequestError_1.default && error.errorName === 'INVALID_TYPE_TO_FIRMWARE_VERSION_UPLOAD') {
|
|
183
|
-
const promptOverride = () => (0, prompts_1.default)({
|
|
184
|
-
type: 'confirm',
|
|
185
|
-
name: 'confirmed',
|
|
186
|
-
message: `A firmware "type=${data.type}" field is not valid because doesn't exist any device with this type ` +
|
|
187
|
-
`thus firmware version not to be uploaded. ` +
|
|
188
|
-
`If you are sure that "type=${data.type}" you've specified is valid, ` +
|
|
189
|
-
`you can override it confirming this question or using --force flag.`,
|
|
190
|
-
});
|
|
191
|
-
if (options.force || (!optionsProvided && (yield promptOverride()).confirmed)) {
|
|
192
|
-
yield (0, firmwareUploadFacade_1.uploadFirmwareVersion)({
|
|
193
|
-
restApi,
|
|
194
|
-
firmware: data,
|
|
195
|
-
pathArr: Array.from(pathSet),
|
|
196
|
-
progressBar: (0, progressBarFactory_1.createProgressBar)(),
|
|
197
|
-
force: true,
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
throw error;
|
|
203
|
-
}
|
|
204
|
-
}));
|
|
205
|
-
});
|
|
206
|
-
},
|
|
207
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import RestApi from '@signageos/sdk/dist/RestApi/RestApi';
|
|
2
|
-
import { ProgressBar } from '../../CommandLine/IProgressBar';
|
|
3
|
-
import { IFirmwareVersionCreatable } from '@signageos/sdk/dist/RestApi/Firmware/Version/IFirmwareVersion';
|
|
4
|
-
export declare function uploadFirmwareVersion(parameters: {
|
|
5
|
-
restApi: RestApi;
|
|
6
|
-
firmware: IFirmwareVersionCreatable;
|
|
7
|
-
pathArr: Array<string>;
|
|
8
|
-
progressBar?: ProgressBar;
|
|
9
|
-
force?: boolean;
|
|
10
|
-
}): Promise<void>;
|