Skip to content

Commit a16e6c6

Browse files
authored
Merge pull request #2 from yanamura/typescript
Change to TypeScript
2 parents bd5b196 + 1ff1499 commit a16e6c6

File tree

12 files changed

+3460
-169
lines changed

12 files changed

+3460
-169
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist/
2+
lib/
3+
node_modules/

.eslintrc.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"plugins": ["jest", "@typescript-eslint"],
3+
"extends": ["plugin:github/es6"],
4+
"parser": "@typescript-eslint/parser",
5+
"parserOptions": {
6+
"ecmaVersion": 9,
7+
"sourceType": "module",
8+
"project": "./tsconfig.json"
9+
},
10+
"rules": {
11+
"eslint-comments/no-use": "off",
12+
"import/no-namespace": "off",
13+
"no-unused-vars": "off",
14+
"@typescript-eslint/no-unused-vars": "error",
15+
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
16+
"@typescript-eslint/no-require-imports": "error",
17+
"@typescript-eslint/array-type": "error",
18+
"@typescript-eslint/await-thenable": "error",
19+
"@typescript-eslint/ban-ts-ignore": "error",
20+
"camelcase": "off",
21+
"@typescript-eslint/camelcase": "error",
22+
"@typescript-eslint/class-name-casing": "error",
23+
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
24+
"@typescript-eslint/func-call-spacing": ["error", "never"],
25+
"@typescript-eslint/generic-type-naming": ["error", "^[A-Z][A-Za-z]*$"],
26+
"@typescript-eslint/no-array-constructor": "error",
27+
"@typescript-eslint/no-empty-interface": "error",
28+
"@typescript-eslint/no-explicit-any": "error",
29+
"@typescript-eslint/no-extraneous-class": "error",
30+
"@typescript-eslint/no-for-in-array": "error",
31+
"@typescript-eslint/no-inferrable-types": "error",
32+
"@typescript-eslint/no-misused-new": "error",
33+
"@typescript-eslint/no-namespace": "error",
34+
"@typescript-eslint/no-non-null-assertion": "warn",
35+
"@typescript-eslint/no-object-literal-type-assertion": "error",
36+
"@typescript-eslint/no-unnecessary-qualifier": "error",
37+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
38+
"@typescript-eslint/no-useless-constructor": "error",
39+
"@typescript-eslint/no-var-requires": "error",
40+
"@typescript-eslint/prefer-for-of": "warn",
41+
"@typescript-eslint/prefer-function-type": "warn",
42+
"@typescript-eslint/prefer-includes": "error",
43+
"@typescript-eslint/prefer-interface": "error",
44+
"@typescript-eslint/prefer-string-starts-ends-with": "error",
45+
"@typescript-eslint/promise-function-async": "error",
46+
"@typescript-eslint/require-array-sort-compare": "error",
47+
"@typescript-eslint/restrict-plus-operands": "error",
48+
"semi": "off",
49+
"@typescript-eslint/semi": ["error", "never"],
50+
"@typescript-eslint/type-annotation-spacing": "error",
51+
"@typescript-eslint/unbound-method": "error"
52+
},
53+
"env": {
54+
"node": true,
55+
"es6": true,
56+
"jest/globals": true
57+
}
58+
}

.github/workflows/diff.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ name: Diff
22

33
on:
44
push:
5-
branches: [ master ]
65

76
jobs:
87
build:
98
runs-on: ubuntu-latest
109

1110
steps:
1211
- uses: actions/checkout@v2
13-
- run: git fetch --prune --unshallow
12+
- run: git fetch -p
13+
- run: git tag --sort version:refname
1414
- name: Diff
1515
id: diff
1616
uses: ./

.gitignore

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Dependency directory
2+
node_modules
3+
4+
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
15
# Logs
26
logs
37
*.log
@@ -38,7 +42,6 @@ bower_components
3842
build/Release
3943

4044
# Dependency directories
41-
node_modules/
4245
jspm_packages/
4346

4447
# TypeScript v1 declaration files
@@ -53,12 +56,6 @@ typings/
5356
# Optional eslint cache
5457
.eslintcache
5558

56-
# Microbundle cache
57-
.rpt2_cache/
58-
.rts2_cache_cjs/
59-
.rts2_cache_es/
60-
.rts2_cache_umd/
61-
6259
# Optional REPL history
6360
.node_repl_history
6461

@@ -75,18 +72,11 @@ typings/
7572
# parcel-bundler cache (https://parceljs.org/)
7673
.cache
7774

78-
# Next.js build output
75+
# next.js build output
7976
.next
8077

81-
# Nuxt.js build / generate output
78+
# nuxt.js build output
8279
.nuxt
83-
# dist
84-
85-
# Gatsby files
86-
.cache/
87-
# Comment in the public line in if your project uses Gatsby and *not* Next.js
88-
# https://nextjs.org/blog/next-9-1#public-directory-support
89-
# public
9080

9181
# vuepress build output
9282
.vuepress/dist
@@ -100,5 +90,10 @@ typings/
10090
# DynamoDB Local files
10191
.dynamodb/
10292

103-
# TernJS port file
104-
.tern-port
93+
# OS metadata
94+
.DS_Store
95+
Thumbs.db
96+
97+
# Ignore built ts files
98+
__tests__/runner/*
99+
lib/**/*

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dist/
2+
lib/
3+
node_modules/

.prettierrc.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"printWidth": 80,
3+
"tabWidth": 2,
4+
"useTabs": false,
5+
"semi": false,
6+
"singleQuote": true,
7+
"trailingComma": "none",
8+
"bracketSpacing": false,
9+
"arrowParens": "avoid",
10+
"parser": "typescript"
11+
}

dist/index.js

Lines changed: 100 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ module.exports =
1919
/******/ };
2020
/******/
2121
/******/ // Execute the module function
22-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22+
/******/ var threw = true;
23+
/******/ try {
24+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
25+
/******/ threw = false;
26+
/******/ } finally {
27+
/******/ if(threw) delete installedModules[moduleId];
28+
/******/ }
2329
/******/
2430
/******/ // Flag the module as loaded
2531
/******/ module.l = true;
@@ -34,7 +40,7 @@ module.exports =
3440
/******/ // the startup function
3541
/******/ function startup() {
3642
/******/ // Load entry module and return exports
37-
/******/ return __webpack_require__(104);
43+
/******/ return __webpack_require__(198);
3844
/******/ };
3945
/******/
4046
/******/ // run startup
@@ -954,87 +960,108 @@ module.exports = require("os");
954960

955961
/***/ }),
956962

957-
/***/ 104:
958-
/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) {
963+
/***/ 129:
964+
/***/ (function(module) {
959965

960-
const core = __webpack_require__(470)
961-
const exec = __webpack_require__(986)
966+
module.exports = require("child_process");
962967

963-
function getTag(tags, name) {
964-
if (name == "prev") {
965-
if (tags.length < 2) {
966-
core.setFailed("need more than 2 tags.")
967-
return ""
968-
}
968+
/***/ }),
969969

970-
return tags[tags.length - 2]
971-
} else if (name == "latest") {
972-
return tags[tags.length - 1]
973-
} else {
974-
return name
975-
}
976-
}
970+
/***/ 198:
971+
/***/ (function(__unusedmodule, exports, __webpack_require__) {
977972

978-
async function run() {
979-
const from = core.getInput("from")
980-
const to = core.getInput("to")
973+
"use strict";
981974

982-
let output = ''
983-
const options = {};
984-
options.listeners = {
985-
stdout: (data) => {
986-
output += data.toString();
975+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
976+
if (k2 === undefined) k2 = k;
977+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
978+
}) : (function(o, m, k, k2) {
979+
if (k2 === undefined) k2 = k;
980+
o[k2] = m[k];
981+
}));
982+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
983+
Object.defineProperty(o, "default", { enumerable: true, value: v });
984+
}) : function(o, v) {
985+
o["default"] = v;
986+
});
987+
var __importStar = (this && this.__importStar) || function (mod) {
988+
if (mod && mod.__esModule) return mod;
989+
var result = {};
990+
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
991+
__setModuleDefault(result, mod);
992+
return result;
993+
};
994+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
995+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
996+
return new (P || (P = Promise))(function (resolve, reject) {
997+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
998+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
999+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
1000+
step((generator = generator.apply(thisArg, _arguments || [])).next());
1001+
});
1002+
};
1003+
Object.defineProperty(exports, "__esModule", { value: true });
1004+
const core = __importStar(__webpack_require__(470));
1005+
const exec = __importStar(__webpack_require__(986));
1006+
function getTag(tags, name) {
1007+
if (name === 'prev') {
1008+
if (tags.length < 2) {
1009+
core.setFailed('need more than 2 tags.');
1010+
return '';
9871011
}
1012+
return tags[tags.length - 2];
9881013
}
989-
990-
const tag_command = 'git tag --sort version:refname'
991-
console.log(tag_command)
992-
await exec.exec(tag_command, [], options).catch(error => {
993-
core.setFailed(error.message)
994-
})
995-
996-
const tags = output.split('\n').filter(Boolean)
997-
console.log(tags)
998-
999-
output = ''
1000-
1001-
const from_tag = getTag(tags, from)
1002-
const to_tag = getTag(tags, to)
1003-
1004-
if (from_tag.length == 0 || to_tag.length == 0) {
1005-
core.setFailed("from or to is invalid")
1006-
return
1014+
else if (name === 'latest') {
1015+
return tags[tags.length - 1];
1016+
}
1017+
else {
1018+
return name;
10071019
}
1008-
1009-
const command = `git log ${from_tag}..${to_tag} --merges --reverse --pretty=format:"* %b"`
1010-
console.log(command)
1011-
1012-
await exec.exec(command, [], options).catch(error => {
1013-
core.setFailed(error.message)
1014-
})
1015-
1016-
console.log(output)
1017-
1018-
output = output.replace(/%/g, '%25')
1019-
output = output.replace(/\n/g, '%0A')
1020-
output = output.replace(/\r/g, '%0D')
1021-
1022-
console.log(output)
1023-
1024-
const setoutput_command = `echo "::set-output name=diff::${output}"`
1025-
exec.exec(setoutput_command).catch(error => {
1026-
core.setFailed(error.message)
1027-
})
10281020
}
1021+
function run() {
1022+
return __awaiter(this, void 0, void 0, function* () {
1023+
const from = core.getInput('from');
1024+
const to = core.getInput('to');
1025+
let output = '';
1026+
const options = {
1027+
listeners: {
1028+
stdout: (data) => {
1029+
output += data.toString();
1030+
}
1031+
}
1032+
};
1033+
const tagCommand = 'git tag --sort version:refname';
1034+
core.info(tagCommand);
1035+
yield exec.exec(tagCommand, [], options).catch(error => {
1036+
core.setFailed(error.message);
1037+
});
1038+
const tags = output.split('\n').filter(Boolean);
1039+
core.info(tags.toString());
1040+
output = '';
1041+
const fromTag = getTag(tags, from);
1042+
const toTag = getTag(tags, to);
1043+
if (fromTag.length === 0 || toTag.length === 0) {
1044+
core.setFailed('from or to is invalid');
1045+
return;
1046+
}
1047+
const command = `git log ${fromTag}..${toTag} --merges --reverse --pretty=format:"* %b"`;
1048+
core.info(command);
1049+
yield exec.exec(command, [], options).catch(error => {
1050+
core.setFailed(error.message);
1051+
});
1052+
core.info(output);
1053+
output = output.replace(/%/g, '%25');
1054+
output = output.replace(/\n/g, '%0A');
1055+
output = output.replace(/\r/g, '%0D');
1056+
core.info(output);
1057+
const setoutputCommand = `echo "::set-output name=diff::${output}"`;
1058+
exec.exec(setoutputCommand).catch(error => {
1059+
core.setFailed(error.message);
1060+
});
1061+
});
1062+
}
1063+
run();
10291064

1030-
run()
1031-
1032-
/***/ }),
1033-
1034-
/***/ 129:
1035-
/***/ (function(module) {
1036-
1037-
module.exports = require("child_process");
10381065

10391066
/***/ }),
10401067

0 commit comments

Comments
 (0)