Skip to content

Commit

Permalink
feat: added support to bump all workspace packages
Browse files Browse the repository at this point in the history
  • Loading branch information
cometkim committed Aug 28, 2020
1 parent 48dbed5 commit 1ef4706
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 42 deletions.
28 changes: 12 additions & 16 deletions .yarn/plugins/@yarnpkg/plugin-bump.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,27 +178,23 @@ module.exports = {
}

async execute() {
const configuration = await core_1.Configuration.find(this.context.cwd, this.context.plugins);
const {
workspace
} = await core_1.Project.find(configuration, this.context.cwd);

if (!workspace) {
throw new Error(`Workspace setting is not found.
Please run the command in path where yarn initialized.`);
}

if (!plugin_essentials_1.default.commands) {
throw new Error(`Yarn commands could not be loaded.
Please upgrade to Yarn 2.`);
}

const dependencies = this.getDependencies(workspace);
const descriptors = [...dependencies.values()].filter(descriptor => this.resolveFullPackageName(descriptor).match(this.packages.join('|') || '.*')).filter(descriptor => !this.resolveFullPackageName(descriptor).match(this.exclude.join('|') || null));
const packageNames = descriptors.map(this.resolveFullPackageName);
const cli = clipanion_1.Cli.from(plugin_essentials_1.default.commands);
const result = await cli.runExit(['up', ...packageNames], this.context);
return result;
const configuration = await core_1.Configuration.find(this.context.cwd, this.context.plugins);
const {
project
} = await core_1.Project.find(configuration, this.context.cwd);

for (const workspace of project.workspaces) {
const dependencies = this.getDependencies(workspace);
const descriptors = [...dependencies.values()].filter(descriptor => this.resolveFullPackageName(descriptor).match(this.packages.join('|') || '.*')).filter(descriptor => !this.resolveFullPackageName(descriptor).match(this.exclude.join('|') || null));
const packageNames = descriptors.map(this.resolveFullPackageName);
const cli = clipanion_1.Cli.from(plugin_essentials_1.default.commands);
await cli.runExit(['up', ...packageNames], this.context);
}
}

}
Expand Down
46 changes: 20 additions & 26 deletions sources/commands/bump.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,41 +69,35 @@ export default class BumpCommand extends BaseCommand {

@Command.Path('bump')
async execute(): Promise<number | void> {
const configuration = await Configuration.find(
this.context.cwd,
this.context.plugins
);
const { workspace } = await Project.find(
configuration,
this.context.cwd
);

if (!workspace) {
throw new Error(
`Workspace setting is not found.
Please run the command in path where yarn initialized.`
);
}

if (!Essentials.commands) {
throw new Error(
`Yarn commands could not be loaded.
Please upgrade to Yarn 2.`
);
}

const dependencies = this.getDependencies(workspace);
const descriptors = [...dependencies.values()]
.filter(descriptor => this.resolveFullPackageName(descriptor)
.match(this.packages.join('|') || '.*' as any))
.filter(descriptor => !this.resolveFullPackageName(descriptor)
.match(this.exclude.join('|') || null as any));
const configuration = await Configuration.find(
this.context.cwd,
this.context.plugins
);

const { project } = await Project.find(
configuration,
this.context.cwd
);

const packageNames = descriptors.map(this.resolveFullPackageName);
for (const workspace of project.workspaces) {
const dependencies = this.getDependencies(workspace);
const descriptors = [...dependencies.values()]
.filter(descriptor => this.resolveFullPackageName(descriptor)
.match(this.packages.join('|') || '.*' as any))
.filter(descriptor => !this.resolveFullPackageName(descriptor)
.match(this.exclude.join('|') || null as any));

const cli = Cli.from(Essentials.commands);
const result = await cli.runExit(['up', ...packageNames], this.context);
const packageNames = descriptors.map(this.resolveFullPackageName);

return result;
const cli = Cli.from(Essentials.commands);
await cli.runExit(['up', ...packageNames], this.context);
}
}
}

0 comments on commit 1ef4706

Please sign in to comment.