Skip to content

Commit 03fe5e2

Browse files
feat: Build for release
1 parent 158f5d7 commit 03fe5e2

File tree

10 files changed

+42
-23
lines changed

10 files changed

+42
-23
lines changed

build.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"owner":"technote-space","repo":"release-github-actions","sha":"29868c694424f1c40bc250866b83f036eb9e020d","ref":"refs/tags/test/v1.7.2.3","tagName":"test/v1.7.2.3","branch":"gh-actions","tags":["test/v1","test/v1.7","test/v1.7.2","test/v1.7.2.3"],"updated_at":"2019-12-08T06:23:27.359Z"}
1+
{"owner":"technote-space","repo":"release-github-actions","sha":"4de4fbc08db8541dcdfe6a79b13153c43573d8b4","ref":"refs/tags/test/v1.7.3","tagName":"test/v1.7.3","branch":"gh-actions","tags":["test/v1","test/v1.7","test/v1.7.3"],"updated_at":"2019-12-08T12:21:25.894Z"}

lib/utils/misc.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ const path_1 = __importDefault(require("path"));
88
const github_action_helper_1 = require("@technote-space/github-action-helper");
99
const core_1 = require("@actions/core");
1010
const constant_1 = require("../constant");
11-
const { getWorkspace, getPrefixRegExp, getBoolValue, getArrayInput, uniqueArray, isSemanticVersioningTagName, useNpm } = github_action_helper_1.Utils;
12-
const getCleanTargets = () => uniqueArray((core_1.getInput('CLEAN_TARGETS') || constant_1.DEFAULT_CLEAN_TARGETS).split(',').map(target => target.trim()).filter(target => target && !target.startsWith('/') && !target.includes('..')));
11+
const { getWorkspace, getPrefixRegExp, getBoolValue, getArrayInput, uniqueArray, isSemanticVersioningTagName, useNpm, escapeRegExp } = github_action_helper_1.Utils;
12+
const getCleanTargets = () => uniqueArray((core_1.getInput('CLEAN_TARGETS') || constant_1.DEFAULT_CLEAN_TARGETS)
13+
.split(',')
14+
// eslint-disable-next-line no-control-regex
15+
.map(target => target.trim().replace(/[\x00-\x1f\x80-\x9f]/, ''))
16+
.filter(target => target && !target.startsWith('/') && !target.includes('..')));
1317
const normalizeCommand = (command) => command.trim().replace(/\s{2,}/g, ' ');
1418
exports.getSearchBuildCommandTargets = () => {
1519
const command = core_1.getInput('BUILD_COMMAND_TARGET');
@@ -35,6 +39,25 @@ exports.detectBuildCommand = (dir) => {
3539
}
3640
return false;
3741
};
42+
exports.getClearFilesCommands = (targets) => {
43+
const commands = [];
44+
const searchValues = '?<>:|"\'@#$%^& ;';
45+
const replaceValue = '$1\\$2';
46+
const escapeFunc = (item) => searchValues.split('').reduce((acc, val) => acc.replace(new RegExp('([^\\\\])(' + escapeRegExp(val) + ')'), replaceValue), item);
47+
const beginWithDash = targets.filter(item => item.startsWith('-')).map(escapeFunc);
48+
const withWildcard = targets.filter(item => !item.startsWith('-') && item.includes('*')).map(escapeFunc);
49+
const withoutWildcard = targets.filter(item => !item.startsWith('-') && !item.includes('*'));
50+
if (beginWithDash.length) {
51+
commands.push(...beginWithDash.map(target => `rm -rdf -- ${target}`));
52+
}
53+
if (withWildcard.length) {
54+
commands.push(...withWildcard.map(target => `rm -rdf ${target}`));
55+
}
56+
if (withoutWildcard.length) {
57+
commands.push({ command: 'rm', args: ['-rdf', ...withoutWildcard] });
58+
}
59+
return commands;
60+
};
3861
exports.getBuildCommands = (dir) => {
3962
let commands = getArrayInput('BUILD_COMMAND', false, '&&').map(normalizeCommand);
4063
const addRemove = !commands.length;
@@ -56,7 +79,7 @@ exports.getBuildCommands = (dir) => {
5679
commands.push(`${pkgManager} install --production`);
5780
}
5881
if (addRemove) {
59-
commands.push({ command: 'rm', args: ['-rdf', ...getCleanTargets()] });
82+
commands.push(...exports.getClearFilesCommands(getCleanTargets()));
6083
}
6184
return commands;
6285
};

node_modules/.yarn-integrity

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@technote-space/filter-github-action/dist/context.js

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@technote-space/filter-github-action/dist/context.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

node_modules/@technote-space/filter-github-action/dist/index.js

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@technote-space/filter-github-action/dist/index.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

node_modules/@technote-space/filter-github-action/package.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@technote-space/github-action-helper/dist/utils.d.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@technote-space/github-action-helper/package.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)