dashboard/compile-aqua.mjs
Anatolios Laskaris 204f7f3be9
fix: Fix dashboard
* Bump js-client

* Temp deploy dev on prod

* Fix

* Fix

* Bump fcli

* Fix

* F

* update js-client.web.standalone

* bump node.js for dev as well

* compile differently

* update multiaddr

* install old multiaddr explicitly

* remove openssl-legacy

* return parameter name

* downgrade

* use kras compatible versions

* remove prefix

* Cleanup

---------

Co-authored-by: Artsiom Shamsutdzinau <shamsartem@gmail.com>
2023-08-14 14:36:03 +03:00

47 lines
1.1 KiB
JavaScript

// @ts-check
import { join } from 'path';
import { AquaConfig, Aqua, Path } from './node_modules/@fluencelabs/aqua-api/aqua-api.js';
import { mkdir, writeFile } from 'fs/promises';
function getConfig({
constants = [],
logLevel = 'info',
noRelay = false,
noXor = false,
targetType = 'air',
tracing = false,
}) {
return new AquaConfig(
logLevel,
constants,
noXor,
noRelay,
{
ts: 'typescript',
js: 'javascript',
air: 'air',
}[targetType],
tracing,
);
}
function compileFromPath({ filePath, ...commonArgs }) {
const config = getConfig(commonArgs);
const { imports = [] } = commonArgs;
return Aqua.compile(new Path(filePath), imports, config);
}
const { generatedSources } = await compileFromPath({
targetType: 'js',
filePath: join('aqua', 'app.aqua'),
imports: ['node_modules'],
});
const targetDir = join('src', '_aqua');
await mkdir(targetDir, { recursive: true });
// @ts-ignore
await writeFile(join(targetDir, 'app.js'), generatedSources[0].jsSource, { encoding: 'utf8' });