@atomrigslab/aptos-wallet-adapter

中文文档
0.1.21发布于 2024/07/11TypeScriptESM + CJS近 30 天下载 1.9万

Scaffold TypeScript npm packages using this template to bootstrap your next library.

原始使用文档
文档目录8 节
  1. Getting Started
  2. Usage
  3. Development
  4. Local Development
  5. Project Development
  6. Development Cleanup
  7. Release Publishing
  8. Continuous Integration

Vite TypeScript NPM Package

Scaffold TypeScript npm packages using this template to bootstrap your next library.

[!TIP] Looking for a JavaScript version of this template? Try: Vite JavaScript NPM Package

Getting Started

Begin via any of the following:

  • Press the "Use this template" button

  • Use GitHub CLI to execute:

    gh repo create <name> --template="https://github.com/jasonsturges/vite-typescript-npm-package"
    
  • Simply git clone, delete the existing .git folder, and initialize a fresh repo:

    git clone https://github.com/jasonsturges/vite-typescript-npm-package.git
    cd vite-typescript-npm-package
    rm -rf .git
    git init
    git add -A
    git commit -m "Initial commit"
    

There is no package lock included so that you may chose either npm or yarn.

Remember to use npm search <term> to avoid naming conflicts in the NPM Registery for your new package name.

Usage

The following tasks are available:

  • dev: Run Vite in watch mode to detect changes - all modules are compiled to the dist/ folder, as well as rollup of all types to a d.ts declaration file
  • start: Run Vite in host mode to work in a local development environment within this package - vite hosts the index.html with real time HMR updates
  • build: Run Vite to build a production release distributable
  • build:types: Run DTS Generator to build d.ts type declarations only

Rollup all your exports to the top-level index.ts for inclusion into the build distributable.

For example, if you have a utils/ folder that contains an arrayUtils.ts file.

/src/utils/arrayUtils.ts:

export const distinct = <T>(array: T[] = []) => [...new Set(array)];

Include that export in the top-level index.ts .

/src/index.ts:

// Main library exports - these are packaged in your distributable
export { distinct } from "./utils/arrayUtils"

Development

There are multiple strategies for development, either working directly from the library or from a linked project.

Local Development

Vite features a host mode for development with real time HMR updates directly from the library via the start script. This enables rapid development within the library instead of linking from other projects.

Using the start task, Vite hosts the index.html for a local development environment. This file is not included in the production build. Note that only exports specified from the index.ts are ultimately bundled into the library.

As an example, this template includes a React app, which could be replaced with a different framework such as Vue, Solid.js, Svelte, etc...

For UI projects, you may want to consider adding tools such as Storybook to isolate UI component development by running a storybook script from this package.

Project Development

To use this library with other app projects before submitting to a registry such as NPM, run the dev script and link packages.

Using the dev task, Vite detects changes and compiles all modules to the dist/ folder, as well as rollup of all types to a d.ts declaration file.

To test your library from within an app:

  • From this library: run npm link or yarn link command to register the package
  • From your app: run npm link "mylib" or yarn link "mylib" command to use the library inside your app during development

Inside your app's node_modules/ folder, a symlink is created to the library.

Development Cleanup

Once development completes, unlink both your library and test app projects.

  • From your app: run npm unlink "mylib" or yarn unlink "mylib" command to remove the library symlink
  • From your library: run npm unlink or yarn unlink command to unregister the package

If you mistakenly forget to unlink, you can manually clean up artifacts from yarn or npm.

For yarn, the link command creates symlinks which can be deleted from your home directory:

~/.config/yarn/link

For npm, the link command creates global packages which can be removed by executing:

sudo npm rm --global "mylib"

Confirm your npm global packages with the command:

npm ls --global --depth 0

For your app, simply reinstall dependencies to clear any forgotten linked packages. This will remove any symlinks in the node_modules/ folder.

Release Publishing

Update your package.json to the next version number and tag a release.

Assure that your package lockfile is also updated by running an install. For npm, this will assure the lockfile has the updated version number. Yarn does not duplicate the version number in the lockfile.

If you are publishing to a private registry such as GitHub packages, update your package.json to include publishConfig and repository:

package.json:

  "publishConfig": {
    "registry": "https://npm.pkg.github.com/@MyOrg"
  },

Unless you are using a continuous integration service such as GitHub Actions, assure that your dist/ folder is cleanly build. Note that npm publish will ship anything inside the distributable folder.

For clean builds, you may want to install the rimraf package and add a clean or prebuild script to your package.json to remove any artifacts from your dist/ folder. Or, manually delete the dist/ folder yourself.

package.json:

  "scripts": {
    "clean": "rimraf dist"
  }

Before you submit for the first time, make sure your package name is available by using npm search. If npm rejects your package name, update your package.json and resubmit.

npm search <term>

Once ready to submit your package to the NPM Registry, execute the following tasks via npm (or yarn):

npm run build

Assure the proper npm login:

npm login

Submit your package to the registry:

npm publish --access public

Continuous Integration

For continuous integration with GitHub Actions, create a .github/workflows/publish.yml:

name: Publish Package to npmjs
on:
  release:
    types: [created]

jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '20'
          registry-url: 'https://registry.npmjs.org'
      - run: npm ci
      - run: npm run build
      - run: npm publish
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

This will deploy your build artifact when a release is tagged.

Obtain an "Automation" CI/CD access token to bypass 2FA from npm by selecting your profile image in the upper right, and chosing "Access Tokens".

To add secrets to your repository:

  • From your repository, select Settings
  • From the Security section of the sidebar, expand Secrets and variables and select Actions
  • From the Secrets tab, press New repository secret to add the NPM_TOKEN key

To add secrets to your organization:

  • From your organization, select Settings
  • From the Security section of the sidebar, expand Secrets and variables and select Actions
  • From the Secrets tab, press New organization secret to add the NPM_TOKEN key

Assure either a .npmrc or publishConfig in your package.json:

package.json:

  "publishConfig": {
    "access": "public",
    "registry": "https://registry.npmjs.org/",
    "scope": "username"
  },

For more information, see:

版本与发布记录

@atomrigslab/aptos-wallet-adapter 共发布 22 个版本,首次发布于 2024/04/16;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.21latest2024/07/112 年前
0.1.202024/07/092 年前
0.1.192024/07/022 年前
0.1.182024/07/012 年前
0.1.172024/07/012 年前
0.1.162024/07/012 年前

关于 @atomrigslab/aptos-wallet-adapter 的常见问题

@atomrigslab/aptos-wallet-adapter 是什么?

Scaffold TypeScript npm packages using this template to bootstrap your next library.

如何安装 @atomrigslab/aptos-wallet-adapter?

在项目目录运行 npm install @atomrigslab/aptos-wallet-adapter,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@aptos-labs/ts-sdk(^1.9.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@atomrigslab/aptos-wallet-adapter 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@atomrigslab/aptos-wallet-adapter 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@atomrigslab/aptos-wallet-adapter 可以商用吗?

@atomrigslab/aptos-wallet-adapter 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@atomrigslab/aptos-wallet-adapter 的下载量有多少?

根据 npm 官方下载统计,@atomrigslab/aptos-wallet-adapter 在 2026/10/07 – 2026/11/05 这 30 天内被下载 19,322 次,日均约 644 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@atomrigslab/aptos-wallet-adapter 还在维护吗?

最新版本 0.1.21 发布于 2024/07/11(2 年前);至今共发布 22 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/04/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。