remove typescript
This commit is contained in:
parent
71078c95a4
commit
d9b64b4f96
13 changed files with 57 additions and 89 deletions
|
@ -22,7 +22,7 @@ TODO example output
|
|||
From the same directory as this README:
|
||||
|
||||
```sh-session
|
||||
$ npm run setup
|
||||
$ npm install -g
|
||||
```
|
||||
|
||||
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 path = require('path')
|
||||
const project = path.join(__dirname, '..', 'tsconfig.json')
|
||||
|
||||
// In dev mode -> use ts-node and dev plugins
|
||||
process.env.NODE_ENV = 'development'
|
||||
|
||||
require('ts-node').register({project})
|
||||
|
||||
// In dev mode, always show stack traces
|
||||
oclif.settings.debug = true;
|
||||
|
||||
|
|
26
package.json
26
package.json
|
@ -12,7 +12,6 @@
|
|||
"repository": "https://git.adamu.jp/adam/kingoftime-cli",
|
||||
"files": [
|
||||
"/bin",
|
||||
"/dist",
|
||||
"/npm-shrinkwrap.json",
|
||||
"/oclif.manifest.json"
|
||||
],
|
||||
|
@ -23,37 +22,27 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@oclif/test": "^2.3.14",
|
||||
"@types/chai": "^4",
|
||||
"@types/mocha": "^9.0.0",
|
||||
"@types/node": "^16.18.23",
|
||||
"chai": "^4",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-oclif": "^4",
|
||||
"eslint-config-oclif-typescript": "^1.0.3",
|
||||
"mocha": "^9",
|
||||
"oclif": "^3.8.0",
|
||||
"shx": "^0.3.3",
|
||||
"ts-node": "^10.9.1",
|
||||
"tslib": "^2.5.0",
|
||||
"typescript": "^4.9.5"
|
||||
"oclif": "^3.8.0"
|
||||
},
|
||||
"oclif": {
|
||||
"bin": "kot",
|
||||
"dirname": "kot",
|
||||
"commands": "./dist/commands",
|
||||
"commands": "./src/commands",
|
||||
"plugins": [
|
||||
"@oclif/plugin-help"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"build": "shx rm -rf dist && tsc -b",
|
||||
"lint": "eslint . --ext .ts --config .eslintrc",
|
||||
"lint": "eslint . --ext .js --config .eslintrc",
|
||||
"postpack": "shx rm -f oclif.manifest.json",
|
||||
"posttest": "npm run lint",
|
||||
"prepack": "npm run build && oclif manifest && oclif readme",
|
||||
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
|
||||
"version": "oclif readme && git add README.md",
|
||||
"setup": "npm install && npm run build && npm link"
|
||||
"prepack": "oclif manifest && oclif readme",
|
||||
"test": "mocha --forbid-only \"test/**/*.test.js\"",
|
||||
"version": "oclif readme && git add README.md"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
|
@ -61,6 +50,5 @@
|
|||
"bugs": "https://git.adamu.jp/adam/kingoftime-cli/issues",
|
||||
"keywords": [
|
||||
"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,18 +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,18 +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,9 +1,9 @@
|
|||
import axios from 'axios'
|
||||
const axios = require('axios')
|
||||
|
||||
const CHECK_IN_ID = 'qmXXCxw9WEWN3X/YrkMWuQ=='
|
||||
const CHECK_OUT_ID = 'j8ekmJaw6W3M4w3i6hlSIQ=='
|
||||
|
||||
async function kingoftime(operationId: string, token: string, userToken: string) {
|
||||
async function kingoftime(operationId, token, userToken) {
|
||||
const response = await axios({
|
||||
method: 'post',
|
||||
// url: 'https://s2.kingtime.jp/gateway/bprgateway',
|
||||
|
@ -23,11 +23,12 @@ async function kingoftime(operationId: string, token: string, userToken: string)
|
|||
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)
|
||||
}
|
||||
|
||||
export async function checkout(token: string, userToken: string): Promise<void> {
|
||||
async function checkout(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 userTokenVar = 'KINGOFTIME_USER_TOKEN'
|
||||
|
||||
export const tokenFlags = {
|
||||
const tokenFlags = {
|
||||
token: Flags.string({
|
||||
env: tokenVar,
|
||||
description: `Defaults to the ${tokenVar} environment variable.`,
|
||||
|
@ -15,3 +15,5 @@ export const tokenFlags = {
|
|||
required: true,
|
||||
}),
|
||||
}
|
||||
|
||||
module.exports = {tokenFlags}
|
|
@ -1,5 +1,4 @@
|
|||
const path = require('path')
|
||||
process.env.TS_NODE_PROJECT = path.resolve('test/tsconfig.json')
|
||||
process.env.NODE_ENV = 'development'
|
||||
|
||||
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