WIP: Revamp the cli, sdk by just-be-dev · Pull Request #1 · linear/linear · GitHub
Skip to content

WIP: Revamp the cli, sdk - #1

Merged
jorilallo merged 25 commits into
linear:masterfrom
just-be-dev:sdk-cli
Sep 30, 2019
Merged

WIP: Revamp the cli, sdk#1
jorilallo merged 25 commits into
linear:masterfrom
just-be-dev:sdk-cli

Conversation

@just-be-dev

Copy link
Copy Markdown
Contributor

Note: The commit history for these changes got messed up due to an unfortunate rebase when trying to merge my changes into the new repo. Sorry about the lack of context there.

This is pretty highly work in progress.

Getting started

To play around with this, you'll want to put both packages in watch mode.

In one terminal

yarn workspace @linear/sdk dev

In another terminal

yarn workspace @linear/cli dev

Finally, from the root of the project run yarn cli to execute the cli.

SDK

The sdk exposes a thin graphql request wrapper for interacting with the api. It also exposes base primitives for interacting with things like issues, teams, etc. There's definitely more to be done here.

One concept I'm playing with is the idea of a selection. When you're querying for a project/team/issue/etc there are generally different field that could result in the object you're searching for. For example, an issue will commonly be searched for by a key. I'll expand on this idea later in the PR.

CLI

This is very bare bones at the moment and was just a mechanism to drive useful changes in the SDK. I'm happy with the base architecture of the CLI itself, but I'm not so sold on how the create command currently functions.

One of the things that makes Linear stand apart is its user experience. I think the CLI should truly be an extension of that. Guided text interfaces could make it trivial to do things like change issue states or assign labels. Granted, a non-interactive mode is important to provide for automation too. More to come.

Comment thread packages/sdk/README.md
Comment thread packages/sdk/src/gql.ts
Comment thread packages/sdk/src/linear.ts Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, this is a bit of a... simplistic mixin system. I spent a little while faffing about with the types and trying to get something more elegant, but this isn't exactly the part of the project I wanted to spent a lot of time on so this works for now.

@@ -0,0 +1,93 @@
import * as Types from '../schema';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these .generated.ts files are generated automatically by graphql-codegen.

@artman
artman requested review from artman and jorilallo and removed request for jorilallo September 16, 2019 23:22
`);

export const getIssue = async (client: Linear, selection: IssueSelection) => {
if ("id" in selection) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an example of a selection in practice. An issue can be selected by id or key. This infrastructure wouldn't be necessary if and issue was queryable by both of these fields.

Granted, GraphQL doesn't support input unions so there's no way in the schema to express that either id or key is required. So very unfortunate...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could expand the API to support queries where one passes the key ID (XXX-123) as id, and same for teams as well. Then creating issues via the API would be much more simple

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep!

@jorilallo
jorilallo self-requested a review September 18, 2019 00:14

@jorilallo jorilallo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. SDK approach makes sense, I think most use cases are simple and there's always the client as fallback. I think @artman might have more comments on the SDK side but for the CLI @oclif looks nice.

As you pointed out, issue creation is tricky. Happy to iterate on it once initial version is out but I would like to keep it light; it should be really fast to create an issue, just title and description and maybe fill the rest after the fact even. I would also like to bring back default team from the previous implementation so it's not required input. If the compose uses $EDITOR, then we could even have some fields in markdown that we could parse for metadata (estimates, labels etc). I have some ideas but excited to get something out to start building on :)

@artman artman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty great! Happy to land this as is (I can work through my comments after land), as I think this is a good basis to build upon.

Comment thread config/tslint.json Outdated
Comment thread config/tslint.json Outdated
Comment thread config/tslint.json Outdated
Comment thread packages/cli/.gitignore Outdated
@jorilallo

jorilallo commented Sep 23, 2019

Copy link
Copy Markdown
Contributor

Lets land after @artman's comment are addressed

@just-be-dev

Copy link
Copy Markdown
Contributor Author

I'll wrap this up on Saturday! 👍

@just-be-dev

Copy link
Copy Markdown
Contributor Author

@jorilallo
jorilallo merged commit ba0ba1c into linear:master Sep 30, 2019
@just-be-dev
just-be-dev deleted the sdk-cli branch November 7, 2019 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants