-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a @mermaidchart/cli
CLI tool for accessing Mermaid Chart
#12
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
"//2": "TODO: decide on a license once this code is finished", | ||
"license": "UNLICENSED", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@knsv, what do you want the license for this package to be?
MIT is the license in the root of the repo, so we could use that: https://github.com/Mermaid-Chart/plugins/blob/main/LICENSE
7210e5b
to
08f9cf9
Compare
c56defb
to
849112d
Compare
```bash | ||
npx @mermaidchart/cli --help | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't test this until we've published this package to NPM, but it should work!
Add an initial @mermaidchart/cli package that can `link`/`pull`/`push` diagrams.
Move the implementation of `push`/`pull`/`link` into their own functions, so that we can reuse them to add the feature for sync Mermaid diagrams from within markdown files.
According to https://web.archive.org/web/20120905053951/http://download.microsoft.com/download/e/6/a/e6aa654f-cccb-421e-9b50-3392e9886084/VistaFileSysNamespaces.pdf, this environment variable it ALLCAPS and at least in Node.JS, it's case-sensitive.
Add a `pnpm run dev` command to make testing/development easier.
Recommend using [npx][] to automatically install, cache, and run @mermaidchart/cli, e.g. with `npx @mermaidchart/cli`, as npx comes with most Node.JS installations. This doesn't currently work since we haven't published this package to NPM, however. [npx]: https://docs.npmjs.com/cli/v10/commands/npx
c7b84c0
to
3211343
Compare
### `login` | ||
|
||
Firstly, go to https://www.mermaidchart.com/app/user/settings and generate an | ||
API key, which you can then setup by running: | ||
|
||
```bash | ||
npx @mermaidchart/cli login | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use OAuth before releasing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, since it's not a mandatory feature that's block the v0.1.0 release, I think it can wait for a future minor release (e.g. v0.1.1)!
But yep, we should definitely add it to make it easier for users to sign-in!
packages/cli/src/commander.ts
Outdated
|
||
export function createCommanderCommand() { | ||
const program = createCommand('mermaid-cli') | ||
.version('0.1.0-alpha.0') // TODO: how can we keep this synced with package.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we import it from the json file? That's how we do in mermaid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed by 480df29
I think in a previous version of this library, I had the file in src/index.ts
, but I compiled the output into ./index.js
. So require("../package.json");
would have had to have switched to require("./package.json");
. But now I'm using a dist/
folder, so the import path to package.json
is the same!
* If set, the user has said to use the projectId to create all documents | ||
* in. | ||
*/ | ||
selectedProjectId?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Consistency
selectedProjectId?: string; | |
selectedProjectID?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I'll look into fixing all of these before we make the first release, but after #22 is merged, to avoid causing merge conflicts.
Currently, this value is hard coded, which isn't great, since it means we need to update the value in two places each time we make a new release. This is a bit slower than the old version, but it shouldn't be too much slower, unless the user is still using a HDD.
📖 Description
Note
This PR is stacked on top of:
setDocument()
command #17Add a @mermaidchart/cli package that can
link
/pull
/push
diagrams, e.g.Configuration file
The configuration file is a TOML file that's stored in:
~/.config/mermaid-config.toml
~/Library/Application Support/mermaid-config.toml
%AppData%\mermaid-config.toml
Currently, the allowed fields are:
Todo
ESLint is currently broken, I think due to the version of TypeScript I'm using.@typescript-eslint/parser
v6.pull
orpush
a single diagram at a time. It would be better to support multiple diagrams at once (e.g. using a glob).pull
/push
/link
on multiple mermaid files at once #15@mermaidchart/sdk
.