@signageos/cli 2.6.0 → 2.7.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 -0
- package/dist/Applet/Build/appletBuildCommand.d.ts +1 -2
- package/dist/Applet/Build/appletBuildCommand.js +1 -2
- package/dist/Applet/Generate/appletGenerateCommand.d.ts +1 -1
- package/dist/Applet/Generate/appletGenerateCommand.js +6 -6
- package/dist/Applet/Start/appletStartCommand.d.ts +1 -1
- package/dist/Applet/Start/appletStartCommand.js +1 -1
- package/dist/Applet/Test/Upload/appletTestRunCommand.d.ts +1 -1
- package/dist/Applet/Test/Upload/appletTestRunCommand.js +1 -1
- package/dist/Applet/Test/Upload/appletTestUploadCommand.d.ts +1 -1
- package/dist/Applet/Test/Upload/appletTestUploadCommand.js +1 -1
- package/dist/Applet/Test/appletTestCommand.d.ts +1 -1
- package/dist/Applet/Test/appletTestCommand.js +1 -1
- package/dist/Applet/Upload/appletUploadCommand.d.ts +1 -1
- package/dist/Applet/Upload/appletUploadCommand.js +1 -1
- package/dist/Applet/appletCommand.d.ts +1 -1
- package/dist/Applet/appletCommand.js +1 -1
- package/dist/Applet/appletFacade.d.ts +2 -2
- package/dist/Applet/appletFacade.js +22 -14
- package/dist/Auth/loginCommand.d.ts +3 -10
- package/dist/Auth/loginCommand.js +10 -22
- package/dist/Command/Autocomplete/Install/installAutocompleteCommand.d.ts +1 -1
- package/dist/Command/Autocomplete/Install/installAutocompleteCommand.js +1 -1
- package/dist/Command/Autocomplete/Install/installAutocompleteCommand.ts +1 -1
- package/dist/Command/Autocomplete/Uninstall/uninstallAutocompleteCommand.d.ts +1 -1
- package/dist/Command/Autocomplete/Uninstall/uninstallAutocompleteCommand.js +1 -1
- package/dist/Command/Autocomplete/autocompleteCommand.d.ts +1 -1
- package/dist/Command/Autocomplete/autocompleteCommand.js +1 -1
- package/dist/Command/commandProcessor.d.ts +1 -0
- package/dist/Command/commandProcessor.js +78 -0
- package/dist/Command/globalArgs.d.ts +0 -2
- package/dist/Command/globalArgs.js +0 -2
- package/dist/CustomScript/Generate/customScriptGenerateCommand.d.ts +32 -8
- package/dist/CustomScript/Generate/customScriptGenerateCommand.js +17 -9
- package/dist/CustomScript/Generate/customScriptGenerateFacade.d.ts +7 -5
- package/dist/CustomScript/Generate/customScriptGenerateFacade.js +81 -32
- package/dist/CustomScript/Generate/customScriptGenerateOptions.d.ts +17 -0
- package/dist/CustomScript/Generate/customScriptGenerateOptions.js +13 -0
- package/dist/CustomScript/Upload/customScriptUploadCommand.d.ts +23 -16
- package/dist/CustomScript/Upload/customScriptUploadCommand.js +26 -18
- package/dist/CustomScript/customScriptCommand.d.ts +31 -9
- package/dist/CustomScript/customScriptCommand.js +9 -7
- package/dist/CustomScript/customScriptFacade.d.ts +1 -1
- package/dist/CustomScript/customScriptFacade.js +29 -19
- package/dist/Device/Connect/connectCommand.d.ts +1 -1
- package/dist/Device/Connect/connectCommand.js +1 -1
- package/dist/Device/Content/setContentCommand.d.ts +16 -6
- package/dist/Device/Content/setContentCommand.js +23 -10
- package/dist/Device/PowerAction/powerActionCommand.d.ts +1 -1
- package/dist/Device/PowerAction/powerActionCommand.js +1 -1
- package/dist/Device/deviceCommand.d.ts +9 -1
- package/dist/Device/deviceCommand.js +1 -1
- package/dist/Device/deviceFacade.d.ts +1 -1
- package/dist/Device/deviceFacade.js +22 -17
- package/dist/Organization/Get/organizationGetCommand.d.ts +1 -1
- package/dist/Organization/Get/organizationGetCommand.js +1 -1
- package/dist/Organization/List/organizationListCommand.d.ts +1 -1
- package/dist/Organization/List/organizationListCommand.js +1 -1
- package/dist/Organization/SetDefault/organizationSetDefaultCommand.d.ts +1 -1
- package/dist/Organization/SetDefault/organizationSetDefaultCommand.js +1 -1
- package/dist/Organization/organizationCommand.d.ts +1 -1
- package/dist/Organization/organizationCommand.js +1 -1
- package/dist/Plugin/Generate/pluginGenerateCommand.d.ts +36 -2
- package/dist/Plugin/Generate/pluginGenerateCommand.js +25 -3
- package/dist/Plugin/Generate/pluginGenerateFacade.d.ts +7 -5
- package/dist/Plugin/Generate/pluginGenerateFacade.js +38 -16
- package/dist/Plugin/Generate/pluginGenerateOptions.d.ts +13 -0
- package/dist/Plugin/Generate/pluginGenerateOptions.js +20 -0
- package/dist/Plugin/Upload/pluginUploadCommand.d.ts +28 -0
- package/dist/Plugin/Upload/pluginUploadCommand.js +31 -2
- package/dist/Plugin/pluginCommand.d.ts +49 -2
- package/dist/Plugin/pluginCommand.js +31 -0
- package/dist/Plugin/pluginFacade.d.ts +1 -1
- package/dist/Plugin/pluginFacade.js +29 -19
- package/dist/Runner/Generate/runnerGenerateCommand.d.ts +36 -2
- package/dist/Runner/Generate/runnerGenerateCommand.js +25 -3
- package/dist/Runner/Generate/runnerGenerateFacade.d.ts +7 -5
- package/dist/Runner/Generate/runnerGenerateFacade.js +38 -16
- package/dist/Runner/Generate/runnerGenerateOptions.d.ts +13 -0
- package/dist/Runner/Generate/runnerGenerateOptions.js +20 -0
- package/dist/Runner/Upload/runnerUploadCommand.d.ts +28 -0
- package/dist/Runner/Upload/runnerUploadCommand.js +31 -2
- package/dist/Runner/runnerCommand.d.ts +41 -2
- package/dist/Runner/runnerCommand.js +23 -0
- package/dist/Runner/runnerFacede.d.ts +1 -1
- package/dist/Runner/runnerFacede.js +29 -19
- package/dist/Timing/List/timingListCommand.d.ts +1 -1
- package/dist/Timing/List/timingListCommand.js +1 -1
- package/dist/Timing/timingCommand.d.ts +1 -1
- package/dist/Timing/timingCommand.js +1 -1
- package/dist/index.js +2 -1
- package/docs/applet/build/index.md +1 -1
- package/docs/applet/generate/index.md +1 -1
- package/docs/applet/index.md +1 -1
- package/docs/applet/start/index.md +1 -1
- package/docs/applet/test/index.md +1 -1
- package/docs/applet/test/run/index.md +1 -1
- package/docs/applet/test/upload/index.md +1 -1
- package/docs/applet/upload/index.md +1 -1
- package/docs/autocomplete/index.md +1 -1
- package/docs/autocomplete/install/index.md +1 -1
- package/docs/autocomplete/uninstall/index.md +1 -1
- package/docs/custom-script/generate/index.md +20 -6
- package/docs/custom-script/index.md +9 -7
- package/docs/custom-script/upload/index.md +19 -14
- package/docs/device/connect/index.md +1 -1
- package/docs/device/index.md +1 -1
- package/docs/device/power-action/index.md +1 -1
- package/docs/device/set-content/index.md +12 -8
- package/docs/index.md +20 -4
- package/docs/login/index.md +2 -2
- package/docs/organization/get/index.md +1 -1
- package/docs/organization/index.md +1 -1
- package/docs/organization/list/index.md +1 -1
- package/docs/organization/set-default/index.md +1 -1
- package/docs/plugin/generate/index.md +31 -1
- package/docs/plugin/index.md +34 -1
- package/docs/plugin/upload/index.md +28 -5
- package/docs/runner/generate/index.md +31 -1
- package/docs/runner/index.md +26 -1
- package/docs/runner/upload/index.md +28 -5
- package/docs/timing/index.md +1 -1
- package/docs/timing/list/index.md +1 -1
- package/package.json +2 -2
|
@@ -41,8 +41,6 @@ function getGlobalApiUrl() {
|
|
|
41
41
|
* # Use staging profile
|
|
42
42
|
* sos --profile staging device connect
|
|
43
43
|
* ```
|
|
44
|
-
*
|
|
45
|
-
* @since 1.0.0
|
|
46
44
|
*/
|
|
47
45
|
function getGlobalProfile() {
|
|
48
46
|
const options = (0, command_line_args_1.default)([generalCommand_1.PROFILE_OPTION], { partial: true });
|
|
@@ -1,26 +1,50 @@
|
|
|
1
|
+
import { CommandLineOptions } from '../../Command/commandDefinition';
|
|
2
|
+
import { OPTION_LIST } from './customScriptGenerateOptions';
|
|
1
3
|
/**
|
|
2
4
|
* Creates a new custom script project with boilerplate code and configuration files.
|
|
3
|
-
*
|
|
4
|
-
* including necessary dependencies and project structure.
|
|
5
|
+
* Generates `.sosconfig.json`, platform directories, and sample implementations.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
+
* Requires: name, description, dangerLevel (low/medium/high/critical).
|
|
8
|
+
*
|
|
9
|
+
* @group Development:21
|
|
7
10
|
*
|
|
8
11
|
* @example
|
|
9
12
|
* ```bash
|
|
10
|
-
* #
|
|
13
|
+
* # Interactive generation
|
|
11
14
|
* sos custom-script generate
|
|
15
|
+
*
|
|
16
|
+
* # Non-interactive (CI/CD)
|
|
17
|
+
* sos custom-script generate --name brightness-control --description "Device brightness" --danger-level low --yes
|
|
12
18
|
* ```
|
|
13
19
|
*
|
|
14
|
-
* @
|
|
20
|
+
* @throws {Error} When git is not installed or parameters missing in non-interactive mode
|
|
15
21
|
*
|
|
16
|
-
* @see {@link
|
|
22
|
+
* @see {@link https://developers.signageos.io/docs/custom-scripts/ Documentation}
|
|
23
|
+
* @see {@link https://developers.signageos.io/docs/custom-scripts/#config-file Config File}
|
|
24
|
+
* @see {@link ../upload/ Upload command}
|
|
17
25
|
*
|
|
18
26
|
* @since 2.2.0
|
|
19
27
|
*/
|
|
20
28
|
export declare const customScriptGenerate: {
|
|
21
29
|
name: "generate";
|
|
22
30
|
description: string;
|
|
23
|
-
optionList:
|
|
31
|
+
optionList: readonly [{
|
|
32
|
+
readonly name: "name";
|
|
33
|
+
readonly type: StringConstructor;
|
|
34
|
+
readonly description: "Custom script name";
|
|
35
|
+
}, {
|
|
36
|
+
readonly name: "description";
|
|
37
|
+
readonly type: StringConstructor;
|
|
38
|
+
readonly description: "Custom script description";
|
|
39
|
+
}, {
|
|
40
|
+
readonly name: "danger-level";
|
|
41
|
+
readonly type: StringConstructor;
|
|
42
|
+
readonly description: "Danger level - Can be one of the following: low, medium, high, critical. It represents the danger level of the Custom Script. It should be set according to the potential impact of the Custom Script on the device.";
|
|
43
|
+
}, {
|
|
44
|
+
readonly name: "yes";
|
|
45
|
+
readonly type: BooleanConstructor;
|
|
46
|
+
readonly description: "Skip confirmation prompts and use provided values";
|
|
47
|
+
}];
|
|
24
48
|
commands: never[];
|
|
25
|
-
run(): Promise<void>;
|
|
49
|
+
run(options: CommandLineOptions<typeof OPTION_LIST>): Promise<void>;
|
|
26
50
|
};
|
|
@@ -19,34 +19,42 @@ const commandDefinition_1 = require("../../Command/commandDefinition");
|
|
|
19
19
|
const customScriptFacade_1 = require("../customScriptFacade");
|
|
20
20
|
const customScriptGenerateFacade_1 = require("./customScriptGenerateFacade");
|
|
21
21
|
const git_1 = require("../../Lib/git");
|
|
22
|
+
const customScriptGenerateOptions_1 = require("./customScriptGenerateOptions");
|
|
22
23
|
/**
|
|
23
24
|
* Creates a new custom script project with boilerplate code and configuration files.
|
|
24
|
-
*
|
|
25
|
-
* including necessary dependencies and project structure.
|
|
25
|
+
* Generates `.sosconfig.json`, platform directories, and sample implementations.
|
|
26
26
|
*
|
|
27
|
-
*
|
|
27
|
+
* Requires: name, description, dangerLevel (low/medium/high/critical).
|
|
28
|
+
*
|
|
29
|
+
* @group Development:21
|
|
28
30
|
*
|
|
29
31
|
* @example
|
|
30
32
|
* ```bash
|
|
31
|
-
* #
|
|
33
|
+
* # Interactive generation
|
|
32
34
|
* sos custom-script generate
|
|
35
|
+
*
|
|
36
|
+
* # Non-interactive (CI/CD)
|
|
37
|
+
* sos custom-script generate --name brightness-control --description "Device brightness" --danger-level low --yes
|
|
33
38
|
* ```
|
|
34
39
|
*
|
|
35
|
-
* @
|
|
40
|
+
* @throws {Error} When git is not installed or parameters missing in non-interactive mode
|
|
36
41
|
*
|
|
37
|
-
* @see {@link
|
|
42
|
+
* @see {@link https://developers.signageos.io/docs/custom-scripts/ Documentation}
|
|
43
|
+
* @see {@link https://developers.signageos.io/docs/custom-scripts/#config-file Config File}
|
|
44
|
+
* @see {@link ../upload/ Upload command}
|
|
38
45
|
*
|
|
39
46
|
* @since 2.2.0
|
|
40
47
|
*/
|
|
41
48
|
exports.customScriptGenerate = (0, commandDefinition_1.createCommandDefinition)({
|
|
42
49
|
name: 'generate',
|
|
43
50
|
description: 'Generate a local repository for developing a Custom Script',
|
|
44
|
-
optionList:
|
|
51
|
+
optionList: customScriptGenerateOptions_1.OPTION_LIST,
|
|
45
52
|
commands: [],
|
|
46
|
-
run() {
|
|
53
|
+
run(options) {
|
|
47
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
55
|
yield (0, git_1.throwErrorIfGitNotInstalled)();
|
|
49
|
-
const
|
|
56
|
+
const skipConfirmation = !!options.yes;
|
|
57
|
+
const { targetDir, name, description, dangerLevel } = yield (0, customScriptGenerateFacade_1.askForParameters)(options, skipConfirmation);
|
|
50
58
|
yield (0, customScriptGenerateFacade_1.downloadBoilerplateCode)(targetDir);
|
|
51
59
|
yield (0, customScriptFacade_1.addToConfigFile)(targetDir, { name, description, dangerLevel });
|
|
52
60
|
(0, log_1.log)('info', `Custom Script ${chalk_1.default.green(name)} has been generated in ${chalk_1.default.green(targetDir)}.`);
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { CommandLineOptions } from '../../Command/commandDefinition';
|
|
2
|
+
import { OPTION_LIST } from './customScriptGenerateOptions';
|
|
1
3
|
/**
|
|
2
4
|
* Prompts the user for the parameters needed to generate a custom script.
|
|
3
5
|
*/
|
|
4
|
-
export declare function askForParameters(): Promise<{
|
|
5
|
-
targetDir:
|
|
6
|
-
name:
|
|
7
|
-
description:
|
|
8
|
-
dangerLevel:
|
|
6
|
+
export declare function askForParameters(options?: CommandLineOptions<typeof OPTION_LIST>, skipConfirmation?: boolean): Promise<{
|
|
7
|
+
targetDir: string;
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
dangerLevel: string;
|
|
9
11
|
}>;
|
|
10
12
|
/**
|
|
11
13
|
* Downloads the latest version of the boilerplate code from the GitHub repository.
|
|
@@ -56,47 +56,96 @@ const git_1 = require("../../Lib/git");
|
|
|
56
56
|
/**
|
|
57
57
|
* Prompts the user for the parameters needed to generate a custom script.
|
|
58
58
|
*/
|
|
59
|
-
function askForParameters() {
|
|
60
|
-
return __awaiter(this,
|
|
59
|
+
function askForParameters(options_1) {
|
|
60
|
+
return __awaiter(this, arguments, void 0, function* (options, skipConfirmation = false) {
|
|
61
61
|
const throwCanceledError = () => {
|
|
62
62
|
throw new Error('Custom Script generation was canceled.');
|
|
63
63
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
{
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
64
|
+
// Get values from options or prompt for them
|
|
65
|
+
let name = options === null || options === void 0 ? void 0 : options.name;
|
|
66
|
+
let description = options === null || options === void 0 ? void 0 : options.description;
|
|
67
|
+
let dangerLevel = options === null || options === void 0 ? void 0 : options['danger-level'];
|
|
68
|
+
// Validate danger level if provided
|
|
69
|
+
const validDangerLevels = ['low', 'medium', 'high', 'critical'];
|
|
70
|
+
if (dangerLevel && !validDangerLevels.includes(dangerLevel)) {
|
|
71
|
+
throw new Error(`Invalid danger level '${dangerLevel}'. Must be one of: ${validDangerLevels.join(', ')}`);
|
|
72
|
+
}
|
|
73
|
+
// If --yes is used, validate all required fields are present without prompting
|
|
74
|
+
if (skipConfirmation) {
|
|
75
|
+
if (!name) {
|
|
76
|
+
throw new Error('Name is required when using --yes. Provide it via --name option.');
|
|
77
|
+
}
|
|
78
|
+
if (!description) {
|
|
79
|
+
throw new Error('Description is required when using --yes. Provide it via --description option.');
|
|
80
|
+
}
|
|
81
|
+
if (!dangerLevel) {
|
|
82
|
+
throw new Error('Danger level is required when using --yes. Provide it via --danger-level option.');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
// Only prompt for missing values when not using --yes
|
|
87
|
+
const promptQuestions = [];
|
|
88
|
+
if (!name) {
|
|
89
|
+
promptQuestions.push({
|
|
90
|
+
type: 'text',
|
|
91
|
+
name: 'name',
|
|
92
|
+
message: 'Type name',
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
if (!description) {
|
|
96
|
+
promptQuestions.push({
|
|
97
|
+
type: 'text',
|
|
98
|
+
name: 'description',
|
|
99
|
+
message: 'Type description',
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (!dangerLevel) {
|
|
103
|
+
promptQuestions.push({
|
|
104
|
+
type: 'select',
|
|
105
|
+
name: 'dangerLevel',
|
|
106
|
+
message: 'Select danger level',
|
|
107
|
+
choices: [
|
|
108
|
+
{ title: 'Low', value: 'low' },
|
|
109
|
+
{ title: 'Medium', value: 'medium' },
|
|
110
|
+
{ title: 'High', value: 'high' },
|
|
111
|
+
{ title: 'Critical', value: 'critical' },
|
|
112
|
+
],
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
// Only prompt if there are questions to ask
|
|
116
|
+
if (promptQuestions.length > 0) {
|
|
117
|
+
const responses = yield (0, prompts_1.default)(promptQuestions, { onCancel: throwCanceledError });
|
|
118
|
+
name = name || responses.name;
|
|
119
|
+
description = description || responses.description;
|
|
120
|
+
dangerLevel = dangerLevel || responses.dangerLevel;
|
|
121
|
+
}
|
|
122
|
+
// Validate all required fields are present after prompting
|
|
123
|
+
if (!name) {
|
|
124
|
+
throw new Error('Name is required. Provide it via --name option or interactively.');
|
|
125
|
+
}
|
|
126
|
+
if (!description) {
|
|
127
|
+
throw new Error('Description is required. Provide it via --description option or interactively.');
|
|
128
|
+
}
|
|
129
|
+
if (!dangerLevel) {
|
|
130
|
+
throw new Error('Danger level is required. Provide it via --danger-level option or interactively.');
|
|
131
|
+
}
|
|
132
|
+
}
|
|
87
133
|
const targetDir = name;
|
|
88
134
|
(0, log_1.log)('info', `Generating Custom Script with these parameters:\n` +
|
|
89
135
|
` - Directory: ${chalk_1.default.green(targetDir)}\n` +
|
|
90
136
|
` - Name: ${chalk_1.default.green(name)}\n` +
|
|
91
137
|
` - Description: ${chalk_1.default.green(description)}\n` +
|
|
92
138
|
` - Danger Level: ${chalk_1.default.green(dangerLevel)}\n`);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
139
|
+
// Skip confirmation if --yes flag is used
|
|
140
|
+
if (!skipConfirmation) {
|
|
141
|
+
const { confirm } = yield (0, prompts_1.default)({
|
|
142
|
+
type: 'confirm',
|
|
143
|
+
name: 'confirm',
|
|
144
|
+
message: 'Confirm',
|
|
145
|
+
});
|
|
146
|
+
if (!confirm) {
|
|
147
|
+
throwCanceledError();
|
|
148
|
+
}
|
|
100
149
|
}
|
|
101
150
|
return {
|
|
102
151
|
targetDir,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const OPTION_LIST: readonly [{
|
|
2
|
+
readonly name: "name";
|
|
3
|
+
readonly type: StringConstructor;
|
|
4
|
+
readonly description: "Custom script name";
|
|
5
|
+
}, {
|
|
6
|
+
readonly name: "description";
|
|
7
|
+
readonly type: StringConstructor;
|
|
8
|
+
readonly description: "Custom script description";
|
|
9
|
+
}, {
|
|
10
|
+
readonly name: "danger-level";
|
|
11
|
+
readonly type: StringConstructor;
|
|
12
|
+
readonly description: "Danger level - Can be one of the following: low, medium, high, critical. It represents the danger level of the Custom Script. It should be set according to the potential impact of the Custom Script on the device.";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "yes";
|
|
15
|
+
readonly type: BooleanConstructor;
|
|
16
|
+
readonly description: "Skip confirmation prompts and use provided values";
|
|
17
|
+
}];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OPTION_LIST = void 0;
|
|
4
|
+
exports.OPTION_LIST = [
|
|
5
|
+
{ name: 'name', type: String, description: 'Custom script name' },
|
|
6
|
+
{ name: 'description', type: String, description: 'Custom script description' },
|
|
7
|
+
{
|
|
8
|
+
name: 'danger-level',
|
|
9
|
+
type: String,
|
|
10
|
+
description: 'Danger level - Can be one of the following: low, medium, high, critical. It represents the danger level of the Custom Script. It should be set according to the potential impact of the Custom Script on the device.',
|
|
11
|
+
},
|
|
12
|
+
{ name: 'yes', type: Boolean, description: 'Skip confirmation prompts and use provided values' },
|
|
13
|
+
];
|
|
@@ -7,34 +7,37 @@ export declare const OPTION_LIST: readonly [{
|
|
|
7
7
|
readonly name: "organization-uid";
|
|
8
8
|
readonly type: StringConstructor;
|
|
9
9
|
readonly description: "Organization UID";
|
|
10
|
+
}, {
|
|
11
|
+
readonly name: "yes";
|
|
12
|
+
readonly type: BooleanConstructor;
|
|
13
|
+
readonly description: "Allow to upload new custom script or create new version without confirmation step";
|
|
10
14
|
}];
|
|
11
15
|
/**
|
|
12
|
-
* Uploads custom script code and configuration to
|
|
13
|
-
*
|
|
14
|
-
* functionality beyond standard applets, including system-level operations and
|
|
15
|
-
* device-specific configurations for multiple platforms.
|
|
16
|
+
* Uploads custom script code and configuration to signageOS platform from `.sosconfig.json`.
|
|
17
|
+
* Creates/updates script, uploads platform-specific files, and provides script UID for execution.
|
|
16
18
|
*
|
|
17
|
-
*
|
|
19
|
+
* May prompt for confirmation when creating new scripts or versions.
|
|
20
|
+
* Use `--yes` to skip prompts for automated deployments.
|
|
21
|
+
*
|
|
22
|
+
* @group Development:22
|
|
18
23
|
*
|
|
19
24
|
* @example
|
|
20
25
|
* ```bash
|
|
21
|
-
* # Upload
|
|
26
|
+
* # Upload interactively
|
|
22
27
|
* sos custom-script upload
|
|
23
28
|
*
|
|
24
|
-
* #
|
|
29
|
+
* # Skip confirmations (CI/CD)
|
|
30
|
+
* sos custom-script upload --yes
|
|
31
|
+
*
|
|
32
|
+
* # Specific organization
|
|
25
33
|
* sos custom-script upload --organization-uid abc123def456
|
|
26
34
|
* ```
|
|
27
35
|
*
|
|
28
|
-
* @throws {Error} When
|
|
29
|
-
* @throws {Error} When script platform configuration is missing
|
|
30
|
-
* @throws {Error} When organization access is denied
|
|
31
|
-
* @throws {Error} When script upload fails
|
|
36
|
+
* @throws {Error} When `.sosconfig.json` missing/invalid or upload fails
|
|
32
37
|
*
|
|
33
|
-
* @see {@link https://developers.signageos.io/docs/custom-scripts/
|
|
34
|
-
*
|
|
35
|
-
* @see {@link ../generate/ Generate
|
|
36
|
-
*
|
|
37
|
-
* @see {@link ../ Custom Script management commands}
|
|
38
|
+
* @see {@link https://developers.signageos.io/docs/custom-scripts/ Documentation}
|
|
39
|
+
* @see {@link https://developers.signageos.io/api/#tag/DeviceCustom-Script REST API}
|
|
40
|
+
* @see {@link ../generate/ Generate command}
|
|
38
41
|
*
|
|
39
42
|
* @since 1.8.0
|
|
40
43
|
*/
|
|
@@ -49,6 +52,10 @@ export declare const customScriptUpload: {
|
|
|
49
52
|
readonly name: "organization-uid";
|
|
50
53
|
readonly type: StringConstructor;
|
|
51
54
|
readonly description: "Organization UID";
|
|
55
|
+
}, {
|
|
56
|
+
readonly name: "yes";
|
|
57
|
+
readonly type: BooleanConstructor;
|
|
58
|
+
readonly description: "Allow to upload new custom script or create new version without confirmation step";
|
|
52
59
|
}];
|
|
53
60
|
commands: never[];
|
|
54
61
|
run(options: CommandLineOptions<typeof OPTION_LIST>): Promise<void>;
|
|
@@ -22,34 +22,41 @@ const helper_1 = require("../../helper");
|
|
|
22
22
|
const organizationFacade_1 = require("../../Organization/organizationFacade");
|
|
23
23
|
const customScriptFacade_1 = require("../customScriptFacade");
|
|
24
24
|
const Debug = (0, debug_1.default)('@signageos/cli:CustomScript:Upload:Command');
|
|
25
|
-
exports.OPTION_LIST = [
|
|
25
|
+
exports.OPTION_LIST = [
|
|
26
|
+
organizationFacade_1.NO_DEFAULT_ORGANIZATION_OPTION,
|
|
27
|
+
organizationFacade_1.ORGANIZATION_UID_OPTION,
|
|
28
|
+
{
|
|
29
|
+
name: 'yes',
|
|
30
|
+
type: Boolean,
|
|
31
|
+
description: `Allow to upload new custom script or create new version without confirmation step`,
|
|
32
|
+
},
|
|
33
|
+
];
|
|
26
34
|
/**
|
|
27
|
-
* Uploads custom script code and configuration to
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
35
|
+
* Uploads custom script code and configuration to signageOS platform from `.sosconfig.json`.
|
|
36
|
+
* Creates/updates script, uploads platform-specific files, and provides script UID for execution.
|
|
37
|
+
*
|
|
38
|
+
* May prompt for confirmation when creating new scripts or versions.
|
|
39
|
+
* Use `--yes` to skip prompts for automated deployments.
|
|
31
40
|
*
|
|
32
|
-
* @group Development:
|
|
41
|
+
* @group Development:22
|
|
33
42
|
*
|
|
34
43
|
* @example
|
|
35
44
|
* ```bash
|
|
36
|
-
* # Upload
|
|
45
|
+
* # Upload interactively
|
|
37
46
|
* sos custom-script upload
|
|
38
47
|
*
|
|
39
|
-
* #
|
|
48
|
+
* # Skip confirmations (CI/CD)
|
|
49
|
+
* sos custom-script upload --yes
|
|
50
|
+
*
|
|
51
|
+
* # Specific organization
|
|
40
52
|
* sos custom-script upload --organization-uid abc123def456
|
|
41
53
|
* ```
|
|
42
54
|
*
|
|
43
|
-
* @throws {Error} When
|
|
44
|
-
* @throws {Error} When script platform configuration is missing
|
|
45
|
-
* @throws {Error} When organization access is denied
|
|
46
|
-
* @throws {Error} When script upload fails
|
|
47
|
-
*
|
|
48
|
-
* @see {@link https://developers.signageos.io/docs/custom-scripts/ Custom Scripts Documentation}
|
|
49
|
-
*
|
|
50
|
-
* @see {@link ../generate/ Generate custom script project}
|
|
55
|
+
* @throws {Error} When `.sosconfig.json` missing/invalid or upload fails
|
|
51
56
|
*
|
|
52
|
-
* @see {@link
|
|
57
|
+
* @see {@link https://developers.signageos.io/docs/custom-scripts/ Documentation}
|
|
58
|
+
* @see {@link https://developers.signageos.io/api/#tag/DeviceCustom-Script REST API}
|
|
59
|
+
* @see {@link ../generate/ Generate command}
|
|
53
60
|
*
|
|
54
61
|
* @since 1.8.0
|
|
55
62
|
*/
|
|
@@ -65,7 +72,8 @@ exports.customScriptUpload = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
65
72
|
const organization = yield (0, organizationFacade_1.getOrganization)(organizationUid);
|
|
66
73
|
const restApi = yield (0, helper_1.createOrganizationRestApi)(organization);
|
|
67
74
|
const config = yield (0, customScriptFacade_1.getConfig)(currentDirectory);
|
|
68
|
-
const
|
|
75
|
+
const skipConfirmation = options.yes;
|
|
76
|
+
const customScriptVersion = yield (0, customScriptFacade_1.ensureCustomScriptVersion)(restApi, config, skipConfirmation);
|
|
69
77
|
for (const platform of Object.keys(config.platforms)) {
|
|
70
78
|
const platformConfig = config.platforms[platform];
|
|
71
79
|
if (!platformConfig) {
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Custom Scripts enable advanced device functionality beyond standard applets,
|
|
4
|
-
* including system-level operations and device-specific configurations.
|
|
2
|
+
* Custom Scripts management for advanced device operations.
|
|
5
3
|
*
|
|
6
|
-
*
|
|
4
|
+
* Allows sending OS-specific scripts with native API access to signageOS devices.
|
|
5
|
+
* Supports JavaScript (browser), PowerShell (Windows), Bash/Shell (Linux/Android).
|
|
6
|
+
*
|
|
7
|
+
* @group Development:101
|
|
7
8
|
*
|
|
8
9
|
* @example
|
|
9
10
|
* ```bash
|
|
10
|
-
* # Generate new
|
|
11
|
+
* # Generate new project
|
|
11
12
|
* sos custom-script generate
|
|
12
13
|
*
|
|
13
|
-
* # Upload
|
|
14
|
+
* # Upload to platform
|
|
14
15
|
* sos custom-script upload
|
|
15
16
|
* ```
|
|
16
17
|
*
|
|
17
|
-
* @see {@link https://developers.signageos.io/docs/custom-scripts/
|
|
18
|
+
* @see {@link https://developers.signageos.io/docs/custom-scripts/ Documentation}
|
|
19
|
+
* @see {@link https://developers.signageos.io/docs/custom-scripts/#config-file Config File}
|
|
18
20
|
*
|
|
19
21
|
* @since 1.8.0
|
|
20
22
|
*/
|
|
@@ -33,15 +35,35 @@ export declare const customScript: {
|
|
|
33
35
|
readonly name: "organization-uid";
|
|
34
36
|
readonly type: StringConstructor;
|
|
35
37
|
readonly description: "Organization UID";
|
|
38
|
+
}, {
|
|
39
|
+
readonly name: "yes";
|
|
40
|
+
readonly type: BooleanConstructor;
|
|
41
|
+
readonly description: "Allow to upload new custom script or create new version without confirmation step";
|
|
36
42
|
}];
|
|
37
43
|
commands: never[];
|
|
38
44
|
run(options: import("../Command/commandDefinition").CommandLineOptions<typeof import("./Upload/customScriptUploadCommand").OPTION_LIST>): Promise<void>;
|
|
39
45
|
} | {
|
|
40
46
|
name: "generate";
|
|
41
47
|
description: string;
|
|
42
|
-
optionList:
|
|
48
|
+
optionList: readonly [{
|
|
49
|
+
readonly name: "name";
|
|
50
|
+
readonly type: StringConstructor;
|
|
51
|
+
readonly description: "Custom script name";
|
|
52
|
+
}, {
|
|
53
|
+
readonly name: "description";
|
|
54
|
+
readonly type: StringConstructor;
|
|
55
|
+
readonly description: "Custom script description";
|
|
56
|
+
}, {
|
|
57
|
+
readonly name: "danger-level";
|
|
58
|
+
readonly type: StringConstructor;
|
|
59
|
+
readonly description: "Danger level - Can be one of the following: low, medium, high, critical. It represents the danger level of the Custom Script. It should be set according to the potential impact of the Custom Script on the device.";
|
|
60
|
+
}, {
|
|
61
|
+
readonly name: "yes";
|
|
62
|
+
readonly type: BooleanConstructor;
|
|
63
|
+
readonly description: "Skip confirmation prompts and use provided values";
|
|
64
|
+
}];
|
|
43
65
|
commands: never[];
|
|
44
|
-
run(): Promise<void>;
|
|
66
|
+
run(options: import("../Command/commandDefinition").CommandLineOptions<typeof import("./Generate/customScriptGenerateOptions").OPTION_LIST>): Promise<void>;
|
|
45
67
|
})[];
|
|
46
68
|
run(): Promise<never>;
|
|
47
69
|
};
|
|
@@ -14,22 +14,24 @@ const commandDefinition_1 = require("../Command/commandDefinition");
|
|
|
14
14
|
const customScriptUploadCommand_1 = require("./Upload/customScriptUploadCommand");
|
|
15
15
|
const customScriptGenerateCommand_1 = require("./Generate/customScriptGenerateCommand");
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
* Custom Scripts enable advanced device functionality beyond standard applets,
|
|
19
|
-
* including system-level operations and device-specific configurations.
|
|
17
|
+
* Custom Scripts management for advanced device operations.
|
|
20
18
|
*
|
|
21
|
-
*
|
|
19
|
+
* Allows sending OS-specific scripts with native API access to signageOS devices.
|
|
20
|
+
* Supports JavaScript (browser), PowerShell (Windows), Bash/Shell (Linux/Android).
|
|
21
|
+
*
|
|
22
|
+
* @group Development:101
|
|
22
23
|
*
|
|
23
24
|
* @example
|
|
24
25
|
* ```bash
|
|
25
|
-
* # Generate new
|
|
26
|
+
* # Generate new project
|
|
26
27
|
* sos custom-script generate
|
|
27
28
|
*
|
|
28
|
-
* # Upload
|
|
29
|
+
* # Upload to platform
|
|
29
30
|
* sos custom-script upload
|
|
30
31
|
* ```
|
|
31
32
|
*
|
|
32
|
-
* @see {@link https://developers.signageos.io/docs/custom-scripts/
|
|
33
|
+
* @see {@link https://developers.signageos.io/docs/custom-scripts/ Documentation}
|
|
34
|
+
* @see {@link https://developers.signageos.io/docs/custom-scripts/#config-file Config File}
|
|
33
35
|
*
|
|
34
36
|
* @since 1.8.0
|
|
35
37
|
*/
|
|
@@ -101,7 +101,7 @@ export declare function getConfig(workDir: string): Promise<{
|
|
|
101
101
|
* Add data to the config file .sosconfig.json
|
|
102
102
|
*/
|
|
103
103
|
export declare function addToConfigFile(workDir: string, data: Partial<CustomScriptConfig>): Promise<void>;
|
|
104
|
-
export declare function ensureCustomScriptVersion(restApi: RestApi, config: CustomScriptConfig): Promise<import("@signageos/sdk/dist/RestApi/CustomScript/Version/CustomScriptVersion").CustomScriptVersion>;
|
|
104
|
+
export declare function ensureCustomScriptVersion(restApi: RestApi, config: CustomScriptConfig, skipConfirmation?: boolean): Promise<import("@signageos/sdk/dist/RestApi/CustomScript/Version/CustomScriptVersion").CustomScriptVersion>;
|
|
105
105
|
export declare function uploadCode({ restApi, workDir, platform, config, customScriptVersion, }: {
|
|
106
106
|
restApi: RestApi;
|
|
107
107
|
workDir: string;
|
|
@@ -118,9 +118,9 @@ function loadConfigFromFile(workDir) {
|
|
|
118
118
|
function getConfigFilePath(workDir) {
|
|
119
119
|
return path.join(workDir, CONFIG_FILE_NAME);
|
|
120
120
|
}
|
|
121
|
-
function ensureCustomScriptVersion(restApi, config) {
|
|
121
|
+
function ensureCustomScriptVersion(restApi, config, skipConfirmation) {
|
|
122
122
|
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
-
const customScript = yield ensureCustomScript(restApi, config);
|
|
123
|
+
const customScript = yield ensureCustomScript(restApi, config, skipConfirmation);
|
|
124
124
|
const customScriptVersion = yield restApi.customScript.version.get({
|
|
125
125
|
customScriptUid: customScript.uid,
|
|
126
126
|
version: config.version,
|
|
@@ -128,15 +128,20 @@ function ensureCustomScriptVersion(restApi, config) {
|
|
|
128
128
|
if (customScriptVersion) {
|
|
129
129
|
return customScriptVersion;
|
|
130
130
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
131
|
+
if (skipConfirmation) {
|
|
132
|
+
(0, log_1.log)('info', chalk_1.default.yellow(`Creating Custom Script version ${config.version}`));
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
const response = yield (0, prompts_1.default)({
|
|
136
|
+
type: 'confirm',
|
|
137
|
+
name: 'newVersion',
|
|
138
|
+
message: `Do you want to create new custom script version ${config.version}?`,
|
|
139
|
+
});
|
|
140
|
+
if (!response.newVersion) {
|
|
141
|
+
throw new Error('Custom Script version creation was canceled.');
|
|
142
|
+
}
|
|
143
|
+
(0, log_1.log)('info', chalk_1.default.yellow(`Creating Custom Script version ${config.version}`));
|
|
138
144
|
}
|
|
139
|
-
(0, log_1.log)('info', chalk_1.default.yellow(`Creating Custom Script version ${config.version}`));
|
|
140
145
|
return yield restApi.customScript.version.create({
|
|
141
146
|
customScriptUid: customScript.uid,
|
|
142
147
|
version: config.version,
|
|
@@ -144,7 +149,7 @@ function ensureCustomScriptVersion(restApi, config) {
|
|
|
144
149
|
});
|
|
145
150
|
});
|
|
146
151
|
}
|
|
147
|
-
function ensureCustomScript(restApi, config) {
|
|
152
|
+
function ensureCustomScript(restApi, config, skipConfirmation) {
|
|
148
153
|
return __awaiter(this, void 0, void 0, function* () {
|
|
149
154
|
if (config.uid) {
|
|
150
155
|
const customScript = yield restApi.customScript.get(config.uid);
|
|
@@ -159,15 +164,20 @@ function ensureCustomScript(restApi, config) {
|
|
|
159
164
|
}
|
|
160
165
|
throw new Error(`Custom Script with uid "${config.uid}" not found`);
|
|
161
166
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
if (skipConfirmation) {
|
|
168
|
+
(0, log_1.log)('info', chalk_1.default.yellow(`Creating Custom Script "${config.name}"`));
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
const response = yield (0, prompts_1.default)({
|
|
172
|
+
type: 'confirm',
|
|
173
|
+
name: 'create',
|
|
174
|
+
message: `Custom Script "${config.name}" does not exist. Do you want to create it?`,
|
|
175
|
+
});
|
|
176
|
+
if (!response.create) {
|
|
177
|
+
throw new Error('Custom Script upload was canceled.');
|
|
178
|
+
}
|
|
179
|
+
(0, log_1.log)('info', chalk_1.default.yellow(`Creating Custom Script "${config.name}"`));
|
|
169
180
|
}
|
|
170
|
-
(0, log_1.log)('info', chalk_1.default.yellow(`Creating Custom Script "${config.name}"`));
|
|
171
181
|
const createdCustomScript = yield restApi.customScript.create({
|
|
172
182
|
name: config.name,
|
|
173
183
|
title: config.name, // TODO change
|