パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v6.0.2

peanut

Dart Webアプリのコンパイル出力でGitHubのgh-pagesブランチを更新します。'pub build'および新しい'pub run build_runner'をサポートしています。

macOSWindowsLinux
30日間ダウンロード
2320
いいね数
139
Pub ポイント
150

パッケージをインストール

flutter pub add peanut

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Peanutは、コンパイルされたWebアプリの出力をGitHubのgh-pagesブランチに自動デプロイするDartパッケージです。従来の'pub build'と最新の'pub run build_runner'ワークフローの両方をサポートしており、Flutter Webアプリの配信プロセスを簡素化します。GitHub PagesでWebアプリをホストしたい開発者向けに設計されており、最小限の設定でビルドおよびプッシュステップを処理します。macOS、Windows、LinuxのCI/CDパイプラインやローカル開発環境にシームレスに統合されます。

用途

  • Flutter Web アプリを GitHub Pages にデプロイする
  • ビルドおよびデプロイの自動化
  • CI/CD ワークフローとの統合
  • Dart プロジェクトから静的 Web コンテンツを配信する
  • ビルド後の gh-pages の更新を簡素化

主な機能

  • pub build および build_runner をサポートしています
  • git push を gh-pages に自動化する
  • クロスプラットフォーム互換性
  • 最小限のセットアップが必要
  • Flutter Web アプリと連携可能

適している対象

  • Flutter Web開発者
  • 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 件

ソースリポジトリ

このパッケージを使用しているプロジェクト