mirror of https://github.com/sualko/cloud_bbb
chore: move back to js scripts
parent
3d9b579d55
commit
dee6866fd1
|
@ -9,19 +9,10 @@ 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';
|
||||
const { generateChangelog, hasChangeLogEntry } = require('./imports/changelog');
|
||||
|
||||
const packageInfo = require('../package.json');
|
||||
|
||||
declare global {
|
||||
interface String {
|
||||
error: string
|
||||
verbose: string
|
||||
warn: string
|
||||
green: string
|
||||
}
|
||||
}
|
||||
|
||||
colors.setTheme({
|
||||
verbose: 'cyan',
|
||||
warn: 'yellow',
|
||||
|
@ -144,7 +135,7 @@ async function keypress() {
|
|||
}]);
|
||||
}
|
||||
|
||||
async function commitChangeLog(): Promise<void> {
|
||||
async function commitChangeLog() {
|
||||
const status = await git.status();
|
||||
|
||||
if (status.staged.length > 0) {
|
||||
|
@ -216,7 +207,7 @@ function createArchive(appId, fileBaseName) {
|
|||
}
|
||||
|
||||
function createNextcloudSignature(appId, filePath) {
|
||||
return new Promise<void>((resolve) => {
|
||||
return new Promise((resolve) => {
|
||||
const sigPath = filePath + '.ncsig';
|
||||
exec(`openssl dgst -sha512 -sign ~/.nextcloud/certificates/${appId}.key ${filePath} | openssl base64 > ${sigPath}`, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
|
@ -239,7 +230,7 @@ function createNextcloudSignature(appId, filePath) {
|
|||
}
|
||||
|
||||
function createGPGSignature(filePath) {
|
||||
return new Promise<void>((resolve) => {
|
||||
return new Promise((resolve) => {
|
||||
exec(`gpg --yes --detach-sign "${filePath}"`, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
throw error;
|
||||
|
@ -261,7 +252,7 @@ function createGPGSignature(filePath) {
|
|||
}
|
||||
|
||||
function createGPGArmorSignature(filePath) {
|
||||
return new Promise<void>((resolve) => {
|
||||
return new Promise((resolve) => {
|
||||
exec(`gpg --yes --detach-sign --armor "${filePath}"`, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
throw error;
|
||||
|
@ -289,7 +280,7 @@ async function validateXml(xmlDoc) {
|
|||
throw 'Found no schema location';
|
||||
}
|
||||
|
||||
let schemaString: string;
|
||||
let schemaString;
|
||||
try {
|
||||
console.log('Downloading schema file...'.verbose);
|
||||
|
||||
|
@ -315,8 +306,8 @@ async function validateXml(xmlDoc) {
|
|||
}
|
||||
}
|
||||
|
||||
function wget(url: string) {
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
function wget(url) {
|
||||
return new Promise((resolve, reject) => {
|
||||
https.get(url, (resp) => {
|
||||
let data = '';
|
||||
|
||||
|
@ -332,4 +323,4 @@ function wget(url: string) {
|
|||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ const inquirer = require('inquirer');
|
|||
|
||||
const git = simpleGit();
|
||||
|
||||
export async function generateChangelog(version: string): Promise<string> {
|
||||
async function generateChangelog(version) {
|
||||
const latestTag = (await git.tags()).latest;
|
||||
const title = `v${version}` === latestTag ? '[Unreleased]' : `${version} (${new Date().toISOString().split('T')[0]})`;
|
||||
|
||||
|
@ -33,13 +33,13 @@ export async function generateChangelog(version: string): Promise<string> {
|
|||
}
|
||||
|
||||
const [, type, scope, description] = match;
|
||||
const entry = { type, scope, description, issues: <string[]> [] };
|
||||
const entry = { type, scope, description, issues: [] };
|
||||
|
||||
if(log.body) {
|
||||
const matches = log.body.match(/(?:fix|fixes|closes?|refs?) #(\d+)/g) || [];
|
||||
|
||||
for (const match of matches) {
|
||||
const [, number] = <RegExpMatchArray> match.match(/(\d+)$/);
|
||||
const [, number] = match.match(/(\d+)$/);
|
||||
|
||||
entry.issues.push(number);
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ export async function generateChangelog(version: string): Promise<string> {
|
|||
return changeLog;
|
||||
}
|
||||
|
||||
export async function editChangeLog(changeLog: string):Promise<string> {
|
||||
async function editChangeLog(changeLog) {
|
||||
const answers = await inquirer.prompt([{
|
||||
type: 'editor',
|
||||
name: 'changeLog',
|
||||
|
@ -104,7 +104,7 @@ export async function editChangeLog(changeLog: string):Promise<string> {
|
|||
return answers.changeLog;
|
||||
}
|
||||
|
||||
export async function hasChangeLogEntry(version: string): Promise<boolean> {
|
||||
async function hasChangeLogEntry(version) {
|
||||
if (!version) {
|
||||
return false;
|
||||
}
|
||||
|
@ -118,14 +118,14 @@ export async function hasChangeLogEntry(version: string): Promise<boolean> {
|
|||
return true;
|
||||
}
|
||||
|
||||
export function getChangelogEntry(version: string): Promise<string> {
|
||||
return new Promise<string>(resolve => {
|
||||
function getChangelogEntry(version) {
|
||||
return new Promise(resolve => {
|
||||
fs.readFile(path.join(__dirname, '..', '..', 'CHANGELOG.md'), 'utf8', function (err, data) {
|
||||
if (err) throw err;
|
||||
|
||||
const releaseHeader = /^\d+\.\d+\.\d+$/.test(version) ? `## ${version}` : '## [Unreleased]';
|
||||
const lines = data.split('\n');
|
||||
const entry: string[] = [];
|
||||
const entry = [];
|
||||
|
||||
let inEntry = false;
|
||||
|
||||
|
@ -147,3 +147,5 @@ export function getChangelogEntry(version: string): Promise<string> {
|
|||
});
|
||||
});
|
||||
}
|
||||
|
||||
exports.default = {generateChangelog, editChangeLog, hasChangeLogEntry, getChangelogEntry};
|
|
@ -8,20 +8,11 @@ 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';
|
||||
const { getChangelogEntry, hasChangeLogEntry } = require('./imports/changelog');
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const packageInfo = require('../package.json');
|
||||
|
||||
declare global {
|
||||
interface String {
|
||||
error: string
|
||||
verbose: string
|
||||
warn: string
|
||||
green: string
|
||||
}
|
||||
}
|
||||
|
||||
colors.setTheme({
|
||||
verbose: 'cyan',
|
||||
warn: 'yellow',
|
||||
|
@ -54,7 +45,9 @@ async function notAlreadyTagged() {
|
|||
}
|
||||
|
||||
async function lastCommitNotBuild() {
|
||||
return (await git.log(['-1'])).latest?.message !== commitMessage;
|
||||
const latest = (await git.log(['-1'])).latest || {};
|
||||
|
||||
return latest.message !== commitMessage;
|
||||
}
|
||||
|
||||
async function isMasterBranch() {
|
||||
|
@ -72,7 +65,7 @@ async function stageAllFiles() {
|
|||
|
||||
const gitProcess = execa('git', ['add', '-u']);
|
||||
|
||||
gitProcess.stdout?.pipe(process.stdout);
|
||||
gitProcess.stdout.pipe(process.stdout);
|
||||
|
||||
return gitProcess;
|
||||
}
|
||||
|
@ -80,7 +73,7 @@ async function stageAllFiles() {
|
|||
function showStagedDiff() {
|
||||
const gitProcess = execa('git', ['diff', '--staged']);
|
||||
|
||||
gitProcess.stdout?.pipe(process.stdout);
|
||||
gitProcess.stdout.pipe(process.stdout);
|
||||
|
||||
return gitProcess;
|
||||
}
|
||||
|
@ -181,7 +174,7 @@ async function createGithubRelease(changeLog) {
|
|||
owner,
|
||||
repo,
|
||||
release_id: releaseResponse.data.id,
|
||||
data: <any> fs.createReadStream(file),
|
||||
data: fs.createReadStream(file),
|
||||
headers: {
|
||||
'content-type': getMimeType(filename),
|
||||
'content-length': fs.statSync(file)['size'],
|
||||
|
@ -206,7 +199,7 @@ async function uploadToNextcloudStore(archiveUrl) {
|
|||
|
||||
const hostname = 'apps.nextcloud.com';
|
||||
const apiEndpoint = '/api/v1/apps/releases';
|
||||
const signatureFile = <string> files.find(file => file.endsWith('.ncsig'));
|
||||
const signatureFile = files.find(file => file.endsWith('.ncsig'));
|
||||
const data = JSON.stringify({
|
||||
download: archiveUrl,
|
||||
signature: fs.readFileSync(signatureFile, 'utf-8'),
|
||||
|
@ -229,7 +222,7 @@ async function uploadToNextcloudStore(archiveUrl) {
|
|||
return;
|
||||
}
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const req = https.request(options, res => {
|
||||
if (res.statusCode === 200) {
|
||||
console.log('App release was updated successfully'.verbose);
|
Loading…
Reference in New Issue