()
| 36 | patterns = Option.Rest(); |
| 37 | |
| 38 | async execute() { |
| 39 | const descriptors = await this.resolvePatternsToDescriptors({ |
| 40 | patterns: this.patterns, |
| 41 | }); |
| 42 | |
| 43 | const installLocations: Array<string> = []; |
| 44 | |
| 45 | for (const descriptor of descriptors) { |
| 46 | const resolved = await this.context.engine.resolveDescriptor(descriptor, {allowTags: true, useCache: false}); |
| 47 | if (resolved === null) |
| 48 | throw new UsageError(`Failed to successfully resolve '${descriptor.range}' to a valid ${descriptor.name} release`); |
| 49 | |
| 50 | this.context.stdout.write(`Adding ${resolved.name}@${resolved.reference} to the cache...\n`); |
| 51 | const packageManagerInfo = await this.context.engine.ensurePackageManager(resolved); |
| 52 | |
| 53 | await this.context.engine.activatePackageManager(packageManagerInfo.locator); |
| 54 | installLocations.push(packageManagerInfo.location); |
| 55 | } |
| 56 | |
| 57 | const baseInstallFolder = folderUtils.getInstallFolder(); |
| 58 | const outputPath = path.resolve(this.context.cwd, this.output ?? `corepack.tgz`); |
| 59 | |
| 60 | if (!this.json) { |
| 61 | this.context.stdout.write(`\n`); |
| 62 | this.context.stdout.write(`Packing the selected tools in ${path.basename(outputPath)}...\n`); |
| 63 | } |
| 64 | |
| 65 | const {create: tarC} = await import(`tar/create`); |
| 66 | |
| 67 | // Recreate the folder in case it was deleted somewhere else: |
| 68 | await mkdir(baseInstallFolder, {recursive: true}); |
| 69 | await tarC({gzip: true, cwd: baseInstallFolder, file: path.resolve(outputPath)}, installLocations.map(location => { |
| 70 | return path.relative(baseInstallFolder, location); |
| 71 | })); |
| 72 | |
| 73 | if (this.json) { |
| 74 | this.context.stdout.write(`${JSON.stringify(outputPath)}\n`); |
| 75 | } else { |
| 76 | this.context.stdout.write(`All done!\n`); |
| 77 | } |
| 78 | } |
| 79 | } |
nothing calls this directly
no test coverage detected