Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let result;
try {
result = yield server.result;
}
catch (error) {
context.reportStatus("Error: " + error);
}
// Copy electron main
const fromMain = path_1.join(context.workspaceRoot, options.electronMain);
const toMain = path_1.join(result.outputPath, path_1.basename(options.electronMain));
fs_1.copyFileSync(fromMain, toMain);
// write electron package to dist
fs_1.writeFileSync(path_1.join(result.outputPath, "package.json"), JSON.stringify(options.electronPackage), { encoding: "utf-8" });
// Build!
try {
yield builder.build(options.packagerConfig);
}
catch (e) {
console.log("Publish error", e);
}
return {
success: true
};
});
}
var build = () => {
// Build
if (!cli.downloadOnly) {
builder
.build({
targets: builder.createTargets([targetOs]),
config: Object.assign(buildConfig, {
extraMetadata: cli.package
? Object.assign(cli.extraMetadata, { package: cli.package })
: cli.extraMetadata
})
})
.then(() => {
console.log("Done");
})
.catch(e => {
if (
e.message.indexOf("GitHub Personal Access Token is not set") !== -1
) {
console.log("Done");
await fs.remove(join(paths.build, 'node_modules'))
await new Promise((resolve, reject) => {
spawn(yarnBin, ['install'], { cwd: paths.build, stdio: 'inherit' })
.on('error', err => reject(err))
.on('close', (code, signal) => (code === 0 ? resolve() : reject(new Error(code))))
})
const targets = [
...(isMacOS ? [builder.Platform.MAC.createTarget()] : []),
...(isWindows ? [builder.Platform.WINDOWS.createTarget()] : []),
...(isLinux ? [builder.Platform.LINUX.createTarget()] : []),
]
for (const target of targets) {
await builder.build({
// targets: builder.Platform.MAC.createTarget(),
targets: target,
config: {
appId: 'studio.delir',
copyright: '© 2017 Ragg',
productName: 'Delir',
electronVersion,
asar: true,
asarUnpack: ['node_modules/'],
npmRebuild: true,
// nodeGypRebuild: true,
directories: {
buildResources: join(__dirname, 'build-assets/build'),
app: paths.build,
output: paths.release,
},
function buildInstaller(gulp, origin, destination, extraFiles) {
const builder = require('electron-builder');
const Platform = builder.Platform;
// Promise is returned
return builder.build({
targets: Platform.MAC.createTarget(),
config: {
appId: 'com.redhat.devsuite.installer',
mac: {
category: 'public.app-category.developer-tools',
icon: 'resources/devsuite.icns',
target: ['dmg'],
publish: null
},
files: '**/*',
extraFiles,
directories: {
app : 'transpiled'
}
}
}).then(() => {
};
break;
case "mac":
console.log("Using build configuration to macOS.");
target = Platform.MAC.createTarget();
break;
case "linux":
console.log("Using build configuration to Linux (64-bit).");
target = Platform.LINUX.createTarget();
break;
default:
console.error("ERROR - Build target not recognised. Accepted targets: win, win32, mac, linux.");
return;
}
builder.build({
targets: target,
config: config
}).then(function (m) {
console.log("Generated files:");
console.log(m);
}).catch(function (e) {
console.error(e);
});
async function build(): Promise {
console.log('Remove build directory.');
await remove(BUILD_PATH);
const packageInfo: PackageInfo = await readJson(
path.resolve(DIST_PATH, 'package.json'),
{ throws: true },
);
console.log('Build started...');
const buildTargets = {
mac: os.platform() === 'darwin' ? ['dmg'] : undefined,
linux: ['snap', 'AppImage'],
win: ['nsis'],
};
await Builder.build({
config: {
appId: packageInfo.appId,
productName: packageInfo.productName,
buildVersion: packageInfo.version,
asar: true,
npmRebuild: false,
directories: {
app: DIST_PATH,
output: BUILD_PATH,
},
mac: {
category: 'public.app-category.developer-tools',
darkModeSupport: true,
icon: path.resolve(SRC_PATH, 'assets/logos/icon-logo.icns'),
},
appImage: {
return new Observable(observer => {
builder.build(config).then(
() => {
observer.next({success: true});
observer.complete();
},
e => {
console.log("Error ", e);
observer.error();
}
);
});
}
gulp.task('redist:windows-squirrel', function () {
var rename = require('gulp-rename');
var builder = require('electron-builder');
const config = getConfig("windows", "squirrel");
console.log(`Electron mirror: ${getElectronMirrorUrl()}`);
return builder.build({
targets: builder.Platform.WINDOWS.createTarget(["squirrel"], builder.Arch.x64),
config,
prepackaged: './dist/win-ia32-unpacked'
}).then((filenames) => {
return gulp.src(filenames, { allowEmpty: true })
.pipe(rename(function (path) {
path.basename = setReleaseFilename(path.basename, {
lowerCase: false,
replaceName: true,
replaceWhitespace: true,
srcName: config.productName,
dstName: config.squirrelWindows.name
});
}))
.pipe(gulp.dest('./dist'));
}).then(() => {
async function runBuilder () {
for (let flag of buildTargets) {
let target
if (flag === '--mac') target = Platform.MAC.createTarget()
if (flag === '--win') target = Platform.WINDOWS.createTarget()
if (flag === '--linux') target = Platform.LINUX.createTarget()
if (flag === '--app-image') target = Platform.LINUX.createTarget()
await builder.build({ 'targets': target, 'config': config })
log.success(`Build for ${flag.substr(2)} complete!`)
}
}
gulp.task('build:dist', ['default'], cb => {
builder.build({
platform: (isCI === true && process.platform === 'linux' ? ['linux', 'win32'] : process.platform),
arch: 'x64',
config: {
appId: 'com.willyb321.media_mate',
nsis: {
oneClick: false,
allowToChangeInstallationDirectory: true
},
mac: {
category: 'public.app-category.entertainment',
target: ['zip'],
publish: [
"github"
]
},
win: {