chore: fix build scripts

pull/126/head
sualko 2021-02-01 10:57:41 +01:00
parent 5be06d6ef9
commit 5dd7669035
3 changed files with 38 additions and 26 deletions

View File

@ -1,16 +1,16 @@
import colors from 'colors';
import fs from 'fs';
import path from 'path';
import inquirer from 'inquirer';
import simpleGit from 'simple-git/promise';
import libxml from 'libxmljs';
import https from 'https';
import archiver from 'archiver';
import execa from 'execa';
import {exec} from 'child_process';
/* eslint-disable @typescript-eslint/no-var-requires */
const colors = require('colors');
const fs = require('fs');
const path = require('path');
const libxml = require('libxmljs');
const https = require('https');
const archiver = require('archiver');
const execa = require('execa');
const simpleGit = require('simple-git/promise');
const inquirer = require('inquirer');
const { exec } = require('child_process');
import { generateChangelog, hasChangeLogEntry } from './imports/changelog';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const packageInfo = require('../package.json');
declare global {

View File

@ -1,7 +1,8 @@
import fs from 'fs';
import path from 'path';
import inquirer from 'inquirer';
import simpleGit from 'simple-git/promise';
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require('fs');
const path = require('path');
const simpleGit = require('simple-git/promise');
const inquirer = require('inquirer');
const git = simpleGit();
@ -104,14 +105,22 @@ export async function editChangeLog(changeLog: string):Promise<string> {
}
export async function hasChangeLogEntry(version: string): Promise<boolean> {
if (!version) {
return false;
}
const entry = await getChangelogEntry(version);
return entry.split('\n').filter(line => !!line.trim()).length > 1;
if (entry.split('\n').filter(line => !!line.trim()).length < 2) {
throw `Found no change log entry for ${version}`;
}
return true;
}
export function getChangelogEntry(version: string): Promise<string> {
return new Promise<string>(resolve => {
fs.readFile(path.join(__dirname, '..', 'CHANGELOG.md'), 'utf8', function (err, data) {
fs.readFile(path.join(__dirname, '..', '..', 'CHANGELOG.md'), 'utf8', function (err, data) {
if (err) throw err;
const releaseHeader = /^\d+\.\d+\.\d+$/.test(version) ? `## ${version}` : '## [Unreleased]';

View File

@ -1,12 +1,13 @@
import colors from 'colors';
import fs from 'fs';
import path from 'path';
import inquirer from 'inquirer';
import simpleGit from 'simple-git/promise';
import https from 'https';
import execa from 'execa';
import {Octokit} from '@octokit/rest';
import dotenv from 'dotenv';
/* eslint-disable @typescript-eslint/no-var-requires */
const colors = require('colors');
const fs = require('fs');
const path = require('path');
const https = require('https');
const execa = require('execa');
const simpleGit = require('simple-git/promise');
const inquirer = require('inquirer');
const dotenv = require('dotenv');
const { Octokit } = require('@octokit/rest');
import { getChangelogEntry, hasChangeLogEntry } from './imports/changelog';
// eslint-disable-next-line @typescript-eslint/no-var-requires
@ -40,6 +41,8 @@ const files = [
path.join(__dirname, '..', 'archives', `bbb-v${packageInfo.version}.tar.gz.sig`),
];
isDryRun && console.log('Script is executed in dry-run mode.'.verbose);
function pull() {
return git.pull('origin', 'master');
}