@signageos/cli 4.0.3 → 4.0.5
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/.env.production +7 -0
- package/README.md +36 -0
- package/dist/Applet/Build/appletBuildCommand.js +2 -2
- package/dist/Applet/Start/appletStartCommand.js +2 -2
- package/dist/Applet/Upload/appletUploadCommand.js +3 -2
- 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/Development/developmentFactory.d.ts +12 -0
- package/dist/Development/developmentFactory.js +30 -0
- package/dist/Device/Connect/connectCommand.js +2 -2
- package/dist/RunControl/runControlHelper.js +7 -5
- package/dist/helper/paginationHelper.d.ts +1 -1
- package/dist/helper.js +17 -7
- package/dist/index.js +1 -0
- package/dist/parameters.js +6 -3
- package/docs/login/index.md +9 -0
- package/package.json +3 -2
package/.env.production
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
SOS_DEFAULT_API_URL=https://api.signageos.io
|
|
2
|
+
SOS_DEFAULT_BOX_HOST=box.signageos.io
|
|
3
|
+
SOS_DEFAULT_FORWARD_SERVER_URL=https://forward.signageos.io
|
|
4
|
+
SOS_DEFAULT_AUTH0_DOMAIN=auth0.signageos.io
|
|
5
|
+
SOS_DEFAULT_AUTH0_CLIENT_ID=8AU8D3zJ4mK8gszZP3gZO0nv9DusSNjV
|
|
6
|
+
SOS_DEFAULT_AUTH0_AUDIENCE=https://sos-production.us.auth0.com/api/v2/
|
|
7
|
+
SOS_DEFAULT_AUTH0_SCOPE=openid profile email offline_access
|
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
|
|
@@ -17,7 +17,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
17
17
|
const commandDefinition_1 = require("../../Command/commandDefinition");
|
|
18
18
|
const organizationFacade_1 = require("../../Organization/organizationFacade");
|
|
19
19
|
const helper_1 = require("../../helper");
|
|
20
|
-
const
|
|
20
|
+
const developmentFactory_1 = require("../../Development/developmentFactory");
|
|
21
21
|
const appletFacade_1 = require("../appletFacade");
|
|
22
22
|
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
23
23
|
const debug_1 = __importDefault(require("debug"));
|
|
@@ -63,7 +63,7 @@ exports.appletBuild = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
63
63
|
const organization = yield (0, organizationFacade_1.getOrganization)(organizationUid);
|
|
64
64
|
const restApi = yield (0, helper_1.createOrganizationRestApi)(organization);
|
|
65
65
|
const config = yield (0, runControlHelper_1.loadConfig)();
|
|
66
|
-
const dev = (0,
|
|
66
|
+
const dev = (0, developmentFactory_1.createDevelopmentWithOptions)({
|
|
67
67
|
organizationUid: organization.uid,
|
|
68
68
|
url: (0, helper_1.getApiUrl)(config),
|
|
69
69
|
accessToken: config.accessToken,
|
|
@@ -19,7 +19,7 @@ const appletUploadCommandHelper_1 = require("../Upload/appletUploadCommandHelper
|
|
|
19
19
|
const emulatorFacade_1 = require("../../Emulator/emulatorFacade");
|
|
20
20
|
const commandDefinition_1 = require("../../Command/commandDefinition");
|
|
21
21
|
const organizationFacade_1 = require("../../Organization/organizationFacade");
|
|
22
|
-
const
|
|
22
|
+
const developmentFactory_1 = require("../../Development/developmentFactory");
|
|
23
23
|
const wait_1 = __importDefault(require("../../Timer/wait"));
|
|
24
24
|
const runControlHelper_1 = require("../../RunControl/runControlHelper");
|
|
25
25
|
const helper_1 = require("../../helper");
|
|
@@ -105,7 +105,7 @@ exports.appletStart = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
105
105
|
const entryFileRelativePath = (0, appletUploadCommandHelper_1.getAppletEntryFileRelativePath)(entryFileAbsolutePath, appletPath);
|
|
106
106
|
const emulatorUid = yield (0, emulatorFacade_1.loadEmulatorOrCreateNewAndReturnUid)(organizationUid);
|
|
107
107
|
const config = yield (0, runControlHelper_1.loadConfig)();
|
|
108
|
-
const dev = (0,
|
|
108
|
+
const dev = (0, developmentFactory_1.createDevelopmentWithOptions)({
|
|
109
109
|
organizationUid,
|
|
110
110
|
url: (0, helper_1.getApiUrl)(config),
|
|
111
111
|
accessToken: config.accessToken,
|
|
@@ -61,7 +61,7 @@ const packageConfig_1 = require("@signageos/sdk/dist/FileSystem/packageConfig");
|
|
|
61
61
|
const commandDefinition_1 = require("../../Command/commandDefinition");
|
|
62
62
|
const appletErrors_1 = require("../appletErrors");
|
|
63
63
|
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
64
|
-
const
|
|
64
|
+
const AppletFilesManagement_1 = require("@signageos/sdk/dist/Development/Applet/Files/AppletFilesManagement");
|
|
65
65
|
const GatewayError_1 = __importDefault(require("@signageos/sdk/dist/RestApi/Error/GatewayError"));
|
|
66
66
|
const NotFoundError_1 = __importDefault(require("@signageos/sdk/dist/RestApi/Error/NotFoundError"));
|
|
67
67
|
const appletValidation_1 = require("../appletValidation");
|
|
@@ -226,7 +226,8 @@ exports.appletUpload = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
226
226
|
const allowVerbose = options[verbose];
|
|
227
227
|
const appletFiles = [];
|
|
228
228
|
if (!isSingleFileApplet) {
|
|
229
|
-
const
|
|
229
|
+
const appletFilesManagement = new AppletFilesManagement_1.AppletFilesManagement();
|
|
230
|
+
const appletFilePaths = yield appletFilesManagement.listAppletFiles({
|
|
230
231
|
appletPath: appletDirectoryPath,
|
|
231
232
|
});
|
|
232
233
|
yield (0, fileSystem_1.validateAllFormalities)(appletDirectoryPath, appletEntryFilePath, appletFilePaths);
|
|
@@ -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: SOS_AUTH0_* env var (user-explicit override) > profile field in ~/.sosrc > SOS_DEFAULT_AUTH0_* env var (package default).
|
|
7
7
|
*/
|
|
8
8
|
export declare function getAuth0Settings(): Auth0Settings;
|
|
9
|
+
/**
|
|
10
|
+
* Read the Box URL from the active profile.
|
|
11
|
+
* Precedence: SOS_BOX_HOST env var (user-explicit override) > profile field in ~/.sosrc > SOS_DEFAULT_BOX_HOST env var (package 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: SOS_AUTH0_* env var (user-explicit override) > profile field in ~/.sosrc > SOS_DEFAULT_AUTH0_* env var (package default).
|
|
9
12
|
*/
|
|
10
13
|
function getAuth0Settings() {
|
|
11
|
-
var _a, _b, _c, _d;
|
|
14
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
15
|
+
const profile = (0, globalArgs_1.getGlobalProfile)();
|
|
12
16
|
return {
|
|
13
|
-
domain: (_a = process.env.SOS_AUTH0_DOMAIN) !== null && _a !== void 0 ? _a : '
|
|
14
|
-
clientId: (
|
|
15
|
-
audience: (
|
|
16
|
-
scope: (
|
|
17
|
+
domain: (_c = (_b = (_a = process.env.SOS_AUTH0_DOMAIN) !== null && _a !== void 0 ? _a : (0, cli_common_1.readProfileField)('auth0Domain', profile)) !== null && _b !== void 0 ? _b : process.env.SOS_DEFAULT_AUTH0_DOMAIN) !== null && _c !== void 0 ? _c : '',
|
|
18
|
+
clientId: (_f = (_e = (_d = process.env.SOS_AUTH0_CLIENT_ID) !== null && _d !== void 0 ? _d : (0, cli_common_1.readProfileField)('auth0ClientId', profile)) !== null && _e !== void 0 ? _e : process.env.SOS_DEFAULT_AUTH0_CLIENT_ID) !== null && _f !== void 0 ? _f : '',
|
|
19
|
+
audience: (_j = (_h = (_g = process.env.SOS_AUTH0_AUDIENCE) !== null && _g !== void 0 ? _g : (0, cli_common_1.readProfileField)('auth0Audience', profile)) !== null && _h !== void 0 ? _h : process.env.SOS_DEFAULT_AUTH0_AUDIENCE) !== null && _j !== void 0 ? _j : '',
|
|
20
|
+
scope: (_m = (_l = (_k = process.env.SOS_AUTH0_SCOPE) !== null && _k !== void 0 ? _k : (0, cli_common_1.readProfileField)('auth0Scope', profile)) !== null && _l !== void 0 ? _l : process.env.SOS_DEFAULT_AUTH0_SCOPE) !== null && _m !== void 0 ? _m : '',
|
|
17
21
|
};
|
|
18
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Read the Box URL from the active profile.
|
|
25
|
+
* Precedence: SOS_BOX_HOST env var (user-explicit override) > profile field in ~/.sosrc > SOS_DEFAULT_BOX_HOST env var (package default).
|
|
26
|
+
*/
|
|
27
|
+
function getBoxUrl() {
|
|
28
|
+
var _a, _b, _c;
|
|
29
|
+
const profile = (0, globalArgs_1.getGlobalProfile)();
|
|
30
|
+
return (_c = (_b = (_a = process.env.SOS_BOX_HOST) !== null && _a !== void 0 ? _a : (0, cli_common_1.readProfileField)('boxUrl', profile)) !== null && _b !== void 0 ? _b : process.env.SOS_DEFAULT_BOX_HOST) !== null && _c !== void 0 ? _c : '';
|
|
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, _g, _h, _j, _k, _l;
|
|
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: (_b = (_a = process.env.SOS_API_URL) !== null && _a !== void 0 ? _a : process.env.SOS_DEFAULT_API_URL) !== null && _b !== void 0 ? _b : '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: (_d = (_c = process.env.SOS_BOX_HOST) !== null && _c !== void 0 ? _c : process.env.SOS_DEFAULT_BOX_HOST) !== null && _d !== void 0 ? _d : '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: (_f = (_e = process.env.SOS_AUTH0_DOMAIN) !== null && _e !== void 0 ? _e : process.env.SOS_DEFAULT_AUTH0_DOMAIN) !== null && _f !== void 0 ? _f : '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: (_h = (_g = process.env.SOS_AUTH0_CLIENT_ID) !== null && _g !== void 0 ? _g : process.env.SOS_DEFAULT_AUTH0_CLIENT_ID) !== null && _h !== void 0 ? _h : '',
|
|
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: (_k = (_j = process.env.SOS_AUTH0_AUDIENCE) !== null && _j !== void 0 ? _j : process.env.SOS_DEFAULT_AUTH0_AUDIENCE) !== null && _k !== void 0 ? _k : '',
|
|
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 = (_l = deviceCode.verification_uri_complete) !== null && _l !== void 0 ? _l : deviceCode.verification_uri;
|
|
90
132
|
// Try to open the verification URL in the default browser
|
|
91
133
|
openInBrowser(verificationUrl);
|
|
92
134
|
console.info('');
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Development } from '@signageos/sdk/dist/Development/Development';
|
|
2
|
+
export interface IDevelopmentFactoryOptions {
|
|
3
|
+
url: string;
|
|
4
|
+
accessToken?: string;
|
|
5
|
+
organizationUid?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Creates a Development instance using deep SDK imports only.
|
|
9
|
+
* Does NOT touch the SDK barrel or its implicit parameters.
|
|
10
|
+
* All configuration is passed explicitly.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createDevelopmentWithOptions(opts: IDevelopmentFactoryOptions): Development;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createDevelopmentWithOptions = createDevelopmentWithOptions;
|
|
7
|
+
const RestApi_1 = __importDefault(require("@signageos/sdk/dist/RestApi/RestApi"));
|
|
8
|
+
const RestApiV2_1 = __importDefault(require("@signageos/sdk/dist/RestApi/RestApiV2"));
|
|
9
|
+
const Development_1 = require("@signageos/sdk/dist/Development/Development");
|
|
10
|
+
const apiVersions_1 = require("@signageos/sdk/dist/RestApi/apiVersions");
|
|
11
|
+
const helper_1 = require("../helper");
|
|
12
|
+
/**
|
|
13
|
+
* Creates a Development instance using deep SDK imports only.
|
|
14
|
+
* Does NOT touch the SDK barrel or its implicit parameters.
|
|
15
|
+
* All configuration is passed explicitly.
|
|
16
|
+
*/
|
|
17
|
+
function createDevelopmentWithOptions(opts) {
|
|
18
|
+
const auth = opts.accessToken ? { accessToken: opts.accessToken } : { clientId: '', secret: '' };
|
|
19
|
+
const baseV1 = {
|
|
20
|
+
url: opts.url,
|
|
21
|
+
auth,
|
|
22
|
+
version: apiVersions_1.ApiVersions.V1,
|
|
23
|
+
clientVersions: (0, helper_1.createClientVersions)(),
|
|
24
|
+
organizationUid: opts.organizationUid,
|
|
25
|
+
};
|
|
26
|
+
const baseV2 = Object.assign(Object.assign({}, baseV1), { version: apiVersions_1.ApiVersions.V2 });
|
|
27
|
+
const v1 = new RestApi_1.default(baseV1, Object.assign(Object.assign({}, baseV1), { organizationUid: undefined }));
|
|
28
|
+
const v2 = new RestApiV2_1.default(baseV2, Object.assign(Object.assign({}, baseV2), { organizationUid: undefined }));
|
|
29
|
+
return new Development_1.Development(v1, v2);
|
|
30
|
+
}
|
|
@@ -18,7 +18,7 @@ const organizationFacade_1 = require("../../Organization/organizationFacade");
|
|
|
18
18
|
const appletFacade_1 = require("../../Applet/appletFacade");
|
|
19
19
|
const helper_1 = require("../../helper");
|
|
20
20
|
const commandDefinition_1 = require("../../Command/commandDefinition");
|
|
21
|
-
const
|
|
21
|
+
const developmentFactory_1 = require("../../Development/developmentFactory");
|
|
22
22
|
const wait_1 = __importDefault(require("../../Timer/wait"));
|
|
23
23
|
const runControlHelper_1 = require("../../RunControl/runControlHelper");
|
|
24
24
|
const appletServerHelper_1 = require("../../Applet/appletServerHelper");
|
|
@@ -108,7 +108,7 @@ exports.connect = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
108
108
|
const organization = yield (0, organizationFacade_1.getOrganization)(organizationUid);
|
|
109
109
|
const restApi = yield (0, helper_1.createOrganizationRestApi)(organization);
|
|
110
110
|
const config = yield (0, runControlHelper_1.loadConfig)();
|
|
111
|
-
const dev = (0,
|
|
111
|
+
const dev = (0, developmentFactory_1.createDevelopmentWithOptions)({
|
|
112
112
|
organizationUid: organization.uid,
|
|
113
113
|
url: (0, helper_1.getApiUrl)(config),
|
|
114
114
|
accessToken: config.accessToken,
|
|
@@ -26,9 +26,12 @@ function loadConfig() {
|
|
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
const profile = (0, globalArgs_1.getGlobalProfile)();
|
|
28
28
|
const config = yield (0, sosControlHelper_1.loadConfig)({ profile });
|
|
29
|
+
Debug('Loaded base config from .sosrc (profile=%o): apiUrl=%o', profile !== null && profile !== void 0 ? profile : '<default>', config.apiUrl);
|
|
29
30
|
// Override with environment variables if they exist.
|
|
30
|
-
//
|
|
31
|
-
//
|
|
31
|
+
// Note: SOS_API_URL is intentionally NOT applied here — it is resolved together
|
|
32
|
+
// with --api-url and SOS_DEFAULT_API_URL in helper.getApiUrl(), so the full
|
|
33
|
+
// precedence chain (cli > SOS_API_URL > .sosrc > SOS_DEFAULT_API_URL) is honored
|
|
34
|
+
// in a single place.
|
|
32
35
|
const envOverride = {};
|
|
33
36
|
if (process.env.SOS_API_IDENTIFICATION) {
|
|
34
37
|
envOverride.identification = process.env.SOS_API_IDENTIFICATION;
|
|
@@ -39,10 +42,9 @@ function loadConfig() {
|
|
|
39
42
|
if (process.env.SOS_ORGANIZATION_UID) {
|
|
40
43
|
envOverride.defaultOrganizationUid = process.env.SOS_ORGANIZATION_UID;
|
|
41
44
|
}
|
|
42
|
-
|
|
43
|
-
envOverride.apiUrl = process.env.SOS_API_URL;
|
|
44
|
-
}
|
|
45
|
+
Debug('Env overrides applied: %o', Object.keys(envOverride));
|
|
45
46
|
const finalConfig = Object.assign(Object.assign({}, config), envOverride);
|
|
47
|
+
Debug('Final config: apiUrl=%o defaultOrganizationUid=%o', finalConfig.apiUrl, finalConfig.defaultOrganizationUid);
|
|
46
48
|
// Check for SOS_ACCESS_TOKEN env var (CI-friendly JWT override)
|
|
47
49
|
const envToken = process.env.SOS_ACCESS_TOKEN;
|
|
48
50
|
if (envToken) {
|
package/dist/helper.js
CHANGED
|
@@ -27,11 +27,13 @@ exports.deserializeJSON = deserializeJSON;
|
|
|
27
27
|
exports.getErrorMessageFromUnknownError = getErrorMessageFromUnknownError;
|
|
28
28
|
exports.autocompleteSuggest = autocompleteSuggest;
|
|
29
29
|
const querystring_1 = require("querystring");
|
|
30
|
+
const debug_1 = __importDefault(require("debug"));
|
|
30
31
|
const RestApi_1 = __importDefault(require("@signageos/sdk/dist/RestApi/RestApi"));
|
|
31
32
|
const runControlHelper_1 = require("./RunControl/runControlHelper");
|
|
32
33
|
const apiVersions_1 = require("@signageos/sdk/dist/RestApi/apiVersions");
|
|
33
34
|
const parameters_1 = require("./parameters");
|
|
34
35
|
const globalArgs_1 = require("./Command/globalArgs");
|
|
36
|
+
const Debug = (0, debug_1.default)('@signageos/cli:helper');
|
|
35
37
|
function loadApiUrl() {
|
|
36
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
39
|
const config = yield (0, runControlHelper_1.loadConfig)();
|
|
@@ -39,13 +41,17 @@ function loadApiUrl() {
|
|
|
39
41
|
});
|
|
40
42
|
}
|
|
41
43
|
function getApiUrl(config) {
|
|
42
|
-
// Precedence:
|
|
43
|
-
// 1.
|
|
44
|
-
// 2.
|
|
45
|
-
// 3.
|
|
44
|
+
// Precedence (highest to lowest):
|
|
45
|
+
// 1. CLI --api-url argument
|
|
46
|
+
// 2. SOS_API_URL env var (user-explicit override, for CI/CD)
|
|
47
|
+
// 3. config.apiUrl (.sosrc field — user's saved profile)
|
|
48
|
+
// 4. SOS_DEFAULT_API_URL env var (package default from .env.production)
|
|
46
49
|
const cliUrl = (0, globalArgs_1.getGlobalApiUrl)();
|
|
50
|
+
const envUrl = process.env.SOS_API_URL;
|
|
47
51
|
const profileUrl = config.apiUrl;
|
|
48
|
-
const
|
|
52
|
+
const defaultUrl = process.env.SOS_DEFAULT_API_URL;
|
|
53
|
+
const rawApiUrl = cliUrl || envUrl || profileUrl || defaultUrl;
|
|
54
|
+
Debug('API URL resolution: cli=%o env(SOS_API_URL)=%o profile=%o env(SOS_DEFAULT_API_URL)=%o resolved=%o', cliUrl, envUrl, profileUrl, defaultUrl, rawApiUrl);
|
|
49
55
|
if (!rawApiUrl) {
|
|
50
56
|
throw new Error(`No API URL is defined. Please use --api-url or set SOS_API_URL environment variable.`);
|
|
51
57
|
}
|
|
@@ -63,8 +69,10 @@ function createOrganizationRestApi(credentials) {
|
|
|
63
69
|
const auth = config.accessToken
|
|
64
70
|
? { accessToken: config.accessToken }
|
|
65
71
|
: { clientId: credentials.oauthClientId, secret: credentials.oauthClientSecret };
|
|
72
|
+
const url = yield loadApiUrl();
|
|
73
|
+
Debug('Creating organization REST API: url=%s authMode=%s organizationUid=%o', url, config.accessToken ? 'jwt' : 'legacy', config.defaultOrganizationUid);
|
|
66
74
|
const options = {
|
|
67
|
-
url
|
|
75
|
+
url,
|
|
68
76
|
auth,
|
|
69
77
|
version: apiVersions_1.ApiVersions.V1,
|
|
70
78
|
clientVersions: createClientVersions(),
|
|
@@ -86,7 +94,9 @@ function createOptions(method, options, data) {
|
|
|
86
94
|
};
|
|
87
95
|
}
|
|
88
96
|
function createUri(options, resource, queryParams) {
|
|
89
|
-
|
|
97
|
+
const uri = [options.url, options.version, resource].join('/') + (typeof queryParams !== 'undefined' ? '?' + (0, querystring_1.stringify)(queryParams) : '');
|
|
98
|
+
Debug('API request URI: %s (auth=%s)', uri, options.accessToken ? 'jwt' : 'legacy');
|
|
99
|
+
return uri;
|
|
90
100
|
}
|
|
91
101
|
function getResource(options, path, query) {
|
|
92
102
|
return fetch(createUri(options, path, query), createOptions('GET', options));
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
});
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
process.env.SOS_SKIP_DOTENV = '1';
|
|
13
14
|
const appletCommand_1 = require("./Applet/appletCommand");
|
|
14
15
|
const loginCommand_1 = require("./Auth/loginCommand");
|
|
15
16
|
const logoutCommand_1 = require("./Auth/logoutCommand");
|
package/dist/parameters.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var _a, _b;
|
|
2
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
4
|
exports.parameters = void 0;
|
|
4
5
|
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
@@ -10,6 +11,8 @@ const rootPath = path.normalize(__dirname + '/..');
|
|
|
10
11
|
// Load environment-specific .env file
|
|
11
12
|
const envFile = environment === 'test' ? '.env.test' : '.env';
|
|
12
13
|
dotenv.config({ path: path.join(rootPath, envFile) });
|
|
14
|
+
// Load production defaults for any vars not already set
|
|
15
|
+
dotenv.config({ path: path.join(rootPath, '.env.production') });
|
|
13
16
|
const configurableEnvVars = [
|
|
14
17
|
'SOS_PROFILE',
|
|
15
18
|
'SOS_API_IDENTIFICATION',
|
|
@@ -24,9 +27,9 @@ for (const envVar of configurableEnvVars) {
|
|
|
24
27
|
(0, log_1.log)('warning', `Environment variable ${envVar} found. Will override default values from ~/.sosrc`);
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
|
-
const apiUrl = process.env.SOS_API_URL;
|
|
30
|
+
const apiUrl = (_a = process.env.SOS_API_URL) !== null && _a !== void 0 ? _a : process.env.SOS_DEFAULT_API_URL;
|
|
28
31
|
if (!apiUrl) {
|
|
29
|
-
throw new Error(`Environment variable SOS_API_URL is required`);
|
|
32
|
+
throw new Error(`Environment variable SOS_API_URL or SOS_DEFAULT_API_URL is required`);
|
|
30
33
|
}
|
|
31
34
|
exports.parameters = {
|
|
32
35
|
environment,
|
|
@@ -34,7 +37,7 @@ exports.parameters = {
|
|
|
34
37
|
version: packageConfig.version,
|
|
35
38
|
profile: process.env.SOS_PROFILE,
|
|
36
39
|
apiUrl,
|
|
37
|
-
forwardServerUrl: process.env.SOS_FORWARD_SERVER_URL,
|
|
40
|
+
forwardServerUrl: (_b = process.env.SOS_FORWARD_SERVER_URL) !== null && _b !== void 0 ? _b : process.env.SOS_DEFAULT_FORWARD_SERVER_URL,
|
|
38
41
|
applet: {
|
|
39
42
|
uid: process.env.SOS_APPLET_UID,
|
|
40
43
|
version: process.env.SOS_APPLET_VERSION,
|
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,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signageos/cli",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.5",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"author": "signageOS.io <dev@signageos.io>",
|
|
6
6
|
"files": [
|
|
7
7
|
".env",
|
|
8
|
+
".env.production",
|
|
8
9
|
"dist",
|
|
9
10
|
"README.md",
|
|
10
11
|
"package.json",
|
|
@@ -87,7 +88,7 @@
|
|
|
87
88
|
"dependencies": {
|
|
88
89
|
"@signageos/cli-common": "0.1.0",
|
|
89
90
|
"@signageos/file": "2.0.1",
|
|
90
|
-
"@signageos/sdk": "2.
|
|
91
|
+
"@signageos/sdk": "2.8.0",
|
|
91
92
|
"archiver": "7.0.1",
|
|
92
93
|
"chalk": "2.4.2",
|
|
93
94
|
"child-process-promise": "2.1.3",
|