Skip to content

Commit 9d5b522

Browse files
committed
pnpfeat: add allow component not found parameter
1 parent 4e6f2d4 commit 9d5b522

7 files changed

Lines changed: 922 additions & 1174 deletions

File tree

action.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ inputs:
2323
mcc_project:
2424
description: "MACH Composer Project"
2525
required: true
26+
allow_component_not_found:
27+
description: "Allow component not found in MCC. This will cause the component to always be marked as changed."
28+
required: false
29+
default: "false"
2630
fallback_reference:
2731
description: "Fallback git reference to compare against (useful for hotfix branches)"
2832
required: false

dist/index.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19701,7 +19701,7 @@ var require_core = __commonJS({
1970119701
return inputs.map((input) => input.trim());
1970219702
}
1970319703
exports.getMultilineInput = getMultilineInput;
19704-
function getBooleanInput(name, options) {
19704+
function getBooleanInput2(name, options) {
1970519705
const trueValue = ["true", "True", "TRUE"];
1970619706
const falseValue = ["false", "False", "FALSE"];
1970719707
const val = getInput2(name, options);
@@ -19712,7 +19712,7 @@ var require_core = __commonJS({
1971219712
throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}
1971319713
Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
1971419714
}
19715-
exports.getBooleanInput = getBooleanInput;
19715+
exports.getBooleanInput = getBooleanInput2;
1971619716
function setOutput2(name, value) {
1971719717
const filePath = process.env["GITHUB_OUTPUT"] || "";
1971819718
if (filePath) {
@@ -35345,7 +35345,10 @@ var getTurboPlan = async (commit) => {
3534535345
write(chunk, encoding, callback) {
3534635346
}
3534735347
});
35348-
const command = `pnpm --silent turbo run build --filter="...[${commit}]" --dry=json`;
35348+
let command = `pnpm --silent turbo run build --dry=json`;
35349+
if (commit) {
35350+
command += ` --filter="...[${commit}]" `;
35351+
}
3534935352
const options = {
3535035353
env: {
3535135354
TURBO_TELEMETRY_DISABLED: "1",
@@ -35413,7 +35416,7 @@ var Client = class {
3541335416
this.token = token.accessToken;
3541435417
return this.token;
3541535418
};
35416-
getLatestVersion = async (component, branch) => {
35419+
getLatestVersion = async (component, branch, allowComponentNotFound) => {
3541735420
const url = `https://api.mach.cloud/organizations/${this.credentials.organization}/projects/${this.credentials.project}/components/${component}/latest?branch=${branch}`;
3541835421
console.log("Request info from " + url);
3541935422
const response = await fetch(url, {
@@ -35422,6 +35425,12 @@ var Client = class {
3542235425
}
3542335426
});
3542435427
if (!response.ok) {
35428+
if (response.status === 404 && allowComponentNotFound) {
35429+
console.warn(
35430+
`Component ${component} not found in branch ${branch}. Continuing without it.`
35431+
);
35432+
return null;
35433+
}
3542535434
console.log(await response.text());
3542635435
throw new Error("Failed to fetch latest version");
3542735436
}
@@ -35451,7 +35460,8 @@ async function run() {
3545135460
core3.info(`Processing ${pkgConfig.name}`);
3545235461
const commitHash = await client.getLatestVersion(
3545335462
pkgConfig.name,
35454-
inputs.branch
35463+
inputs.branch,
35464+
inputs.allowComponentNotFound
3545535465
);
3545635466
let affectedPackages = [];
3545735467
if (commitHash) {
@@ -35461,6 +35471,8 @@ async function run() {
3546135471
pkgConfig,
3546235472
inputs.fallbackReference
3546335473
);
35474+
} else if (inputs.allowComponentNotFound) {
35475+
affectedPackages = [pkgConfig.scope];
3546435476
}
3546535477
for (const pkg of affectedPackages) {
3546635478
if (!result.includes(pkg)) {
@@ -35483,7 +35495,8 @@ var readInputs = () => {
3548335495
mccClientID: core3.getInput("mcc_client_id"),
3548435496
mccClientSecret: core3.getInput("mcc_client_secret"),
3548535497
mccOrganization: core3.getInput("mcc_organization"),
35486-
mccProject: core3.getInput("mcc_project")
35498+
mccProject: core3.getInput("mcc_project"),
35499+
allowComponentNotFound: core3.getBooleanInput("allow_component_not_found")
3548735500
};
3548835501
};
3548935502

0 commit comments

Comments
 (0)