Skip to content

Commit

Permalink
feat: build for release
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 29, 2020
1 parent 8c40c30 commit a8a8e25
Show file tree
Hide file tree
Showing 374 changed files with 7,871 additions and 16,679 deletions.
2 changes: 1 addition & 1 deletion build.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"owner":"technote-space","repo":"toc-generator","sha":"ee6c4be51de4b847cb936021bfe37701fef354dd","ref":"refs/tags/test/v2.5.2.325127638","tagName":"test/v2.5.2.325127638","branch":"gh-actions","tags":["test/v2.5.2.325127638","test/v2.5.2","test/v2.5","test/v2"],"updated_at":"2020-10-23T23:34:32.685Z"}
{"owner":"technote-space","repo":"toc-generator","sha":"FETCH_HEAD","ref":"refs/heads/master","tagName":"test/v2.5.2","branch":"gh-actions","tags":["test/v2.5.2","test/v2.5","test/v2"],"updated_at":"2020-10-29T18:54:14.283Z"}
4 changes: 1 addition & 3 deletions lib/constant.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CLOSING_COMMENT = exports.OPENING_COMMENT = exports.TARGET_EVENTS = exports.ACTION_REPO = exports.ACTION_OWNER = exports.ACTION_NAME = void 0;
exports.TARGET_EVENTS = exports.ACTION_REPO = exports.ACTION_OWNER = exports.ACTION_NAME = void 0;
exports.ACTION_NAME = 'TOC Generator';
exports.ACTION_OWNER = 'technote-space';
exports.ACTION_REPO = 'toc-generator';
Expand All @@ -17,5 +17,3 @@ exports.TARGET_EVENTS = {
'closed',
],
};
exports.OPENING_COMMENT = '<!-- START doctoc ';
exports.CLOSING_COMMENT = '<!-- END doctoc ';
7 changes: 2 additions & 5 deletions lib/utils/doctoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.doctoc = exports.executeDoctoc = exports.transformAndSave = void 0;
const github_action_helper_1 = require("@technote-space/github-action-helper");
const fs_1 = require("fs");
const fast_glob_1 = require("fast-glob");
const file_1 = __importDefault(require("doctoc/lib/file"));
const doctoc_1 = require("@technote-space/doctoc");
const misc_1 = require("./misc");
const transform_1 = require("./transform");
exports.transformAndSave = (files, title) => {
Expand All @@ -37,7 +34,7 @@ exports.executeDoctoc = (paths, title, logger) => parsePaths(paths).map(path =>
const stat = fs_1.statSync(path);
if (stat.isDirectory()) {
logger.displayCommand('DocToccing "%s" and its sub directories.', path);
return exports.transformAndSave(file_1.default.findMarkdownFiles(path), title);
return exports.transformAndSave(doctoc_1.findMarkdownFiles(path), title);
}
logger.displayCommand('DocToccing single file "%s".', path);
return exports.transformAndSave([{ path }], title);
Expand Down
6 changes: 2 additions & 4 deletions lib/utils/misc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getArrayInput = exports.cleanPath = exports.homeExpanded = exports.getRunnerArguments = exports.getEntryPrefix = exports.getMaxHeaderLevel = exports.wrapToc = exports.wrapTitle = exports.isFolding = exports.isNoTitle = exports.replaceDirectory = void 0;
exports.getArrayInput = exports.cleanPath = exports.homeExpanded = exports.getRunnerArguments = exports.getEntryPrefix = exports.getMaxHeaderLevel = exports.isFolding = exports.isNoTitle = exports.replaceDirectory = void 0;
const path_1 = require("path");
const os_1 = require("os");
const github_action_helper_1 = require("@technote-space/github-action-helper");
Expand All @@ -18,9 +18,7 @@ exports.replaceDirectory = (message) => {
const getTargetPaths = () => github_action_helper_1.Utils.getArrayInput('TARGET_PATHS', true).filter(target => target && !target.startsWith('/') && !target.includes('..'));
const getTocTitle = () => core_1.getInput('TOC_TITLE');
exports.isNoTitle = (title) => '' === title;
exports.isFolding = (title) => !exports.isNoTitle(title) && github_action_helper_1.Utils.getBoolValue(core_1.getInput('FOLDING'));
exports.wrapTitle = (title) => exports.isFolding(title) ? `<summary>${title.replace(/^([*_]*)(.+)\1$/, '$2')}</summary>` : title;
exports.wrapToc = (toc, title) => exports.isFolding(title) ? `<details>\n${toc}\n</details>` : toc;
exports.isFolding = () => github_action_helper_1.Utils.getBoolValue(core_1.getInput('FOLDING'));
exports.getMaxHeaderLevel = () => /^\d+$/.test(core_1.getInput('MAX_HEADER_LEVEL')) ? Number.parseInt(core_1.getInput('MAX_HEADER_LEVEL')) : undefined;
exports.getEntryPrefix = () => core_1.getInput('ENTRY_PREFIX');
const getExecuteCommands = (logger) => {
Expand Down
54 changes: 12 additions & 42 deletions lib/utils/transform.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,19 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformWithWrap = exports.normalizeMarkerComment = void 0;
const transform_1 = __importStar(require("doctoc/lib/transform"));
const update_section_1 = __importDefault(require("update-section"));
exports.transformWithWrap = void 0;
const fs_1 = require("fs");
const doctoc_1 = require("@technote-space/doctoc");
const github_action_helper_1 = require("@technote-space/github-action-helper");
const misc_1 = require("./misc");
const constant_1 = require("../constant");
const matchesStart = (line) => github_action_helper_1.Utils.getRegExp(constant_1.OPENING_COMMENT).test(line);
const matchesEnd = (line) => github_action_helper_1.Utils.getRegExp(constant_1.CLOSING_COMMENT).test(line);
exports.normalizeMarkerComment = (contents) => {
const replacedOpening = misc_1.getArrayInput('OPENING_COMMENT').reduce((acc, comment) => acc.split('\n').map(line => line.replace(github_action_helper_1.Utils.getPrefixRegExp(comment), constant_1.OPENING_COMMENT)).join('\n'), contents);
return misc_1.getArrayInput('CLOSING_COMMENT').reduce((acc, comment) => acc.split('\n').map(line => line.replace(github_action_helper_1.Utils.getPrefixRegExp(comment), constant_1.CLOSING_COMMENT)).join('\n'), replacedOpening);
};
exports.transformWithWrap = (path, title) => {
const content = exports.normalizeMarkerComment(fs_1.readFileSync(path, 'utf8'));
const { toc } = transform_1.default(content, undefined, misc_1.getMaxHeaderLevel(), misc_1.wrapTitle(title), misc_1.isNoTitle(title), misc_1.getEntryPrefix());
// transformed is not working
// https://github.com/thlorenz/doctoc/pull/169
const data = update_section_1.default(content, `${transform_1.start}\n${misc_1.wrapToc(toc, title)}\n${transform_1.end}`, matchesStart, matchesEnd, true);
const transformed = data !== content;
if (transformed) {
return { path, transformed, data };
}
return { path, transformed, data: '' };
const { transformed, data } = doctoc_1.transform(fs_1.readFileSync(path, 'utf8'), {
maxHeaderLevel: misc_1.getMaxHeaderLevel(),
title,
isNotitle: misc_1.isNoTitle(title),
isFolding: misc_1.isFolding(),
entryPrefix: misc_1.getEntryPrefix(),
checkOpeningComments: github_action_helper_1.Utils.uniqueArray(misc_1.getArrayInput('OPENING_COMMENT').concat(doctoc_1.CHECK_OPENING_COMMENT)),
checkClosingComments: github_action_helper_1.Utils.uniqueArray(misc_1.getArrayInput('CLOSING_COMMENT').concat(doctoc_1.CHECK_CLOSING_COMMENT)),
});
return { path, transformed, data };
};
1 change: 0 additions & 1 deletion node_modules/.bin/doctoc

This file was deleted.

Loading

0 comments on commit a8a8e25

Please sign in to comment.