CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/npm-lerna--init

tessl install tessl/npm-lerna--init@6.6.0

Create a new Lerna repo or upgrade an existing repo to the current version of Lerna

Agent Success

Agent success rate when using this tile

75%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.36x

Baseline

Agent success rate without this tile

55%

task.mdevals/scenario-2/

Package Build Reporter

A utility script that executes commands across all packages in a monorepo and generates a build report.

Overview

You need to create a Node.js script that uses Lerna to execute shell commands across multiple packages in a monorepo. The script should gather information about each package (specifically the package name and line count), then generate a JSON report summarizing the results.

Requirements

Command Execution

The script must execute a shell command in each package directory to count the number of lines in JavaScript files. The command should:

  • Use standard Unix utilities (like find and wc) to count lines
  • Run across all packages in the monorepo
  • Capture the output from each package execution

Report Generation

After executing commands across all packages, generate a JSON report file named build-report.json in the project root containing:

  • An array of package results
  • Each result should include:
    • packageName: The name of the package
    • lineCount: The total number of lines counted (as a number)

The report should be sorted alphabetically by package name.

Error Handling

If the command execution fails or produces no output, the script should handle the error gracefully and exit with a non-zero exit code.

Expected Behavior

When run in a monorepo with packages @myapp/pkg-a, @myapp/pkg-b, and @myapp/pkg-c, the generated build-report.json should look like:

{
  "packages": [
    {
      "packageName": "@myapp/pkg-a",
      "lineCount": 150
    },
    {
      "packageName": "@myapp/pkg-b",
      "lineCount": 200
    },
    {
      "packageName": "@myapp/pkg-c",
      "lineCount": 75
    }
  ]
}

Implementation

@generates

API

/**
 * Executes commands across all packages and generates a build report.
 * The function uses Lerna to run shell commands in each package directory.
 *
 * @returns {Promise<void>} Resolves when the report is successfully generated
 * @throws {Error} If command execution fails or produces invalid output
 */
async function generateBuildReport() {
  // IMPLEMENTATION HERE
}

module.exports = { generateBuildReport };

Test Cases

  • Running the script in a monorepo with 3 packages creates a build-report.json file with an array of 3 package results @test
  • Each package result in the report contains both packageName and lineCount properties @test
  • The packages in the report are sorted alphabetically by package name @test
  • The lineCount values are numbers, not strings @test

Dependencies { .dependencies }

lerna { .dependency }

Provides monorepo management and command execution across packages.

@satisfied-by

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@lerna/init@6.6.x
tile.json