1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-30 08:26:59 +02:00
joplin/gulpfile.js

73 lines
2.2 KiB
JavaScript
Raw Normal View History

2020-02-17 22:55:09 +02:00
const gulp = require('gulp');
2023-04-06 12:11:45 +02:00
const execa = require('execa');
const { stdout } = require('process');
const execCommand = async (executableName, args, options = null) => {
options = {
showInput: true,
showStdout: true,
showStderr: true,
quiet: false,
...options,
};
if (options.quiet) {
options.showInput = false;
options.showStdout = false;
options.showStderr = false;
}
if (options.showInput) {
stdout.write(`> ${executableName} ${args.join(' ')}\n`);
}
const promise = execa(executableName, args);
if (options.showStdout && promise.stdout) promise.stdout.pipe(process.stdout);
if (options.showStderr && promise.stderr) promise.stderr.pipe(process.stderr);
const result = await promise;
return result.stdout.trim();
};
2020-02-17 22:55:09 +02:00
const tasks = {
2020-11-05 18:58:23 +02:00
completePublishAll: {
fn: async () => {
2023-04-06 12:11:45 +02:00
await execCommand('git', ['add', '-A']);
await execCommand('git', ['commit', '-m', 'Releasing sub-packages']);
2023-02-26 14:33:59 +02:00
// Lerna does some unnecessary auth check that doesn't work with
// automation tokens, thus the --no-verify-access. Automation token
// is still used for access when publishing even with this flag
// (publishing would fail otherwise).
// https://github.com/lerna/lerna/issues/2788
2023-04-06 12:11:45 +02:00
await execCommand('lerna', ['publish', 'from-package', '-y', '--no-verify-access']);
2023-04-06 12:11:45 +02:00
await execCommand('yarn', ['install']);
await execCommand('git', ['add', '-A']);
await execCommand('git', ['commit', '-m', 'Lock file']);
2023-02-26 14:33:59 +02:00
2023-04-06 12:11:45 +02:00
await execCommand('git', ['push']);
2020-11-05 18:58:23 +02:00
},
},
build: {
fn: async () => {
// Building everything in parallel seems to be unreliable on CI as
// certain scripts randomly fail with missing files or folder, or
// cannot delete certain directories (eg. copyPluginAssets or
// copyApplicationAssets). Because of this, on CI, we run the build
// sequencially. Locally we run it in parallel, which is much
// faster, especially when having to rebuild after adding a
// dependency.
if (process.env.BUILD_SEQUENCIAL === '1') {
2023-04-06 12:11:45 +02:00
await execCommand('yarn', ['run', 'buildSequential']);
} else {
2023-04-06 12:11:45 +02:00
await execCommand('yarn', ['run', 'buildParallel']);
}
},
},
2020-02-17 22:55:09 +02:00
};
for (const taskName in tasks) {
gulp.task(taskName, tasks[taskName].fn);
}