SIGN IN SIGN UP

feat(functions): support npm package versions and tags in kit install (#11010)

* refactor(functions): use string arrays instead of Sets in kit install helpers

### Description
Refactors function kit installation helper APIs (`extractExistingFunctionsInfo`, `promptKitInstanceId`, `promptKitId`, `generateUniqueId`, and `ExistingFunctionsInfo`) to use standard `string[]` arrays instead of `Set<string>` per codebase conventions (using intrinsic arrays in module APIs).

### Scenarios Tested
- Unit tests in `src/functions/kits/install.spec.ts` (`npm run mocha:fast -- src/functions/kits/install.spec.ts`).
- Verified unique ID generation and suffix collision avoidance with string arrays.
- Verified existing kit, codebase, and instance ID validation and prompt collisions.

### Sample Commands
N/A (Internal refactoring)

* feat(functions): support npm package versions and tags in kit install

### Description
Enhances package specifier and kit name parsing to support npm version numbers (e.g. `@1.2.3`, `@^2.0.0`, `@1.0.0-rc.1`) and distribution tags (e.g. `@next`, `@latest`):
- Updates `parseNpmPackageSpecifier` to properly handle empty versions vs defined versions.
- Updates `validateNpmPackageName` to allow specifiers with versions/tags while rejecting trailing `@` without a version.
- Updates `sanitizePackageNameToKitName` to parse the specifier first and extract the unscoped package name before sanitizing to avoid baking versions/tags into default kit IDs.
- Updates `isThirdPartyPackage` to extract the base package name before evaluating scope.

### Scenarios Tested
- Added unit tests for scoped and unscoped package specifiers with versions and tags.
- Verified validation and error cases for trailing `@` and malformed names.
- Ran full test suite in `src/functions/kits/install.spec.ts`.

### Sample Commands
- `firebase functions:kits:install --package @firebase-function-kits/firestore-bigquery-export@next`
- `firebase functions:kits:install --package my-kit@1.2.3`

* fix(functions): validate raw package specifier before parsing in resolvePackageSource

- Pass rawPkgName to validateNpmPackageName before destructuring packageName.
- Simplify validateNpmPackageName condition.
- Add unit test for malformed specifiers in resolvePackageSource.
T
Thomas Bouldin committed
f61140f080effbba08a6f0c2e437dbaf7732a825
Parent: 8559e80
Committed by GitHub <noreply@github.com> on 9/1/2026, 12:18:58 AM