@companion-module/tools 0.2.0 → 0.3.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 +13 -0
- package/package.json +7 -5
- package/scripts/build.js +9 -0
- package/scripts/check.js +31 -0
- package/scripts/generate-manifest.js +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.3.0](https://github.com/bitfocus/companion-module-tools/compare/v0.2.0...v0.3.0) (2022-10-01)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* validateManifest before building module ([0166c7d](https://github.com/bitfocus/companion-module-tools/commit/0166c7da0ed725de77e3c71bc7992f8fd9deba94))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* generating of manifest incorrectly processing 'products' field ([5f5ad9e](https://github.com/bitfocus/companion-module-tools/commit/5f5ad9e802249e4c9fe60ad8eb2278c715fa0a15))
|
|
14
|
+
* update runtime.api in conversion script ([ce95e96](https://github.com/bitfocus/companion-module-tools/commit/ce95e96626023e11ec7fe460278a3418dc6f0eaf))
|
|
15
|
+
|
|
3
16
|
## [0.2.0](https://github.com/bitfocus/companion-module-tools/compare/v0.1.1...v0.2.0) (2022-09-04)
|
|
4
17
|
|
|
5
18
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@companion-module/tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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.
|
|
22
|
-
"@typescript-eslint/parser": "^5.
|
|
23
|
-
"eslint": "^8.
|
|
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.
|
|
37
|
+
"@companion-module/base": "^0.3.0"
|
|
36
38
|
}
|
|
37
39
|
}
|
package/scripts/build.js
CHANGED
|
@@ -37,9 +37,18 @@ const frameworkPackageJson = JSON.parse(await fs.readFile(path.join(frameworkDir
|
|
|
37
37
|
const manifestJson = JSON.parse(await fs.readFile(path.resolve('./companion/manifest.json')))
|
|
38
38
|
manifestJson.runtime.entrypoint = '../main.js'
|
|
39
39
|
manifestJson.version = srcPackageJson.version
|
|
40
|
+
manifestJson.runtime.api = 'nodejs-ipc'
|
|
40
41
|
manifestJson.runtime.apiVersion = frameworkPackageJson.version
|
|
41
42
|
await fs.writeFile(path.resolve('./pkg/companion/manifest.json'), JSON.stringify(manifestJson))
|
|
42
43
|
|
|
44
|
+
// Make sure the manifest is valid
|
|
45
|
+
try {
|
|
46
|
+
validateManifest(manifestJson)
|
|
47
|
+
} catch (e) {
|
|
48
|
+
console.error('Manifest validation failed', e)
|
|
49
|
+
process.exit(1)
|
|
50
|
+
}
|
|
51
|
+
|
|
43
52
|
// Generate a minimal package.json
|
|
44
53
|
const packageJson = {
|
|
45
54
|
name: manifestJson.name,
|
package/scripts/check.js
ADDED
|
@@ -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: '
|
|
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:
|
|
63
|
+
products: products,
|
|
61
64
|
keywords: pkgJson.keywords || [],
|
|
62
65
|
}
|
|
63
66
|
|