A step by step guide to creating bit Scope for GitHub’s GraphQL API like this one: https://bitsrc.io/giladshoham/github-graphql
From this Scope, any user can easily install these components using NPM or import them into their own projects using Bit to quickly modify them to suit their own use case.
To run this project you will have to generate a github token to access GitHub’s API.
creating-a-personal-access-token-for-the-command-line
Then, copy the generated token into ./src/App.js
instead of the 'YOUR TOEKN HERE' string.
npm i
npm start
This project is based on simple create react app.
Make sure to run npm install
before starting the process.
Also, please create a user and a free Scope with Bit. You can learn more about Bit in this getting started guide.
- First, let’s install Bit.
$ npm install bit-bin -g
- Let’s initialize Bit for the project.
$ cd github-graphql-template
$ bit init
- Let’s add the components to be tracked by Bit.
$ bit add src/*/* -t src/{PARENT}/{FILE_NAME}.spec.js # use a glob pattern to track multiple components in the same path or a single path to track a single component.
$ bit import bit.envs/compilers/react -c
the following component environments were installed
- bit.envs/compilers/[email protected]
$ bit import bit.envs/testers/mocha -t
the following component environments were installed
- bit.envs/testers/[email protected]
- Now let’s lock a version and isolate the components from the project.
bit tag --all 1.0.0
$ bit export username.scopename # Share components to this Scope
Note that using the --eject
flag you can also remove an exported component from your source-code and add it as a package dependency in your project’s package.json
file.
That’s it. You can now install the components using your favorite package manager, or use bit import
to bring their source code into any repository, make changes and sync them across your codebase.