@signageos/cli 4.0.2 → 4.0.4
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 +36 -0
- package/dist/Applet/Build/appletBuildCommand.js +4 -0
- package/dist/Applet/Start/appletStartCommand.js +5 -0
- package/dist/Auth/auth0Settings.d.ts +6 -1
- package/dist/Auth/auth0Settings.js +19 -6
- package/dist/Auth/loginCommand.d.ts +9 -2
- package/dist/Auth/loginCommand.js +63 -21
- package/dist/Device/Connect/connectCommand.js +4 -0
- package/docs/login/index.md +9 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -80,6 +80,42 @@ identification=xxxxxxxxxxxxxxxxxxxx
|
|
|
80
80
|
apiSecurityToken=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
+
#### Custom deployment
|
|
84
|
+
|
|
85
|
+
When connecting to a non-default signageOS deployment, use the `--interactive-profile` flag during login. This will interactively prompt for connection settings:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
sos login --interactive-profile
|
|
89
|
+
# You will be prompted to enter:
|
|
90
|
+
# Server API URL: https://api.example.com
|
|
91
|
+
# Box URL: box.example.com
|
|
92
|
+
# Auth0 domain: auth0.example.com
|
|
93
|
+
# Auth0 client ID: <your-client-id>
|
|
94
|
+
# Auth0 audience: https://auth0.example.com/api/v2/
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The settings are saved to `~/.sosrc` and used for all subsequent commands automatically.
|
|
98
|
+
|
|
99
|
+
Alternatively, you can configure the settings directly in `~/.sosrc`:
|
|
100
|
+
```ini
|
|
101
|
+
apiUrl=https://api.example.com
|
|
102
|
+
boxUrl=box.example.com
|
|
103
|
+
auth0Domain=auth0.example.com
|
|
104
|
+
auth0ClientId=<your-client-id>
|
|
105
|
+
auth0Audience=https://auth0.example.com/api/v2/
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
All settings can also be overridden with environment variables (useful for CI/CD):
|
|
109
|
+
|
|
110
|
+
| Environment Variable | Config Field |
|
|
111
|
+
|---------------------|---------------|
|
|
112
|
+
| `SOS_API_URL` | `apiUrl` |
|
|
113
|
+
| `SOS_BOX_HOST` | `boxUrl` |
|
|
114
|
+
| `SOS_AUTH0_DOMAIN` | `auth0Domain` |
|
|
115
|
+
| `SOS_AUTH0_CLIENT_ID` | `auth0ClientId` |
|
|
116
|
+
| `SOS_AUTH0_AUDIENCE` | `auth0Audience` |
|
|
117
|
+
| `SOS_AUTH0_SCOPE` | `auth0Scope` |
|
|
118
|
+
|
|
83
119
|
### Applet
|
|
84
120
|
```bash
|
|
85
121
|
sos applet --help
|
|
@@ -22,6 +22,7 @@ const appletFacade_1 = require("../appletFacade");
|
|
|
22
22
|
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
23
23
|
const debug_1 = __importDefault(require("debug"));
|
|
24
24
|
const appletValidation_1 = require("../appletValidation");
|
|
25
|
+
const runControlHelper_1 = require("../../RunControl/runControlHelper");
|
|
25
26
|
const Debug = (0, debug_1.default)('@signageos/cli:Applet:Build:appletBuildCommand');
|
|
26
27
|
exports.OPTION_LIST = [organizationFacade_1.NO_DEFAULT_ORGANIZATION_OPTION, organizationFacade_1.ORGANIZATION_UID_OPTION, appletFacade_1.APPLET_UID_OPTION];
|
|
27
28
|
/**
|
|
@@ -61,8 +62,11 @@ exports.appletBuild = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
61
62
|
const organizationUid = yield (0, organizationFacade_1.getOrganizationUidOrDefaultOrSelect)(options);
|
|
62
63
|
const organization = yield (0, organizationFacade_1.getOrganization)(organizationUid);
|
|
63
64
|
const restApi = yield (0, helper_1.createOrganizationRestApi)(organization);
|
|
65
|
+
const config = yield (0, runControlHelper_1.loadConfig)();
|
|
64
66
|
const dev = (0, dist_1.createDevelopment)({
|
|
65
67
|
organizationUid: organization.uid,
|
|
68
|
+
url: (0, helper_1.getApiUrl)(config),
|
|
69
|
+
accessToken: config.accessToken,
|
|
66
70
|
});
|
|
67
71
|
const appletUid = yield (0, appletFacade_1.getAppletUid)(restApi, options);
|
|
68
72
|
const appletVersion = yield (0, appletFacade_1.getAppletVersion)(currentDirectory);
|
|
@@ -21,6 +21,8 @@ const commandDefinition_1 = require("../../Command/commandDefinition");
|
|
|
21
21
|
const organizationFacade_1 = require("../../Organization/organizationFacade");
|
|
22
22
|
const dist_1 = require("@signageos/sdk/dist");
|
|
23
23
|
const wait_1 = __importDefault(require("../../Timer/wait"));
|
|
24
|
+
const runControlHelper_1 = require("../../RunControl/runControlHelper");
|
|
25
|
+
const helper_1 = require("../../helper");
|
|
24
26
|
const appletServerHelper_1 = require("../appletServerHelper");
|
|
25
27
|
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
26
28
|
const parameters_1 = require("../../parameters");
|
|
@@ -102,8 +104,11 @@ exports.appletStart = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
102
104
|
const entryFileAbsolutePath = yield (0, appletUploadCommandHelper_1.getAppletEntryFileAbsolutePath)(currentDirectory, options);
|
|
103
105
|
const entryFileRelativePath = (0, appletUploadCommandHelper_1.getAppletEntryFileRelativePath)(entryFileAbsolutePath, appletPath);
|
|
104
106
|
const emulatorUid = yield (0, emulatorFacade_1.loadEmulatorOrCreateNewAndReturnUid)(organizationUid);
|
|
107
|
+
const config = yield (0, runControlHelper_1.loadConfig)();
|
|
105
108
|
const dev = (0, dist_1.createDevelopment)({
|
|
106
109
|
organizationUid,
|
|
110
|
+
url: (0, helper_1.getApiUrl)(config),
|
|
111
|
+
accessToken: config.accessToken,
|
|
107
112
|
});
|
|
108
113
|
const emulatorServerPort = (_a = options[PORT_OPTION.name]) !== null && _a !== void 0 ? _a : DEFAULT_PORT;
|
|
109
114
|
const hotReloadEnabled = options[appletServerHelper_1.HOT_RELOAD_OPTION.name];
|
|
@@ -3,6 +3,11 @@ import { Auth0Settings } from '@signageos/cli-common';
|
|
|
3
3
|
* Auth0 settings for the signageOS CLI tool (regular API).
|
|
4
4
|
*
|
|
5
5
|
* These connect to the regular signageOS API (not admin API).
|
|
6
|
-
*
|
|
6
|
+
* Precedence: environment variable > profile field in ~/.sosrc > .env default.
|
|
7
7
|
*/
|
|
8
8
|
export declare function getAuth0Settings(): Auth0Settings;
|
|
9
|
+
/**
|
|
10
|
+
* Read the Box URL from the active profile.
|
|
11
|
+
* Precedence: profile field in ~/.sosrc > environment variable (.env default).
|
|
12
|
+
*/
|
|
13
|
+
export declare function getBoxUrl(): string;
|
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getAuth0Settings = getAuth0Settings;
|
|
4
|
+
exports.getBoxUrl = getBoxUrl;
|
|
5
|
+
const cli_common_1 = require("@signageos/cli-common");
|
|
6
|
+
const globalArgs_1 = require("../Command/globalArgs");
|
|
4
7
|
/**
|
|
5
8
|
* Auth0 settings for the signageOS CLI tool (regular API).
|
|
6
9
|
*
|
|
7
10
|
* These connect to the regular signageOS API (not admin API).
|
|
8
|
-
*
|
|
11
|
+
* Precedence: environment variable > profile field in ~/.sosrc > .env default.
|
|
9
12
|
*/
|
|
10
13
|
function getAuth0Settings() {
|
|
11
|
-
var _a, _b, _c, _d;
|
|
14
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
15
|
+
const profile = (0, globalArgs_1.getGlobalProfile)();
|
|
12
16
|
return {
|
|
13
|
-
domain: (_a = process.env.SOS_AUTH0_DOMAIN) !== null &&
|
|
14
|
-
clientId: (
|
|
15
|
-
audience: (
|
|
16
|
-
scope: (
|
|
17
|
+
domain: (_b = (_a = (0, cli_common_1.readProfileField)('auth0Domain', profile)) !== null && _a !== void 0 ? _a : process.env.SOS_AUTH0_DOMAIN) !== null && _b !== void 0 ? _b : '',
|
|
18
|
+
clientId: (_d = (_c = (0, cli_common_1.readProfileField)('auth0ClientId', profile)) !== null && _c !== void 0 ? _c : process.env.SOS_AUTH0_CLIENT_ID) !== null && _d !== void 0 ? _d : '',
|
|
19
|
+
audience: (_f = (_e = (0, cli_common_1.readProfileField)('auth0Audience', profile)) !== null && _e !== void 0 ? _e : process.env.SOS_AUTH0_AUDIENCE) !== null && _f !== void 0 ? _f : '',
|
|
20
|
+
scope: (_h = (_g = (0, cli_common_1.readProfileField)('auth0Scope', profile)) !== null && _g !== void 0 ? _g : process.env.SOS_AUTH0_SCOPE) !== null && _h !== void 0 ? _h : '',
|
|
17
21
|
};
|
|
18
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Read the Box URL from the active profile.
|
|
25
|
+
* Precedence: profile field in ~/.sosrc > environment variable (.env default).
|
|
26
|
+
*/
|
|
27
|
+
function getBoxUrl() {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
const profile = (0, globalArgs_1.getGlobalProfile)();
|
|
30
|
+
return (_b = (_a = (0, cli_common_1.readProfileField)('boxUrl', profile)) !== null && _a !== void 0 ? _a : process.env.SOS_BOX_HOST) !== null && _b !== void 0 ? _b : '';
|
|
31
|
+
}
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
* # Interactive login (opens browser for Auth0 authentication)
|
|
11
11
|
* sos login
|
|
12
12
|
*
|
|
13
|
+
* # Login with custom configuration (prompts for Auth0 and connection settings)
|
|
14
|
+
* sos login --interactive-profile
|
|
15
|
+
*
|
|
13
16
|
* # Login with a specific profile
|
|
14
17
|
* sos --profile staging login
|
|
15
18
|
* ```
|
|
@@ -19,7 +22,11 @@
|
|
|
19
22
|
export declare const login: {
|
|
20
23
|
name: "login";
|
|
21
24
|
description: string;
|
|
22
|
-
optionList:
|
|
25
|
+
optionList: readonly [{
|
|
26
|
+
readonly name: "interactive-profile";
|
|
27
|
+
readonly type: BooleanConstructor;
|
|
28
|
+
readonly description: "Prompt for custom Auth0 and connection settings (for custom deployments)";
|
|
29
|
+
}];
|
|
23
30
|
commands: never[];
|
|
24
|
-
run(): Promise<void>;
|
|
31
|
+
run(options: import("../Command/commandDefinition").CommandLineOptions<readonly Readonly<Readonly<import("command-line-args").OptionDefinition & import("command-line-usage").OptionDefinition>>[]>): Promise<void>;
|
|
25
32
|
};
|
|
@@ -17,7 +17,6 @@ const node_child_process_1 = require("node:child_process");
|
|
|
17
17
|
const node_os_1 = require("node:os");
|
|
18
18
|
const chalk_1 = __importDefault(require("chalk"));
|
|
19
19
|
const prompts_1 = __importDefault(require("prompts"));
|
|
20
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
21
20
|
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
22
21
|
const sosControlHelper_1 = require("@signageos/sdk/dist/SosHelper/sosControlHelper");
|
|
23
22
|
const cli_common_1 = require("@signageos/cli-common");
|
|
@@ -37,6 +36,13 @@ function openInBrowser(url) {
|
|
|
37
36
|
}
|
|
38
37
|
});
|
|
39
38
|
}
|
|
39
|
+
const LOGIN_OPTION_LIST = [
|
|
40
|
+
{
|
|
41
|
+
name: 'interactive-profile',
|
|
42
|
+
type: Boolean,
|
|
43
|
+
description: 'Prompt for custom Auth0 and connection settings (for custom deployments)',
|
|
44
|
+
},
|
|
45
|
+
];
|
|
40
46
|
/**
|
|
41
47
|
* Authenticates the user via the Auth0 Device Authorization Flow.
|
|
42
48
|
* Opens a browser-based verification page where the user logs in,
|
|
@@ -49,6 +55,9 @@ function openInBrowser(url) {
|
|
|
49
55
|
* # Interactive login (opens browser for Auth0 authentication)
|
|
50
56
|
* sos login
|
|
51
57
|
*
|
|
58
|
+
* # Login with custom configuration (prompts for Auth0 and connection settings)
|
|
59
|
+
* sos login --interactive-profile
|
|
60
|
+
*
|
|
52
61
|
* # Login with a specific profile
|
|
53
62
|
* sos --profile staging login
|
|
54
63
|
* ```
|
|
@@ -58,35 +67,68 @@ function openInBrowser(url) {
|
|
|
58
67
|
exports.login = (0, commandDefinition_1.createCommandDefinition)({
|
|
59
68
|
name: 'login',
|
|
60
69
|
description: 'Authenticate user with signageOS via Auth0',
|
|
61
|
-
optionList:
|
|
70
|
+
optionList: LOGIN_OPTION_LIST,
|
|
62
71
|
commands: [],
|
|
63
|
-
run() {
|
|
72
|
+
run(options) {
|
|
64
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
-
var _a;
|
|
74
|
+
var _a, _b, _c, _d, _e, _f;
|
|
66
75
|
const profile = (0, globalArgs_1.getGlobalProfile)();
|
|
67
76
|
const configFilePath = (0, sosControlHelper_1.getConfigFilePath)();
|
|
68
|
-
|
|
69
|
-
if (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
77
|
+
const interactiveProfile = options['interactive-profile'];
|
|
78
|
+
if (interactiveProfile) {
|
|
79
|
+
(0, log_1.log)('info', `Setting up custom connection settings in ${configFilePath}.`);
|
|
80
|
+
const { inputApiUrl } = yield (0, prompts_1.default)({
|
|
81
|
+
type: 'text',
|
|
82
|
+
name: 'inputApiUrl',
|
|
83
|
+
message: 'Server API URL',
|
|
84
|
+
initial: (_a = process.env.SOS_API_URL) !== null && _a !== void 0 ? _a : 'https://api.signageos.io',
|
|
85
|
+
validate: (v) => (v.startsWith('http') ? true : 'Must be a valid URL starting with http'),
|
|
86
|
+
});
|
|
87
|
+
if (!inputApiUrl) {
|
|
88
|
+
throw new Error('API URL is required to log in.');
|
|
89
|
+
}
|
|
90
|
+
(0, cli_common_1.writeProfileField)('apiUrl', inputApiUrl.replace(/\/+$/, ''), profile);
|
|
91
|
+
const { inputBoxUrl } = yield (0, prompts_1.default)({
|
|
92
|
+
type: 'text',
|
|
93
|
+
name: 'inputBoxUrl',
|
|
94
|
+
message: 'Box URL',
|
|
95
|
+
initial: (_b = process.env.SOS_BOX_HOST) !== null && _b !== void 0 ? _b : 'box.signageos.io',
|
|
96
|
+
});
|
|
97
|
+
if (inputBoxUrl) {
|
|
98
|
+
(0, cli_common_1.writeProfileField)('boxUrl', inputBoxUrl.replace(/\/+$/, ''), profile);
|
|
99
|
+
}
|
|
100
|
+
const { inputAuth0Domain } = yield (0, prompts_1.default)({
|
|
101
|
+
type: 'text',
|
|
102
|
+
name: 'inputAuth0Domain',
|
|
103
|
+
message: 'Auth0 domain',
|
|
104
|
+
initial: (_c = process.env.SOS_AUTH0_DOMAIN) !== null && _c !== void 0 ? _c : 'auth0.signageos.io',
|
|
105
|
+
});
|
|
106
|
+
if (inputAuth0Domain) {
|
|
107
|
+
(0, cli_common_1.writeProfileField)('auth0Domain', inputAuth0Domain, profile);
|
|
108
|
+
}
|
|
109
|
+
const { inputAuth0ClientId } = yield (0, prompts_1.default)({
|
|
110
|
+
type: 'text',
|
|
111
|
+
name: 'inputAuth0ClientId',
|
|
112
|
+
message: 'Auth0 client ID',
|
|
113
|
+
initial: (_d = process.env.SOS_AUTH0_CLIENT_ID) !== null && _d !== void 0 ? _d : '',
|
|
114
|
+
});
|
|
115
|
+
if (inputAuth0ClientId) {
|
|
116
|
+
(0, cli_common_1.writeProfileField)('auth0ClientId', inputAuth0ClientId, profile);
|
|
117
|
+
}
|
|
118
|
+
const { inputAuth0Audience } = yield (0, prompts_1.default)({
|
|
119
|
+
type: 'text',
|
|
120
|
+
name: 'inputAuth0Audience',
|
|
121
|
+
message: 'Auth0 audience',
|
|
122
|
+
initial: (_e = process.env.SOS_AUTH0_AUDIENCE) !== null && _e !== void 0 ? _e : '',
|
|
123
|
+
});
|
|
124
|
+
if (inputAuth0Audience) {
|
|
125
|
+
(0, cli_common_1.writeProfileField)('auth0Audience', inputAuth0Audience, profile);
|
|
84
126
|
}
|
|
85
127
|
}
|
|
86
128
|
const auth0 = (0, auth0Settings_1.getAuth0Settings)();
|
|
87
129
|
(0, log_1.log)('info', 'Starting Auth0 Device Authorization Flow...');
|
|
88
130
|
const deviceCode = yield (0, cli_common_1.requestDeviceCode)(auth0);
|
|
89
|
-
const verificationUrl = (
|
|
131
|
+
const verificationUrl = (_f = deviceCode.verification_uri_complete) !== null && _f !== void 0 ? _f : deviceCode.verification_uri;
|
|
90
132
|
// Try to open the verification URL in the default browser
|
|
91
133
|
openInBrowser(verificationUrl);
|
|
92
134
|
console.info('');
|
|
@@ -20,6 +20,7 @@ const helper_1 = require("../../helper");
|
|
|
20
20
|
const commandDefinition_1 = require("../../Command/commandDefinition");
|
|
21
21
|
const sdk_1 = require("@signageos/sdk");
|
|
22
22
|
const wait_1 = __importDefault(require("../../Timer/wait"));
|
|
23
|
+
const runControlHelper_1 = require("../../RunControl/runControlHelper");
|
|
23
24
|
const appletServerHelper_1 = require("../../Applet/appletServerHelper");
|
|
24
25
|
const debug_1 = __importDefault(require("debug"));
|
|
25
26
|
const appletUploadCommandHelper_1 = require("../../Applet/Upload/appletUploadCommandHelper");
|
|
@@ -106,8 +107,11 @@ exports.connect = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
106
107
|
const organizationUid = yield (0, organizationFacade_1.getOrganizationUidOrDefaultOrSelect)(options);
|
|
107
108
|
const organization = yield (0, organizationFacade_1.getOrganization)(organizationUid);
|
|
108
109
|
const restApi = yield (0, helper_1.createOrganizationRestApi)(organization);
|
|
110
|
+
const config = yield (0, runControlHelper_1.loadConfig)();
|
|
109
111
|
const dev = (0, sdk_1.createDevelopment)({
|
|
110
112
|
organizationUid: organization.uid,
|
|
113
|
+
url: (0, helper_1.getApiUrl)(config),
|
|
114
|
+
accessToken: config.accessToken,
|
|
111
115
|
});
|
|
112
116
|
const appletUid = yield (0, appletFacade_1.getAppletUid)(restApi, options);
|
|
113
117
|
const appletVersion = yield (0, appletFacade_1.getAppletVersion)(currentDirectory);
|
package/docs/login/index.md
CHANGED
|
@@ -20,12 +20,21 @@ then stores the resulting JWT tokens in `~/.sosrc`.
|
|
|
20
20
|
sos login [options]
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
## Options
|
|
24
|
+
|
|
25
|
+
| Option | Description |
|
|
26
|
+
| ----------------------- | ---------------------------------------------------------------------------------- |
|
|
27
|
+
| `--interactive-profile` | Prompt for custom Auth0 and connection settings (for custom deployments) (boolean) |
|
|
28
|
+
|
|
23
29
|
## Examples
|
|
24
30
|
|
|
25
31
|
```bash
|
|
26
32
|
# Interactive login (opens browser for Auth0 authentication)
|
|
27
33
|
sos login
|
|
28
34
|
|
|
35
|
+
# Login with custom configuration (prompts for Auth0 and connection settings)
|
|
36
|
+
sos login --interactive-profile
|
|
37
|
+
|
|
29
38
|
# Login with a specific profile
|
|
30
39
|
sos --profile staging login
|
|
31
40
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signageos/cli",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"author": "signageOS.io <dev@signageos.io>",
|
|
6
6
|
"files": [
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"dependencies": {
|
|
88
88
|
"@signageos/cli-common": "0.1.0",
|
|
89
89
|
"@signageos/file": "2.0.1",
|
|
90
|
-
"@signageos/sdk": "2.
|
|
90
|
+
"@signageos/sdk": "2.7.0",
|
|
91
91
|
"archiver": "7.0.1",
|
|
92
92
|
"chalk": "2.4.2",
|
|
93
93
|
"child-process-promise": "2.1.3",
|