|
136 | 136 | end |
137 | 137 | end |
138 | 138 |
|
139 | | - it "uses the fallback manager" do |
| 139 | + it "uses the fallback manager when no lockfile is present" do |
140 | 140 | with_package_json_file({ "version" => "1.0.0" }) do |
141 | 141 | package_json = described_class.read(Dir.pwd, fallback_manager: :yarn_classic) |
142 | 142 |
|
143 | 143 | expect(package_json.manager).to be_a PackageJson::Managers::YarnClassicLike |
144 | 144 | end |
145 | 145 | end |
146 | 146 |
|
| 147 | + it "detects npm from package-lock.json" do |
| 148 | + with_package_json_file({ "version" => "1.0.0" }) do |
| 149 | + File.write("package-lock.json", "{}") |
| 150 | + package_json = described_class.read(Dir.pwd, fallback_manager: :yarn_classic) |
| 151 | + |
| 152 | + expect(package_json.manager).to be_a PackageJson::Managers::NpmLike |
| 153 | + end |
| 154 | + end |
| 155 | + |
| 156 | + it "detects pnpm from pnpm-lock.yaml" do |
| 157 | + with_package_json_file({ "version" => "1.0.0" }) do |
| 158 | + File.write("pnpm-lock.yaml", "lockfileVersion: '6.0'") |
| 159 | + package_json = described_class.read(Dir.pwd, fallback_manager: :npm) |
| 160 | + |
| 161 | + expect(package_json.manager).to be_a PackageJson::Managers::PnpmLike |
| 162 | + end |
| 163 | + end |
| 164 | + |
| 165 | + it "detects bun from bun.lockb" do |
| 166 | + with_package_json_file({ "version" => "1.0.0" }) do |
| 167 | + File.write("bun.lockb", "") |
| 168 | + package_json = described_class.read(Dir.pwd, fallback_manager: :npm) |
| 169 | + |
| 170 | + expect(package_json.manager).to be_a PackageJson::Managers::BunLike |
| 171 | + end |
| 172 | + end |
| 173 | + |
| 174 | + it "detects yarn classic from yarn.lock without __metadata:" do |
| 175 | + with_package_json_file({ "version" => "1.0.0" }) do |
| 176 | + File.write("yarn.lock", "# yarn lockfile v1\n\npackage@^1.0.0:\n version \"1.0.0\"") |
| 177 | + package_json = described_class.read(Dir.pwd, fallback_manager: :npm) |
| 178 | + |
| 179 | + expect(package_json.manager).to be_a PackageJson::Managers::YarnClassicLike |
| 180 | + end |
| 181 | + end |
| 182 | + |
| 183 | + it "detects yarn berry from yarn.lock with __metadata:" do |
| 184 | + with_package_json_file({ "version" => "1.0.0" }) do |
| 185 | + File.write("yarn.lock", "__metadata:\n version: 6\n cacheKey: 8") |
| 186 | + package_json = described_class.read(Dir.pwd, fallback_manager: :npm) |
| 187 | + |
| 188 | + expect(package_json.manager).to be_a PackageJson::Managers::YarnBerryLike |
| 189 | + end |
| 190 | + end |
| 191 | + |
| 192 | + it "prioritizes bun.lockb over other lockfiles" do |
| 193 | + with_package_json_file({ "version" => "1.0.0" }) do |
| 194 | + File.write("bun.lockb", "") |
| 195 | + File.write("package-lock.json", "{}") |
| 196 | + File.write("yarn.lock", "# yarn lockfile v1") |
| 197 | + package_json = described_class.read(Dir.pwd, fallback_manager: :npm) |
| 198 | + |
| 199 | + expect(package_json.manager).to be_a PackageJson::Managers::BunLike |
| 200 | + end |
| 201 | + end |
| 202 | + |
| 203 | + it "prioritizes pnpm-lock.yaml over yarn.lock and package-lock.json" do |
| 204 | + with_package_json_file({ "version" => "1.0.0" }) do |
| 205 | + File.write("pnpm-lock.yaml", "lockfileVersion: '6.0'") |
| 206 | + File.write("package-lock.json", "{}") |
| 207 | + File.write("yarn.lock", "# yarn lockfile v1") |
| 208 | + package_json = described_class.read(Dir.pwd, fallback_manager: :npm) |
| 209 | + |
| 210 | + expect(package_json.manager).to be_a PackageJson::Managers::PnpmLike |
| 211 | + end |
| 212 | + end |
| 213 | + |
| 214 | + it "prioritizes yarn.lock over package-lock.json" do |
| 215 | + with_package_json_file({ "version" => "1.0.0" }) do |
| 216 | + File.write("yarn.lock", "# yarn lockfile v1") |
| 217 | + File.write("package-lock.json", "{}") |
| 218 | + package_json = described_class.read(Dir.pwd, fallback_manager: :bun) |
| 219 | + |
| 220 | + expect(package_json.manager).to be_a PackageJson::Managers::YarnClassicLike |
| 221 | + end |
| 222 | + end |
| 223 | + |
147 | 224 | it "does not add the packageManager property" do |
148 | 225 | with_package_json_file({ "version" => "1.0.0" }) do |
149 | 226 | described_class.read(Dir.pwd, fallback_manager: :yarn_classic) |
|
306 | 383 | end |
307 | 384 | end |
308 | 385 |
|
309 | | - it "uses the fallback manager" do |
| 386 | + it "uses the fallback manager when no lockfile is present" do |
310 | 387 | with_package_json_file({ "version" => "1.0.0" }) do |
311 | 388 | package_json = described_class.new(fallback_manager: :yarn_classic) |
312 | 389 |
|
313 | 390 | expect(package_json.manager).to be_a PackageJson::Managers::YarnClassicLike |
314 | 391 | end |
315 | 392 | end |
316 | 393 |
|
| 394 | + it "detects npm from package-lock.json" do |
| 395 | + with_package_json_file({ "version" => "1.0.0" }) do |
| 396 | + File.write("package-lock.json", "{}") |
| 397 | + package_json = described_class.new(fallback_manager: :yarn_classic) |
| 398 | + |
| 399 | + expect(package_json.manager).to be_a PackageJson::Managers::NpmLike |
| 400 | + end |
| 401 | + end |
| 402 | + |
| 403 | + it "detects pnpm from pnpm-lock.yaml" do |
| 404 | + with_package_json_file({ "version" => "1.0.0" }) do |
| 405 | + File.write("pnpm-lock.yaml", "lockfileVersion: '6.0'") |
| 406 | + package_json = described_class.new(fallback_manager: :npm) |
| 407 | + |
| 408 | + expect(package_json.manager).to be_a PackageJson::Managers::PnpmLike |
| 409 | + end |
| 410 | + end |
| 411 | + |
| 412 | + it "detects bun from bun.lockb" do |
| 413 | + with_package_json_file({ "version" => "1.0.0" }) do |
| 414 | + File.write("bun.lockb", "") |
| 415 | + package_json = described_class.new(fallback_manager: :npm) |
| 416 | + |
| 417 | + expect(package_json.manager).to be_a PackageJson::Managers::BunLike |
| 418 | + end |
| 419 | + end |
| 420 | + |
| 421 | + it "detects yarn classic from yarn.lock without __metadata:" do |
| 422 | + with_package_json_file({ "version" => "1.0.0" }) do |
| 423 | + File.write("yarn.lock", "# yarn lockfile v1\n\npackage@^1.0.0:\n version \"1.0.0\"") |
| 424 | + package_json = described_class.new(fallback_manager: :npm) |
| 425 | + |
| 426 | + expect(package_json.manager).to be_a PackageJson::Managers::YarnClassicLike |
| 427 | + end |
| 428 | + end |
| 429 | + |
| 430 | + it "detects yarn berry from yarn.lock with __metadata:" do |
| 431 | + with_package_json_file({ "version" => "1.0.0" }) do |
| 432 | + File.write("yarn.lock", "__metadata:\n version: 6\n cacheKey: 8") |
| 433 | + package_json = described_class.new(fallback_manager: :npm) |
| 434 | + |
| 435 | + expect(package_json.manager).to be_a PackageJson::Managers::YarnBerryLike |
| 436 | + end |
| 437 | + end |
| 438 | + |
317 | 439 | it "does not add the packageManager property" do |
318 | 440 | with_package_json_file({ "version" => "1.0.0" }) do |
319 | 441 | described_class.new(fallback_manager: :yarn_classic) |
|
0 commit comments