@companion-module/tools 0.2.0 → 0.3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.1](https://github.com/bitfocus/companion-module-tools/compare/v0.3.0...v0.3.1) (2022-10-01)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * errors ([26af195](https://github.com/bitfocus/companion-module-tools/commit/26af195288010c759dd354fc3d9e9d1946a1a16d))
9
+
10
+ ## [0.3.0](https://github.com/bitfocus/companion-module-tools/compare/v0.2.0...v0.3.0) (2022-10-01)
11
+
12
+
13
+ ### Features
14
+
15
+ * validateManifest before building module ([0166c7d](https://github.com/bitfocus/companion-module-tools/commit/0166c7da0ed725de77e3c71bc7992f8fd9deba94))
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * generating of manifest incorrectly processing 'products' field ([5f5ad9e](https://github.com/bitfocus/companion-module-tools/commit/5f5ad9e802249e4c9fe60ad8eb2278c715fa0a15))
21
+ * update runtime.api in conversion script ([ce95e96](https://github.com/bitfocus/companion-module-tools/commit/ce95e96626023e11ec7fe460278a3418dc6f0eaf))
22
+
3
23
  ## [0.2.0](https://github.com/bitfocus/companion-module-tools/compare/v0.1.1...v0.2.0) (2022-09-04)
4
24
 
5
25
 
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "@companion-module/tools",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
7
+ "repository": "https://github.com/bitfocus/companion-module-tools",
7
8
  "bin": {
8
9
  "companion-module-build": "scripts/build.js",
10
+ "companion-module-check": "scripts/check.js",
9
11
  "companion-generate-manifest": "scripts/generate-manifest.js"
10
12
  },
11
13
  "files": [
@@ -18,9 +20,9 @@
18
20
  "webpack.*"
19
21
  ],
20
22
  "dependencies": {
21
- "@typescript-eslint/eslint-plugin": "^5.36.1",
22
- "@typescript-eslint/parser": "^5.36.1",
23
- "eslint": "^8.23.0",
23
+ "@typescript-eslint/eslint-plugin": "^5.38.1",
24
+ "@typescript-eslint/parser": "^5.38.1",
25
+ "eslint": "^8.24.0",
24
26
  "eslint-config-prettier": "^8.5.0",
25
27
  "eslint-plugin-node": "^11.1.0",
26
28
  "eslint-plugin-prettier": "^4.2.1",
@@ -32,6 +34,6 @@
32
34
  "zx": "^4.3.0"
33
35
  },
34
36
  "peerDependencies": {
35
- "@companion-module/base": "^0.2.0"
37
+ "@companion-module/base": "^0.4.0"
36
38
  }
37
39
  }
package/scripts/build.js CHANGED
@@ -4,6 +4,7 @@ import path from 'path'
4
4
  import { fs } from 'zx'
5
5
  import { findUp } from 'find-up'
6
6
  import * as tar from 'tar'
7
+ import { validateManifest } from '@companion-module/base'
7
8
 
8
9
  async function findModuleDir(cwd) {
9
10
  const stat = await fs.stat(cwd)
@@ -37,9 +38,18 @@ const frameworkPackageJson = JSON.parse(await fs.readFile(path.join(frameworkDir
37
38
  const manifestJson = JSON.parse(await fs.readFile(path.resolve('./companion/manifest.json')))
38
39
  manifestJson.runtime.entrypoint = '../main.js'
39
40
  manifestJson.version = srcPackageJson.version
41
+ manifestJson.runtime.api = 'nodejs-ipc'
40
42
  manifestJson.runtime.apiVersion = frameworkPackageJson.version
41
43
  await fs.writeFile(path.resolve('./pkg/companion/manifest.json'), JSON.stringify(manifestJson))
42
44
 
45
+ // Make sure the manifest is valid
46
+ try {
47
+ validateManifest(manifestJson)
48
+ } catch (e) {
49
+ console.error('Manifest validation failed', e)
50
+ process.exit(1)
51
+ }
52
+
43
53
  // Generate a minimal package.json
44
54
  const packageJson = {
45
55
  name: manifestJson.name,
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env zx
2
+
3
+ import path from 'path'
4
+ import { fs } from 'zx'
5
+ import { findUp } from 'find-up'
6
+ import { validateManifest } from '@companion-module/base'
7
+
8
+ async function findModuleDir(cwd) {
9
+ const stat = await fs.stat(cwd)
10
+ if (stat.isFile()) cwd = path.dirname(cwd)
11
+
12
+ const pkgJsonPath = await findUp('package.json', { cwd })
13
+ return path.dirname(pkgJsonPath)
14
+ }
15
+
16
+ // const toolsDir = path.join(__dirname, '..')
17
+ const toolsDir = await findModuleDir(require.resolve('@companion-module/tools'))
18
+ const frameworkDir = await findModuleDir(require.resolve('@companion-module/base'))
19
+ console.log(`Checking for: ${process.cwd()}`)
20
+
21
+ console.log(`Tools path: ${toolsDir}`)
22
+ console.log(`Framework path: ${frameworkDir}`)
23
+
24
+ const manifestJson = JSON.parse(await fs.readFile(path.resolve('./companion/manifest.json')))
25
+
26
+ try {
27
+ validateManifest(manifestJson)
28
+ } catch (e) {
29
+ console.error('Manifest validation failed', e)
30
+ process.exit(1)
31
+ }
@@ -35,6 +35,9 @@ if (Array.isArray(pkgJson.contributors)) {
35
35
  }
36
36
  }
37
37
 
38
+ let products = pkgJson.products || pkgJson.product || []
39
+ if (typeof products === 'string') products = [products]
40
+
38
41
  const manifest = {
39
42
  id: pkgJson.name,
40
43
  name: pkgJson.name,
@@ -49,7 +52,7 @@ const manifest = {
49
52
 
50
53
  runtime: {
51
54
  type: 'node14',
52
- api: 'socket.io',
55
+ api: 'nodejs-ipc',
53
56
  apiVersion: '0.0.0',
54
57
 
55
58
  entrypoint: path.join('../', pkgJson.main || 'index.js'),
@@ -57,7 +60,7 @@ const manifest = {
57
60
  },
58
61
 
59
62
  manufacturer: pkgJson.manufacturer ?? '',
60
- products: pkgJson.products ?? (pkgJson.product ? [pkgJson.product] : []),
63
+ products: products,
61
64
  keywords: pkgJson.keywords || [],
62
65
  }
63
66