@yarnpkg/plugin-git
Advanced tools
@@ -7,3 +7,3 @@ "use strict"; | ||
| const fslib_1 = require("@yarnpkg/fslib"); | ||
| const gitUtils = tslib_1.__importStar(require("./gitUtils")); | ||
| const gitUtils = (0, tslib_1.__importStar)(require("./gitUtils")); | ||
| class GitFetcher { | ||
@@ -29,4 +29,3 @@ supports(locator, opts) { | ||
| loader: () => this.cloneFromRemote(normalizedLocator, nextOpts), | ||
| skipIntegrityCheck: opts.skipIntegrityCheck, | ||
| }); | ||
| }, opts.cacheOptions); | ||
| return { | ||
@@ -33,0 +32,0 @@ packageFs, |
@@ -16,2 +16,3 @@ import { Resolver, ResolveOptions, MinimalResolveOptions } from '@yarnpkg/core'; | ||
| linkType: LinkType; | ||
| conditions: string | null; | ||
| dependencies: Map<import("@yarnpkg/core").IdentHash, Descriptor>; | ||
@@ -18,0 +19,0 @@ peerDependencies: Map<import("@yarnpkg/core").IdentHash, Descriptor>; |
@@ -8,3 +8,3 @@ "use strict"; | ||
| const core_3 = require("@yarnpkg/core"); | ||
| const gitUtils = tslib_1.__importStar(require("./gitUtils")); | ||
| const gitUtils = (0, tslib_1.__importStar)(require("./gitUtils")); | ||
| class GitResolver { | ||
@@ -46,2 +46,3 @@ supportsDescriptor(descriptor, opts) { | ||
| linkType: core_2.LinkType.HARD, | ||
| conditions: manifest.getConditions(), | ||
| dependencies: manifest.dependencies, | ||
@@ -48,0 +49,0 @@ peerDependencies: manifest.peerDependencies, |
+18
-2
@@ -1,2 +0,3 @@ | ||
| import { Configuration, Locator } from '@yarnpkg/core'; | ||
| import { Configuration, Locator, Project } from '@yarnpkg/core'; | ||
| import { PortablePath } from '@yarnpkg/fslib'; | ||
| export declare enum TreeishProtocols { | ||
@@ -29,2 +30,17 @@ Commit = "commit", | ||
| export declare function resolveUrl(url: string, configuration: Configuration): Promise<string>; | ||
| export declare function clone(url: string, configuration: Configuration): Promise<import("@yarnpkg/fslib").PortablePath>; | ||
| export declare function clone(url: string, configuration: Configuration): Promise<PortablePath>; | ||
| export declare function fetchRoot(initialCwd: PortablePath): Promise<PortablePath | null>; | ||
| export declare function fetchBase(root: PortablePath, { baseRefs }: { | ||
| baseRefs: Array<string>; | ||
| }): Promise<{ | ||
| hash: string; | ||
| title: string; | ||
| }>; | ||
| export declare function fetchChangedFiles(root: PortablePath, { base, project }: { | ||
| base: string; | ||
| project: Project; | ||
| }): Promise<PortablePath[]>; | ||
| export declare function fetchChangedWorkspaces({ ref, project }: { | ||
| ref: string | true; | ||
| project: Project; | ||
| }): Promise<Set<import("@yarnpkg/core").Workspace>>; |
+91
-8
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.clone = exports.resolveUrl = exports.lsRemote = exports.normalizeLocator = exports.normalizeRepoUrl = exports.splitRepoUrl = exports.isGitUrl = exports.TreeishProtocols = void 0; | ||
| exports.fetchChangedWorkspaces = exports.fetchChangedFiles = exports.fetchBase = exports.fetchRoot = exports.clone = exports.resolveUrl = exports.lsRemote = exports.normalizeLocator = exports.normalizeRepoUrl = exports.splitRepoUrl = exports.isGitUrl = exports.TreeishProtocols = void 0; | ||
| const tslib_1 = require("tslib"); | ||
| const core_1 = require("@yarnpkg/core"); | ||
| const fslib_1 = require("@yarnpkg/fslib"); | ||
| const git_url_parse_1 = tslib_1.__importDefault(require("git-url-parse")); | ||
| const querystring_1 = tslib_1.__importDefault(require("querystring")); | ||
| const semver_1 = tslib_1.__importDefault(require("semver")); | ||
| const url_1 = tslib_1.__importDefault(require("url")); | ||
| const clipanion_1 = require("clipanion"); | ||
| const git_url_parse_1 = (0, tslib_1.__importDefault)(require("git-url-parse")); | ||
| const querystring_1 = (0, tslib_1.__importDefault)(require("querystring")); | ||
| const semver_1 = (0, tslib_1.__importDefault)(require("semver")); | ||
| const url_1 = (0, tslib_1.__importDefault)(require("url")); | ||
| function makeGitEnvironment() { | ||
@@ -128,3 +129,3 @@ return { | ||
| } | ||
| catch (_b) { | ||
| catch { | ||
| parsedUrl = null; | ||
@@ -145,3 +146,3 @@ } | ||
| const normalizedRepoUrl = normalizeRepoUrl(repo, { git: true }); | ||
| const networkSettings = core_1.httpUtils.getNetworkSettings(`https://${git_url_parse_1.default(normalizedRepoUrl).resource}`, { configuration }); | ||
| const networkSettings = core_1.httpUtils.getNetworkSettings(`https://${(0, git_url_parse_1.default)(normalizedRepoUrl).resource}`, { configuration }); | ||
| if (!networkSettings.enableNetwork) | ||
@@ -256,3 +257,3 @@ throw new Error(`Request to '${normalizedRepoUrl}' has been blocked because of your configuration settings`); | ||
| const normalizedRepoUrl = normalizeRepoUrl(repo, { git: true }); | ||
| if (core_1.httpUtils.getNetworkSettings(`https://${git_url_parse_1.default(normalizedRepoUrl).resource}`, { configuration }).enableNetwork === false) | ||
| if (core_1.httpUtils.getNetworkSettings(`https://${(0, git_url_parse_1.default)(normalizedRepoUrl).resource}`, { configuration }).enableNetwork === false) | ||
| throw new Error(`Request to '${normalizedRepoUrl}' has been blocked because of your configuration settings`); | ||
@@ -273,1 +274,83 @@ const directory = await fslib_1.xfs.mktempPromise(); | ||
| exports.clone = clone; | ||
| async function fetchRoot(initialCwd) { | ||
| // Note: We can't just use `git rev-parse --show-toplevel`, because on Windows | ||
| // it may return long paths even when the cwd uses short paths, and we have no | ||
| // way to detect it from Node (not even realpath). | ||
| let match = null; | ||
| let cwd; | ||
| let nextCwd = initialCwd; | ||
| do { | ||
| cwd = nextCwd; | ||
| if (await fslib_1.xfs.existsPromise(fslib_1.ppath.join(cwd, `.git`))) | ||
| match = cwd; | ||
| nextCwd = fslib_1.ppath.dirname(cwd); | ||
| } while (match === null && nextCwd !== cwd); | ||
| return match; | ||
| } | ||
| exports.fetchRoot = fetchRoot; | ||
| async function fetchBase(root, { baseRefs }) { | ||
| if (baseRefs.length === 0) | ||
| throw new clipanion_1.UsageError(`Can't run this command with zero base refs specified.`); | ||
| const ancestorBases = []; | ||
| for (const candidate of baseRefs) { | ||
| const { code } = await core_1.execUtils.execvp(`git`, [`merge-base`, candidate, `HEAD`], { cwd: root }); | ||
| if (code === 0) { | ||
| ancestorBases.push(candidate); | ||
| } | ||
| } | ||
| if (ancestorBases.length === 0) | ||
| throw new clipanion_1.UsageError(`No ancestor could be found between any of HEAD and ${baseRefs.join(`, `)}`); | ||
| const { stdout: mergeBaseStdout } = await core_1.execUtils.execvp(`git`, [`merge-base`, `HEAD`, ...ancestorBases], { cwd: root, strict: true }); | ||
| const hash = mergeBaseStdout.trim(); | ||
| const { stdout: showStdout } = await core_1.execUtils.execvp(`git`, [`show`, `--quiet`, `--pretty=format:%s`, hash], { cwd: root, strict: true }); | ||
| const title = showStdout.trim(); | ||
| return { hash, title }; | ||
| } | ||
| exports.fetchBase = fetchBase; | ||
| // Note: This returns all changed files from the git diff, | ||
| // which can include files not belonging to a workspace | ||
| async function fetchChangedFiles(root, { base, project }) { | ||
| const ignorePattern = core_1.miscUtils.buildIgnorePattern(project.configuration.get(`changesetIgnorePatterns`)); | ||
| const { stdout: localStdout } = await core_1.execUtils.execvp(`git`, [`diff`, `--name-only`, `${base}`], { cwd: root, strict: true }); | ||
| const trackedFiles = localStdout.split(/\r\n|\r|\n/).filter(file => file.length > 0).map(file => fslib_1.ppath.resolve(root, fslib_1.npath.toPortablePath(file))); | ||
| const { stdout: untrackedStdout } = await core_1.execUtils.execvp(`git`, [`ls-files`, `--others`, `--exclude-standard`], { cwd: root, strict: true }); | ||
| const untrackedFiles = untrackedStdout.split(/\r\n|\r|\n/).filter(file => file.length > 0).map(file => fslib_1.ppath.resolve(root, fslib_1.npath.toPortablePath(file))); | ||
| const changedFiles = [...new Set([...trackedFiles, ...untrackedFiles].sort())]; | ||
| return ignorePattern | ||
| ? changedFiles.filter(p => !fslib_1.ppath.relative(project.cwd, p).match(ignorePattern)) | ||
| : changedFiles; | ||
| } | ||
| exports.fetchChangedFiles = fetchChangedFiles; | ||
| // Note: yarn artifacts are excluded from workspace change detection | ||
| // as they can be modified by changes to any workspace manifest file. | ||
| async function fetchChangedWorkspaces({ ref, project }) { | ||
| if (project.configuration.projectCwd === null) | ||
| throw new clipanion_1.UsageError(`This command can only be run from within a Yarn project`); | ||
| const ignoredPaths = [ | ||
| fslib_1.ppath.resolve(project.cwd, project.configuration.get(`cacheFolder`)), | ||
| fslib_1.ppath.resolve(project.cwd, project.configuration.get(`installStatePath`)), | ||
| fslib_1.ppath.resolve(project.cwd, project.configuration.get(`lockfileFilename`)), | ||
| fslib_1.ppath.resolve(project.cwd, project.configuration.get(`virtualFolder`)), | ||
| ]; | ||
| await project.configuration.triggerHook((hooks) => { | ||
| return hooks.populateYarnPaths; | ||
| }, project, (path) => { | ||
| if (path != null) { | ||
| ignoredPaths.push(path); | ||
| } | ||
| }); | ||
| const root = await fetchRoot(project.configuration.projectCwd); | ||
| if (root == null) | ||
| throw new clipanion_1.UsageError(`This command can only be run on Git repositories`); | ||
| const base = await fetchBase(root, { baseRefs: typeof ref === `string` ? [ref] : project.configuration.get(`changesetBaseRefs`) }); | ||
| const changedFiles = await fetchChangedFiles(root, { base: base.hash, project }); | ||
| return new Set(core_1.miscUtils.mapAndFilter(changedFiles, file => { | ||
| const workspace = project.tryWorkspaceByFilePath(file); | ||
| if (workspace === null) | ||
| return core_1.miscUtils.mapAndFilter.skip; | ||
| if (ignoredPaths.some(ignoredPath => file.startsWith(ignoredPath))) | ||
| return core_1.miscUtils.mapAndFilter.skip; | ||
| return workspace; | ||
| })); | ||
| } | ||
| exports.fetchChangedWorkspaces = fetchChangedWorkspaces; |
+1
-1
@@ -8,3 +8,3 @@ "use strict"; | ||
| const GitResolver_1 = require("./GitResolver"); | ||
| const gitUtils = tslib_1.__importStar(require("./gitUtils")); | ||
| const gitUtils = (0, tslib_1.__importStar)(require("./gitUtils")); | ||
| exports.gitUtils = gitUtils; | ||
@@ -11,0 +11,0 @@ const plugin = { |
+6
-4
| { | ||
| "name": "@yarnpkg/plugin-git", | ||
| "version": "2.4.0", | ||
| "version": "2.5.0-rc.1", | ||
| "license": "BSD-2-Clause", | ||
@@ -8,3 +8,4 @@ "main": "./lib/index.js", | ||
| "@types/semver": "^7.1.0", | ||
| "@yarnpkg/fslib": "^2.5.0", | ||
| "@yarnpkg/fslib": "^2.6.0-rc.11", | ||
| "clipanion": "^3.0.1", | ||
| "git-url-parse": "11.1.2", | ||
@@ -15,7 +16,7 @@ "semver": "^7.1.2", | ||
| "peerDependencies": { | ||
| "@yarnpkg/core": "^3.0.0" | ||
| "@yarnpkg/core": "^3.1.0-rc.12" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/git-url-parse": "^9.0.0", | ||
| "@yarnpkg/core": "3.0.0" | ||
| "@yarnpkg/core": "^3.1.0-rc.12" | ||
| }, | ||
@@ -41,3 +42,4 @@ "repository": { | ||
| }, | ||
| "stableVersion": "2.4.0", | ||
| "typings": "./lib/index.d.ts" | ||
| } |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
43865
14.5%643
18.63%7
16.67%3
50%+ Added
+ Added
Updated