패키지, 저장소 및 앱 카테고리 검색

패키지 상세v6.0.2

peanut

Dart 웹 앱의 컴파일된 출력으로 GitHub gh-pages 브랜치를 업데이트합니다. 'pub build' 및 새로운 'pub run build_runner'을 지원합니다.

macOSWindowsLinux
30일 다운로드
2.3천
좋아요
139
Pub 점수
150

패키지 설치

flutter pub add peanut

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Peanut은 컴파일된 웹 앱 출력물을 GitHub의 gh-pages 브랜치에 자동으로 배포하는 Dart 패키지입니다. 전통적인 'pub build'와 현대적인 'pub run build_runner' 워크플로우를 모두 지원하며, Flutter 웹 애플리케이션의 게시 프로세스를 간소화합니다. GitHub Pages에서 웹 앱을 호스팅하고자 하는 개발자를 위해 설계되었으며, 최소한의 구성으로 빌드 및 푸시 단계를 처리합니다. macOS, Windows, Linux 환경에서 CI/CD 파이프라인 또는 로컬 개발 환경과 원활하게 통합됩니다.

사용 사례

  • Flutter 웹 앱을 GitHub Pages에 배포하기
  • 빌드 및 배포 자동화
  • CI/CD 워크플로우와의 통합
  • Dart 프로젝트에서 정적 웹 콘텐츠 게시하기
  • 빌드 후 gh-pages 업데이트 간소화

주요 기능

  • pub build 및 build_runner를 지원합니다
  • git push를 gh-pages로 자동화
  • 크로스 플랫폼 호환성
  • 최소한의 설정 필요
  • Flutter 웹 앱과 호환됩니다

적합한 대상

  • Flutter 웹 개발자
  • GitHub Pages 사용자
  • CI/CD 자동화
  • Dart 프로젝트 유지보수자
  • 간단한 배포를 원하는 개발자

고려 사항

  • GitHub 리포지토리 접근 권한이 필요합니다
  • 올바른 git 자격 증명을 구성해야 합니다
  • GitHub 외 호스팅에는 적합하지 않습니다
  • 현대적인 워크플로우를 위해 build_runner에 의존합니다
  • 환경에 따라 설정이 필요할 수 있습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Pub Package CI

Run flutter build web or dart pub run build_runner build and put the output in another branch. An easy way to update gh-pages.

Install

dart pub global activate peanut

or

flutter pub global activate peanut

Run

peanut

or

flutter pub global run peanut

This will build your project into a temporary directory, and then it will update the local gh-pages branch with the build output.

Read more about peanut in this article.

Options

$ peanut --help
Usage: peanut [<args>]

Arguments:
-d, --directories                The directories that should be built.
                                 (defaults to "web")
-b, --branch                     The git branch where the built content should
                                 be committed.
                                 (defaults to "gh-pages")
-c, --build-config               The configuration to use when running
                                 `build_runner`.
    --[no-]release               Flutter: enabled passes `--release`, otherwise
                                 passes `--profile`.
                                 Other: enabled passes `--release`, otherwise
                                 passes `--no-release`.
                                 (defaults to on)
-m, --message                    (defaults to "Built <directories>")
    --[no-]source-branch-info    Includes the name of the source branch and SHA
                                 in the commit message
                                 (defaults to on)
    --[no-]version-info          Includes the pubspec version of the package in
                                 the commit message
    --post-build-dart-script     Optional Dart script to run after all builds
                                 have completed, but before files are committed
                                 to the repository.
    --builder-options            Builder options YAML or a path to a file
                                 containing builder options YAML.
                                 See the README for details.
    --[no-]verbose               Print more details when running.
    --dry-run                    Verifies configuration and prints commands that
                                 would be executed, but does not do any work.
    --[no-]wasm                  Whether to build for WebAssembly (WASM).
    --extra-args                 Extra arguments to provide to the target CLI
                                 within a single string.
                                 Examples:
                                 --extra-args "--dart-define TEST_VAR=123"
                                 --extra-args "--dart-define --base-href=/base/"
-h, --help                       Prints usage information.
    --version                    Print the current version.

Configuration file

peanut also supports a configuration file. Convenient if you have one-off settings you'd rather not type every time you deploy.

The peanut.yaml from this repository:

# Configuration for https://pub.dev/packages/peanut
directories:
  - example

# The Dart script to run after the build is complete, but before the changes are committed.
# This script is run in the root of the package.
# The script has access to the root of the build output directory as the first argument.
post-build-dart-script: tool/post_build.dart

# Build options to pass to `build_runner`.
# These are merged with any existing `build.yaml` file.
builder-options:
  build_web_compilers|entrypoint:
    compilers:
      dart2wasm:
        args:
          - -O4
          - --no-strip-wasm
      dart2js:
        args:
          - --stage=dump-info-all
          - --no-frequency-based-minification
          - --no-source-maps
          - -O4
  build_web_compilers|dart2js_archive_extractor:
    filter_outputs: false

Post-build Dart script

You can optionally specify a Dart script to run after the build is complete, but before the changes are committed.

post-build-dart-script: tool/post_build.dart

This script is run from the root of the package.

It receives two arguments:

  1. The path to a temporary directory which contains the build output. For example, if you are building a single directory web, the output will be in a web subdirectory of this temporary directory.
  2. A JSON-encoded map where keys are the source directories that were built, and values are the corresponding output sub-directories within the temporary directory from the first argument.

For example, if you run peanut -d web, the script will be called with:

  • args[0]: /tmp/peanut.xyz (a temporary path)
  • args[1]: {"web":"."}

The index.html for the web build would be at /tmp/peanut.xyz/index.html.

Examples

  • https://github.com/dart-lang/sample-pop_pop_win/
    • Output: https://dart-lang.github.io/sample-pop_pop_win/
    • No custom configuration.
  • https://github.com/kevmoo/pubviz
    • Output: http://kevmoo.github.io/pubviz/
    • Custom peanut.yaml file to specify builder-options and example as the source directory.

Git tricks

The easiest way to push your gh-pages branch to github (without switching from your working branch) is:

git push origin --set-upstream gh-pages

To create (or update) your local gh-pages branch to match what's on the server.

git update-ref refs/heads/gh-pages origin/gh-pages

This is also useful if you want to undo a peanut run.

Publishing automation

For information about our publishing automation and release process, see https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

카테고리

의존성

의존성 목록 13 개

소스 저장소

이 패키지를 사용하는 프로젝트