body method

  1. @override
String body(
  1. String path,
  2. String baseName,
  3. String className
)
override

Defines the actual body code. path is passed relative to lib, baseName is the filename, and className is the filename converted to Pascal case.

実際の本体コードを定義します。pathlibからの相対パス、baseNameにファイル名が渡され、classNameにファイル名をパスカルケースに変換した値が渡されます。

Implementation

@override
String body(String path, String baseName, String className) {
  final workingPath = workingDirectory?.difference(Directory.current);
  return """
# Build and upload a Flutter web app.
#
# The built related files will be stored in Github storage. (storage expires in 1 day)
#
# FlutterのWebアプリをビルドしアップロードします。
#
# ビルドされた関連ファイルがGithubのストレージに保管されます。(保管期限1日)
name: WebProductionWorkflow

on:
${buildOnClaudeCode ? """
# This workflow runs when there is a pull_request on the main, master, develop branch.
# main, master, develop branch に pull_request があったらこの workflow が走る。
pull_request:
  branches:
    - main
    - master
    - develop
  types:
    - opened
    - reopened
    - synchronize
""" : ""}
# This workflow runs when there is a push on the publish branch.
# publish branch に push があったらこの workflow が走る。
push:
  branches:
    - publish

jobs:
# ----------------------------------------------------------------- #
# Status check
# ----------------------------------------------------------------- #
status_check:
  runs-on: ubuntu-latest
  timeout-minutes: 30
  defaults:
    run:
      working-directory: ${workingPath.isEmpty ? "." : workingPath}
  steps:
    # Check-out.
    # チェックアウト。
    - name: Checks-out my repository
      timeout-minutes: 10
      uses: actions/checkout@v4

    # Flutter status check.
    # Flutterのステータスチェックを行います。
    - name: Flutter status check
      timeout-minutes: 30
      uses: ./.github/actions/status_check

# ----------------------------------------------------------------- #
# Build for Web
# ----------------------------------------------------------------- #
build_web:
  runs-on: ubuntu-latest
  needs: status_check
  timeout-minutes: 30
  defaults:
    run:
      working-directory: ${workingPath.isEmpty ? "." : workingPath}
  steps:
    # Check-out.
    # チェックアウト。
    - name: Checks-out my repository
      timeout-minutes: 10
      uses: actions/checkout@v4

    # Install flutter.
    # Flutterのインストール。
    - name: Install flutter
      timeout-minutes: 10
      uses: subosito/flutter-action@v2
      with:
        channel: stable
        cache: true

    # Check flutter version.
    # Flutterのバージョン確認。
    - name: Run flutter version
      run: flutter --version
      timeout-minutes: 3

    # Download package.
    # パッケージのダウンロード。
    - name: Download flutter packages
      run: flutter pub get
      timeout-minutes: 3

    # Creation of the Assets folder.
    # Assetsフォルダの作成。
    - name: Create assets folder
      run: mkdir -p assets

    # Generate web files.
    # Webファイルを生成。
    - name: Building web build
      run: flutter build web --build-number \$((\$GITHUB_RUN_NUMBER+$defaultIncrementNumber)) --release --dart-define=FLAVOR=prod
      timeout-minutes: 30

    # Upload the generated files.
    # 生成されたファイルのアップロード。
    - name: Upload web artifacts
      uses: actions/upload-artifact@v4
      timeout-minutes: 15
      with:
        name: web_release
        path: ${workingPath.isEmpty ? "." : workingPath}/build/web
        retention-days: 1
""";
}