Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let interlaced = this.interlaced;
// No need to buffer the output if we're executing the commands sequentially
if (!this.parallel)
interlaced = true;
const needsProcessing = new Map();
const processing = new Set();
const concurrency = this.parallel ? Math.max(1, cpus().length / 2) : 1;
const limit = pLimit(this.jobs || concurrency);
let commandCount = 0;
const report = await StreamReport.start({
configuration,
stdout: this.context.stdout,
}, async report => {
const runCommand = async (workspace: Workspace, {commandIndex}: {commandIndex: number}) => {
if (!this.parallel && this.verbose && commandIndex > 1)
report.reportSeparator();
const prefix = getPrefix(workspace, {configuration, verbose: this.verbose, commandIndex});
const [stdout, stdoutEnd] = createStream(report, {prefix, interlaced});
const [stderr, stderrEnd] = createStream(report, {prefix, interlaced});
try {
const exitCode = (await this.cli.run([this.commandName, ...this.args], {
cwd: workspace.cwd,
stdout,
async execute() {
const configuration = await Configuration.find(this.context.cwd, this.context.plugins);
const {project, workspace} = await Project.find(configuration, this.context.cwd);
const cache = await Cache.find(configuration);
if (!workspace)
throw new WorkspaceRequiredError(this.context.cwd);
const applyReport = await StreamReport.start({
configuration,
json: this.json,
stdout: this.context.stdout,
}, async report => {
const allDependents: Map> = new Map();
// First we compute the reverse map to figure out which workspace is
// depended upon by which other.
//
// Note that we need to do this before applying the new versions,
// otherwise the `findWorkspacesByDescriptor` calls won't be able to
// resolve the workspaces anymore (because the workspace versions will
const prompt = inquirer.createPromptModule({
input: this.context.stdin,
output: this.context.stdout,
});
let registry: string;
if (this.scope && this.publish)
registry = npmConfigUtils.getScopeRegistry(this.scope, {configuration, type: npmConfigUtils.RegistryType.PUBLISH_REGISTRY});
else if (this.scope)
registry = npmConfigUtils.getScopeRegistry(this.scope, {configuration});
else if (this.publish)
registry = npmConfigUtils.getPublishRegistry((await openWorkspace(configuration, this.context.cwd)).manifest, {configuration});
else
registry = npmConfigUtils.getDefaultRegistry({configuration});
const report = await StreamReport.start({
configuration,
stdout: this.context.stdout,
}, 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});
async execute() {
const configuration = await Configuration.find(this.context.cwd, this.context.plugins);
const report = await StreamReport.start({
configuration,
stdout: this.context.stdout,
}, async report => {
const {project} = await Project.find(configuration, this.context.cwd);
const name = this.name!;
const candidatePath = ppath.resolve(this.context.cwd, NodeFS.toPortablePath(name));
let pluginBuffer;
if (await xfs.existsPromise(candidatePath)) {
report.reportInfo(MessageName.UNNAMED, `Reading ${configuration.format(candidatePath, `green`)}`);
pluginBuffer = await xfs.readFilePromise(candidatePath);
} else {
const ident = structUtils.tryParseIdent(name);
if (!workspace)
throw new WorkspaceRequiredError(this.context.cwd);
const topLevelWorkspace = project.topLevelWorkspace;
for (const pattern of this.patterns) {
const descriptor = structUtils.parseDescriptor(pattern);
const dependencyMeta = topLevelWorkspace.manifest.ensureDependencyMeta(descriptor);
dependencyMeta.unplugged = true;0;
}
await topLevelWorkspace.persistManifest();
const report = await StreamReport.start({
configuration,
stdout: this.context.stdout,
}, async report => {
await project.install({cache, report});
});
return report.exitCode();
}
}
async execute() {
const configuration = await Configuration.find(this.context.cwd, this.context.plugins);
const {project} = await Project.find(configuration, this.context.cwd);
const report = await StreamReport.start({
configuration,
stdout: this.context.stdout,
}, async (report: StreamReport) => {
if (this.range === `latest`)
this.range = `*`;
let candidates: Array = [];
let bundleUrl: string;
let bundleVersion: string;
if (BERRY_RANGES.has(this.range)) {
bundleUrl = `https://github.com/yarnpkg/berry/raw/master/packages/yarnpkg-cli/bin/yarn.js`;
bundleVersion = `rc`;
candidates = [bundleVersion];
} else if (this.range === `nightly-v1`) {
async executeStandard() {
const configuration = await Configuration.find(this.context.cwd, this.context.plugins);
const {project, workspace} = await Project.find(configuration, this.context.cwd);
if (!workspace)
throw new WorkspaceRequiredError(this.context.cwd);
await project.resolveEverything({
lockfileOnly: true,
report: new ThrowReport(),
});
const report = await StreamReport.start({
configuration,
stdout: this.context.stdout,
}, 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:`);
]);
hasChanged = true;
}
}
if (hasChanged) {
await configuration.triggerMultipleHooks(
(hooks: Hooks) => hooks.afterWorkspaceDependencyReplacement,
afterWorkspaceDependencyReplacementList,
);
if (askedQuestions)
this.context.stdout.write(`\n`);
const installReport = await StreamReport.start({
configuration,
stdout: this.context.stdout,
}, async report => {
await project.install({cache, report});
});
return installReport.exitCode();
}
}
}
async execute() {
const configuration = await Configuration.find(this.context.cwd, this.context.plugins);
let registry: string;
if (this.scope && this.publish)
registry = npmConfigUtils.getScopeRegistry(this.scope, {configuration, type: npmConfigUtils.RegistryType.PUBLISH_REGISTRY});
else if (this.scope)
registry = npmConfigUtils.getScopeRegistry(this.scope, {configuration});
else if (this.publish)
registry = npmConfigUtils.getPublishRegistry((await openWorkspace(configuration, this.context.cwd)).manifest, {configuration});
else
registry = npmConfigUtils.getDefaultRegistry({configuration});
const report = await StreamReport.start({
configuration,
stdout: this.context.stdout,
}, async report => {
try {
const response = await npmHttpUtils.get(`/-/whoami`, {
configuration,
registry,
authType: npmHttpUtils.AuthType.ALWAYS_AUTH,
json: true,
});
report.reportInfo(MessageName.UNNAMED, response.username);
} catch (err) {
if (err.name !== `HTTPError`) {
throw err;
} else if (err.response.statusCode === 401 || err.response.statusCode === 403) {