diff --git a/README.md b/README.md index 3fca578..b2cb84f 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/bin/dev b/bin/dev index bbc3f51..8911760 100755 --- a/bin/dev +++ b/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; diff --git a/package.json b/package.json index a3ff3a2..4705104 100644 --- a/package.json +++ b/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" + ] } diff --git a/src/commands/checkin.js b/src/commands/checkin.js new file mode 100644 index 0000000..5045cc5 --- /dev/null +++ b/src/commands/checkin.js @@ -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 diff --git a/src/commands/checkin.ts b/src/commands/checkin.ts deleted file mode 100644 index ea0ea57..0000000 --- a/src/commands/checkin.ts +++ /dev/null @@ -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 { - const {flags} = await this.parse(Checkout) - await checkin(flags.token, flags['user-token']) - } -} diff --git a/src/commands/checkout.js b/src/commands/checkout.js new file mode 100644 index 0000000..5146eee --- /dev/null +++ b/src/commands/checkout.js @@ -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 diff --git a/src/commands/checkout.ts b/src/commands/checkout.ts deleted file mode 100644 index c376037..0000000 --- a/src/commands/checkout.ts +++ /dev/null @@ -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 { - const {flags} = await this.parse(Checkout) - await checkout(flags.token, flags['user-token']) - } -} diff --git a/src/index.ts b/src/index.js similarity index 100% rename from src/index.ts rename to src/index.js diff --git a/src/kingoftime.ts b/src/kingoftime.js similarity index 73% rename from src/kingoftime.ts rename to src/kingoftime.js index 501aa83..d9454bd 100644 --- a/src/kingoftime.ts +++ b/src/kingoftime.js @@ -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 { +async function checkin(token, userToken) { await kingoftime(CHECK_IN_ID, token, userToken) } -export async function checkout(token: string, userToken: string): Promise { +async function checkout(token, userToken) { await kingoftime(CHECK_OUT_ID, token, userToken) } +module.exports = {checkin, checkout} diff --git a/src/token-flags.ts b/src/tokenFlags.js similarity index 80% rename from src/token-flags.ts rename to src/tokenFlags.js index 0a784c9..f0109f9 100644 --- a/src/token-flags.ts +++ b/src/tokenFlags.js @@ -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} diff --git a/test/helpers/init.js b/test/helpers/init.js index 338e715..55ca635 100644 --- a/test/helpers/init.js +++ b/test/helpers/init.js @@ -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 || {} diff --git a/test/tsconfig.json b/test/tsconfig.json deleted file mode 100644 index 95898fc..0000000 --- a/test/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../tsconfig", - "compilerOptions": { - "noEmit": true - }, - "references": [ - {"path": ".."} - ] -} diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index 34727db..0000000 --- a/tsconfig.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "compilerOptions": { - "declaration": true, - "importHelpers": true, - "module": "commonjs", - "outDir": "dist", - "rootDir": "src", - "strict": true, - "target": "es2019" - }, - "include": [ - "src/**/*" - ] -}