@companion-module/tools 1.4.0 → 1.4.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,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.4.1](https://github.com/bitfocus/companion-module-tools/compare/v1.4.0...v1.4.1) (2023-09-11)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * support for yarn3 ([6ab2458](https://github.com/bitfocus/companion-module-tools/commit/6ab2458c6148da0b1a305e377408b4cb64399dce))
9
+
3
10
  ## [1.4.0](https://github.com/bitfocus/companion-module-tools/compare/v1.3.2...v1.4.0) (2023-08-22)
4
11
 
5
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@companion-module/tools",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
package/scripts/build.js CHANGED
@@ -20,6 +20,7 @@ async function findModuleDir(cwd) {
20
20
  }
21
21
 
22
22
  // const toolsDir = path.join(__dirname, '..')
23
+ const moduleDir = process.cwd()
23
24
  const toolsDir = await findModuleDir(require.resolve('@companion-module/tools'))
24
25
  const frameworkDir = await findModuleDir(require.resolve('@companion-module/base'))
25
26
  console.log(`Building for: ${process.cwd()}`)
@@ -30,17 +31,21 @@ console.log(`Framework path: ${frameworkDir}`)
30
31
  // clean old
31
32
  await fs.remove('pkg')
32
33
 
33
- const webpackArgs = {}
34
- if (argv.dev || argv.debug) webpackArgs['env'] = 'dev'
34
+ const webpackArgs = {
35
+ ROOT: moduleDir,
36
+ }
37
+ if (argv.dev || argv.debug) webpackArgs['dev'] = true
35
38
 
36
39
  const webpackArgsArray = []
37
40
  for (const [k, v] of Object.entries(webpackArgs)) {
38
- webpackArgsArray.push(`--${k}`, v)
41
+ webpackArgsArray.push(`--env`, v === true ? k : `${k}=${v}`)
39
42
  }
40
43
 
41
44
  // build the code
45
+ $.cwd = toolsDir
42
46
  const webpackConfig = path.join(toolsDir, 'webpack.config.cjs').replace(/\\/g, '/') // Fix slashes because windows is a pain
43
- await $`yarn webpack -c ${webpackConfig} ${webpackArgsArray}`
47
+ await $`yarn run -B webpack -c ${webpackConfig} ${webpackArgsArray}`
48
+ $.cwd = undefined
44
49
 
45
50
  // copy in the metadata
46
51
  await fs.copy('companion', 'pkg/companion')
@@ -77,44 +77,3 @@ if (await fs.pathExists('HELP.md')) {
77
77
  if (await fs.pathExists('images')) await fs.move('images', path.join(manifestDir, 'images'))
78
78
  if (await fs.pathExists('documentation')) await fs.move('documentation', path.join(manifestDir, 'documentation'))
79
79
  }
80
-
81
- // for (const folder of dirs) {
82
- // if (folder.match(/companion-module-/) && !ignoreNames.includes(folder)) {
83
- // const moduleDir = path.join(outerDir, folder)
84
- // const moduleNewDir = path.join(outerManifest, folder)
85
- // const manifestDir = path.join(moduleNewDir, 'companion')
86
-
87
- //
88
- // await fs.mkdirp(manifestDir)
89
- // await fs.writeFile(path.join(manifestDir, 'manifest.json'), JSON.stringify(manifest, undefined, '\t'))
90
-
91
- // if (await fs.pathExists(( 'HELP.md'))) {
92
- // await fs.copy(( 'HELP.md'), path.join(manifestDir, 'HELP.md'))
93
-
94
- // // guess at what images might be needed by the help
95
- // if (await fs.pathExists(( 'images')))
96
- // await fs.copy(( 'images'), path.join(manifestDir, 'images'))
97
- // if (await fs.pathExists(( 'documentation')))
98
- // await fs.copy(( 'documentation'), path.join(manifestDir, 'documentation'))
99
- // }
100
-
101
- // await fs.writeFile(
102
- // path.join(outerEntrypoints, `${pkgJson.name}.cjs`),
103
- // `
104
- // global.modulePkg = require('companion-module-${pkgJson.name}/package.json')
105
- // global.moduleFactory = require('companion-module-${pkgJson.name}')
106
- // global.moduleName = "${pkgJson.name}"
107
- // import('../../dist/index.js')
108
- // `
109
- // )
110
- // }
111
- // }
112
-
113
- // console.log('Bundling code. This will take a couple of minutes')
114
- // await $`yarn webpack`
115
-
116
- // // trick node into treating them all as cjs
117
- // await fs.writeFile(`manifests/package.json`, '')
118
-
119
- // // const useDir = await fs.pathExists('./module/legacy')
120
- // // const baseDir = useDir ? './module/legacy' : './node_modules/companion-wrapped-module'
@@ -1,24 +1,26 @@
1
1
  const path = require('path')
2
2
 
3
- const frameworkDir = path.relative(process.cwd(), path.resolve('@companion-module/base'))
4
- const pkgJson = require(path.join(process.cwd(), 'package.json'))
3
+ module.exports = async (env) => {
4
+ if (!env.ROOT) throw new Error(`Missing ROOT`)
5
5
 
6
- if (!pkgJson.main) throw new Error(`Missing main in package.json`)
6
+ const frameworkDir = path.relative(env.ROOT, path.resolve('@companion-module/base'))
7
+ const pkgJson = require(path.join(env.ROOT, 'package.json'))
7
8
 
8
- let webpackExt = {}
9
- try {
10
- webpackExt = require(path.join(process.cwd(), 'build-config.cjs'))
9
+ if (!pkgJson.main) throw new Error(`Missing main in package.json`)
11
10
 
12
- console.log('Found additional webpack configuration')
13
- } catch (e) {
14
- // Ignore
15
- }
11
+ let webpackExt = {}
12
+ try {
13
+ webpackExt = require(path.join(env.ROOT, 'build-config.cjs'))
16
14
 
17
- let externalsExt = []
18
- if (Array.isArray(webpackExt.externals)) externalsExt = webpackExt.externals
19
- else if (webpackExt.externals) externalsExt = [webpackExt.externals]
15
+ console.log('Found additional webpack configuration')
16
+ } catch (e) {
17
+ // Ignore
18
+ }
19
+
20
+ let externalsExt = []
21
+ if (Array.isArray(webpackExt.externals)) externalsExt = webpackExt.externals
22
+ else if (webpackExt.externals) externalsExt = [webpackExt.externals]
20
23
 
21
- module.exports = async (env) => {
22
24
  return {
23
25
  entry: {
24
26
  main: './' + pkgJson.main, // path.join(frameworkDir, 'dist/entrypoint.js'),
@@ -28,9 +30,9 @@ module.exports = async (env) => {
28
30
  mode: env.dev ? 'development' : 'production',
29
31
  // devtool: env.dev ? undefined : 'source-map', // TODO - this would be nice, but I think the files have to be uploaded directly to sentry which is problematic...
30
32
  output: {
31
- path: path.resolve(process.cwd(), 'pkg'),
33
+ path: path.resolve(env.ROOT, 'pkg'),
32
34
  },
33
- context: path.resolve(process.cwd(), '.'),
35
+ context: path.resolve(env.ROOT, '.'),
34
36
  target: 'node',
35
37
  externals: [
36
38
  // Allow for custom externals
@@ -39,7 +41,7 @@ module.exports = async (env) => {
39
41
  experiments: {
40
42
  topLevelAwait: true,
41
43
  },
42
- optimization: {
44
+ optimization: {
43
45
  minimize: !webpackExt.disableMinifier,
44
46
  },
45
47
  module: {