@companion-module/tools 0.0.1-0 → 0.1.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 ADDED
@@ -0,0 +1,42 @@
1
+ # Changelog
2
+
3
+ ## [0.1.1](https://github.com/bitfocus/companion-module-tools/compare/v0.1.0...v0.1.1) (2022-07-21)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * don't rename modules ([0d35f51](https://github.com/bitfocus/companion-module-tools/commit/0d35f510cf24333b753d8b34a5c4af27623fcaed))
9
+
10
+ ## [0.1.0](https://github.com/bitfocus/companion-module-tools/compare/v0.0.2...v0.1.0) (2022-07-12)
11
+
12
+
13
+ ### Features
14
+
15
+ * add runtime.apiVersion to manifest ([b42703b](https://github.com/bitfocus/companion-module-tools/commit/b42703b5bac6e2cb6addc8e71239c24e26c43b90))
16
+ * remove husky & lint-staged ([7b71d84](https://github.com/bitfocus/companion-module-tools/commit/7b71d84cb8850242846d5118f651fd7ae129615c))
17
+
18
+
19
+ ### Bug Fixes
20
+
21
+ * set `importHelpers: false` for recommended tsconfig ([1b04d89](https://github.com/bitfocus/companion-module-tools/commit/1b04d89bc50922466dffb416b4ed3b4acf63be71))
22
+ * set version field in manifest when generating pkg.tgz ([b42703b](https://github.com/bitfocus/companion-module-tools/commit/b42703b5bac6e2cb6addc8e71239c24e26c43b90))
23
+ * update @companion-module/base ([33df2a6](https://github.com/bitfocus/companion-module-tools/commit/33df2a61796954c30c01e25a5f08a2a1bd874e64))
24
+
25
+ ## [0.0.2](https://github.com/bitfocus/companion-module-tools/compare/v0.0.1...v0.0.2) (2022-07-10)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * missing webpack config ([a039dee](https://github.com/bitfocus/companion-module-tools/commit/a039deeb7c1736ce87f3bba8759c230de7ad883d))
31
+
32
+ ## 0.0.1 (2022-07-10)
33
+
34
+
35
+ ### Features
36
+
37
+ * initial commit ([c07d9af](https://github.com/bitfocus/companion-module-tools/commit/c07d9af14b2f950ac93095ed1b6e37d0a206ef99))
38
+
39
+
40
+ ### Miscellaneous Chores
41
+
42
+ * update readme ([8a240c5](https://github.com/bitfocus/companion-module-tools/commit/8a240c5bd6ebc14d9f978fd0e14dba41986626da))
package/README.md CHANGED
@@ -7,3 +7,7 @@ This is a collection of tools, used for developing and verifying Companion modul
7
7
  ### companion-module-build
8
8
 
9
9
  When used, this will build a module ready for distibution
10
+
11
+ ### companion-generate-manifest
12
+
13
+ Generate the new format manifest from an old package.json
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@companion-module/tools",
3
- "version": "0.0.1-0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
@@ -14,7 +14,8 @@
14
14
  "tsconfig",
15
15
  ".prettierrc.json",
16
16
  "index.js",
17
- "CHANGELOG.md"
17
+ "CHANGELOG.md",
18
+ "webpack.*"
18
19
  ],
19
20
  "dependencies": {
20
21
  "@typescript-eslint/eslint-plugin": "^5.30.5",
@@ -24,8 +25,6 @@
24
25
  "eslint-plugin-node": "^11.1.0",
25
26
  "eslint-plugin-prettier": "^4.2.1",
26
27
  "find-up": "^6.3.0",
27
- "husky": "^8.0.1",
28
- "lint-staged": "^13.0.3",
29
28
  "parse-author": "^2.0.0",
30
29
  "prettier": "^2.7.1",
31
30
  "webpack": "^5.73.0",
@@ -33,6 +32,6 @@
33
32
  "zx": "^4.3.0"
34
33
  },
35
34
  "peerDependencies": {
36
- "@companion-module/base": "^0.0.3"
35
+ "@companion-module/base": "^0.1.1"
37
36
  }
38
37
  }
package/scripts/build.js CHANGED
@@ -31,8 +31,13 @@ await $`yarn webpack -c ${webpackConfig}`
31
31
  // copy in the metadata
32
32
  await fs.copy('companion', 'pkg/companion')
33
33
 
34
+ const srcPackageJson = JSON.parse(await fs.readFile(path.resolve('./package.json')))
35
+ const frameworkPackageJson = JSON.parse(await fs.readFile(path.join(frameworkDir, 'package.json')))
36
+
34
37
  const manifestJson = JSON.parse(await fs.readFile(path.resolve('./companion/manifest.json')))
35
38
  manifestJson.runtime.entrypoint = '../main.js'
39
+ manifestJson.version = srcPackageJson.version
40
+ manifestJson.runtime.apiVersion = frameworkPackageJson.version
36
41
  await fs.writeFile(path.resolve('./pkg/companion/manifest.json'), JSON.stringify(manifestJson))
37
42
 
38
43
  // Generate a minimal package.json
@@ -36,20 +36,21 @@ if (Array.isArray(pkgJson.contributors)) {
36
36
  }
37
37
 
38
38
  const manifest = {
39
- id: `bitfocus.${pkgJson.name}`,
39
+ id: pkgJson.name,
40
40
  name: pkgJson.name,
41
41
  shortname: pkgJson.shortname ?? pkgJson.name,
42
42
  description: pkgJson.description ?? pkgJson.name,
43
- version: pkgJson.version ?? '0.0.0',
43
+ version: '0.0.0',
44
44
  license: pkgJson.license,
45
45
  repository: pkgJson.repository?.url ?? `https://github.com/bitfocus/companion-module-${pkgJson.name}.git`,
46
46
  bugs: pkgJson.bugs?.url ?? `https://github.com/bitfocus/companion-module-${pkgJson.name}/issues`,
47
47
  maintainers: maintainers,
48
- legacyIds: [...(pkgJson.legacy || []), pkgJson.name],
48
+ legacyIds: [...(pkgJson.legacy || [])],
49
49
 
50
50
  runtime: {
51
51
  type: 'node14',
52
52
  api: 'socket.io',
53
+ apiVersion: '0.0.0',
53
54
 
54
55
  entrypoint: path.join('../', pkgJson.main || 'index.js'),
55
56
  // universal: boolean
@@ -9,7 +9,7 @@
9
9
  "*": ["../node_modules/*"]
10
10
  },
11
11
  "declaration": false,
12
- "importHelpers": true,
12
+ "importHelpers": false,
13
13
  "listFiles": false,
14
14
  "traceResolution": false,
15
15
  "pretty": true,
@@ -0,0 +1,57 @@
1
+ const path = require('path')
2
+
3
+ const frameworkDir = path.relative(process.cwd(), path.resolve('@companion-module/base'))
4
+ const pkgJson = require(path.join(process.cwd(), 'package.json'))
5
+
6
+ if (!pkgJson.main) throw new Error(`Missing main in package.json`)
7
+
8
+ let webpackExt = {}
9
+ try {
10
+ webpackExt = require(path.join(process.cwd(), 'webpack-ext.cjs'))
11
+
12
+ console.log('Found additional webpack configuration')
13
+ } catch (e) {
14
+ // Ignore
15
+ }
16
+
17
+ let externalsExt = []
18
+ if (Array.isArray(webpackExt.externals)) externalsExt = webpackExt.externals
19
+ else if (webpackExt.externals) externalsExt = [webpackExt.externals]
20
+
21
+ module.exports = {
22
+ entry: {
23
+ main: './' + pkgJson.main, // path.join(frameworkDir, 'dist/entrypoint.js'),
24
+ // Allow for custom entrypoints
25
+ ...webpackExt.entry,
26
+ },
27
+ mode: 'production',
28
+ // devtool: 'source-map', // TODO - this would be nice, but I think the files have to be uploaded directly to sentry which is problematic...
29
+ // mode: 'development',
30
+ output: {
31
+ path: path.resolve(process.cwd(), 'pkg'),
32
+ },
33
+ context: path.resolve(process.cwd(), '.'),
34
+ target: 'node',
35
+ externals: [
36
+ // Allow for custom externals
37
+ ...externalsExt,
38
+ ],
39
+ experiments: {
40
+ topLevelAwait: true,
41
+ },
42
+ module: {
43
+ rules: [
44
+ {
45
+ test: /\.json$/,
46
+ type: 'asset/inline',
47
+ },
48
+ // {
49
+ // test: /BUILD$/,
50
+ // type: 'asset/resource',
51
+ // generator: {
52
+ // filename: 'BUILD',
53
+ // },
54
+ // },
55
+ ],
56
+ },
57
+ }