@@ -264,67 +264,7 @@ def apply_prettier_all_over
264
264
git commit : ". -m 'Run prettier one last time'"
265
265
end
266
266
267
- # Sets Yarn Berry up in the project directory by initializing it with what is probably Yarn Classic.
268
- #
269
- # This is required as the Berry binary is actually downloaded and committed to the codebase, and
270
- # the global yarn command passes through to it when detected (even if its Yarn Classic).
271
- #
272
- # This also requires us to temporarily create a package.json as otherwise Yarn Berry will
273
- # look up the file tree and initialize itself in every directory that has a yarn.lock
274
- def setup_yarn_berry
275
- # safeguard against parent directories having a yarn.lock
276
- File . write ( "package.json" , "{}" ) unless File . exist? ( "package.json" )
277
-
278
- run "yarn init -2"
279
- run "yarn config set enableGlobalCache true"
280
- run "yarn config set nodeLinker #{ ENV . fetch ( "PACKAGE_JSON_YARN_BERRY_LINKER" , "node-modules" ) } "
281
-
282
- ignores = <<~YARN
283
- .pnp.*
284
- .yarn/*
285
- !.yarn/patches
286
- !.yarn/plugins
287
- !.yarn/releases
288
- !.yarn/sdks
289
- !.yarn/versions
290
- YARN
291
- File . write ( ".gitignore" , ignores , mode : "a" )
292
-
293
- # this will be properly (re)created later
294
- File . unlink ( "package.json" )
295
- end
296
-
297
- # Bun uses a binary-based lockfile which cannot be parsed by shakapacker or
298
- # osv-detector, so we want to configure bun to always write a yarn.lock
299
- # in addition so that such tools can check it
300
- def setup_bun
301
- File . write ( "bunfig.toml" , <<~TOML )
302
- [install.lockfile]
303
- print = "yarn"
304
- TOML
305
- end
306
-
307
- def add_yarn_package_extension_dependency ( name , dependency )
308
- return unless File . exist? ( ".yarnrc.yml" )
309
-
310
- require "yaml"
311
-
312
- yarnrc = YAML . load_file ( ".yarnrc.yml" )
313
-
314
- yarnrc [ "packageExtensions" ] ||= { }
315
- yarnrc [ "packageExtensions" ] [ "#{ name } @*" ] ||= { }
316
- yarnrc [ "packageExtensions" ] [ "#{ name } @*" ] [ "dependencies" ] ||= { }
317
- yarnrc [ "packageExtensions" ] [ "#{ name } @*" ] [ "dependencies" ] [ dependency ] = "*"
318
-
319
- File . write ( ".yarnrc.yml" , yarnrc . to_yaml )
320
- end
321
-
322
267
def package_json
323
- if @package_json . nil?
324
- setup_yarn_berry if ENV . fetch ( "PACKAGE_JSON_FALLBACK_MANAGER" , nil ) == "yarn_berry"
325
- setup_bun if ENV . fetch ( "PACKAGE_JSON_FALLBACK_MANAGER" , nil ) == "bun"
326
- end
327
-
328
268
@package_json ||= PackageJson . new
329
269
end
330
270
@@ -346,8 +286,7 @@ def build_engines_field(existing)
346
286
node_version = File . read ( "./.node-version" ) . strip
347
287
348
288
existing . merge ( {
349
- "node" => "^#{ node_version } " ,
350
- "yarn" => "^1.0.0"
289
+ "node" => "^#{ node_version } "
351
290
} )
352
291
end
353
292
@@ -361,26 +300,23 @@ def cleanup_package_json
361
300
}
362
301
end
363
302
364
- # TODO: this doesn't work when using pnpm even though it shouldn't matter? anyway, replace with 'exec' support
365
- # run "npx -y sort-package-json"
366
-
367
303
# ensure the lockfile is up to date with any changes we've made to package.json
368
304
package_json . manager . install!
369
305
end
370
306
371
- # Adds the given <code>packages</code> as dependencies using <code>yarn add</code>
307
+ # Adds the given <code>packages</code> as dependencies using the preferred package manager
372
308
#
373
309
# @param [Array<String>] packages
374
- def yarn_add_dependencies ( packages )
310
+ def add_js_dependencies ( packages )
375
311
puts "adding #{ packages . join ( " " ) } as dependencies"
376
312
377
313
package_json . manager . add! ( packages )
378
314
end
379
315
380
- # Adds the given <code>packages</code> as devDependencies using <code>yarn add --dev</code>
316
+ # Adds the given <code>packages</code> as devDependencies using the preferred package manager
381
317
#
382
318
# @param [Array<String>] packages
383
- def yarn_add_dev_dependencies ( packages )
319
+ def add_js_dev_dependencies ( packages )
384
320
puts "adding #{ packages . join ( " " ) } as dev dependencies"
385
321
386
322
package_json . manager . add! ( packages , type : :dev )
0 commit comments