|
|
|
@ -1,10 +1,15 @@
|
|
|
|
import { spawn } from 'child_process'
|
|
|
|
import { spawn } from 'child_process'
|
|
|
|
import fs from 'fs';
|
|
|
|
import fs from 'fs';
|
|
|
|
import request from 'request'
|
|
|
|
import request from 'request'
|
|
|
|
import decompress from 'decompress'
|
|
|
|
|
|
|
|
import requestProgress from 'request-progress'
|
|
|
|
import requestProgress from 'request-progress'
|
|
|
|
import { Octokit } from 'octokit';
|
|
|
|
import { Octokit } from 'octokit';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { fileURLToPath } from 'url';
|
|
|
|
|
|
|
|
import path from 'path';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
|
|
|
|
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
|
|
|
|
|
|
|
|
const TOKEN = process.env.LEAN4GAME_GITHUB_TOKEN
|
|
|
|
const TOKEN = process.env.LEAN4GAME_GITHUB_TOKEN
|
|
|
|
const octokit = new Octokit({
|
|
|
|
const octokit = new Octokit({
|
|
|
|
auth: TOKEN
|
|
|
|
auth: TOKEN
|
|
|
|
@ -77,11 +82,7 @@ async function doImport (owner, repo, id) {
|
|
|
|
progress[id].output += `Download from ${url}\n`
|
|
|
|
progress[id].output += `Download from ${url}\n`
|
|
|
|
await download(id, url, `tmp/artifact_${artifactId}.zip`)
|
|
|
|
await download(id, url, `tmp/artifact_${artifactId}.zip`)
|
|
|
|
progress[id].output += `Download finished.\n`
|
|
|
|
progress[id].output += `Download finished.\n`
|
|
|
|
progress[id].output += `Unpacking ZIP.\n`
|
|
|
|
await runProcess(id, "/bin/bash", [`${__dirname}/unpack.sh`, artifactId],".")
|
|
|
|
const files = await decompress(`tmp/artifact_${artifactId}.zip`, `tmp/artifact_${artifactId}`)
|
|
|
|
|
|
|
|
if (files.length != 1) { throw Error(`Unexpected number of files in ZIP: ${files.length}`) }
|
|
|
|
|
|
|
|
progress[id].output += `Unpacking TAR.\n`
|
|
|
|
|
|
|
|
const files_inner = await decompress(`tmp/artifact_${artifactId}/${files[0].path}`, `tmp/artifact_${artifactId}_inner`)
|
|
|
|
|
|
|
|
let manifest = fs.readFileSync(`tmp/artifact_${artifactId}_inner/manifest.json`);
|
|
|
|
let manifest = fs.readFileSync(`tmp/artifact_${artifactId}_inner/manifest.json`);
|
|
|
|
manifest = JSON.parse(manifest);
|
|
|
|
manifest = JSON.parse(manifest);
|
|
|
|
if (manifest.length !== 1) {
|
|
|
|
if (manifest.length !== 1) {
|
|
|
|
|