@@ -31,22 +31,42 @@ var __importStar = (this && this.__importStar) || function (mod) {
3131};
3232Object.defineProperty(exports, "__esModule", ({ value: true }));
3333const core = __importStar(__nccwpck_require__(2186));
34+ const fs = __importStar(__nccwpck_require__(7147));
3435const axios_1 = __importStar(__nccwpck_require__(8757));
3536const xcode_selector_1 = __nccwpck_require__(8865);
3637async function validateSubscription() {
37- var _a;
38- const API_URL = `https://agent.api.stepsecurity.io/v1/github/${process.env.GITHUB_REPOSITORY}/actions/subscription`;
38+ const eventPath = process.env.GITHUB_EVENT_PATH;
39+ let repoPrivate;
40+ if (eventPath && fs.existsSync(eventPath)) {
41+ const eventData = JSON.parse(fs.readFileSync(eventPath, 'utf8'));
42+ repoPrivate = eventData?.repository?.private;
43+ }
44+ const upstream = 'maxim-lobanov/setup-xcode';
45+ const action = process.env.GITHUB_ACTION_REPOSITORY;
46+ const docsUrl = 'https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions';
47+ core.info('');
48+ core.info('\u001b[1;36mStepSecurity Maintained Action\u001b[0m');
49+ core.info(`Secure drop-in replacement for ${upstream}`);
50+ if (repoPrivate === false)
51+ core.info('\u001b[32m\u2713 Free for public repositories\u001b[0m');
52+ core.info(`\u001b[36mLearn more:\u001b[0m ${docsUrl}`);
53+ core.info('');
54+ if (repoPrivate === false)
55+ return;
56+ const serverUrl = process.env.GITHUB_SERVER_URL || 'https://github.com';
57+ const body = { action: action || '' };
58+ if (serverUrl !== 'https://github.com')
59+ body.ghes_server = serverUrl;
3960 try {
40- await axios_1.default.get(API_URL , { timeout: 3000 });
61+ await axios_1.default.post(`https://agent.api.stepsecurity.io/v1/github/${process.env.GITHUB_REPOSITORY}/actions/maintained-actions-subscription`, body , { timeout: 3000 });
4162 }
4263 catch (error) {
43- if ((0, axios_1.isAxiosError)(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === 403) {
44- core.error("Subscription is not valid. Reach out to support@stepsecurity.io");
64+ if ((0, axios_1.isAxiosError)(error) && error.response?.status === 403) {
65+ core.error(`\u001b[1;31mThis action requires a StepSecurity subscription for private repositories.\u001b[0m`);
66+ core.error(`\u001b[31mLearn how to enable a subscription: ${docsUrl}\u001b[0m`);
4567 process.exit(1);
4668 }
47- else {
48- core.info("Timeout or API not reachable. Continuing to next step.");
49- }
69+ core.info('Timeout or API not reachable. Continuing to next step.');
5070 }
5171}
5272async function run() {
@@ -127,7 +147,6 @@ class XcodeSelector {
127147 return xcodeVersions.sort((first, second) => semver.compare(second.version, first.version));
128148 }
129149 findVersion(versionSpec) {
130- var _a;
131150 const availableVersions = this.getAllVersions();
132151 if (availableVersions.length === 0) {
133152 return null;
@@ -144,9 +163,9 @@ class XcodeSelector {
144163 isStable = false;
145164 versionSpec = versionSpec.slice(0, -betaSuffix.length);
146165 }
147- return ((_a = availableVersions
166+ return (availableVersions
148167 .filter(ver => ver.stable === isStable)
149- .find(ver => semver.satisfies(ver.version, versionSpec))) !== null && _a !== void 0 ? _a : null);
168+ .find(ver => semver.satisfies(ver.version, versionSpec)) ?? null);
150169 }
151170 setVersion(xcodeVersion) {
152171 if (!fs.existsSync(xcodeVersion.path)) {
@@ -219,9 +238,8 @@ const getInstalledXcodeApps = () => {
219238};
220239exports.getInstalledXcodeApps = getInstalledXcodeApps;
221240const getXcodeReleaseType = (xcodeRootPath) => {
222- var _a, _b;
223241 const licenseInfo = (0, exports.parsePlistFile)(path.join(xcodeRootPath, "Contents", "Resources", "LicenseInfo.plist"));
224- const licenseType = (_b = (_a = licenseInfo === null || licenseInfo === void 0 ? void 0 : licenseInfo .licenseType) === null || _a === void 0 ? void 0 : _a .toString()) === null || _b === void 0 ? void 0 : _b .toLowerCase();
242+ const licenseType = licenseInfo? .licenseType? .toString()? .toLowerCase();
225243 if (!licenseType) {
226244 core.debug("Unable to determine Xcode version type based on license plist");
227245 core.debug("Xcode License plist doesn't contain 'licenseType' property");
@@ -231,10 +249,9 @@ const getXcodeReleaseType = (xcodeRootPath) => {
231249};
232250exports.getXcodeReleaseType = getXcodeReleaseType;
233251const getXcodeVersionInfo = (xcodeRootPath) => {
234- var _a, _b;
235252 const versionInfo = (0, exports.parsePlistFile)(path.join(xcodeRootPath, "Contents", "version.plist"));
236- const xcodeVersion = semver.coerce((_a = versionInfo === null || versionInfo === void 0 ? void 0 : versionInfo .CFBundleShortVersionString) === null || _a === void 0 ? void 0 : _a .toString());
237- const xcodeBuildNumber = (_b = versionInfo === null || versionInfo === void 0 ? void 0 : versionInfo .ProductBuildVersion) === null || _b === void 0 ? void 0 : _b .toString();
253+ const xcodeVersion = semver.coerce(versionInfo? .CFBundleShortVersionString? .toString());
254+ const xcodeBuildNumber = versionInfo? .ProductBuildVersion? .toString();
238255 if (!xcodeVersion || !semver.valid(xcodeVersion)) {
239256 core.debug(`Unable to retrieve Xcode version info on path '${xcodeRootPath}'`);
240257 return null;
0 commit comments