Skip to content

Commit

Permalink
Add extension detection, enforce url, custom coordinates (#41)
Browse files Browse the repository at this point in the history
Co-authored-by: Jerome Prinet <[email protected]>
  • Loading branch information
welandaz and jprinet authored Aug 2, 2024
1 parent 1d769fc commit d0c4c24
Show file tree
Hide file tree
Showing 13 changed files with 2,706 additions and 114 deletions.
16 changes: 16 additions & 0 deletions build-scan-shared/src/setup/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,26 @@ export function getCcudExtensionVersion(): string {
return sharedInput.getInput('develocity-ccud-extension-version')
}

export function getDevelocityCustomMavenExtensionCoordinates(): string {
return sharedInput.getInput('develocity-custom-develocity-maven-extension-coordinates')
}

export function getDevelocityCustomCcudExtensionCoordinates(): string {
return sharedInput.getInput('develocity-custom-ccud-extension-coordinates')
}

export function getDevelocityAllowUntrustedServer(): string {
return sharedInput.getInput('develocity-allow-untrusted-server')
}

export function getDevelocityEnforceUrl(): boolean {
return getBooleanInput('develocity-enforce-url')
}

export function getDevelocityCaptureFileFingerprints(): boolean {
return getBooleanInput('develocity-capture-file-fingerprints')
}

export function getDevelocityAccessKey(): string {
return sharedInput.getInput('develocity-access-key')
}
Expand Down
38 changes: 38 additions & 0 deletions build-scan-shared/src/utils/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ import * as core from '@actions/core'
import fs from 'fs'
import path from 'path'
import * as toolCache from '@actions/tool-cache'
import https from 'https'

export function getDelimiter(): string {
return path.delimiter
}

export function getAbsoluteFilePath(extensionsFileName: string): string {
return path.resolve(process.cwd(), extensionsFileName)
}

export function existsSync(fileName: string): boolean {
return fs.existsSync(fileName)
Expand Down Expand Up @@ -51,3 +60,32 @@ export function renameSync(oldPath: string, newPath: string): void {
}
fs.renameSync(oldPath, newPath)
}

export async function downloadFile(url: string, downloadFolder: string): Promise<string> {
const fileName = path.basename(url)
const filePath = path.join(downloadFolder, fileName)

return new Promise((resolve, reject) => {
// Ensure the download folder exists
if (!existsSync(downloadFolder)) {
mkdirSync(downloadFolder)
}

const file = fs.createWriteStream(filePath)
https
.get(url, response => {
if (response.statusCode !== 200) {
reject(new Error(`Failed to get '${url}' (${response.statusCode})`))
return
}
response.pipe(file)
file.on('finish', () => {
file.close()
resolve(filePath)
})
})
.on('error', err => {
fs.unlink(filePath, () => reject(err.message))
})
})
}
52 changes: 52 additions & 0 deletions dist/maven-publish-build-scan/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135144,7 +135144,11 @@ exports.getDevelocityUrl = getDevelocityUrl;
exports.getDevelocityInjectionEnabled = getDevelocityInjectionEnabled;
exports.getDevelocityMavenExtensionVersion = getDevelocityMavenExtensionVersion;
exports.getCcudExtensionVersion = getCcudExtensionVersion;
exports.getDevelocityCustomMavenExtensionCoordinates = getDevelocityCustomMavenExtensionCoordinates;
exports.getDevelocityCustomCcudExtensionCoordinates = getDevelocityCustomCcudExtensionCoordinates;
exports.getDevelocityAllowUntrustedServer = getDevelocityAllowUntrustedServer;
exports.getDevelocityEnforceUrl = getDevelocityEnforceUrl;
exports.getDevelocityCaptureFileFingerprints = getDevelocityCaptureFileFingerprints;
exports.getDevelocityAccessKey = getDevelocityAccessKey;
exports.getDevelocityTokenExpiry = getDevelocityTokenExpiry;
exports.getWorkflowName = getWorkflowName;
Expand All @@ -135170,9 +135174,21 @@ function getDevelocityMavenExtensionVersion() {
function getCcudExtensionVersion() {
return sharedInput.getInput('develocity-ccud-extension-version');
}
function getDevelocityCustomMavenExtensionCoordinates() {
return sharedInput.getInput('develocity-custom-develocity-maven-extension-coordinates');
}
function getDevelocityCustomCcudExtensionCoordinates() {
return sharedInput.getInput('develocity-custom-ccud-extension-coordinates');
}
function getDevelocityAllowUntrustedServer() {
return sharedInput.getInput('develocity-allow-untrusted-server');
}
function getDevelocityEnforceUrl() {
return (0, input_1.getBooleanInput)('develocity-enforce-url');
}
function getDevelocityCaptureFileFingerprints() {
return (0, input_1.getBooleanInput)('develocity-capture-file-fingerprints');
}
function getDevelocityAccessKey() {
return sharedInput.getInput('develocity-access-key');
}
Expand Down Expand Up @@ -135624,6 +135640,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getDelimiter = getDelimiter;
exports.getAbsoluteFilePath = getAbsoluteFilePath;
exports.existsSync = existsSync;
exports.extractZip = extractZip;
exports.mkdirSync = mkdirSync;
Expand All @@ -135633,10 +135651,18 @@ exports.writeFileSync = writeFileSync;
exports.writeContentToFileSync = writeContentToFileSync;
exports.copyFileSync = copyFileSync;
exports.renameSync = renameSync;
exports.downloadFile = downloadFile;
const core = __importStar(__nccwpck_require__(42186));
const fs_1 = __importDefault(__nccwpck_require__(57147));
const path_1 = __importDefault(__nccwpck_require__(71017));
const toolCache = __importStar(__nccwpck_require__(27784));
const https_1 = __importDefault(__nccwpck_require__(95687));
function getDelimiter() {
return path_1.default.delimiter;
}
function getAbsoluteFilePath(extensionsFileName) {
return path_1.default.resolve(process.cwd(), extensionsFileName);
}
function existsSync(fileName) {
return fs_1.default.existsSync(fileName);
}
Expand Down Expand Up @@ -135679,6 +135705,32 @@ function renameSync(oldPath, newPath) {
}
fs_1.default.renameSync(oldPath, newPath);
}
async function downloadFile(url, downloadFolder) {
const fileName = path_1.default.basename(url);
const filePath = path_1.default.join(downloadFolder, fileName);
return new Promise((resolve, reject) => {
// Ensure the download folder exists
if (!existsSync(downloadFolder)) {
mkdirSync(downloadFolder);
}
const file = fs_1.default.createWriteStream(filePath);
https_1.default
.get(url, response => {
if (response.statusCode !== 200) {
reject(new Error(`Failed to get '${url}' (${response.statusCode})`));
return;
}
response.pipe(file);
file.on('finish', () => {
file.close();
resolve(filePath);
});
})
.on('error', err => {
fs_1.default.unlink(filePath, () => reject(err.message));
});
});
}


/***/ }),
Expand Down
Loading

0 comments on commit d0c4c24

Please sign in to comment.