mirror of https://github.com/Budibase/budibase.git
7 changed files with 50 additions and 40 deletions
@ -1,17 +0,0 @@ |
|||
const fs = require("fs-extra") |
|||
const { join } = require("path") |
|||
|
|||
const chmodr = async (dir, perms) => { |
|||
const children = await fs.readdir(dir) |
|||
for (let child of children) { |
|||
const fullChildPath = join(dir, child) |
|||
const stat = await fs.stat(join(dir, child)) |
|||
if (stat.isFile()) { |
|||
await fs.chmod(fullChildPath, perms) |
|||
} else { |
|||
await chmodr(fullChildPath, perms) |
|||
} |
|||
} |
|||
} |
|||
|
|||
module.exports = chmodr |
|||
@ -1,7 +1,35 @@ |
|||
const { resolve } = require("path") |
|||
const { cwd } = require("process") |
|||
const stream = require("stream") |
|||
const fetch = require("node-fetch") |
|||
const tar = require("tar-fs") |
|||
const zlib = require("zlib") |
|||
const { promisify } = require("util") |
|||
const streamPipeline = promisify(stream.pipeline) |
|||
|
|||
const appPackageFolder = (config, appname) => |
|||
exports.appPackageFolder = (config, appname) => |
|||
resolve(cwd(), config.latestPackagesFolder, appname) |
|||
|
|||
module.exports.appPackageFolder = appPackageFolder |
|||
|
|||
exports.downloadExtractComponentLibraries = async appFolder => { |
|||
|
|||
const LIBRARIES = [ |
|||
"materialdesign-components", |
|||
"standard-components" |
|||
] |
|||
|
|||
// Need to download tarballs directly from NPM as our users may not have node on their machine
|
|||
for (let lib of LIBRARIES) { |
|||
// download tarball
|
|||
// TODO: make sure the latest version is always downloaded
|
|||
const registryUrl = `https://registry.npmjs.org/@budibase/${lib}/-/${lib}-0.1.2.tgz`; |
|||
const response = await fetch(registryUrl) |
|||
if (!response.ok) throw new Error(`unexpected response ${response.statusText}`) |
|||
|
|||
await streamPipeline( |
|||
response.body, |
|||
zlib.Unzip(), |
|||
tar.extract(`${appFolder}/node_modules/@budibase/${lib}`) |
|||
) |
|||
} |
|||
} |
|||
Loading…
Reference in new issue