0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

yamory で monorepo を管理する

Posted at

yamory で monorepo をスキャンする方法について書く。

Introduction

現職のプロダクトでは、monorepo で複数の TypeScript プロジェクトを管理している。ご存知の通り monorepo では、複数のプロジェクトが依存関係を持つことができる。yamory で monorepo をスキャンするためには、いくつかの設定が必要になる。今回は、monorepo で管理されているプロジェクトの依存関係を解析する方法を書く。

tl;dr

  • monorepo の場合は package.json が複数存在するため、yamory でスキャンするためには、プロジェクトを指定する必要がある。
  • GitHub Actions で monorepo をスキャンするためには、スクリプトを作成して自動化することができる。

Configuration

npm Workspaces 1 で monorepo を管理している。
Nx や Turborepo を採用しなかった理由は、AWS Amplify との連携が難しいためである。(2024年4月時点)
以下は、monorepo の構成例です:

.
├── ./api
│   └── ./api/package.json
├── ./load-testing
│   └── ./load-testing/package.json
└── ./web-api-tests
    └── ./web-api-tests/package.json

yamory configuration

yamory で monorepo をスキャンするためには、コンソールでプロジェクトを指定する必要がある。
以下は、monorepo のプロジェクトで yamory を実行する例です。

PROJECT_GROUP_KEY=api YAMORY_API_KEY=xxxxx YAMORY_OPEN_SYSTEM=true YAMORY_DISTRIBUTED=true bash -c "$(curl -sSf -L https://localscanner.yamory.io/script/npm)" -- --manifest ./api/package.json

Scanning Automation

yamory で monorepo をスキャンするためには、スクリプトを作成して自動化することができる。以下は、GitHub Actions で yamory を実行するスクリプトの例です:

name: yamory Scan

on:
  workflow_dispatch:
  schedule:
    - cron: '0 0 * * *'

jobs:
  # README at:
  # https://docs.github.com/ja/actions/writing-workflows/workflow-syntax-for-github-actions#example-of-onworkflow_callsecrets
  # https://zenn.dev/dzeyelid/articles/fc4bd999fbccd8
  api:
    uses: ./.github/workflows/reusable-yamory-scan.yml
    secrets:
      yamory_api_key: ${{ secrets.YAMORY_API_KEY }}
    with:
      project_group_key: api
      manifest_path: ./api/package.json
      environment: development
name: Reusable yamory Scan

on:
  workflow_call:
    inputs:
      project_group_key:
        required: true
        type: string
      manifest_path:
        required: true
        type: string
      environment:
        type: string
        required: true
        default: 'development'
    secrets:
      yamory_api_key:
        required: true

jobs:
  yamory-scan:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    environment: ${{ inputs.environment }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          ref: main

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '22.8.0'

      # README at: https://docs.yamory.io/4e7c5078485249c8857bbed0191fe8a8
      - name: Run yamory scan
        run: |
          PROJECT_GROUP_KEY=${{ inputs.project_group_key }} YAMORY_API_KEY=${{ secrets.yamory_api_key }} YAMORY_OPEN_SYSTEM=true YAMORY_DISTRIBUTED=true bash -c "$(curl -sSf -L https://localscanner.yamory.io/script/npm)" -- --manifest ${{ inputs.manifest_path }}

あとがき

Coding Agent の登場により、Engineering の世界は大きく変わると思う。実体験として Cline 2 はコーディング体験を大幅に変えた。よく言われるように、クラウドや k8s の登場時のような変革が起こると思う。個人的には、5年前、10年前のような高揚感がある。それらを越える可能性もある。新しいテクノロジーやフレームワークよりも、Agent を含めた LLM による変革を追っていきたい。

  1. https://docs.npmjs.com/cli/v7/using-npm/workspaces

  2. https://docs.cline.bot/

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?