Skip to content

Commit 388b46d

Browse files
authored
Merge pull request #54 from hackmdio/feature/sc-2229-v1-api-cli
v2 HackMD CLI
2 parents 5925251 + 0feb1e3 commit 388b46d

33 files changed

+16414
-2980
lines changed

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
SERVER_URL=
1+
HMD_API_ENDPOINT_URL=
2+
HMD_API_ACCESS_TOKEN=

.github/workflows/config-test.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "Config Test"
2+
3+
on: push
4+
5+
jobs:
6+
test:
7+
name: test config files
8+
runs-on: ubuntu-latest
9+
10+
strategy:
11+
matrix:
12+
node-version: ['12', '14', '16']
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v2
17+
- name: Use Node.js ${{ matrix.node-version }}
18+
uses: actions/setup-node@v2
19+
with:
20+
node-version: ${{ matrix.node-version }}
21+
- name: Install dependencies
22+
run: npm install
23+
- run: npm run test
24+

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Changelog
2+
3+
All notable changes to HackMD-CLI will be documented in this file.
4+
5+
## 2.0.0
6+
7+
### Added
8+
9+
- Rewrite old and add new commands supported by [v2 @hackmd/api](https://www.npmjs.com/package/@hackmd/api)
10+
- Github Action CI for config testing
11+
12+
### Changed
13+
14+
- Migrate [oclif](https://www.npmjs.com/package/oclif) to v2.5.0
15+
- Change to use hackmd api end point URL and and access token for authentication
16+
17+
### Removed
18+
19+
- Remove commands based on deprecated v1 @hackmd/api, including `import`, `export`
20+
- CodiMD has not been supported

README.md

Lines changed: 272 additions & 111 deletions
Large diffs are not rendered by default.

bin/dev

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env node
2+
3+
const oclif = require('@oclif/core')
4+
5+
const path = require('path')
6+
const project = path.join(__dirname, '..', 'tsconfig.json')
7+
8+
// In dev mode -> use ts-node and dev plugins
9+
process.env.NODE_ENV = 'development'
10+
11+
require('ts-node').register({project})
12+
13+
// In dev mode, always show stack traces
14+
oclif.settings.debug = true;
15+
16+
// Start the CLI
17+
oclif.run().then(oclif.flush).catch(oclif.Errors.handle)

bin/dev.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
3+
node "%~dp0\dev" %*

bin/run

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
11
#!/usr/bin/env node
22

3-
const fs = require('fs')
4-
const path = require('path')
5-
const project = path.join(__dirname, '../tsconfig.json')
6-
const dev = fs.existsSync(project)
3+
const oclif = require('@oclif/core')
74

8-
if (process.env.NODE_ENV === 'development') {
9-
require('dotenv').config()
10-
}
11-
12-
if (dev) {
13-
require('ts-node').register({project})
14-
}
15-
16-
require(`../${dev ? 'src' : 'lib'}`).run()
17-
.then(require('@oclif/command/flush'))
18-
.catch(require('@oclif/errors/handle'))
5+
oclif.run().then(require('@oclif/core/flush')).catch(require('@oclif/core/handle'))

bin/run.cmd

100644100755
File mode changed.

0 commit comments

Comments
 (0)