Pavel 9667c4fec6
feat!: Standalone web JS Client (#243)
- Move marine-related part into FJS repo (fixes DXJ-184)
- Move towards component-oriented architecture (fixes DXJ-183)
- Different JS Client distros for node.js and web (fixes DXJ-185)
- Update libp2p to 0.42.2 (fixes DXJ-26)
- Add JS Client API (fixes DXJ-196, fixes DXJ-177, fixes DXJ-60)
- Add Smoke test for JS Client web (fixes DXJ-253)

---------

Co-authored-by: Anatoly Laskaris <github_me@nahsi.dev>
2023-02-13 21:41:35 +07:00

47 lines
1.3 KiB
JavaScript

#! /usr/bin/env node
import * as fs from 'fs';
import * as path from 'path';
const firstArgument = process.argv[2];
if (!firstArgument) {
console.log(`Expected exactly 1 argument, got 0. Usage: ${path.basename(process.argv[1])} <destination directory>`);
process.exit(1);
}
let destPath = firstArgument;
if (!path.isAbsolute(destPath)) {
destPath = path.join(process.cwd(), destPath);
}
async function copyFile(packageName: string, fileName: string) {
const modulePath = require.resolve(packageName);
const source = path.join(path.dirname(modulePath), fileName);
const dest = path.join(destPath, fileName);
console.log(`copying ${fileName}`);
console.log('from: ', source);
console.log('to: ', dest);
await fs.promises.copyFile(source, dest);
}
async function main() {
console.log('ensure directory exists: ', destPath);
await fs.promises.mkdir(destPath, { recursive: true });
await Promise.all([
copyFile('@fluencelabs/marine.worker-script', 'marine-js.web.js'),
copyFile('@fluencelabs/marine-js', 'marine-js.wasm'),
copyFile('@fluencelabs/avm', 'avm.wasm'),
]);
}
main()
.then(() => {
console.log('done!');
})
.catch((err) => {
console.error('Something went wrong!', err);
});