Compare commits
3 commits
7e0b4c7b73
...
6ba7fb1555
Author | SHA1 | Date | |
---|---|---|---|
6ba7fb1555 | |||
c836387169 | |||
d9b64b4f96 |
15 changed files with 66 additions and 92 deletions
2
.dockerignore
Normal file
2
.dockerignore
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
.git/
|
||||||
|
node_modules/
|
6
Dockerfile
Normal file
6
Dockerfile
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
FROM node:20
|
||||||
|
WORKDIR /root/kot
|
||||||
|
ADD . .
|
||||||
|
RUN npm install
|
||||||
|
RUN npm install -g
|
||||||
|
ENTRYPOINT ["kot"]
|
|
@ -26,7 +26,7 @@ $ kot checkout
|
||||||
From the same directory as this README:
|
From the same directory as this README:
|
||||||
|
|
||||||
```sh-session
|
```sh-session
|
||||||
$ npm run setup
|
$ npm install -g
|
||||||
```
|
```
|
||||||
|
|
||||||
Now the `kot` command should be available on your system.
|
Now the `kot` command should be available on your system.
|
||||||
|
|
3
bin/dev
3
bin/dev
|
@ -3,13 +3,10 @@
|
||||||
const oclif = require('@oclif/core')
|
const oclif = require('@oclif/core')
|
||||||
|
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const project = path.join(__dirname, '..', 'tsconfig.json')
|
|
||||||
|
|
||||||
// In dev mode -> use ts-node and dev plugins
|
// In dev mode -> use ts-node and dev plugins
|
||||||
process.env.NODE_ENV = 'development'
|
process.env.NODE_ENV = 'development'
|
||||||
|
|
||||||
require('ts-node').register({project})
|
|
||||||
|
|
||||||
// In dev mode, always show stack traces
|
// In dev mode, always show stack traces
|
||||||
oclif.settings.debug = true;
|
oclif.settings.debug = true;
|
||||||
|
|
||||||
|
|
26
package.json
26
package.json
|
@ -12,7 +12,6 @@
|
||||||
"repository": "https://git.adamu.jp/adam/kingoftime-cli",
|
"repository": "https://git.adamu.jp/adam/kingoftime-cli",
|
||||||
"files": [
|
"files": [
|
||||||
"/bin",
|
"/bin",
|
||||||
"/dist",
|
|
||||||
"/npm-shrinkwrap.json",
|
"/npm-shrinkwrap.json",
|
||||||
"/oclif.manifest.json"
|
"/oclif.manifest.json"
|
||||||
],
|
],
|
||||||
|
@ -23,37 +22,27 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@oclif/test": "^2.3.14",
|
"@oclif/test": "^2.3.14",
|
||||||
"@types/chai": "^4",
|
|
||||||
"@types/mocha": "^9.0.0",
|
|
||||||
"@types/node": "^16.18.23",
|
|
||||||
"chai": "^4",
|
"chai": "^4",
|
||||||
"eslint": "^7.32.0",
|
"eslint": "^7.32.0",
|
||||||
"eslint-config-oclif": "^4",
|
"eslint-config-oclif": "^4",
|
||||||
"eslint-config-oclif-typescript": "^1.0.3",
|
|
||||||
"mocha": "^9",
|
"mocha": "^9",
|
||||||
"oclif": "^3.8.0",
|
"oclif": "^3.8.0"
|
||||||
"shx": "^0.3.3",
|
|
||||||
"ts-node": "^10.9.1",
|
|
||||||
"tslib": "^2.5.0",
|
|
||||||
"typescript": "^4.9.5"
|
|
||||||
},
|
},
|
||||||
"oclif": {
|
"oclif": {
|
||||||
"bin": "kot",
|
"bin": "kot",
|
||||||
"dirname": "kot",
|
"dirname": "kot",
|
||||||
"commands": "./dist/commands",
|
"commands": "./src/commands",
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"@oclif/plugin-help"
|
"@oclif/plugin-help"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "shx rm -rf dist && tsc -b",
|
"lint": "eslint . --ext .js --config .eslintrc",
|
||||||
"lint": "eslint . --ext .ts --config .eslintrc",
|
|
||||||
"postpack": "shx rm -f oclif.manifest.json",
|
"postpack": "shx rm -f oclif.manifest.json",
|
||||||
"posttest": "npm run lint",
|
"posttest": "npm run lint",
|
||||||
"prepack": "npm run build && oclif manifest && oclif readme",
|
"prepack": "oclif manifest && oclif readme",
|
||||||
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
|
"test": "mocha --forbid-only \"test/**/*.test.js\"",
|
||||||
"version": "oclif readme && git add README.md",
|
"version": "oclif readme && git add README.md"
|
||||||
"setup": "npm install && npm run build && npm link"
|
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12.0.0"
|
"node": ">=12.0.0"
|
||||||
|
@ -61,6 +50,5 @@
|
||||||
"bugs": "https://git.adamu.jp/adam/kingoftime-cli/issues",
|
"bugs": "https://git.adamu.jp/adam/kingoftime-cli/issues",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"oclif"
|
"oclif"
|
||||||
],
|
]
|
||||||
"types": "dist/index.d.ts"
|
|
||||||
}
|
}
|
||||||
|
|
20
src/commands/checkin.js
Normal file
20
src/commands/checkin.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
const {Command} = require('@oclif/core')
|
||||||
|
const {tokenFlags} = require('../tokenFlags')
|
||||||
|
const {checkin} = require('../kingoftime')
|
||||||
|
|
||||||
|
class CheckinCommand extends Command {
|
||||||
|
static description = 'Check in'
|
||||||
|
|
||||||
|
static examples = [
|
||||||
|
'<%= config.bin %> <%= command.id %>',
|
||||||
|
]
|
||||||
|
|
||||||
|
static flags = tokenFlags
|
||||||
|
|
||||||
|
async run() {
|
||||||
|
const {flags} = await this.parse(CheckinCommand)
|
||||||
|
await checkin(flags.token, flags['user-token'])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = CheckinCommand
|
|
@ -1,16 +0,0 @@
|
||||||
import {Command} from '@oclif/core'
|
|
||||||
import {tokenFlags} from '../token-flags'
|
|
||||||
import {checkin} from '../kingoftime'
|
|
||||||
|
|
||||||
export default class Checkout extends Command {
|
|
||||||
static description = 'Check in';
|
|
||||||
|
|
||||||
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
||||||
|
|
||||||
static flags = tokenFlags;
|
|
||||||
|
|
||||||
public async run(): Promise<void> {
|
|
||||||
const {flags} = await this.parse(Checkout)
|
|
||||||
await checkin(flags.token, flags['user-token'])
|
|
||||||
}
|
|
||||||
}
|
|
20
src/commands/checkout.js
Normal file
20
src/commands/checkout.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
const {Command} = require('@oclif/core')
|
||||||
|
const {tokenFlags} = require('../tokenFlags')
|
||||||
|
const {checkout} = require('../kingoftime')
|
||||||
|
|
||||||
|
class CheckoutCommand extends Command {
|
||||||
|
static description = 'Check out'
|
||||||
|
|
||||||
|
static examples = [
|
||||||
|
'<%= config.bin %> <%= command.id %>',
|
||||||
|
]
|
||||||
|
|
||||||
|
static flags = tokenFlags
|
||||||
|
|
||||||
|
async run() {
|
||||||
|
const {flags} = await this.parse(CheckoutCommand)
|
||||||
|
await checkout(flags.token, flags['user-token'])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = CheckoutCommand
|
|
@ -1,16 +0,0 @@
|
||||||
import {Command} from '@oclif/core'
|
|
||||||
import {tokenFlags} from '../token-flags'
|
|
||||||
import {checkout} from '../kingoftime'
|
|
||||||
|
|
||||||
export default class Checkout extends Command {
|
|
||||||
static description = 'Check out';
|
|
||||||
|
|
||||||
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
||||||
|
|
||||||
static flags = tokenFlags;
|
|
||||||
|
|
||||||
public async run(): Promise<void> {
|
|
||||||
const {flags} = await this.parse(Checkout)
|
|
||||||
await checkout(flags.token, flags['user-token'])
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,13 +1,9 @@
|
||||||
import axios from 'axios'
|
const axios = require('axios')
|
||||||
|
|
||||||
const CHECK_IN_ID = 'qmXXCxw9WEWN3X/YrkMWuQ=='
|
const CHECK_IN_ID = 'qmXXCxw9WEWN3X/YrkMWuQ=='
|
||||||
const CHECK_OUT_ID = 'j8ekmJaw6W3M4w3i6hlSIQ=='
|
const CHECK_OUT_ID = 'j8ekmJaw6W3M4w3i6hlSIQ=='
|
||||||
|
|
||||||
async function kingoftime(
|
async function kingoftime(operationId, token, userToken) {
|
||||||
operationId: string,
|
|
||||||
token: string,
|
|
||||||
userToken: string,
|
|
||||||
) {
|
|
||||||
const response = await axios({
|
const response = await axios({
|
||||||
method: 'post',
|
method: 'post',
|
||||||
url: 'https://s2.ta.kingoftime.jp/gateway/bprgateway',
|
url: 'https://s2.ta.kingoftime.jp/gateway/bprgateway',
|
||||||
|
@ -26,13 +22,12 @@ async function kingoftime(
|
||||||
console.log(response.data)
|
console.log(response.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function checkin(token: string, userToken: string): Promise<void> {
|
async function checkin(token, userToken) {
|
||||||
await kingoftime(CHECK_IN_ID, token, userToken)
|
await kingoftime(CHECK_IN_ID, token, userToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function checkout(
|
async function checkout(token, userToken) {
|
||||||
token: string,
|
|
||||||
userToken: string,
|
|
||||||
): Promise<void> {
|
|
||||||
await kingoftime(CHECK_OUT_ID, token, userToken)
|
await kingoftime(CHECK_OUT_ID, token, userToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports = {checkin, checkout}
|
|
@ -1,9 +1,9 @@
|
||||||
import {Flags} from '@oclif/core'
|
const {Flags} = require('@oclif/core')
|
||||||
|
|
||||||
const tokenVar = 'KINGOFTIME_TOKEN'
|
const tokenVar = 'KINGOFTIME_TOKEN'
|
||||||
const userTokenVar = 'KINGOFTIME_USER_TOKEN'
|
const userTokenVar = 'KINGOFTIME_USER_TOKEN'
|
||||||
|
|
||||||
export const tokenFlags = {
|
const tokenFlags = {
|
||||||
token: Flags.string({
|
token: Flags.string({
|
||||||
env: tokenVar,
|
env: tokenVar,
|
||||||
description: `Defaults to the ${tokenVar} environment variable.`,
|
description: `Defaults to the ${tokenVar} environment variable.`,
|
||||||
|
@ -15,3 +15,5 @@ export const tokenFlags = {
|
||||||
required: true,
|
required: true,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports = {tokenFlags}
|
|
@ -1,5 +1,4 @@
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
process.env.TS_NODE_PROJECT = path.resolve('test/tsconfig.json')
|
|
||||||
process.env.NODE_ENV = 'development'
|
process.env.NODE_ENV = 'development'
|
||||||
|
|
||||||
global.oclif = global.oclif || {}
|
global.oclif = global.oclif || {}
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
{
|
|
||||||
"extends": "../tsconfig",
|
|
||||||
"compilerOptions": {
|
|
||||||
"noEmit": true
|
|
||||||
},
|
|
||||||
"references": [
|
|
||||||
{"path": ".."}
|
|
||||||
]
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"declaration": true,
|
|
||||||
"importHelpers": true,
|
|
||||||
"module": "commonjs",
|
|
||||||
"outDir": "dist",
|
|
||||||
"rootDir": "src",
|
|
||||||
"strict": true,
|
|
||||||
"target": "es2019"
|
|
||||||
},
|
|
||||||
"include": [
|
|
||||||
"src/**/*"
|
|
||||||
]
|
|
||||||
}
|
|
Loading…
Reference in a new issue