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

View File

@ -1,7 +1,8 @@
import fs from 'fs'; /* eslint-disable @typescript-eslint/no-var-requires */
import path from 'path'; const fs = require('fs');
import inquirer from 'inquirer'; const path = require('path');
import simpleGit from 'simple-git/promise'; const simpleGit = require('simple-git/promise');
const inquirer = require('inquirer');
const git = simpleGit(); const git = simpleGit();
@ -104,14 +105,22 @@ export async function editChangeLog(changeLog: string):Promise<string> {
} }
export async function hasChangeLogEntry(version: string): Promise<boolean> { export async function hasChangeLogEntry(version: string): Promise<boolean> {
if (!version) {
return false;
}
const entry = await getChangelogEntry(version); 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> { export function getChangelogEntry(version: string): Promise<string> {
return new Promise<string>(resolve => { 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; if (err) throw err;
const releaseHeader = /^\d+\.\d+\.\d+$/.test(version) ? `## ${version}` : '## [Unreleased]'; const releaseHeader = /^\d+\.\d+\.\d+$/.test(version) ? `## ${version}` : '## [Unreleased]';

View File

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