camstreamerlib 2.0.0 → 2.0.1

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.
Files changed (2) hide show
  1. package/CreatePackage.js +19 -1
  2. package/package.json +1 -1
package/CreatePackage.js CHANGED
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const AdmZip = require("adm-zip");
4
4
  const Path = require("path");
5
5
  const fs = require("fs");
6
+ const child_process_1 = require("child_process");
6
7
  function isDirectory(path) {
7
8
  const stat = fs.statSync(path);
8
9
  return stat.isDirectory();
9
10
  }
11
+ const productionModulesFolder = 'production_modules';
10
12
  function getPackageVersion(folder) {
11
13
  try {
12
14
  const manifest = fs.readFileSync(Path.join(folder, 'manifest.json'));
@@ -25,7 +27,7 @@ function createZipArchive(zip, folder, options) {
25
27
  const isDir = isDirectory(path);
26
28
  if (file[0] === '.' ||
27
29
  zipFileRegex.test(file) ||
28
- (file === 'node_modules' && !options.includeNodeModules) ||
30
+ file === 'node_modules' ||
29
31
  (file === 'src' && options.typeScriptPackage) ||
30
32
  options.excludedFileNames.includes(file)) {
31
33
  continue;
@@ -33,6 +35,9 @@ function createZipArchive(zip, folder, options) {
33
35
  else if (file === 'dist' && options.typeScriptPackage) {
34
36
  zip.addLocalFolder(path);
35
37
  }
38
+ else if (file === productionModulesFolder && options.includeNodeModules) {
39
+ zip.addLocalFolder(Path.join(productionModulesFolder, 'node_modules'), 'node_modules');
40
+ }
36
41
  else if (isDir) {
37
42
  zip.addLocalFolder(path, file);
38
43
  }
@@ -41,6 +46,16 @@ function createZipArchive(zip, folder, options) {
41
46
  }
42
47
  }
43
48
  }
49
+ function installDependencies() {
50
+ if (!fs.existsSync(productionModulesFolder)) {
51
+ fs.mkdirSync(productionModulesFolder, {});
52
+ }
53
+ fs.cpSync('package.json', Path.join(productionModulesFolder, 'package.json'));
54
+ fs.cpSync('package-lock.json', Path.join(productionModulesFolder, 'package-lock.json'));
55
+ (0, child_process_1.execSync)(`npm ci --omit=dev`, {
56
+ cwd: Path.join(process.cwd(), productionModulesFolder),
57
+ });
58
+ }
44
59
  function main(args) {
45
60
  const options = {
46
61
  includeNodeModules: false,
@@ -55,6 +70,9 @@ function main(args) {
55
70
  options.excludedFileNames = arg.substring(arg.indexOf('=') + 1).split(',');
56
71
  }
57
72
  }
73
+ if (options.includeNodeModules) {
74
+ installDependencies();
75
+ }
58
76
  if (fs.existsSync('dist')) {
59
77
  options.typeScriptPackage = true;
60
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "camstreamerlib",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Helper library for CamStreamer ACAP applications.",
5
5
  "prettier": "@camstreamer/prettier-config",
6
6
  "dependencies": {