Skip to content
Merged
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
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ inputs:
required: false
description: 'use cache distributives'
default: 'false'
download_timeout:
required: false
description:
'distributive download timeout, seconds (large offline distributions of
EDT ~1.5GB)'
default: '1800'
runs:
using: node20
main: dist/index.js
34 changes: 21 additions & 13 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export async function run(): Promise<void> {
const type = core.getInput('type')
const edt_version = core.getInput('edt_version')
const onec_version = core.getInput('onec_version')
const downloadTimeout = parseInt(
core.getInput('download_timeout') || '1800',
10
)

const useCache = core.getBooleanInput('cache') && isCacheFeatureAvailable()
const useCacheDistr =
Expand All @@ -19,13 +23,17 @@ export async function run(): Promise<void> {
if (edt_version === undefined) {
throw new Error('EDT version not specified')
}
installer = new tools.EDT(edt_version, process.platform)
installer = new tools.EDT(edt_version, process.platform, downloadTimeout)
} else if (type === 'onec') {
logger.info('Install 1C:Enterprise v.' + onec_version)
if (onec_version === undefined) {
throw new Error('Onec version not specified')
}
installer = new tools.Platform83(onec_version, process.platform)
installer = new tools.Platform83(
onec_version,
process.platform,
downloadTimeout
)
} else {
throw new Error('failed to recognize the installer type')
}
Expand Down
7 changes: 5 additions & 2 deletions src/onegetjs/downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,18 @@
constructor(
login: string,
password: string,
config?: { preferredProvider?: AuthProviderType }
config?: {
preferredProvider?: AuthProviderType
downloadTimeout?: number
}
) {
if (!login || !password) {
const err = new Error('Do not set login or/and password')
logger.error(err.message)
throw err
}

this.httpClient = new HttpClient()
this.httpClient = new HttpClient(config?.downloadTimeout)
this.authProvider = AuthProviderFactory.create({
username: login,
password: password,
Expand All @@ -40,11 +43,11 @@
return response.data
}

async get(url: string): Promise<any> {

Check warning on line 46 in src/onegetjs/downloader.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected any. Specify a different type

Check warning on line 46 in src/onegetjs/downloader.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected any. Specify a different type
return this.httpClient.get(url)
}

extractFileName(url: string, headers?: any): string | undefined {

Check warning on line 50 in src/onegetjs/downloader.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected any. Specify a different type

Check warning on line 50 in src/onegetjs/downloader.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected any. Specify a different type
// Try to extract from Content-Disposition header
if (headers?.['content-disposition']) {
const match = headers['content-disposition'].match(
Expand Down
7 changes: 5 additions & 2 deletions src/onegetjs/httpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
export class HttpClient {
private client: Got
private jar: CookieJar
private streamRequestTimeout: number

constructor() {
constructor(downloadTimeout?: number) {
this.jar = new CookieJar()
this.streamRequestTimeout =
(downloadTimeout && downloadTimeout > 0 ? downloadTimeout : 1800) * 1000

this.client = got.extend({
timeout: { request: 30000 },
Expand Down Expand Up @@ -47,12 +50,12 @@

async get(
url: string,
options?: any

Check warning on line 53 in src/onegetjs/httpClient.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected any. Specify a different type

Check warning on line 53 in src/onegetjs/httpClient.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected any. Specify a different type
): Promise<{ data: any; request: any; status: number; headers?: any }> {

Check warning on line 54 in src/onegetjs/httpClient.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected any. Specify a different type

Check warning on line 54 in src/onegetjs/httpClient.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected any. Specify a different type

Check warning on line 54 in src/onegetjs/httpClient.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected any. Specify a different type

Check warning on line 54 in src/onegetjs/httpClient.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected any. Specify a different type

Check warning on line 54 in src/onegetjs/httpClient.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected any. Specify a different type

Check warning on line 54 in src/onegetjs/httpClient.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected any. Specify a different type
if (options?.isStream) {
// For streams, return the stream directly with extended timeout
const stream = this.client.stream.get(url, {
timeout: { request: 300000 } // 5 minutes for large files
timeout: { request: this.streamRequestTimeout }
})
return new Promise((resolve, reject) => {
stream.on('response', (response: Response) => {
Expand All @@ -78,9 +81,9 @@

async post(
url: string,
data: any,

Check warning on line 84 in src/onegetjs/httpClient.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected any. Specify a different type

Check warning on line 84 in src/onegetjs/httpClient.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected any. Specify a different type
config: any = {}

Check warning on line 85 in src/onegetjs/httpClient.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected any. Specify a different type

Check warning on line 85 in src/onegetjs/httpClient.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected any. Specify a different type
): Promise<{ data: any; request: any; status: number; headers?: any }> {

Check warning on line 86 in src/onegetjs/httpClient.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected any. Specify a different type

Check warning on line 86 in src/onegetjs/httpClient.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected any. Specify a different type

Check warning on line 86 in src/onegetjs/httpClient.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected any. Specify a different type

Check warning on line 86 in src/onegetjs/httpClient.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected any. Specify a different type
const contentType = (config.headers?.['Content-Type'] || '').toLowerCase()
const isJson =
typeof data === 'object' && contentType.startsWith('application/json')
Expand Down
9 changes: 5 additions & 4 deletions src/onegetjs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ export default class OneGet {
client: Client
downloadTo: string

constructor(downloadTo: string) {
constructor(downloadTo: string, config?: { downloadTimeout?: number }) {
const login = process.env.ONEC_USERNAME ?? ''
const password = process.env.ONEC_PASSWORD ?? ''
this.client = new Client(login, password)
this.client = new Client(login, password, config)
this.downloadTo = downloadTo
}

Expand Down Expand Up @@ -129,7 +129,8 @@ export default class OneGet {
export async function downloadRelease(
release: ReleaseDescription,
destination: string,
unpack = false
unpack = false,
downloadTimeout?: number
): Promise<void> {
const downloadDestination = unpack
? path.resolve('tmp', '__downloads__')
Expand All @@ -138,7 +139,7 @@ export async function downloadRelease(
io.mkdirP(downloadDestination)
io.mkdirP(destination)

const oneGet = new OneGet(downloadDestination)
const oneGet = new OneGet(downloadDestination, { downloadTimeout })
await oneGet.auth()
const version = await oneGet.versionInfo(release.project, release.version)
const artifacts = await oneGet.download(version, release)
Expand Down
7 changes: 5 additions & 2 deletions src/tools/edt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ export class EDT extends OnecTool {
version: string
cache_: string[]
platform: string
constructor(version: string, platform: string) {
downloadTimeout?: number
constructor(version: string, platform: string, downloadTimeout?: number) {
super()
this.version = version
this.platform = platform
this.cache_ = this.getCacheDirs()
this.downloadTimeout = downloadTimeout
}
async download(): Promise<void> {
const onegetPlatform = this.getPlatformType()
Expand All @@ -28,7 +30,8 @@ export class EDT extends OnecTool {
offline: true
},
`/tmp/${this.INSTALLER_CACHE_PRIMARY_KEY}`,
true
true,
this.downloadTimeout
)
}

Expand Down
7 changes: 5 additions & 2 deletions src/tools/platform83.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ export class Platform83 extends OnecTool {
version: string
cache_: string[]
platform: string
constructor(version: string, platform: string) {
downloadTimeout?: number
constructor(version: string, platform: string, downloadTimeout?: number) {
super()
this.version = version
this.platform = platform
this.cache_ = this.getCacheDirs()
this.downloadTimeout = downloadTimeout
}

useNewInstaller(): boolean {
Expand All @@ -42,7 +44,8 @@ export class Platform83 extends OnecTool {
type: installerType
},
this.getInstallersPath(),
true
true,
this.downloadTimeout
)

logger.info(`onec was downloaded`)
Expand Down
Loading