@signageos/cli 2.9.0 → 3.0.0-rc.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/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/Device/deviceFacade.js +2 -1
- package/dist/Emulator/emulatorFacade.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
|
@@ -47,9 +47,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
48
|
exports.appletGenerate = void 0;
|
|
49
49
|
const fs = __importStar(require("fs-extra"));
|
|
50
|
-
const child_process = __importStar(require("child_process"));
|
|
50
|
+
const child_process = __importStar(require("node:child_process"));
|
|
51
51
|
const chalk_1 = __importDefault(require("chalk"));
|
|
52
|
-
const path = __importStar(require("path"));
|
|
52
|
+
const path = __importStar(require("node:path"));
|
|
53
53
|
const prompts_1 = __importDefault(require("prompts"));
|
|
54
54
|
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
55
55
|
const git_1 = require("../../Lib/git");
|
|
@@ -80,7 +80,7 @@ var Packager;
|
|
|
80
80
|
const NAME_REGEXP = /^\w(\w|\d|-)*\w$/;
|
|
81
81
|
let PACKAGER_EXECUTABLE = 'npm';
|
|
82
82
|
const OPTION_LIST = [
|
|
83
|
-
{ name: 'name', type: String, description: `Applet name. Match RegExp:
|
|
83
|
+
{ name: 'name', type: String, description: String.raw `Applet name. Match RegExp: /^\w(\w|\d|-)*\w$/` },
|
|
84
84
|
{ name: 'applet-version', type: String, description: 'Applet initial version. Use semantic version', defaultValue: '0.0.0' },
|
|
85
85
|
{ name: 'target-dir', type: String, description: 'Directory where will be the applet generated to' },
|
|
86
86
|
{ name: 'git', type: String, description: 'Init applet as git repository "no" (default) or "yes"' },
|
|
@@ -122,7 +122,7 @@ const RUNSCRIPTS = {
|
|
|
122
122
|
webpack: {
|
|
123
123
|
start: 'webpack serve --mode development',
|
|
124
124
|
build: 'webpack --mode production',
|
|
125
|
-
connect:
|
|
125
|
+
connect: String.raw `echo "Deprecated command \"npm run connect\". Use \"npm run watch\" instead." && npm run watch`,
|
|
126
126
|
watch: 'webpack --watch',
|
|
127
127
|
},
|
|
128
128
|
rspack: {
|
|
@@ -180,9 +180,9 @@ exports.appletGenerate = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
180
180
|
return __awaiter(this, void 0, void 0, function* () {
|
|
181
181
|
const currentDirectory = process.cwd();
|
|
182
182
|
// Detect if the command has been called with optional parameters
|
|
183
|
-
const excludedKeys = ['command', 'applet-version'];
|
|
183
|
+
const excludedKeys = new Set(['command', 'applet-version']);
|
|
184
184
|
const argumentsFound = Object.entries(options)
|
|
185
|
-
.filter(([key]) => !excludedKeys.
|
|
185
|
+
.filter(([key]) => !excludedKeys.has(key))
|
|
186
186
|
.map(([key, value]) => ({ [key]: value })).length > 0;
|
|
187
187
|
console.info('sOS CLI started with params:', options);
|
|
188
188
|
// Create file index
|
|
@@ -303,8 +303,8 @@ exports.appletGenerate = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
303
303
|
RUNSCRIPTS.common = {
|
|
304
304
|
prepare: 'pnpm run clean && pnpm run build',
|
|
305
305
|
upload: 'sos applet upload',
|
|
306
|
-
clean: '
|
|
307
|
-
escheck: '
|
|
306
|
+
clean: 'npx rimraf dist',
|
|
307
|
+
escheck: 'pnpm es-check --module es5 "./dist/**/*.js"',
|
|
308
308
|
postbuild: 'pnpm run escheck',
|
|
309
309
|
};
|
|
310
310
|
break;
|
|
@@ -339,8 +339,7 @@ exports.appletGenerate = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
339
339
|
generateFiles.push({
|
|
340
340
|
path: path.join(appletRootDirectory, 'src', 'index.ts'),
|
|
341
341
|
content: createIndexTs(),
|
|
342
|
-
}
|
|
343
|
-
generateFiles.push({
|
|
342
|
+
}, {
|
|
344
343
|
path: path.join(appletRootDirectory, 'tsconfig.json'),
|
|
345
344
|
content: createTsConfig(),
|
|
346
345
|
});
|
|
@@ -359,12 +358,10 @@ exports.appletGenerate = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
359
358
|
}
|
|
360
359
|
// Create styles
|
|
361
360
|
// TODO sass support
|
|
362
|
-
{
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
});
|
|
367
|
-
}
|
|
361
|
+
generateFiles.push({
|
|
362
|
+
path: path.join(appletRootDirectory, 'src', 'index.css'),
|
|
363
|
+
content: createIndexCss(),
|
|
364
|
+
});
|
|
368
365
|
// Create custom npm registry config
|
|
369
366
|
if (typeof options['npm-registry'] === 'string') {
|
|
370
367
|
generateFiles.push({
|
|
@@ -379,12 +376,10 @@ exports.appletGenerate = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
379
376
|
generateFiles.push({
|
|
380
377
|
path: path.join(appletRootDirectory, 'package.json'),
|
|
381
378
|
content: JSON.stringify(yield createPackageConfig(appletName, String(options['applet-version']), bundler, language), undefined, 2) + '\n',
|
|
382
|
-
}
|
|
383
|
-
generateFiles.push({
|
|
379
|
+
}, {
|
|
384
380
|
path: path.join(appletRootDirectory, 'CHANGELOG.md'),
|
|
385
381
|
content: createChangelogFile(),
|
|
386
|
-
}
|
|
387
|
-
generateFiles.push({
|
|
382
|
+
}, {
|
|
388
383
|
path: path.join(appletRootDirectory, 'README.md'),
|
|
389
384
|
content: createReadmeFile(),
|
|
390
385
|
});
|
|
@@ -408,12 +403,10 @@ exports.appletGenerate = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
408
403
|
generateFiles.push({
|
|
409
404
|
path: path.join(appletRootDirectory, 'public', 'index.html'),
|
|
410
405
|
content: createIndexHtml(appletName),
|
|
411
|
-
}
|
|
412
|
-
generateFiles.push({
|
|
406
|
+
}, {
|
|
413
407
|
path: path.join(appletRootDirectory, '.sosignore'),
|
|
414
408
|
content: 'node_modules/\n',
|
|
415
|
-
}
|
|
416
|
-
generateFiles.push({
|
|
409
|
+
}, {
|
|
417
410
|
path: path.join(appletRootDirectory, 'sos.config.local.json'),
|
|
418
411
|
content: '{}\n',
|
|
419
412
|
});
|
|
@@ -439,29 +432,18 @@ exports.appletGenerate = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
439
432
|
if (packagerFound) {
|
|
440
433
|
// Install dependencies
|
|
441
434
|
process.chdir(appletRootDirectory);
|
|
442
|
-
// Ensure the default .npmrc file will be loaded from project root
|
|
443
|
-
// Yarn 2+ uses .yarnrc.yml, but we can use this flag to override user's .npmrc
|
|
444
|
-
const packagerPrefix = ''; // 'NPM_CONFIG_USERCONFIG=/dev/null';
|
|
445
|
-
// Apply packager specific options
|
|
446
|
-
let configFlag = '';
|
|
447
|
-
switch (packager) {
|
|
448
|
-
case Packager.Yarn:
|
|
449
|
-
// Prevent Yarn from automatically detecting yarnrc and npmrc files
|
|
450
|
-
configFlag = '--no-default-rc';
|
|
451
|
-
break;
|
|
452
|
-
case Packager.Bun:
|
|
453
|
-
// Prevent Bun from failing on issues related to lockfile permissions
|
|
454
|
-
configFlag = '--frozen-lockfile';
|
|
455
|
-
break;
|
|
456
|
-
default:
|
|
457
|
-
// Other packagers (npm, pnpm) currently do not require any special config
|
|
458
|
-
}
|
|
459
435
|
const installCommand = packager === Packager.Yarn ? 'add' : 'install';
|
|
460
436
|
// Log the command being executed
|
|
461
|
-
console.info(`Installing dependencies: ${
|
|
462
|
-
|
|
437
|
+
console.info(`Installing dependencies: ${PACKAGER_EXECUTABLE} ${installCommand} --save-dev ${mergedDeps.join(' ')}`);
|
|
438
|
+
// Override registry env so the spawned process doesn't inherit a private
|
|
439
|
+
// registry from the parent project's .npmrc or global config.
|
|
440
|
+
// npm_config_registry is recognised by npm, bun and pnpm.
|
|
441
|
+
const registryUrl = typeof options['npm-registry'] === 'string' ? options['npm-registry'] : 'https://registry.npmjs.org/';
|
|
442
|
+
const spawnEnv = Object.assign(Object.assign({}, process.env), { npm_config_registry: registryUrl });
|
|
443
|
+
const child = child_process.spawn(PACKAGER_EXECUTABLE, [installCommand, '--save-dev', ...mergedDeps], {
|
|
463
444
|
stdio: 'pipe', // Use 'pipe' to capture stdout and stderr
|
|
464
445
|
shell: true,
|
|
446
|
+
env: spawnEnv,
|
|
465
447
|
});
|
|
466
448
|
// Capture and log stdout
|
|
467
449
|
child.stdout.on('data', (data) => {
|
|
@@ -471,23 +453,33 @@ exports.appletGenerate = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
471
453
|
child.stderr.on('data', (data) => {
|
|
472
454
|
console.error(`${data.toString()}`);
|
|
473
455
|
});
|
|
474
|
-
//
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
456
|
+
// Wait for the install process to finish before returning
|
|
457
|
+
yield new Promise((resolve, reject) => {
|
|
458
|
+
child.on('error', (error) => {
|
|
459
|
+
console.error(`Error executing command: ${error.message}`);
|
|
460
|
+
reject(error);
|
|
461
|
+
});
|
|
462
|
+
child.on('close', (code) => {
|
|
463
|
+
if (code === 0) {
|
|
464
|
+
(0, log_1.log)('info', `\nApplet ${chalk_1.default.green(appletName)} created!`);
|
|
465
|
+
const cdCommand = chalk_1.default.green(`cd ${appletRootDirectoryName}`);
|
|
466
|
+
const startCommand = chalk_1.default.green(`${PACKAGER_EXECUTABLE} start`);
|
|
467
|
+
(0, log_1.log)('info', `\nContinue with ${cdCommand} and ${startCommand}`);
|
|
468
|
+
resolve();
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
console.error(`Command exited with code ${code}`);
|
|
472
|
+
resolve(); // Don't reject — let the CLI exit gracefully
|
|
473
|
+
}
|
|
474
|
+
});
|
|
487
475
|
});
|
|
488
476
|
}
|
|
489
477
|
else {
|
|
490
|
-
|
|
478
|
+
const installMessage = chalk_1.default.red(`Please first install ${PACKAGER_EXECUTABLE} globally.`);
|
|
479
|
+
const cdMessage = chalk_1.default.green(`cd ${appletRootDirectoryName}`);
|
|
480
|
+
const installCmd = chalk_1.default.green(`${PACKAGER_EXECUTABLE} install`);
|
|
481
|
+
const startCmd = chalk_1.default.green(`${PACKAGER_EXECUTABLE} start`);
|
|
482
|
+
(0, log_1.log)('info', `${installMessage}\nContinue with ${cdMessage}, ${installCmd} and ${startCmd}`);
|
|
491
483
|
(0, log_1.log)('info', `\nApplet ${chalk_1.default.white(appletName)} created!`);
|
|
492
484
|
}
|
|
493
485
|
});
|
|
@@ -530,7 +522,7 @@ const createPackageConfig = (name, version, bundler, language) => __awaiter(void
|
|
|
530
522
|
const createWebpackConfig = () => importFileAsString('./Templates/webpack.config.js.template');
|
|
531
523
|
const createRspackConfig = () => importFileAsString('./Templates/rspack.config.mjs.template');
|
|
532
524
|
const createIndexHtml = (title) => {
|
|
533
|
-
return importFileAsString('./Templates/index.html.template').
|
|
525
|
+
return importFileAsString('./Templates/index.html.template').replaceAll('${title}', title);
|
|
534
526
|
};
|
|
535
527
|
const createIndexCss = () => importFileAsString('./Templates/index.css.template');
|
|
536
528
|
const createIndexJs = () => importFileAsString('./Templates/index.js.template');
|
|
@@ -21,6 +21,7 @@ const appletFacade_1 = require("../../appletFacade");
|
|
|
21
21
|
const progressBarFactory_1 = require("../../../CommandLine/progressBarFactory");
|
|
22
22
|
const deviceFacade_1 = require("../../../Device/deviceFacade");
|
|
23
23
|
const appletTestRunFacade_1 = require("./appletTestRunFacade");
|
|
24
|
+
const paginationHelper_1 = require("../../../helper/paginationHelper");
|
|
24
25
|
const wait_1 = __importDefault(require("../../../Timer/wait"));
|
|
25
26
|
const commandDefinition_1 = require("../../../Command/commandDefinition");
|
|
26
27
|
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
@@ -86,7 +87,7 @@ exports.appletTestRun = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
86
87
|
const appletUid = yield (0, appletFacade_1.getAppletUid)(restApi, options);
|
|
87
88
|
const applet = yield restApi.applet.get(appletUid);
|
|
88
89
|
const appletVersion = yield restApi.applet.version.get(appletUid, version);
|
|
89
|
-
const testSuites = yield restApi.applet.tests.list(applet.uid, appletVersion.version);
|
|
90
|
+
const testSuites = yield (0, paginationHelper_1.getAllPages)(yield restApi.applet.tests.list(applet.uid, appletVersion.version));
|
|
90
91
|
if (!tests || tests.length === 0) {
|
|
91
92
|
tests = testSuites.map((testSuite) => testSuite.identifier);
|
|
92
93
|
}
|
|
@@ -21,6 +21,7 @@ const appletTestUploadFacade_1 = require("./appletTestUploadFacade");
|
|
|
21
21
|
const appletFacade_1 = require("../../appletFacade");
|
|
22
22
|
const progressBarFactory_1 = require("../../../CommandLine/progressBarFactory");
|
|
23
23
|
const packageConfig_1 = require("@signageos/sdk/dist/FileSystem/packageConfig");
|
|
24
|
+
const paginationHelper_1 = require("../../../helper/paginationHelper");
|
|
24
25
|
const commandDefinition_1 = require("../../../Command/commandDefinition");
|
|
25
26
|
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
26
27
|
const appletValidation_1 = require("../../appletValidation");
|
|
@@ -97,7 +98,7 @@ exports.appletTestUpload = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
97
98
|
if (isVerbose) {
|
|
98
99
|
printMatchedFiles(testFiles);
|
|
99
100
|
}
|
|
100
|
-
const testSuites = yield restApi.applet.tests.list(applet.uid, appletVersion.version);
|
|
101
|
+
const testSuites = yield (0, paginationHelper_1.getAllPages)(yield restApi.applet.tests.list(applet.uid, appletVersion.version));
|
|
101
102
|
const testSuitesMap = {};
|
|
102
103
|
for (const testSuite of testSuites) {
|
|
103
104
|
testSuitesMap[testSuite.identifier] = testSuite;
|
|
@@ -45,6 +45,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
45
45
|
exports.getAppletFileRelativePath = getAppletFileRelativePath;
|
|
46
46
|
exports.getAppletFilesDictionary = getAppletFilesDictionary;
|
|
47
47
|
const path = __importStar(require("path"));
|
|
48
|
+
const paginationHelper_1 = require("../../helper/paginationHelper");
|
|
48
49
|
function getAppletFileRelativePath(fileAbsolutePath, directoryAbsolutePath) {
|
|
49
50
|
const directoryAbsolutePathNormalized = path.normalize(directoryAbsolutePath);
|
|
50
51
|
const fileAbsolutePathNormalized = path.normalize(fileAbsolutePath);
|
|
@@ -66,7 +67,7 @@ function getAppletFileRelativePath(fileAbsolutePath, directoryAbsolutePath) {
|
|
|
66
67
|
function getAppletFilesDictionary(restApi, appletUid, appletVersion) {
|
|
67
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
69
|
const filesDictionary = {};
|
|
69
|
-
const files = yield restApi.applet.version.file.list(appletUid, appletVersion);
|
|
70
|
+
const files = yield (0, paginationHelper_1.getAllPages)(yield restApi.applet.version.file.list(appletUid, appletVersion));
|
|
70
71
|
for (const file of files) {
|
|
71
72
|
filesDictionary[file.path] = file;
|
|
72
73
|
}
|
|
@@ -57,6 +57,7 @@ const parameters_1 = require("../parameters");
|
|
|
57
57
|
const packageConfig_1 = require("@signageos/sdk/dist/FileSystem/packageConfig");
|
|
58
58
|
const appletErrors_1 = require("./appletErrors");
|
|
59
59
|
const helper_1 = require("../helper");
|
|
60
|
+
const paginationHelper_1 = require("../helper/paginationHelper");
|
|
60
61
|
exports.APPLET_UID_OPTION = { name: 'applet-uid', type: String, description: 'Applet UID' };
|
|
61
62
|
function getApplet(directoryPath) {
|
|
62
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -97,7 +98,8 @@ function getAppletUid(restApi_1, options_1) {
|
|
|
97
98
|
const currentApplet = yield getApplet(currentDirectory);
|
|
98
99
|
let appletUid = options['applet-uid'] || currentApplet.uid;
|
|
99
100
|
if (!appletUid) {
|
|
100
|
-
|
|
101
|
+
// Fetch all pages to ensure we don't miss any applets
|
|
102
|
+
const applets = yield (0, paginationHelper_1.getAllPages)(yield restApi.applet.list());
|
|
101
103
|
const candidatesOfApplets = applets.filter((applet) => applet.name === currentApplet.name);
|
|
102
104
|
if (candidatesOfApplets.length === 0) {
|
|
103
105
|
appletUid = undefined;
|
|
@@ -137,7 +139,7 @@ function getAppletVersionFromApi(restApi_1, appletUid_1) {
|
|
|
137
139
|
return __awaiter(this, arguments, void 0, function* (restApi, appletUid, skipConfirmation = false) {
|
|
138
140
|
var _a;
|
|
139
141
|
let appletVersion;
|
|
140
|
-
const appletVersions = yield restApi.applet.version.list(appletUid);
|
|
142
|
+
const appletVersions = yield (0, paginationHelper_1.getAllPages)(yield restApi.applet.version.list(appletUid));
|
|
141
143
|
if (appletVersions.length === 1 && ((_a = appletVersions[0]) === null || _a === void 0 ? void 0 : _a.version)) {
|
|
142
144
|
appletVersion = appletVersions[0].version;
|
|
143
145
|
}
|
|
@@ -22,6 +22,7 @@ const helper_1 = require("../helper");
|
|
|
22
22
|
const IPowerAction_1 = require("@signageos/sdk/dist/RestApi/Device/PowerAction/IPowerAction");
|
|
23
23
|
const apiVersions_1 = require("@signageos/sdk/dist/RestApi/apiVersions");
|
|
24
24
|
const runControlHelper_1 = require("../RunControl/runControlHelper");
|
|
25
|
+
const paginationHelper_1 = require("../helper/paginationHelper");
|
|
25
26
|
const Debug = (0, debug_1.default)('@signageos/cli:Device:facade');
|
|
26
27
|
exports.typeMap = new Map([
|
|
27
28
|
['reboot', { name: 'Reboot Device', action: IPowerAction_1.DevicePowerAction.SystemReboot }],
|
|
@@ -43,7 +44,7 @@ function getDeviceUid(restApi_1, options_1) {
|
|
|
43
44
|
throw new Error('Device UID is required. Please specify --device-uid argument.');
|
|
44
45
|
}
|
|
45
46
|
else {
|
|
46
|
-
const devices = yield restApi.device.list();
|
|
47
|
+
const devices = yield (0, paginationHelper_1.getAllPages)(yield restApi.device.list());
|
|
47
48
|
const response = yield (0, prompts_1.default)({
|
|
48
49
|
type: 'autocomplete',
|
|
49
50
|
name: 'deviceUid',
|
|
@@ -21,6 +21,7 @@ const AuthenticationError_1 = __importDefault(require("@signageos/sdk/dist/RestA
|
|
|
21
21
|
const apiVersions_1 = require("@signageos/sdk/dist/RestApi/apiVersions");
|
|
22
22
|
const helper_1 = require("../helper");
|
|
23
23
|
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
24
|
+
const paginationHelper_1 = require("../helper/paginationHelper");
|
|
24
25
|
const createRestApi = (config) => {
|
|
25
26
|
var _a, _b;
|
|
26
27
|
const options = {
|
|
@@ -37,7 +38,8 @@ const createRestApi = (config) => {
|
|
|
37
38
|
function getListOfEmulators(restApi, organizationUid) {
|
|
38
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
40
|
try {
|
|
40
|
-
|
|
41
|
+
// Fetch all pages to ensure we get all emulators
|
|
42
|
+
const emulators = yield (0, paginationHelper_1.getAllPages)(yield restApi.emulator.list({ organizationUid }));
|
|
41
43
|
return emulators;
|
|
42
44
|
}
|
|
43
45
|
catch (e) {
|
|
@@ -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.0",
|
|
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.4.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>;
|
|
@@ -1,99 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
-
};
|
|
47
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
-
exports.uploadFirmwareVersion = uploadFirmwareVersion;
|
|
49
|
-
const path = __importStar(require("path"));
|
|
50
|
-
const fs = __importStar(require("fs-extra"));
|
|
51
|
-
const fileSystem_1 = require("../../Lib/fileSystem");
|
|
52
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
53
|
-
function uploadFirmwareVersion(parameters) {
|
|
54
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
const { restApi, firmware, pathArr, progressBar } = parameters;
|
|
56
|
-
const sizes = yield Promise.all(pathArr.map((filePath) => __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
const stat = yield fs.stat(filePath);
|
|
58
|
-
return stat.size;
|
|
59
|
-
})));
|
|
60
|
-
// Process each file sequentially for cleaner output
|
|
61
|
-
for (const index in pathArr) {
|
|
62
|
-
const filePath = pathArr[index];
|
|
63
|
-
if (!filePath) {
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
const fileSize = sizes[Number.parseInt(index)];
|
|
67
|
-
if (fileSize === undefined) {
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
const fileName = path.basename(filePath);
|
|
71
|
-
// Log with newline for cleaner output
|
|
72
|
-
console.info(chalk_1.default.yellow(`Uploading ${filePath}\n`));
|
|
73
|
-
if (progressBar) {
|
|
74
|
-
progressBar.init({ size: fileSize, name: fileName });
|
|
75
|
-
}
|
|
76
|
-
const md5Hash = yield (0, fileSystem_1.getFileMD5Checksum)(filePath);
|
|
77
|
-
const stream = fs.createReadStream(filePath);
|
|
78
|
-
stream.pause();
|
|
79
|
-
stream.on('data', (chunk) => {
|
|
80
|
-
if (progressBar) {
|
|
81
|
-
progressBar.update({ add: chunk.length, name: fileName });
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
firmware.files.push({
|
|
85
|
-
hash: md5Hash,
|
|
86
|
-
content: stream,
|
|
87
|
-
size: fileSize,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
try {
|
|
91
|
-
yield restApi.firmwareVersion.create(firmware, parameters.force);
|
|
92
|
-
}
|
|
93
|
-
finally {
|
|
94
|
-
if (progressBar) {
|
|
95
|
-
progressBar.end();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function validateFileExistenceSync(path: string): void;
|
|
@@ -1,48 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.default = validateFileExistenceSync;
|
|
37
|
-
const fs = __importStar(require("fs-extra"));
|
|
38
|
-
function validateFileExistenceSync(path) {
|
|
39
|
-
if (fs.existsSync(path)) {
|
|
40
|
-
const stats = fs.statSync(path);
|
|
41
|
-
if (!stats.isFile()) {
|
|
42
|
-
throw new Error(`${path} is not file.`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
throw new Error(`${path} does not exist.`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Provides commands for managing device firmware on the signageOS platform.
|
|
3
|
-
* Firmware management includes uploading new firmware versions for different
|
|
4
|
-
* device types and application platforms.
|
|
5
|
-
*
|
|
6
|
-
* @group Private
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```bash
|
|
10
|
-
* # Upload firmware version
|
|
11
|
-
* sos firmware upload
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* @see {@link ./upload/ Upload firmware version command}
|
|
15
|
-
*
|
|
16
|
-
* @since 0.6.0
|
|
17
|
-
*/
|
|
18
|
-
export declare const firmware: {
|
|
19
|
-
name: "firmware";
|
|
20
|
-
description: string;
|
|
21
|
-
optionList: never[];
|
|
22
|
-
commands: {
|
|
23
|
-
name: "upload";
|
|
24
|
-
description: string;
|
|
25
|
-
optionList: readonly [{
|
|
26
|
-
readonly name: "application-type";
|
|
27
|
-
readonly alias: "a";
|
|
28
|
-
readonly type: StringConstructor;
|
|
29
|
-
readonly description: "Application type for the firmware (e.g., linux, android, webos)";
|
|
30
|
-
}, {
|
|
31
|
-
readonly name: "firmware-version";
|
|
32
|
-
readonly alias: "f";
|
|
33
|
-
readonly type: StringConstructor;
|
|
34
|
-
readonly description: "Version identifier for the firmware package";
|
|
35
|
-
}, {
|
|
36
|
-
readonly name: "firmware-type";
|
|
37
|
-
readonly type: StringConstructor;
|
|
38
|
-
readonly description: "Device model prefixed with brand (e.g., \"benq_sl550\", \"rpi4\", \"rpi\")";
|
|
39
|
-
}, {
|
|
40
|
-
readonly name: "src";
|
|
41
|
-
readonly type: StringConstructor;
|
|
42
|
-
readonly multiple: true;
|
|
43
|
-
readonly description: "Path(s) to firmware file(s) to upload";
|
|
44
|
-
}, {
|
|
45
|
-
readonly name: "force";
|
|
46
|
-
readonly type: BooleanConstructor;
|
|
47
|
-
readonly description: "When firmware cannot be uploaded due to invalid firmware \"type\", do it anyways.";
|
|
48
|
-
}];
|
|
49
|
-
commands: never[];
|
|
50
|
-
run(options: import("../Command/commandDefinition").CommandLineOptions<readonly [{
|
|
51
|
-
readonly name: "application-type";
|
|
52
|
-
readonly alias: "a";
|
|
53
|
-
readonly type: StringConstructor;
|
|
54
|
-
readonly description: "Application type for the firmware (e.g., linux, android, webos)";
|
|
55
|
-
}, {
|
|
56
|
-
readonly name: "firmware-version";
|
|
57
|
-
readonly alias: "f";
|
|
58
|
-
readonly type: StringConstructor;
|
|
59
|
-
readonly description: "Version identifier for the firmware package";
|
|
60
|
-
}, {
|
|
61
|
-
readonly name: "firmware-type";
|
|
62
|
-
readonly type: StringConstructor;
|
|
63
|
-
readonly description: "Device model prefixed with brand (e.g., \"benq_sl550\", \"rpi4\", \"rpi\")";
|
|
64
|
-
}, {
|
|
65
|
-
readonly name: "src";
|
|
66
|
-
readonly type: StringConstructor;
|
|
67
|
-
readonly multiple: true;
|
|
68
|
-
readonly description: "Path(s) to firmware file(s) to upload";
|
|
69
|
-
}, {
|
|
70
|
-
readonly name: "force";
|
|
71
|
-
readonly type: BooleanConstructor;
|
|
72
|
-
readonly description: "When firmware cannot be uploaded due to invalid firmware \"type\", do it anyways.";
|
|
73
|
-
}]>): Promise<void>;
|
|
74
|
-
}[];
|
|
75
|
-
run(): Promise<never>;
|
|
76
|
-
};
|
|
@@ -1,42 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.firmware = void 0;
|
|
13
|
-
const commandDefinition_1 = require("../Command/commandDefinition");
|
|
14
|
-
const firmwareUploadCommand_1 = require("./Upload/firmwareUploadCommand");
|
|
15
|
-
/**
|
|
16
|
-
* Provides commands for managing device firmware on the signageOS platform.
|
|
17
|
-
* Firmware management includes uploading new firmware versions for different
|
|
18
|
-
* device types and application platforms.
|
|
19
|
-
*
|
|
20
|
-
* @group Private
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```bash
|
|
24
|
-
* # Upload firmware version
|
|
25
|
-
* sos firmware upload
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @see {@link ./upload/ Upload firmware version command}
|
|
29
|
-
*
|
|
30
|
-
* @since 0.6.0
|
|
31
|
-
*/
|
|
32
|
-
exports.firmware = (0, commandDefinition_1.createCommandDefinition)({
|
|
33
|
-
name: 'firmware',
|
|
34
|
-
description: 'Firmware management',
|
|
35
|
-
optionList: [],
|
|
36
|
-
commands: [firmwareUploadCommand_1.firmwareUpload],
|
|
37
|
-
run() {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
throw new Error('Unknown command');
|
|
40
|
-
});
|
|
41
|
-
},
|
|
42
|
-
});
|