hackmdio / hackmd-cli Goto Github PK
View Code? Open in Web Editor NEWThe HackMD/CodiMD Command Line Tool
Home Page: https://github.com/hackmdio/hackmd-cli
License: MIT License
The HackMD/CodiMD Command Line Tool
Home Page: https://github.com/hackmdio/hackmd-cli
License: MIT License
If we try to update a note that is not ours, but that we are allowed to edit, the note is edited but the API answers with a 403 Forbidden
answer:
$ hackmd-cli export --noteId jmYbFyeLQOyS2mwonYqCYw
aa
$ hackmd-cli notes update --noteId jmYbFyeLQOyS2mwonYqCYw --content="bb"
Update note content failed
Error: Received an error response (403 Forbidden) from HackMD
Code: 403
$ hackmd-cli export --noteId jmYbFyeLQOyS2mwonYqCYw
bb
This problem is on the hackmd API side, but I don't know on which repo to open the issue...
First of all, thanks for maintaining this tool.
Sometimes, when using the notes update
command, the note is not fully updated. Here is a fairly small example/reproduction:
$ hackmd-cli notes create --content='
aa
```
aab
```
aab'
ID Title User path Team path
────────────────────── ──────── ───────── ─────────
59bbDYGPSESuaJuBh_fD4A Untitled gitmd
to create a note with some content. Now, update it with some other content:
$ hackmd-cli notes update --noteId 59bbDYGPSESuaJuBh_fD4A --content='
aa
```json
aabc
```
aabc'
However, the last modification (the last line) is not taken into account:
$ hackmd-cli export --noteId 59bbDYGPSESuaJuBh_fD4A
aa
```json
aabc
```
aab
If I do the hackmd-cli notes update
command again, the content of the note matches what is required.
However, I've seen some old content/new content pairs where hackmd-cli notes update
does nothing...
This seems to be a hackmd API bug (rather than the CLI), as I tried to directly write the HTTP requests, and it fails. But I could not find any github repository where we can file issues on the API itself. Feel free to redirect me if I'm not opening the issue in the right repo!
(while writing the HTTP requests by hand, I've also seen a case where writing a newline at the end of the JSON payload would change the outcome of the "update" API request... if that helps to track the bug)
$ tsc -b
src/commands/export.ts:44:38 - error TS2339: Property 'exportStream' does not exist on type 'API'.
44 const stream = await APIClient.exportStream(args.noteId, exportType)
~~~~~~~~~~~~
src/commands/export.ts:50:25 - error TS2339: Property 'exportStream' does not exist on type 'API'.
50 await APIClient.exportStream(args.noteId, exportType)
~~~~~~~~~~~~
Found 2 errors.
Hi, I am looking to integrate an auto-publishing pipeline with GitHub Actions. Our current documentation is written in HackMD-favoured markdown, is there a way to directly convert markdown to html file with a command like the following:
hackmd-cli export --import filename.md --html filename.html
Many thanks!
TypeError: Cannot destructure property 'pluginVersions' of '_c' as it is undefined.
A great feature would be to set the sharing permissions of a note from the CLI, for example publishing a note in view or edit mode. Everything under the sharing menu.
This would support the workflow of importing a note, publishing it and sharing the link without having to enter the web interface.
When I use hackmd-cli notes update --noteId="XYZ" --content="New content"
to set the contents of a note, the title of the note is removed. Trying to include the title of the note in the content, e.g.
hackmd-cli notes update --noteId="XYZ" --content="# My title\nNew content"
does not solve the issue: instead, the # My title
part is included in the content of the note and the title is still empty.
oclif.manifest.json
is under version control, but postpack
removes it. either the postpack
script is wrong, or oclif.manifest.json
should not be under version control
hackmd-cli login
The CLI should either ask the password again, or simply fail and say "cannot login with empty password".
And then when checked with whoami
:
$ hackmd-cli whoami
You are not logged in yet.
$ hackmd-cli version
@hackmd/hackmd-cli/1.1.0 linux-x64 node-v12.16.0
Please support removing notes of specified note ids.
I set CMD_CLI_SERVER_URL
in my shell env, then ran npx @hackmd/codimd-cli login
, but received the error:
ENOENT: no such file or directory, open '/Users/boneskull/.codimd/config.json'
It seems the env var is not getting picked up and/or the config file is expected to be required when it should not.
Something like hackmdio/vscode-hackmd#24
This is a really useful tool, thank you for developing it.
For our use cases, it would be very helpful to be able to specify the page slug for an imported note. This would need to include a check for whether the note already exists, to avoid overwriting the content of existing notes, but would be very helpful to increase the findability of old notes.
I've installed codimd-cli from npm using
npm install --global @hackmd/codimd-cli
then I've explicitly set serverUrl
in ~/.codimd/config.json
:
{
"serverUrl": "https://hackmd.io"
}
and then I tried to login to my HackMD account using
codimd-cli login
but I always get
Login failed, please ensure your email/password is set
The file ~/.codimd/cookies.json
is always created, regardless if I type in the correct password or not. The file's content looks like this (with [REDACTED]
secrets):
{"hackmd.io":{"/":{"_csrf":{"key":"_csrf","value":"[REDACTED]","domain":"hackmd.io","path":"/","hostOnly":true,"creation":"2020-07-01T14:35:42.800Z","lastAccessed":"2020-07-01T14:35:42.802Z"},"locale":{"key":"locale","value":"dev","expires":"2021-07-01T14:35:42.000Z","domain":"hackmd.io","path":"/","secure":true,"hostOnly":true,"creation":"2020-07-01T14:35:42.801Z","lastAccessed":"2020-07-01T14:35:42.801Z"},"connect.sid":{"key":"connect.sid","value":"s%[REDACTED]","expires":"2020-07-15T14:35:42.000Z","domain":"hackmd.io","path":"/","secure":true,"httpOnly":true,"hostOnly":true,"creation":"2020-07-01T14:35:42.802Z","lastAccessed":"2020-07-01T14:35:42.802Z"}}}}
I've tried it several times and made sure that I didn't make any typos (even changed my password to an ASCII-only one to be sure special characters aren't the problem), but no success. What am I missing?
I'm using Node.js 14 on Ubuntu 20.04. npm version
gives me
{
npm: '6.14.5',
ares: '1.16.0',
brotli: '1.0.7',
cldr: '37.0',
icu: '67.1',
llhttp: '2.0.4',
modules: '83',
napi: '6',
nghttp2: '1.41.0',
node: '14.4.0',
openssl: '1.1.1g',
tz: '2019c',
unicode: '13.0',
uv: '1.37.0',
v8: '8.1.307.31-node.33',
zlib: '1.2.11'
}
We don't need two libraries for the same purpose.
It would be really helpful if one could export all documents with a flag.
For example:
hackmd-cli export --all --md
This way, one can easily keep their documents on their device as a backup (in case any loss of data occurs)
It would be very useful to use the list command to return only notes that match a tag.
Use case: use hackmd-cli to export some notes and batch commit them to git. Not every note should be exported, but because list
returns all notes, need to download them all and then process them based on tag in YAML metadata. Listing by tag would reduce the number of exports speeding up the process.
The mixed-use of oclif multi command/single command causes flag parsing weird sometimes.
Lines 20 to 30 in 1f8f30f
I want to move the pipe import command under import.ts
command.
When I export this HackMD document using
hackmd-cli export --md 0HvXpVyxQku6LRXpT8Zz9Q > test.md
the resulting test.md
file is "randomly" truncated.
Sometimes I get all lines, sometimes only n lines, sometimes even a broken file (I guess because the data stream returned is cut off in between valid UTF-8 character codes).
I only experienced this with one document so far and can't tell what exactly causes the issue. I tried to iteratively strip the file down to find out what lines exactly are triggering the issue, but I've capitulated after a short while. Due to the (perceived) "randomness" of the results, I suspect the problem is not the CLI itself but what it receives from the HackMD server (though I might be completely wrong about this of course).
To make it as easy as possible for you to reproduce the issue, I created a simple bash script:
#!/bin/bash
# create an empty array to store the results
unset n_lines
declare -a n_lines
# export the document 20 times and each time print the number of lines
for i in {1..20} ; do
n_lines+=(`hackmd-cli export --md 0HvXpVyxQku6LRXpT8Zz9Q | wc -l`)
echo "In export number `printf "%02d" $i` the document had ${n_lines[-1]} lines."
done
# finally print a summary of these 20 exports (two columns)
printf "Summary:\n\n times n_lines\n`echo "${n_lines[@]}" | tr ' ' '\n' | sort | uniq -c`\n"
The correct number of lines the script should report is 666 (the last newline char is not counted as a separate line by wc -l
).
When I run the script on my system, I get results like:
In export number 01 the document had 666 lines.
In export number 02 the document had 575 lines.
In export number 03 the document had 485 lines.
In export number 04 the document had 666 lines.
In export number 05 the document had 666 lines.
In export number 06 the document had 666 lines.
In export number 07 the document had 666 lines.
In export number 08 the document had 666 lines.
In export number 09 the document had 666 lines.
In export number 10 the document had 666 lines.
In export number 11 the document had 655 lines.
In export number 12 the document had 575 lines.
In export number 13 the document had 655 lines.
In export number 14 the document had 666 lines.
In export number 15 the document had 666 lines.
In export number 16 the document had 575 lines.
In export number 17 the document had 485 lines.
In export number 18 the document had 666 lines.
In export number 19 the document had 575 lines.
In export number 20 the document had 575 lines.
Summary:
times n_lines
2 485
5 575
2 655
11 666
Ubuntu 20.04
@hackmd/hackmd-cli/1.1.1 linux-x64 node-v14.4.0
hackmd-cli/src/commands/history.ts
Lines 27 to 33 in 16aad49
Currently it only returns ID and Name
We can return more fields like tags/updated time/created time
This feature is highly desirable. Is it being worked upon?
There is no easy way to change note's permission in mass. While I can mass import Markdown note with this CLI, I cannot seem to control the permission of those notes with CLI. And it is a painstakingly long process to do it one-by-one on the web GUI.
It would be great if there is a command like this:
hackmd-cli chmod [NOTEID] [[-r|--readable] [owner|login|everyone]] [[-w|--writable] [owner|login|everyone]]
Example,
$ hackmd-cli chmod some-note-id -r everyone -w login
Permission of your note https://hackmd.io/some-note-id has changed.
Readable: everyone
Writable: login
First of all: Thanks a million for your awesome work!
Now I've noticed that there are two different npm packages in the npm repository:
The first one clearly seems to be maintained by HackMD team members. The second one is authored by Dylan Bourdere Andreou. I can't tell how this person is related to the HackMD/CodiMD project and if he's trustworthy. Since there have been various cases of hijacked/faked npm packages in the past and npm has quite a questionable security track record, I thought it would be best to ask you guys.
Can you shed some light into this? Do you know why there are two npm packages for the same codimd-cli tool? And if so, do you know what's the difference between the two packages?
I've tried to quickly inspect the differences in the tarballs of the two packages (1, 2) using tardiff, but as it seems, tardiff's --modified
flag doesn't really work as supposed...
It would be awesome if you could type hackmd-cli notes:create --edit
to edit the note directly from vim (or $EDITOR).
Print config path (note: without credentials)
I believe this should be first implemented by the client APIs.
I've installed codimd-cli from npm using
npm install --global @hackmd/codimd-cli
and then tried to display the help using
codimd-cli help
which resulted in the following error:
/home/salim/.by_pkg_mngr/npm/lib/node_modules/@hackmd/codimd-cli/lib/config.js:32
throw new Error(`
^
Error:
Please specify CodiMD server url either in /home/salim/.codimd/config.json or by environment varaible.
You can learn how to config codimd-cli on https://github.com/hackmdio/codimd-cli
at Object.<anonymous> (/home/salim/.by_pkg_mngr/npm/lib/node_modules/@hackmd/codimd-cli/lib/config.js:32:11)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at require (internal/modules/cjs/helpers.js:73:18)
at Object.<anonymous> (/home/salim/.by_pkg_mngr/npm/lib/node_modules/@hackmd/codimd-cli/lib/api.js:9:42)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
The README states:
hackmd-cli
operates on official HackMD instance (hackmd.io
) by default.
But this is obviously not the case for the npm package. Explicitly setting the serverUrl
key (to anything) in ~/.codimd/config.json
eliminates the error message.
(Besides, there's a typo in the error message above: varaible
)
I'm using Node.js 14 on Ubuntu 20.04. npm version
gives me
{
npm: '6.14.5',
ares: '1.16.0',
brotli: '1.0.7',
cldr: '37.0',
icu: '67.1',
llhttp: '2.0.4',
modules: '83',
napi: '6',
nghttp2: '1.41.0',
node: '14.4.0',
openssl: '1.1.1g',
tz: '2019c',
unicode: '13.0',
uv: '1.37.0',
v8: '8.1.307.31-node.33',
zlib: '1.2.11'
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.