@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.
- package/README.md +54 -19
- package/dist/Applet/Build/appletBuildCommand.js +28 -72
- package/dist/Applet/Generate/Templates/CHANGELOG.md.template +7 -0
- package/dist/Applet/Generate/Templates/README.md.template +3 -0
- package/dist/Applet/Generate/Templates/rspack.config.mjs.template +12 -12
- package/dist/Applet/Generate/appletGenerateCommand.d.ts +23 -62
- package/dist/Applet/Generate/appletGenerateCommand.js +432 -365
- package/dist/Applet/Start/appletStartCommand.js +70 -132
- package/dist/Applet/Test/Upload/appletTestRunCommand.js +90 -178
- package/dist/Applet/Test/Upload/appletTestRunFacade.js +5 -29
- package/dist/Applet/Test/Upload/appletTestUploadCommand.js +99 -224
- package/dist/Applet/Test/Upload/appletTestUploadFacade.js +51 -105
- package/dist/Applet/Test/appletTestCommand.js +6 -36
- package/dist/Applet/Upload/appletUploadCommand.js +199 -305
- package/dist/Applet/Upload/appletUploadCommandHelper.js +129 -144
- package/dist/Applet/Upload/appletUploadFacade.d.ts +2 -2
- package/dist/Applet/Upload/appletUploadFacade.js +184 -265
- package/dist/Applet/Upload/appletUploadFacadeHelper.js +51 -55
- package/dist/Applet/appletCommand.d.ts +25 -157
- package/dist/Applet/appletCommand.js +9 -39
- package/dist/Applet/appletErrors.js +5 -24
- package/dist/Applet/appletFacade.js +122 -147
- package/dist/Applet/appletServerHelper.js +18 -55
- package/dist/Auth/loginCommand.d.ts +2 -2
- package/dist/Auth/loginCommand.js +105 -136
- package/dist/Cache/tmpCache.js +47 -16
- package/dist/Cli/helper.js +3 -5
- package/dist/Cli/packageVersion.js +99 -131
- package/dist/Command/Autocomplete/Install/installAutocompleteCommand.d.ts +10 -0
- package/dist/Command/Autocomplete/Install/installAutocompleteCommand.js +39 -0
- package/dist/Command/Autocomplete/Install/installAutocompleteCommand.ts +30 -0
- package/dist/Command/Autocomplete/Install/sos-completion.sh +63 -0
- package/dist/Command/Autocomplete/Uninstall/uninstallAutocompleteCommand.d.ts +8 -0
- package/dist/Command/Autocomplete/Uninstall/uninstallAutocompleteCommand.js +120 -0
- package/dist/Command/Autocomplete/autocompleteCommand.d.ts +22 -0
- package/dist/Command/Autocomplete/autocompleteCommand.js +32 -0
- package/dist/Command/autoComplete.d.ts +4 -0
- package/dist/Command/autoComplete.js +184 -0
- package/dist/Command/commandDefinition.d.ts +9 -9
- package/dist/Command/commandDefinition.js +1 -3
- package/dist/Command/commandProcessor.js +41 -131
- package/dist/Command/globalArgs.js +9 -8
- package/dist/CommandLine/IProgressBar.js +0 -1
- package/dist/CommandLine/progressBarFactory.d.ts +1 -1
- package/dist/CommandLine/progressBarFactory.js +42 -13
- package/dist/CustomScript/Generate/customScriptGenerateCommand.js +17 -56
- package/dist/CustomScript/Generate/customScriptGenerateFacade.js +94 -109
- package/dist/CustomScript/Upload/customScriptUploadCommand.js +44 -120
- package/dist/CustomScript/customScriptCommand.d.ts +1 -9
- package/dist/CustomScript/customScriptCommand.js +6 -36
- package/dist/CustomScript/customScriptFacade.d.ts +2 -2
- package/dist/CustomScript/customScriptFacade.js +187 -297
- package/dist/Device/Connect/connectCommand.js +73 -137
- package/dist/Device/Content/setContentCommand.js +33 -78
- package/dist/Device/PowerAction/powerActionCommand.js +22 -65
- package/dist/Device/deviceCommand.js +7 -37
- package/dist/Device/deviceFacade.js +71 -127
- package/dist/Emulator/IEmulator.js +0 -1
- package/dist/Emulator/createDomain.d.ts +0 -1
- package/dist/Emulator/createDomain.js +44 -14
- package/dist/Emulator/emulatorFacade.js +75 -133
- package/dist/Emulator/emulatorFactory.js +123 -126
- package/dist/Firmware/Upload/firmwareUploadCommand.js +133 -221
- package/dist/Firmware/Upload/firmwareUploadFacade.js +75 -112
- package/dist/Firmware/Upload/firmwareUploadHelper.js +38 -6
- package/dist/Firmware/firmwareCommand.js +5 -35
- package/dist/Lib/archive.js +56 -62
- package/dist/Lib/childProcess.js +37 -5
- package/dist/Lib/fileSystem.js +76 -87
- package/dist/Lib/git.d.ts +1 -1
- package/dist/Lib/git.js +58 -87
- package/dist/Organization/Get/organizationGetCommand.js +14 -50
- package/dist/Organization/List/organizationListCommand.js +12 -46
- package/dist/Organization/SetDefault/organizationSetDefaultCommand.js +18 -56
- package/dist/Organization/organizationCommand.js +7 -37
- package/dist/Organization/organizationFacade.js +102 -177
- package/dist/RunControl/runControlHelper.js +14 -64
- package/dist/Timer/wait.js +2 -3
- package/dist/Timing/List/timingListCommand.js +20 -62
- package/dist/Timing/timingCommand.js +5 -35
- package/dist/generalCommand.js +1 -2
- package/dist/helper.d.ts +4 -4
- package/dist/helper.js +61 -122
- package/dist/index.js +19 -46
- package/dist/parameters.js +17 -40
- package/package.json +52 -57
- package/dist/Applet/Build/appletBuildCommand.js.map +0 -1
- package/dist/Applet/Generate/appletGenerateCommand.js.map +0 -1
- package/dist/Applet/Start/appletStartCommand.js.map +0 -1
- package/dist/Applet/Test/Upload/appletTestRunCommand.js.map +0 -1
- package/dist/Applet/Test/Upload/appletTestRunFacade.js.map +0 -1
- package/dist/Applet/Test/Upload/appletTestUploadCommand.js.map +0 -1
- package/dist/Applet/Test/Upload/appletTestUploadFacade.js.map +0 -1
- package/dist/Applet/Test/appletTestCommand.js.map +0 -1
- package/dist/Applet/Upload/appletUploadCommand.js.map +0 -1
- package/dist/Applet/Upload/appletUploadCommandHelper.js.map +0 -1
- package/dist/Applet/Upload/appletUploadFacade.js.map +0 -1
- package/dist/Applet/Upload/appletUploadFacadeHelper.js.map +0 -1
- package/dist/Applet/appletCommand.js.map +0 -1
- package/dist/Applet/appletErrors.js.map +0 -1
- package/dist/Applet/appletFacade.js.map +0 -1
- package/dist/Applet/appletServerHelper.js.map +0 -1
- package/dist/Auth/loginCommand.js.map +0 -1
- package/dist/Cache/tmpCache.js.map +0 -1
- package/dist/Cli/helper.js.map +0 -1
- package/dist/Cli/packageVersion.js.map +0 -1
- package/dist/Command/commandDefinition.js.map +0 -1
- package/dist/Command/commandProcessor.js.map +0 -1
- package/dist/Command/globalArgs.js.map +0 -1
- package/dist/CommandLine/IProgressBar.js.map +0 -1
- package/dist/CommandLine/progressBarFactory.js.map +0 -1
- package/dist/CustomScript/Generate/customScriptGenerateCommand.js.map +0 -1
- package/dist/CustomScript/Generate/customScriptGenerateFacade.js.map +0 -1
- package/dist/CustomScript/Upload/customScriptUploadCommand.js.map +0 -1
- package/dist/CustomScript/customScriptCommand.js.map +0 -1
- package/dist/CustomScript/customScriptFacade.js.map +0 -1
- package/dist/Device/Connect/connectCommand.js.map +0 -1
- package/dist/Device/Content/setContentCommand.js.map +0 -1
- package/dist/Device/PowerAction/powerActionCommand.js.map +0 -1
- package/dist/Device/deviceCommand.js.map +0 -1
- package/dist/Device/deviceFacade.js.map +0 -1
- package/dist/Emulator/IEmulator.js.map +0 -1
- package/dist/Emulator/createDomain.js.map +0 -1
- package/dist/Emulator/emulatorFacade.js.map +0 -1
- package/dist/Emulator/emulatorFactory.js.map +0 -1
- package/dist/Firmware/Upload/firmwareUploadCommand.js.map +0 -1
- package/dist/Firmware/Upload/firmwareUploadFacade.js.map +0 -1
- package/dist/Firmware/Upload/firmwareUploadHelper.js.map +0 -1
- package/dist/Firmware/firmwareCommand.js.map +0 -1
- package/dist/Lib/archive.js.map +0 -1
- package/dist/Lib/childProcess.js.map +0 -1
- package/dist/Lib/fileSystem.js.map +0 -1
- package/dist/Lib/git.js.map +0 -1
- package/dist/Organization/Get/organizationGetCommand.js.map +0 -1
- package/dist/Organization/List/organizationListCommand.js.map +0 -1
- package/dist/Organization/SetDefault/organizationSetDefaultCommand.js.map +0 -1
- package/dist/Organization/organizationCommand.js.map +0 -1
- package/dist/Organization/organizationFacade.js.map +0 -1
- package/dist/RunControl/runControlHelper.js.map +0 -1
- package/dist/Timer/wait.js.map +0 -1
- package/dist/Timing/List/timingListCommand.js.map +0 -1
- package/dist/Timing/timingCommand.js.map +0 -1
- package/dist/generalCommand.js.map +0 -1
- package/dist/helper.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/parameters.js.map +0 -1
|
@@ -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
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
13
|
-
export
|
|
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
|
|
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 =
|
|
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
|
|
12
|
-
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
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 =
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
function processCommand(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
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
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
154
|
-
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.
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,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 =
|
|
4
|
-
|
|
36
|
+
exports.createProgressBar = createProgressBar;
|
|
37
|
+
const cliProgress = __importStar(require("cli-progress"));
|
|
5
38
|
function createProgressBar() {
|
|
6
|
-
|
|
39
|
+
const progressBar = new cliProgress.Bar({
|
|
7
40
|
format: '[{bar}] {name} {percentage}% | ETA: {eta}s | {value}/{total}',
|
|
8
41
|
}, cliProgress.Presets.rect);
|
|
9
|
-
|
|
10
|
-
|
|
42
|
+
let current = 0;
|
|
43
|
+
let currentName = 'preparing';
|
|
11
44
|
return {
|
|
12
|
-
init
|
|
13
|
-
var size = _a.size, name = _a.name;
|
|
45
|
+
init({ size, name }) {
|
|
14
46
|
currentName = name;
|
|
15
|
-
progressBar.start(size, current, { name
|
|
47
|
+
progressBar.start(size, current, { name });
|
|
16
48
|
},
|
|
17
|
-
update
|
|
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
|
|
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
|
|
12
|
-
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
|
52
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|