@signageos/cli 2.3.1 → 2.3.2
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 +1 -0
- package/dist/Applet/Build/appletBuildCommand.js +28 -72
- 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 +398 -365
- package/dist/Applet/Start/appletStartCommand.js +69 -131
- package/dist/Applet/Test/Upload/appletTestRunCommand.js +89 -177
- package/dist/Applet/Test/Upload/appletTestRunFacade.js +4 -27
- package/dist/Applet/Test/Upload/appletTestUploadCommand.js +98 -223
- package/dist/Applet/Test/Upload/appletTestUploadFacade.js +39 -102
- package/dist/Applet/Test/appletTestCommand.js +6 -36
- package/dist/Applet/Upload/appletUploadCommand.js +199 -305
- package/dist/Applet/Upload/appletUploadCommandHelper.js +103 -138
- package/dist/Applet/Upload/appletUploadFacade.d.ts +2 -2
- package/dist/Applet/Upload/appletUploadFacade.js +172 -263
- package/dist/Applet/Upload/appletUploadFacadeHelper.js +39 -52
- package/dist/Applet/appletCommand.d.ts +22 -62
- package/dist/Applet/appletCommand.js +9 -39
- package/dist/Applet/appletErrors.js +5 -24
- package/dist/Applet/appletFacade.js +106 -141
- package/dist/Applet/appletServerHelper.js +16 -53
- package/dist/Auth/loginCommand.js +96 -137
- package/dist/Cache/tmpCache.js +35 -13
- package/dist/Cli/helper.js +1 -2
- package/dist/Cli/packageVersion.js +82 -123
- package/dist/Command/commandDefinition.js +0 -1
- package/dist/Command/commandProcessor.js +40 -129
- package/dist/Command/globalArgs.js +7 -5
- package/dist/CommandLine/IProgressBar.js +0 -1
- package/dist/CommandLine/progressBarFactory.js +31 -11
- package/dist/CustomScript/Generate/customScriptGenerateCommand.js +17 -56
- package/dist/CustomScript/Generate/customScriptGenerateFacade.js +82 -106
- package/dist/CustomScript/Upload/customScriptUploadCommand.js +44 -120
- package/dist/CustomScript/customScriptCommand.js +6 -36
- package/dist/CustomScript/customScriptFacade.js +175 -294
- package/dist/Device/Connect/connectCommand.js +72 -136
- 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 +67 -123
- package/dist/Emulator/IEmulator.js +0 -1
- package/dist/Emulator/createDomain.js +33 -12
- package/dist/Emulator/emulatorFacade.js +74 -131
- package/dist/Emulator/emulatorFactory.js +112 -124
- package/dist/Firmware/Upload/firmwareUploadCommand.js +133 -221
- package/dist/Firmware/Upload/firmwareUploadFacade.js +64 -110
- package/dist/Firmware/Upload/firmwareUploadHelper.js +27 -5
- package/dist/Firmware/firmwareCommand.js +5 -35
- package/dist/Lib/archive.js +45 -60
- package/dist/Lib/childProcess.js +27 -5
- package/dist/Lib/fileSystem.js +62 -82
- package/dist/Lib/git.d.ts +1 -1
- package/dist/Lib/git.js +44 -82
- 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 +97 -172
- package/dist/RunControl/runControlHelper.js +11 -60
- package/dist/Timer/wait.js +1 -2
- package/dist/Timing/List/timingListCommand.js +20 -62
- package/dist/Timing/timingCommand.js +5 -35
- package/dist/generalCommand.js +1 -2
- package/dist/helper.js +48 -109
- package/dist/index.js +15 -45
- package/dist/parameters.js +17 -40
- package/package.json +16 -18
- 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,27 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,291 +31,177 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
32
|
});
|
|
10
33
|
};
|
|
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
|
-
}
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
36
|
};
|
|
38
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
38
|
exports.createMultiFileFileApplet = exports.createSingleFileApplet = exports.updateMultiFileApplet = exports.updateSingleFileApplet = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
const fs = __importStar(require("fs-extra"));
|
|
41
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
42
|
+
const debug_1 = __importDefault(require("debug"));
|
|
43
|
+
const NotFoundError_1 = __importDefault(require("@signageos/sdk/dist/RestApi/Error/NotFoundError"));
|
|
44
|
+
const appletUploadFacadeHelper_1 = require("./appletUploadFacadeHelper");
|
|
45
|
+
const fileSystem_1 = require("../../Lib/fileSystem");
|
|
46
|
+
const log_1 = require("@signageos/sdk/dist/Console/log");
|
|
47
|
+
const Debug = (0, debug_1.default)('@signageos/cli:Applet:Upload:appletUploadFacade');
|
|
49
48
|
function updateSingleFileApplet(parameters) {
|
|
50
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
appletBinary = fs.createReadStream(applet.binaryFilePath, { encoding: 'utf8' });
|
|
57
|
-
return [4 /*yield*/, restApi.applet.version.update(applet.uid, applet.version, {
|
|
58
|
-
binary: appletBinary,
|
|
59
|
-
frontAppletVersion: applet.frontAppletVersion,
|
|
60
|
-
})];
|
|
61
|
-
case 1:
|
|
62
|
-
_a.sent();
|
|
63
|
-
return [2 /*return*/];
|
|
64
|
-
}
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const { restApi, applet } = parameters;
|
|
51
|
+
const appletBinary = fs.createReadStream(applet.binaryFilePath, { encoding: 'utf8' });
|
|
52
|
+
yield restApi.applet.version.update(applet.uid, applet.version, {
|
|
53
|
+
binary: appletBinary,
|
|
54
|
+
frontAppletVersion: applet.frontAppletVersion,
|
|
65
55
|
});
|
|
66
56
|
});
|
|
67
57
|
}
|
|
68
58
|
exports.updateSingleFileApplet = updateSingleFileApplet;
|
|
69
|
-
|
|
70
|
-
var
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
fileStream
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return [3 /*break*/, 9];
|
|
130
|
-
case 8:
|
|
131
|
-
error_1 = _c.sent();
|
|
132
|
-
if (fileSize === 0) {
|
|
133
|
-
throw new Error("Empty files are temporarily disallowed ".concat(fileAbsolutePath));
|
|
134
|
-
}
|
|
135
|
-
throw error_1;
|
|
136
|
-
case 9:
|
|
137
|
-
index++;
|
|
138
|
-
return [3 /*break*/, 2];
|
|
139
|
-
case 10:
|
|
140
|
-
_a = [];
|
|
141
|
-
for (_b in currentAppletFiles)
|
|
142
|
-
_a.push(_b);
|
|
143
|
-
_i = 0;
|
|
144
|
-
_c.label = 11;
|
|
145
|
-
case 11:
|
|
146
|
-
if (!(_i < _a.length)) return [3 /*break*/, 17];
|
|
147
|
-
fileRelativePath = _a[_i];
|
|
148
|
-
if (!currentAppletFiles.hasOwnProperty(fileRelativePath)) return [3 /*break*/, 16];
|
|
149
|
-
_c.label = 12;
|
|
150
|
-
case 12:
|
|
151
|
-
_c.trys.push([12, 14, , 15]);
|
|
152
|
-
return [4 /*yield*/, restApi.applet.version.file.remove(applet.uid, applet.version, fileRelativePath, { build: false })];
|
|
153
|
-
case 13:
|
|
154
|
-
_c.sent();
|
|
155
|
-
return [3 /*break*/, 15];
|
|
156
|
-
case 14:
|
|
157
|
-
error_2 = _c.sent();
|
|
158
|
-
if (error_2 instanceof NotFoundError_1.default) {
|
|
59
|
+
const updateMultiFileApplet = (parameters) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
const { restApi, applet, progressBar } = parameters;
|
|
62
|
+
const currentAppletFiles = yield (0, appletUploadFacadeHelper_1.getAppletFilesDictionary)(restApi, applet.uid, applet.version);
|
|
63
|
+
let changedFilesCounter = 0;
|
|
64
|
+
for (let index = 0; index < applet.files.length; index++) {
|
|
65
|
+
const fileAbsolutePath = applet.files[index];
|
|
66
|
+
if (!fileAbsolutePath) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const fileRelativePath = (0, appletUploadFacadeHelper_1.getAppletFileRelativePath)(fileAbsolutePath, applet.directoryPath);
|
|
70
|
+
const fileRelativePosixPath = path.posix.normalize(fileRelativePath.replace(/\\/g, '/'));
|
|
71
|
+
const fileStats = yield fs.stat(fileAbsolutePath);
|
|
72
|
+
const fileSize = fileStats.size;
|
|
73
|
+
const fileHash = yield (0, fileSystem_1.getFileMD5Checksum)(fileAbsolutePath);
|
|
74
|
+
const fileType = yield (0, fileSystem_1.getFileType)(fileAbsolutePath);
|
|
75
|
+
const currentFileHash = (_a = currentAppletFiles[fileRelativePosixPath]) === null || _a === void 0 ? void 0 : _a.hash;
|
|
76
|
+
const currentFileType = (_b = currentAppletFiles[fileRelativePosixPath]) === null || _b === void 0 ? void 0 : _b.type;
|
|
77
|
+
delete currentAppletFiles[fileRelativePosixPath];
|
|
78
|
+
Debug('check file changed', fileHash, currentFileHash, fileType, currentFileType);
|
|
79
|
+
if (fileHash === currentFileHash && fileType === currentFileType) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
changedFilesCounter++;
|
|
84
|
+
(0, log_1.log)('info', chalk_1.default.yellow(` Uploading ${fileAbsolutePath}`));
|
|
85
|
+
}
|
|
86
|
+
if (progressBar) {
|
|
87
|
+
progressBar.init({ size: fileSize, name: fileRelativePath });
|
|
88
|
+
}
|
|
89
|
+
const fileStream = fs.createReadStream(fileAbsolutePath);
|
|
90
|
+
fileStream.pause();
|
|
91
|
+
fileStream.on('data', (chunk) => {
|
|
92
|
+
if (progressBar) {
|
|
93
|
+
progressBar.update({ add: chunk.length });
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
try {
|
|
97
|
+
// update file is just alias to create file (both are idempotent)
|
|
98
|
+
yield restApi.applet.version.file.update(applet.uid, applet.version, fileRelativePosixPath, {
|
|
99
|
+
content: fileStream,
|
|
100
|
+
hash: fileHash,
|
|
101
|
+
size: fileSize,
|
|
102
|
+
type: fileType,
|
|
103
|
+
}, { build: false });
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
if (fileSize === 0) {
|
|
107
|
+
throw new Error(`Empty files are temporarily disallowed ${fileAbsolutePath}`);
|
|
108
|
+
}
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
for (const fileRelativePath in currentAppletFiles) {
|
|
113
|
+
if (currentAppletFiles.hasOwnProperty(fileRelativePath)) {
|
|
114
|
+
try {
|
|
115
|
+
yield restApi.applet.version.file.remove(applet.uid, applet.version, fileRelativePath, { build: false });
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
if (error instanceof NotFoundError_1.default) {
|
|
159
119
|
/*
|
|
160
120
|
* This means that the file we are trying to remove somehow already got removed.
|
|
161
121
|
* It's not expected behavior but the running CLI command shouldn't fail because of it.
|
|
162
122
|
* Probably it's caused by some other process interfering.
|
|
163
123
|
*/
|
|
164
|
-
|
|
124
|
+
Debug(`remove old file ${fileRelativePath} failed`);
|
|
165
125
|
}
|
|
166
126
|
else {
|
|
167
|
-
throw
|
|
168
|
-
}
|
|
169
|
-
return [3 /*break*/, 15];
|
|
170
|
-
case 15:
|
|
171
|
-
changedFilesCounter++;
|
|
172
|
-
_c.label = 16;
|
|
173
|
-
case 16:
|
|
174
|
-
_i++;
|
|
175
|
-
return [3 /*break*/, 11];
|
|
176
|
-
case 17: return [4 /*yield*/, restApi.applet.version.get(applet.uid, applet.version)];
|
|
177
|
-
case 18:
|
|
178
|
-
appletVersion = _c.sent();
|
|
179
|
-
appletEntryFilePosixPath = path.posix.normalize(applet.entryFilePath.replace(/\\/g, '/'));
|
|
180
|
-
if (!(changedFilesCounter > 0 || appletVersion.entryFile !== appletEntryFilePosixPath)) return [3 /*break*/, 20];
|
|
181
|
-
// The update applet version has to be the last after upload all files to trigger applet version build
|
|
182
|
-
return [4 /*yield*/, restApi.applet.version.update(applet.uid, applet.version, {
|
|
183
|
-
entryFile: appletEntryFilePosixPath,
|
|
184
|
-
})];
|
|
185
|
-
case 19:
|
|
186
|
-
// The update applet version has to be the last after upload all files to trigger applet version build
|
|
187
|
-
_c.sent();
|
|
188
|
-
_c.label = 20;
|
|
189
|
-
case 20:
|
|
190
|
-
if (progressBar) {
|
|
191
|
-
progressBar.end();
|
|
127
|
+
throw error;
|
|
192
128
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
return [2 /*return*/];
|
|
129
|
+
}
|
|
130
|
+
changedFilesCounter++;
|
|
197
131
|
}
|
|
198
|
-
}
|
|
199
|
-
|
|
132
|
+
}
|
|
133
|
+
const appletVersion = yield restApi.applet.version.get(applet.uid, applet.version);
|
|
134
|
+
const appletEntryFilePosixPath = path.posix.normalize(applet.entryFilePath.replace(/\\/g, '/'));
|
|
135
|
+
if (changedFilesCounter > 0 || appletVersion.entryFile !== appletEntryFilePosixPath) {
|
|
136
|
+
// The update applet version has to be the last after upload all files to trigger applet version build
|
|
137
|
+
yield restApi.applet.version.update(applet.uid, applet.version, {
|
|
138
|
+
entryFile: appletEntryFilePosixPath,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
if (progressBar) {
|
|
142
|
+
progressBar.end();
|
|
143
|
+
}
|
|
144
|
+
if (changedFilesCounter === 0) {
|
|
145
|
+
(0, log_1.log)('info', `No files changed in ${chalk_1.default.yellow.bold(applet.directoryPath)}`);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
200
148
|
exports.updateMultiFileApplet = updateMultiFileApplet;
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
return [4 /*yield*/, restApi.applet.version.create(applet.uid, {
|
|
209
|
-
binary: appletBinary,
|
|
210
|
-
version: applet.version,
|
|
211
|
-
frontAppletVersion: applet.frontAppletVersion,
|
|
212
|
-
})];
|
|
213
|
-
case 1:
|
|
214
|
-
_a.sent();
|
|
215
|
-
return [2 /*return*/];
|
|
216
|
-
}
|
|
149
|
+
const createSingleFileApplet = (parameters) => __awaiter(void 0, void 0, void 0, function* () {
|
|
150
|
+
const { restApi, applet } = parameters;
|
|
151
|
+
const appletBinary = fs.createReadStream(applet.binaryFilePath, { encoding: 'utf8' });
|
|
152
|
+
yield restApi.applet.version.create(applet.uid, {
|
|
153
|
+
binary: appletBinary,
|
|
154
|
+
version: applet.version,
|
|
155
|
+
frontAppletVersion: applet.frontAppletVersion,
|
|
217
156
|
});
|
|
218
|
-
});
|
|
157
|
+
});
|
|
219
158
|
exports.createSingleFileApplet = createSingleFileApplet;
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
return [4 /*yield*/, (0, fileSystem_1.getFileMD5Checksum)(fileAbsolutePath)];
|
|
243
|
-
case 1:
|
|
244
|
-
fileHash = _a.sent();
|
|
245
|
-
return [4 /*yield*/, (0, fileSystem_1.getFileType)(fileAbsolutePath)];
|
|
246
|
-
case 2:
|
|
247
|
-
fileType = _a.sent();
|
|
248
|
-
return [4 /*yield*/, fs.stat(fileAbsolutePath)];
|
|
249
|
-
case 3:
|
|
250
|
-
fileSize = (_a.sent()).size;
|
|
251
|
-
if (fileSize === 0) {
|
|
252
|
-
throw new Error("Empty files are temporarily disallowed ".concat(fileAbsolutePath));
|
|
253
|
-
}
|
|
254
|
-
if (progressBar) {
|
|
255
|
-
progressBar.init({ size: fileSize, name: fileRelativePath });
|
|
256
|
-
}
|
|
257
|
-
fileStream = fs.createReadStream(fileAbsolutePath);
|
|
258
|
-
fileStream.pause();
|
|
259
|
-
fileStream.on('data', function (chunk) {
|
|
260
|
-
if (progressBar) {
|
|
261
|
-
progressBar.update({ add: chunk.length });
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
filePosixPath = path.posix.normalize(fileRelativePath.replace(/\\/g, '/'));
|
|
265
|
-
(0, log_1.log)('info', chalk_1.default.yellow(" Uploading ".concat(fileAbsolutePath)));
|
|
266
|
-
return [2 /*return*/, restApi.applet.version.file.create(applet.uid, applet.version, {
|
|
267
|
-
name: path.basename(filePosixPath),
|
|
268
|
-
path: filePosixPath,
|
|
269
|
-
type: fileType,
|
|
270
|
-
hash: fileHash,
|
|
271
|
-
content: fileStream,
|
|
272
|
-
size: fileSize,
|
|
273
|
-
}, { build: false })];
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
}); }))];
|
|
277
|
-
case 3:
|
|
278
|
-
_a.sent();
|
|
279
|
-
return [3 /*break*/, 5];
|
|
280
|
-
case 4:
|
|
159
|
+
const createMultiFileFileApplet = (parameters) => __awaiter(void 0, void 0, void 0, function* () {
|
|
160
|
+
const { restApi, applet, progressBar } = parameters;
|
|
161
|
+
const appletEntryFilePosixPath = path.posix.normalize(applet.entryFilePath.replace(/\\/g, '/'));
|
|
162
|
+
try {
|
|
163
|
+
yield restApi.applet.version.create(applet.uid, {
|
|
164
|
+
version: applet.version,
|
|
165
|
+
entryFile: appletEntryFilePosixPath,
|
|
166
|
+
});
|
|
167
|
+
yield Promise.all(applet.files.map((fileAbsolutePath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
168
|
+
const fileRelativePath = (0, appletUploadFacadeHelper_1.getAppletFileRelativePath)(fileAbsolutePath, applet.directoryPath);
|
|
169
|
+
const fileHash = yield (0, fileSystem_1.getFileMD5Checksum)(fileAbsolutePath);
|
|
170
|
+
const fileType = yield (0, fileSystem_1.getFileType)(fileAbsolutePath);
|
|
171
|
+
const fileSize = (yield fs.stat(fileAbsolutePath)).size;
|
|
172
|
+
if (fileSize === 0) {
|
|
173
|
+
throw new Error(`Empty files are temporarily disallowed ${fileAbsolutePath}`);
|
|
174
|
+
}
|
|
175
|
+
if (progressBar) {
|
|
176
|
+
progressBar.init({ size: fileSize, name: fileRelativePath });
|
|
177
|
+
}
|
|
178
|
+
const fileStream = fs.createReadStream(fileAbsolutePath);
|
|
179
|
+
fileStream.pause();
|
|
180
|
+
fileStream.on('data', (chunk) => {
|
|
281
181
|
if (progressBar) {
|
|
282
|
-
progressBar.
|
|
182
|
+
progressBar.update({ add: chunk.length });
|
|
283
183
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
return
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
184
|
+
});
|
|
185
|
+
const filePosixPath = path.posix.normalize(fileRelativePath.replace(/\\/g, '/'));
|
|
186
|
+
(0, log_1.log)('info', chalk_1.default.yellow(` Uploading ${fileAbsolutePath}`));
|
|
187
|
+
return restApi.applet.version.file.create(applet.uid, applet.version, {
|
|
188
|
+
name: path.basename(filePosixPath),
|
|
189
|
+
path: filePosixPath,
|
|
190
|
+
type: fileType,
|
|
191
|
+
hash: fileHash,
|
|
192
|
+
content: fileStream,
|
|
193
|
+
size: fileSize,
|
|
194
|
+
}, { build: false });
|
|
195
|
+
})));
|
|
196
|
+
}
|
|
197
|
+
finally {
|
|
198
|
+
if (progressBar) {
|
|
199
|
+
progressBar.end();
|
|
294
200
|
}
|
|
201
|
+
}
|
|
202
|
+
// The extra update applet version which has to be after upload all files to trigger applet version build
|
|
203
|
+
yield restApi.applet.version.update(applet.uid, applet.version, {
|
|
204
|
+
entryFile: appletEntryFilePosixPath,
|
|
295
205
|
});
|
|
296
|
-
});
|
|
206
|
+
});
|
|
297
207
|
exports.createMultiFileFileApplet = createMultiFileFileApplet;
|
|
298
|
-
//# sourceMappingURL=appletUploadFacade.js.map
|
|
@@ -1,4 +1,27 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,72 +31,36 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
32
|
});
|
|
10
33
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
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
|
-
}
|
|
37
|
-
};
|
|
38
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
35
|
exports.getAppletFilesDictionary = exports.getAppletFileRelativePath = void 0;
|
|
40
|
-
|
|
36
|
+
const path = __importStar(require("path"));
|
|
41
37
|
function getAppletFileRelativePath(fileAbsolutePath, directoryAbsolutePath) {
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
const directoryAbsolutePathNormalized = path.normalize(directoryAbsolutePath);
|
|
39
|
+
const fileAbsolutePathNormalized = path.normalize(fileAbsolutePath);
|
|
44
40
|
if (!path.isAbsolute(fileAbsolutePathNormalized)) {
|
|
45
|
-
throw new Error(
|
|
41
|
+
throw new Error(`Internal Error: Got relative file path, but need absolute to continue. Current path: ${fileAbsolutePathNormalized}`);
|
|
46
42
|
}
|
|
47
43
|
if (!path.isAbsolute(directoryAbsolutePathNormalized)) {
|
|
48
|
-
throw new Error(
|
|
44
|
+
throw new Error(`Internal Error: Try input absolute applet directory path. Current path: ${directoryAbsolutePathNormalized}`);
|
|
49
45
|
}
|
|
50
|
-
|
|
46
|
+
const isFileInAppletDir = fileAbsolutePathNormalized.startsWith(directoryAbsolutePathNormalized);
|
|
51
47
|
if (!isFileInAppletDir) {
|
|
52
|
-
throw new Error(
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
throw new Error(`All project files must be in the project directory.` +
|
|
49
|
+
`\nFile path: ${fileAbsolutePathNormalized}` +
|
|
50
|
+
`\nApplet directory path: ${directoryAbsolutePathNormalized}`);
|
|
55
51
|
}
|
|
56
|
-
|
|
52
|
+
const fileRelativePath = fileAbsolutePathNormalized.substring(directoryAbsolutePathNormalized.length + 1);
|
|
57
53
|
return fileRelativePath;
|
|
58
54
|
}
|
|
59
55
|
exports.getAppletFileRelativePath = getAppletFileRelativePath;
|
|
60
56
|
function getAppletFilesDictionary(restApi, appletUid, appletVersion) {
|
|
61
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
filesDictionary = {};
|
|
67
|
-
return [4 /*yield*/, restApi.applet.version.file.list(appletUid, appletVersion)];
|
|
68
|
-
case 1:
|
|
69
|
-
currentAppletFiles = _a.sent();
|
|
70
|
-
currentAppletFiles.forEach(function (file) {
|
|
71
|
-
filesDictionary[file.path] = file;
|
|
72
|
-
});
|
|
73
|
-
return [2 /*return*/, filesDictionary];
|
|
74
|
-
}
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
const filesDictionary = {};
|
|
59
|
+
const currentAppletFiles = yield restApi.applet.version.file.list(appletUid, appletVersion);
|
|
60
|
+
currentAppletFiles.forEach((file) => {
|
|
61
|
+
filesDictionary[file.path] = file;
|
|
75
62
|
});
|
|
63
|
+
return filesDictionary;
|
|
76
64
|
});
|
|
77
65
|
}
|
|
78
66
|
exports.getAppletFilesDictionary = getAppletFilesDictionary;
|
|
79
|
-
//# sourceMappingURL=appletUploadFacadeHelper.js.map
|