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

pnpm #317

Merged
merged 11 commits into from
Dec 5, 2022
Merged

pnpm #317

Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = {
},
],
ignorePatterns: [
"pnpm-lock.yaml",
"./**/node_modules",
"node_modules",
"./**/lib",
Expand Down
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
yarn.lock linguist-generated=true -diff
pnpm-lock.yaml linguist-generated=true -diff
lib/**/*.js linguist-generated=true -diff
lib/**/*.d.ts linguist-generated=true -diff
near-contract-standards/lib/**/*.js linguist-generated=true -diff
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,19 @@ jobs:
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Setup pnpm
uses: pnpm/action-setup@v2.2.2
with:
node-version: "16"
version: 7
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: pnpm
- name: Install modules
run: yarn
run: pnpm install
- name: Run build
run: yarn build
run: pnpm build
- name: Run git status
run: git status
- name: check build is included in branch
Expand Down
40 changes: 23 additions & 17 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,42 @@ jobs:
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Setup pnpm
uses: pnpm/action-setup@v2.2.2
with:
node-version: "16"
version: 7
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: pnpm
- name: Install dependencies
run: yarn && cd examples && yarn
run: pnpm install && cd examples && pnpm install
- name: clean-state
run: cd examples && yarn build:clean-state && yarn test:clean-state
run: cd examples && pnpm build:clean-state && pnpm test:clean-state
- name: counter
run: cd examples && yarn build:counter && yarn test:counter
run: cd examples && pnpm build:counter && pnpm test:counter
- name: counter-lowlevel
run: cd examples && yarn build:counter-lowlevel && yarn test:counter-lowlevel
run: cd examples && pnpm build:counter-lowlevel && pnpm test:counter-lowlevel
- name: counter-ts
run: cd examples && yarn build:counter-ts && yarn test:counter-ts
run: cd examples && pnpm build:counter-ts && pnpm test:counter-ts
- name: cross-contract-call
run: cd examples && yarn build:cross-contract-call && yarn test:cross-contract-call
run: cd examples && pnpm build:cross-contract-call && pnpm test:cross-contract-call
- name: fungible-token-lockable
run: cd examples && yarn build:fungible-token-lockable && yarn test:fungible-token-lockable
run: cd examples && pnpm build:fungible-token-lockable && pnpm test:fungible-token-lockable
- name: fungible-token
run: cd examples && yarn build:fungible-token && yarn test:fungible-token
run: cd examples && pnpm build:fungible-token && pnpm test:fungible-token
- name: non-fungible-token
run: cd examples && yarn build:non-fungible-token && yarn test:non-fungible-token
run: cd examples && pnpm build:non-fungible-token && pnpm test:non-fungible-token
- name: status-message-collections
run: cd examples && yarn build:status-message-collections && yarn test:status-message-collections
run: cd examples && pnpm build:status-message-collections && pnpm test:status-message-collections
- name: status-message
run: cd examples && yarn build:status-message && yarn test:status-message
run: cd examples && pnpm build:status-message && pnpm test:status-message
- name: parking-lot
run: cd examples && yarn build:parking-lot && yarn test:parking-lot
run: cd examples && pnpm build:parking-lot && pnpm test:parking-lot
- name: standard nft
run: cd examples && yarn build-nft && yarn test:nft
run: cd examples && pnpm build-nft && pnpm test:nft
- name: programmatic-update
run: cd examples && yarn build:programmatic-update && yarn test:programmatic-update
run: cd examples && pnpm build:programmatic-update && pnpm test:programmatic-update
- name: cross-contract-call-loop
run: cd examples && yarn build:cross-contract-call-loop && yarn test:cross-contract-call-loop
run: cd examples && pnpm build:cross-contract-call-loop && pnpm test:cross-contract-call-loop
15 changes: 10 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,21 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
- name: Setup pnpm
uses: pnpm/action-setup@v2.2.2
with:
version: 7
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "16"
node-version: 16.x
cache: pnpm
- name: Install modules
run: yarn
run: pnpm install
- name: Run lint
run: yarn lint
run: pnpm lint
- name: Format code
run: yarn format
run: pnpm format
- name: Run git status
run: git status
- name: Check that lints where commited
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: "16"
- name: Install modules
run: yarn
- name: Setup pnpm
uses: pnpm/action-setup@v2.2.2
with:
version: 7
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: pnpm
- name: Run unit tests
run: yarn test:unit
run: pnpm test:unit
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
node_modules
yarn-error.log
vendor
.idea
deps
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ build
node_modules
lib
cli
pnpm-lock.yaml

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ There are a couple of contract examples in the project:
- [Status message board with unique messages](https://github.com/near/near-sdk-js/tree/develop/examples/src/status-message-collections.js)
- [Programmatic Update After Locking The Contract](https://github.com/near/near-sdk-js/tree/develop/examples/src/programmatic-update.js)

To build all examples, run `yarn build` in `examples/`. To test all examples, run `yarn test`. You can also build and test one specific example with `yarn build:<example-name>` and `yarn test:<example-name>`, see `examples/package.json`.
To build all examples, run `pnpm build` in `examples/`. To test all examples, run `pnpm test`. You can also build and test one specific example with `pnpm build:<example-name>` and `pnpm test:<example-name>`, see `examples/package.json`.

To deploy and call a contract on a NEAR node, use near-cli's `near deploy` and `near call`.

Expand Down Expand Up @@ -75,7 +75,7 @@ To use nightly host functions, such as `altBn128G1Sum`, your contract need to be

```
export NEAR_NIGHTLY=1
yarn build
pnpm build
```

### About Type
Expand Down
11 changes: 11 additions & 0 deletions TOOLING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Tooling

This document describes at a high level some the key tools used across `near-js`.

## Package Manager - [PNPM](https://pnpm.io/)

PNPM is a package manager focused on fast installations while still being disk efficient. It manages dependency installations across the monorepo as well as linking interdependent packages. Unlike other package managers, PNPM creates a non-flat `node_modules` structure which ensures packages only have access to dependencies defined in their `package.json`.

## Automation - [GitHub Actions](https://github.com/features/actions)

Github Actions is used to automate various tasks including PR checks (linting, type checks, and tests).
10 changes: 5 additions & 5 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"type": "module",
"scripts": {
"postinstall": "cd .. && yarn link && cd examples && yarn link near-sdk-js",
"postinstall": "pnpm link --global near-sdk-js",
"build": "run-s build:*",
"build:status-message": "near-sdk-js build src/status-message.js build/status-message.wasm",
"build:clean-state": "near-sdk-js build src/clean-state.js build/clean-state.wasm",
Expand All @@ -25,7 +25,7 @@
"build:nft-contract": "near-sdk-js build src/standard-nft/my-nft.ts build/my-nft.wasm",
"build:nft-receiver": "near-sdk-js build src/standard-nft/test-token-receiver.ts build/nft-receiver.wasm",
"build:nft-approval-receiver": "near-sdk-js build src/standard-nft/test-approval-receiver.ts build/nft-approval-receiver.wasm",
"test": "ava && yarn test:counter-lowlevel && yarn test:counter-ts",
"test": "ava && pnpm test:counter-lowlevel && pnpm test:counter-ts",
"test:nft": "ava __tests__/standard-nft/*",
"test:status-message": "ava __tests__/test-status-message.ava.js",
"test:clean-state": "ava __tests__/test-clean-state.ava.js",
Expand All @@ -46,14 +46,14 @@
"license": "Apache-2.0",
"dependencies": {
"lodash-es": "^4.17.21",
"near-sdk-js": "file:../",
"near-contract-standards": "file:../near-contract-standards/"
"near-contract-standards": "file:../near-contract-standards/",
"near-sdk-js": "^0.6.0",
"typescript": "^4.7.4"
},
"devDependencies": {
"@types/lodash-es": "^4.17.6",
"ava": "^4.2.0",
"near-workspaces": "3.2.1",
"typescript": "^4.7.4",
"npm-run-all": "^4.1.5"
}
}
Loading