@signageos/cli 2.3.1 → 2.4.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 +54 -19
- package/dist/Applet/Build/appletBuildCommand.js +28 -72
- package/dist/Applet/Generate/Templates/CHANGELOG.md.template +7 -0
- package/dist/Applet/Generate/Templates/README.md.template +3 -0
- package/dist/Applet/Generate/Templates/rspack.config.mjs.template +12 -12
- package/dist/Applet/Generate/appletGenerateCommand.d.ts +23 -62
- package/dist/Applet/Generate/appletGenerateCommand.js +432 -365
- package/dist/Applet/Start/appletStartCommand.js +70 -132
- package/dist/Applet/Test/Upload/appletTestRunCommand.js +90 -178
- package/dist/Applet/Test/Upload/appletTestRunFacade.js +5 -29
- package/dist/Applet/Test/Upload/appletTestUploadCommand.js +99 -224
- package/dist/Applet/Test/Upload/appletTestUploadFacade.js +51 -105
- package/dist/Applet/Test/appletTestCommand.js +6 -36
- package/dist/Applet/Upload/appletUploadCommand.js +199 -305
- package/dist/Applet/Upload/appletUploadCommandHelper.js +129 -144
- package/dist/Applet/Upload/appletUploadFacade.d.ts +2 -2
- package/dist/Applet/Upload/appletUploadFacade.js +184 -265
- package/dist/Applet/Upload/appletUploadFacadeHelper.js +51 -55
- package/dist/Applet/appletCommand.d.ts +25 -157
- package/dist/Applet/appletCommand.js +9 -39
- package/dist/Applet/appletErrors.js +5 -24
- package/dist/Applet/appletFacade.js +122 -147
- package/dist/Applet/appletServerHelper.js +18 -55
- package/dist/Auth/loginCommand.d.ts +2 -2
- package/dist/Auth/loginCommand.js +105 -136
- package/dist/Cache/tmpCache.js +47 -16
- package/dist/Cli/helper.js +3 -5
- package/dist/Cli/packageVersion.js +99 -131
- package/dist/Command/Autocomplete/Install/installAutocompleteCommand.d.ts +10 -0
- package/dist/Command/Autocomplete/Install/installAutocompleteCommand.js +39 -0
- package/dist/Command/Autocomplete/Install/installAutocompleteCommand.ts +30 -0
- package/dist/Command/Autocomplete/Install/sos-completion.sh +63 -0
- package/dist/Command/Autocomplete/Uninstall/uninstallAutocompleteCommand.d.ts +8 -0
- package/dist/Command/Autocomplete/Uninstall/uninstallAutocompleteCommand.js +120 -0
- package/dist/Command/Autocomplete/autocompleteCommand.d.ts +22 -0
- package/dist/Command/Autocomplete/autocompleteCommand.js +32 -0
- package/dist/Command/autoComplete.d.ts +4 -0
- package/dist/Command/autoComplete.js +184 -0
- package/dist/Command/commandDefinition.d.ts +9 -9
- package/dist/Command/commandDefinition.js +1 -3
- package/dist/Command/commandProcessor.js +41 -131
- package/dist/Command/globalArgs.js +9 -8
- package/dist/CommandLine/IProgressBar.js +0 -1
- package/dist/CommandLine/progressBarFactory.d.ts +1 -1
- package/dist/CommandLine/progressBarFactory.js +42 -13
- package/dist/CustomScript/Generate/customScriptGenerateCommand.js +17 -56
- package/dist/CustomScript/Generate/customScriptGenerateFacade.js +94 -109
- package/dist/CustomScript/Upload/customScriptUploadCommand.js +44 -120
- package/dist/CustomScript/customScriptCommand.d.ts +1 -9
- package/dist/CustomScript/customScriptCommand.js +6 -36
- package/dist/CustomScript/customScriptFacade.d.ts +2 -2
- package/dist/CustomScript/customScriptFacade.js +187 -297
- package/dist/Device/Connect/connectCommand.js +73 -137
- package/dist/Device/Content/setContentCommand.js +33 -78
- package/dist/Device/PowerAction/powerActionCommand.js +22 -65
- package/dist/Device/deviceCommand.js +7 -37
- package/dist/Device/deviceFacade.js +71 -127
- package/dist/Emulator/IEmulator.js +0 -1
- package/dist/Emulator/createDomain.d.ts +0 -1
- package/dist/Emulator/createDomain.js +44 -14
- package/dist/Emulator/emulatorFacade.js +75 -133
- package/dist/Emulator/emulatorFactory.js +123 -126
- package/dist/Firmware/Upload/firmwareUploadCommand.js +133 -221
- package/dist/Firmware/Upload/firmwareUploadFacade.js +75 -112
- package/dist/Firmware/Upload/firmwareUploadHelper.js +38 -6
- package/dist/Firmware/firmwareCommand.js +5 -35
- package/dist/Lib/archive.js +56 -62
- package/dist/Lib/childProcess.js +37 -5
- package/dist/Lib/fileSystem.js +76 -87
- package/dist/Lib/git.d.ts +1 -1
- package/dist/Lib/git.js +58 -87
- package/dist/Organization/Get/organizationGetCommand.js +14 -50
- package/dist/Organization/List/organizationListCommand.js +12 -46
- package/dist/Organization/SetDefault/organizationSetDefaultCommand.js +18 -56
- package/dist/Organization/organizationCommand.js +7 -37
- package/dist/Organization/organizationFacade.js +102 -177
- package/dist/RunControl/runControlHelper.js +14 -64
- package/dist/Timer/wait.js +2 -3
- package/dist/Timing/List/timingListCommand.js +20 -62
- package/dist/Timing/timingCommand.js +5 -35
- package/dist/generalCommand.js +1 -2
- package/dist/helper.d.ts +4 -4
- package/dist/helper.js +61 -122
- package/dist/index.js +19 -46
- package/dist/parameters.js +17 -40
- package/package.json +52 -57
- package/dist/Applet/Build/appletBuildCommand.js.map +0 -1
- package/dist/Applet/Generate/appletGenerateCommand.js.map +0 -1
- package/dist/Applet/Start/appletStartCommand.js.map +0 -1
- package/dist/Applet/Test/Upload/appletTestRunCommand.js.map +0 -1
- package/dist/Applet/Test/Upload/appletTestRunFacade.js.map +0 -1
- package/dist/Applet/Test/Upload/appletTestUploadCommand.js.map +0 -1
- package/dist/Applet/Test/Upload/appletTestUploadFacade.js.map +0 -1
- package/dist/Applet/Test/appletTestCommand.js.map +0 -1
- package/dist/Applet/Upload/appletUploadCommand.js.map +0 -1
- package/dist/Applet/Upload/appletUploadCommandHelper.js.map +0 -1
- package/dist/Applet/Upload/appletUploadFacade.js.map +0 -1
- package/dist/Applet/Upload/appletUploadFacadeHelper.js.map +0 -1
- package/dist/Applet/appletCommand.js.map +0 -1
- package/dist/Applet/appletErrors.js.map +0 -1
- package/dist/Applet/appletFacade.js.map +0 -1
- package/dist/Applet/appletServerHelper.js.map +0 -1
- package/dist/Auth/loginCommand.js.map +0 -1
- package/dist/Cache/tmpCache.js.map +0 -1
- package/dist/Cli/helper.js.map +0 -1
- package/dist/Cli/packageVersion.js.map +0 -1
- package/dist/Command/commandDefinition.js.map +0 -1
- package/dist/Command/commandProcessor.js.map +0 -1
- package/dist/Command/globalArgs.js.map +0 -1
- package/dist/CommandLine/IProgressBar.js.map +0 -1
- package/dist/CommandLine/progressBarFactory.js.map +0 -1
- package/dist/CustomScript/Generate/customScriptGenerateCommand.js.map +0 -1
- package/dist/CustomScript/Generate/customScriptGenerateFacade.js.map +0 -1
- package/dist/CustomScript/Upload/customScriptUploadCommand.js.map +0 -1
- package/dist/CustomScript/customScriptCommand.js.map +0 -1
- package/dist/CustomScript/customScriptFacade.js.map +0 -1
- package/dist/Device/Connect/connectCommand.js.map +0 -1
- package/dist/Device/Content/setContentCommand.js.map +0 -1
- package/dist/Device/PowerAction/powerActionCommand.js.map +0 -1
- package/dist/Device/deviceCommand.js.map +0 -1
- package/dist/Device/deviceFacade.js.map +0 -1
- package/dist/Emulator/IEmulator.js.map +0 -1
- package/dist/Emulator/createDomain.js.map +0 -1
- package/dist/Emulator/emulatorFacade.js.map +0 -1
- package/dist/Emulator/emulatorFactory.js.map +0 -1
- package/dist/Firmware/Upload/firmwareUploadCommand.js.map +0 -1
- package/dist/Firmware/Upload/firmwareUploadFacade.js.map +0 -1
- package/dist/Firmware/Upload/firmwareUploadHelper.js.map +0 -1
- package/dist/Firmware/firmwareCommand.js.map +0 -1
- package/dist/Lib/archive.js.map +0 -1
- package/dist/Lib/childProcess.js.map +0 -1
- package/dist/Lib/fileSystem.js.map +0 -1
- package/dist/Lib/git.js.map +0 -1
- package/dist/Organization/Get/organizationGetCommand.js.map +0 -1
- package/dist/Organization/List/organizationListCommand.js.map +0 -1
- package/dist/Organization/SetDefault/organizationSetDefaultCommand.js.map +0 -1
- package/dist/Organization/organizationCommand.js.map +0 -1
- package/dist/Organization/organizationFacade.js.map +0 -1
- package/dist/RunControl/runControlHelper.js.map +0 -1
- package/dist/Timer/wait.js.map +0 -1
- package/dist/Timing/List/timingListCommand.js.map +0 -1
- package/dist/Timing/timingCommand.js.map +0 -1
- package/dist/generalCommand.js.map +0 -1
- package/dist/helper.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/parameters.js.map +0 -1
|
@@ -1,4 +1,37 @@
|
|
|
1
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
|
+
})();
|
|
2
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,48 +41,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
41
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
42
|
});
|
|
10
43
|
};
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
46
|
};
|
|
38
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
exports.getConfig = getConfig;
|
|
49
|
+
exports.addToConfigFile = addToConfigFile;
|
|
50
|
+
exports.ensureCustomScriptVersion = ensureCustomScriptVersion;
|
|
51
|
+
exports.uploadCode = uploadCode;
|
|
52
|
+
const path = __importStar(require("path"));
|
|
53
|
+
const os = __importStar(require("os"));
|
|
54
|
+
const fs = __importStar(require("fs-extra"));
|
|
55
|
+
const z = __importStar(require("zod"));
|
|
56
|
+
const prompts_1 = __importDefault(require("prompts"));
|
|
57
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
58
|
+
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
59
|
+
const archive_1 = require("../Lib/archive");
|
|
60
|
+
const fileSystem_1 = require("../Lib/fileSystem");
|
|
61
|
+
const runtimeFileSystem_1 = require("@signageos/sdk/dist/Development/runtimeFileSystem");
|
|
62
|
+
const CONFIG_FILE_NAME = '.sosconfig.json';
|
|
63
|
+
const CUSTOM_SCRIPTS_BUILDS_DIRNAME = 'custom_scripts_builds';
|
|
64
|
+
const PlatformSchema = z.strictObject({
|
|
53
65
|
/** List of files/directories that are part of the custom script for a particular platform. */
|
|
54
66
|
rootDir: z.string(),
|
|
55
67
|
/** Main file of the particular platform script that will be executed. */
|
|
@@ -57,7 +69,7 @@ var PlatformSchema = z.strictObject({
|
|
|
57
69
|
/** What type of runtime is the script for the particular platform (i.e. node.js, bash,...). */
|
|
58
70
|
runtime: z.string(),
|
|
59
71
|
});
|
|
60
|
-
|
|
72
|
+
const ConfigSchema = z.object({
|
|
61
73
|
uid: z.string().optional(),
|
|
62
74
|
name: z.string(),
|
|
63
75
|
version: z.string(),
|
|
@@ -76,230 +88,144 @@ var ConfigSchema = z.object({
|
|
|
76
88
|
* Load and validate the config file .sosconfig.json
|
|
77
89
|
*/
|
|
78
90
|
function getConfig(workDir) {
|
|
79
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
-
|
|
81
|
-
return
|
|
82
|
-
switch (_a.label) {
|
|
83
|
-
case 0: return [4 /*yield*/, loadConfigFromFile(workDir)];
|
|
84
|
-
case 1:
|
|
85
|
-
config = _a.sent();
|
|
86
|
-
return [2 /*return*/, ConfigSchema.parse(config)];
|
|
87
|
-
}
|
|
88
|
-
});
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
const config = yield loadConfigFromFile(workDir);
|
|
93
|
+
return ConfigSchema.parse(config);
|
|
89
94
|
});
|
|
90
95
|
}
|
|
91
|
-
exports.getConfig = getConfig;
|
|
92
96
|
/**
|
|
93
97
|
* Add data to the config file .sosconfig.json
|
|
94
98
|
*/
|
|
95
99
|
function addToConfigFile(workDir, data) {
|
|
96
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
case 1:
|
|
102
|
-
previousContent = _a.sent();
|
|
103
|
-
filePath = getConfigFilePath(workDir);
|
|
104
|
-
newContent = Object.assign({}, previousContent, data);
|
|
105
|
-
return [4 /*yield*/, fs.writeFile(filePath, JSON.stringify(newContent, undefined, '\t') + '\n')];
|
|
106
|
-
case 2:
|
|
107
|
-
_a.sent();
|
|
108
|
-
return [2 /*return*/];
|
|
109
|
-
}
|
|
110
|
-
});
|
|
100
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
const previousContent = yield loadConfigFromFile(workDir);
|
|
102
|
+
const filePath = getConfigFilePath(workDir);
|
|
103
|
+
const newContent = Object.assign({}, previousContent, data);
|
|
104
|
+
yield fs.writeFile(filePath, JSON.stringify(newContent, undefined, '\t') + '\n');
|
|
111
105
|
});
|
|
112
106
|
}
|
|
113
|
-
exports.addToConfigFile = addToConfigFile;
|
|
114
107
|
function loadConfigFromFile(workDir) {
|
|
115
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
case 1:
|
|
123
|
-
if (!(_a.sent())) {
|
|
124
|
-
throw new Error("Config file ".concat(CONFIG_FILE_NAME, " not found"));
|
|
125
|
-
}
|
|
126
|
-
fileContent = fs.readFileSync(filePath, 'utf-8');
|
|
127
|
-
return [2 /*return*/, JSON.parse(fileContent)];
|
|
128
|
-
}
|
|
129
|
-
});
|
|
108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
const filePath = getConfigFilePath(workDir);
|
|
110
|
+
if (!(yield fs.pathExists(filePath))) {
|
|
111
|
+
throw new Error(`Config file ${CONFIG_FILE_NAME} not found`);
|
|
112
|
+
}
|
|
113
|
+
const fileContent = fs.readFileSync(filePath, 'utf-8');
|
|
114
|
+
return JSON.parse(fileContent);
|
|
130
115
|
});
|
|
131
116
|
}
|
|
132
117
|
function getConfigFilePath(workDir) {
|
|
133
118
|
return path.join(workDir, CONFIG_FILE_NAME);
|
|
134
119
|
}
|
|
135
120
|
function ensureCustomScriptVersion(restApi, config) {
|
|
136
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
response = _a.sent();
|
|
159
|
-
if (!response.newVersion) {
|
|
160
|
-
throw new Error('Custom Script version creation was canceled.');
|
|
161
|
-
}
|
|
162
|
-
(0, log_1.log)('info', chalk_1.default.yellow("Creating Custom Script version ".concat(config.version)));
|
|
163
|
-
return [4 /*yield*/, restApi.customScript.version.create({
|
|
164
|
-
customScriptUid: customScript.uid,
|
|
165
|
-
version: config.version,
|
|
166
|
-
configDefinition: config.configDefinition,
|
|
167
|
-
})];
|
|
168
|
-
case 4: return [2 /*return*/, _a.sent()];
|
|
169
|
-
}
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
const customScript = yield ensureCustomScript(restApi, config);
|
|
123
|
+
const customScriptVersion = yield restApi.customScript.version.get({
|
|
124
|
+
customScriptUid: customScript.uid,
|
|
125
|
+
version: config.version,
|
|
126
|
+
});
|
|
127
|
+
if (customScriptVersion) {
|
|
128
|
+
return customScriptVersion;
|
|
129
|
+
}
|
|
130
|
+
const response = yield (0, prompts_1.default)({
|
|
131
|
+
type: 'confirm',
|
|
132
|
+
name: 'newVersion',
|
|
133
|
+
message: `Do you want to create new custom script version ${config.version}?`,
|
|
134
|
+
});
|
|
135
|
+
if (!response.newVersion) {
|
|
136
|
+
throw new Error('Custom Script version creation was canceled.');
|
|
137
|
+
}
|
|
138
|
+
(0, log_1.log)('info', chalk_1.default.yellow(`Creating Custom Script version ${config.version}`));
|
|
139
|
+
return yield restApi.customScript.version.create({
|
|
140
|
+
customScriptUid: customScript.uid,
|
|
141
|
+
version: config.version,
|
|
142
|
+
configDefinition: config.configDefinition,
|
|
170
143
|
});
|
|
171
144
|
});
|
|
172
145
|
}
|
|
173
|
-
exports.ensureCustomScriptVersion = ensureCustomScriptVersion;
|
|
174
146
|
function ensureCustomScript(restApi, config) {
|
|
175
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
name: config.name,
|
|
187
|
-
title: config.name,
|
|
188
|
-
description: config.description,
|
|
189
|
-
dangerLevel: config.dangerLevel,
|
|
190
|
-
})];
|
|
191
|
-
case 2:
|
|
192
|
-
_a.sent();
|
|
193
|
-
return [2 /*return*/, customScript];
|
|
194
|
-
case 3: throw new Error("Custom Script with uid \"".concat(config.uid, "\" not found"));
|
|
195
|
-
case 4: return [4 /*yield*/, prompts({
|
|
196
|
-
type: 'confirm',
|
|
197
|
-
name: 'create',
|
|
198
|
-
message: "Custom Script \"".concat(config.name, "\" does not exist. Do you want to create it?"),
|
|
199
|
-
})];
|
|
200
|
-
case 5:
|
|
201
|
-
response = _a.sent();
|
|
202
|
-
if (!response.create) {
|
|
203
|
-
throw new Error('Custom Script upload was canceled.');
|
|
204
|
-
}
|
|
205
|
-
(0, log_1.log)('info', chalk_1.default.yellow("Creating Custom Script \"".concat(config.name, "\"")));
|
|
206
|
-
return [4 /*yield*/, restApi.customScript.create({
|
|
207
|
-
name: config.name,
|
|
208
|
-
title: config.name,
|
|
209
|
-
description: config.description,
|
|
210
|
-
dangerLevel: config.dangerLevel,
|
|
211
|
-
})];
|
|
212
|
-
case 6:
|
|
213
|
-
createdCustomScript = _a.sent();
|
|
214
|
-
// TODO ask for permission or read from CLI arg
|
|
215
|
-
(0, log_1.log)('info', chalk_1.default.yellow('Adding Custom Script uid to the config file'));
|
|
216
|
-
return [4 /*yield*/, addToConfigFile(process.cwd(), { uid: createdCustomScript.uid })];
|
|
217
|
-
case 7:
|
|
218
|
-
_a.sent();
|
|
219
|
-
return [2 /*return*/, createdCustomScript];
|
|
147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
if (config.uid) {
|
|
149
|
+
const customScript = yield restApi.customScript.get(config.uid);
|
|
150
|
+
if (customScript) {
|
|
151
|
+
yield restApi.customScript.update(customScript.uid, {
|
|
152
|
+
name: config.name,
|
|
153
|
+
title: config.name, // TODO change
|
|
154
|
+
description: config.description,
|
|
155
|
+
dangerLevel: config.dangerLevel,
|
|
156
|
+
});
|
|
157
|
+
return customScript;
|
|
220
158
|
}
|
|
159
|
+
throw new Error(`Custom Script with uid "${config.uid}" not found`);
|
|
160
|
+
}
|
|
161
|
+
const response = yield (0, prompts_1.default)({
|
|
162
|
+
type: 'confirm',
|
|
163
|
+
name: 'create',
|
|
164
|
+
message: `Custom Script "${config.name}" does not exist. Do you want to create it?`,
|
|
165
|
+
});
|
|
166
|
+
if (!response.create) {
|
|
167
|
+
throw new Error('Custom Script upload was canceled.');
|
|
168
|
+
}
|
|
169
|
+
(0, log_1.log)('info', chalk_1.default.yellow(`Creating Custom Script "${config.name}"`));
|
|
170
|
+
const createdCustomScript = yield restApi.customScript.create({
|
|
171
|
+
name: config.name,
|
|
172
|
+
title: config.name, // TODO change
|
|
173
|
+
description: config.description,
|
|
174
|
+
dangerLevel: config.dangerLevel,
|
|
221
175
|
});
|
|
176
|
+
// TODO ask for permission or read from CLI arg
|
|
177
|
+
(0, log_1.log)('info', chalk_1.default.yellow('Adding Custom Script uid to the config file'));
|
|
178
|
+
yield addToConfigFile(process.cwd(), { uid: createdCustomScript.uid });
|
|
179
|
+
return createdCustomScript;
|
|
222
180
|
});
|
|
223
181
|
}
|
|
224
182
|
function uploadCode(_a) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
return [4 /*yield*/, generateCustomScriptPlatformCodeArchive(workDir, config, customScriptVersion, platform)];
|
|
233
|
-
case 1:
|
|
234
|
-
codeArchive = _b.sent();
|
|
235
|
-
return [4 /*yield*/, restApi.customScript.version.platform.get({
|
|
236
|
-
customScriptUid: customScriptVersion.customScriptUid,
|
|
237
|
-
version: customScriptVersion.version,
|
|
238
|
-
platform: platform,
|
|
239
|
-
})];
|
|
240
|
-
case 2:
|
|
241
|
-
customScriptVersionPlatform = _b.sent();
|
|
242
|
-
if ((customScriptVersionPlatform === null || customScriptVersionPlatform === void 0 ? void 0 : customScriptVersionPlatform.md5Checksum) === codeArchive.md5Checksum) {
|
|
243
|
-
(0, log_1.log)('info', chalk_1.default.yellow("Skipping upload for ".concat(platform, " - no changes detected")));
|
|
244
|
-
return [2 /*return*/];
|
|
245
|
-
}
|
|
246
|
-
_b.label = 3;
|
|
247
|
-
case 3:
|
|
248
|
-
_b.trys.push([3, , 6, 8]);
|
|
249
|
-
(0, log_1.log)('info', chalk_1.default.yellow("Uploading files for ".concat(platform)));
|
|
250
|
-
return [4 /*yield*/, uploadCodeArchive({
|
|
251
|
-
restApi: restApi,
|
|
252
|
-
customScriptVersion: customScriptVersion,
|
|
253
|
-
platform: platform,
|
|
254
|
-
codeArchive: codeArchive,
|
|
255
|
-
})];
|
|
256
|
-
case 4:
|
|
257
|
-
_b.sent();
|
|
258
|
-
return [4 /*yield*/, restApi.customScript.version.platform.update({
|
|
259
|
-
customScriptUid: customScriptVersion.customScriptUid,
|
|
260
|
-
version: customScriptVersion.version,
|
|
261
|
-
platform: platform,
|
|
262
|
-
mainFile: mainFile,
|
|
263
|
-
runtime: runtime,
|
|
264
|
-
md5Checksum: codeArchive.md5Checksum,
|
|
265
|
-
})];
|
|
266
|
-
case 5:
|
|
267
|
-
_b.sent();
|
|
268
|
-
return [3 /*break*/, 8];
|
|
269
|
-
case 6: return [4 /*yield*/, codeArchive.delete()];
|
|
270
|
-
case 7:
|
|
271
|
-
_b.sent();
|
|
272
|
-
return [7 /*endfinally*/];
|
|
273
|
-
case 8: return [2 /*return*/];
|
|
274
|
-
}
|
|
183
|
+
return __awaiter(this, arguments, void 0, function* ({ restApi, workDir, platform, config, customScriptVersion, }) {
|
|
184
|
+
const { mainFile, runtime } = config;
|
|
185
|
+
const codeArchive = yield generateCustomScriptPlatformCodeArchive(workDir, config, customScriptVersion, platform);
|
|
186
|
+
const customScriptVersionPlatform = yield restApi.customScript.version.platform.get({
|
|
187
|
+
customScriptUid: customScriptVersion.customScriptUid,
|
|
188
|
+
version: customScriptVersion.version,
|
|
189
|
+
platform,
|
|
275
190
|
});
|
|
191
|
+
if ((customScriptVersionPlatform === null || customScriptVersionPlatform === void 0 ? void 0 : customScriptVersionPlatform.md5Checksum) === codeArchive.md5Checksum) {
|
|
192
|
+
(0, log_1.log)('info', chalk_1.default.yellow(`Skipping upload for ${platform} - no changes detected`));
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
(0, log_1.log)('info', chalk_1.default.yellow(`Uploading files for ${platform}`));
|
|
197
|
+
yield uploadCodeArchive({
|
|
198
|
+
restApi,
|
|
199
|
+
customScriptVersion,
|
|
200
|
+
platform,
|
|
201
|
+
codeArchive,
|
|
202
|
+
});
|
|
203
|
+
yield restApi.customScript.version.platform.update({
|
|
204
|
+
customScriptUid: customScriptVersion.customScriptUid,
|
|
205
|
+
version: customScriptVersion.version,
|
|
206
|
+
platform,
|
|
207
|
+
mainFile,
|
|
208
|
+
runtime,
|
|
209
|
+
md5Checksum: codeArchive.md5Checksum,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
finally {
|
|
213
|
+
yield codeArchive.delete();
|
|
214
|
+
}
|
|
276
215
|
});
|
|
277
216
|
}
|
|
278
|
-
exports.uploadCode = uploadCode;
|
|
279
217
|
function uploadCodeArchive(_a) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
return [4 /*yield*/, restApi.customScript.version.platform.archive.upload({
|
|
292
|
-
customScriptUid: customScriptVersion.customScriptUid,
|
|
293
|
-
version: customScriptVersion.version,
|
|
294
|
-
platform: platform,
|
|
295
|
-
md5Checksum: codeArchive.md5Checksum,
|
|
296
|
-
size: fileSize,
|
|
297
|
-
stream: fileStream,
|
|
298
|
-
})];
|
|
299
|
-
case 2:
|
|
300
|
-
_b.sent();
|
|
301
|
-
return [2 /*return*/];
|
|
302
|
-
}
|
|
218
|
+
return __awaiter(this, arguments, void 0, function* ({ restApi, customScriptVersion, platform, codeArchive, }) {
|
|
219
|
+
const filePath = codeArchive.filePath;
|
|
220
|
+
const fileSize = (yield fs.stat(filePath)).size;
|
|
221
|
+
const fileStream = fs.createReadStream(filePath);
|
|
222
|
+
yield restApi.customScript.version.platform.archive.upload({
|
|
223
|
+
customScriptUid: customScriptVersion.customScriptUid,
|
|
224
|
+
version: customScriptVersion.version,
|
|
225
|
+
platform,
|
|
226
|
+
md5Checksum: codeArchive.md5Checksum,
|
|
227
|
+
size: fileSize,
|
|
228
|
+
stream: fileStream,
|
|
303
229
|
});
|
|
304
230
|
});
|
|
305
231
|
}
|
|
@@ -310,39 +236,21 @@ function uploadCodeArchive(_a) {
|
|
|
310
236
|
* After archive isn't needed anymore, it should be deleted using the delete method.
|
|
311
237
|
*/
|
|
312
238
|
function generateCustomScriptPlatformCodeArchive(workDir, config, customScriptVersion, platform) {
|
|
313
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
return [2 /*return*/, {
|
|
329
|
-
filePath: archiveFilePath,
|
|
330
|
-
md5Checksum: md5Checksum,
|
|
331
|
-
delete: function () {
|
|
332
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
333
|
-
return __generator(this, function (_a) {
|
|
334
|
-
switch (_a.label) {
|
|
335
|
-
case 0: return [4 /*yield*/, fs.unlink(archiveFilePath)];
|
|
336
|
-
case 1:
|
|
337
|
-
_a.sent();
|
|
338
|
-
return [2 /*return*/];
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
});
|
|
342
|
-
},
|
|
343
|
-
}];
|
|
344
|
-
}
|
|
345
|
-
});
|
|
239
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
240
|
+
const buildsDir = yield ensureBuildsDirectory(customScriptVersion);
|
|
241
|
+
const archiveFileName = `${platform}.zip`;
|
|
242
|
+
const archiveFilePath = path.join(buildsDir, archiveFileName);
|
|
243
|
+
yield (0, archive_1.generateZip)(workDir, config.rootDir, archiveFilePath);
|
|
244
|
+
const md5Checksum = yield (0, fileSystem_1.getFileMD5Checksum)(archiveFilePath);
|
|
245
|
+
return {
|
|
246
|
+
filePath: archiveFilePath,
|
|
247
|
+
md5Checksum,
|
|
248
|
+
delete() {
|
|
249
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
250
|
+
yield fs.unlink(archiveFilePath);
|
|
251
|
+
});
|
|
252
|
+
},
|
|
253
|
+
};
|
|
346
254
|
});
|
|
347
255
|
}
|
|
348
256
|
/**
|
|
@@ -351,20 +259,11 @@ function generateCustomScriptPlatformCodeArchive(workDir, config, customScriptVe
|
|
|
351
259
|
* This directory is used to store temporary files generated by the CLI.
|
|
352
260
|
*/
|
|
353
261
|
function ensureBuildsDirectory(customScriptVersion) {
|
|
354
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
case 1:
|
|
360
|
-
runtimeDir = _a.sent();
|
|
361
|
-
buildsDir = path.join(runtimeDir, customScriptVersion.customScriptUid, customScriptVersion.version);
|
|
362
|
-
return [4 /*yield*/, fs.ensureDir(buildsDir)];
|
|
363
|
-
case 2:
|
|
364
|
-
_a.sent();
|
|
365
|
-
return [2 /*return*/, buildsDir];
|
|
366
|
-
}
|
|
367
|
-
});
|
|
262
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
263
|
+
const runtimeDir = yield ensureRuntimeDir();
|
|
264
|
+
const buildsDir = path.join(runtimeDir, customScriptVersion.customScriptUid, customScriptVersion.version);
|
|
265
|
+
yield fs.ensureDir(buildsDir);
|
|
266
|
+
return buildsDir;
|
|
368
267
|
});
|
|
369
268
|
}
|
|
370
269
|
/**
|
|
@@ -373,18 +272,9 @@ function ensureBuildsDirectory(customScriptVersion) {
|
|
|
373
272
|
* This directory is used to store temporary files generated by the CLI.
|
|
374
273
|
*/
|
|
375
274
|
function ensureRuntimeDir() {
|
|
376
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
case 0:
|
|
381
|
-
runtimeDir = path.join(os.tmpdir(), runtimeFileSystem_1.RUNTIME_DIRNAME, CUSTOM_SCRIPTS_BUILDS_DIRNAME);
|
|
382
|
-
return [4 /*yield*/, fs.ensureDir(runtimeDir)];
|
|
383
|
-
case 1:
|
|
384
|
-
_a.sent();
|
|
385
|
-
return [2 /*return*/, runtimeDir];
|
|
386
|
-
}
|
|
387
|
-
});
|
|
275
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
276
|
+
const runtimeDir = path.join(os.tmpdir(), runtimeFileSystem_1.RUNTIME_DIRNAME, CUSTOM_SCRIPTS_BUILDS_DIRNAME);
|
|
277
|
+
yield fs.ensureDir(runtimeDir);
|
|
278
|
+
return runtimeDir;
|
|
388
279
|
});
|
|
389
280
|
}
|
|
390
|
-
//# sourceMappingURL=customScriptFacade.js.map
|