Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial typescript support #468

Merged
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e8d0e3d
initial typescript support (need to adjust github action)
Tguntenaar Nov 14, 2023
9d34288
fix: replace strings before bos-loader is called
Tguntenaar Nov 16, 2023
ed13d73
remove dist
Tguntenaar Nov 16, 2023
212141b
refac Tag to transpile to MainComponent
Tguntenaar Nov 16, 2023
cc3f945
change transpiledPathPrefix to build/src
Tguntenaar Nov 16, 2023
31fd311
rename BaseProps to DevHubBaseProps
Tguntenaar Nov 16, 2023
3f85dc2
transpile to build/src
Tguntenaar Nov 16, 2023
b389bee
change REPL_DEVHUB_CONTRACT replacement back to devgovgigs.near
Tguntenaar Nov 16, 2023
0fef9cc
wip: move replacements to js script and out of dev.sh (mac only) and …
Tguntenaar Nov 16, 2023
ff0d9cc
Merge branch 'main' of github.com:Tguntenaar/neardevhub-widgets into …
Tguntenaar Nov 19, 2023
7402aa4
lint
Tguntenaar Nov 19, 2023
7055b67
refac: remove include from history
Tguntenaar Nov 19, 2023
1a3095f
refac: remove INCLUDE: and add autocomplete module
Tguntenaar Nov 19, 2023
6cd31b9
remove: unused legacy include.js
Tguntenaar Nov 19, 2023
f7e935c
fix: deploy bos components from ./build working directory
Tguntenaar Nov 19, 2023
8401e47
feat: add watchman to build files on change
Tguntenaar Nov 19, 2023
c3a9b3e
remove node package fb-watchman
Tguntenaar Nov 19, 2023
61d8515
fix: pipeline test issue caused by watchman
Tguntenaar Nov 19, 2023
bdb785a
fix: move to watchman nodejs client
Tguntenaar Nov 20, 2023
5a8bb5f
fix: instead of MainC.. use funcName after transpile
Tguntenaar Nov 20, 2023
6b331b8
remove old comments
Tguntenaar Nov 20, 2023
f1dbdd3
remove unused SIGNER_ID
Tguntenaar Nov 20, 2023
d994616
added default account_id
Tguntenaar Nov 20, 2023
8ad6eb4
fix: removed cause generated neardevhub-widgets
Tguntenaar Nov 22, 2023
cd02863
fix: buggy behaviour
Tguntenaar Nov 22, 2023
6e18f6f
change CONTRIBUTING.md
Tguntenaar Nov 22, 2023
b16ed99
Merge branch 'main' into feature/456-move-to-typescript
Tguntenaar Nov 23, 2023
9124104
changed: use watcher instead of fb-watchman
Tguntenaar Dec 5, 2023
627e815
remove fb-watch commands
Tguntenaar Dec 11, 2023
38b8f33
added options to watch
Tguntenaar Dec 12, 2023
f632786
blocked, running npm run watch from dev.sh rebuilds too often
Tguntenaar Dec 12, 2023
b1234fb
Merge branch 'main' of github.com:near/neardevhub-widgets into featur…
Tguntenaar Dec 12, 2023
d3ddfb8
feat: trap bos-loader and run watch parallel
Tguntenaar Dec 13, 2023
0e1b8b6
update: contribution.md on the dev process
Tguntenaar Dec 13, 2023
4daba20
remove watchmanconfig
Tguntenaar Dec 13, 2023
ffd8467
Merge branch 'main' of github.com:near/neardevhub-widgets into featur…
Tguntenaar Dec 18, 2023
5d4f9fb
Update CONTRIBUTING.md zsh -> sh
Tguntenaar Dec 18, 2023
d040a65
Merge branch 'main' of github.com:near/neardevhub-widgets into featur…
Tguntenaar Dec 21, 2023
be0e662
update import statement
Tguntenaar Dec 21, 2023
01969d3
edit the CONTRIBUTING deploy preview steps
Tguntenaar Dec 21, 2023
9e1fb7c
Merge branch 'main' into feature/456-move-to-typescript
Tguntenaar Dec 29, 2023
ced9056
Merge branch 'main' of github.com:near/neardevhub-widgets into featur…
Tguntenaar Jan 4, 2024
e5559cd
fmt
Tguntenaar Jan 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions .github/workflows/deploy-dev-testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,19 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set replacements
id: set_replacements
run: |
echo "replacements=$(jq -r '[to_entries[] | .["find"] = "${" + .key + "}" | .["replace"] = .value | del(.key, .value)]' replacements.dev.json | tr -d "\n\r")" >> $GITHUB_OUTPUT

- name: Replace placeholders
uses: flcdrg/replace-multiple-action@v1
- name: Set up node
uses: actions/setup-node@v3
with:
files: '**/*.jsx'
find: '${{ steps.set_replacements.outputs.replacements }}'
prefix: '(^|.*)'
suffix: '($|.*)'
node-version: 20
cache: "npm"
- run: npm run build

- name: Install bos CLI
run: |
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/FroVolod/bos-cli-rs/releases/download/v0.3.2/bos-cli-installer.sh | sh

- name: Deploy widgets
working-directory: ./build
run: |
which bos
echo $PATH
Expand Down
17 changes: 6 additions & 11 deletions .github/workflows/deploy-prod-mainnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,18 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set replacements
id: set_replacements
run: |
echo "replacements=$(jq -r '[to_entries[] | .["find"] = "${" + .key + "}" | .["replace"] = .value | del(.key, .value)]' replacements.mainnet.json | tr -d "\n\r")" >> $GITHUB_OUTPUT

- name: Replace placeholders
uses: flcdrg/replace-multiple-action@v1
- name: Set up node
uses: actions/setup-node@v3
with:
files: "**/*.jsx"
find: "${{ steps.set_replacements.outputs.replacements }}"
prefix: "(^|.*)"
suffix: "($|.*)"
node-version: 20
cache: "npm"
- run: npm run build

- name: Install bos CLI
run: |
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/FroVolod/bos-cli-rs/releases/download/v0.3.6/bos-cli-installer.sh | sh

- name: Deploy widgets
working-directory: ./build
run: |
bos components deploy "$NEAR_SOCIAL_DEPLOY_ID" sign-as "$NEAR_SOCIAL_ACCOUNT_ID" network-config mainnet sign-with-plaintext-private-key --signer-public-key "$NEAR_SOCIAL_ACCOUNT_PUBLIC_KEY" --signer-private-key "$NEAR_SOCIAL_ACCOUNT_PRIVATE_KEY" send
35 changes: 26 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Contribution Guidelines for DevHub Repos

## Introduction

At DevHub, we value the contributions of each individual. This document provides an overview of the developer setup and deployment process to help you contribute to our project. We also recommend familiarizing yourself with [how we work](https://github.com/near/devgigsboard-widgets/blob/main/docs/how-we-work.md) to learn about our development process and enhance your contribution experience.

## Developer Setup
Expand Down Expand Up @@ -28,12 +29,26 @@ npm install

#### Run the dev script

To initiate the development environment, you can use the following script. This script will first check if bos-loader is installed and, if not, install it. Then, it will serve the default development environment.
To initiate the development environment, you can use the following script. This script will first check if bos-loader is installed and, if not, install it. Then, it will serve the default development environment and watch for changes inside `./src`.

```sh
```zsh
Tguntenaar marked this conversation as resolved.
Show resolved Hide resolved
npm run dev
```

This runs the bos-loader and the watcher together. You can also run testnet by running:

```zsh
npm run dev:testnet
```

While testing the testnet, it's necessary to manually execute the watch script yourself to ensure that changes to files trigger the rebuilding process.

Open another terminal and run:

```zsh
npm run watch
```

#### Customizing Creator ID, Contract ID, or Network

If you need to customize the account ID, override the contract ID, or specify a different network for your development environment, you can use the following flags:
Expand All @@ -44,24 +59,26 @@ If you need to customize the account ID, override the contract ID, or specify a

Here's how you can use these flags:

> [!IMPORTANT]
> You will have to change the replace script flags in package.json in order for the watch script to keep using the right flags.

```sh
npm run dev -a your_account_id -c your_contract_id -n your_network
npm run replace -a your_account_id -c your_contract_id -n your_network
```

For example:

```sh
npm run dev -a bob.near -c contract.bobs.near -n mainnet
npm run replace -a bob.near -c contract.bobs.near -n mainnet
```

By using these flags, you have the flexibility to customize the development environment according to your specific needs.


#### Developing across multiple environments

When referencing a component or any parameter that depends on the network, please use the placeholders defined in replacements.*.json. There are three such files that correspond to different environments:
When referencing a component or any parameter that depends on the network, please use the placeholders defined in replacements.\*.json. There are three such files that correspond to different environments:

`replacements.dev.json` - deploys the develop branch, to testnet @ test.beta.near.org
`replacements.dev.json` - deploys the develop branch, to testnet @ test.beta.near.org

`replacements.testnet.json` - deploys main branch, to testnet @ test.near.org

Expand Down Expand Up @@ -123,6 +140,7 @@ There is GitHub Actions automation that deploys all the widgets to [`devgovgigs.
Thus, once a PR is merged, you should see the new version of the widgets on [DevHub](https://neardevhub.org) in less than 15 seconds.

### Before Publishing

Before publishing, make sure that you’ve go through this section.

#### Code Style and Formatting
Expand All @@ -139,7 +157,6 @@ We use [Playwright](https://playwright.dev) for tests, which are located in the

See the [test-pipeline](./.github/workflows/continuous-integration-workflow.yml) for what dependencies that needs to be installed on your workstation for tests to run.


#### Making Changes to common.jsx

The `common.jsx` file contains a set of shared utilities that are often reused in DevHub widgets. When you need to change it, just edit the file in the root of the project, and update the widgets with this one command:
Expand All @@ -156,4 +173,4 @@ Sometimes there is a need to deposit extra tokens to cover the widgets’ storag
bos social-db prepaid-storage deposit
```

NOTE: `bos` CLI will interactively ask all the rest of the details to prepare the transaction.
NOTE: `bos` CLI will interactively ask all the rest of the details to prepare the transaction.
21 changes: 21 additions & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
declare interface BosContext {
accountId?: string;
networkId: NetworkId;
props: object;
}

declare const Widget: (params: {
src: string;
props: object;
}) => React.ReactNode;

declare interface DevHubBaseProps {
page: any;
}

declare var styled = {
div,
a,
ul,
span,
};
46 changes: 0 additions & 46 deletions module/include.js

This file was deleted.

Loading