Skip to content

Commit

Permalink
Typescript migration (#3)
Browse files Browse the repository at this point in the history
* typescript testing

* entry point changed

* parcel node

* ci: version bumped to v 0.1.4

* project migrated into typescript

* ci: version bumped to v 0.3.1

* project migrated into typescript

Co-authored-by: GitHub Version Bumper <[email protected]>
  • Loading branch information
kaangokdemir and GitHub Version Bumper authored Aug 12, 2020
1 parent b78dc8e commit 49de579
Show file tree
Hide file tree
Showing 11 changed files with 4,480 additions and 600 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
6 changes: 5 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ module.exports = {
es6: true,
node: true,
},
plugins: [
'@typescript-eslint',
],
extends: [
'standard',
],
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2018,
ecmaVersion: 2020,
},
rules: {
'no-unused-vars': 1,
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.nyc_output
.cache
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ RUN npm ci --only=production
COPY . .

# Run `node /index.js`
ENTRYPOINT ["node", "/index.js"]
ENTRYPOINT ["node", "/dist/index.js"]
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ after pushing or merging into your branch, major versioning would happen instead
## TODO

- Currently only supports `json` need to support `yaml` an `toml` files as well.
- Currently only patches the version. Minor and major versions could be updatable as well.
- Migrate to TypeScript.

## Contributors

Expand Down
5 changes: 5 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5,006 changes: 4,423 additions & 583 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
{
"name": "github-version-bumper",
"version": "0.1.3",
"version": "0.3.1",
"repository": {
"type": "git",
"url": "git+https://github.com/kaangokdemir/github-version-bumper.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"license": "MIT",
"bugs": {
"url": "https://github.com/kaangokdemir/github-version-bumper/issues"
},
"homepage": "https://github.com/kaangokdemir/github-version-bumper#readme",
"private": true,
"main": "index.js",
"main": "./dist/index.js",
"scripts": {
"start": "node ./index.js",
"start": "node ./dist/index.js",
"build": "parcel build ./src/index.ts --no-source-maps --target node",
"test": "jest"
},
"dependencies": {
Expand All @@ -24,6 +25,7 @@
"yargs": "^15.3.1"
},
"devDependencies": {
"@types/node": "^14.0.27",
"@typescript-eslint/eslint-plugin": "^3.9.0",
"@typescript-eslint/parser": "^3.9.0",
"eslint": "^7.6.0",
Expand All @@ -35,6 +37,8 @@
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"jest": "^25.2.7",
"standard": "^14.3.3"
"standard": "^14.3.3",
"typescript": "^3.9.7",
"parcel-bundler": "^1.12.4"
}
}
4 changes: 1 addition & 3 deletions helpers/bumper.js → src/helpers/bumper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const bump = require('json-bump')

const bumpVersion = async (fileName, options) => {
export const bumpVersion = async (fileName: string, options?: object) => {
await bump(fileName, options)
if (fileName === 'package.json') {
try {
Expand All @@ -10,5 +10,3 @@ const bumpVersion = async (fileName, options) => {
}
}
}

module.exports = bumpVersion
11 changes: 6 additions & 5 deletions index.js → src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { Toolkit } = require('actions-toolkit')
const bumpVersion = require('./helpers/bumper')
import { bumpVersion } from './helpers/bumper'
import { Toolkit } from 'actions-toolkit'

// Change working directory if user defined PACKAGEJSON_DIR
if (process.env.PACKAGEJSON_DIR) {
process.env.GITHUB_WORKSPACE = `${process.env.GITHUB_WORKSPACE}/${process.env.PACKAGEJSON_DIR}`
Expand Down Expand Up @@ -29,8 +30,8 @@ Toolkit.run(async (tools) => {
])

const currentBranch = /refs\/[a-zA-Z]+\/(.*)/.exec(
process.env.GITHUB_REF,
)[1]
process.env.GITHUB_REF as string,
)?.[1] as string

await tools.runInWorkspace('git', ['checkout', currentBranch])

Expand All @@ -40,6 +41,7 @@ Toolkit.run(async (tools) => {

console.log('lastcommitmessage', lastCommit)

// Bumping Starts
if (lastCommit.includes('[ci-bump major]')) {
console.log('major')
await bumpVersion(fileName, { major: true })
Expand All @@ -50,7 +52,6 @@ Toolkit.run(async (tools) => {
console.log('patch')
await bumpVersion(fileName)
}
// Bumping Starts

const newVersion = JSON.parse(tools.getFile(fileName)).version

Expand Down
27 changes: 27 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": "./src",
"paths": {
"@/*": ["src/*"]
},
"lib": ["esnext", "dom", "dom.iterable", "scripthost"]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": ["node_modules"]
}

0 comments on commit 49de579

Please sign in to comment.