-
Notifications
You must be signed in to change notification settings - Fork 0
/
pullLatestFromSoftmotions.js
executable file
·63 lines (48 loc) · 1.98 KB
/
pullLatestFromSoftmotions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env node
import util from 'util';
import fs from 'fs';
import childProcess from 'node:child_process';
const exec = util.promisify(childProcess.exec);
async function main () {
const { stdout, stderr } = await exec(
`git ls-remote https://github.com/Softmotions/ejdb.git HEAD | awk '{ print $1}'`
);
const latestSoftmotionsHead = stdout.trim();
if (stderr.trim().length > 0) {
throw new Error('git ls-remote failed:', stderr);
}
console.log('softmotions/ejdb head:\n ', latestSoftmotionsHead + '\n');
if (latestSoftmotionsHead.length !== 40) {
throw new Error(`Latest head from SoftMotions was not the expected length`);
}
const installSourceData = await fs.promises.readFile('./installSource.sh', 'utf8');
const newInstallSourceData = [
'SOFTMOTIONS_BRANCH=' + latestSoftmotionsHead,
...installSourceData.split('\n').slice(1)
].join('\n');
await fs.promises.writeFile('./installSource.sh', newInstallSourceData);
const currentSoftmotionsHead = installSourceData.split('\n')[0].split('=')[1];
console.log('markwylde/node-ejdb-lite using:\n ', currentSoftmotionsHead + '\n');
if (currentSoftmotionsHead === latestSoftmotionsHead) {
console.log('No changes since last update');
process.exit(0);
}
{
if (!fs.existsSync('ejdb')) {
await exec('git clone --recursive https://github.com/Softmotions/ejdb.git');
}
}
{
const { error, stdout, stderr } = await exec(`
git diff --name-only HEAD ${currentSoftmotionsHead}
`, { cwd: 'ejdb' });
console.log('Differences since current release:')
console.log(stdout.split('\n').slice(0, -1).map(i => ` - ${i}`).join('\n'));
}
const { stdout: masterPackageJson } = await exec('git show master:package.json');
const masterPackage = JSON.parse(masterPackageJson);
await exec(`npm vers --allow-same-version --no-git-tag-version ${masterPackage.version}`);
await exec('npm vers patch --no-git-tag-version');
await exec('npm install --ignore-scripts');
}
main();