camstreamerlib 1.6.2 → 1.7.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/CreatePackage.d.ts +1 -0
- package/CreatePackage.js +59 -0
- package/README.md +14 -0
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/CreatePackage.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const Path = require("path");
|
|
5
|
+
const AdmZip = require("adm-zip");
|
|
6
|
+
function isDirectory(path) {
|
|
7
|
+
const stat = fs.statSync(path);
|
|
8
|
+
return stat.isDirectory();
|
|
9
|
+
}
|
|
10
|
+
function createZipArchive(zip, folder, options) {
|
|
11
|
+
const files = fs.readdirSync(folder);
|
|
12
|
+
for (let file of files) {
|
|
13
|
+
const path = Path.join(folder, file);
|
|
14
|
+
const isDir = isDirectory(path);
|
|
15
|
+
if (file[0] == '.' ||
|
|
16
|
+
(file == 'node_modules' && !options.includeNodeModules) ||
|
|
17
|
+
(file == 'src' && options.typeScriptPackage)) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
else if (file == 'dist' && options.typeScriptPackage) {
|
|
21
|
+
zip.addLocalFolder(path);
|
|
22
|
+
}
|
|
23
|
+
else if (isDir) {
|
|
24
|
+
zip.addLocalFolder(path, file);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
zip.addLocalFile(path);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function main(args) {
|
|
32
|
+
const folder = Path.resolve('.');
|
|
33
|
+
const zipFile = Path.basename(folder) + '.zip';
|
|
34
|
+
const options = {
|
|
35
|
+
includeNodeModules: false,
|
|
36
|
+
typeScriptPackage: false,
|
|
37
|
+
};
|
|
38
|
+
for (let arg of args) {
|
|
39
|
+
if (arg == '-i' || arg == '-includeNodeModules') {
|
|
40
|
+
options.includeNodeModules = true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (fs.existsSync('dist')) {
|
|
44
|
+
options.typeScriptPackage = true;
|
|
45
|
+
}
|
|
46
|
+
if (fs.existsSync(zipFile)) {
|
|
47
|
+
try {
|
|
48
|
+
fs.unlinkSync(zipFile);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
console.log('An error occured: ', error);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const zip = new AdmZip();
|
|
56
|
+
createZipArchive(zip, folder, options);
|
|
57
|
+
zip.writeZip(zipFile);
|
|
58
|
+
}
|
|
59
|
+
main(process.argv.slice(2));
|
package/README.md
CHANGED
|
@@ -334,3 +334,17 @@ np
|
|
|
334
334
|
```
|
|
335
335
|
The utility will ask you for the prefered version raise and if you are lucky, everything will run just fine.
|
|
336
336
|
Finally, edit GitHub release form.
|
|
337
|
+
|
|
338
|
+
### Preparing a package to upload to CamScripter
|
|
339
|
+
If you want to create your own package and upload it to CamScripter App, you can use the script CreatePackage. It creates a zip file which contains all required files and directories in your package folder. The script accepts source code written either in JavaScript or TypeScript if the package has the correct structure (more information in https://github.com/CamStreamer/CamScripterApp_examples/#readme). To include this script in your package add the following lines in the file package.json:
|
|
340
|
+
```json
|
|
341
|
+
"scripts": {
|
|
342
|
+
"create-package": "node node_modules/camstreamerlib/CreatePackage.js"
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
By default, the zipped package does not contain node_modules directory. If you want to include it (required when uploading to CamScripter App on Axis camera), add this:
|
|
346
|
+
```json
|
|
347
|
+
"scripts": {
|
|
348
|
+
"create-package": "node node_modules/camstreamerlib/CreatePackage.js -includeNodeModules"
|
|
349
|
+
}
|
|
350
|
+
```
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "camstreamerlib",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Helper library for CamStreamer ACAP applications.",
|
|
5
5
|
"prettier": "@camstreamer/prettier-config",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"crypto": "^1.0.1",
|
|
8
8
|
"eventemitter2": "^5.0.1",
|
|
9
9
|
"prettify-xml": "^1.2.0",
|
|
10
|
+
"adm-zip": "^0.5.9",
|
|
10
11
|
"typescript": "^4.7.4",
|
|
11
12
|
"ws": "^7.4.2",
|
|
12
13
|
"xml2js": "^0.4.19"
|