Skip to content

Commit

Permalink
feat: fetch bundled modules from git
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Nov 25, 2022
1 parent aa2207a commit 913b772
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 31 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "bundled-modules"]
path = bundled-modules
url = https://github.com/bitfocus/companion-bundled-modules
1 change: 1 addition & 0 deletions bundled-modules
Submodule bundled-modules added at 0e46ef
2 changes: 1 addition & 1 deletion lib/Instance/Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Instance extends CoreBase {

const searchDirs = [
// Paths to look for modules, lowest to highest priority
path.resolve('bundled-modules'),
path.resolve(path.join(rootPath, 'bundled-modules')),
]

const legacyCandidates = await this.#loadInfoForModulesInDir(path.join(rootPath, '/module-legacy/manifests'), false)
Expand Down
31 changes: 1 addition & 30 deletions tools/build/dist.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -88,33 +88,4 @@ await fs.mkdir('dist/module-legacy')
await fs.copy('module-legacy/manifests', 'dist/module-legacy/manifests')

// Bundle in modules
const modulesPath = 'dist/bundled-modules'
// const moduleTmp = 'dist/module-tmp'
await fs.mkdir(modulesPath)
const bundleJson = JSON.parse(await fs.readFile('./bundled-modules.json'))

// Download them all
for (const [id, url] of Object.entries(bundleJson)) {
console.log('url', url)
if (url) {
// Download and extract to tmp dir
const response = await fetch(url)
if (!response.ok) throw new Error(`unexpected response ${response.statusText}`)

const moduleDir = path.join(modulesPath, id)
await fs.mkdir(moduleDir)
await streamPipeline(
response.body,
tar.x({
strip: 1,
C: moduleDir,
})
)

// const modJson = JSON.parse(await fs.readFile(path.join(moduleTmp, 'companion/manifest.json')))

// const targetDir = path.join(modulesPath, id)
// // await fs.rmdir()
// await fs.move(moduleTmp, targetDir)
}
}
await fs.copy('bundled-modules', 'dist/bundled-modules')

0 comments on commit 913b772

Please sign in to comment.