Giter Club home page Giter Club logo

bos-workspace's Introduction

bos-workspace

๐Ÿšง Warning: This library has recently undergone a major refactor. ๐Ÿšง

If this is not your first time using bos-workspace, read the migration guide. The legacy documentation for v0.0.1-alpha.6 can be found here.

bos-workspace is a comprehensive toolset designed to simplify the development and deployment of NEAR components and applications. With support for hot reload, TypeScript, and multi-app management, it caters to developers looking for an efficient and scalable developer environment.

Quickstart

To begin, either:

  • Use the template repository with quickstart app, preconfigured git workflows, and playwright test suite

  • Use the init command for an empty workspace:

npx bos-workspace init
  • Clone widgets from an existing account:
npx bos-workspace clone [accountId] [dest]
npx bos-workspace dev [dest | accountId]
  • Or install bos-workspace within an existing project:
yarn add -D bos-workspace

and ensure the proper workspace structure and usage.

Usage

bos-workspace supports both multi and single app development because of Apps and Workspaces:

  • App: which belong to an Account, described by a bos.config.json. A structure may look like this:
app.near/
โ”œโ”€โ”€ widget/
โ”‚   โ””โ”€โ”€ example.jsx
โ””โ”€โ”€ bos.config.json

where the content of bos.config.json is (at least):

{
  "account": "app.near"
}
  • Workspace: may hold multiple apps, described by a bos.workspace.json
apps/
โ”œโ”€โ”€ app1.near/
โ”‚   โ”œโ”€โ”€ widget/
โ”‚   โ”‚   โ””โ”€โ”€ example.jsx
โ”‚   โ””โ”€โ”€ bos.config.json
โ”œโ”€โ”€ app2.near/
โ”‚   โ”œโ”€โ”€ widget/
โ”‚   โ”‚   โ””โ”€โ”€ example.jsx
โ”‚   โ””โ”€โ”€ bos.config.json
bos.workspace.json

where the content of bos.workspace.json is:

{
  "apps": ["/apps/*"]
}

Note: The "app name" is not required to end in .near, and apps don't necessarily have to be stored in a directory named /apps. What's important is that the bos.config.json is located at the same level as directories such as /widget, and that bos.workspace.json specifies the directory it resides in.

Configuration

The bos.config.json file serves as the configuration file for managing various settings and options related to the workspace.

A fully featured config may look like this:

{
  "account": "quickstart.near",
  "aliases": ["./aliases.mainnet.json"],
  "index": "quickstart.near/widget/home",
  "overrides": {
    "testnet": {
      "account": "quickstart.testnet",
      "aliases": ["./aliases.testnet.json"],
      "index": "quickstart.testnet/widget/home"
    }
  },
  "accounts": {
    "deploy": "quickstart.near",
    "signer": "devs.near",
  },
  "format": true,
  "ipfs": {
    "gateway": "https://ipfs.near.social/ipfs",
    "uploadApi": "https://ipfs.near.social/add",
    "uploadApiHeaders": {},
  },
}

Base Configuration

The bos.config.json file consists of a base configuration that defines default values and settings for the BOS environment.

  • account: (Optional) Specifies the default account to serve widgets from. If not provided, the default value is set to "bos.workspace".
  • accounts: (Optional) Defines account configuration options for the deploy command.
    • deploy: Specifies the account to deploy widgets to.
    • signer: Specifies the account to sign the transaction.
  • ipfs: (Optional) Configures IPFS settings for uploading and using local assets.
    • gateway: IPFS gateway to use for accessing files. Default value is "https://ipfs.near.social/ipfs".
    • uploadApi: IPFS API endpoint to upload to. Default value is "https://ipfs.near.social/add".
    • uploadApiHeaders: Any additional headers to send with IPFS upload API requests.
  • format: (Optional) Indicates whether to format code on build. Default value is true.
  • aliases: (Optional) Provides a list of alias files to use for replacing network-specific values with correct overrides.
  • index: (Optional) Default widget src to use when using a custom gateway dist.

Network Overrides

The bos.config.json file supports network configuration overrides of this base configuration, allowing developers to specify different settings for specific networks (e.g., mainnet, testnet).

  • overrides: (Optional) Defines overrides for network-specific configurations. These values are used via the -n flag in commands, respectivly:
    • mainnet
    • testnet

Aliases

When working with values that differ accross different networks, developers can define aliases in separate JSON files according to environment. These aliases are replaced during build.

  • Account: Defines the "owner" of the widgets in the workspace, according to network.
    • Pattern: {config_account}
  • Aliases: Defines patterns for replacing other account and contract references. These are particularly useful for widget sources accross environments, such as using mob.near for mainnet, and mike.testnet for testnet.
    • Pattern: ${alias_key}

    • Example:

      {
        "account": "[MAINNET_ACCOUNT_ID]",
        "aliases": ["./aliases.mainnet.json"],
        "overrides": {
          "testnet": {
            "account": "[TESTNET_ACCOUNT_ID]",
            "aliases": ["./aliases.testnet.json"]
          }
        }
      }

      with accompaning jsons:

      aliases.mainnet.json

      {
        "devs": "devs.near",
        "mob": "mob.near",
      }

      aliases.testnet.json

      {
        "devs": "neardevs.testnet",
        "mob": "mike.testnet"
      }

Customizing the Gateway

Running the bos-workspace dev server will start a local gateway with a standard near-social-vm installed unless the --no-gateway flag is provided in your dev command:

bw dev --no-gateway

However, there is an option to override this default gateway with a custom /dist. This is helpful when building widgets that utilize custom VM elements. To use this feature, use the -g flag with a path to the local custom distribution:

bw dev -g path/to/dist

This will automatically start the local gateway, but using the provided dist.

It is easy to build and distribute a custom gateway using the near-bos-webcomponent, see "Configuring VM Custom Elements".

The bos-workspace dev server is specially configured with the near-bos-webcomponent to automatically set the rpc attribute with the proxy-rpc when provided.

Commands

You can run bw or bos-workspace to see the list of commands.

Usage: bos-workspace [options] [command]

Build decentralized apps

Options:
  -V, --version                                  output the version number
  -h, --help                                     display help for command

Commands:
  dev [options] [src]                            Run the development server
  build [options] [src] [dest]                   Build the project
  workspace|ws [options] [command] [src] [dest]  Work with multiple apps
  init [options] [path]                          Initialize a new project
  clone [account] [dest]                         Clone a SocialDB repository
  pull [account]                                 Pull updates from a SocialDB repository
  deploy [options] [appName]                     Deploy the project
  upload [string]                                Upload data to SocialDB (not implemented)
  help [command]                                 display help for command

If the gateway can't fetch local components, try disabling brave shields or your adblock. If the commands don't work, try again using Node >=16

Deployment

Usage (CLI)

Command: deploy

Deploys an app in the workspace via a convenient wrapper to bos-cli-rs.

bw deploy [app name] --deploy-account-id [deployAccountId] --signer-account-id [signerAccountId] --signer-public-key [signerPublicKey] --signer-private-key [signerPrivateKey]
  • [app name]: Name of the app to be deployed. Assumed to be the current app in App structure (bos.config.json), but is required when using the Workspace structure (bos.workspace.json); this should match the name of the App's directory.

  • --deploy-account-id <deployAccountId> (Optional): Account under which component code should be deployed. Defaults to config.account, or will use config.accounts.deploy if specified.

  • --signer-account-id <signerAccountId> (Optional): Account which will be used for signing deploy transactions, frequently the same as deploy-account-id. Defaults to config.account, or will use config.accounts.deploy if specified.

  • --signer-public-key <signerPublicKey> (Required): Public key for signing transactions in the format: ed25519:<public_key>.

  • --signer-private-key <signerPrivateKey> (Required): Private key in ed25519:<private_key> format for signing transactions.

  • -n, --network <network> (Optional): Network to deploy for (default: "mainnet").

Usage (Git Workflow)

Prerequisites

  1. Must be upgraded to bos-workspace v1, see the migration guide
  2. Specify testnet overrides + aliases in bos.config.json.

Mainnet

  1. Create .github/workflow/release-mainnet.yml
name: Deploy Components to Mainnet
on:
  push:
    branches: [main]
jobs:
  deploy-mainnet:
    uses: NEARBuilders/bos-workspace/.github/workflows/deploy.yml@main
    with:
      bw-legacy: false
      deploy-env: "mainnet"
      app-name: "[APP_NAME]"
      deploy-account-address: "[DEPLOY_ACCOUNT]"
      signer-account-address: "[SIGNER_ACCOUNT]"
      signer-public-key: [PUBLIC_KEY]
    secrets:
      SIGNER_PRIVATE_KEY: ${{ secrets.SIGNER_PRIVATE_KEY }} // then configure this in your Github/Settings/Actions

Testnet

  1. Create .github/workflow/release-testnet.yml
name: Deploy Components to Testnet
on:
  push:
    branches: [develop]
jobs:
  deploy-mainnet:
    uses: NEARBuilders/bos-workspace/.github/workflows/deploy.yml@main
    with:
      bw-legacy: false
      build-env: "testnet"
      deploy-env: "testnet"
      app-name: "[APP_NAME]"
      deploy-account-address: "[DEPLOY_ACCOUNT]" // testnet account
      signer-account-address: "[SIGNER_ACCOUNT]"
      signer-public-key: [PUBLIC_KEY] 
    secrets:
      SIGNER_PRIVATE_KEY: ${{ secrets.SIGNER_PRIVATE_KEY }} // then configure this in your Github/Settings/Actions

Reference: quickstart

API Endpoints

A running bos-workspace server exposes several endpoints for interacting with local data:

Gateway Frontend

URL: http://127.0.0.1:8080/

-> Provides a frontend interface for viewing and interacting with widgets.

Loader API

URL: http://127.0.0.1:8080/api/loader

Method: POST

-> Receive all built and served data.

WebSocket

URL: ws://127.0.0.1:8080/

-> WebSocket for hot reload, delivers most updated data.

Proxy RPC

URL: http://127.0.0.1:8080/api/proxy-rpc

-> Proxies RPC requests, use as rpcUrl in near-api-js.

Contributing

Read CONTRIBUTING

bos-workspace's People

Contributors

elliotbraem avatar sekaiking avatar ittechhunter avatar thisistheaj avatar kapasinh avatar

Stargazers

Cuong DC avatar Billzy avatar Dennis avatar  avatar Dawn Kelly avatar Matt avatar  avatar Javed Khan avatar Luรญs Freitas avatar Isayah Culbertson avatar Mario Reder avatar Mohamed ElKhamisy avatar Jacob Lindahl avatar Wenderson Pires avatar Rogan X avatar Josh Ford avatar Alexander Pena avatar  avatar James Waugh avatar NEAR HackerHouse avatar Robert Yan avatar  avatar  avatar

Watchers

Seth Feibus avatar  avatar T guntenaar avatar

bos-workspace's Issues

[BUG] Clone should give error if account doesn't exist

We have a clone function for initializing a bos-workspace from existing widgets an account may hold. This is helpful when creating a bos-workspace for an existing account, so we don't need to copy and paste widget code around.

I tried using this on a mistyped account Id and got an error:

Screenshot 2024-04-30 at 8 09 56โ€ฏAM

This is because the account I tried (near-catalog.near) does not exist. I would expect a clearer error, something like:

"Are you sure this account exists? : near-catalog.near "

Allow an IPFS path for custom gateway path

The dev command allows a custom gateway path via the -g flag, which is useful when building with gateways with custom components.

Example usage:

trylivepeer.near/package.json

  "scripts": {
    "bw": "bos-workspace",
    "dev": "pnpm run dev:gateway && pnpm run dev:apps",
    "dev:gateway": "cd gateway && pnpm run build",
    "dev:apps": "pnpm run bw ws dev -g gateway/dist/"
  },

Following the README for Publishing libraries to NEARFS, adapt this flag to allow either the path to a dist or nearfs url

https://ipfs.web4.near.page/ipfs/bafybeicu5ozyhhsd4bpz4keiur6cwexnrzwxla5kaxwhrcu52fkno5q5fa/

Preparing for First Stable Release

Overview

This Epic tracks all the tasks and issues required to launch the first stable release of bos-workspace. Our goal is to ensure that the release is dev-friendly, well-tested, and well-documented.

Core functionalities

Complete documentation

Testing & Bugs

The code is missing tests, we need to improve the test coverage to ensure nothing breaks with new versions based on the core functionalities.

Remove container stylings from local viewer

Possibly could be one of the first dev tools; the ability to toggle "container" vs full-width.

Devs developing specific components may want "container"; devs building fully branded websites may want full-width.

Create reusable workflow for preview deploys

Bigger teams like to include preview deploys in their pull requests; this typically involves the developer deploying to a dedicated account and sharing a link -- although this can be difficult when working on multiple stories at one time (either needs a dedicated account per story, or need to rotate through the deploys depending on the order they are reviewed).

A possible solution (only in testnet) is to create github workflow that generates an implicit account via near-cli-rs, then deploys to this account and shares the preview link automatically.

Ability to specify env in bos.config.json

A couple of ecosystem projects set up their Github workflows to deploy to testnet, then to mainnet.
For example, see near-discovery-components (although this uses bos-loader exclusively).

To do this, there are different replacements file for each environment that get passed to bos-loader replacements flag.

See:
Image

We should be able to support the same in bos-workspace.

Acceptance Criteria

  • Builders should be able to assign different account Ids according to environment, e.g "mob.near" in mainnet and "eugenethedream" in testnet
  • Builders should be able to assign different contract ids according to environment, e.g "devgovgigs.near" in mainnet and "thomas.preview.testnet" in testnet
  • Builders should be able to assign other aliases according to environment(?)

Implement deploy command

This needs to be completed: lib/deploy.ts

This should be able to work within a workspace or for a singular app (bos.workspace.json or just a bos.config.json).

You can reference the git workflow for deploying code in what the steps should be, see this: https://github.com/NEARBuilders/bos-workspace/blob/main/.github/workflows/deploy.yml

bw-legacy === false means use the current (v1.0.0-alpha.*) bos-workspace. We have this flag here because some projects are still using an old version of bos-workspace.

Installing doesn't expose bos-workspace or bw

This broke in latest alpha version:

neither installing it globally or in the repository exposed bos-workspace or bw to be used.

We should make sure this works before transferring it over.

Most projects using bos-workspace are set to this version atm:

   "bos-workspace": "github:nearbuilders/bos-workspace#main"

Reduce redirectMap latency & "VM is dead"

When developing locally, there can be some unexpected behavior and discrepancy between what is local and what has been published to social contract.

For example, in below, you'll see two errors pop up in potlock.near/widget/Components.Nav:

potlock

First, it throws a "props.hrefWithParams" function not found error, although the local version of Components.Nav and all of its children do not use this function (the published version does).

Also, you'll see "potlock.near/widget/Cart.NavItem is not found", which is a new widget that has been added locally and is not yet published. Since we are pulling from local, this shouldn't be an issue, but the error showing is why I suspect a request for published version is made first.

Turning off wifi and running the app shows no errors.

Additional notes

  • "VM is dead" is also a common error you'll find, although it seems to go away as the application becomes more performant.
  • Need to confirm if this is only an issue with hot reload and local gateway, check if it works with flags + no hot reload
  • Why is the VM making a request when the key exists in redirect map?

Enable local data during dev

This used to be a feature of bos-workspace 0.0.1, but was only partially carried over from the refactor.

We're able to use local widgets, but what if I want to reference local data when I do bos-workspace dev?

For example, I have a Social.get(${config_account}/project/nested.projectId) in my code to reference the JSON I have stored at project/nested/projectId in my workspace?

The prior implementation of this can be found HERE, feel free to use it as a reference. In short, it loops through all the files in designated directories and builds a large data.json.

I think in the new implementation, we should do the same, but associate it with a configuration in the bos.config.json that designates which directories should be uploaded. For example:

bos.config.json

{
    "account": "sample.near",
    "data": { 
      "include": ["type", "thing", "project"]
    }
  }

Where the strings in "include" are references to the directory names in same level as the bos.config.json. An example of a repository that would use this feature is hyperfiles.

This data should be exposed through the dev server so it is used during RPC proxy, see in lib/server. It could use the same devJson, just save outside of "components".

Acceptance criteria

  • Local data can be referenced in workspace code
  • Throws error if an "included" directory does not exist
  • Should watch for changes in included directories
  • Test coverage

[BUG] deleted files still show in my workspace

I did a clone to download all of devs.near's widgets.

(from /examples, see contributing guide)
../bin/bw.js clone devs.near

I checked them out locally

../bin/bw.js ws dev

They appeared. I went through and deleted a ton because I don't need all these widgets.

I run them again...
../bin/bw.js ws dev

but these files are still showing in bos-workspace portal, despite not in my filesystem.

After deleting files, they should no longer show in my workspace.

Build & deploy web4 gateway

We have the -g flag for a custom gateway used for development-- now we want to be able to set a gateway and read the "index" from bos.config.json, so we can deploy this resulting /dist

Deploying to web4

telegram-cloud-photo-size-1-5125439505636109465-y

Text guide

Git workflow templates for mainnet, testnet, and preview branches

This is an example of a current Github workflow utilizing bos-workspace:

BluntDAO

name: Deploy Components to Mainnet
on:
  push:
    branches: [main]
jobs:
  deploy-widgets:
    runs-on: ubuntu-latest
    name: Deploy widgets to social.near (mainnet)
    env:
      BOS_DEPLOY_ACCOUNT_ID: ${{ vars.BOS_DEPLOY_ACCOUNT_ID }}
      BOS_SIGNER_ACCOUNT_ID: ${{ vars.BOS_SIGNER_ACCOUNT_ID }}
      BOS_SIGNER_PUBLIC_KEY: ${{ vars.BOS_SIGNER_PUBLIC_KEY }}
      BOS_SIGNER_PRIVATE_KEY: ${{ secrets.BOS_SIGNER_PRIVATE_KEY }}
      NETWORK_ID: mainnet

    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Install near-social CLI
        run: |
          curl --proto '=https' --tlsv1.2 -LsSf https://github.com/FroVolod/bos-cli-rs/releases/download/v0.3.1/bos-cli-v0.3.1-installer.sh | sh
      
      - name: Install bos-workspace from dev branch
        run: |
          npm install -D bos-workspace
  
      - name: Build the workspaces
        run: |
          npm run build

      - name: Deploy widgets
        working-directory: ./build/bluntdao
        run: |
          bos components deploy "$BOS_DEPLOY_ACCOUNT_ID" sign-as "$BOS_SIGNER_ACCOUNT_ID" network-config mainnet sign-with-plaintext-private-key --signer-public-key "$BOS_SIGNER_PUBLIC_KEY" --signer-private-key "$BOS_SIGNER_PRIVATE_KEY" send

Notice that we need to set the working directory to ./build/bluntdao

We could replace this with a template, like this one where deploy account, signer account, public key, private key, and the app name (bluntdao) get passed as variables to it

[BUG]: Deeply nested routes have stopped working

After the latest update (v1.0.0-alpha.11), deeply nested routes such as:

./widget/deeply/nested/index.tsx
./widget/very/deeply/nested/index.tsx

Have stopped working.

We would expect these to build correctly, to:

./widget/deeply.nested.index.tsx
./widget/very.deeply.nested.index.tsx

Saving attributions to metadata

If a widget looks like this on the social contract:

{
  [accountId]: {
    widget: {
     [widgetName]: {
        "": JSON.stringify(code),
        "metadata": {
          name: "",
          description: "",
        }
      } 
  }
  }
}

We could extend metadata to include an array of users to attribute. This could be handled from bos-workspace, with an ultimately goal of it potentially populated based on mappings of a user's github handle with their near account.

Incorrect paths on Windows

Windows users are getting mismatched paths when building, see below:

telegram-cloud-photo-size-1-4958545859721669713-x

Then on click, it goes here: Source code for "hyperfiles.near/widget/hyperfile/index" is not found
This does not occur on windows.

We should expect the paths in the image to be:
hyperfiles.near/widget/adapter.github, etc

And the link should be the same. The dot should be replacing this character.

TailwindCSS Support

Easier way of styling components with Tailwind can be achieved by incorporating either PostCSS, TailwindCLI or TailwindCDN directly in the gateway and when components are ready to be published user can/should compile the CSS file (can also be automated)

I believe for testing purposes users shall be able to have easy way to inject anything they want into the development gateway provided anyway

The resulted CSS file can be uploaded and referenced later in an wrapper component similar to this implementation by Andria

Tried installing bos-cli-rs using rust package manager cargo . it got failed in the middle Error configuring OpenSSL build:

I am currently on my Windows machine. the exact error that occurred during the installation was

error: failed to run custom build command for openssl-sys v0.9.97

Caused by:
process didn't exit successfully: C:\Users\SASWAT~1\AppData\Local\Temp\cargo-installW4uxhg\release\build\openssl-sys-a52d4764de55824a\build-script-main (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR
X86_64_PC_WINDOWS_MSVC_OPENSSL_NO_VENDOR unset
cargo:rerun-if-env-changed=OPENSSL_NO_VENDOR
OPENSSL_NO_VENDOR unset
running "perl" "./Configure" "--prefix=C:\Users\SASWAT~1\AppData\Local\Temp\cargo-installW4uxhg\release\build\openssl-sys-8d11540cf2537ff2\out\openssl-build\install" "--openssldir=SYS$MANAGER:[OPENSSL]" "no-dso" "no-shared" "no-ssl3" "no-tests" "no-comp" "no-zlib" "no-zlib-dynamic" "--libdir=lib" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "no-capieng" "no-asm" "VC-WIN64A"

--- stderr
thread 'main' panicked at C:\Users\saswat marpureddy.cargo\registry\src\index.crates.io-6f17d22bba15001f\openssl-src-300.1.6+3.1.4\src\lib.rs:585:9:

Error configuring OpenSSL build:
Command: "perl" "./Configure" "--prefix=C:\Users\SASWAT~1\AppData\Local\Temp\cargo-installW4uxhg\release\build\openssl-sys-8d11540cf2537ff2\out\openssl-build\install" "--openssldir=SYS$MANAGER:[OPENSSL]" "no-dso" "no-shared" "no-ssl3" "no-tests" "no-comp" "no-zlib" "no-zlib-dynamic" "--libdir=lib" "no-md2" "no-rc5" "no-weak-ssl-ciphers" "no-camellia" "no-idea" "no-seed" "no-capieng" "no-asm" "VC-WIN64A"
Failed to execute: program not found

note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to compile bos-cli v0.3.6 (https://github.com/FroVolod/bos-cli-rs#46037ed0), intermediate artifacts can be found at C:\Users\SASWAT~1\AppData\Local\Temp\cargo-installW4uxhg

Apps directory can be repetitive

After setting up multiple bos-workspaces across the ecosystem, I've encountered some recurring feedback.

Typically, bos-workspaces have not been used as monorepos handling multiple different apps and will instead use one app + deploy accountId, which will be setup in a Github Action

A common flow I've had to do is the following:

For bluntdao, I needed to initialize a bos-workspace, pull in existing widgets, then set up the workflow

mkdir bluntdao-components
cd bluntdao-components

mkdir apps
mkdir apps/bluntdao
mkdir apps/bluntdao/widget
touch apps/bluntdao/bos.config.json
touch apps/bluntdao/widget/hello.jsx

cd apps/bluntdao
bos components download bluntdao.near
// this downloads all bluntdao components to a /src directory
 // now we need to move them all to the widget directory 
mv src/widget/* widget/.  

npm init (create package.json)
npm install bos-workspace

// create npm run dev and npm run build in package.json -> bw dev, bw build

// copy over github workflows
// modify github workflow working directory to be the app name (bluntdao)

npm run dev

And then sometimes, if there are multiple apps, such as genadrop; instead of dedicate different accounts for each app, they add a prefix like in genadrop, so there are prefixes GenaDrop and CPlanet, and so you can have a structure that looks like this:

apps/bluntdao/widget/bluntdao/hello.jsx


I think the multi-app flow is powerful, and maybe GenaDrop and CPlanet should be following it rather than what they are doing now deploying to the same account

But it is very common to set up a github repository for only one app + to only configure one deploy and signer account for it for the Github Action; and so the deep directories repeating the same app name can be confusing.

I feel like both should be supported, especially considering the context of #25 and #19; but it may mean changing default behavior or reducing a layer; food for thought

Migrate projects using bos-workspace

Creating this story to keep track of all the projects + repositories that are using bos-workspace and must be updated/maintained.

Ideally we can update these to a stable version with a uniform structure, as well as using the reusable workflow, so there is minimal maintenance going forward.

Support for multiple repositories on a single port

Currently, running bos-workspace dev in a new repository starts a server on a new port (e.g., 8080) if 4040 is already in use. This feature would allow developers to work on multiple projects simultaneously without needing to switch ports.

This way, I can check out multiple repositories, run "bos-workspace dev", and the files in the repo will be appended to the existing server.

For example, I am working on Build DAO gateway repository, which uses the Feed widget in bos-blocks. Currently, I drag and drop the "apps" I need, but this risks duplication or changes detaching from original repo

Implement upload command

This used to be a feature of bos-workspace 0.0.1, but was only partially carried over from the refactor. To be completed after #99.

The purpose of the command is to upload other data, besides widget to the social contract. As you can see, looking at an account's data tree on social contract, see every.near's here, there can be other data aside from widget such as "type", "thing", "project"... we want to enable the ability to manage and upload these files from bos-workspace.

The prior implementation of this can be found HERE, feel free to use it as a reference. In short, it loops through all the files in designated directories and builds a large data.json, converts to base64, then uploads to social contract via near cli command.

I think in the new implementation, we should do the same, but associate it with a configuration in the bos.config.json that designates which directories should be uploaded. For example:

bos.config.json

{
    "account": "sample.near",
    "data": { 
      "include": ["type", "thing", "project"]
    }
  }

Where the strings in "include" are references to the directory names in same level as the bos.config.json. An example of a repository that would use this feature is hyperfiles.

Acceptance criteria

  • Upload command uploads data to social.near contract
  • Command throws error if an "included" directory does not exist
  • Test coverage
    • should throw error if included directory does not exist
    • should call social contract with correct values & base64 encoded json

"No files match the pattern" during bw init

When trying to use the bos-workspace init command via npx bos-workspace init, I get the following error:

โžœ npx bos-workspace init
โœ” What NEAR AccountId deploys your project? โ€ฆ test.near
No such file or directory: /Users/ebraem/.npm/_npx/ab7f07b18dde6119/node_modules/bos-workspace/templates/js
No such file or directory: test.near/_gitignore
No such file or directory: test.near/_github
Error: No files match the pattern: test.near/README.md
    at /Users/ebraem/.npm/_npx/ab7f07b18dde6119/node_modules/replace-in-file/lib/helpers/glob-async.js:23:23
    at f (/Users/ebraem/.npm/_npx/ab7f07b18dde6119/node_modules/once/once.js:25:25)
    at Glob.<anonymous> (/Users/ebraem/.npm/_npx/ab7f07b18dde6119/node_modules/replace-in-file/node_modules/glob/glob.js:148:7)
    at Glob.emit (node:events:514:28)
    at Glob._finish (/Users/ebraem/.npm/_npx/ab7f07b18dde6119/node_modules/replace-in-file/node_modules/glob/glob.js:194:8)
    at done (/Users/ebraem/.npm/_npx/ab7f07b18dde6119/node_modules/replace-in-file/node_modules/glob/glob.js:179:14)
    at Glob._processSimple2 (/Users/ebraem/.npm/_npx/ab7f07b18dde6119/node_modules/replace-in-file/node_modules/glob/glob.js:688:12)
    at /Users/ebraem/.npm/_npx/ab7f07b18dde6119/node_modules/replace-in-file/node_modules/glob/glob.js:676:10
    at Glob._stat2 (/Users/ebraem/.npm/_npx/ab7f07b18dde6119/node_modules/replace-in-file/node_modules/glob/glob.js:772:12)
    at lstatcb_ (/Users/ebraem/.npm/_npx/ab7f07b18dde6119/node_modules/replace-in-file/node_modules/glob/glob.js:764:12)
Something went wrong when generating your app. You may need to delete the folder at test.near

This error does not happen if I access bos-workspace directly, outside of npx.

Ability to toggle environment in default gateway

Just as I am able to toggle environment on an application like nearblocks:

Screenshot 2024-03-26 at 11 11 17โ€ฏPM

I want to be able to do this on the bos-workspace gateway. I should be able to sign in with a testnet account. This environment environment should be passed to the NearSocial/VM so contract calls in widgets reflect correct environment.

deployAccount and signerAccount in bos.config.json

The github action is just a deploy, we can find other ways to run it.

Rather than just "appAccount", what if the bos.config.json allowed the deploy and signer account for deploying these widgets in via smart contract?

Improve the parser syntax

The /*__@replace:alias__*/ is hard to type and not optimal. Maybe we should switch it to something more concise, easier to write and read with less constraints without conflicting with other code.

We need a syntax that is language agnostic, we want the commands to be parsed in every type of comments one line or multi line, be it in JS, HTML, CSS, JSONC or any language. Using the @ in js will also help with syntax highlighting.

for example to import a module:

// @alias(hello)
// @import(module)
// @account
/* @alias(hello) */
<!-- @alias(hello) -->
/* @alias(hello) */
// @skip
{}

This will break projects using the older syntax, if we choose to implement it we have to support both syntaxes until we remove the old in a future major release.

@elliotBraem, you used bos-workspace more than anyone, so what do you think about this? is a an unnecessary change or an improvement?

Ability to configure bos-workspace gateway from config

Currently, the default gateway will show this screen on start:

Screenshot 2024-04-21 at 9 25 49โ€ฏPM

I want to be able to override this with a custom widget. This can come from a "workspace" field in bos.config.json or bos.workspace.json

It should be able to be overridden depending on environment.

Nested files don't work on Windows

I do not have Windows, but I have faced this issue with a few devs.

In an app director, a L1 widget such as widget/home.jsx works fine, but a L2 widget like widget/home/index.jsx will not work when accessing via widget/home.index.

Add CLI Options to give more control on what's running

We need some to add some options to the cli, mainly:

  • bw dev --gateway-port 5555 --loader-port 5556 define ports to use with the servers.
  • bw dev --no-gateway launch bos-loader without the gateway.
  • bw dev --no-hot disable web-socket server and only use http server.

Integrate create-bos-app

Screenshot 2023-12-01 at 6 22 45โ€ฏPM

create-bos-app is a hackathon project created by @sethfork. I've been using it a lot for starting new projects and when directing others to get started.

Seth has agreed that we can combine the two of these and integrate it with bos-workspace.

In implementing this, we can draw inspiration from wenderson's create-alem-dapp which utilizes existing template git repositories (e.g. we could use app-template ) to initialize projects.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.