Skip to content

Replace yarn with pnpm as package manager #893

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ labels: 🐛 Bug Report, 🔍 Needs Triage
| ---------------- | ---------- |
| `magic-sdk` |
| Browser |
| `yarn` |
| `pnpm` |
| Operating System |
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ labels: ❓Question
| ---------------- | ---------- |
| `magic-sdk` |
| Browser |
| `yarn` |
| `pnpm` |
| Operating System |
16 changes: 8 additions & 8 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 22
cache: 'yarn'
cache: 'pnpm'

- name: Install dependencies
run: |
yarn -v
yarn install --immutable
pnpm -v
pnpm install

- name: Build
run: yarn build
run: pnpm build

- name: Upload Build Results
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -61,12 +61,12 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 22
cache: 'yarn'
cache: 'pnpm'

- name: Install dependencies
run: |
yarn -v
yarn install --immutable
pnpm -v
pnpm install

- name: Download Build Results
uses: actions/download-artifact@v4
Expand All @@ -75,4 +75,4 @@ jobs:
path: packages

- name: Create Canary Release
run: yarn auto canary -v
run: pnpm exec auto canary -v
24 changes: 12 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,29 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 22
cache: 'yarn'
cache: 'pnpm'

- name: Install dependencies
run: |
yarn -v
yarn install --immutable
pnpm -v
pnpm install

- name: Apply semver updates (if any)
run: |
if yarn auto version; then
AUTO_VERSION=$(yarn auto version)
if pnpm exec auto version; then
AUTO_VERSION=$(pnpm exec auto version)
echo "Auto Version: $AUTO_VERSION"
if [[ $AUTO_VERSION == pre* ]]; then
yarn lerna version "$AUTO_VERSION" --no-git-tag-version --no-push --yes --preid "$GITHUB_REF"
pnpm exec lerna version "$AUTO_VERSION" --no-git-tag-version --no-push --yes --preid "$GITHUB_REF"
elif [[ $AUTO_VERSION ]]; then
yarn lerna version "$AUTO_VERSION" --no-git-tag-version --no-push --yes
pnpm exec lerna version "$AUTO_VERSION" --no-git-tag-version --no-push --yes
fi
else
echo "Unable to bump version successfully." && exit 1
fi

- name: Build
run: yarn build
run: pnpm build

- name: Upload Build Results
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -81,12 +81,12 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 22
cache: 'yarn'
cache: 'pnpm'

- name: Install dependencies
run: |
yarn -v
yarn install --immutable
pnpm -v
pnpm install

- name: Download Build Results
uses: actions/download-artifact@v4
Expand All @@ -95,4 +95,4 @@ jobs:
path: packages

- name: Create Release
run: yarn auto shipit -vv
run: pnpm exec auto shipit -vv
22 changes: 11 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 22
cache: 'yarn'
cache: 'pnpm'
- run: |
yarn -v
yarn
pnpm -v
pnpm install

- name: Lint
run: |
yarn run build
yarn run lint
pnpm run build
pnpm run lint

- name: Audit Production Dependencies
run: yarn audit --groups dependencies || true
run: pnpm audit --no-frozen-lockfile || true

test:
runs-on: ubuntu-22.04
Expand All @@ -48,12 +48,12 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: 22
cache: 'yarn'
cache: 'pnpm'
- run: |
yarn -v
yarn
pnpm -v
pnpm install

- name: Test
run: |
yarn build
yarn run test
pnpm build
pnpm run test
11 changes: 3 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,12 @@
/**/coverage
/**/.nyc_output

# We use Yarn
# We use pnpm
/package-lock.json
/**/package-lock.json
/**/yarn-error.log
.yarn/*
!.yarn/patches
!.yarn/releases
!.yarn/plugins
!.yarn/sdks
!.yarn/versions
.pnp.*
.pnpm-store/
pnpm-debug.log

# Output files
/**/dist
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
yarn wsrun:all --concurrency 1 --changedSince HEAD -c lint-staged
pnpm wsrun:all --concurrency 1 --changedSince HEAD -c lint-staged
28 changes: 0 additions & 28 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

This file was deleted.

874 changes: 0 additions & 874 deletions .yarn/releases/yarn-3.6.0.cjs

This file was deleted.

9 changes: 0 additions & 9 deletions .yarnrc.yml

This file was deleted.

4 changes: 2 additions & 2 deletions BUILD_SYSTEM.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This monorepo implements a custom build system using a combination of tools:

- [Yarn](https://yarnpkg.com) (for dependency management)
- [pnpm](https://pnpm.io) (for dependency management)
- [`wsrun`](https://github.com/hfour/wsrun) (for running workspace scripts)
- [ESBuild](https://esbuild.github.io) (for transpilation, minification, and bundling of source codes)
- [TypeScript](https://www.typescriptlang.org) (for static typing)
Expand Down Expand Up @@ -135,5 +135,5 @@ Monorepos tend to require lots of same-y boilerplate. The most common boilerplat
Simply run the following command, then answer a few interactive prompts:

```zsh
yarn scaffold
pnpm scaffold
```
18 changes: 9 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Please note we have a **code of conduct**, please follow it in all your interact
- For features: `feature/[package_name]/[issue_number]/[descriptive_feature_name]`
- For chores/the rest: `chore/[package_name]/[descriptive_chore_name]`

4. Install & hoist dependencies with Yarn + Lerna: `yarn install`
4. Install & hoist dependencies with pnpm: `pnpm install`
5. Add `./node_modules/.bin` to your system's [`PATH`](https://en.wikipedia.org/wiki/PATH_(variable)), if it's not already listed.
6. Start building for development: `yarn build`
6. Start building for development: `pnpm build`

> Note: There is no hot-reloading development script for now (which sucks, I know). Recently, the build system in Magic JS SDK changed to use a bundler as opposed to delivering TSC-transpiled files. This has complicated the matter of serving a development-specific flow. We will revisit this problem in the future.

Expand All @@ -43,13 +43,13 @@ To ensure ESLint is able to properly lint source files in your VS Code developme

| NPM Script | Usage | Description |
| ---------- | ----- | ----------- |
| `wsrun` | `PKG=$PACKAGE_TARGET yarn wsrun` | Execute arbitrary scripts via `wsrun` for the specified package, or interactively select a package if `$PKG` is omitted. |
| `wsrun:all` | `yarn wsrun` | Execute arbitrary scripts via `wsrun` for all packages in the monorepo (same as `PKG=* yarn wsrun ...`). |
| `dev` | `PKG=$PACKAGE_TARGET yarn dev` | Build the specified package with a hot-reloading dev server, or interactively select a package if `$PKG` is omitted. |
| `build` | `PKG=$PACKAGE_TARGET yarn build` | Build the specified package for production, or interactively select a package if `$PKG` is omitted. |
| `clean` | `PKG=$PACKAGE_TARGET yarn clean` | Run cleaning scripts for the specified package, or interactively select a package if `$PKG` is omitted. Available flags: (`--cache`, `--test-artifacts`, `--deps`) |
| `lint` | `PKG=$PACKAGE_TARGET yarn lint` | Run the linter for the specified package, or interactively select a package if `$PKG` is omitted. |
| `test` | `PKG=$PACKAGE_TARGET yarn test` | Run tests for the specified package, or interactively select a package if `$PKG` is omitted. |
| `wsrun` | `PKG=$PACKAGE_TARGET pnpm wsrun` | Execute arbitrary scripts via `wsrun` for the specified package, or interactively select a package if `$PKG` is omitted. |
| `wsrun:all` | `pnpm wsrun` | Execute arbitrary scripts via `wsrun` for all packages in the monorepo (same as `PKG=* pnpm wsrun ...`). |
| `dev` | `PKG=$PACKAGE_TARGET pnpm dev` | Build the specified package with a hot-reloading dev server, or interactively select a package if `$PKG` is omitted. |
| `build` | `PKG=$PACKAGE_TARGET pnpm build` | Build the specified package for production, or interactively select a package if `$PKG` is omitted. |
| `clean` | `PKG=$PACKAGE_TARGET pnpm clean` | Run cleaning scripts for the specified package, or interactively select a package if `$PKG` is omitted. Available flags: (`--cache`, `--test-artifacts`, `--deps`) |
| `lint` | `PKG=$PACKAGE_TARGET pnpm lint` | Run the linter for the specified package, or interactively select a package if `$PKG` is omitted. |
| `test` | `PKG=$PACKAGE_TARGET pnpm test` | Run tests for the specified package, or interactively select a package if `$PKG` is omitted. |

## Opening a Pull Request

Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ npm install --save magic-sdk # If you're targeting web browsers
npm install --save @magic-sdk/react-native-bare # If you're targeting Bare React Native
npm install --save @magic-sdk/react-native-expo # If you're targeting Expo React Native

# Via Yarn:
yarn add magic-sdk # If you're targeting web browsers
yarn add @magic-sdk/react-native-bare # If you're targeting Bare React Native
yarn add @magic-sdk/react-native-expo # If you're targeting Expo React Native
# Via pnpm:
pnpm add magic-sdk # If you're targeting web browsers
pnpm add @magic-sdk/react-native-bare # If you're targeting Bare React Native
pnpm add @magic-sdk/react-native-expo # If you're targeting Expo React Native
```

Alternatively, you can load via CDN by adding a script tag to your app’s `<head>`:
Expand Down Expand Up @@ -97,19 +97,19 @@ These are packages Magic JS SDK uses internally to work seamlessly across platfo
Run tests for all packages

```bash
yarn test
pnpm test
```

Test an individual package

```bash
PKG=magic-sdk yarn test
PKG=@magic-sdk/react-native-bare yarn test
PKG=@magic-sdk/react-native-expo yarn test
PKG=magic-sdk pnpm test
PKG=@magic-sdk/react-native-bare pnpm test
PKG=@magic-sdk/react-native-expo pnpm test
```

Test specific files

```bash
yarn test /test/**/constructor.spec.ts
pnpm test /test/**/constructor.spec.ts
```
14 changes: 14 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Jest configuration for React Native packages
* This helps address environment configuration issues when running with pnpm
*/
module.exports = {
testEnvironment: 'node',
transform: {
'^.+\\.(ts|tsx)$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
testEnvironmentOptions: {
url: 'http://localhost/'
}
};
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,8 @@
"released"
]
},
"packageManager": "yarn@3.6.0"
"packageManager": "pnpm@9.15.1",
"dependencies": {
"magic-sdk": "^29.0.5"
}
}
2 changes: 0 additions & 2 deletions packages/@magic-ext/aptos/src/MagicAptosWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,11 @@ export class MagicAptosWallet implements AdapterPlugin {
}

async onNetworkChange(callback: any): Promise<void> {
console.warn('onNetworkChange is not supported');
callback();
return Promise.resolve();
}

async onAccountChange(callback: any): Promise<void> {
console.warn('onAccountChange is not supported');
callback();
return Promise.resolve();
}
Expand Down
4 changes: 2 additions & 2 deletions packages/@magic-ext/oauth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ Integrating your app with OAuth will require our client-side NPM package and OAu
# Via NPM:
npm install --save magic-sdk @magic-ext/oauth

# Via Yarn:
yarn add magic-sdk @magic-ext/oauth
# Via pnpm:
pnpm add magic-sdk @magic-ext/oauth
```

Alternatively, you can load via CDN with by adding a script tag to your app’s `<head>`:
Expand Down
4 changes: 2 additions & 2 deletions packages/@magic-ext/oauth2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Integrating your app with OAuth will require our client-side NPM package and OAu
# Via NPM:
npm install --save magic-sdk @magic-ext/oauth2

# Via Yarn:
yarn add magic-sdk @magic-ext/oauth2
# Via pnpm:
pnpm add magic-sdk @magic-ext/oauth2
```

Alternatively, you can load via CDN with by adding a script tag to your app’s `<head>`:
Expand Down
4 changes: 2 additions & 2 deletions packages/@magic-ext/oauth2/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ export class OAuthExtension extends Extension.Internal<'oauth2'> {

await this.request<string | null>(requestPayload);
} catch (verificationError) {
console.log('Error while verifying telegram data', verificationError);
// Silent error when verifying telegram data
}
};
} catch (seamlessLoginError) {
console.log('Error while loading telegram-web-app script', seamlessLoginError);
// Silent error when loading telegram-web-app script
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/@magic-ext/oidc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Integrating your app with Magic will require our client-side NPM package and the
# Via NPM:
npm install --save magic-sdk @magic-ext/oidc

# Via Yarn:
yarn add magic-sdk @magic-ext/oidc
# Via pnpm:
pnpm add magic-sdk @magic-ext/oidc
```

Alternatively, you can load via CDN with by adding a script tag to your app’s `<head>`:
Expand Down
4 changes: 2 additions & 2 deletions packages/@magic-ext/react-native-bare-oauth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ Integrating your app with OAuth will require our client-side NPM package and OAu
# Via NPM:
npm install --save @magic-ext/react-native-bare-oauth

# Via Yarn:
yarn add @magic-ext/react-native-bare-oauth
# Via pnpm:
pnpm add @magic-ext/react-native-bare-oauth
```
### ⚠️ This library can only be used on a bare react native project that uses [@magic-sdk/react-native-bare](https://github.com/magiclabs/magic-js/tree/master/packages/%40magic-sdk/react-native-bare).

Expand Down
4 changes: 2 additions & 2 deletions packages/@magic-ext/react-native-expo-oauth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ Integrating your app with OAuth will require our client-side NPM package and OAu
# Via NPM:
npm install --save @magic-ext/react-native-expo-oauth

# Via Yarn:
yarn add @magic-ext/react-native-expo-oauth
# Via pnpm:
pnpm add @magic-ext/react-native-expo-oauth
```
### ⚠️ This library can only be used on an Expo project that uses [@magic-sdk/react-native-expo](https://github.com/magiclabs/magic-js/tree/master/packages/%40magic-sdk/react-native-expo).

Expand Down
Loading