feat(flutter-packages-builder): create flutter packages builder script#82
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a Node.js tool to build all opt-in Flutter packages/apps (those containing web/package.json) using the lower-bound Flutter SDK version from each package’s pubspec.yaml, then generates a merged build/web/package.json and packs the build output into a .tgz.
Changes:
- Introduces
tool/build-flutter-packages.mjsto discover eligible packages underpackages/andapps/. - Uses FVM-installed Flutter versions (derived from
environment.flutter) to build each target (flutter build web --profile). - Writes
build/web/package.json, runsnpm pack, and renames the tarball to<name>.tgz.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Adds a Node-based CLI script to build Flutter web packages/apps that opt in via web/package.json, selecting the Flutter SDK version from each package’s environment.flutter constraint and producing a packed .tgz artifact.
Changes:
- Introduces
tool/build-flutter-packages.mjsto discover eligible packages and build them with an FVM-installed Flutter version. - Implements a lightweight
pubspec.yamlparser to extractname,description,version, andenvironment.flutter. - Generates
build/web/package.json(merged fromweb/package.json+ pubspec metadata) and runsnpm packto create a tarball.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Adds a Node-based tooling script to build Flutter workspace packages that opt in via web/package.json, selecting a Flutter SDK version based on each package’s environment.flutter constraint and producing an npm tarball from the web build output.
Changes:
- Introduces
tool/build-flutter-packages.mjsto discover eligible packages via Melos and build them with a selected FVM-managed Flutter SDK. - Generates
build/web/package.jsonby merging metadata frompubspec.yamlwithweb/package.json, then runsnpm packand renames the resulting tarball.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /** | ||
| * Returns all workspace packages that have a `web/` directory, sourced from | ||
| * `melos list --dir-exists=web --json` so discovery matches the workspace globs | ||
| * in melos.yaml exactly. | ||
| */ | ||
| function discoverPackages() { | ||
| const result = spawnSync('melos', ['list', '--dir-exists=web', '--json'], { encoding: 'utf8', cwd: repoRoot }); | ||
| if (result.error || result.status !== 0) { | ||
| console.error('✗ `melos list --dir-exists=web --json` failed — is Melos installed and on PATH?'); | ||
| if (result.error) console.error(` ${result.error.message}`); | ||
| process.exit(result.status ?? 1); | ||
| } | ||
|
|
||
| let packages; | ||
| try { | ||
| packages = JSON.parse(result.stdout); | ||
| } catch { | ||
| console.error('✗ Failed to parse `melos list --dir-exists=web --json` output.'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| return packages.map(({ location }) => ({ | ||
| dir: location, | ||
| pubspecPath: join(location, 'pubspec.yaml'), | ||
| webPkgPath: join(location, 'web', 'package.json'), | ||
| })); | ||
| } |
Details
Create flutter packages builder script