YAMLResume

CLI

YAMLResume 采用单仓库(mono-repo)结构,这意味着所有包都包含在单个仓库中。得益于 pnpm workspace,这种方法简化了包之间的依赖管理和版本控制。

在撰写本文时,YAMLResume 仓库有两个包:

yamlresume/core 构建

yamlresume/cli 依赖于 yamlresume/core 才能正常工作。因此,当您想要测试 yamlresume/cli 时,您需要确保 yamlresume/core 也已构建并可用。

您可以使用以下命令来做到这一点:

# build for dev purpose
pnpm core build

# build for production, which will minify the output and generate TypeScript
# DTS files `.d.ts`
pnpm core build:prod

# watch for file changes and build automatically
pnpm core build:watch

yamlresume/cli 构建

一旦 yamlresume/core 构建完成,您可以通过两种方式运行 CLI 命令:

  1. 本地构建 yamlresume/cli 并使用 dist/cli.js 运行 node.js:
pnpm cli build
node packages/cli/dist/cli.js <command> [options]
  1. 借助 tsx 直接运行 yamlresume/cli
pnpm cli dev <command> [options]

# this command will translate to
# tsx src/cli.ts

演示

yamlresume/core 构建:

$ pnpm core build

> @yamlresume/yamlresume@0.7.1 core /Users/hanyu/work/yamlresume/yamlresume
> pnpm --filter @yamlresume/core build

> @yamlresume/core@0.7.1 build /Users/hanyu/work/yamlresume/yamlresume/packages/core
> tsup

CLI Building entry: src/index.ts
CLI Using tsconfig: tsconfig.json
CLI tsup v8.4.0
CLI Using tsup config: /Users/hanyu/work/yamlresume/yamlresume/packages/core/tsup.config.ts
CLI Target: esnext
CLI Cleaning output folder
ESM Build start
ESM dist/index.js 160.91 KB
ESM ⚡️ Build success in 111ms

yamlresume/cli 构建:

$ pnpm cli build

> @yamlresume/yamlresume@0.7.1 cli /Users/hanyu/work/yamlresume/yamlresume
> pnpm --filter yamlresume build

> yamlresume@0.7.1 build /Users/hanyu/work/yamlresume/yamlresume/packages/cli
> tsup

CLI Building entry: src/cli.ts
CLI Using tsconfig: tsconfig.json
CLI tsup v8.4.0
CLI Using tsup config: /Users/hanyu/work/yamlresume/yamlresume/packages/cli/tsup.config.ts
CLI Target: esnext
CLI Cleaning output folder
ESM Build start
ESM dist/cli.js 11.36 KB
ESM ⚡️ Build success in 42ms

通过 pnpm cli dev 使用 tsx 测试 yamlresume/cli

$ pnpm cli dev help

> @yamlresume/yamlresume@0.7.1 cli /Users/hanyu/work/yamlresume/yamlresume
> pnpm --filter yamlresume dev help

> yamlresume@0.7.1 dev /Users/hanyu/work/yamlresume/yamlresume/packages/cli
> tsx src/cli.ts help

Usage: yamlresume [options] [command]

YAMLResume — Resume as Code in YAML

 __   __ _    __  __ _     ____
 \ \ / // \  |  \/  | |   |  _ \ ___  ___ _   _ ___  ___   ___
  \ V // _ \ | |\/| | |   | |_) / _ \/ __| | | / _ \/ _ \ / _ \
   | |/ ___ \| |  | | |___|  _ <  __/\__ \ |_| | | | | | |  __/
   |_/_/   \_\_|  |_|_____|_| \_\___||___/\____|_| |_| |_|\___|


Options:
  -V, --version                  output the version number
  -v, --verbose                  verbose output
  -h, --help                     display help for command

Commands:
  new [filename]                 create a new resume
  build [options] <resume-path>  build a resume to LaTeX and PDF
  dev [options] <resume-path>    build on file changes (watch mode)
  languages                      i18n and l10n support
  templates                      manage resume templates
  validate <resume-path>         validate a resume against the YAMLResume schema
  help [command]                 display help for command

使用 Node.js 测试 yamlresume/cli

$ node packages/cli/dist/cli.js -V
0.7.1
Edit on GitHub

Last updated on