@@ -180,8 +180,16 @@ func buildNodejsLibrary(googleapisDir, packagesDir, libraryName string) (*config
180180 if err != nil {
181181 return nil , fmt .Errorf ("parsing API paths for %s: %w" , libraryName , err )
182182 }
183- library .APIs = apis
184- library .Nodejs .NodejsAPIs = buildNodejsLibraryAPIs (googleapisDir , apis )
183+
184+ var filteredAPIs []* config.API
185+ for _ , api := range apis {
186+ if libraryName == "google-cloud-compute" && api .Path == "google/cloud/compute/v1small" {
187+ continue
188+ }
189+ filteredAPIs = append (filteredAPIs , api )
190+ }
191+ library .APIs = filteredAPIs
192+ library .Nodejs .NodejsAPIs = buildNodejsLibraryAPIs (googleapisDir , filteredAPIs )
185193 }
186194
187195 // Extract copyright year from existing generated source files.
@@ -240,9 +248,54 @@ func buildNodejsLibrary(googleapisDir, packagesDir, libraryName string) (*config
240248 library .Keep = append (library .Keep , dirKeep ... )
241249 }
242250
251+ if libraryName == "google-cloud-compute" {
252+ v1smallKeep , err := nodejsV1SmallKeep (pkgDir )
253+ if err != nil {
254+ return nil , fmt .Errorf ("collecting keep files for v1small: %w" , err )
255+ }
256+ library .Keep = append (library .Keep , v1smallKeep ... )
257+ }
258+
243259 return library , nil
244260}
245261
262+ // TODO(https://github.com/googleapis/librarian/issues/4751): Do not
263+ // generate or delete v1small. This package is not meant to be used and
264+ // will be deprecated in the future, but for now (during the migration
265+ // period) it will be set to not be maintained.
266+ //
267+ // We explicitly add these files to the keep list to prevent the clean
268+ // phase from deleting them, as the generation phase skips v1small.
269+ func nodejsV1SmallKeep (pkgDir string ) ([]string , error ) {
270+ var paths []string
271+ err := filepath .WalkDir (pkgDir , func (path string , d os.DirEntry , err error ) error {
272+ if err != nil {
273+ return err
274+ }
275+ if d .IsDir () {
276+ if d .Name () == "node_modules" || d .Name () == "owl-bot-staging" {
277+ return filepath .SkipDir
278+ }
279+ return nil
280+ }
281+ rel , err := filepath .Rel (pkgDir , path )
282+ if err != nil {
283+ return err
284+ }
285+ if strings .Contains (rel , "v1small" ) {
286+ paths = append (paths , rel )
287+ }
288+ return nil
289+ })
290+ if err != nil {
291+ if errors .Is (err , fs .ErrNotExist ) {
292+ return nil , nil
293+ }
294+ return nil , err
295+ }
296+ return paths , nil
297+ }
298+
246299func buildNodejsLibraryAPIs (googleapisDir string , apis []* config.API ) []* config.NodejsAPI {
247300 var nodejsAPIs []* config.NodejsAPI
248301 for _ , api := range apis {
0 commit comments