Skip to content

Commit

Permalink
Merge pull request #2 from yanamura/typescript
Browse files Browse the repository at this point in the history
Change to TypeScript
  • Loading branch information
yanamura authored Jun 13, 2020
2 parents bd5b196 + 1ff1499 commit a16e6c6
Show file tree
Hide file tree
Showing 12 changed files with 3,460 additions and 169 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
lib/
node_modules/
58 changes: 58 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"plugins": ["jest", "@typescript-eslint"],
"extends": ["plugin:github/es6"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 9,
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"eslint-comments/no-use": "off",
"import/no-namespace": "off",
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/explicit-member-accessibility": ["error", {"accessibility": "no-public"}],
"@typescript-eslint/no-require-imports": "error",
"@typescript-eslint/array-type": "error",
"@typescript-eslint/await-thenable": "error",
"@typescript-eslint/ban-ts-ignore": "error",
"camelcase": "off",
"@typescript-eslint/camelcase": "error",
"@typescript-eslint/class-name-casing": "error",
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
"@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/generic-type-naming": ["error", "^[A-Z][A-Za-z]*$"],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-extraneous-class": "error",
"@typescript-eslint/no-for-in-array": "error",
"@typescript-eslint/no-inferrable-types": "error",
"@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-namespace": "error",
"@typescript-eslint/no-non-null-assertion": "warn",
"@typescript-eslint/no-object-literal-type-assertion": "error",
"@typescript-eslint/no-unnecessary-qualifier": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-useless-constructor": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/prefer-for-of": "warn",
"@typescript-eslint/prefer-function-type": "warn",
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-interface": "error",
"@typescript-eslint/prefer-string-starts-ends-with": "error",
"@typescript-eslint/promise-function-async": "error",
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"semi": "off",
"@typescript-eslint/semi": ["error", "never"],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error"
},
"env": {
"node": true,
"es6": true,
"jest/globals": true
}
}
4 changes: 2 additions & 2 deletions .github/workflows/diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: Diff

on:
push:
branches: [ master ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- run: git fetch --prune --unshallow
- run: git fetch -p
- run: git tag --sort version:refname
- name: Diff
id: diff
uses: ./
Expand Down
31 changes: 13 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Dependency directory
node_modules

# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
logs
*.log
Expand Down Expand Up @@ -38,7 +42,6 @@ bower_components
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
Expand All @@ -53,12 +56,6 @@ typings/
# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

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

# Next.js build output
# next.js build output
.next

# Nuxt.js build / generate output
# nuxt.js build output
.nuxt
# dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist
Expand All @@ -100,5 +90,10 @@ typings/
# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
# OS metadata
.DS_Store
Thumbs.db

# Ignore built ts files
__tests__/runner/*
lib/**/*
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist/
lib/
node_modules/
11 changes: 11 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid",
"parser": "typescript"
}
173 changes: 100 additions & 73 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@ module.exports =
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ var threw = true;
/******/ try {
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete installedModules[moduleId];
/******/ }
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
Expand All @@ -34,7 +40,7 @@ module.exports =
/******/ // the startup function
/******/ function startup() {
/******/ // Load entry module and return exports
/******/ return __webpack_require__(104);
/******/ return __webpack_require__(198);
/******/ };
/******/
/******/ // run startup
Expand Down Expand Up @@ -954,87 +960,108 @@ module.exports = require("os");

/***/ }),

/***/ 104:
/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) {
/***/ 129:
/***/ (function(module) {

const core = __webpack_require__(470)
const exec = __webpack_require__(986)
module.exports = require("child_process");

function getTag(tags, name) {
if (name == "prev") {
if (tags.length < 2) {
core.setFailed("need more than 2 tags.")
return ""
}
/***/ }),

return tags[tags.length - 2]
} else if (name == "latest") {
return tags[tags.length - 1]
} else {
return name
}
}
/***/ 198:
/***/ (function(__unusedmodule, exports, __webpack_require__) {

async function run() {
const from = core.getInput("from")
const to = core.getInput("to")
"use strict";

let output = ''
const options = {};
options.listeners = {
stdout: (data) => {
output += data.toString();
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.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(__webpack_require__(470));
const exec = __importStar(__webpack_require__(986));
function getTag(tags, name) {
if (name === 'prev') {
if (tags.length < 2) {
core.setFailed('need more than 2 tags.');
return '';
}
return tags[tags.length - 2];
}

const tag_command = 'git tag --sort version:refname'
console.log(tag_command)
await exec.exec(tag_command, [], options).catch(error => {
core.setFailed(error.message)
})

const tags = output.split('\n').filter(Boolean)
console.log(tags)

output = ''

const from_tag = getTag(tags, from)
const to_tag = getTag(tags, to)

if (from_tag.length == 0 || to_tag.length == 0) {
core.setFailed("from or to is invalid")
return
else if (name === 'latest') {
return tags[tags.length - 1];
}
else {
return name;
}

const command = `git log ${from_tag}..${to_tag} --merges --reverse --pretty=format:"* %b"`
console.log(command)

await exec.exec(command, [], options).catch(error => {
core.setFailed(error.message)
})

console.log(output)

output = output.replace(/%/g, '%25')
output = output.replace(/\n/g, '%0A')
output = output.replace(/\r/g, '%0D')

console.log(output)

const setoutput_command = `echo "::set-output name=diff::${output}"`
exec.exec(setoutput_command).catch(error => {
core.setFailed(error.message)
})
}
function run() {
return __awaiter(this, void 0, void 0, function* () {
const from = core.getInput('from');
const to = core.getInput('to');
let output = '';
const options = {
listeners: {
stdout: (data) => {
output += data.toString();
}
}
};
const tagCommand = 'git tag --sort version:refname';
core.info(tagCommand);
yield exec.exec(tagCommand, [], options).catch(error => {
core.setFailed(error.message);
});
const tags = output.split('\n').filter(Boolean);
core.info(tags.toString());
output = '';
const fromTag = getTag(tags, from);
const toTag = getTag(tags, to);
if (fromTag.length === 0 || toTag.length === 0) {
core.setFailed('from or to is invalid');
return;
}
const command = `git log ${fromTag}..${toTag} --merges --reverse --pretty=format:"* %b"`;
core.info(command);
yield exec.exec(command, [], options).catch(error => {
core.setFailed(error.message);
});
core.info(output);
output = output.replace(/%/g, '%25');
output = output.replace(/\n/g, '%0A');
output = output.replace(/\r/g, '%0D');
core.info(output);
const setoutputCommand = `echo "::set-output name=diff::${output}"`;
exec.exec(setoutputCommand).catch(error => {
core.setFailed(error.message);
});
});
}
run();

run()

/***/ }),

/***/ 129:
/***/ (function(module) {

module.exports = require("child_process");

/***/ }),

Expand Down
Loading

0 comments on commit a16e6c6

Please sign in to comment.