release?
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
import spawnSync from "./spawnSync.ts"
|
||||
|
||||
const deno = true // works, but produces largest executables
|
||||
const bun = false // has weird issues
|
||||
const pkg = false // smallest executables but don't work
|
||||
|
||||
if (deno) {
|
||||
//spawnSync('deno', ['install'], { stdio: 'inherit', shell: true })
|
||||
const deno_targets = [
|
||||
'x86_64-apple-darwin',
|
||||
'aarch64-apple-darwin',
|
||||
'x86_64-pc-windows-msvc',
|
||||
'x86_64-unknown-linux-gnu',
|
||||
'aarch64-unknown-linux-gnu'
|
||||
]
|
||||
for (const target of deno_targets) {
|
||||
spawnSync('deno', [
|
||||
'compile', '--allow-all', '--target', target,
|
||||
'--output', 'bin/deno/packwiz-extras-' + target,
|
||||
'--no-check', 'src/cli.ts'
|
||||
], { stdio: 'inherit', shell: true })
|
||||
}
|
||||
}
|
||||
|
||||
if (bun) {
|
||||
const bun_targets = [
|
||||
'bun-linux-x64-baseline',
|
||||
'bun-linux-arm64',
|
||||
'bun-linux-x64-musl-baseline',
|
||||
'bun-linux-arm64-musl',
|
||||
'bun-windows-x64-baseline',
|
||||
'bun-darwin-x64-baseline',
|
||||
'bun-darwin-arm64'
|
||||
]
|
||||
for (const target of bun_targets) {
|
||||
spawnSync('bun', [
|
||||
'build', '--compile',
|
||||
'--target', target,
|
||||
'--outfile', 'bin/bun/packwiz-extras-' + target,
|
||||
'src/cli.ts'
|
||||
], { stdio: 'inherit', shell: true })
|
||||
}
|
||||
}
|
||||
|
||||
if (pkg) {
|
||||
const pkg_targets = [
|
||||
'latest-linux-x64',
|
||||
'latest-linux-arm64',
|
||||
'latest-windows-x64',
|
||||
'latest-macos-x64',
|
||||
'latest-macos-arm64'
|
||||
]
|
||||
spawnSync('pkg', [
|
||||
'--targets', pkg_targets.join(','),
|
||||
'--output', 'bin/pkg/packwiz-extras',
|
||||
'--no-bytecode', '--public', // doesn't build without these
|
||||
//'--sea', // doesn't build with this
|
||||
'--compress', 'GZip',
|
||||
//'--compress', 'Brotli', // same size as GZip and the internet says GZip is better
|
||||
'src/cli.ts'
|
||||
], { stdio: 'inherit', shell: true })
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
import fs from 'node:fs'
|
||||
|
||||
export default async function download(url: string, path: string) {
|
||||
if (fs.existsSync(path)) {
|
||||
return console.log(path + ' already downloaded')
|
||||
}
|
||||
console.log('downloading ' + url + ' to ' + path)
|
||||
const response = await fetch(url)
|
||||
if (!response.ok) {
|
||||
console.error(response.statusText)
|
||||
process.exit(1)
|
||||
}
|
||||
const reader = response.body?.getReader()
|
||||
const writeStream = fs.createWriteStream(path, 'binary')
|
||||
const totalSize = Number(response.headers.get('content-length'))
|
||||
let receivedSize = 0
|
||||
let chunk = await reader!.read()
|
||||
let lastProgress = 0
|
||||
while (!chunk.done) {
|
||||
writeStream.write(chunk.value)
|
||||
receivedSize += chunk.value!.length
|
||||
const progress = Math.floor((receivedSize / totalSize) * 100)
|
||||
if (process.stdout.isTTY) process.stdout.write(progress + '%\r')
|
||||
else if (progress !== lastProgress) {
|
||||
process.stdout.write('.')
|
||||
lastProgress = progress
|
||||
}
|
||||
chunk = await reader!.read()
|
||||
}
|
||||
process.stdout.write('\n')
|
||||
writeStream.close()
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { type SpawnSyncOptions, spawnSync as nodeSpawnSync } from 'node:child_process'
|
||||
|
||||
export default function spawnSync(command: string, args?: readonly string[], options: SpawnSyncOptions = {}) {
|
||||
if (!options.stdio) options.stdio = 'inherit' // I wanna know what's going on
|
||||
if (!options.shell) options.shell = true // Windows requires this for PATHEXT support
|
||||
const result = nodeSpawnSync(command, args, options)
|
||||
if (result.error) throw result.error // Don't silently fail
|
||||
if (result.status !== 0) process.exit(result.status) // Don't continue if a command fails
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import fs from 'node:fs'
|
||||
import spawnSync from './spawnSync.ts'
|
||||
import download from './downloadProgress.ts'
|
||||
|
||||
await download('https://mediafilez.forgecdn.net/files/7223/56/All%20the%20Mods%2010-5.1.zip', 'modpack.zip')
|
||||
|
||||
fs.mkdirSync('test', { recursive: true })
|
||||
spawnSync('packwiz', ['curseforge', 'import', '../modpack.zip'], { cwd: 'test' })
|
||||
spawnSync('deno', ['run', '--allow-all', 'src/cli.ts', '--pack-file=test/pack.toml', 'cf','detect'])
|
||||
spawnSync('deno', ['run', '--allow-all', 'src/cli.ts', '--pack-file=test/pack.toml', 'cf','urls'])
|
||||
spawnSync('deno', ['run', '--allow-all', 'src/cli.ts', '--pack-file=test/pack.toml', 'mr','detect'])
|
||||
spawnSync('deno', ['run', '--allow-all', 'src/cli.ts', '--pack-file=test/pack.toml', 'mr','merge'])
|
||||
fs.rmSync('test', { recursive: true })
|
||||
Reference in New Issue
Block a user