Hello Near
++ A greeting stored in + {CONTRACT} +
++ The contract says: + {greeting} +
+ ++ Login to change the greeting +
+diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ff4c1936..85b52d2f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 bos-workspace@0.0.1-alpha.6 + yarn global add bos-workspace@0.0.1-alpha.6 else - npm install -g bos-workspace + npm global add bos-workspace fi - name: Build and deploy the workspace diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml deleted file mode 100644 index 8cf5df46..00000000 --- a/.github/workflows/linter.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Lint Code Base - -on: - pull_request: - branches: [main] - -jobs: - lint: - name: Lint Code Base - runs-on: ubuntu-latest - - permissions: - contents: read - packages: read - statuses: write - - steps: - - name: Checkout - id: checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup Node.js - id: setup-node - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: npm - - - name: Install Dependencies - id: install - run: npm install - - - name: Lint Code Base - id: super-linter - uses: super-linter/super-linter/slim@v5 - env: - DEFAULT_BRANCH: main - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - JAVASCRIPT_DEFAULT_STYLE: prettier - JAVASCRIPT_ES_CONFIG_FILE: .eslintrc.yml - VALIDATE_JSCPD: false - VALIDATE_ALL_CODEBASE: false - VALIDATE_CSS: false - VALIDATE_MARKDOWN: false - FILTER_REGEX_EXCLUDE: .*/dist/.* diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6b7902f0..15da1c98 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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}} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 843f58a2..4798d642 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/.gitignore b/.gitignore index c90ac9ef..9348b614 100644 --- a/.gitignore +++ b/.gitignore @@ -21,9 +21,7 @@ Thumbs.db # Ignore built ts files dist/**/* - -# ignore yarn.lock -yarn.lock +/examples/**/build/ # tests __app_example_1/ \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..7ae82cd2 --- /dev/null +++ b/CONTRIBUTING.md @@ -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. diff --git a/README.md b/README.md index 8f2c5b55..c7e78c54 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 00000000..49027217 --- /dev/null +++ b/examples/README.md @@ -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` diff --git a/examples/multi/apps/GoodbyeNothing/bos.config.json b/examples/multi/apps/GoodbyeNothing/bos.config.json new file mode 100644 index 00000000..6dff13a1 --- /dev/null +++ b/examples/multi/apps/GoodbyeNothing/bos.config.json @@ -0,0 +1,3 @@ +{ + "account": "goodbyenothing.near" +} \ No newline at end of file diff --git a/examples/multi/apps/GoodbyeNothing/data.json b/examples/multi/apps/GoodbyeNothing/data.json new file mode 100644 index 00000000..0de83adc --- /dev/null +++ b/examples/multi/apps/GoodbyeNothing/data.json @@ -0,0 +1,3 @@ +{ + "goodbyenothing.near": {} +} diff --git a/examples/multi/apps/GoodbyeNothing/widget/GoodbyeNothing.js b/examples/multi/apps/GoodbyeNothing/widget/GoodbyeNothing.js new file mode 100644 index 00000000..ded73d6e --- /dev/null +++ b/examples/multi/apps/GoodbyeNothing/widget/GoodbyeNothing.js @@ -0,0 +1 @@ +return
goodbye nothing
; diff --git a/examples/multi/apps/HelloWorld/bos.config.json b/examples/multi/apps/HelloWorld/bos.config.json new file mode 100644 index 00000000..52d2f947 --- /dev/null +++ b/examples/multi/apps/HelloWorld/bos.config.json @@ -0,0 +1,3 @@ +{ + "account": "helloworld.near" +} \ No newline at end of file diff --git a/examples/multi/apps/HelloWorld/data.json b/examples/multi/apps/HelloWorld/data.json new file mode 100644 index 00000000..09024c2c --- /dev/null +++ b/examples/multi/apps/HelloWorld/data.json @@ -0,0 +1,3 @@ +{ + "helloworld.near": {} +} diff --git a/examples/multi/apps/HelloWorld/widget/HelloWorld.js b/examples/multi/apps/HelloWorld/widget/HelloWorld.js new file mode 100644 index 00000000..150e9ab6 --- /dev/null +++ b/examples/multi/apps/HelloWorld/widget/HelloWorld.js @@ -0,0 +1 @@ +returnhello world
; diff --git a/examples/multi/bos.workspace.json b/examples/multi/bos.workspace.json index 7de31531..a2c1d3e1 100644 --- a/examples/multi/bos.workspace.json +++ b/examples/multi/bos.workspace.json @@ -1,3 +1,3 @@ { - apps: ["./app1", "./app2", "./apps/*"] -} + "apps": ["./apps/*"] +} \ No newline at end of file diff --git a/examples/single/aliases.mainnet.json b/examples/single/aliases.mainnet.json new file mode 100644 index 00000000..483c5242 --- /dev/null +++ b/examples/single/aliases.mainnet.json @@ -0,0 +1,3 @@ +{ + "contract": "hello.near-examples.near" +} \ No newline at end of file diff --git a/examples/single/aliases.testnet.json b/examples/single/aliases.testnet.json new file mode 100644 index 00000000..bf75e885 --- /dev/null +++ b/examples/single/aliases.testnet.json @@ -0,0 +1,3 @@ +{ + "contract": "hello.near-examples.testnet" +} \ No newline at end of file diff --git a/examples/single/bos.config.json b/examples/single/bos.config.json index 5e1d8dd1..ad26b611 100644 --- a/examples/single/bos.config.json +++ b/examples/single/bos.config.json @@ -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"] } } } diff --git a/examples/single/data.json b/examples/single/data.json new file mode 100644 index 00000000..6d1607ee --- /dev/null +++ b/examples/single/data.json @@ -0,0 +1,3 @@ +{ + "quickstart.near": {} +} diff --git a/examples/single/widget/home.jsx b/examples/single/widget/home.jsx index e69de29b..f32425a8 100644 --- a/examples/single/widget/home.jsx +++ b/examples/single/widget/home.jsx @@ -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 ( ++ A greeting stored in + {CONTRACT} +
++ Login to change the greeting +
+