Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await tsc("src", {
target : "esnext",
declaration : true,
outDir : "dist/"
});
});
task("dist", async context => {
await context.clean();
await context.prepareDistFolder();
await context.dist("esnext", "es7");
await context.dist("es6", "es6");
await exec("tsc")
});
task("publish", async () => {
await exec("dist")
await npmPublish({path : "dist"});
})
context(class {
getConfig() {
return FuseBox.init({
homeDir: "src",
globals: { 'default': '*' }, // we need to expore index in our bundles
target: this.target,
output: "dist/$name.js",
cache: !this.isProduction,
plugins: [!this.isProduction && WebIndexPlugin(),
this.isProduction && QuantumPlugin({
containedAPI: true,
ensureES5: false,
})
}
createBundle(fuse) {
const app = fuse.bundle("app");
if (!this.isProduction) {
app.watch()
app.hmr()
}
app.instructions(">index.jsx");
return app;
}
});
task("clean", () => src("dist").clean("dist").exec() )
task("default", ["clean"], async context => {
const fuse = context.getConfig();
fuse.dev();
context.createBundle(fuse);
await fuse.run();
});
task("dist", ["clean"], async context => {
context.isProduction = true;
const fuse = context.getConfig();
fuse.dev(); // remove it later
context.createBundle(fuse);
await fuse.run();
});
isProdBuild &&
QuantumPlugin({
bakeApiIntoBundle: appName,
treeshake: true,
uglify: true
})
]
})
const bundle = fuseConfig.bundle(appName)
task('test', () => {
bundle.test('[spec/**/**.ts]', {})
})
task('cp.jest', () => {
return src('jest/**', { base: 'src/templates/unit-tests' }).dest('.build/')
})
task('bundle', ['cp.jest', 'ng.modules'], () => {
bundle.instructions('> [src/index.ts]')
!isProdBuild &&
bundle.watch(`src/**`).completed(fp => shabang(fp.bundle, absOutputPath))
fuseConfig.run().then(bp => {
const bundle = bp.bundles.get(appName)
bundle && shabang(bundle, absOutputPath)
})
})
task('ng.modules', () => {
return new Promise((res, rej) => {
await copy(
`./builds/.cache/uncompressed/${ platform }/sharp`,
path.join( buildFolder, 'node_modules', 'sharp' )
);
await copy(
`./builds/.cache/uncompressed/${ platform }/libvips/lib`,
path.join( buildFolder, 'node_modules', 'sharp', 'build', 'Release' )
);
}
task( 'package:win', context => package( 'win32' ) );
task( 'package:linux', context => package( 'linux' ) );
task( 'package:darwin', context => package( 'darwin' ) );
task( 'package', [ 'package:win', 'package:linux', 'package:darwin' ] );
task( 'check', async context => {
await tsc( __dirname, {
...JSON.parse( ( await fs.readFile( 'tsconfig.json', 'utf8' ) ) ).compilerOptions,
noEmit: true,
watch: true
} );
} );
task( 'default', [ 'build:dev' ] );
async function reset ( folder ) {
const stats = await fs.stat( folder ).catch( err => null );
if ( stats ) {
await del( folder );
fuse.bundle("vendor")
.cache(true)
.instructions('~ startup.ts');
if (!production) {
fuse.bundle("app")
.instructions(" > [startup.ts]")
.hmr()
.watch();
fuse.dev();
} else {
fuse.bundle('app').instructions(" > [startup.ts]")
}
fuse.run();
};
task('clean', async () => await src('dist/*').clean('dist').exec());
task("dev", ['clean'], () => run(false));
task("prod", ['clean'], () => run(true));
]
} );
fuse.bundle( "vendor" )
.instructions( "~ cli.ts" )
const app = fuse.bundle( "app" )
.completed( proc => proc.start() )
.instructions( "> [cli.ts]" );
if ( watch ) app.watch();
await fuse.run();
};
task( 'build:dev', async context => build( false, true ) );
task( 'build:rel', async context => build( true, true ) );
task( 'build:copy', async context => {
await watch( '**/*.(yaml|json)', { base: "src" } )
.dest( "lib/" )
.exec();
} );
let packageDependencies = {
'win32': {
'ffmpeg': 'https://ffmpeg.zeranoe.com/builds/win64/static/ffmpeg-4.1-win64-static.zip',
'rethinkdb': 'https://download.rethinkdb.com/windows/rethinkdb-2.3.6.zip',
'sharp': 'https://github.com/lovell/sharp/releases/download/v0.21.1/sharp-v0.21.1-node-v64-win32-x64.tar.gz',
'libvips': 'https://github.com/lovell/sharp-libvips/releases/download/v8.7.0/libvips-8.7.0-win32-x64.tar.gz'
},
CSSPlugin({
outFile: (file) => `dist/${file}`
})
]
]
});
}
});
task('clean', async context => {
await src('./dist')
.clean('dist/')
.exec()
});
task('default', ['clean'], async context => {
const fuse = context.getConfig();
fuse.bundle('example').instructions('> example.js');
await fuse.run();
});
path.join( buildFolder, 'node_modules', 'sharp' )
);
await copy(
`./builds/.cache/uncompressed/${ platform }/libvips/lib`,
path.join( buildFolder, 'node_modules', 'sharp', 'build', 'Release' )
);
}
task( 'package:win', context => package( 'win32' ) );
task( 'package:linux', context => package( 'linux' ) );
task( 'package:darwin', context => package( 'darwin' ) );
task( 'package', [ 'package:win', 'package:linux', 'package:darwin' ] );
task( 'check', async context => {
await tsc( __dirname, {
...JSON.parse( ( await fs.readFile( 'tsconfig.json', 'utf8' ) ) ).compilerOptions,
noEmit: true,
watch: true
} );
} );
task( 'default', [ 'build:dev' ] );
async function reset ( folder ) {
const stats = await fs.stat( folder ).catch( err => null );
if ( stats ) {
await del( folder );
} else {
await makeDir( folder );
`./builds./cache/uncompressed/${ platform }/ffmpeg`,
path.join( buildFolder, 'storage', 'ffmpeg' )
);
await copy(
`./builds/.cache/uncompressed/${ platform }/sharp`,
path.join( buildFolder, 'node_modules', 'sharp' )
);
await copy(
`./builds/.cache/uncompressed/${ platform }/libvips/lib`,
path.join( buildFolder, 'node_modules', 'sharp', 'build', 'Release' )
);
}
task( 'package:win', context => package( 'win32' ) );
task( 'package:linux', context => package( 'linux' ) );
task( 'package:darwin', context => package( 'darwin' ) );
task( 'package', [ 'package:win', 'package:linux', 'package:darwin' ] );
task( 'check', async context => {
await tsc( __dirname, {
...JSON.parse( ( await fs.readFile( 'tsconfig.json', 'utf8' ) ) ).compilerOptions,
noEmit: true,
watch: true
} );
} );
task( 'default', [ 'build:dev' ] );
async function reset ( folder ) {