@signageos/cli 4.0.4 → 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/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 +2 -2
- package/dist/Auth/auth0Settings.js +9 -9
- package/dist/Auth/loginCommand.js +7 -7
- 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/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
|
|
@@ -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,11 +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
|
-
* Precedence:
|
|
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
9
|
/**
|
|
10
10
|
* Read the Box URL from the active profile.
|
|
11
|
-
* Precedence: profile field in ~/.sosrc >
|
|
11
|
+
* Precedence: SOS_BOX_HOST env var (user-explicit override) > profile field in ~/.sosrc > SOS_DEFAULT_BOX_HOST env var (package default).
|
|
12
12
|
*/
|
|
13
13
|
export declare function getBoxUrl(): string;
|
|
@@ -8,24 +8,24 @@ const globalArgs_1 = require("../Command/globalArgs");
|
|
|
8
8
|
* Auth0 settings for the signageOS CLI tool (regular API).
|
|
9
9
|
*
|
|
10
10
|
* These connect to the regular signageOS API (not admin API).
|
|
11
|
-
* Precedence:
|
|
11
|
+
* Precedence: SOS_AUTH0_* env var (user-explicit override) > profile field in ~/.sosrc > SOS_DEFAULT_AUTH0_* env var (package default).
|
|
12
12
|
*/
|
|
13
13
|
function getAuth0Settings() {
|
|
14
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
14
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
15
15
|
const profile = (0, globalArgs_1.getGlobalProfile)();
|
|
16
16
|
return {
|
|
17
|
-
domain: (_b = (_a = (0, cli_common_1.readProfileField)('auth0Domain', profile)) !== null &&
|
|
18
|
-
clientId: (
|
|
19
|
-
audience: (
|
|
20
|
-
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 : '',
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Read the Box URL from the active profile.
|
|
25
|
-
* Precedence: profile field in ~/.sosrc >
|
|
25
|
+
* Precedence: SOS_BOX_HOST env var (user-explicit override) > profile field in ~/.sosrc > SOS_DEFAULT_BOX_HOST env var (package default).
|
|
26
26
|
*/
|
|
27
27
|
function getBoxUrl() {
|
|
28
|
-
var _a, _b;
|
|
28
|
+
var _a, _b, _c;
|
|
29
29
|
const profile = (0, globalArgs_1.getGlobalProfile)();
|
|
30
|
-
return (_b = (_a = (0, cli_common_1.readProfileField)('boxUrl', profile)) !== null &&
|
|
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
31
|
}
|
|
@@ -71,7 +71,7 @@ exports.login = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
71
71
|
commands: [],
|
|
72
72
|
run(options) {
|
|
73
73
|
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
var _a, _b, _c, _d, _e, _f;
|
|
74
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
75
75
|
const profile = (0, globalArgs_1.getGlobalProfile)();
|
|
76
76
|
const configFilePath = (0, sosControlHelper_1.getConfigFilePath)();
|
|
77
77
|
const interactiveProfile = options['interactive-profile'];
|
|
@@ -81,7 +81,7 @@ exports.login = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
81
81
|
type: 'text',
|
|
82
82
|
name: 'inputApiUrl',
|
|
83
83
|
message: 'Server API URL',
|
|
84
|
-
initial: (_a = process.env.SOS_API_URL) !== null && _a !== void 0 ? _a : 'https://api.signageos.io',
|
|
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
85
|
validate: (v) => (v.startsWith('http') ? true : 'Must be a valid URL starting with http'),
|
|
86
86
|
});
|
|
87
87
|
if (!inputApiUrl) {
|
|
@@ -92,7 +92,7 @@ exports.login = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
92
92
|
type: 'text',
|
|
93
93
|
name: 'inputBoxUrl',
|
|
94
94
|
message: 'Box URL',
|
|
95
|
-
initial: (
|
|
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
96
|
});
|
|
97
97
|
if (inputBoxUrl) {
|
|
98
98
|
(0, cli_common_1.writeProfileField)('boxUrl', inputBoxUrl.replace(/\/+$/, ''), profile);
|
|
@@ -101,7 +101,7 @@ exports.login = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
101
101
|
type: 'text',
|
|
102
102
|
name: 'inputAuth0Domain',
|
|
103
103
|
message: 'Auth0 domain',
|
|
104
|
-
initial: (
|
|
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
105
|
});
|
|
106
106
|
if (inputAuth0Domain) {
|
|
107
107
|
(0, cli_common_1.writeProfileField)('auth0Domain', inputAuth0Domain, profile);
|
|
@@ -110,7 +110,7 @@ exports.login = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
110
110
|
type: 'text',
|
|
111
111
|
name: 'inputAuth0ClientId',
|
|
112
112
|
message: 'Auth0 client ID',
|
|
113
|
-
initial: (
|
|
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
114
|
});
|
|
115
115
|
if (inputAuth0ClientId) {
|
|
116
116
|
(0, cli_common_1.writeProfileField)('auth0ClientId', inputAuth0ClientId, profile);
|
|
@@ -119,7 +119,7 @@ exports.login = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
119
119
|
type: 'text',
|
|
120
120
|
name: 'inputAuth0Audience',
|
|
121
121
|
message: 'Auth0 audience',
|
|
122
|
-
initial: (
|
|
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
123
|
});
|
|
124
124
|
if (inputAuth0Audience) {
|
|
125
125
|
(0, cli_common_1.writeProfileField)('auth0Audience', inputAuth0Audience, profile);
|
|
@@ -128,7 +128,7 @@ exports.login = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
128
128
|
const auth0 = (0, auth0Settings_1.getAuth0Settings)();
|
|
129
129
|
(0, log_1.log)('info', 'Starting Auth0 Device Authorization Flow...');
|
|
130
130
|
const deviceCode = yield (0, cli_common_1.requestDeviceCode)(auth0);
|
|
131
|
-
const verificationUrl = (
|
|
131
|
+
const verificationUrl = (_l = deviceCode.verification_uri_complete) !== null && _l !== void 0 ? _l : deviceCode.verification_uri;
|
|
132
132
|
// Try to open the verification URL in the default browser
|
|
133
133
|
openInBrowser(verificationUrl);
|
|
134
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/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",
|