@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.
Files changed (36) hide show
  1. package/dist/Applet/Generate/appletGenerateCommand.js +50 -58
  2. package/dist/Applet/Test/Upload/appletTestRunCommand.js +2 -1
  3. package/dist/Applet/Test/Upload/appletTestUploadCommand.js +2 -1
  4. package/dist/Applet/Upload/appletUploadFacadeHelper.js +2 -1
  5. package/dist/Applet/appletFacade.js +4 -2
  6. package/dist/CustomScript/Generate/customScriptGenerateCommand.js +6 -0
  7. package/dist/CustomScript/customScriptFacade.d.ts +17 -1
  8. package/dist/CustomScript/customScriptFacade.js +16 -5
  9. package/dist/Device/deviceFacade.js +2 -1
  10. package/dist/Emulator/emulatorFacade.js +7 -1
  11. package/dist/Lib/fileSystem.d.ts +5 -0
  12. package/dist/Lib/fileSystem.js +23 -0
  13. package/dist/Plugin/Generate/pluginGenerateCommand.js +6 -0
  14. package/dist/Plugin/Upload/pluginUploadCommand.js +1 -2
  15. package/dist/Plugin/pluginFacade.d.ts +14 -0
  16. package/dist/Plugin/pluginFacade.js +25 -2
  17. package/dist/Runner/Generate/runnerGenerateCommand.js +6 -0
  18. package/dist/Runner/Upload/runnerUploadCommand.js +6 -6
  19. package/dist/Runner/{runnerFacede.js → runnerFacade.js} +3 -1
  20. package/dist/helper/paginationHelper.d.ts +7 -0
  21. package/dist/helper/paginationHelper.js +32 -0
  22. package/dist/helper.d.ts +0 -1
  23. package/dist/helper.js +0 -20
  24. package/dist/index.js +1 -2
  25. package/docs/applet/generate/index.md +1 -1
  26. package/package.json +3 -6
  27. package/.env +0 -3
  28. package/dist/Firmware/Upload/firmwareUploadCommand.d.ts +0 -90
  29. package/dist/Firmware/Upload/firmwareUploadCommand.js +0 -207
  30. package/dist/Firmware/Upload/firmwareUploadFacade.d.ts +0 -10
  31. package/dist/Firmware/Upload/firmwareUploadFacade.js +0 -99
  32. package/dist/Firmware/Upload/firmwareUploadHelper.d.ts +0 -1
  33. package/dist/Firmware/Upload/firmwareUploadHelper.js +0 -48
  34. package/dist/Firmware/firmwareCommand.d.ts +0 -76
  35. package/dist/Firmware/firmwareCommand.js +0 -42
  36. /package/dist/Runner/{runnerFacede.d.ts → runnerFacade.d.ts} +0 -0
@@ -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: /^\\w(\\w|\\d|-)*\\w$/` },
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: 'echo "Deprecated command \\"npm run connect\\". Use \\"npm run watch\\" instead." && npm run watch',
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.includes(key))
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: 'pnpx rimraf dist',
307
- escheck: 'pnpx es-check@9.4.0 --module es5 "./dist/**/*.js"',
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
- generateFiles.push({
364
- path: path.join(appletRootDirectory, 'src', 'index.css'),
365
- content: createIndexCss(),
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: ${packagerPrefix} ${PACKAGER_EXECUTABLE} ${installCommand} ${configFlag} --save-dev ${mergedDeps.join(' ')}`);
462
- const child = child_process.spawn(PACKAGER_EXECUTABLE, [packagerPrefix, installCommand, configFlag, '--save-dev', ...mergedDeps], {
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
- // Handle errors
475
- child.on('error', (error) => {
476
- console.error(`Error executing command: ${error.message}`);
477
- });
478
- // Handle process exit
479
- child.on('close', (code) => {
480
- if (code === 0) {
481
- (0, log_1.log)('info', `\nApplet ${chalk_1.default.green(appletName)} created!`);
482
- (0, log_1.log)('info', `\nContinue with ${chalk_1.default.green(`cd ${appletRootDirectoryName}`)} and ${chalk_1.default.green(`${PACKAGER_EXECUTABLE} start`)}`);
483
- }
484
- else {
485
- console.error(`Command exited with code ${code}`);
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
- (0, log_1.log)('info', `${chalk_1.default.red(`Please first install ${PACKAGER_EXECUTABLE} globally.`)}\nContinue with ${chalk_1.default.green(`cd ${appletRootDirectoryName}`)}, ${chalk_1.default.green(`${PACKAGER_EXECUTABLE} install`)} and ${chalk_1.default.green(`${PACKAGER_EXECUTABLE} start`)}`);
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').replace(/\$\{title\}/g, title);
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
- const applets = yield restApi.applet.list();
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
  }
@@ -18,6 +18,8 @@ const log_1 = require("@signageos/sdk/dist/Console/log");
18
18
  const commandDefinition_1 = require("../../Command/commandDefinition");
19
19
  const customScriptFacade_1 = require("../customScriptFacade");
20
20
  const customScriptGenerateFacade_1 = require("./customScriptGenerateFacade");
21
+ const fileSystem_1 = require("../../Lib/fileSystem");
22
+ const packageVersion_1 = require("../../Cli/packageVersion");
21
23
  const git_1 = require("../../Lib/git");
22
24
  const customScriptGenerateOptions_1 = require("./customScriptGenerateOptions");
23
25
  /**
@@ -57,6 +59,10 @@ exports.customScriptGenerate = (0, commandDefinition_1.createCommandDefinition)(
57
59
  const { targetDir, name, description, dangerLevel } = yield (0, customScriptGenerateFacade_1.askForParameters)(options, skipConfirmation);
58
60
  yield (0, customScriptGenerateFacade_1.downloadBoilerplateCode)(targetDir);
59
61
  yield (0, customScriptFacade_1.addToConfigFile)(targetDir, { name, description, dangerLevel });
62
+ const frontAppletVersion = yield (0, packageVersion_1.getLatestVersion)('@signageos/front-applet');
63
+ if (frontAppletVersion) {
64
+ yield (0, fileSystem_1.addFrontAppletVersionToConfigFile)(targetDir, frontAppletVersion);
65
+ }
60
66
  (0, log_1.log)('info', `Custom Script ${chalk_1.default.green(name)} has been generated in ${chalk_1.default.green(targetDir)}.`);
61
67
  (0, log_1.log)('info', 'Next steps:');
62
68
  (0, log_1.log)('info', ` - Open the folder ${chalk_1.default.green(targetDir)} and read the ${chalk_1.default.green('README.md')} file.`);
@@ -24,6 +24,13 @@ declare const ConfigSchema: z.ZodObject<{
24
24
  version: z.ZodString;
25
25
  description: z.ZodOptional<z.ZodString>;
26
26
  dangerLevel: z.ZodOptional<z.ZodString>;
27
+ sos: z.ZodOptional<z.ZodObject<{
28
+ '@signageos/front-applet': z.ZodOptional<z.ZodString>;
29
+ }, "strip", z.ZodTypeAny, {
30
+ '@signageos/front-applet'?: string | undefined;
31
+ }, {
32
+ '@signageos/front-applet'?: string | undefined;
33
+ }>>;
27
34
  /**
28
35
  * Config of individual custom script implementations for each target platform.
29
36
  *
@@ -57,6 +64,9 @@ declare const ConfigSchema: z.ZodObject<{
57
64
  }>;
58
65
  configDefinition: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
59
66
  description?: string | undefined;
67
+ sos?: {
68
+ '@signageos/front-applet'?: string | undefined;
69
+ } | undefined;
60
70
  uid?: string | undefined;
61
71
  dangerLevel?: string | undefined;
62
72
  }, {
@@ -69,6 +79,9 @@ declare const ConfigSchema: z.ZodObject<{
69
79
  }>;
70
80
  configDefinition: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
71
81
  description?: string | undefined;
82
+ sos?: {
83
+ '@signageos/front-applet'?: string | undefined;
84
+ } | undefined;
72
85
  uid?: string | undefined;
73
86
  dangerLevel?: string | undefined;
74
87
  }>;
@@ -94,6 +107,9 @@ export declare function getConfig(workDir: string): Promise<{
94
107
  }>;
95
108
  configDefinition: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
96
109
  description?: string | undefined;
110
+ sos?: {
111
+ '@signageos/front-applet'?: string | undefined;
112
+ } | undefined;
97
113
  uid?: string | undefined;
98
114
  dangerLevel?: string | undefined;
99
115
  }>;
@@ -101,7 +117,7 @@ export declare function getConfig(workDir: string): Promise<{
101
117
  * Add data to the config file .sosconfig.json
102
118
  */
103
119
  export declare function addToConfigFile(workDir: string, data: Partial<CustomScriptConfig>): Promise<void>;
104
- export declare function ensureCustomScriptVersion(restApi: RestApi, config: CustomScriptConfig, skipConfirmation?: boolean): Promise<import("@signageos/sdk/dist/RestApi/CustomScript/Version/CustomScriptVersion").CustomScriptVersion>;
120
+ export declare function ensureCustomScriptVersion(restApi: RestApi, config: CustomScriptConfig, skipConfirmation?: boolean): Promise<ICustomScriptVersion | import("@signageos/sdk/dist/RestApi/CustomScript/Version/CustomScriptVersion").CustomScriptVersion>;
105
121
  export declare function uploadCode({ restApi, workDir, platform, config, customScriptVersion, }: {
106
122
  restApi: RestApi;
107
123
  workDir: string;
@@ -60,7 +60,6 @@ const log_1 = require("@signageos/sdk/dist/Console/log");
60
60
  const archive_1 = require("../Lib/archive");
61
61
  const fileSystem_1 = require("../Lib/fileSystem");
62
62
  const runtimeFileSystem_1 = require("@signageos/sdk/dist/Development/runtimeFileSystem");
63
- const CONFIG_FILE_NAME = '.sosconfig.json';
64
63
  const CUSTOM_SCRIPTS_BUILDS_DIRNAME = 'custom_scripts_builds';
65
64
  exports.PlatformSchema = z.strictObject({
66
65
  /** List of files/directories that are part of the custom script for a particular platform. */
@@ -76,6 +75,11 @@ const ConfigSchema = z.object({
76
75
  version: z.string(),
77
76
  description: z.string().optional(),
78
77
  dangerLevel: z.string().optional(),
78
+ sos: z
79
+ .object({
80
+ '@signageos/front-applet': z.string().optional(),
81
+ })
82
+ .optional(),
79
83
  /**
80
84
  * Config of individual custom script implementations for each target platform.
81
85
  *
@@ -109,17 +113,23 @@ function loadConfigFromFile(workDir) {
109
113
  return __awaiter(this, void 0, void 0, function* () {
110
114
  const filePath = getConfigFilePath(workDir);
111
115
  if (!(yield fs.pathExists(filePath))) {
112
- throw new Error(`Config file ${CONFIG_FILE_NAME} not found`);
116
+ throw new Error(`Config file ${fileSystem_1.SOS_CONFIG_FILE_NAME} not found`);
117
+ }
118
+ const fileContent = yield fs.readFile(filePath, 'utf-8');
119
+ try {
120
+ return JSON.parse(fileContent);
121
+ }
122
+ catch (error) {
123
+ throw new Error(`Invalid JSON in ${fileSystem_1.SOS_CONFIG_FILE_NAME}: ${error instanceof Error ? error.message : String(error)}`);
113
124
  }
114
- const fileContent = fs.readFileSync(filePath, 'utf-8');
115
- return JSON.parse(fileContent);
116
125
  });
117
126
  }
118
127
  function getConfigFilePath(workDir) {
119
- return path.join(workDir, CONFIG_FILE_NAME);
128
+ return path.join(workDir, fileSystem_1.SOS_CONFIG_FILE_NAME);
120
129
  }
121
130
  function ensureCustomScriptVersion(restApi, config, skipConfirmation) {
122
131
  return __awaiter(this, void 0, void 0, function* () {
132
+ var _a;
123
133
  const customScript = yield ensureCustomScript(restApi, config, skipConfirmation);
124
134
  const customScriptVersion = yield restApi.customScript.version.get({
125
135
  customScriptUid: customScript.uid,
@@ -146,6 +156,7 @@ function ensureCustomScriptVersion(restApi, config, skipConfirmation) {
146
156
  customScriptUid: customScript.uid,
147
157
  version: config.version,
148
158
  configDefinition: config.configDefinition,
159
+ jsApiVersion: (_a = config.sos) === null || _a === void 0 ? void 0 : _a['@signageos/front-applet'],
149
160
  });
150
161
  });
151
162
  }
@@ -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',
@@ -18,9 +18,11 @@ const prompts_1 = __importDefault(require("prompts"));
18
18
  const runControlHelper_1 = require("../RunControl/runControlHelper");
19
19
  const RestApi_1 = __importDefault(require("@signageos/sdk/dist/RestApi/RestApi"));
20
20
  const AuthenticationError_1 = __importDefault(require("@signageos/sdk/dist/RestApi/Error/AuthenticationError"));
21
+ const NotFoundError_1 = __importDefault(require("@signageos/sdk/dist/RestApi/Error/NotFoundError"));
21
22
  const apiVersions_1 = require("@signageos/sdk/dist/RestApi/apiVersions");
22
23
  const helper_1 = require("../helper");
23
24
  const log_1 = require("@signageos/sdk/dist/Console/log");
25
+ const paginationHelper_1 = require("../helper/paginationHelper");
24
26
  const createRestApi = (config) => {
25
27
  var _a, _b;
26
28
  const options = {
@@ -37,13 +39,17 @@ const createRestApi = (config) => {
37
39
  function getListOfEmulators(restApi, organizationUid) {
38
40
  return __awaiter(this, void 0, void 0, function* () {
39
41
  try {
40
- const emulators = yield restApi.emulator.list({ organizationUid });
42
+ // Fetch all pages to ensure we get all emulators
43
+ const emulators = yield (0, paginationHelper_1.getAllPages)(yield restApi.emulator.list({ organizationUid }));
41
44
  return emulators;
42
45
  }
43
46
  catch (e) {
44
47
  if (e instanceof AuthenticationError_1.default) {
45
48
  throw new Error(`Authentication error. Try to login using ${chalk_1.default.green('sos login')}`);
46
49
  }
50
+ else if (e instanceof NotFoundError_1.default) {
51
+ throw new Error(`Organization with UID ${chalk_1.default.red(organizationUid)} was not found.`);
52
+ }
47
53
  else {
48
54
  throw new Error('Unknown error: ' + e.message);
49
55
  }
@@ -1,3 +1,4 @@
1
+ export declare const SOS_CONFIG_FILE_NAME = ".sosconfig.json";
1
2
  export declare function getFileType(filePath: string): Promise<string>;
2
3
  export declare function validateAllFormalities(appletPath: string, entryFileAbsolutePath: string, appletFilePaths: string[]): Promise<void>;
3
4
  /**
@@ -6,4 +7,8 @@ export declare function validateAllFormalities(appletPath: string, entryFileAbso
6
7
  * This function will ignore differences in slashes. It will only check if the file is included no matter what slashes are used.
7
8
  */
8
9
  export declare function isPathIncluded(filePaths: string[], filePath: string): boolean;
10
+ /**
11
+ * Writes the latest @signageos/front-applet version into the .sosconfig.json of the generated project.
12
+ */
13
+ export declare function addFrontAppletVersionToConfigFile(targetDir: string, frontAppletVersion: string): Promise<void>;
9
14
  export declare function getFileMD5Checksum(filePath: string): Promise<string>;
@@ -45,9 +45,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
45
45
  return (mod && mod.__esModule) ? mod : { "default": mod };
46
46
  };
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.SOS_CONFIG_FILE_NAME = void 0;
48
49
  exports.getFileType = getFileType;
49
50
  exports.validateAllFormalities = validateAllFormalities;
50
51
  exports.isPathIncluded = isPathIncluded;
52
+ exports.addFrontAppletVersionToConfigFile = addFrontAppletVersionToConfigFile;
51
53
  exports.getFileMD5Checksum = getFileMD5Checksum;
52
54
  const path = __importStar(require("path"));
53
55
  const file_1 = __importDefault(require("@signageos/file"));
@@ -56,6 +58,7 @@ const fs = __importStar(require("fs-extra"));
56
58
  const debug_1 = __importDefault(require("debug"));
57
59
  const packageConfig_1 = require("@signageos/sdk/dist/FileSystem/packageConfig");
58
60
  const Debug = (0, debug_1.default)('@signageos/cli:FileSystem:helper');
61
+ exports.SOS_CONFIG_FILE_NAME = '.sosconfig.json';
59
62
  const DEFAULT_FILE_TYPE = 'application/octet-stream';
60
63
  function getFileType(filePath) {
61
64
  return __awaiter(this, void 0, void 0, function* () {
@@ -93,6 +96,26 @@ function isPathIncluded(filePaths, filePath) {
93
96
  const sanitizedFilePaths = filePaths.map((filePathItem) => filePathItem.replace(/\\/g, '/'));
94
97
  return sanitizedFilePaths.includes(sanitizedFilePath);
95
98
  }
99
+ /**
100
+ * Writes the latest @signageos/front-applet version into the .sosconfig.json of the generated project.
101
+ */
102
+ function addFrontAppletVersionToConfigFile(targetDir, frontAppletVersion) {
103
+ return __awaiter(this, void 0, void 0, function* () {
104
+ const configPath = path.join(targetDir, exports.SOS_CONFIG_FILE_NAME);
105
+ if (!(yield fs.pathExists(configPath))) {
106
+ return;
107
+ }
108
+ const rawContent = yield fs.readFile(configPath, 'utf-8');
109
+ try {
110
+ const content = JSON.parse(rawContent);
111
+ content.sos = Object.assign(Object.assign({}, content.sos), { '@signageos/front-applet': frontAppletVersion });
112
+ yield fs.writeFile(configPath, JSON.stringify(content, undefined, '\t') + '\n');
113
+ }
114
+ catch (error) {
115
+ throw new Error(`Invalid JSON in ${exports.SOS_CONFIG_FILE_NAME}: ${error instanceof Error ? error.message : String(error)}`);
116
+ }
117
+ });
118
+ }
96
119
  function getFileMD5Checksum(filePath) {
97
120
  return __awaiter(this, void 0, void 0, function* () {
98
121
  const hash = (0, crypto_1.createHash)('md5');
@@ -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 pluginGenerateFacade_1 = require("./pluginGenerateFacade");
22
+ const fileSystem_1 = require("../../Lib/fileSystem");
22
23
  const pluginGenerateOptions_1 = require("./pluginGenerateOptions");
24
+ const packageVersion_1 = require("../../Cli/packageVersion");
23
25
  /**
24
26
  * Generates a local repository for developing a Plugin with boilerplate code and configuration files.
25
27
  * Sets up complete development environment with necessary dependencies and project structure.
@@ -52,6 +54,10 @@ exports.pluginGenerate = (0, commandDefinition_1.createCommandDefinition)({
52
54
  const { targetDir, name, description } = yield (0, pluginGenerateFacade_1.askForParameters)(options, skipConfirmation);
53
55
  yield (0, pluginGenerateFacade_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', `Plugin ${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.`);
@@ -17,7 +17,6 @@ const chalk_1 = __importDefault(require("chalk"));
17
17
  const log_1 = require("@signageos/sdk/dist/Console/log");
18
18
  const commandDefinition_1 = require("../../Command/commandDefinition");
19
19
  const organizationFacade_1 = require("../../Organization/organizationFacade");
20
- const customScriptFacade_1 = require("../../CustomScript/customScriptFacade");
21
20
  const pluginFacade_1 = require("../pluginFacade");
22
21
  const util_1 = require("util");
23
22
  const helper_1 = require("../../helper");
@@ -64,7 +63,7 @@ exports.pluginUpload = (0, commandDefinition_1.createCommandDefinition)({
64
63
  const organizationUid = yield (0, organizationFacade_1.getOrganizationUidOrDefaultOrSelect)(options, skipPrompts);
65
64
  const organization = yield (0, organizationFacade_1.getOrganization)(organizationUid);
66
65
  const restApi = yield (0, helper_1.createOrganizationRestApi)(organization);
67
- const config = yield (0, customScriptFacade_1.getConfig)(currentDirectory);
66
+ const config = yield (0, pluginFacade_1.getSosConfig)(currentDirectory);
68
67
  const schema = yield (0, pluginFacade_1.loadSchemas)(currentDirectory);
69
68
  const skipConfirmation = !!options.yes;
70
69
  const pluginVersion = yield (0, pluginFacade_1.ensurePluginVersion)(restApi, config, schema, skipConfirmation);
@@ -16,6 +16,13 @@ export declare const ConfigSchema: z.ZodObject<{
16
16
  name: z.ZodString;
17
17
  version: z.ZodString;
18
18
  description: z.ZodOptional<z.ZodString>;
19
+ sos: z.ZodOptional<z.ZodObject<{
20
+ '@signageos/front-applet': z.ZodOptional<z.ZodString>;
21
+ }, "strip", z.ZodTypeAny, {
22
+ '@signageos/front-applet'?: string | undefined;
23
+ }, {
24
+ '@signageos/front-applet'?: string | undefined;
25
+ }>>;
19
26
  /**
20
27
  * Config of individual plugin script implementations for each target platform.
21
28
  *
@@ -46,6 +53,9 @@ export declare const ConfigSchema: z.ZodObject<{
46
53
  }>;
47
54
  configDefinition: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
48
55
  description?: string | undefined;
56
+ sos?: {
57
+ '@signageos/front-applet'?: string | undefined;
58
+ } | undefined;
49
59
  uid?: string | undefined;
50
60
  }, {
51
61
  version: string;
@@ -57,6 +67,10 @@ export declare const ConfigSchema: z.ZodObject<{
57
67
  }>;
58
68
  configDefinition: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
59
69
  description?: string | undefined;
70
+ sos?: {
71
+ '@signageos/front-applet'?: string | undefined;
72
+ } | undefined;
60
73
  uid?: string | undefined;
61
74
  }>;
62
75
  export type PluginConfig = z.infer<typeof ConfigSchema>;
76
+ export declare function getSosConfig(workDir: string): Promise<PluginConfig>;