Series of articles:

  • Step one, create the first command
  • Step 2: Set up the development environment
  • Step 3: Get information about github projects
  • The fourth step is to obtain project information through lifting code
  • [Hand in hand to take you to lift a scaffolding] step five, finish the job

Scaffolding, as a tool, is mainly used to transport the project templates we have already prepared (Webpack configuration, KOA prototype, etc.). In this step we will create the project templates for transport. Obtain related information from github Api document through the interface

Ps: This step is based on Github

Create a project team dedicated to maintaining project templates

In order not to write their usual variety of spicy chicken code mixed together, here I specifically created an organization will not create brothers please Baidu

  • Change the directory to the organization you just created

  • Create a project

  • Add a file to the project you created, upload it to Github and tag it

Preparations are complete

Get project information through the Github open API

baseUrl: api.github.com

As a scaffold, we need to obtain the following project information:

= = = = = = = = = = = = = = = = = = = = = = = = = = = added = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =

Ps The Github open API has a limit on the number of requests (60 unauthorized requests per hour), so there may be a problem as shown in the following figure. The solution is to add an authToken to the requestThe next articleThe temporary solution in this section is to add your own Github account password when running commands.

Gets the list of projects that the organization belongs toThe document

We can try to get the project directory under the organization we just created

curl https://api.github.com/orgs/learn-cli-organization/repos

// Do not delete the colon between "your Github account: your Github password"
curl -u "Your Github account: Your Github password" https://api.github.com/orgs/learn-cli-organization/repos

// The result returned[{"id": 157579674."node_id": "MDEwOlJlcG9zaXRvcnkxNTc1Nzk2NzQ="."name": "demo"."full_name": "learn-cli-organization/demo"."private": false."owner": {
      "login": "learn-cli-organization"."id": 45043923."node_id": "MDEyOk9yZ2FuaXphdGlvbjQ1MDQzOTIz"."avatar_url": "https://avatars2.githubusercontent.com/u/45043923?v=4"."gravatar_id": ""."url": "https://api.github.com/users/learn-cli-organization"."html_url": "https://github.com/learn-cli-organization"."followers_url": "https://api.github.com/users/learn-cli-organization/followers"."following_url": "https://api.github.com/users/learn-cli-organization/following{/other_user}"."gists_url": "https://api.github.com/users/learn-cli-organization/gists{/gist_id}"."starred_url": "https://api.github.com/users/learn-cli-organization/starred{/owner}{/repo}"."subscriptions_url": "https://api.github.com/users/learn-cli-organization/subscriptions"."organizations_url": "https://api.github.com/users/learn-cli-organization/orgs"."repos_url": "https://api.github.com/users/learn-cli-organization/repos"."events_url": "https://api.github.com/users/learn-cli-organization/events{/privacy}"."received_events_url": "https://api.github.com/users/learn-cli-organization/received_events"."type": "Organization"."site_admin": false
    },
    "html_url": "https://github.com/learn-cli-organization/demo"."description": null."fork": false."url": "https://api.github.com/repos/learn-cli-organization/demo"."forks_url": "https://api.github.com/repos/learn-cli-organization/demo/forks"."keys_url": "https://api.github.com/repos/learn-cli-organization/demo/keys{/key_id}"."collaborators_url": "https://api.github.com/repos/learn-cli-organization/demo/collaborators{/collaborator}"."teams_url": "https://api.github.com/repos/learn-cli-organization/demo/teams"."hooks_url": "https://api.github.com/repos/learn-cli-organization/demo/hooks"."issue_events_url": "https://api.github.com/repos/learn-cli-organization/demo/issues/events{/number}"."events_url": "https://api.github.com/repos/learn-cli-organization/demo/events"."assignees_url": "https://api.github.com/repos/learn-cli-organization/demo/assignees{/user}"."branches_url": "https://api.github.com/repos/learn-cli-organization/demo/branches{/branch}"."tags_url": "https://api.github.com/repos/learn-cli-organization/demo/tags"."blobs_url": "https://api.github.com/repos/learn-cli-organization/demo/git/blobs{/sha}"."git_tags_url": "https://api.github.com/repos/learn-cli-organization/demo/git/tags{/sha}"."git_refs_url": "https://api.github.com/repos/learn-cli-organization/demo/git/refs{/sha}"."trees_url": "https://api.github.com/repos/learn-cli-organization/demo/git/trees{/sha}"."statuses_url": "https://api.github.com/repos/learn-cli-organization/demo/statuses/{sha}"."languages_url": "https://api.github.com/repos/learn-cli-organization/demo/languages"."stargazers_url": "https://api.github.com/repos/learn-cli-organization/demo/stargazers"."contributors_url": "https://api.github.com/repos/learn-cli-organization/demo/contributors"."subscribers_url": "https://api.github.com/repos/learn-cli-organization/demo/subscribers"."subscription_url": "https://api.github.com/repos/learn-cli-organization/demo/subscription"."commits_url": "https://api.github.com/repos/learn-cli-organization/demo/commits{/sha}"."git_commits_url": "https://api.github.com/repos/learn-cli-organization/demo/git/commits{/sha}"."comments_url": "https://api.github.com/repos/learn-cli-organization/demo/comments{/number}"."issue_comment_url": "https://api.github.com/repos/learn-cli-organization/demo/issues/comments{/number}"."contents_url": "https://api.github.com/repos/learn-cli-organization/demo/contents/{+path}"."compare_url": "https://api.github.com/repos/learn-cli-organization/demo/compare/{base}... {head}"."merges_url": "https://api.github.com/repos/learn-cli-organization/demo/merges"."archive_url": "https://api.github.com/repos/learn-cli-organization/demo/{archive_format}{/ref}"."downloads_url": "https://api.github.com/repos/learn-cli-organization/demo/downloads"."issues_url": "https://api.github.com/repos/learn-cli-organization/demo/issues{/number}"."pulls_url": "https://api.github.com/repos/learn-cli-organization/demo/pulls{/number}"."milestones_url": "https://api.github.com/repos/learn-cli-organization/demo/milestones{/number}"."notifications_url": "https://api.github.com/repos/learn-cli-organization/demo/notifications{?since,all,participating}"."labels_url": "https://api.github.com/repos/learn-cli-organization/demo/labels{/name}"."releases_url": "https://api.github.com/repos/learn-cli-organization/demo/releases{/id}"."deployments_url": "https://api.github.com/repos/learn-cli-organization/demo/deployments"."created_at": "2018-11-14T16:41:01Z"."updated_at": "2018-11-14T16:42:39Z"."pushed_at": "2018-11-14T16:43:18Z"."git_url": "git://github.com/learn-cli-organization/demo.git"."ssh_url": "[email protected]:learn-cli-organization/demo.git"."clone_url": "https://github.com/learn-cli-organization/demo.git"."svn_url": "https://github.com/learn-cli-organization/demo"."homepage": null."size": 0."stargazers_count": 0."watchers_count": 0."language": "JavaScript"."has_issues": true."has_projects": true."has_downloads": true."has_wiki": true."has_pages": false."forks_count": 0."mirror_url": null."archived": false."open_issues_count": 0."license": null."forks": 0."open_issues": 0."watchers": 0."default_branch": "master"."permissions": {
      "admin": false."push": false."pull": true}}]Copy the code

Getting this array means that we have access to all the projects in the project group, a wave of unexpected business exchanges ^_^

Gets the version number of the specified projectThe document

Using the previous interface, we successfully obtained all project information in the project group. Next, we can obtain the version information of the specified project through the following interface (tags).

curl https://api.github.com/repos/learn-cli-organization/demo/tags

// Do not delete the colon between "your Github account: your Github password"
curl -u "Your Github account: Your Github password" https://api.github.com/repos/learn-cli-organization/demo/tags

// Return the result[{"name": "v0.0.1"."zipball_url": "https://api.github.com/repos/learn-cli-organization/demo/zipball/v0.0.1"."tarball_url": "https://api.github.com/repos/learn-cli-organization/demo/tarball/v0.0.1"."commit": {
      "sha": "00f0dda86e5f922e2ae406c25e19b44b2463f690"."url": "https://api.github.com/repos/learn-cli-organization/demo/commits/00f0dda86e5f922e2ae406c25e19b44b2463f690"
    },
    "node_id": "MDM6UmVmMTU3NTc5Njc0OnYwLjAuMQ=="}]Copy the code

Next episode: So far, we have been able to obtain the project information. Next we will combine inquirer. Js to achieve interactive command line dynamic retrieval of this information