@signageos/cli 4.0.1 → 4.0.3
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.
|
@@ -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];
|
|
@@ -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);
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: ci-cd-setup
|
|
3
|
+
title: CI/CD Pipeline Setup
|
|
4
|
+
sidebar_position: 1
|
|
5
|
+
---
|
|
6
|
+
# CI/CD Pipeline Setup
|
|
7
|
+
|
|
8
|
+
How to configure the signageOS CLI for automated pipelines (GitLab CI, GitHub Actions, and other CI/CD tools) where interactive login is not possible.
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
On a **local development machine**, you authenticate by running `sos login`, which interactively prompts for your username and password, generates a personal API security token, and stores it in `~/.sosrc`.
|
|
13
|
+
|
|
14
|
+
In a **CI/CD pipeline**, there is no interactive terminal. Instead, you generate a long-lived API security token ahead of time and provide it to the pipeline via the `~/.sosrc` configuration file or environment variables.
|
|
15
|
+
|
|
16
|
+
## Step 1: Generate an API Security Token
|
|
17
|
+
|
|
18
|
+
Before configuring your pipeline, generate a personal API security token:
|
|
19
|
+
|
|
20
|
+
1. Log in to [signageOS Box](https://box.signageos.io)
|
|
21
|
+
2. Navigate to **Settings** → **Profile** → **API Tokens**
|
|
22
|
+
3. Create a new token (account-wide or organization-scoped, depending on your needs)
|
|
23
|
+
4. Copy the **Token ID** (identification) and **Token secret** values — you will need both
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## Step 2: Configure Authentication
|
|
27
|
+
|
|
28
|
+
You have two options — choose whichever fits your pipeline best.
|
|
29
|
+
|
|
30
|
+
### Option A: Configuration File (`~/.sosrc`)
|
|
31
|
+
|
|
32
|
+
Create the `~/.sosrc` file in the CI runner's home directory with your credentials in INI format:
|
|
33
|
+
|
|
34
|
+
```ini
|
|
35
|
+
apiUrl=https://api.signageos.io
|
|
36
|
+
identification=527f75f50ce2f3cxxxxx
|
|
37
|
+
apiSecurityToken=7dc58dc275c87283cddf78bc41755cb5f7fxxxxx
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The file supports the following fields:
|
|
41
|
+
|
|
42
|
+
| Field | Required | Description |
|
|
43
|
+
|-------|----------|-------------|
|
|
44
|
+
| `apiUrl` | Yes | signageOS API endpoint (typically `https://api.signageos.io`) |
|
|
45
|
+
| `identification` | Yes | Token ID from your security token |
|
|
46
|
+
| `apiSecurityToken` | Yes | The security token secret |
|
|
47
|
+
| `defaultOrganizationUid` | No | Default organization UID for commands that require one |
|
|
48
|
+
|
|
49
|
+
> **Security:** The CLI writes this file with permissions `0600` (owner read/write only). Make sure your pipeline step preserves these permissions.
|
|
50
|
+
|
|
51
|
+
### Option B: Environment Variables
|
|
52
|
+
|
|
53
|
+
Instead of writing a file, you can set environment variables that override `~/.sosrc` values:
|
|
54
|
+
|
|
55
|
+
| Environment Variable | Overrides |
|
|
56
|
+
|---------------------|-----------|
|
|
57
|
+
| `SOS_API_URL` | `apiUrl` |
|
|
58
|
+
| `SOS_API_IDENTIFICATION` | `identification` |
|
|
59
|
+
| `SOS_API_SECURITY_TOKEN` | `apiSecurityToken` |
|
|
60
|
+
| `SOS_ORGANIZATION_UID` | `defaultOrganizationUid` |
|
|
61
|
+
|
|
62
|
+
Environment variables take precedence over the configuration file, so you can combine both approaches (e.g., a base `.sosrc` with env var overrides for specific jobs).
|
|
63
|
+
|
|
64
|
+
## Pipeline Examples
|
|
65
|
+
|
|
66
|
+
### GitLab CI
|
|
67
|
+
|
|
68
|
+
Store your credentials as [CI/CD variables](https://docs.gitlab.com/ee/ci/variables/) in your project or group settings (masked and protected).
|
|
69
|
+
|
|
70
|
+
```yaml
|
|
71
|
+
# .gitlab-ci.yml
|
|
72
|
+
|
|
73
|
+
variables:
|
|
74
|
+
SOS_API_URL: "https://api.signageos.io"
|
|
75
|
+
|
|
76
|
+
stages:
|
|
77
|
+
- deploy
|
|
78
|
+
|
|
79
|
+
deploy-applet:
|
|
80
|
+
stage: deploy
|
|
81
|
+
image: node:20
|
|
82
|
+
before_script:
|
|
83
|
+
- npm install -g @signageos/cli
|
|
84
|
+
# Write ~/.sosrc from CI/CD variables
|
|
85
|
+
- |
|
|
86
|
+
cat > ~/.sosrc <<EOF
|
|
87
|
+
apiUrl=${SOS_API_URL}
|
|
88
|
+
identification=${SOS_API_IDENTIFICATION}
|
|
89
|
+
apiSecurityToken=${SOS_API_SECURITY_TOKEN}
|
|
90
|
+
EOF
|
|
91
|
+
- chmod 600 ~/.sosrc
|
|
92
|
+
script:
|
|
93
|
+
- sos applet upload
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Alternatively, using only environment variables (no file needed):
|
|
97
|
+
|
|
98
|
+
```yaml
|
|
99
|
+
deploy-applet:
|
|
100
|
+
stage: deploy
|
|
101
|
+
image: node:20
|
|
102
|
+
variables:
|
|
103
|
+
SOS_API_URL: "https://api.signageos.io"
|
|
104
|
+
# SOS_API_IDENTIFICATION and SOS_API_SECURITY_TOKEN come from CI/CD settings
|
|
105
|
+
before_script:
|
|
106
|
+
- npm install -g @signageos/cli
|
|
107
|
+
script:
|
|
108
|
+
- sos applet upload
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### GitHub Actions
|
|
112
|
+
|
|
113
|
+
Store your credentials as [repository secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets).
|
|
114
|
+
|
|
115
|
+
```yaml
|
|
116
|
+
# .github/workflows/deploy.yml
|
|
117
|
+
|
|
118
|
+
name: Deploy Applet
|
|
119
|
+
|
|
120
|
+
on:
|
|
121
|
+
push:
|
|
122
|
+
branches: [main]
|
|
123
|
+
|
|
124
|
+
jobs:
|
|
125
|
+
deploy:
|
|
126
|
+
runs-on: ubuntu-latest
|
|
127
|
+
steps:
|
|
128
|
+
- uses: actions/checkout@v4
|
|
129
|
+
|
|
130
|
+
- uses: actions/setup-node@v4
|
|
131
|
+
with:
|
|
132
|
+
node-version: 20
|
|
133
|
+
|
|
134
|
+
- name: Install signageOS CLI
|
|
135
|
+
run: npm install -g @signageos/cli
|
|
136
|
+
|
|
137
|
+
- name: Configure signageOS credentials
|
|
138
|
+
run: |
|
|
139
|
+
cat > ~/.sosrc <<EOF
|
|
140
|
+
apiUrl=https://api.signageos.io
|
|
141
|
+
identification=${{ secrets.SOS_API_IDENTIFICATION }}
|
|
142
|
+
apiSecurityToken=${{ secrets.SOS_API_SECURITY_TOKEN }}
|
|
143
|
+
EOF
|
|
144
|
+
chmod 600 ~/.sosrc
|
|
145
|
+
|
|
146
|
+
- name: Deploy applet
|
|
147
|
+
run: sos applet upload
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Or using environment variables:
|
|
151
|
+
|
|
152
|
+
```yaml
|
|
153
|
+
- name: Deploy applet
|
|
154
|
+
env:
|
|
155
|
+
SOS_API_URL: "https://api.signageos.io"
|
|
156
|
+
SOS_API_IDENTIFICATION: ${{ secrets.SOS_API_IDENTIFICATION }}
|
|
157
|
+
SOS_API_SECURITY_TOKEN: ${{ secrets.SOS_API_SECURITY_TOKEN }}
|
|
158
|
+
run: sos applet upload
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Using Profiles in CI/CD
|
|
162
|
+
|
|
163
|
+
If your pipeline needs to operate against multiple signageOS environments (e.g., staging and production), use profiles (see [`sos login`](/cli/login/) documentation):
|
|
164
|
+
|
|
165
|
+
```ini
|
|
166
|
+
[profile staging]
|
|
167
|
+
apiUrl=https://api.staging.signageos.io
|
|
168
|
+
identification=xxxxxxxxxxxxxxxxxxxx
|
|
169
|
+
apiSecurityToken=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
170
|
+
|
|
171
|
+
[profile production]
|
|
172
|
+
apiUrl=https://api.signageos.io
|
|
173
|
+
identification=yyyyyyyyyyyyyyyyyyyy
|
|
174
|
+
apiSecurityToken=yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Then target a specific profile per job:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# Deploy to staging
|
|
181
|
+
sos --profile staging applet upload
|
|
182
|
+
|
|
183
|
+
# Deploy to production
|
|
184
|
+
sos --profile production applet upload
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
You can also select a profile via the `SOS_PROFILE` environment variable:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
export SOS_PROFILE=production
|
|
191
|
+
sos applet upload
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Setting a Default Organization
|
|
195
|
+
|
|
196
|
+
Some CLI commands operate on a specific organization. To avoid interactive prompts in CI/CD, set the default organization:
|
|
197
|
+
|
|
198
|
+
**In `~/.sosrc`:**
|
|
199
|
+
```ini
|
|
200
|
+
apiUrl=https://api.signageos.io
|
|
201
|
+
identification=527f75f50ce2f3cxxxxx
|
|
202
|
+
apiSecurityToken=7dc58dc275c87283cddf78bc41755cb5f7fxxxxx
|
|
203
|
+
defaultOrganizationUid=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**Or via environment variable:**
|
|
207
|
+
```bash
|
|
208
|
+
export SOS_ORGANIZATION_UID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Troubleshooting
|
|
212
|
+
|
|
213
|
+
### "Identification or token is missing"
|
|
214
|
+
|
|
215
|
+
The CLI cannot find valid credentials. Verify that:
|
|
216
|
+
- The `~/.sosrc` file exists and contains both `identification` and `apiSecurityToken`
|
|
217
|
+
- Or the `SOS_API_IDENTIFICATION` and `SOS_API_SECURITY_TOKEN` environment variables are set
|
|
218
|
+
- The token has not expired or been revoked
|
|
219
|
+
|
|
220
|
+
### "No API URL is defined"
|
|
221
|
+
|
|
222
|
+
The CLI needs an API URL. Ensure either:
|
|
223
|
+
- `apiUrl` is set in `~/.sosrc`
|
|
224
|
+
- Or `SOS_API_URL` environment variable is defined
|
|
225
|
+
|
|
226
|
+
### "Your authentication token is outdated"
|
|
227
|
+
|
|
228
|
+
The `identification` value does not match the expected format (20-character hex string). Regenerate the token via [signageOS Box](https://box.signageos.io/settings) or re-run `sos login` on your local machine and copy the new values.
|
|
229
|
+
|
|
230
|
+
## Security Best Practices
|
|
231
|
+
|
|
232
|
+
- **Never commit credentials** to your repository. Use CI/CD secret variables or a secrets manager.
|
|
233
|
+
- **Use masked variables** in GitLab CI / GitHub Actions so tokens don't appear in job logs.
|
|
234
|
+
- **Scope tokens appropriately** — prefer organization-scoped tokens when your pipeline only needs access to a single organization.
|
|
235
|
+
- **Rotate tokens periodically** and revoke unused ones via signageOS Box settings.
|
|
236
|
+
|
|
237
|
+
## See Also
|
|
238
|
+
|
|
239
|
+
- [`sos login`](/cli/login/) — Interactive authentication for local development
|
|
240
|
+
- [Global Options](/cli/) — `--profile` and `--api-url` flags
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@signageos/cli",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
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",
|