@yarnpkg/plugin-http
Advanced tools
| export declare const TARBALL_REGEXP: RegExp; | ||
| export declare const PROTOCOL_REGEXP: RegExp; |
| import { Plugin } from '@yarnpkg/core'; | ||
| declare const plugin: Plugin; | ||
| export default plugin; |
| import { Fetcher, FetchOptions, MinimalFetchOptions } from '@yarnpkg/core'; | ||
| import { Locator } from '@yarnpkg/core'; | ||
| export declare class TarballHttpFetcher implements Fetcher { | ||
| supports(locator: Locator, opts: MinimalFetchOptions): boolean; | ||
| getLocalPath(locator: Locator, opts: FetchOptions): null; | ||
| fetch(locator: Locator, opts: FetchOptions): Promise<{ | ||
| packageFs: import("../../yarnpkg-fslib/sources").FakeFS<import("../../yarnpkg-fslib/sources").PortablePath>; | ||
| releaseFs: () => void; | ||
| prefixPath: import("../../yarnpkg-fslib/sources").PortablePath; | ||
| checksum: string; | ||
| }>; | ||
| fetchFromNetwork(locator: Locator, opts: FetchOptions): Promise<import("../../yarnpkg-fslib/sources").ZipFS>; | ||
| } |
| import { Resolver, ResolveOptions, MinimalResolveOptions } from '@yarnpkg/core'; | ||
| import { Descriptor, Locator } from '@yarnpkg/core'; | ||
| import { LinkType } from '@yarnpkg/core'; | ||
| export declare class TarballHttpResolver implements Resolver { | ||
| supportsDescriptor(descriptor: Descriptor, opts: MinimalResolveOptions): boolean; | ||
| supportsLocator(locator: Locator, opts: MinimalResolveOptions): boolean; | ||
| shouldPersistResolution(locator: Locator, opts: MinimalResolveOptions): boolean; | ||
| bindDescriptor(descriptor: Descriptor, fromLocator: Locator, opts: MinimalResolveOptions): Descriptor; | ||
| getResolutionDependencies(descriptor: Descriptor, opts: MinimalResolveOptions): never[]; | ||
| getCandidates(descriptor: Descriptor, dependencies: unknown, opts: ResolveOptions): Promise<Locator[]>; | ||
| resolve(locator: Locator, opts: ResolveOptions): Promise<{ | ||
| version: string; | ||
| languageName: any; | ||
| linkType: LinkType; | ||
| dependencies: Map<import("../../yarnpkg-core/sources").IdentHash, Descriptor>; | ||
| peerDependencies: Map<import("../../yarnpkg-core/sources").IdentHash, Descriptor>; | ||
| dependenciesMeta: Map<string, Map<string | null, import("../../yarnpkg-core/sources").DependencyMeta>>; | ||
| peerDependenciesMeta: Map<string, import("../../yarnpkg-core/sources").PeerDependencyMeta>; | ||
| bin: Map<string, import("../../yarnpkg-fslib/sources").PortablePath>; | ||
| locatorHash: import("../../yarnpkg-core/sources").LocatorHash; | ||
| reference: string; | ||
| identHash: import("../../yarnpkg-core/sources").IdentHash; | ||
| scope: string | null; | ||
| name: string; | ||
| }>; | ||
| } |
+3
-9
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.PROTOCOL_REGEXP = exports.TARBALL_REGEXP = void 0; | ||
| const TARBALL_REGEXP = /^[^?]*\.(?:tar\.gz|tgz)(?:\?.*)?$/; | ||
| exports.TARBALL_REGEXP = TARBALL_REGEXP; | ||
| const PROTOCOL_REGEXP = /^https?:/; | ||
| exports.PROTOCOL_REGEXP = PROTOCOL_REGEXP; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.TARBALL_REGEXP = /^[^?]*\.(?:tar\.gz|tgz)(?:\?.*)?$/; | ||
| exports.PROTOCOL_REGEXP = /^https?:/; |
+12
-16
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.default = void 0; | ||
| var _TarballHttpFetcher = require("./TarballHttpFetcher"); | ||
| var _TarballHttpResolver = require("./TarballHttpResolver"); | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const TarballHttpFetcher_1 = require("./TarballHttpFetcher"); | ||
| const TarballHttpResolver_1 = require("./TarballHttpResolver"); | ||
| const plugin = { | ||
| fetchers: [_TarballHttpFetcher.TarballHttpFetcher], | ||
| resolvers: [_TarballHttpResolver.TarballHttpResolver] | ||
| }; // eslint-disable-next-line arca/no-default-export | ||
| var _default = plugin; | ||
| exports.default = _default; | ||
| fetchers: [ | ||
| TarballHttpFetcher_1.TarballHttpFetcher, | ||
| ], | ||
| resolvers: [ | ||
| TarballHttpResolver_1.TarballHttpResolver, | ||
| ], | ||
| }; | ||
| // eslint-disable-next-line arca/no-default-export | ||
| exports.default = plugin; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.TarballHttpFetcher = void 0; | ||
| var _core = require("@yarnpkg/core"); | ||
| var _constants = require("./constants"); | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const core_1 = require("@yarnpkg/core"); | ||
| const core_2 = require("@yarnpkg/core"); | ||
| const constants_1 = require("./constants"); | ||
| class TarballHttpFetcher { | ||
| supports(locator, opts) { | ||
| if (!_constants.TARBALL_REGEXP.test(locator.reference)) return false; | ||
| if (_constants.PROTOCOL_REGEXP.test(locator.reference)) return true; | ||
| return false; | ||
| } | ||
| getLocalPath(locator, opts) { | ||
| return null; | ||
| } | ||
| async fetch(locator, opts) { | ||
| const expectedChecksum = opts.checksums.get(locator.locatorHash) || null; | ||
| const [packageFs, releaseFs, checksum] = await opts.cache.fetchPackageFromCache(locator, expectedChecksum, async () => { | ||
| opts.report.reportInfoOnce(_core.MessageName.FETCH_NOT_CACHED, `${_core.structUtils.prettyLocator(opts.project.configuration, locator)} can't be found in the cache and will be fetched from the remote server`); | ||
| return await this.fetchFromNetwork(locator, opts); | ||
| }); | ||
| return { | ||
| packageFs, | ||
| releaseFs, | ||
| prefixPath: _core.structUtils.getIdentVendorPath(locator), | ||
| checksum | ||
| }; | ||
| } | ||
| async fetchFromNetwork(locator, opts) { | ||
| const sourceBuffer = await _core.httpUtils.get(locator.reference, { | ||
| configuration: opts.project.configuration | ||
| }); | ||
| return await _core.tgzUtils.convertToZip(sourceBuffer, { | ||
| stripComponents: 1, | ||
| prefixPath: _core.structUtils.getIdentVendorPath(locator) | ||
| }); | ||
| } | ||
| supports(locator, opts) { | ||
| if (!constants_1.TARBALL_REGEXP.test(locator.reference)) | ||
| return false; | ||
| if (constants_1.PROTOCOL_REGEXP.test(locator.reference)) | ||
| return true; | ||
| return false; | ||
| } | ||
| getLocalPath(locator, opts) { | ||
| return null; | ||
| } | ||
| async fetch(locator, opts) { | ||
| const expectedChecksum = opts.checksums.get(locator.locatorHash) || null; | ||
| const [packageFs, releaseFs, checksum] = await opts.cache.fetchPackageFromCache(locator, expectedChecksum, async () => { | ||
| opts.report.reportInfoOnce(core_1.MessageName.FETCH_NOT_CACHED, `${core_2.structUtils.prettyLocator(opts.project.configuration, locator)} can't be found in the cache and will be fetched from the remote server`); | ||
| return await this.fetchFromNetwork(locator, opts); | ||
| }); | ||
| return { | ||
| packageFs, | ||
| releaseFs, | ||
| prefixPath: core_2.structUtils.getIdentVendorPath(locator), | ||
| checksum, | ||
| }; | ||
| } | ||
| async fetchFromNetwork(locator, opts) { | ||
| const sourceBuffer = await core_2.httpUtils.get(locator.reference, { | ||
| configuration: opts.project.configuration, | ||
| }); | ||
| return await core_2.tgzUtils.convertToZip(sourceBuffer, { | ||
| stripComponents: 1, | ||
| prefixPath: core_2.structUtils.getIdentVendorPath(locator), | ||
| }); | ||
| } | ||
| } | ||
| exports.TarballHttpFetcher = TarballHttpFetcher; | ||
| exports.TarballHttpFetcher = TarballHttpFetcher; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { | ||
| value: true | ||
| }); | ||
| exports.TarballHttpResolver = void 0; | ||
| var _core = require("@yarnpkg/core"); | ||
| var _constants = require("./constants"); | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const core_1 = require("@yarnpkg/core"); | ||
| const core_2 = require("@yarnpkg/core"); | ||
| const core_3 = require("@yarnpkg/core"); | ||
| const constants_1 = require("./constants"); | ||
| class TarballHttpResolver { | ||
| supportsDescriptor(descriptor, opts) { | ||
| if (!_constants.TARBALL_REGEXP.test(descriptor.range)) return false; | ||
| if (_constants.PROTOCOL_REGEXP.test(descriptor.range)) return true; | ||
| return false; | ||
| } | ||
| supportsLocator(locator, opts) { | ||
| if (!_constants.TARBALL_REGEXP.test(locator.reference)) return false; | ||
| if (_constants.PROTOCOL_REGEXP.test(locator.reference)) return true; | ||
| return false; | ||
| } | ||
| shouldPersistResolution(locator, opts) { | ||
| return true; | ||
| } | ||
| bindDescriptor(descriptor, fromLocator, opts) { | ||
| return descriptor; | ||
| } | ||
| getResolutionDependencies(descriptor, opts) { | ||
| return []; | ||
| } | ||
| async getCandidates(descriptor, dependencies, opts) { | ||
| return [_core.structUtils.convertDescriptorToLocator(descriptor)]; | ||
| } | ||
| async resolve(locator, opts) { | ||
| if (!opts.fetchOptions) throw new Error(`Assertion failed: This resolver cannot be used unless a fetcher is configured`); | ||
| const packageFetch = await opts.fetchOptions.fetcher.fetch(locator, opts.fetchOptions); | ||
| const manifest = await _core.miscUtils.releaseAfterUseAsync(async () => { | ||
| return await _core.Manifest.find(packageFetch.prefixPath, { | ||
| baseFs: packageFetch.packageFs | ||
| }); | ||
| }, packageFetch.releaseFs); | ||
| return { ...locator, | ||
| version: manifest.version || `0.0.0`, | ||
| languageName: opts.project.configuration.get(`defaultLanguageName`), | ||
| linkType: _core.LinkType.HARD, | ||
| dependencies: manifest.dependencies, | ||
| peerDependencies: manifest.peerDependencies, | ||
| dependenciesMeta: manifest.dependenciesMeta, | ||
| peerDependenciesMeta: manifest.peerDependenciesMeta, | ||
| bin: manifest.bin | ||
| }; | ||
| } | ||
| supportsDescriptor(descriptor, opts) { | ||
| if (!constants_1.TARBALL_REGEXP.test(descriptor.range)) | ||
| return false; | ||
| if (constants_1.PROTOCOL_REGEXP.test(descriptor.range)) | ||
| return true; | ||
| return false; | ||
| } | ||
| supportsLocator(locator, opts) { | ||
| if (!constants_1.TARBALL_REGEXP.test(locator.reference)) | ||
| return false; | ||
| if (constants_1.PROTOCOL_REGEXP.test(locator.reference)) | ||
| return true; | ||
| return false; | ||
| } | ||
| shouldPersistResolution(locator, opts) { | ||
| return true; | ||
| } | ||
| bindDescriptor(descriptor, fromLocator, opts) { | ||
| return descriptor; | ||
| } | ||
| getResolutionDependencies(descriptor, opts) { | ||
| return []; | ||
| } | ||
| async getCandidates(descriptor, dependencies, opts) { | ||
| return [core_3.structUtils.convertDescriptorToLocator(descriptor)]; | ||
| } | ||
| async resolve(locator, opts) { | ||
| if (!opts.fetchOptions) | ||
| throw new Error(`Assertion failed: This resolver cannot be used unless a fetcher is configured`); | ||
| const packageFetch = await opts.fetchOptions.fetcher.fetch(locator, opts.fetchOptions); | ||
| const manifest = await core_3.miscUtils.releaseAfterUseAsync(async () => { | ||
| return await core_1.Manifest.find(packageFetch.prefixPath, { baseFs: packageFetch.packageFs }); | ||
| }, packageFetch.releaseFs); | ||
| return Object.assign(Object.assign({}, locator), { version: manifest.version || `0.0.0`, languageName: opts.project.configuration.get(`defaultLanguageName`), linkType: core_2.LinkType.HARD, dependencies: manifest.dependencies, peerDependencies: manifest.peerDependencies, dependenciesMeta: manifest.dependenciesMeta, peerDependenciesMeta: manifest.peerDependenciesMeta, bin: manifest.bin }); | ||
| } | ||
| } | ||
| exports.TarballHttpResolver = TarballHttpResolver; | ||
| exports.TarballHttpResolver = TarballHttpResolver; |
+4
-4
| { | ||
| "name": "@yarnpkg/plugin-http", | ||
| "version": "2.0.0-rc.10", | ||
| "version": "2.0.0-rc.11", | ||
| "main": "./lib/index.js", | ||
| "dependencies": { | ||
| "@yarnpkg/fslib": "^2.0.0-rc.12" | ||
| "@yarnpkg/fslib": "^2.0.0-rc.15" | ||
| }, | ||
| "peerDependencies": { | ||
| "@yarnpkg/core": "^2.0.0-rc.18" | ||
| "@yarnpkg/core": "^2.0.0-rc.20" | ||
| }, | ||
| "devDependencies": { | ||
| "@yarnpkg/core": "^2.0.0-rc.18" | ||
| "@yarnpkg/core": "^2.0.0-rc.20" | ||
| }, | ||
@@ -14,0 +14,0 @@ "repository": { |
7728
54.31%10
66.67%147
34.86%3
50%Updated