Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
| `dependency-threshold` | Threshold for warning about significant increase in number of dependencies | No | `10` |
| `size-threshold` | Threshold (in bytes) for warning about significant increase in package size | No | `100000` |
| `duplicate-threshold` | Threshold for warning about packages with multiple versions | No | `1` |
| `exclude-packages` | Regular expression pattern to exclude packages from analysis | No | None |
| `base-packages` | Glob pattern for base branch pack files (e.g., `"./base-packs/*.tgz"`) | No | None |
| `source-packages` | Glob pattern for source branch pack files (e.g., `"./source-packs/*.tgz"`) | No | None |
| `pack-size-threshold` | Threshold (in bytes) for warning about significant increase in total pack size | No | `50000` |
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ inputs:
description: 'Threshold for warning about packages with multiple versions'
required: false
default: '1'
exclude-packages:
description: 'Regular expression pattern to exclude packages from analysis'
required: false

runs:
using: node24
Expand Down
57 changes: 39 additions & 18 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19744,10 +19744,10 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
(0, command_1.issueCommand)("error", (0, utils_1.toCommandProperties)(properties), message instanceof Error ? message.toString() : message);
}
exports.error = error;
function warning(message, properties = {}) {
function warning2(message, properties = {}) {
(0, command_1.issueCommand)("warning", (0, utils_1.toCommandProperties)(properties), message instanceof Error ? message.toString() : message);
}
exports.warning = warning;
exports.warning = warning2;
function notice(message, properties = {}) {
(0, command_1.issueCommand)("notice", (0, utils_1.toCommandProperties)(properties), message instanceof Error ? message.toString() : message);
}
Expand Down Expand Up @@ -24406,6 +24406,23 @@ async function run() {
const lockfilePath = detectLockfile(workspacePath);
const token = core4.getInput("github-token", { required: true });
const prNumber = parseInt(core4.getInput("pr-number", { required: true }), 10);
const dependencyThreshold = parseInt(
core4.getInput("dependency-threshold") || "10",
10
);
const sizeThreshold = parseInt(
core4.getInput("size-threshold") || "100000",
10
);
const duplicateThreshold = parseInt(
core4.getInput("duplicate-threshold") || "1",
10
);
const packSizeThreshold = parseInt(
core4.getInput("pack-size-threshold") || "50000",
10
);
const excludePackages = core4.getInput("exclude-packages");
if (Number.isNaN(prNumber) || prNumber < 1) {
core4.info("No valid pull request number was found. Skipping.");
return;
Expand Down Expand Up @@ -24437,22 +24454,26 @@ async function run() {
}
const currentDeps = parseLockfile(lockfilePath, currentPackageLock);
const baseDeps = parseLockfile(lockfilePath, basePackageLock);
const dependencyThreshold = parseInt(
core4.getInput("dependency-threshold") || "10",
10
);
const sizeThreshold = parseInt(
core4.getInput("size-threshold") || "100000",
10
);
const duplicateThreshold = parseInt(
core4.getInput("duplicate-threshold") || "1",
10
);
const packSizeThreshold = parseInt(
core4.getInput("pack-size-threshold") || "50000",
10
);
if (excludePackages) {
try {
const excludeRegex = new RegExp(excludePackages);
core4.info(`Excluding packages matching pattern: ${excludePackages}`);
for (const packageName of currentDeps.keys()) {
if (excludeRegex.test(packageName)) {
currentDeps.delete(packageName);
}
}
for (const packageName of baseDeps.keys()) {
if (excludeRegex.test(packageName)) {
baseDeps.delete(packageName);
}
}
} catch (err) {
core4.warning(
`Invalid exclude-packages regex pattern: ${excludePackages}`
);
}
}
core4.info(`Dependency threshold set to ${dependencyThreshold}`);
core4.info(`Size threshold set to ${formatBytes(sizeThreshold)}`);
core4.info(`Duplicate threshold set to ${duplicateThreshold}`);
Expand Down
55 changes: 39 additions & 16 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ async function run(): Promise<void> {
const lockfilePath = detectLockfile(workspacePath);
const token = core.getInput('github-token', {required: true});
const prNumber = parseInt(core.getInput('pr-number', {required: true}), 10);
const dependencyThreshold = parseInt(
core.getInput('dependency-threshold') || '10',
10
);
const sizeThreshold = parseInt(
core.getInput('size-threshold') || '100000',
10
);
const duplicateThreshold = parseInt(
core.getInput('duplicate-threshold') || '1',
10
);
const packSizeThreshold = parseInt(
core.getInput('pack-size-threshold') || '50000',
10
);
const excludePackages = core.getInput('exclude-packages');

if (Number.isNaN(prNumber) || prNumber < 1) {
core.info('No valid pull request number was found. Skipping.');
Expand Down Expand Up @@ -84,22 +101,28 @@ async function run(): Promise<void> {
const currentDeps = parseLockfile(lockfilePath, currentPackageLock);
const baseDeps = parseLockfile(lockfilePath, basePackageLock);

const dependencyThreshold = parseInt(
core.getInput('dependency-threshold') || '10',
10
);
const sizeThreshold = parseInt(
core.getInput('size-threshold') || '100000',
10
);
const duplicateThreshold = parseInt(
core.getInput('duplicate-threshold') || '1',
10
);
const packSizeThreshold = parseInt(
core.getInput('pack-size-threshold') || '50000',
10
);
// Filter out excluded packages if pattern is provided
if (excludePackages) {
try {
const excludeRegex = new RegExp(excludePackages);
core.info(`Excluding packages matching pattern: ${excludePackages}`);

for (const packageName of currentDeps.keys()) {
if (excludeRegex.test(packageName)) {
currentDeps.delete(packageName);
}
}
for (const packageName of baseDeps.keys()) {
if (excludeRegex.test(packageName)) {
baseDeps.delete(packageName);
}
}
} catch (err) {
core.warning(
`Invalid exclude-packages regex pattern: ${excludePackages}`
);
}
}

core.info(`Dependency threshold set to ${dependencyThreshold}`);
core.info(`Size threshold set to ${formatBytes(sizeThreshold)}`);
Expand Down