@signageos/cli 2.5.0 → 2.6.0-rc.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/dist/Applet/Generate/appletGenerateCommand.js +1 -1
- package/dist/CustomScript/customScriptFacade.d.ts +5 -5
- package/dist/CustomScript/customScriptFacade.js +5 -4
- package/dist/Plugin/Generate/pluginGenerateCommand.d.ts +7 -0
- package/dist/Plugin/Generate/pluginGenerateCommand.js +38 -0
- package/dist/Plugin/Generate/pluginGenerateFacade.d.ts +12 -0
- package/dist/Plugin/Generate/pluginGenerateFacade.js +106 -0
- package/dist/Plugin/Upload/pluginUploadCommand.d.ts +25 -0
- package/dist/Plugin/Upload/pluginUploadCommand.js +70 -0
- package/dist/Plugin/pluginCommand.d.ts +27 -0
- package/dist/Plugin/pluginCommand.js +26 -0
- package/dist/Plugin/pluginFacade.d.ts +62 -0
- package/dist/Plugin/pluginFacade.js +251 -0
- package/dist/Runner/Generate/runnerGenerateCommand.d.ts +7 -0
- package/dist/Runner/Generate/runnerGenerateCommand.js +38 -0
- package/dist/Runner/Generate/runnerGenerateFacade.d.ts +12 -0
- package/dist/Runner/Generate/runnerGenerateFacade.js +107 -0
- package/dist/Runner/Upload/runnerUploadCommand.d.ts +25 -0
- package/dist/Runner/Upload/runnerUploadCommand.js +72 -0
- package/dist/Runner/runnerCommand.d.ts +27 -0
- package/dist/Runner/runnerCommand.js +26 -0
- package/dist/Runner/runnerFacede.d.ts +15 -0
- package/dist/Runner/runnerFacede.js +234 -0
- package/dist/index.js +3 -1
- package/docs/applet/index.md +10 -10
- package/docs/applet/test/index.md +4 -4
- package/docs/autocomplete/index.md +4 -4
- package/docs/custom-script/index.md +4 -4
- package/docs/device/index.md +6 -6
- package/docs/index.md +16 -14
- package/docs/organization/index.md +6 -6
- package/docs/plugin/generate/index.md +43 -0
- package/docs/plugin/index.md +72 -0
- package/docs/plugin/upload/index.md +50 -0
- package/docs/runner/generate/index.md +43 -0
- package/docs/runner/index.md +72 -0
- package/docs/runner/upload/index.md +50 -0
- package/docs/timing/index.md +2 -2
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import RestApi from '@signageos/sdk/dist/RestApi/RestApi';
|
|
3
3
|
import { ICustomScriptVersion } from '@signageos/sdk/dist/RestApi/CustomScript/Version/ICustomScriptVersion';
|
|
4
|
-
declare const PlatformSchema: z.ZodObject<{
|
|
4
|
+
export declare const PlatformSchema: z.ZodObject<{
|
|
5
5
|
/** List of files/directories that are part of the custom script for a particular platform. */
|
|
6
6
|
rootDir: z.ZodString;
|
|
7
7
|
/** Main file of the particular platform script that will be executed. */
|
|
@@ -23,7 +23,7 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
23
23
|
name: z.ZodString;
|
|
24
24
|
version: z.ZodString;
|
|
25
25
|
description: z.ZodOptional<z.ZodString>;
|
|
26
|
-
dangerLevel: z.ZodString
|
|
26
|
+
dangerLevel: z.ZodOptional<z.ZodString>;
|
|
27
27
|
/**
|
|
28
28
|
* Config of individual custom script implementations for each target platform.
|
|
29
29
|
*
|
|
@@ -50,7 +50,6 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
50
50
|
}, "strip", z.ZodTypeAny, {
|
|
51
51
|
version: string;
|
|
52
52
|
name: string;
|
|
53
|
-
dangerLevel: string;
|
|
54
53
|
platforms: Record<string, {
|
|
55
54
|
rootDir: string;
|
|
56
55
|
mainFile: string;
|
|
@@ -59,10 +58,10 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
59
58
|
configDefinition: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
|
|
60
59
|
description?: string | undefined;
|
|
61
60
|
uid?: string | undefined;
|
|
61
|
+
dangerLevel?: string | undefined;
|
|
62
62
|
}, {
|
|
63
63
|
version: string;
|
|
64
64
|
name: string;
|
|
65
|
-
dangerLevel: string;
|
|
66
65
|
platforms: Record<string, {
|
|
67
66
|
rootDir: string;
|
|
68
67
|
mainFile: string;
|
|
@@ -71,6 +70,7 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
71
70
|
configDefinition: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
|
|
72
71
|
description?: string | undefined;
|
|
73
72
|
uid?: string | undefined;
|
|
73
|
+
dangerLevel?: string | undefined;
|
|
74
74
|
}>;
|
|
75
75
|
export type CustomScriptConfig = z.infer<typeof ConfigSchema>;
|
|
76
76
|
/**
|
|
@@ -87,7 +87,6 @@ export interface CodeArchive {
|
|
|
87
87
|
export declare function getConfig(workDir: string): Promise<{
|
|
88
88
|
version: string;
|
|
89
89
|
name: string;
|
|
90
|
-
dangerLevel: string;
|
|
91
90
|
platforms: Record<string, {
|
|
92
91
|
rootDir: string;
|
|
93
92
|
mainFile: string;
|
|
@@ -96,6 +95,7 @@ export declare function getConfig(workDir: string): Promise<{
|
|
|
96
95
|
configDefinition: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
|
|
97
96
|
description?: string | undefined;
|
|
98
97
|
uid?: string | undefined;
|
|
98
|
+
dangerLevel?: string | undefined;
|
|
99
99
|
}>;
|
|
100
100
|
/**
|
|
101
101
|
* Add data to the config file .sosconfig.json
|
|
@@ -45,6 +45,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
45
45
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.PlatformSchema = void 0;
|
|
48
49
|
exports.getConfig = getConfig;
|
|
49
50
|
exports.addToConfigFile = addToConfigFile;
|
|
50
51
|
exports.ensureCustomScriptVersion = ensureCustomScriptVersion;
|
|
@@ -61,7 +62,7 @@ const fileSystem_1 = require("../Lib/fileSystem");
|
|
|
61
62
|
const runtimeFileSystem_1 = require("@signageos/sdk/dist/Development/runtimeFileSystem");
|
|
62
63
|
const CONFIG_FILE_NAME = '.sosconfig.json';
|
|
63
64
|
const CUSTOM_SCRIPTS_BUILDS_DIRNAME = 'custom_scripts_builds';
|
|
64
|
-
|
|
65
|
+
exports.PlatformSchema = z.strictObject({
|
|
65
66
|
/** List of files/directories that are part of the custom script for a particular platform. */
|
|
66
67
|
rootDir: z.string(),
|
|
67
68
|
/** Main file of the particular platform script that will be executed. */
|
|
@@ -74,14 +75,14 @@ const ConfigSchema = z.object({
|
|
|
74
75
|
name: z.string(),
|
|
75
76
|
version: z.string(),
|
|
76
77
|
description: z.string().optional(),
|
|
77
|
-
dangerLevel: z.string(),
|
|
78
|
+
dangerLevel: z.string().optional(),
|
|
78
79
|
/**
|
|
79
80
|
* Config of individual custom script implementations for each target platform.
|
|
80
81
|
*
|
|
81
82
|
* A Custom Script is only a virtual unit that consists of multiple platform-specific scripts.
|
|
82
83
|
* This record is a mapping of platform names to their respective platform-specific scripts.
|
|
83
84
|
*/
|
|
84
|
-
platforms: z.record(z.string(), PlatformSchema),
|
|
85
|
+
platforms: z.record(z.string(), exports.PlatformSchema),
|
|
85
86
|
configDefinition: z.array(z.object({}).passthrough()), // outsource validation to API because it's a bit complex
|
|
86
87
|
});
|
|
87
88
|
/**
|
|
@@ -171,7 +172,7 @@ function ensureCustomScript(restApi, config) {
|
|
|
171
172
|
name: config.name,
|
|
172
173
|
title: config.name, // TODO change
|
|
173
174
|
description: config.description,
|
|
174
|
-
dangerLevel: config.dangerLevel,
|
|
175
|
+
dangerLevel: config.dangerLevel ? config.dangerLevel : 'normal', // default to 'normal' if not provided
|
|
175
176
|
});
|
|
176
177
|
// TODO ask for permission or read from CLI arg
|
|
177
178
|
(0, log_1.log)('info', chalk_1.default.yellow('Adding Custom Script uid to the config file'));
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.pluginGenerate = void 0;
|
|
16
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
+
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
18
|
+
const commandDefinition_1 = require("../../Command/commandDefinition");
|
|
19
|
+
const git_1 = require("../../Lib/git");
|
|
20
|
+
const customScriptFacade_1 = require("../../CustomScript/customScriptFacade");
|
|
21
|
+
const pluginGenerateFacade_1 = require("./pluginGenerateFacade");
|
|
22
|
+
exports.pluginGenerate = (0, commandDefinition_1.createCommandDefinition)({
|
|
23
|
+
name: 'generate',
|
|
24
|
+
description: 'Generates a local repository for developing a Plugin',
|
|
25
|
+
optionList: [],
|
|
26
|
+
commands: [],
|
|
27
|
+
run() {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
yield (0, git_1.throwErrorIfGitNotInstalled)();
|
|
30
|
+
const { targetDir, name, description } = yield (0, pluginGenerateFacade_1.askForParameters)();
|
|
31
|
+
yield (0, pluginGenerateFacade_1.downloadBoilerplateCode)(targetDir);
|
|
32
|
+
yield (0, customScriptFacade_1.addToConfigFile)(targetDir, { name, description });
|
|
33
|
+
(0, log_1.log)('info', `Plugin ${chalk_1.default.green(name)} has been generated in ${chalk_1.default.green(targetDir)}.`);
|
|
34
|
+
(0, log_1.log)('info', 'Next steps:');
|
|
35
|
+
(0, log_1.log)('info', ` - Open the folder ${chalk_1.default.green(targetDir)} and read the ${chalk_1.default.green('README.md')} file.`);
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prompts the user for the parameters needed to generate a plugin.
|
|
3
|
+
*/
|
|
4
|
+
export declare function askForParameters(): Promise<{
|
|
5
|
+
targetDir: any;
|
|
6
|
+
name: any;
|
|
7
|
+
description: any;
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* Downloads the latest version of the boilerplate code from the GitHub repository.
|
|
11
|
+
*/
|
|
12
|
+
export declare function downloadBoilerplateCode(targetDir: string): Promise<void>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.askForParameters = askForParameters;
|
|
49
|
+
exports.downloadBoilerplateCode = downloadBoilerplateCode;
|
|
50
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
51
|
+
const prompts_1 = __importDefault(require("prompts"));
|
|
52
|
+
const path = __importStar(require("path"));
|
|
53
|
+
const fs = __importStar(require("fs-extra"));
|
|
54
|
+
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
55
|
+
const git_1 = require("../../Lib/git");
|
|
56
|
+
/**
|
|
57
|
+
* Prompts the user for the parameters needed to generate a plugin.
|
|
58
|
+
*/
|
|
59
|
+
function askForParameters() {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const throwCanceledError = () => {
|
|
62
|
+
throw new Error('Plugin generation was canceled.');
|
|
63
|
+
};
|
|
64
|
+
const { name, description } = yield (0, prompts_1.default)([
|
|
65
|
+
{
|
|
66
|
+
type: 'text',
|
|
67
|
+
name: 'name',
|
|
68
|
+
message: 'Type name',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
type: 'text',
|
|
72
|
+
name: 'description',
|
|
73
|
+
message: 'Type description',
|
|
74
|
+
},
|
|
75
|
+
], { onCancel: throwCanceledError });
|
|
76
|
+
const targetDir = name;
|
|
77
|
+
(0, log_1.log)('info', `Generating Plugin with these parameters:\n` +
|
|
78
|
+
` - Directory: ${chalk_1.default.green(targetDir)}\n` +
|
|
79
|
+
` - Name: ${chalk_1.default.green(name)}\n` +
|
|
80
|
+
` - Description: ${chalk_1.default.green(description)}\n`);
|
|
81
|
+
const { confirm } = yield (0, prompts_1.default)({
|
|
82
|
+
type: 'confirm',
|
|
83
|
+
name: 'confirm',
|
|
84
|
+
message: 'Confirm',
|
|
85
|
+
});
|
|
86
|
+
if (!confirm) {
|
|
87
|
+
throwCanceledError();
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
targetDir,
|
|
91
|
+
name,
|
|
92
|
+
description,
|
|
93
|
+
};
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Downloads the latest version of the boilerplate code from the GitHub repository.
|
|
98
|
+
*/
|
|
99
|
+
function downloadBoilerplateCode(targetDir) {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
const URL = 'https://github.com/signageos/plugins-boilerplate';
|
|
102
|
+
yield (0, git_1.cloneGitRepository)(URL, targetDir);
|
|
103
|
+
// we just want the code, not the git history
|
|
104
|
+
yield fs.remove(path.join(targetDir, '.git'));
|
|
105
|
+
});
|
|
106
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CommandLineOptions } from '../../Command/commandDefinition';
|
|
2
|
+
export declare const OPTION_LIST: readonly [{
|
|
3
|
+
readonly name: "no-default-organization";
|
|
4
|
+
readonly type: BooleanConstructor;
|
|
5
|
+
readonly description: "Prevent using the defaultOrganizationUid from ~/.sosrc";
|
|
6
|
+
}, {
|
|
7
|
+
readonly name: "organization-uid";
|
|
8
|
+
readonly type: StringConstructor;
|
|
9
|
+
readonly description: "Organization UID";
|
|
10
|
+
}];
|
|
11
|
+
export declare const pluginUpload: {
|
|
12
|
+
name: "upload";
|
|
13
|
+
description: string;
|
|
14
|
+
optionList: readonly [{
|
|
15
|
+
readonly name: "no-default-organization";
|
|
16
|
+
readonly type: BooleanConstructor;
|
|
17
|
+
readonly description: "Prevent using the defaultOrganizationUid from ~/.sosrc";
|
|
18
|
+
}, {
|
|
19
|
+
readonly name: "organization-uid";
|
|
20
|
+
readonly type: StringConstructor;
|
|
21
|
+
readonly description: "Organization UID";
|
|
22
|
+
}];
|
|
23
|
+
commands: never[];
|
|
24
|
+
run(options: CommandLineOptions<typeof OPTION_LIST>): Promise<void>;
|
|
25
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.pluginUpload = exports.OPTION_LIST = void 0;
|
|
16
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
+
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
18
|
+
const commandDefinition_1 = require("../../Command/commandDefinition");
|
|
19
|
+
const organizationFacade_1 = require("../../Organization/organizationFacade");
|
|
20
|
+
const customScriptFacade_1 = require("../../CustomScript/customScriptFacade");
|
|
21
|
+
const pluginFacade_1 = require("../pluginFacade");
|
|
22
|
+
const util_1 = require("util");
|
|
23
|
+
const helper_1 = require("../../helper");
|
|
24
|
+
const debug_1 = __importDefault(require("debug"));
|
|
25
|
+
const Debug = (0, debug_1.default)('@signageos/cli:Plugin:Upload:Command');
|
|
26
|
+
exports.OPTION_LIST = [organizationFacade_1.NO_DEFAULT_ORGANIZATION_OPTION, organizationFacade_1.ORGANIZATION_UID_OPTION];
|
|
27
|
+
exports.pluginUpload = (0, commandDefinition_1.createCommandDefinition)({
|
|
28
|
+
name: 'upload',
|
|
29
|
+
description: 'Uploads current plugin version',
|
|
30
|
+
optionList: exports.OPTION_LIST,
|
|
31
|
+
commands: [],
|
|
32
|
+
run(options) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const currentDirectory = process.cwd();
|
|
35
|
+
const organizationUid = yield (0, organizationFacade_1.getOrganizationUidOrDefaultOrSelect)(options);
|
|
36
|
+
const organization = yield (0, organizationFacade_1.getOrganization)(organizationUid);
|
|
37
|
+
const restApi = yield (0, helper_1.createOrganizationRestApi)(organization);
|
|
38
|
+
const config = yield (0, customScriptFacade_1.getConfig)(currentDirectory);
|
|
39
|
+
const schema = yield (0, pluginFacade_1.loadSchemas)(currentDirectory);
|
|
40
|
+
const pluginVersion = yield (0, pluginFacade_1.ensurePluginVersion)(restApi, config, schema);
|
|
41
|
+
for (const platform of Object.keys(config.platforms)) {
|
|
42
|
+
const platformConfig = config.platforms[platform];
|
|
43
|
+
if (!platformConfig) {
|
|
44
|
+
console.warn(`Skipping platform ${platform} due to missing configuration`);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
yield (0, pluginFacade_1.uploadCode)({
|
|
48
|
+
restApi,
|
|
49
|
+
workDir: currentDirectory,
|
|
50
|
+
platform,
|
|
51
|
+
config: platformConfig,
|
|
52
|
+
pluginVersion,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (!(0, util_1.isDeepStrictEqual)(pluginVersion.configDefinition, config.configDefinition)) {
|
|
56
|
+
Debug('Config definition is different, updating plugin version.');
|
|
57
|
+
yield restApi.plugin.version.update({
|
|
58
|
+
pluginUid: pluginVersion.pluginUid,
|
|
59
|
+
version: pluginVersion.version,
|
|
60
|
+
configDefinition: config.configDefinition,
|
|
61
|
+
schema: [schema],
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
Debug('Config definition is the same, skipping update.');
|
|
66
|
+
}
|
|
67
|
+
(0, log_1.log)('info', `Plugin ${chalk_1.default.green(config.name)} version ${chalk_1.default.green(config.version)} has been uploaded.`);
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const plugin: {
|
|
2
|
+
name: "plugin";
|
|
3
|
+
description: string;
|
|
4
|
+
optionList: never[];
|
|
5
|
+
commands: ({
|
|
6
|
+
name: "generate";
|
|
7
|
+
description: string;
|
|
8
|
+
optionList: never[];
|
|
9
|
+
commands: never[];
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
} | {
|
|
12
|
+
name: "upload";
|
|
13
|
+
description: string;
|
|
14
|
+
optionList: readonly [{
|
|
15
|
+
readonly name: "no-default-organization";
|
|
16
|
+
readonly type: BooleanConstructor;
|
|
17
|
+
readonly description: "Prevent using the defaultOrganizationUid from ~/.sosrc";
|
|
18
|
+
}, {
|
|
19
|
+
readonly name: "organization-uid";
|
|
20
|
+
readonly type: StringConstructor;
|
|
21
|
+
readonly description: "Organization UID";
|
|
22
|
+
}];
|
|
23
|
+
commands: never[];
|
|
24
|
+
run(options: import("../Command/commandDefinition").CommandLineOptions<typeof import("./Upload/pluginUploadCommand").OPTION_LIST>): Promise<void>;
|
|
25
|
+
})[];
|
|
26
|
+
run(): Promise<never>;
|
|
27
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.plugin = void 0;
|
|
13
|
+
const commandDefinition_1 = require("../Command/commandDefinition");
|
|
14
|
+
const pluginGenerateCommand_1 = require("./Generate/pluginGenerateCommand");
|
|
15
|
+
const pluginUploadCommand_1 = require("./Upload/pluginUploadCommand");
|
|
16
|
+
exports.plugin = (0, commandDefinition_1.createCommandDefinition)({
|
|
17
|
+
name: 'plugin',
|
|
18
|
+
description: 'Plugin management',
|
|
19
|
+
optionList: [],
|
|
20
|
+
commands: [pluginGenerateCommand_1.pluginGenerate, pluginUploadCommand_1.pluginUpload],
|
|
21
|
+
run() {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
throw new Error('Unknown command');
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import RestApi from '@signageos/sdk/dist/RestApi/RestApi';
|
|
3
|
+
import { IPluginVersion } from '@signageos/sdk/dist/RestApi/Plugin/Version/IPluginVersion';
|
|
4
|
+
import { PlatformConfig } from '../CustomScript/customScriptFacade';
|
|
5
|
+
export declare function ensurePluginVersion(restApi: RestApi, config: PluginConfig, schema: any): Promise<import("@signageos/sdk/dist/RestApi/Plugin/Version/PluginVersion").PluginVersion>;
|
|
6
|
+
export declare function uploadCode({ restApi, workDir, platform, config, pluginVersion, }: {
|
|
7
|
+
restApi: RestApi;
|
|
8
|
+
workDir: string;
|
|
9
|
+
platform: string;
|
|
10
|
+
config: PlatformConfig;
|
|
11
|
+
pluginVersion: IPluginVersion;
|
|
12
|
+
}): Promise<void>;
|
|
13
|
+
export declare function loadSchemas(workDir: string): Promise<any>;
|
|
14
|
+
export declare const ConfigSchema: z.ZodObject<{
|
|
15
|
+
uid: z.ZodOptional<z.ZodString>;
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
version: z.ZodString;
|
|
18
|
+
description: z.ZodOptional<z.ZodString>;
|
|
19
|
+
/**
|
|
20
|
+
* Config of individual plugin script implementations for each target platform.
|
|
21
|
+
*
|
|
22
|
+
* A plugin Script is only a virtual unit that consists of multiple platform-specific scripts.
|
|
23
|
+
* This record is a mapping of platform names to their respective platform-specific scripts.
|
|
24
|
+
*/
|
|
25
|
+
platforms: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
26
|
+
rootDir: z.ZodString;
|
|
27
|
+
mainFile: z.ZodString;
|
|
28
|
+
runtime: z.ZodString;
|
|
29
|
+
}, "strict", z.ZodTypeAny, {
|
|
30
|
+
rootDir: string;
|
|
31
|
+
mainFile: string;
|
|
32
|
+
runtime: string;
|
|
33
|
+
}, {
|
|
34
|
+
rootDir: string;
|
|
35
|
+
mainFile: string;
|
|
36
|
+
runtime: string;
|
|
37
|
+
}>>;
|
|
38
|
+
configDefinition: z.ZodArray<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>, "many">;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
version: string;
|
|
41
|
+
name: string;
|
|
42
|
+
platforms: Record<string, {
|
|
43
|
+
rootDir: string;
|
|
44
|
+
mainFile: string;
|
|
45
|
+
runtime: string;
|
|
46
|
+
}>;
|
|
47
|
+
configDefinition: z.objectOutputType<{}, z.ZodTypeAny, "passthrough">[];
|
|
48
|
+
description?: string | undefined;
|
|
49
|
+
uid?: string | undefined;
|
|
50
|
+
}, {
|
|
51
|
+
version: string;
|
|
52
|
+
name: string;
|
|
53
|
+
platforms: Record<string, {
|
|
54
|
+
rootDir: string;
|
|
55
|
+
mainFile: string;
|
|
56
|
+
runtime: string;
|
|
57
|
+
}>;
|
|
58
|
+
configDefinition: z.objectInputType<{}, z.ZodTypeAny, "passthrough">[];
|
|
59
|
+
description?: string | undefined;
|
|
60
|
+
uid?: string | undefined;
|
|
61
|
+
}>;
|
|
62
|
+
export type PluginConfig = z.infer<typeof ConfigSchema>;
|