@signageos/cli 2.7.1 → 2.8.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 +12 -0
- package/dist/Applet/Generate/appletGenerateCommand.js +5 -1
- package/dist/Emulator/emulatorFactory.js +18 -0
- package/dist/helper.d.ts +1 -0
- package/dist/helper.js +14 -0
- package/docs/index.md +13 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -175,6 +175,18 @@ sos applet start
|
|
|
175
175
|
| --detach *(optional)* | Run the applet HTTP server in the background (detached process) | false |
|
|
176
176
|
| --forward-server-url *(optional)* | Custom forward server URL for `sos device connect` command. | https://forward.signageos.io |
|
|
177
177
|
|
|
178
|
+
##### Local Configuration
|
|
179
|
+
You can create a `sos.config.local.json` file in your applet directory to provide configuration values during local development. This file is automatically loaded when running `sos applet start` and passed to your applet as configuration.
|
|
180
|
+
|
|
181
|
+
```json
|
|
182
|
+
{
|
|
183
|
+
"myConfigKey": "myConfigValue",
|
|
184
|
+
"anotherSetting": true
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
This is useful for testing your applet with different configuration values without having to deploy it to a device.
|
|
189
|
+
|
|
178
190
|
#### Applet Tests Upload
|
|
179
191
|
```bash
|
|
180
192
|
sos applet test upload
|
|
@@ -413,11 +413,15 @@ exports.appletGenerate = (0, commandDefinition_1.createCommandDefinition)({
|
|
|
413
413
|
path: path.join(appletRootDirectory, '.sosignore'),
|
|
414
414
|
content: 'node_modules/\n',
|
|
415
415
|
});
|
|
416
|
+
generateFiles.push({
|
|
417
|
+
path: path.join(appletRootDirectory, 'sos.config.local.json'),
|
|
418
|
+
content: '{}\n',
|
|
419
|
+
});
|
|
416
420
|
// Initialise git repository
|
|
417
421
|
if (git === GitOptions.Yes && gitFound) {
|
|
418
422
|
generateFiles.push({
|
|
419
423
|
path: path.join(appletRootDirectory, '.gitignore'),
|
|
420
|
-
content: 'node_modules/\n./dist',
|
|
424
|
+
content: 'node_modules/\n./dist\nsos.config.local.json',
|
|
421
425
|
});
|
|
422
426
|
yield (0, git_1.initGitRepository)(appletRootDirectory, true).catch((error) => {
|
|
423
427
|
console.error(`Git repository initialization failed: ${error}`);
|
|
@@ -57,8 +57,10 @@ const fsExtra = __importStar(require("fs-extra"));
|
|
|
57
57
|
const chalk_1 = __importDefault(require("chalk"));
|
|
58
58
|
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
59
59
|
const fileSystem_1 = require("../Lib/fileSystem");
|
|
60
|
+
const helper_1 = require("../helper");
|
|
60
61
|
const DUMMY_CHECKSUM = '0000000000ffffffffff';
|
|
61
62
|
const APPLET_DIRECTORY_PATH = '/applet';
|
|
63
|
+
const SOS_CONFIG_LOCAL_FILENAME = 'sos.config.local.json';
|
|
62
64
|
function createEmulator(params, organizationUid, dev) {
|
|
63
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
66
|
const { appletUid, appletVersion, emulatorServerPort, appletPath, entryFileRelativePath } = params;
|
|
@@ -84,6 +86,7 @@ function createEmulator(params, organizationUid, dev) {
|
|
|
84
86
|
res.redirect(`${req.originalUrl}${req.originalUrl.includes('?') ? '&' : '?'}duid=${params.emulatorUid}`);
|
|
85
87
|
}
|
|
86
88
|
else {
|
|
89
|
+
const localConfig = loadSosLocalConfig(appletPath);
|
|
87
90
|
const page = fsExtra.readFileSync(path.join(frontDisplayDistPath, 'index.html')).toString();
|
|
88
91
|
const script = `
|
|
89
92
|
<script>
|
|
@@ -91,6 +94,7 @@ function createEmulator(params, organizationUid, dev) {
|
|
|
91
94
|
window.__SOS_BUNDLED_APPLET.binaryFile = location.origin + ${JSON.stringify(envVars.binaryFilePath)};
|
|
92
95
|
window.__SOS_BUNDLED_APPLET.uid = ${JSON.stringify(envVars.uid)};
|
|
93
96
|
window.__SOS_BUNDLED_APPLET.version = ${JSON.stringify(envVars.version)};
|
|
97
|
+
window.__SOS_BUNDLED_APPLET.config = ${JSON.stringify(localConfig)};
|
|
94
98
|
window.__SOS_BUNDLED_APPLET.checksum = ${JSON.stringify(envVars.checksum)};
|
|
95
99
|
window.__SOS_BUNDLED_APPLET.frontAppletVersion = ${JSON.stringify(envVars.frontAppletVersion)};
|
|
96
100
|
window.__SOS_BUNDLED_APPLET.frontAppletBinaryFile = ${JSON.stringify(envVars.frontAppletBinaryFile)};
|
|
@@ -139,3 +143,17 @@ function createEmulator(params, organizationUid, dev) {
|
|
|
139
143
|
};
|
|
140
144
|
});
|
|
141
145
|
}
|
|
146
|
+
function loadSosLocalConfig(appletPath) {
|
|
147
|
+
const sosConfigLocalPath = path.join(appletPath, SOS_CONFIG_LOCAL_FILENAME);
|
|
148
|
+
if (fsExtra.existsSync(sosConfigLocalPath)) {
|
|
149
|
+
try {
|
|
150
|
+
const configContent = fsExtra.readFileSync(sosConfigLocalPath, 'utf8');
|
|
151
|
+
(0, log_1.log)('info', `Loaded local config from ${SOS_CONFIG_LOCAL_FILENAME}`);
|
|
152
|
+
return JSON.parse(configContent);
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
(0, log_1.log)('warning', `Failed to load ${SOS_CONFIG_LOCAL_FILENAME}: ${(0, helper_1.getErrorMessageFromUnknownError)(error)}`);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return {};
|
|
159
|
+
}
|
package/dist/helper.d.ts
CHANGED
|
@@ -32,4 +32,5 @@ export declare function postResource(options: IOptions, path: string, query?: an
|
|
|
32
32
|
export declare function putResource(options: IOptions, path: string, query?: any, data?: any): Promise<Response>;
|
|
33
33
|
export declare function deleteResource(options: IOptions, path: string): Promise<Response>;
|
|
34
34
|
export declare function deserializeJSON(_key: string, value: any): any;
|
|
35
|
+
export declare function getErrorMessageFromUnknownError(error: unknown): unknown;
|
|
35
36
|
export {};
|
package/dist/helper.js
CHANGED
|
@@ -25,6 +25,7 @@ exports.postResource = postResource;
|
|
|
25
25
|
exports.putResource = putResource;
|
|
26
26
|
exports.deleteResource = deleteResource;
|
|
27
27
|
exports.deserializeJSON = deserializeJSON;
|
|
28
|
+
exports.getErrorMessageFromUnknownError = getErrorMessageFromUnknownError;
|
|
28
29
|
const querystring_1 = require("querystring");
|
|
29
30
|
const RestApi_1 = __importDefault(require("@signageos/sdk/dist/RestApi/RestApi"));
|
|
30
31
|
const runControlHelper_1 = require("./RunControl/runControlHelper");
|
|
@@ -115,3 +116,16 @@ function deserializeJSON(_key, value) {
|
|
|
115
116
|
}
|
|
116
117
|
return value;
|
|
117
118
|
}
|
|
119
|
+
function getErrorMessageFromUnknownError(error) {
|
|
120
|
+
if (error) {
|
|
121
|
+
if (typeof error === 'object' && 'message' in error) {
|
|
122
|
+
return error.message;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
return `${error}`;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
}
|
package/docs/index.md
CHANGED
|
@@ -32,6 +32,19 @@ npm install -g @signageos/cli
|
|
|
32
32
|
2. **Generate a new applet**: `sos applet generate --name my-applet`
|
|
33
33
|
3. **Start development**: `cd my-applet && sos applet start`
|
|
34
34
|
|
|
35
|
+
### Local Configuration
|
|
36
|
+
|
|
37
|
+
You can create a `sos.config.local.json` file in your applet directory to provide configuration values during local development:
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"myConfigKey": "myConfigValue",
|
|
42
|
+
"anotherSetting": true
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
This configuration is automatically loaded when running `sos applet start` and passed to your applet, making it easy to test different configuration scenarios without deploying to a device.
|
|
47
|
+
|
|
35
48
|
## Usage
|
|
36
49
|
|
|
37
50
|
```bash
|