@companion-module/tools 0.5.2 → 1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.0.1](https://github.com/bitfocus/companion-module-tools/compare/v1.0.0...v1.0.1) (2023-02-17)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * missing prebuilds in built packages ([acd76e8](https://github.com/bitfocus/companion-module-tools/commit/acd76e84ed98916f31d251ddddc0a601514c91c0))
9
+
10
+ ## [1.0.0](https://github.com/bitfocus/companion-module-tools/compare/v0.5.2...v1.0.0) (2023-02-05)
11
+
12
+
13
+ ### ⚠ BREAKING CHANGES
14
+
15
+ * rename webpack-ext.cjs to build-config.cjs
16
+
17
+ ### Features
18
+
19
+ * rename webpack-ext.cjs to build-config.cjs ([c8864cd](https://github.com/bitfocus/companion-module-tools/commit/c8864cd55306a4ae60c6602cf7c73bf81eb585be))
20
+ * support including 'extraFiles' in the built pkg ([b130f57](https://github.com/bitfocus/companion-module-tools/commit/b130f572a13ddef49596ba0a4103d18d22b8a231))
21
+
3
22
  ## [0.5.2](https://github.com/bitfocus/companion-module-tools/compare/v0.5.1...v0.5.2) (2023-01-10)
4
23
 
5
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@companion-module/tools",
3
- "version": "0.5.2",
3
+ "version": "1.0.1",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
@@ -23,15 +23,15 @@
23
23
  "webpack.*"
24
24
  ],
25
25
  "dependencies": {
26
- "@typescript-eslint/eslint-plugin": "^5.48.1",
27
- "@typescript-eslint/parser": "^5.48.1",
28
- "eslint": "^8.31.0",
26
+ "@typescript-eslint/eslint-plugin": "^5.50.0",
27
+ "@typescript-eslint/parser": "^5.50.0",
28
+ "eslint": "^8.33.0",
29
29
  "eslint-config-prettier": "^8.6.0",
30
30
  "eslint-plugin-node": "^11.1.0",
31
31
  "eslint-plugin-prettier": "^4.2.1",
32
32
  "find-up": "^6.3.0",
33
33
  "parse-author": "^2.0.0",
34
- "prettier": "^2.8.2",
34
+ "prettier": "^2.8.3",
35
35
  "tar": "^6.1.13",
36
36
  "webpack": "^5.75.0",
37
37
  "webpack-cli": "^5.0.1",
package/scripts/build.js CHANGED
@@ -40,6 +40,7 @@ await fs.copy('companion', 'pkg/companion')
40
40
  const srcPackageJson = JSON.parse(await fs.readFile(path.resolve('./package.json')))
41
41
  const frameworkPackageJson = JSON.parse(await fs.readFile(path.join(frameworkDir, 'package.json')))
42
42
 
43
+ // Copy the manifest, overriding some properties
43
44
  const manifestJson = JSON.parse(await fs.readFile(path.resolve('./companion/manifest.json')))
44
45
  manifestJson.runtime.entrypoint = '../main.js'
45
46
  manifestJson.version = srcPackageJson.version
@@ -66,9 +67,11 @@ const packageJson = {
66
67
  }
67
68
 
68
69
  // Ensure that any externals are added as dependencies
69
- const webpackExtPath = path.resolve('webpack-ext.cjs')
70
+ const webpackExtPath = path.resolve('build-config.cjs')
70
71
  if (fs.existsSync(webpackExtPath)) {
71
72
  const webpackExt = require(webpackExtPath)
73
+
74
+ // Add any external dependencies, with versions matching what is currntly installed
72
75
  if (webpackExt.externals) {
73
76
  const extArray = Array.isArray(webpackExt.externals) ? webpackExt.externals : [webpackExt.externals]
74
77
  for (const extGroup of extArray) {
@@ -84,6 +87,7 @@ if (fs.existsSync(webpackExtPath)) {
84
87
  }
85
88
  }
86
89
 
90
+ // Copy across any prebuilds that can be loaded corectly
87
91
  if (webpackExt.prebuilds) {
88
92
  await fs.mkdir('pkg/prebuilds')
89
93
 
@@ -91,26 +95,35 @@ if (fs.existsSync(webpackExtPath)) {
91
95
  const srcDir = await findModuleDir(require.resolve(lib))
92
96
  const dirs = await fs.readdir(path.join(srcDir, 'prebuilds'))
93
97
  for (const dir of dirs) {
94
- fs.copy(path.join(srcDir, 'prebuilds', dir), path.join('pkg/prebuilds', dir))
98
+ await fs.copy(path.join(srcDir, 'prebuilds', dir), path.join('pkg/prebuilds', dir))
95
99
  }
96
100
  }
97
101
  }
102
+
103
+ // copy extra files
104
+ if (Array.isArray(webpackExt.extraFiles)) {
105
+ const files = await globby(webpackExt.extraFiles)
106
+ for (const file of files) {
107
+ await fs.copy(file, path.join('pkg', file), {
108
+ recursive: true,
109
+ overwrite: false,
110
+ })
111
+ }
112
+ }
98
113
  }
99
114
 
100
115
  // Write the package.json
101
116
  // packageJson.bundleDependencies = Object.keys(packageJson.dependencies)
102
117
  await fs.writeFile('pkg/package.json', JSON.stringify(packageJson))
103
118
 
119
+ // If we found any depenendencies for the pkg, install them
104
120
  if (Object.keys(packageJson.dependencies).length) {
105
- await $`yarn --cwd pkg`
121
+ await $`yarn --cwd pkg install`
106
122
  }
107
123
 
108
124
  // Create tgz of the build
109
- // await $`yarn --cwd pkg pack --filename pkg/package.tgz`
110
-
111
125
  await tar
112
- .c(
113
- // or tar.create
126
+ .create(
114
127
  {
115
128
  gzip: true,
116
129
  },
@@ -7,7 +7,7 @@ if (!pkgJson.main) throw new Error(`Missing main in package.json`)
7
7
 
8
8
  let webpackExt = {}
9
9
  try {
10
- webpackExt = require(path.join(process.cwd(), 'webpack-ext.cjs'))
10
+ webpackExt = require(path.join(process.cwd(), 'build-config.cjs'))
11
11
 
12
12
  console.log('Found additional webpack configuration')
13
13
  } catch (e) {