Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// We only care about workspaces, and we only care about workspaces that will be bumped
if (!releases.has(resolution))
continue;
// Quick note: we don't want to check whether the workspace pointer
// by `resolution` is private, because while it doesn't makes sense
// to bump a private package because its dependencies changed, the
// opposite isn't true: a (public) package might need to be bumped
// because one of its dev dependencies is a (private) package whose
// behavior sensibly changed.
if (!hasDepsErrors && (files.length > 0 || hasDiffErrors))
report.reportSeparator();
report.reportError(MessageName.UNNAMED, `${structUtils.prettyLocator(configuration, workspace.anchoredLocator)} doesn't have a bump strategy attached, but depends on ${structUtils.prettyLocator(configuration, pkg)} which will be re-released.`);
hasDepsErrors = true;
}
}
if (hasDiffErrors || hasDepsErrors) {
report.reportSeparator();
report.reportInfo(MessageName.UNNAMED, `This command detected that at least some workspaces have received modifications but no explicit instructions as to how they had to be released (if needed).`);
report.reportInfo(MessageName.UNNAMED, `To correct these errors, run \`yarn version ... --deferred\` in each of them with the adequate bump strategies, then run \`yarn version check\` again.`);
}
});
let useWorkspaceProtocol = false;
if (range.startsWith(WorkspaceResolver.protocol)) {
range = range.slice(WorkspaceResolver.protocol.length);
useWorkspaceProtocol = true;
// Workspaces referenced through their path never get upgraded ("workspace:packages/yarnpkg-core")
if (range === workspace.relativeCwd) {
continue;
}
}
// We can only auto-upgrade the basic semver ranges (we can't auto-upgrade ">=1.0.0 <2.0.0", for example)
const parsed = range.match(SUPPORTED_UPGRADE_REGEXP);
if (!parsed) {
report.reportWarning(MessageName.UNNAMED, `Couldn't auto-upgrade range ${range} (in ${structUtils.prettyLocator(configuration, workspace.anchoredLocator)})`);
continue;
}
let newRange = `${parsed[1]}${newVersion}`;
if (useWorkspaceProtocol)
newRange = `${WorkspaceResolver.protocol}${newRange}`;
const newDescriptor = structUtils.makeDescriptor(descriptor, newRange);
dependent.manifest[set].set(identHash, newDescriptor);
}
};
}, async report => {
const credentials = await getCredentials(prompt);
const url = `/-/user/org.couchdb.user:${encodeURIComponent(credentials.name)}`;
try {
const response = await npmHttpUtils.put(url, credentials, {
configuration,
registry,
json: true,
authType: npmHttpUtils.AuthType.NO_AUTH,
});
// @ts-ignore
await setAuthToken(registry, response.token, {configuration});
return report.reportInfo(MessageName.UNNAMED, `Successfully logged in`);
} catch (error) {
return report.reportError(MessageName.AUTHENTICATION_INVALID, `Invalid Authentication`);
}
});
bundleUrl = asset.browser_download_url;
bundleVersion = release.version.version;
candidates = satisfying.map(release => release.version.version);
} else {
throw new UsageError(`Invalid version descriptor "${this.range}"`);
}
if (candidates.length === 1)
report.reportInfo(MessageName.UNNAMED, `Found matching release with ${configuration.format(bundleVersion, `#87afff`)}`);
else
report.reportInfo(MessageName.UNNAMED, `Selecting the highest release amongst ${configuration.format(bundleVersion, `#87afff`)} and ${candidates.length - 1} other${candidates.length === 2 ? `` : `s`}`);
if (!this.dryRun) {
report.reportInfo(MessageName.UNNAMED, `Downloading ${configuration.format(bundleUrl, `green`)}`);
const bundleBuffer = await httpUtils.get(bundleUrl, {configuration});
await setVersion(project, bundleVersion, bundleBuffer, {report});
}
});
const newVersion = workspace.manifest.raw.nextVersion.semver;
if (typeof newVersion === `undefined`)
return;
if (typeof newVersion !== `string`)
throw new Error(`Assertion failed: The nextVersion.semver should have been a string`);
const oldVersion = workspace.manifest.version;
workspace.manifest.version = newVersion;
workspace.manifest.raw.nextVersion = undefined;
const identString = workspace.manifest.name !== null
? structUtils.stringifyIdent(workspace.manifest.name)
: null;
report.reportInfo(MessageName.UNNAMED, `${structUtils.prettyLocator(configuration, workspace.anchoredLocator)}: Bumped to ${newVersion}`);
report.reportJson({cwd: workspace.cwd, ident: identString, oldVersion, newVersion});
const dependents = allDependents.get(workspace);
if (typeof dependents === `undefined`)
return;
for (const [dependent, set, identHash] of dependents) {
const descriptor = dependent.manifest[set].get(identHash);
if (typeof descriptor === `undefined`)
throw new Error(`Assertion failed: The dependency should have existed`);
let range = descriptor.range;
let useWorkspaceProtocol = false;
if (range.startsWith(WorkspaceResolver.protocol)) {
range = range.slice(WorkspaceResolver.protocol.length);
break;
}
}
if (commandPromises.length === 0) {
const cycle = Array.from(needsProcessing.values()).map(workspace => {
return structUtils.prettyLocator(configuration, workspace.anchoredLocator);
}).join(`, `);
return report.reportError(MessageName.CYCLIC_DEPENDENCIES, `Dependency cycle detected (${cycle})`);
}
const exitCodes: Array = await Promise.all(commandPromises);
if ((this.topological || this.topologicalDev) && exitCodes.some(exitCode => exitCode !== 0)) {
report.reportError(MessageName.UNNAMED, `The command failed for workspaces that are depended upon by other workspaces; can't satisfy the dependency graph`);
}
}
});
}
}
};
let ready = false;
if (!this.force && xfs.existsSync(ppath.join(target, `.git` as Filename))) {
report.reportInfo(MessageName.UNNAMED, `Fetching the latest commits`);
report.reportSeparator();
try {
await runWorkflow(UPDATE_WORKFLOW(this));
ready = true;
} catch (error) {
report.reportSeparator();
report.reportWarning(MessageName.UNNAMED, `Repository update failed; we'll try to regenerate it`);
}
}
if (!ready) {
report.reportInfo(MessageName.UNNAMED, `Cloning the remote repository`);
report.reportSeparator();
await xfs.removePromise(target);
await xfs.mkdirpPromise(target);
await runWorkflow(CLONE_WORKFLOW(this, target));
}
report.reportSeparator();
report.reportInfo(MessageName.UNNAMED, `Building a fresh bundle`);
report.reportSeparator();
}, async report => {
const root = await fetchRoot(this.context.cwd);
const base = await fetchBase(root);
const files = await fetchChangedFiles(root, {base: base.hash});
const workspaces = [...new Set(files.map(file => project.getWorkspaceByFilePath(file)))];
let hasDiffErrors = false;
let hasDepsErrors = false;
report.reportInfo(MessageName.UNNAMED, `Your PR was started right after ${configuration.format(base.hash.slice(0, 7), `yellow`)} ${configuration.format(base.message, `magenta`)}`);
if (files.length > 0) {
report.reportInfo(MessageName.UNNAMED, `you have changed the following files since then:`);
for (const file of files) {
report.reportInfo(null, file);
}
}
const status = await fetchWorkspacesStatus(workspaces, {root, base: base.hash});
if (status.undecided.length > 0) {
if (!hasDiffErrors && files.length > 0)
report.reportSeparator();
for (const workspace of status.undecided)
report.reportError(MessageName.UNNAMED, `${structUtils.prettyLocator(configuration, workspace.anchoredLocator)} has been modified but doesn't have a bump strategy attached`);
if (!this.force && xfs.existsSync(ppath.join(target, `.git` as Filename))) {
report.reportInfo(MessageName.UNNAMED, `Fetching the latest commits`);
report.reportSeparator();
try {
await runWorkflow(UPDATE_WORKFLOW(this));
ready = true;
} catch (error) {
report.reportSeparator();
report.reportWarning(MessageName.UNNAMED, `Repository update failed; we'll try to regenerate it`);
}
}
if (!ready) {
report.reportInfo(MessageName.UNNAMED, `Cloning the remote repository`);
report.reportSeparator();
await xfs.removePromise(target);
await xfs.mkdirpPromise(target);
await runWorkflow(CLONE_WORKFLOW(this, target));
}
report.reportSeparator();
report.reportInfo(MessageName.UNNAMED, `Building a fresh bundle`);
report.reportSeparator();
await runWorkflow(BUILD_WORKFLOW(this));
report.reportSeparator();