@finsweet/docs-theme

中文文档
0.1.8发布于 2023/03/14ISCES Module零依赖近 30 天下载 2846

Official docs starter template for Finsweet projects.

原始使用文档
文档目录15 节
  1. Reference
  2. Included tools
  3. Requirements
  4. Getting started
  5. Installing
  6. Building
  7. Serving files on development mode
  8. Building multiple files
  9. Setting up a path alias
  10. Testing
  11. Contributing guide
  12. Pre-defined scripts
  13. CI/CD
  14. Continuous Integration
  15. Continuous Deployment

Finsweet Developer Starter

A starter template for both Client & Power projects.

Before starting to work with this template, please take some time to read through the documentation.

Reference

Included tools

This template contains some preconfigured development tools:

  • Typescript: A superset of Javascript that adds an additional layer of Typings, bringing more security and efficiency to the written code.
  • Prettier: Code formatting that assures consistency across all Finsweet's projects.
  • ESLint: Code linting that enforces industries' best practices. It uses our own custom configuration to maintain consistency across all Finsweet's projects.
  • Playwright: Fast and reliable end-to-end testing.
  • esbuild: Javascript bundler that compiles, bundles and minifies the original Typescript files.
  • Changesets: A way to manage your versioning and changelogs.
  • Finsweet's TypeScript Utils: Some utilities to help you in your Webflow development.

Requirements

This template requires the use of pnpm. You can install pnpm with:

npm i -g pnpm

To enable automatic deployments to npm, please read the Continuous Deployment section.

Getting started

The quickest way to start developing a new project is by creating a new repository from this template.

Once the new repository has been created, update the package.json file with the correct information, specially the name of the package which has to be unique.

Installing

After creating the new repository, open it in your terminal and install the packages by running:

pnpm install

If this is the first time using Playwright and you want to use it in this project, you'll also have to install the browsers by running:

pnpm playwright install

You can read more about the use of Playwright in the Testing section.

It is also recommended that you install the following extensions in your VSCode editor:

Building

To build the files, you have two defined scripts:

  • pnpm dev: Builds and creates a local server that serves all files (check Serving files on development mode for more info).
  • pnpm build: Builds to the production directory (dist).

Serving files on development mode

When you run pnpm dev, two things happen:

  • esbuild is set to watch mode. Every time that you save your files, the project will be rebuilt.
  • A local server is created under http://localhost:3000 that serves all your project files. You can import them in your Webflow projects like:
<script defer src="http://localhost:3000/{FILE_PATH}.js"></script>
  • Live Reloading is enabled by default, meaning that every time you save a change in your files, the website you're working on will reload automatically. You can disable it in /bin/build.js.

Building multiple files

If you need to build multiple files into different outputs, you can do it by updating the build settings.

In bin/build.js, update the ENTRY_POINTS array with any files you'd like to build:

const entryPoints = [
  'src/home/index.ts',
  'src/contact/whatever.ts',
  'src/hooyah.ts',
  'src/home/other.ts',
];

This will tell esbuild to build all those files and output them in the dist folder for production and in http://localhost:3000 for development.

Setting up a path alias

Path aliases are very helpful to avoid code like:

import example from '../../../../utils/example';

Instead, we can create path aliases that map to a specific folder, so the code becomes cleaner like:

import example from '$utils/example';

You can set up path aliases using the paths setting in tsconfig.json. This template has an already predefined path as an example:

{
  "paths": {
    "$utils/*": ["src/utils/*"]
  }
}

To avoid any surprises, take some time to familiarize yourself with the tsconfig enabled flags.

Testing

As previously mentioned, this library has Playwright included as an automated testing tool.

All tests are located under the /tests folder. This template includes a test spec example that will help you catch up with Playwright.

After installing the dependencies, you can try it out by running pnpm test. Make sure you replace it with your own tests! Writing proper tests will help improve the maintainability and scalability of your project in the long term.

By default, Playwright will also run pnpm dev in the background while the tests are running, so your files served under localhost:3000 will run as usual. You can disable this behavior in the playwright.config.ts file.

If you project doesn't require any testing, you should disable the Tests job in the CI workflow by commenting it out in the .github/workflows/ci.yml file. This will prevent the tests from running when you open a Pull Request.

Contributing guide

In general, your development workflow should look like this:

  1. Create a new branch where to develop a new feature or bug fix.
  2. Once you've finished the implementation, create a Changeset (or multiple) explaining the changes that you've made in the codebase.
  3. Open a Pull Request and wait until the CI workflows finish. If something fails, please try to fix it before merging the PR. If you don't want to wait for the CI workflows to run on GitHub to know if something fails, it will be always faster to run them in your machine before opening a PR.
  4. Merge the Pull Request. The Changesets bot will automatically open a new PR with updates to the CHANGELOG.md, you should also merge that one. If you have automatic npm deployments enabled, Changesets will also publish this new version on npm.

If you need to work on several features before publishing a new version on npm, it is a good practise to create a development branch where to merge all the PR's before pushing your code to master.

Pre-defined scripts

This template contains a set of predefined scripts in the package.json file:

  • pnpm dev: Builds and creates a local server that serves all files (check Serving files on development mode for more info).
  • pnpm build: Builds to the production directory (dist).
  • pnpm lint: Scans the codebase with ESLint and Prettier to see if there are any errors.
  • pnpm lint:fix: Fixes all auto-fixable issues in ESLint.
  • pnpm check: Checks for TypeScript errors in the codebase.
  • pnpm format: Formats all the files in the codebase using Prettier. You probably won't need this script if you have automatic formatting on save active in your editor.
  • pnpm test: Will run all the tests that are located in the /tests folder.
  • pnpm test:headed: Will run all the tests that are located in the /tests folder visually in headed browsers.
  • pnpm release: This command is defined for Changesets. You don't have to interact with it.
  • pnpm run update: Scans the dependencies of the project and provides an interactive UI to select the ones that you want to update.

CI/CD

This template contains a set of helpers with proper CI/CD workflows.

Continuous Integration

When you open a Pull Request, a Continuous Integration workflow will run to:

  • Lint & check your code. It uses the pnpm lint and pnpm check commands under the hood.
  • Run the automated tests. It uses the pnpm test command under the hood.

If any of these jobs fail, you will get a warning in your Pull Request and should try to fix your code accordingly.

Note: If your project doesn't contain any defined tests in the /tests folder, you can skip the Tests workflow job by commenting it out in the .github/workflows/ci.yml file. This will significantly improve the workflow running times.

Continuous Deployment

Changesets allows us to generate automatic changelog updates when merging a Pull Request to the master branch.

To generate a new changelog, run:

pnpm changeset

You'll be prompted with a few questions to complete the changelog.

Once the Pull Request is merged into master, a new Pull Request will automatically be opened by a changesets bot that bumps the package version and updates the CHANGELOG.md file. You'll have to manually merge this new PR to complete the workflow.

If an NPM_TOKEN secret is included in the repository secrets, Changesets will automatically deploy the new package version to npm. Keep reading for more info about this.

How to automatically deploy updates to npm

As mentioned before, Changesets will automatically deploy the new package version to npm if an NPM_TOKEN secret is provided.

This npm token should be:

  • From Finsweet's npm organization if this repository is meant for internal/product development.
  • From a client's npm organization if this repository is meant for client development. In this case, you should ask the client to create an npm account and provide you the credentials (or the npm token, if they know how to get it).

Once you're logged into the npm account, you can get an access token by following this guide.

The access token must be then placed in a repository secret named NPM_TOKEN.

版本与发布记录

@finsweet/docs-theme 共发布 9 个版本,首次发布于 2023/02/23;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.8latest2023/03/143 年前
0.1.72023/03/093 年前
0.1.62023/03/093 年前
0.1.52023/02/283 年前
0.1.42023/02/253 年前
0.1.32023/02/253 年前

关于 @finsweet/docs-theme 的常见问题

@finsweet/docs-theme 是什么?

Official docs starter template for Finsweet projects.

如何安装 @finsweet/docs-theme?

在项目目录运行 npm install @finsweet/docs-theme,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:vue(^3.2.47)、vitepress(^1.0.0-alpha.49)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@finsweet/docs-theme 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/finsweet__docs-theme 是否存在。

@finsweet/docs-theme 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@finsweet/docs-theme 可以商用吗?

@finsweet/docs-theme 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@finsweet/docs-theme 的下载量有多少?

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

@finsweet/docs-theme 还在维护吗?

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