Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async execute() {
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);
if (workspace.manifest.private)
throw new UsageError(`Private workspaces cannot be published`);
if (workspace.manifest.name === null || workspace.manifest.version === null)
throw new UsageError(`Workspaces must have valid names and versions to be published on an external registry`);
await project.resolveEverything({
lockfileOnly: true,
report: new ThrowReport(),
});
// We store it so that TS knows that it's non-null
const ident = workspace.manifest.name;
const version = workspace.manifest.version;
const registry = npmConfigUtils.getPublishRegistry(workspace.manifest, {configuration});
const report = await StreamReport.start({
configuration,
stdout: this.context.stdout,
}, async report => {
// Not an error if --tolerate-republish is set
if (this.tolerateRepublish) {
try {
const registryData = await npmHttpUtils.get(npmHttpUtils.getIdentUrl(ident), {
export async function fetchDescriptorFrom(ident: Ident, range: string, {project, cache, preserveModifier = true}: {project: Project, cache: Cache, preserveModifier?: boolean}) {
const latestDescriptor = structUtils.makeDescriptor(ident, range);
const report = new ThrowReport();
const fetcher = project.configuration.makeFetcher();
const resolver = project.configuration.makeResolver();
const resolverOptions = {checksums: project.storedChecksums, project, cache, fetcher, report, resolver};
let candidateLocators;
try {
candidateLocators = await resolver.getCandidates(latestDescriptor, new Map(), resolverOptions);
} catch {
return null;
}
if (candidateLocators.length === 0)
return null;
async function makeResolveFn(project: Project) {
const cache = await Cache.find(project.configuration);
const resolver = project.configuration.makeResolver();
const fetcher = project.configuration.makeFetcher();
const checksums = project.storedChecksums;
const yarnReport = new ThrowReport();
const fetchOptions = {project, fetcher, cache, checksums, report: yarnReport};
const resolveOptions = {...fetchOptions, resolver};
return async (descriptor: Descriptor) => {
const candidates = await resolver.getCandidates(descriptor, new Map(), resolveOptions);
if (candidates.length === 0)
return null;
return await resolver.resolve(candidates[0], resolveOptions);
};
}
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);
if (await packUtils.hasPackScripts(workspace)) {
if (this.installIfNeeded) {
await project.install({
cache: await Cache.find(configuration),
report: new ThrowReport(),
});
} else {
await project.resolveEverything({
lockfileOnly: true,
report: new ThrowReport(),
});
}
}
const target = typeof this.out !== `undefined`
? ppath.resolve(this.context.cwd, interpolateOutputName(this.out, {workspace}))
: ppath.resolve(workspace.cwd, `package.tgz` as Filename);
const report = await StreamReport.start({
configuration,
stdout: this.context.stdout,
json: this.json,
}, async report => {
await packUtils.prepareForPack(workspace, {report}, async () => {
report.reportJson({base: workspace.cwd});
async executeInteractive() {
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 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)))];
if (workspaces.length === 0)
return;
const status = await fetchWorkspacesStatus(workspaces, {root, base: base.hash});
if (status.undecided.length === 0)
if (fetchUndecidedDependentWorkspaces(status, {project}).length === 0)
return;
const useListInput = function (value: T, values: Array, {active, minus, plus, set}: {active: boolean, minus: string, plus: string, set: (value: T) => void}) {
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`)}`);