Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(forge): add filtering to workspace() #78

Merged
merged 2 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 11 additions & 25 deletions tool/forge/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,6 @@
import { compile, targets } from "@roka/forge/compile";
import { workspace } from "@roka/forge/package";
import { release } from "@roka/forge/release";
import { common } from "@std/path/common";
import { resolve } from "@std/path/resolve";

async function filter(packages: string[]) {
return (await workspace())
.filter((pkg) =>
packages.length === 0 ||
packages.includes(pkg.module) ||
packages.map((f) => resolve(f)).some((path) =>
common([resolve(pkg.directory), path]) === path
)
);
}

function compileCommand(targets: string[]) {
return new Command()
Expand All @@ -46,10 +33,9 @@
.option("--checksum", "Create a checksum file.", { default: false })
.option("--install=[directory:file]", "Install for local user.")
.option("--concurrency=<number:number>", "Max concurrent compilations.")
.action(async (options, ...names) => {
const packages = (await filter(names)).filter((pkg) =>
pkg.config.compile
);
.action(async (options, ...filter) => {
const packages = (await workspace({ filter }))
.filter((pkg) => pkg.config.compile);

Check warning on line 38 in tool/forge/cli.ts

View check run for this annotation

Codecov / codecov/patch

tool/forge/cli.ts#L36-L38

Added lines #L36 - L38 were not covered by tests
await pool(packages.map(async (pkg) => {
const artifacts = await compile(pkg, options);
console.log(`📦 Compiled ${pkg.module}`);
Expand All @@ -74,8 +60,9 @@
"GitHub personal token for GitHub actions.",
{ prefix: "GITHUB_" },
)
.action(async (options, ...names) => {
const packages = (await filter(names)).filter((pkg) => pkg.update);
.action(async (options, ...filter) => {
const packages = (await workspace({ filter }))
.filter((pkg) => pkg.update);

Check warning on line 65 in tool/forge/cli.ts

View check run for this annotation

Codecov / codecov/patch

tool/forge/cli.ts#L63-L65

Added lines #L63 - L65 were not covered by tests
const pr = await bump(packages, options);
if (pr) console.log(`🚀 Created version bump pull request [${pr.url}]`);
else console.log("📦 Bumped package versions");
Expand All @@ -92,10 +79,9 @@
"GitHub personal token for GitHub actions.",
{ prefix: "GITHUB_", required: true },
)
.action(async (options, ...names) => {
const packages = (await filter(names)).filter((pkg) =>
pkg.config.version !== pkg.release?.version
);
.action(async (options, ...filter) => {
const packages = (await workspace({ filter }))
.filter((pkg) => pkg.config.version !== pkg.release?.version);

Check warning on line 84 in tool/forge/cli.ts

View check run for this annotation

Codecov / codecov/patch

tool/forge/cli.ts#L82-L84

Added lines #L82 - L84 were not covered by tests
await pool(packages.map(async (pkg) => {
const [rls, assets] = await release(pkg, options);
console.log(`🚀 Released ${pkg.module} [${rls.url}]`);
Expand All @@ -111,8 +97,8 @@
.option("--changelog", "Print changelog of updated packages.", {
default: false,
})
.action(async ({ changelog }, ...names) => {
const packages = await filter(names);
.action(async ({ changelog }, ...filter) => {
const packages = await workspace({ filter });

Check warning on line 101 in tool/forge/cli.ts

View check run for this annotation

Codecov / codecov/patch

tool/forge/cli.ts#L100-L101

Added lines #L100 - L101 were not covered by tests
new Table().body(
packages.map((pkg) => [
"📦",
Expand Down
Loading