@signageos/cli 1.1.5 → 1.2.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/CHANGELOG.md +14 -0
- package/README.md +23 -6
- package/dist/Applet/Build/appletBuildCommand.d.ts +33 -0
- package/dist/Applet/Build/appletBuildCommand.js +99 -0
- package/dist/Applet/Build/appletBuildCommand.js.map +1 -0
- package/dist/Applet/Generate/appletGenerateCommand.js +1 -1
- package/dist/Applet/Generate/appletGenerateCommand.js.map +1 -1
- package/dist/Applet/Start/appletStartCommand.d.ts +34 -8
- package/dist/Applet/Start/appletStartCommand.js +90 -24
- package/dist/Applet/Start/appletStartCommand.js.map +1 -1
- package/dist/Applet/Test/Upload/appletTestUploadCommand.js +1 -1
- package/dist/Applet/Test/Upload/appletTestUploadCommand.js.map +1 -1
- package/dist/Applet/Upload/appletUploadCommand.js +72 -79
- package/dist/Applet/Upload/appletUploadCommand.js.map +1 -1
- package/dist/Applet/Upload/appletUploadCommandHelper.d.ts +0 -3
- package/dist/Applet/Upload/appletUploadCommandHelper.js +18 -10
- package/dist/Applet/Upload/appletUploadCommandHelper.js.map +1 -1
- package/dist/Applet/appletCommand.d.ts +64 -8
- package/dist/Applet/appletCommand.js +2 -0
- package/dist/Applet/appletCommand.js.map +1 -1
- package/dist/Applet/appletFacade.js +3 -2
- package/dist/Applet/appletFacade.js.map +1 -1
- package/dist/Applet/appletServerHelper.d.ts +18 -0
- package/dist/Applet/appletServerHelper.js +83 -0
- package/dist/Applet/appletServerHelper.js.map +1 -0
- package/dist/Auth/loginCommand.js +2 -1
- package/dist/Auth/loginCommand.js.map +1 -1
- package/dist/Device/Connect/connectCommand.d.ts +28 -12
- package/dist/Device/Connect/connectCommand.js +55 -29
- package/dist/Device/Connect/connectCommand.js.map +1 -1
- package/dist/Device/deviceCommand.d.ts +28 -12
- package/dist/Device/deviceFacade.d.ts +0 -2
- package/dist/Device/deviceFacade.js +1 -40
- package/dist/Device/deviceFacade.js.map +1 -1
- package/dist/Emulator/IEmulator.d.ts +1 -1
- package/dist/Emulator/emulatorFacade.js.map +1 -1
- package/dist/Emulator/emulatorFactory.d.ts +4 -2
- package/dist/Emulator/emulatorFactory.js +84 -73
- package/dist/Emulator/emulatorFactory.js.map +1 -1
- package/dist/FileSystem/helper.d.ts +5 -10
- package/dist/FileSystem/helper.js +26 -147
- package/dist/FileSystem/helper.js.map +1 -1
- package/dist/RunControl/runControlHelper.d.ts +5 -9
- package/dist/RunControl/runControlHelper.js +24 -104
- package/dist/RunControl/runControlHelper.js.map +1 -1
- package/dist/helper.d.ts +1 -1
- package/dist/helper.js.map +1 -1
- package/dist/parameters.d.ts +0 -11
- package/dist/parameters.js +0 -13
- package/dist/parameters.js.map +1 -1
- package/package.json +3 -11
|
@@ -45,86 +45,97 @@ var cors = require("cors");
|
|
|
45
45
|
var serveStatic = require("serve-static");
|
|
46
46
|
var mime = require("mime");
|
|
47
47
|
var fsExtra = require("fs-extra");
|
|
48
|
-
var glob = require("globby");
|
|
49
48
|
var chalk_1 = require("chalk");
|
|
50
|
-
var createDomain_1 = require("./createDomain");
|
|
51
49
|
var log_1 = require("@signageos/sdk/dist/Console/log");
|
|
50
|
+
var helper_1 = require("../FileSystem/helper");
|
|
52
51
|
var DUMMY_CHECKSUM = '0000000000ffffffffff';
|
|
53
52
|
var APPLET_DIRECTORY_PATH = '/applet';
|
|
54
|
-
function createEmulator(params, organizationUid) {
|
|
55
|
-
var _a;
|
|
53
|
+
function createEmulator(params, organizationUid, dev) {
|
|
56
54
|
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
55
|
+
var appletUid, appletVersion, emulatorServerPort, appletPath, entryFileRelativePath, entryFileAbsolutePath, frontDisplayPath, frontDisplayDistPath, envVars, app, server;
|
|
56
|
+
var _this = this;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
appletUid = params.appletUid, appletVersion = params.appletVersion, emulatorServerPort = params.emulatorServerPort, appletPath = params.appletPath, entryFileRelativePath = params.entryFileRelativePath;
|
|
59
|
+
entryFileAbsolutePath = path.join(appletPath, entryFileRelativePath);
|
|
60
|
+
frontDisplayPath = path.dirname(require.resolve('@signageos/front-display/package.json', { paths: [appletPath] }));
|
|
61
|
+
frontDisplayDistPath = path.join(frontDisplayPath, 'dist');
|
|
62
|
+
if (!organizationUid) {
|
|
63
|
+
throw new Error("No default organization selected. Use ".concat(chalk_1.default.green('sos organization set-default'), " first."));
|
|
64
|
+
}
|
|
65
|
+
envVars = {
|
|
66
|
+
uid: appletUid || '__default_timing__',
|
|
67
|
+
version: appletVersion || '0.0.0',
|
|
68
|
+
organizationUid: organizationUid,
|
|
69
|
+
binaryFilePath: "".concat(APPLET_DIRECTORY_PATH, "/").concat(entryFileRelativePath),
|
|
70
|
+
checksum: DUMMY_CHECKSUM,
|
|
71
|
+
frontAppletVersion: '',
|
|
72
|
+
frontAppletBinaryFile: '', // has bundled front applet
|
|
73
|
+
};
|
|
74
|
+
app = express();
|
|
75
|
+
app.use(cors());
|
|
76
|
+
app.get('/', function (req, res) {
|
|
77
|
+
if (!req.query.duid) {
|
|
78
|
+
res.redirect("".concat(req.originalUrl).concat(req.originalUrl.includes('?') ? '&' : '?', "duid=").concat(params.emulatorUid));
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
res.send("<script>\n\t\t\t\t\twindow.__SOS_BUNDLED_APPLET = {};\n\t\t\t\t\twindow.__SOS_BUNDLED_APPLET.binaryFile = location.origin + ".concat(JSON.stringify(envVars.binaryFilePath), ";\n\t\t\t\t\twindow.__SOS_BUNDLED_APPLET.uid = ").concat(JSON.stringify(envVars.uid), ";\n\t\t\t\t\twindow.__SOS_BUNDLED_APPLET.version = ").concat(JSON.stringify(envVars.version), ";\n\t\t\t\t\twindow.__SOS_BUNDLED_APPLET.checksum = ").concat(JSON.stringify(envVars.checksum), ";\n\t\t\t\t\twindow.__SOS_BUNDLED_APPLET.frontAppletVersion = ").concat(JSON.stringify(envVars.frontAppletVersion), ";\n\t\t\t\t\twindow.__SOS_BUNDLED_APPLET.frontAppletBinaryFile = ").concat(JSON.stringify(envVars.frontAppletBinaryFile), ";\n\t\t\t\t\twindow.__SOS_AUTO_VERIFICATION = {};\n\t\t\t\t\twindow.__SOS_AUTO_VERIFICATION.organizationUid = ").concat(JSON.stringify(envVars.organizationUid), ";\n\t\t\t\t</script>")
|
|
82
|
+
+ fsExtra.readFileSync(path.join(frontDisplayDistPath, 'index.html')).toString());
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
app.use(serveStatic(frontDisplayDistPath));
|
|
86
|
+
server = http.createServer(app);
|
|
87
|
+
server.listen(emulatorServerPort, function () {
|
|
88
|
+
var emulatorUrl = "http://localhost:".concat(emulatorServerPort);
|
|
89
|
+
(0, log_1.log)('info', "Emulator is running at ".concat(chalk_1.default.blue(chalk_1.default.bold(emulatorUrl))));
|
|
90
|
+
});
|
|
91
|
+
app.use(APPLET_DIRECTORY_PATH, function (req, res) { return __awaiter(_this, void 0, void 0, function () {
|
|
92
|
+
var fileUrl, relativeFilePath, absoluteFilePath, appletFilePaths, prependFileContent, entryFileContent, contentType, readStream;
|
|
93
|
+
return __generator(this, function (_a) {
|
|
94
|
+
switch (_a.label) {
|
|
95
|
+
case 0:
|
|
96
|
+
fileUrl = url.parse(req.url);
|
|
97
|
+
relativeFilePath = fileUrl.pathname ? fileUrl.pathname.substring(1) : '';
|
|
98
|
+
absoluteFilePath = path.join(appletPath, relativeFilePath);
|
|
99
|
+
return [4 /*yield*/, dev.applet.files.listAppletFiles({
|
|
100
|
+
appletPath: appletPath,
|
|
101
|
+
})];
|
|
102
|
+
case 1:
|
|
103
|
+
appletFilePaths = _a.sent();
|
|
104
|
+
if (!(0, helper_1.isPathIncluded)(appletFilePaths, absoluteFilePath)) {
|
|
105
|
+
res.status(404).send("File \"".concat(relativeFilePath, "\" was not found"));
|
|
106
|
+
return [2 /*return*/];
|
|
107
|
+
}
|
|
108
|
+
if (!(relativeFilePath === entryFileRelativePath)) return [3 /*break*/, 3];
|
|
109
|
+
prependFileContent = '<script>window.onunload = function () { window.parent.location.reload(); }</script>';
|
|
110
|
+
res.setHeader('Content-Type', 'text/html');
|
|
111
|
+
return [4 /*yield*/, fsExtra.readFile(entryFileAbsolutePath, 'utf8')];
|
|
112
|
+
case 2:
|
|
113
|
+
entryFileContent = _a.sent();
|
|
114
|
+
res.send(prependFileContent + entryFileContent);
|
|
115
|
+
return [2 /*return*/];
|
|
116
|
+
case 3:
|
|
117
|
+
contentType = mime.getType(absoluteFilePath) || 'application/octet-stream';
|
|
114
118
|
res.setHeader('Content-Type', contentType);
|
|
115
|
-
|
|
119
|
+
readStream = fsExtra.createReadStream(absoluteFilePath);
|
|
116
120
|
readStream.pipe(res);
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
return [2 /*return*/];
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}); });
|
|
125
|
+
return [2 /*return*/, {
|
|
126
|
+
stop: function () {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
128
|
+
return __generator(this, function (_a) {
|
|
129
|
+
switch (_a.label) {
|
|
130
|
+
case 0: return [4 /*yield*/, new Promise(function (resolve, reject) { return server.close(function (error) { return error ? reject(error) : resolve(); }); })];
|
|
131
|
+
case 1:
|
|
132
|
+
_a.sent();
|
|
133
|
+
return [2 /*return*/];
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
},
|
|
138
|
+
}];
|
|
128
139
|
});
|
|
129
140
|
});
|
|
130
141
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emulatorFactory.js","sourceRoot":"","sources":["../../src/Emulator/emulatorFactory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2BAA6B;AAC7B,2BAA6B;AAC7B,yBAA2B;AAC3B,iCAAmC;AACnC,2BAA6B;AAC7B,0CAA4C;AAC5C,2BAA6B;AAC7B,kCAAoC;AACpC
|
|
1
|
+
{"version":3,"file":"emulatorFactory.js","sourceRoot":"","sources":["../../src/Emulator/emulatorFactory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2BAA6B;AAC7B,2BAA6B;AAC7B,yBAA2B;AAC3B,iCAAmC;AACnC,2BAA6B;AAC7B,0CAA4C;AAC5C,2BAA6B;AAC7B,kCAAoC;AACpC,+BAA0B;AAE1B,uDAAsD;AAEtD,+CAAsD;AAWtD,IAAM,cAAc,GAAG,sBAAsB,CAAC;AAC9C,IAAM,qBAAqB,GAAG,SAAS,CAAC;AAYxC,SAAsB,cAAc,CACnC,MAA6B,EA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O,EAAE,MAAM,IAAK,OAAA,MAAM,CAAC,KAAK,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,EAAjC,CAAiC,CAAC,EAA1D,CAA0D,CAAC,EAAA;;wCAAxG,SAAwG,CAAC;;;;;qBACzG;iBACD,EAAC;;;CACF;AA3FD,wCA2FC"}
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
export declare function computeFileMD5(filePath: string): Promise<string>;
|
|
2
2
|
export declare function getFileType(filePath: string): Promise<string>;
|
|
3
|
+
export declare function validateAllFormalities(appletPath: string, entryFileAbsolutePath: string, appletFilePaths: string[]): Promise<void>;
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* This is the platform/OS idependent way to check if a file is included in a list of files.
|
|
6
|
+
* So there can be backslashes and slashes on Windows and only slashes on Linux/UNIX.
|
|
7
|
+
* This function will ignore differences in slashes. It will only check if the file is included no matter what slashes are used.
|
|
5
8
|
*/
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function validateAllFormalities(appletDir: string, entryFile: string): Promise<void>;
|
|
8
|
-
/**
|
|
9
|
-
* @note glob patterns are also supported
|
|
10
|
-
* @param appletDir directory of applet
|
|
11
|
-
* @param files is a list of tracked files
|
|
12
|
-
* @returns all matched results, which are included in `files`
|
|
13
|
-
*/
|
|
14
|
-
export declare function getAllPaths(appletDir: string, files: string[]): Promise<string[]>;
|
|
9
|
+
export declare function isPathIncluded(filePaths: string[], filePath: string): boolean;
|
|
@@ -35,46 +35,15 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
-
if (!m) return o;
|
|
41
|
-
var i = m.call(o), r, ar = [], e;
|
|
42
|
-
try {
|
|
43
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
-
}
|
|
45
|
-
catch (error) { e = { error: error }; }
|
|
46
|
-
finally {
|
|
47
|
-
try {
|
|
48
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
-
}
|
|
50
|
-
finally { if (e) throw e.error; }
|
|
51
|
-
}
|
|
52
|
-
return ar;
|
|
53
|
-
};
|
|
54
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
55
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
56
|
-
if (ar || !(i in from)) {
|
|
57
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
58
|
-
ar[i] = from[i];
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
62
|
-
};
|
|
63
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
64
|
-
exports.
|
|
39
|
+
exports.isPathIncluded = exports.validateAllFormalities = exports.getFileType = exports.computeFileMD5 = void 0;
|
|
65
40
|
var fs = require("fs-extra");
|
|
66
41
|
var path = require("path");
|
|
67
42
|
var file_1 = require("@signageos/file");
|
|
68
|
-
var glob = require("globby");
|
|
69
|
-
var chalk_1 = require("chalk");
|
|
70
43
|
var Debug = require("debug");
|
|
71
44
|
var helper_1 = require("../Stream/helper");
|
|
72
|
-
var packageConfig_1 = require("
|
|
73
|
-
var log_1 = require("@signageos/sdk/dist/Console/log");
|
|
45
|
+
var packageConfig_1 = require("@signageos/sdk/dist/FileSystem/packageConfig");
|
|
74
46
|
var debug = Debug('@signageos/cli:FileSystem:helper');
|
|
75
|
-
var parseIgnoreFile = require('parse-gitignore');
|
|
76
|
-
var DEFAULT_IGNORE_FILE = '.sosignore';
|
|
77
|
-
var IGNORE_FILES = [DEFAULT_IGNORE_FILE, '.npmignore', '.gitignore'];
|
|
78
47
|
var DEFAULT_FILE_TYPE = 'application/octet-stream';
|
|
79
48
|
function computeFileMD5(filePath) {
|
|
80
49
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -105,133 +74,43 @@ function getFileType(filePath) {
|
|
|
105
74
|
});
|
|
106
75
|
}
|
|
107
76
|
exports.getFileType = getFileType;
|
|
108
|
-
|
|
109
|
-
* @note file existence is validated the very beginning of upload
|
|
110
|
-
*/
|
|
111
|
-
function listDirectoryContentRecursively(appletDirPath, ignoreFileDirPath) {
|
|
112
|
-
var _a;
|
|
77
|
+
function validateAllFormalities(appletPath, entryFileAbsolutePath, appletFilePaths) {
|
|
113
78
|
return __awaiter(this, void 0, void 0, function () {
|
|
114
|
-
var
|
|
115
|
-
return __generator(this, function (_b) {
|
|
116
|
-
switch (_b.label) {
|
|
117
|
-
case 0: return [4 /*yield*/, (0, packageConfig_1.loadPackage)(appletDirPath)];
|
|
118
|
-
case 1:
|
|
119
|
-
pkgJson = (_a = _b.sent()) !== null && _a !== void 0 ? _a : {};
|
|
120
|
-
files = [];
|
|
121
|
-
if (!(pkgJson.files && Array.isArray(pkgJson.files))) return [3 /*break*/, 3];
|
|
122
|
-
filesSet_1 = prepareFilesToInclude();
|
|
123
|
-
return [4 /*yield*/, getAllPaths(appletDirPath, pkgJson.files)];
|
|
124
|
-
case 2:
|
|
125
|
-
paths = _b.sent();
|
|
126
|
-
paths.forEach(function (p) { return filesSet_1.add(p); });
|
|
127
|
-
files = __spreadArray([], __read(filesSet_1), false).map(function (f) { return path.join(appletDirPath, f); });
|
|
128
|
-
return [3 /*break*/, 11];
|
|
129
|
-
case 3:
|
|
130
|
-
ignorePatterns_1 = [];
|
|
131
|
-
usedIgnoreFilePath = undefined;
|
|
132
|
-
index = 0;
|
|
133
|
-
_b.label = 4;
|
|
134
|
-
case 4:
|
|
135
|
-
if (!(index < IGNORE_FILES.length)) return [3 /*break*/, 7];
|
|
136
|
-
ignoreFileName = IGNORE_FILES[index];
|
|
137
|
-
ignoreFilePath = path.join(ignoreFileDirPath, ignoreFileName);
|
|
138
|
-
return [4 /*yield*/, fs.pathExists(ignoreFilePath)];
|
|
139
|
-
case 5:
|
|
140
|
-
ignoreFileExists = _b.sent();
|
|
141
|
-
if (ignoreFileExists) {
|
|
142
|
-
usedIgnoreFilePath = ignoreFilePath;
|
|
143
|
-
return [3 /*break*/, 7];
|
|
144
|
-
}
|
|
145
|
-
_b.label = 6;
|
|
146
|
-
case 6:
|
|
147
|
-
index++;
|
|
148
|
-
return [3 /*break*/, 4];
|
|
149
|
-
case 7:
|
|
150
|
-
if (usedIgnoreFilePath) {
|
|
151
|
-
(0, log_1.log)('info', "Use ignore file: ".concat(chalk_1.default.green.bold(usedIgnoreFilePath), "."));
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
(0, log_1.log)('info', "No ignore file found in ".concat(chalk_1.default.yellow.bold(ignoreFileDirPath), "."));
|
|
155
|
-
}
|
|
156
|
-
if (!usedIgnoreFilePath) return [3 /*break*/, 9];
|
|
157
|
-
return [4 /*yield*/, fs.readFile(usedIgnoreFilePath)];
|
|
158
|
-
case 8:
|
|
159
|
-
usedIgnoreFileBuffer = _b.sent();
|
|
160
|
-
ignoreFilePatterns = parseIgnoreFile(usedIgnoreFileBuffer);
|
|
161
|
-
ignoreFilePatterns.forEach(function (pattern) { return ignorePatterns_1.push("!".concat(pattern)); });
|
|
162
|
-
_b.label = 9;
|
|
163
|
-
case 9: return [4 /*yield*/, glob(__spreadArray(['**/*', '!node_modules/'], __read(ignorePatterns_1), false), {
|
|
164
|
-
cwd: appletDirPath,
|
|
165
|
-
absolute: true,
|
|
166
|
-
dot: true,
|
|
167
|
-
})];
|
|
168
|
-
case 10:
|
|
169
|
-
files = _b.sent();
|
|
170
|
-
_b.label = 11;
|
|
171
|
-
case 11:
|
|
172
|
-
debug('listed files', files);
|
|
173
|
-
return [2 /*return*/, files];
|
|
174
|
-
}
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
exports.listDirectoryContentRecursively = listDirectoryContentRecursively;
|
|
179
|
-
function prepareFilesToInclude() {
|
|
180
|
-
var alwaysInclude = [
|
|
181
|
-
'package.json',
|
|
182
|
-
];
|
|
183
|
-
return new Set(alwaysInclude);
|
|
184
|
-
}
|
|
185
|
-
function validateAllFormalities(appletDir, entryFile) {
|
|
186
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
187
|
-
var pkgJson, absolutePkgPath, paths;
|
|
79
|
+
var packageConfig, expectedMain, mainFileAbsolutePath;
|
|
188
80
|
return __generator(this, function (_a) {
|
|
189
81
|
switch (_a.label) {
|
|
190
|
-
case 0: return [4 /*yield*/, (0, packageConfig_1.loadPackage)(
|
|
82
|
+
case 0: return [4 /*yield*/, (0, packageConfig_1.loadPackage)(appletPath)];
|
|
191
83
|
case 1:
|
|
192
|
-
|
|
193
|
-
if (!
|
|
194
|
-
|
|
195
|
-
|
|
84
|
+
packageConfig = _a.sent();
|
|
85
|
+
if (!packageConfig) {
|
|
86
|
+
throw new Error("Cannot find package.json file in path ".concat(appletPath));
|
|
87
|
+
}
|
|
88
|
+
if (!packageConfig.main) {
|
|
89
|
+
expectedMain = entryFileAbsolutePath.slice(appletPath.length + 1);
|
|
90
|
+
throw new Error("The package.json is missing \"main\", but should to be \"".concat(expectedMain, "\""));
|
|
196
91
|
}
|
|
197
|
-
|
|
198
|
-
|
|
92
|
+
mainFileAbsolutePath = path.join(appletPath, packageConfig.main);
|
|
93
|
+
if (mainFileAbsolutePath !== entryFileAbsolutePath) {
|
|
94
|
+
throw new Error("".concat(packageConfig.main, " from package.json file doesn't match with entry file: ").concat(entryFileAbsolutePath));
|
|
199
95
|
}
|
|
200
|
-
if (!
|
|
201
|
-
|
|
202
|
-
case 2:
|
|
203
|
-
paths = _a.sent();
|
|
204
|
-
if (!paths.includes(pkgJson.main)) {
|
|
205
|
-
throw new Error("".concat(pkgJson.main, " is not a part of tracking files"));
|
|
96
|
+
if (!isPathIncluded(appletFilePaths, mainFileAbsolutePath)) {
|
|
97
|
+
throw new Error("".concat(packageConfig.main, " is not a part of tracking files"));
|
|
206
98
|
}
|
|
207
|
-
|
|
208
|
-
case 3: return [2 /*return*/];
|
|
99
|
+
return [2 /*return*/];
|
|
209
100
|
}
|
|
210
101
|
});
|
|
211
102
|
});
|
|
212
103
|
}
|
|
213
104
|
exports.validateAllFormalities = validateAllFormalities;
|
|
214
105
|
/**
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
* @returns all matched results, which are included in `files`
|
|
106
|
+
* This is the platform/OS idependent way to check if a file is included in a list of files.
|
|
107
|
+
* So there can be backslashes and slashes on Windows and only slashes on Linux/UNIX.
|
|
108
|
+
* This function will ignore differences in slashes. It will only check if the file is included no matter what slashes are used.
|
|
219
109
|
*/
|
|
220
|
-
function
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
switch (_a.label) {
|
|
225
|
-
case 0: return [4 /*yield*/, glob(files, {
|
|
226
|
-
cwd: appletDir,
|
|
227
|
-
dot: true,
|
|
228
|
-
})];
|
|
229
|
-
case 1:
|
|
230
|
-
paths = _a.sent();
|
|
231
|
-
return [2 /*return*/, paths];
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
});
|
|
110
|
+
function isPathIncluded(filePaths, filePath) {
|
|
111
|
+
var sanitizedFilePath = filePath.replace(/\\/g, '/');
|
|
112
|
+
var sanitizedFilePaths = filePaths.map(function (filePathItem) { return filePathItem.replace(/\\/g, '/'); });
|
|
113
|
+
return sanitizedFilePaths.includes(sanitizedFilePath);
|
|
235
114
|
}
|
|
236
|
-
exports.
|
|
115
|
+
exports.isPathIncluded = isPathIncluded;
|
|
237
116
|
//# sourceMappingURL=helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../src/FileSystem/helper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"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C,MAAM,GAAG,CAAC,CAAC,CAAC;wBACxE,MAAM,IAAI,KAAK,CAAC,mEAAyD,YAAY,OAAG,CAAC,CAAC;qBAC1F;oBAEK,oBAAoB,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;oBAEvE,IAAI,oBAAoB,KAAK,qBAAqB,EAAE;wBACnD,MAAM,IAAI,KAAK,CAAC,UAAG,aAAa,CAAC,IAAI,oEAA0D,qBAAqB,CAAE,CAAC,CAAC;qBACxH;oBAED,IAAI,CAAC,cAAc,CAAC,eAAe,EAAE,oBAAoB,CAAC,EAAE;wBAC3D,MAAM,IAAI,KAAK,CAAC,UAAG,aAAa,CAAC,IAAI,qCAAkC,CAAC,CAAC;qBACzE;;;;;CACD;AApBD,wDAoBC;AAED;;;;GAIG;AACH,SAAgB,cAAc,CAAC,SAAmB,EAAE,QAAgB;IACnE,IAAM,iBAAiB,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACvD,IAAM,kBAAkB,GAAG,SAAS,CAAC,GAAG,CAAC,UAAC,YAAY,IAAK,OAAA,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,EAAhC,CAAgC,CAAC,CAAC;IAC7F,OAAO,kBAAkB,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;AACvD,CAAC;AAJD,wCAIC"}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
defaultOrganizationUid?: string;
|
|
6
|
-
emulatorUid?: string;
|
|
7
|
-
}
|
|
1
|
+
import { IConfig } from '@signageos/sdk/dist/SosHelper/sosControlHelper';
|
|
2
|
+
/** The same as loadConfig in SDK, but respect CLI --profile argument */
|
|
3
|
+
export declare function loadConfig(): Promise<IConfig & Required<Pick<IConfig, "apiUrl">>>;
|
|
4
|
+
/** The same as saveConfig in SDK, but respect CLI --profile argument */
|
|
8
5
|
export declare function saveConfig(newConfig: IConfig): Promise<void>;
|
|
6
|
+
/** The same as updateConfig in SDK, but respect CLI --profile argument */
|
|
9
7
|
export declare function updateConfig(partialConfig: Partial<IConfig>): Promise<void>;
|
|
10
|
-
export declare function loadConfig(): Promise<IConfig>;
|
|
11
|
-
export declare function getConfigFilePath(): string;
|