@signageos/cli 2.3.1 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/README.md +54 -19
  2. package/dist/Applet/Build/appletBuildCommand.js +28 -72
  3. package/dist/Applet/Generate/Templates/CHANGELOG.md.template +7 -0
  4. package/dist/Applet/Generate/Templates/README.md.template +3 -0
  5. package/dist/Applet/Generate/Templates/rspack.config.mjs.template +12 -12
  6. package/dist/Applet/Generate/appletGenerateCommand.d.ts +23 -62
  7. package/dist/Applet/Generate/appletGenerateCommand.js +432 -365
  8. package/dist/Applet/Start/appletStartCommand.js +70 -132
  9. package/dist/Applet/Test/Upload/appletTestRunCommand.js +90 -178
  10. package/dist/Applet/Test/Upload/appletTestRunFacade.js +5 -29
  11. package/dist/Applet/Test/Upload/appletTestUploadCommand.js +99 -224
  12. package/dist/Applet/Test/Upload/appletTestUploadFacade.js +51 -105
  13. package/dist/Applet/Test/appletTestCommand.js +6 -36
  14. package/dist/Applet/Upload/appletUploadCommand.js +199 -305
  15. package/dist/Applet/Upload/appletUploadCommandHelper.js +129 -144
  16. package/dist/Applet/Upload/appletUploadFacade.d.ts +2 -2
  17. package/dist/Applet/Upload/appletUploadFacade.js +184 -265
  18. package/dist/Applet/Upload/appletUploadFacadeHelper.js +51 -55
  19. package/dist/Applet/appletCommand.d.ts +25 -157
  20. package/dist/Applet/appletCommand.js +9 -39
  21. package/dist/Applet/appletErrors.js +5 -24
  22. package/dist/Applet/appletFacade.js +122 -147
  23. package/dist/Applet/appletServerHelper.js +18 -55
  24. package/dist/Auth/loginCommand.d.ts +2 -2
  25. package/dist/Auth/loginCommand.js +105 -136
  26. package/dist/Cache/tmpCache.js +47 -16
  27. package/dist/Cli/helper.js +3 -5
  28. package/dist/Cli/packageVersion.js +99 -131
  29. package/dist/Command/Autocomplete/Install/installAutocompleteCommand.d.ts +10 -0
  30. package/dist/Command/Autocomplete/Install/installAutocompleteCommand.js +39 -0
  31. package/dist/Command/Autocomplete/Install/installAutocompleteCommand.ts +30 -0
  32. package/dist/Command/Autocomplete/Install/sos-completion.sh +63 -0
  33. package/dist/Command/Autocomplete/Uninstall/uninstallAutocompleteCommand.d.ts +8 -0
  34. package/dist/Command/Autocomplete/Uninstall/uninstallAutocompleteCommand.js +120 -0
  35. package/dist/Command/Autocomplete/autocompleteCommand.d.ts +22 -0
  36. package/dist/Command/Autocomplete/autocompleteCommand.js +32 -0
  37. package/dist/Command/autoComplete.d.ts +4 -0
  38. package/dist/Command/autoComplete.js +184 -0
  39. package/dist/Command/commandDefinition.d.ts +9 -9
  40. package/dist/Command/commandDefinition.js +1 -3
  41. package/dist/Command/commandProcessor.js +41 -131
  42. package/dist/Command/globalArgs.js +9 -8
  43. package/dist/CommandLine/IProgressBar.js +0 -1
  44. package/dist/CommandLine/progressBarFactory.d.ts +1 -1
  45. package/dist/CommandLine/progressBarFactory.js +42 -13
  46. package/dist/CustomScript/Generate/customScriptGenerateCommand.js +17 -56
  47. package/dist/CustomScript/Generate/customScriptGenerateFacade.js +94 -109
  48. package/dist/CustomScript/Upload/customScriptUploadCommand.js +44 -120
  49. package/dist/CustomScript/customScriptCommand.d.ts +1 -9
  50. package/dist/CustomScript/customScriptCommand.js +6 -36
  51. package/dist/CustomScript/customScriptFacade.d.ts +2 -2
  52. package/dist/CustomScript/customScriptFacade.js +187 -297
  53. package/dist/Device/Connect/connectCommand.js +73 -137
  54. package/dist/Device/Content/setContentCommand.js +33 -78
  55. package/dist/Device/PowerAction/powerActionCommand.js +22 -65
  56. package/dist/Device/deviceCommand.js +7 -37
  57. package/dist/Device/deviceFacade.js +71 -127
  58. package/dist/Emulator/IEmulator.js +0 -1
  59. package/dist/Emulator/createDomain.d.ts +0 -1
  60. package/dist/Emulator/createDomain.js +44 -14
  61. package/dist/Emulator/emulatorFacade.js +75 -133
  62. package/dist/Emulator/emulatorFactory.js +123 -126
  63. package/dist/Firmware/Upload/firmwareUploadCommand.js +133 -221
  64. package/dist/Firmware/Upload/firmwareUploadFacade.js +75 -112
  65. package/dist/Firmware/Upload/firmwareUploadHelper.js +38 -6
  66. package/dist/Firmware/firmwareCommand.js +5 -35
  67. package/dist/Lib/archive.js +56 -62
  68. package/dist/Lib/childProcess.js +37 -5
  69. package/dist/Lib/fileSystem.js +76 -87
  70. package/dist/Lib/git.d.ts +1 -1
  71. package/dist/Lib/git.js +58 -87
  72. package/dist/Organization/Get/organizationGetCommand.js +14 -50
  73. package/dist/Organization/List/organizationListCommand.js +12 -46
  74. package/dist/Organization/SetDefault/organizationSetDefaultCommand.js +18 -56
  75. package/dist/Organization/organizationCommand.js +7 -37
  76. package/dist/Organization/organizationFacade.js +102 -177
  77. package/dist/RunControl/runControlHelper.js +14 -64
  78. package/dist/Timer/wait.js +2 -3
  79. package/dist/Timing/List/timingListCommand.js +20 -62
  80. package/dist/Timing/timingCommand.js +5 -35
  81. package/dist/generalCommand.js +1 -2
  82. package/dist/helper.d.ts +4 -4
  83. package/dist/helper.js +61 -122
  84. package/dist/index.js +19 -46
  85. package/dist/parameters.js +17 -40
  86. package/package.json +52 -57
  87. package/dist/Applet/Build/appletBuildCommand.js.map +0 -1
  88. package/dist/Applet/Generate/appletGenerateCommand.js.map +0 -1
  89. package/dist/Applet/Start/appletStartCommand.js.map +0 -1
  90. package/dist/Applet/Test/Upload/appletTestRunCommand.js.map +0 -1
  91. package/dist/Applet/Test/Upload/appletTestRunFacade.js.map +0 -1
  92. package/dist/Applet/Test/Upload/appletTestUploadCommand.js.map +0 -1
  93. package/dist/Applet/Test/Upload/appletTestUploadFacade.js.map +0 -1
  94. package/dist/Applet/Test/appletTestCommand.js.map +0 -1
  95. package/dist/Applet/Upload/appletUploadCommand.js.map +0 -1
  96. package/dist/Applet/Upload/appletUploadCommandHelper.js.map +0 -1
  97. package/dist/Applet/Upload/appletUploadFacade.js.map +0 -1
  98. package/dist/Applet/Upload/appletUploadFacadeHelper.js.map +0 -1
  99. package/dist/Applet/appletCommand.js.map +0 -1
  100. package/dist/Applet/appletErrors.js.map +0 -1
  101. package/dist/Applet/appletFacade.js.map +0 -1
  102. package/dist/Applet/appletServerHelper.js.map +0 -1
  103. package/dist/Auth/loginCommand.js.map +0 -1
  104. package/dist/Cache/tmpCache.js.map +0 -1
  105. package/dist/Cli/helper.js.map +0 -1
  106. package/dist/Cli/packageVersion.js.map +0 -1
  107. package/dist/Command/commandDefinition.js.map +0 -1
  108. package/dist/Command/commandProcessor.js.map +0 -1
  109. package/dist/Command/globalArgs.js.map +0 -1
  110. package/dist/CommandLine/IProgressBar.js.map +0 -1
  111. package/dist/CommandLine/progressBarFactory.js.map +0 -1
  112. package/dist/CustomScript/Generate/customScriptGenerateCommand.js.map +0 -1
  113. package/dist/CustomScript/Generate/customScriptGenerateFacade.js.map +0 -1
  114. package/dist/CustomScript/Upload/customScriptUploadCommand.js.map +0 -1
  115. package/dist/CustomScript/customScriptCommand.js.map +0 -1
  116. package/dist/CustomScript/customScriptFacade.js.map +0 -1
  117. package/dist/Device/Connect/connectCommand.js.map +0 -1
  118. package/dist/Device/Content/setContentCommand.js.map +0 -1
  119. package/dist/Device/PowerAction/powerActionCommand.js.map +0 -1
  120. package/dist/Device/deviceCommand.js.map +0 -1
  121. package/dist/Device/deviceFacade.js.map +0 -1
  122. package/dist/Emulator/IEmulator.js.map +0 -1
  123. package/dist/Emulator/createDomain.js.map +0 -1
  124. package/dist/Emulator/emulatorFacade.js.map +0 -1
  125. package/dist/Emulator/emulatorFactory.js.map +0 -1
  126. package/dist/Firmware/Upload/firmwareUploadCommand.js.map +0 -1
  127. package/dist/Firmware/Upload/firmwareUploadFacade.js.map +0 -1
  128. package/dist/Firmware/Upload/firmwareUploadHelper.js.map +0 -1
  129. package/dist/Firmware/firmwareCommand.js.map +0 -1
  130. package/dist/Lib/archive.js.map +0 -1
  131. package/dist/Lib/childProcess.js.map +0 -1
  132. package/dist/Lib/fileSystem.js.map +0 -1
  133. package/dist/Lib/git.js.map +0 -1
  134. package/dist/Organization/Get/organizationGetCommand.js.map +0 -1
  135. package/dist/Organization/List/organizationListCommand.js.map +0 -1
  136. package/dist/Organization/SetDefault/organizationSetDefaultCommand.js.map +0 -1
  137. package/dist/Organization/organizationCommand.js.map +0 -1
  138. package/dist/Organization/organizationFacade.js.map +0 -1
  139. package/dist/RunControl/runControlHelper.js.map +0 -1
  140. package/dist/Timer/wait.js.map +0 -1
  141. package/dist/Timing/List/timingListCommand.js.map +0 -1
  142. package/dist/Timing/timingCommand.js.map +0 -1
  143. package/dist/generalCommand.js.map +0 -1
  144. package/dist/helper.js.map +0 -1
  145. package/dist/index.js.map +0 -1
  146. package/dist/parameters.js.map +0 -1
@@ -0,0 +1,184 @@
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.generateCompletionScript = generateCompletionScript;
37
+ exports.installAutoCompletion = installAutoCompletion;
38
+ exports.setupCompletion = setupCompletion;
39
+ const fs = __importStar(require("fs"));
40
+ const path = __importStar(require("path"));
41
+ // Function to extract command structure for auto-completion
42
+ function buildCompletionSchema(command, parentCommand = '', isRoot = true) {
43
+ const commandName = isRoot ? '' : parentCommand ? `${parentCommand} ${command.name}` : command.name;
44
+ const result = {};
45
+ // Add subcommands
46
+ if (command.commands.length > 0) {
47
+ result[commandName] = command.commands.map((cmd) => cmd.name);
48
+ }
49
+ // Add options
50
+ const options = command.optionList.map((opt) => `--${opt.name}`);
51
+ if (options.length > 0) {
52
+ result[`${commandName} options`] = options;
53
+ }
54
+ // Process subcommands with a simpler approach
55
+ for (const subCommand of command.commands) {
56
+ const newParent = commandName || '';
57
+ Object.assign(result, buildCompletionSchema(subCommand, newParent, false));
58
+ }
59
+ return result;
60
+ }
61
+ // Move the shell script to a separate file and dynamically read it
62
+ function generateCompletionScript(rootCommand) {
63
+ const commandSchema = buildCompletionSchema(rootCommand);
64
+ const topLevelCommands = commandSchema[''] ? commandSchema[''].join(' ') : '';
65
+ // Read the shell script from the file
66
+ const scriptPath = path.resolve(__dirname, './Autocomplete/Install/sos-completion.sh');
67
+ let script = fs.readFileSync(scriptPath, 'utf8');
68
+ // Generate case statements for each command path
69
+ let commandCases = '';
70
+ for (const cmdPath in commandSchema) {
71
+ if (cmdPath === '') {
72
+ continue;
73
+ } // Skip the top-level commands
74
+ const subcommands = commandSchema[cmdPath] ? commandSchema[cmdPath].join(' ') : '';
75
+ if (subcommands) {
76
+ commandCases += ` "${cmdPath}")\n COMPREPLY=( $(compgen -W "${subcommands}" -- "$cur") )\n return 0\n ;;\n`;
77
+ }
78
+ }
79
+ // If no command cases were generated, add a comment to make the script valid
80
+ if (!commandCases) {
81
+ commandCases = ' # No subcommands available\n';
82
+ }
83
+ // Replace placeholders in the shell script
84
+ script = script.replace(/\${TOPLEVEL_COMMANDS}/g, topLevelCommands);
85
+ script = script.replace(/ # COMMAND_SCHEMA_CASES will be replaced with actual cases during generation/g, commandCases);
86
+ return script;
87
+ }
88
+ function installAutoCompletion(rootCommand) {
89
+ try {
90
+ const script = generateCompletionScript(rootCommand);
91
+ const homeDir = process.env.HOME || process.env.USERPROFILE || '';
92
+ if (!homeDir) {
93
+ console.error('Could not determine home directory for auto-completion installation.');
94
+ return false;
95
+ }
96
+ // Write completion script
97
+ const completionFilePath = path.join(homeDir, '.sos-completion.sh');
98
+ fs.writeFileSync(completionFilePath, script, 'utf8');
99
+ fs.chmodSync(completionFilePath, '755');
100
+ // Configure shell
101
+ const sourceLine = `source ${completionFilePath}`;
102
+ const configResult = configureShellFile(homeDir, sourceLine);
103
+ // Display message
104
+ displayInstallationMessage(completionFilePath, configResult);
105
+ return configResult.configured;
106
+ }
107
+ catch (error) {
108
+ const errorMessage = error instanceof Error ? error.message : String(error);
109
+ console.error('Error installing auto-completion:', errorMessage);
110
+ return false;
111
+ }
112
+ }
113
+ // Helper functions for better organization
114
+ function configureShellFile(homeDir, sourceLine) {
115
+ const shellConfigFiles = ['.zshrc', '.bashrc', '.bash_profile'];
116
+ const activeShell = process.env.SHELL || '';
117
+ // Try to prioritize the current shell's config file
118
+ let orderedConfigFiles = [...shellConfigFiles];
119
+ if (activeShell.includes('zsh')) {
120
+ orderedConfigFiles = ['.zshrc', ...orderedConfigFiles.filter((f) => f !== '.zshrc')];
121
+ }
122
+ else if (activeShell.includes('bash')) {
123
+ orderedConfigFiles = ['.bashrc', '.bash_profile', ...orderedConfigFiles.filter((f) => f !== '.bashrc' && f !== '.bash_profile')];
124
+ }
125
+ for (const configFile of orderedConfigFiles) {
126
+ const configFilePath = path.join(homeDir, configFile);
127
+ try {
128
+ // Skip if file doesn't exist
129
+ if (!fs.existsSync(configFilePath)) {
130
+ continue;
131
+ }
132
+ // Skip if file isn't writable
133
+ const stats = fs.statSync(configFilePath);
134
+ // eslint-disable-next-line no-bitwise
135
+ if ((stats.mode & 0o200) === 0) {
136
+ continue;
137
+ }
138
+ const content = fs.readFileSync(configFilePath, 'utf8');
139
+ // Check if already configured
140
+ if (content.includes(sourceLine)) {
141
+ return { configured: true, file: configFile };
142
+ }
143
+ // Add source line
144
+ fs.appendFileSync(configFilePath, `\n# Added by signageOS CLI for tab completion\n${sourceLine}\n`);
145
+ return { configured: true, file: configFile };
146
+ }
147
+ catch (error) {
148
+ const errorMessage = error instanceof Error ? error.message : String(error);
149
+ console.error(`Failed to configure ${configFile}:`, errorMessage);
150
+ }
151
+ }
152
+ // No config file found
153
+ return {
154
+ configured: false,
155
+ error: `No suitable shell configuration file found or accessible in ${homeDir}`,
156
+ };
157
+ }
158
+ function displayInstallationMessage(completionFilePath, config) {
159
+ // Base message for all scenarios
160
+ const message = ['Auto-completion for signageOS CLI:', `✅ Script installed at: ${completionFilePath}`];
161
+ // Add configuration status
162
+ if (config.configured) {
163
+ message.push(`✅ Source line added to your ${config.file}`);
164
+ message.push('\nTo start using tab completion right away, run:');
165
+ message.push(` source ${completionFilePath}`);
166
+ }
167
+ else {
168
+ message.push('❌ Could not automatically configure your shell');
169
+ if (config.error) {
170
+ message.push(` Reason: ${config.error}`);
171
+ }
172
+ message.push('\nTo enable tab completion, add this line to your shell config:');
173
+ message.push(` source ${completionFilePath}`);
174
+ }
175
+ // Add usage examples
176
+ message.push('\nUsage examples:');
177
+ message.push(' sos [TAB] # Show all top-level commands');
178
+ message.push(' sos applet [TAB] # Show all applet subcommands');
179
+ console.log(message.join('\n'));
180
+ }
181
+ // Create a standalone completion setup command
182
+ function setupCompletion(rootCommand) {
183
+ return installAutoCompletion(rootCommand);
184
+ }
@@ -1,23 +1,23 @@
1
1
  import { OptionDefinition as ArgsOptionDefinition } from 'command-line-args';
2
2
  import { OptionDefinition as UsageOptionDefinition } from 'command-line-usage';
3
3
  import { GENERAL_OPTION_LIST } from '../generalCommand';
4
- export declare type ICommandOption = Readonly<ArgsOptionDefinition & UsageOptionDefinition>;
5
- export declare type OptionList = Readonly<ICommandOption[]>;
6
- declare type GetNumberTypeByConstructor<T extends BooleanConstructor | StringConstructor | NumberConstructor> = T extends NumberConstructor ? number : unknown;
7
- declare type GetNumOrStrTypeByConstructor<T extends BooleanConstructor | StringConstructor | NumberConstructor> = T extends StringConstructor ? string : GetNumberTypeByConstructor<T>;
8
- declare type GetTypeByConstructor<T extends BooleanConstructor | StringConstructor | NumberConstructor> = T extends BooleanConstructor ? boolean : GetNumOrStrTypeByConstructor<T>;
9
- declare type ArrayIfMultiple<O, T> = O extends {
4
+ export type ICommandOption = Readonly<ArgsOptionDefinition & UsageOptionDefinition>;
5
+ export type OptionList = Readonly<ICommandOption[]>;
6
+ type GetNumberTypeByConstructor<T extends BooleanConstructor | StringConstructor | NumberConstructor> = T extends NumberConstructor ? number : unknown;
7
+ type GetNumOrStrTypeByConstructor<T extends BooleanConstructor | StringConstructor | NumberConstructor> = T extends StringConstructor ? string : GetNumberTypeByConstructor<T>;
8
+ type GetTypeByConstructor<T extends BooleanConstructor | StringConstructor | NumberConstructor> = T extends BooleanConstructor ? boolean : GetNumOrStrTypeByConstructor<T>;
9
+ type ArrayIfMultiple<O, T> = O extends {
10
10
  multiple: true;
11
11
  } ? T[] : T;
12
- declare type OptionListWithGeneral<OL extends OptionList> = [...typeof GENERAL_OPTION_LIST, ...OL];
13
- export declare type CommandLineOptions<OL extends OptionList> = {
12
+ type OptionListWithGeneral<OL extends OptionList> = [...typeof GENERAL_OPTION_LIST, ...OL];
13
+ export type CommandLineOptions<OL extends OptionList> = {
14
14
  [P in OptionListWithGeneral<OL>[number]['name']]: ArrayIfMultiple<Extract<OptionListWithGeneral<OL>[number], {
15
15
  name: P;
16
16
  }>, GetTypeByConstructor<Extract<OptionListWithGeneral<OL>[number], {
17
17
  name: P;
18
18
  }>['type']>> | undefined;
19
19
  };
20
- export declare type ICommand<N extends string, OL extends OptionList> = {
20
+ export type ICommand<N extends string, OL extends OptionList> = {
21
21
  name: N;
22
22
  description: string;
23
23
  optionList: OL;
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createCommandDefinition = void 0;
3
+ exports.createCommandDefinition = createCommandDefinition;
4
4
  function createCommandDefinition(def) {
5
5
  return def;
6
6
  }
7
- exports.createCommandDefinition = createCommandDefinition;
8
- //# sourceMappingURL=commandDefinition.js.map
@@ -8,151 +8,61 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __read = (this && this.__read) || function (o, n) {
39
- var m = typeof Symbol === "function" && o[Symbol.iterator];
40
- if (!m) return o;
41
- var i = m.call(o), r, ar = [], e;
42
- try {
43
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
- }
45
- catch (error) { e = { error: error }; }
46
- finally {
47
- try {
48
- if (r && !r.done && (m = i["return"])) m.call(i);
49
- }
50
- finally { if (e) throw e.error; }
51
- }
52
- return ar;
53
- };
54
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
55
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
56
- if (ar || !(i in from)) {
57
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
58
- ar[i] = from[i];
59
- }
60
- }
61
- return to.concat(ar || Array.prototype.slice.call(from));
62
- };
63
- var __values = (this && this.__values) || function(o) {
64
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
65
- if (m) return m.call(o);
66
- if (o && typeof o.length === "number") return {
67
- next: function () {
68
- if (o && i >= o.length) o = void 0;
69
- return { value: o && o[i++], done: !o };
70
- }
71
- };
72
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
73
13
  };
74
14
  Object.defineProperty(exports, "__esModule", { value: true });
75
- exports.processCommand = void 0;
76
- var Debug = require("debug");
77
- var chalk_1 = require("chalk");
78
- var cliUsage = require("command-line-usage");
79
- var cliArgs = require("command-line-args");
80
- var packageVersion_1 = require("../Cli/packageVersion");
81
- var log_1 = require("@signageos/sdk/dist/Console/log");
82
- var debug = Debug('@signageos/cli:Command:processor');
83
- function processCommand(currentCommand, parentOptionList, commandIndex) {
84
- if (parentOptionList === void 0) { parentOptionList = []; }
85
- if (commandIndex === void 0) { commandIndex = 0; }
86
- return __awaiter(this, void 0, void 0, function () {
87
- var nestedOptionList, currentOptions, subCommandName, subCommand, newVer, error_1;
88
- return __generator(this, function (_a) {
89
- switch (_a.label) {
90
- case 0:
91
- nestedOptionList = __spreadArray(__spreadArray([], __read(parentOptionList), false), __read(currentCommand.optionList), false);
92
- currentOptions = cliArgs(nestedOptionList, { partial: true });
93
- debug('process', currentOptions);
94
- subCommandName = currentOptions.command[commandIndex];
95
- subCommand = currentCommand.commands.find(function (command) { return command.name === subCommandName; });
96
- if (!subCommand) return [3 /*break*/, 2];
97
- return [4 /*yield*/, processCommand(subCommand, nestedOptionList, commandIndex + 1)];
98
- case 1:
99
- _a.sent();
100
- return [3 /*break*/, 9];
101
- case 2:
102
- if (!currentOptions.help) return [3 /*break*/, 3];
103
- printUsage(currentCommand, nestedOptionList);
104
- return [3 /*break*/, 9];
105
- case 3:
106
- if (!currentOptions.version) return [3 /*break*/, 5];
107
- return [4 /*yield*/, (0, packageVersion_1.printVersion)()];
108
- case 4:
109
- _a.sent();
110
- return [3 /*break*/, 9];
111
- case 5:
112
- _a.trys.push([5, 8, , 9]);
113
- return [4 /*yield*/, (0, packageVersion_1.newVersionAvailable)()];
114
- case 6:
115
- newVer = _a.sent();
15
+ exports.processCommand = processCommand;
16
+ const debug_1 = __importDefault(require("debug"));
17
+ const chalk_1 = __importDefault(require("chalk"));
18
+ const command_line_usage_1 = __importDefault(require("command-line-usage"));
19
+ const command_line_args_1 = __importDefault(require("command-line-args"));
20
+ const packageVersion_1 = require("../Cli/packageVersion");
21
+ const log_1 = require("@signageos/sdk/dist/Console/log");
22
+ const Debug = (0, debug_1.default)('@signageos/cli:Command:processor');
23
+ function processCommand(currentCommand_1) {
24
+ return __awaiter(this, arguments, void 0, function* (currentCommand, parentOptionList = [], commandIndex = 0) {
25
+ const nestedOptionList = [...parentOptionList, ...currentCommand.optionList];
26
+ const currentOptions = (0, command_line_args_1.default)(nestedOptionList, { partial: true });
27
+ Debug('process', currentOptions);
28
+ const subCommandName = currentOptions.command[commandIndex];
29
+ const subCommand = currentCommand.commands.find((command) => command.name === subCommandName);
30
+ if (subCommand) {
31
+ yield processCommand(subCommand, nestedOptionList, commandIndex + 1);
32
+ }
33
+ else {
34
+ if (currentOptions.help) {
35
+ printUsage(currentCommand, nestedOptionList);
36
+ }
37
+ else if (currentOptions.version) {
38
+ yield (0, packageVersion_1.printVersion)();
39
+ }
40
+ else {
41
+ try {
42
+ const newVer = yield (0, packageVersion_1.newVersionAvailable)();
116
43
  if (newVer) {
117
44
  (0, log_1.log)('info', (0, packageVersion_1.getUpdateVersionMessage)());
118
45
  }
119
- return [4 /*yield*/, currentCommand.run(currentOptions)];
120
- case 7:
121
- _a.sent();
122
- return [3 /*break*/, 9];
123
- case 8:
124
- error_1 = _a.sent();
125
- (0, log_1.log)('error', error_1.message);
46
+ yield currentCommand.run(currentOptions);
47
+ }
48
+ catch (error) {
49
+ (0, log_1.log)('error', error.message);
126
50
  printUsage(currentCommand, nestedOptionList);
127
51
  process.exit(1);
128
- return [3 /*break*/, 9];
129
- case 9: return [2 /*return*/];
52
+ }
130
53
  }
131
- });
54
+ }
132
55
  });
133
56
  }
134
- exports.processCommand = processCommand;
135
57
  function printUsage(currentCommand, optionList) {
136
- var e_1, _a;
137
58
  (0, log_1.log)('info', chalk_1.default.bold(currentCommand.name));
138
59
  (0, log_1.log)('info', ' - ' + chalk_1.default.italic(currentCommand.description), '');
139
- try {
140
- for (var _b = __values(currentCommand.commands), _c = _b.next(); !_c.done; _c = _b.next()) {
141
- var command = _c.value;
142
- (0, log_1.log)('info', ' ' + chalk_1.default.bold(command.name));
143
- (0, log_1.log)('info', ' - ' + chalk_1.default.italic(command.description), '');
144
- }
145
- }
146
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
147
- finally {
148
- try {
149
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
150
- }
151
- finally { if (e_1) throw e_1.error; }
60
+ for (const command of currentCommand.commands) {
61
+ (0, log_1.log)('info', ' ' + chalk_1.default.bold(command.name));
62
+ (0, log_1.log)('info', ' - ' + chalk_1.default.italic(command.description), '');
152
63
  }
153
- var usage = cliUsage({
154
- optionList: optionList,
64
+ const usage = (0, command_line_usage_1.default)({
65
+ optionList,
155
66
  });
156
67
  (0, log_1.log)('info', usage);
157
68
  }
158
- //# sourceMappingURL=commandProcessor.js.map
@@ -1,16 +1,17 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getGlobalProfile = exports.getGlobalApiUrl = void 0;
4
- var cliArgs = require("command-line-args");
5
- var generalCommand_1 = require("../generalCommand");
6
+ exports.getGlobalApiUrl = getGlobalApiUrl;
7
+ exports.getGlobalProfile = getGlobalProfile;
8
+ const command_line_args_1 = __importDefault(require("command-line-args"));
9
+ const generalCommand_1 = require("../generalCommand");
6
10
  function getGlobalApiUrl() {
7
- var options = cliArgs([generalCommand_1.API_URL_OPTION], { partial: true });
11
+ const options = (0, command_line_args_1.default)([generalCommand_1.API_URL_OPTION], { partial: true });
8
12
  return options[generalCommand_1.API_URL_OPTION.name];
9
13
  }
10
- exports.getGlobalApiUrl = getGlobalApiUrl;
11
14
  function getGlobalProfile() {
12
- var options = cliArgs([generalCommand_1.PROFILE_OPTION], { partial: true });
15
+ const options = (0, command_line_args_1.default)([generalCommand_1.PROFILE_OPTION], { partial: true });
13
16
  return options[generalCommand_1.PROFILE_OPTION.name];
14
17
  }
15
- exports.getGlobalProfile = getGlobalProfile;
16
- //# sourceMappingURL=globalArgs.js.map
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=IProgressBar.js.map
@@ -5,7 +5,7 @@ export declare function createProgressBar(): {
5
5
  }): void;
6
6
  update({ add, name }: {
7
7
  add: number;
8
- name?: string | undefined;
8
+ name?: string;
9
9
  }): void;
10
10
  end(): void;
11
11
  };
@@ -1,29 +1,58 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createProgressBar = void 0;
4
- var cliProgress = require("cli-progress");
36
+ exports.createProgressBar = createProgressBar;
37
+ const cliProgress = __importStar(require("cli-progress"));
5
38
  function createProgressBar() {
6
- var progressBar = new cliProgress.Bar({
39
+ const progressBar = new cliProgress.Bar({
7
40
  format: '[{bar}] {name} {percentage}% | ETA: {eta}s | {value}/{total}',
8
41
  }, cliProgress.Presets.rect);
9
- var current = 0;
10
- var currentName = 'preparing';
42
+ let current = 0;
43
+ let currentName = 'preparing';
11
44
  return {
12
- init: function (_a) {
13
- var size = _a.size, name = _a.name;
45
+ init({ size, name }) {
14
46
  currentName = name;
15
- progressBar.start(size, current, { name: name });
47
+ progressBar.start(size, current, { name });
16
48
  },
17
- update: function (_a) {
18
- var add = _a.add, name = _a.name;
49
+ update({ add, name }) {
19
50
  current += add;
20
51
  currentName = name || currentName;
21
52
  progressBar.update(current + add, { name: currentName });
22
53
  },
23
- end: function () {
54
+ end() {
24
55
  progressBar.stop();
25
56
  },
26
57
  };
27
58
  }
28
- exports.createProgressBar = createProgressBar;
29
- //# sourceMappingURL=progressBarFactory.js.map
@@ -8,70 +8,31 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
13
  };
38
14
  Object.defineProperty(exports, "__esModule", { value: true });
39
15
  exports.customScriptGenerate = void 0;
40
- var chalk_1 = require("chalk");
41
- var log_1 = require("@signageos/sdk/dist/Console/log");
42
- var commandDefinition_1 = require("../../Command/commandDefinition");
43
- var customScriptFacade_1 = require("../customScriptFacade");
44
- var customScriptGenerateFacade_1 = require("./customScriptGenerateFacade");
45
- var git_1 = require("../../Lib/git");
16
+ const chalk_1 = __importDefault(require("chalk"));
17
+ const log_1 = require("@signageos/sdk/dist/Console/log");
18
+ const commandDefinition_1 = require("../../Command/commandDefinition");
19
+ const customScriptFacade_1 = require("../customScriptFacade");
20
+ const customScriptGenerateFacade_1 = require("./customScriptGenerateFacade");
21
+ const git_1 = require("../../Lib/git");
46
22
  exports.customScriptGenerate = (0, commandDefinition_1.createCommandDefinition)({
47
23
  name: 'generate',
48
24
  description: 'Generates a local repository for developing a Custom Script',
49
25
  optionList: [],
50
26
  commands: [],
51
- run: function () {
52
- return __awaiter(this, void 0, void 0, function () {
53
- var _a, targetDir, name, description, dangerLevel;
54
- return __generator(this, function (_b) {
55
- switch (_b.label) {
56
- case 0: return [4 /*yield*/, (0, git_1.throwErrorIfGitNotInstalled)()];
57
- case 1:
58
- _b.sent();
59
- return [4 /*yield*/, (0, customScriptGenerateFacade_1.askForParameters)()];
60
- case 2:
61
- _a = _b.sent(), targetDir = _a.targetDir, name = _a.name, description = _a.description, dangerLevel = _a.dangerLevel;
62
- return [4 /*yield*/, (0, customScriptGenerateFacade_1.downloadBoilerplateCode)(targetDir)];
63
- case 3:
64
- _b.sent();
65
- return [4 /*yield*/, (0, customScriptFacade_1.addToConfigFile)(targetDir, { name: name, description: description, dangerLevel: dangerLevel })];
66
- case 4:
67
- _b.sent();
68
- (0, log_1.log)('info', "Custom Script ".concat(chalk_1.default.green(name), " has been generated in ").concat(chalk_1.default.green(targetDir), "."));
69
- (0, log_1.log)('info', 'Next steps:');
70
- (0, log_1.log)('info', " - Open the folder ".concat(chalk_1.default.green(targetDir), " and read the ").concat(chalk_1.default.green('README.md'), " file."));
71
- return [2 /*return*/];
72
- }
73
- });
27
+ run() {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ yield (0, git_1.throwErrorIfGitNotInstalled)();
30
+ const { targetDir, name, description, dangerLevel } = yield (0, customScriptGenerateFacade_1.askForParameters)();
31
+ yield (0, customScriptGenerateFacade_1.downloadBoilerplateCode)(targetDir);
32
+ yield (0, customScriptFacade_1.addToConfigFile)(targetDir, { name, description, dangerLevel });
33
+ (0, log_1.log)('info', `Custom Script ${chalk_1.default.green(name)} has been generated in ${chalk_1.default.green(targetDir)}.`);
34
+ (0, log_1.log)('info', 'Next steps:');
35
+ (0, log_1.log)('info', ` - Open the folder ${chalk_1.default.green(targetDir)} and read the ${chalk_1.default.green('README.md')} file.`);
74
36
  });
75
37
  },
76
38
  });
77
- //# sourceMappingURL=customScriptGenerateCommand.js.map