Skip to content

Commit

Permalink
Adds contributing guide, examples (#72)
Browse files Browse the repository at this point in the history
* adds contributing guide and updates dist

* update to yarn

* unignore yarn lock

* update node to 18

* removes linter
  • Loading branch information
elliotBraem authored Apr 8, 2024
1 parent b1cd036 commit 0b4f592
Show file tree
Hide file tree
Showing 155 changed files with 15,601 additions and 25,885 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,14 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: "18"
cache: yarn

- name: Install bos-workspace globally
run: |
if [ "${{ inputs.bw-legacy }}" = "true" ]; then
npm install -g [email protected]
yarn global add [email protected]
else
npm install -g bos-workspace
npm global add bos-workspace
fi
- name: Build and deploy the workspace
Expand Down
47 changes: 0 additions & 47 deletions .github/workflows/linter.yml

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ jobs:
id: setup-node
uses: actions/setup-node@v2
with:
node-version: 16
cache: npm
node-version: 18
cache: yarn
registry-url: "https://registry.npmjs.org"

- name: Install Dependencies
id: install
run: npm install
run: yarn install

- name: Publish to npm
id: publish
run: npm publish
run: yarn npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
id: setup-node
uses: actions/setup-node@v2
with:
node-version: 16
cache: npm
node-version: 18
cache: yarn

- name: Install Dependencies
id: install
run: npm install
run: yarn install

- name: Execute Test Tools
run: npm test
run: yarn run test
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ Thumbs.db

# Ignore built ts files
dist/**/*

# ignore yarn.lock
yarn.lock
/examples/**/build/

# tests
__app_example_1/
29 changes: 29 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Contributing Guide

Thank you for considering contributing to bos-workspace! Here are some guidelines to help you get started.

## Getting Started

To contribute to bos-workspace, follow these steps:

1. Fork the repository on GitHub.
2. Clone your forked repository to your local machine.
3. Make your changes locally, see the [examples](./examples/) for how to do this.
4. Test your changes to ensure they work as expected.
5. Commit your changes with descriptive commit messages. We like [Semantic Commit Messages](https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716).
6. Push your changes to your fork on GitHub.
7. Create a pull request to the main repository.

## Code Style

Please follow the existing code style and conventions used in the project.

## Testing

This repository uses jest unit tests, which can be found in [/tests](./tests/). Ensure that your changes include appropriate tests and that existing tests pass.

## Submitting Issues

If you encounter any issues or have feature requests, please submit them through GitHub issues. Include as much detail as possible to help us understand and address the problem efficiently.

Thank you for your interest in contributing to bos-workspace! Your contributions are greatly appreciated.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
To begin, either [use this template repository](https://github.com/new?template_name=quickstart&template_owner=NEARBuilders) or install `bos-workspace` within an existing project:

```cmd
npm install bos-workspace
yarn add -D bos-workspace
```

Then, you can clone widgets from an existing [account](https://near.social/mob.near/widget/Everyone) via:
Expand Down
16 changes: 16 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Examples

This folder contains example apps demonstrating the various functionalities and use cases of the bos-workspace CLI. They serve as a reference for users to understand how to interact with the tool and leverage its features, as well as an environemnt for testing changes during development of this tool.

## Contents

- `/single`: Demonstrates basic usage of a single App. It is a reproduction of the [Guest Book](https://docs.near.org/tutorials/examples/guest-book) and is configured with aliases in both mainnet and testnet.
- `/multi`: Demonstrates basic usage of a Workspace with multiple apps. The `bos.workspace.json` makes reference to two simple Apps.

## Usage

To use these examples while developing the CLI locally, follow the below steps:

1. From the root directory, ensure that you have installed the necessary dependencies, `yarn`
2. Run the `dev` script to watch for changes, `yarn dev`
3. Run one of the examples, referencing the local cli, e.g. `../bin/bw.js dev` or `../bin/bw.js ws dev`
3 changes: 3 additions & 0 deletions examples/multi/apps/GoodbyeNothing/bos.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"account": "goodbyenothing.near"
}
3 changes: 3 additions & 0 deletions examples/multi/apps/GoodbyeNothing/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"goodbyenothing.near": {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return <p>goodbye nothing</p>;
3 changes: 3 additions & 0 deletions examples/multi/apps/HelloWorld/bos.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"account": "helloworld.near"
}
3 changes: 3 additions & 0 deletions examples/multi/apps/HelloWorld/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"helloworld.near": {}
}
1 change: 1 addition & 0 deletions examples/multi/apps/HelloWorld/widget/HelloWorld.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
return <p>hello world</p>;
4 changes: 2 additions & 2 deletions examples/multi/bos.workspace.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
apps: ["./app1", "./app2", "./apps/*"]
}
"apps": ["./apps/*"]
}
3 changes: 3 additions & 0 deletions examples/single/aliases.mainnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"contract": "hello.near-examples.near"
}
3 changes: 3 additions & 0 deletions examples/single/aliases.testnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"contract": "hello.near-examples.testnet"
}
17 changes: 6 additions & 11 deletions examples/single/bos.config.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
{
accounts: {
deploy: "deploy.near",
signer: "signer.near",
dev: "dev.near"
},
format: true,
overrides: {
testnet: {
account: "testing.testnet",
format: false,
aliasesSrc: ["src/aliases.testnet.json"]
"account": "quickstart.near",
"aliases": ["./aliases.mainnet.json"],
"overrides": {
"testnet": {
"account": "quickstart.testnet",
"aliases": ["./aliases.testnet.json"]
}
}
}
3 changes: 3 additions & 0 deletions examples/single/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"quickstart.near": {}
}
60 changes: 60 additions & 0 deletions examples/single/widget/home.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const CONTRACT = "${alias_contract}"; // this will get replaced by bos-workspace according to -n {network_env}
const storedGreeting = Near.view(CONTRACT, "get_greeting") ?? "hello world";

if (!storedGreeting || context.loading) {
return "Loading...";
}

const [greeting, setGreeting] = useState(storedGreeting);
const [showSpinner, setShowSpinner] = useState(false);
const loggedIn = !!context.accountId;

const onInputChange = ({ target }) => {
setGreeting(target.value);
};

const onBtnClick = () => {
setShowSpinner(true);
Near.call(CONTRACT, "set_greeting", { greeting });
setShowSpinner(false);
};

const Main = styled.div`
font-family: -apple-system, BlinkMacSystemFont, Segoe UI
`;

// Render
return (
<Main>
<div className="text-center">
<h3 className="font-weight-bold"> Hello Near </h3>
<p className="small font-weight-light">
A greeting stored in
<span className="text-danger">{CONTRACT}</span>
</p>
</div>
<div className="container py-4 px-5 text-dark bg-light rounded">
<h2 className="text-center">
The contract says:
<span className="text-primary"> {greeting} </span>
</h2>

<div class="p-4">
<div className="input-group" hidden={!loggedIn}>
<input placeholder="Store a new greeting" onChange={onInputChange} />
<button className="btn btn-primary" onClick={onBtnClick}>
<span hidden={showSpinner}>Save</span>
<i
className="spinner-border spinner-border-sm"
hidden={!showSpinner}
></i>
</button>
</div>

<p className="text-center py-2" hidden={loggedIn}>
Login to change the greeting
</p>
</div>
</div>
</Main>
);
2 changes: 0 additions & 2 deletions gateway/dist/1008.d7a8f9159603702300d8.bundle.js

This file was deleted.

Loading

0 comments on commit 0b4f592

Please sign in to comment.