- use different pen for write logs
- remove default value for configuration, to cleanly fallback to defaults - rename gitHelper, move dir exists helper - add reading input values group - improve warning for configuration
This commit is contained in:
@@ -6,9 +6,7 @@ branding:
|
||||
color: 'green'
|
||||
inputs:
|
||||
configuration:
|
||||
required: true
|
||||
description: 'path to the configuration file'
|
||||
default: "configuration.json"
|
||||
path:
|
||||
description: 'the path to runt his action in'
|
||||
owner:
|
||||
|
||||
+38
-35
@@ -146,7 +146,7 @@ exports.DefaultConfiguration = {
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 9621:
|
||||
/***/ 353:
|
||||
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
@@ -182,39 +182,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.createCommandManager = void 0;
|
||||
const exec = __importStar(__webpack_require__(1514));
|
||||
const fs = __importStar(__webpack_require__(5747));
|
||||
const io = __importStar(__webpack_require__(7436));
|
||||
const utils_1 = __webpack_require__(918);
|
||||
function createCommandManager(workingDirectory) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return yield GitCommandManager.createCommandManager(workingDirectory);
|
||||
});
|
||||
}
|
||||
exports.createCommandManager = createCommandManager;
|
||||
function directoryExistsSync(path, required) {
|
||||
if (!path) {
|
||||
throw new Error("Arg 'path' must not be empty");
|
||||
}
|
||||
let stats;
|
||||
try {
|
||||
stats = fs.statSync(path);
|
||||
}
|
||||
catch (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
if (!required) {
|
||||
return false;
|
||||
}
|
||||
throw new Error(`Directory '${path}' does not exist`);
|
||||
}
|
||||
throw new Error(`Encountered an error when checking whether path '${path}' exists: ${error.message}`);
|
||||
}
|
||||
if (stats.isDirectory()) {
|
||||
return true;
|
||||
}
|
||||
else if (!required) {
|
||||
return false;
|
||||
}
|
||||
throw new Error(`Directory '${path}' does not exist`);
|
||||
}
|
||||
class GitCommandManager {
|
||||
// Private constructor; use createCommandManager()
|
||||
constructor() {
|
||||
@@ -250,7 +225,7 @@ class GitCommandManager {
|
||||
}
|
||||
execGit(args, allowAllExitCodes = false, silent = false) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
directoryExistsSync(this.workingDirectory, true);
|
||||
utils_1.directoryExistsSync(this.workingDirectory, true);
|
||||
const result = new GitOutput();
|
||||
const stdout = [];
|
||||
const options = {
|
||||
@@ -322,12 +297,13 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
const core = __importStar(__webpack_require__(2186));
|
||||
const utils_1 = __webpack_require__(918);
|
||||
const releaseNotes_1 = __webpack_require__(5882);
|
||||
const git_helper_1 = __webpack_require__(9621);
|
||||
const gitHelper_1 = __webpack_require__(353);
|
||||
const github = __importStar(__webpack_require__(5438));
|
||||
const path = __importStar(__webpack_require__(5622));
|
||||
const configuration_1 = __webpack_require__(5527);
|
||||
function run() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
core.startGroup(`📘 Reading input values`);
|
||||
try {
|
||||
let githubWorkspacePath = process.env['GITHUB_WORKSPACE'];
|
||||
if (!githubWorkspacePath) {
|
||||
@@ -345,7 +321,7 @@ function run() {
|
||||
core.debug(`configurationPath = '${configurationPath}'`);
|
||||
const providedConfiguration = utils_1.readConfiguration(configurationPath);
|
||||
if (!providedConfiguration) {
|
||||
core.error(`Configuration provided, but it couldn't be found, or failed to parse`);
|
||||
core.info(`⚠️ Configuration provided, but it couldn't be found, or failed to parse. Fallback to Defaults`);
|
||||
}
|
||||
else {
|
||||
configuration = providedConfiguration;
|
||||
@@ -359,7 +335,7 @@ function run() {
|
||||
const ignorePreReleases = core.getInput('ignorePreReleases');
|
||||
if (!toTag) {
|
||||
// if not specified try to retrieve tag from git
|
||||
const gitHelper = yield git_helper_1.createCommandManager(repositoryPath);
|
||||
const gitHelper = yield gitHelper_1.createCommandManager(repositoryPath);
|
||||
const latestTag = yield gitHelper.latestTag();
|
||||
toTag = latestTag;
|
||||
core.debug(`toTag = '${latestTag}'`);
|
||||
@@ -399,6 +375,7 @@ function run() {
|
||||
else {
|
||||
core.debug(`Resolved 'toTag' as ${toTag}`);
|
||||
}
|
||||
core.endGroup();
|
||||
const releaseNotes = new releaseNotes_1.ReleaseNotes({
|
||||
owner,
|
||||
repo,
|
||||
@@ -964,7 +941,7 @@ function buildChangelog(prs, config) {
|
||||
: configuration_1.DefaultConfiguration.pr_template), validatedTransformers));
|
||||
}
|
||||
core.info(`ℹ️ Used ${validateTransfomers.length} transformers to adjust message`);
|
||||
core.info(`✏️ Wrote messages for ${prs.length} pull requests`);
|
||||
core.info(`✒️ Wrote messages for ${prs.length} pull requests`);
|
||||
// bring PRs into the order of categories
|
||||
const categorized = new Map();
|
||||
const categories = (_b = config.categories) !== null && _b !== void 0 ? _b : configuration_1.DefaultConfiguration.categories;
|
||||
@@ -998,12 +975,12 @@ function buildChangelog(prs, config) {
|
||||
changelog = `${changelog}\n`;
|
||||
}
|
||||
}
|
||||
core.info(`✏️ Wrote ${categorized.size} categorized pull requests down`);
|
||||
core.info(`✒️ Wrote ${categorized.size} categorized pull requests down`);
|
||||
let changelogUncategorized = '';
|
||||
for (const pr of uncategorized) {
|
||||
changelogUncategorized = `${changelogUncategorized + pr}\n`;
|
||||
}
|
||||
core.info(`✏️ Wrote ${changelogUncategorized.length} non categorized pull requests down`);
|
||||
core.info(`✒️ Wrote ${changelogUncategorized.length} non categorized pull requests down`);
|
||||
// fill template
|
||||
let transformedChangelog = (_c = config.template) !== null && _c !== void 0 ? _c : configuration_1.DefaultConfiguration.template;
|
||||
transformedChangelog = transformedChangelog.replace('${{CHANGELOG}}', changelog);
|
||||
@@ -1089,7 +1066,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.readConfiguration = void 0;
|
||||
exports.directoryExistsSync = exports.readConfiguration = void 0;
|
||||
const fs = __importStar(__webpack_require__(5747));
|
||||
function readConfiguration(filename) {
|
||||
try {
|
||||
@@ -1102,6 +1079,32 @@ function readConfiguration(filename) {
|
||||
}
|
||||
}
|
||||
exports.readConfiguration = readConfiguration;
|
||||
function directoryExistsSync(path, required) {
|
||||
if (!path) {
|
||||
throw new Error("Arg 'path' must not be empty");
|
||||
}
|
||||
let stats;
|
||||
try {
|
||||
stats = fs.statSync(path);
|
||||
}
|
||||
catch (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
if (!required) {
|
||||
return false;
|
||||
}
|
||||
throw new Error(`Directory '${path}' does not exist`);
|
||||
}
|
||||
throw new Error(`Encountered an error when checking whether path '${path}' exists: ${error.message}`);
|
||||
}
|
||||
if (stats.isDirectory()) {
|
||||
return true;
|
||||
}
|
||||
else if (!required) {
|
||||
return false;
|
||||
}
|
||||
throw new Error(`Directory '${path}' does not exist`);
|
||||
}
|
||||
exports.directoryExistsSync = directoryExistsSync;
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -1,6 +1,7 @@
|
||||
import * as exec from '@actions/exec'
|
||||
import * as fs from 'fs'
|
||||
import * as io from '@actions/io'
|
||||
import { directoryExistsSync } from './utils';
|
||||
|
||||
export async function createCommandManager(
|
||||
workingDirectory: string
|
||||
@@ -8,37 +9,6 @@ export async function createCommandManager(
|
||||
return await GitCommandManager.createCommandManager(workingDirectory)
|
||||
}
|
||||
|
||||
function directoryExistsSync(path: string, required?: boolean): boolean {
|
||||
if (!path) {
|
||||
throw new Error("Arg 'path' must not be empty")
|
||||
}
|
||||
|
||||
let stats: fs.Stats
|
||||
try {
|
||||
stats = fs.statSync(path)
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
if (!required) {
|
||||
return false
|
||||
}
|
||||
|
||||
throw new Error(`Directory '${path}' does not exist`)
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`Encountered an error when checking whether path '${path}' exists: ${error.message}`
|
||||
)
|
||||
}
|
||||
|
||||
if (stats.isDirectory()) {
|
||||
return true
|
||||
} else if (!required) {
|
||||
return false
|
||||
}
|
||||
|
||||
throw new Error(`Directory '${path}' does not exist`)
|
||||
}
|
||||
|
||||
class GitCommandManager {
|
||||
private gitPath = ''
|
||||
private workingDirectory = ''
|
||||
+4
-4
@@ -1,12 +1,13 @@
|
||||
import * as core from '@actions/core'
|
||||
import {readConfiguration} from './utils'
|
||||
import {ReleaseNotes} from './releaseNotes'
|
||||
import {createCommandManager} from './git-helper'
|
||||
import {createCommandManager} from './gitHelper'
|
||||
import * as github from '@actions/github'
|
||||
import * as path from 'path'
|
||||
import {DefaultConfiguration} from './configuration'
|
||||
|
||||
async function run(): Promise<void> {
|
||||
core.startGroup(`📘 Reading input values`)
|
||||
try {
|
||||
let githubWorkspacePath = process.env['GITHUB_WORKSPACE']
|
||||
if (!githubWorkspacePath) {
|
||||
@@ -29,9 +30,7 @@ async function run(): Promise<void> {
|
||||
core.debug(`configurationPath = '${configurationPath}'`)
|
||||
const providedConfiguration = readConfiguration(configurationPath)
|
||||
if (!providedConfiguration) {
|
||||
core.error(
|
||||
`Configuration provided, but it couldn't be found, or failed to parse`
|
||||
)
|
||||
core.info(`⚠️ Configuration provided, but it couldn't be found, or failed to parse. Fallback to Defaults`)
|
||||
} else {
|
||||
configuration = providedConfiguration
|
||||
}
|
||||
@@ -94,6 +93,7 @@ async function run(): Promise<void> {
|
||||
} else {
|
||||
core.debug(`Resolved 'toTag' as ${toTag}`)
|
||||
}
|
||||
core.endGroup()
|
||||
|
||||
const releaseNotes = new ReleaseNotes({
|
||||
owner,
|
||||
|
||||
+3
-3
@@ -35,7 +35,7 @@ export function buildChangelog(
|
||||
)
|
||||
}
|
||||
core.info(`ℹ️ Used ${validateTransfomers.length} transformers to adjust message`)
|
||||
core.info(`✏️ Wrote messages for ${prs.length} pull requests`)
|
||||
core.info(`✒️ Wrote messages for ${prs.length} pull requests`)
|
||||
|
||||
// bring PRs into the order of categories
|
||||
const categorized = new Map<Category, string[]>()
|
||||
@@ -76,13 +76,13 @@ export function buildChangelog(
|
||||
changelog = `${changelog}\n`
|
||||
}
|
||||
}
|
||||
core.info(`✏️ Wrote ${categorized.size} categorized pull requests down`)
|
||||
core.info(`✒️ Wrote ${categorized.size} categorized pull requests down`)
|
||||
|
||||
let changelogUncategorized = ''
|
||||
for (const pr of uncategorized) {
|
||||
changelogUncategorized = `${changelogUncategorized + pr}\n`
|
||||
}
|
||||
core.info(`✏️ Wrote ${changelogUncategorized.length} non categorized pull requests down`)
|
||||
core.info(`✒️ Wrote ${changelogUncategorized.length} non categorized pull requests down`)
|
||||
|
||||
// fill template
|
||||
let transformedChangelog = config.template ?? DefaultConfiguration.template
|
||||
|
||||
@@ -10,3 +10,34 @@ export function readConfiguration(filename: string): Configuration | null {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export function directoryExistsSync(path: string, required?: boolean): boolean {
|
||||
if (!path) {
|
||||
throw new Error("Arg 'path' must not be empty")
|
||||
}
|
||||
|
||||
let stats: fs.Stats
|
||||
try {
|
||||
stats = fs.statSync(path)
|
||||
} catch (error) {
|
||||
if (error.code === 'ENOENT') {
|
||||
if (!required) {
|
||||
return false
|
||||
}
|
||||
|
||||
throw new Error(`Directory '${path}' does not exist`)
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
`Encountered an error when checking whether path '${path}' exists: ${error.message}`
|
||||
)
|
||||
}
|
||||
|
||||
if (stats.isDirectory()) {
|
||||
return true
|
||||
} else if (!required) {
|
||||
return false
|
||||
}
|
||||
|
||||
throw new Error(`Directory '${path}' does not exist`)
|
||||
}
|
||||
Reference in New Issue
Block a user