fix(cli): wrong release assets content
This commit is contained in:
parent
47c5867922
commit
458c5c9457
2 changed files with 11 additions and 5 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import { createReadStream, existsSync, statSync } from 'fs'
|
||||||
import { join } from 'path'
|
import { join } from 'path'
|
||||||
|
|
||||||
import { Octokit } from '@octokit/rest'
|
import { Octokit } from '@octokit/rest'
|
||||||
|
@ -8,7 +9,6 @@ import { getNapiConfig } from './consts'
|
||||||
import { debugFactory } from './debug'
|
import { debugFactory } from './debug'
|
||||||
import { spawn } from './spawn'
|
import { spawn } from './spawn'
|
||||||
import { updatePackageJson } from './update-package'
|
import { updatePackageJson } from './update-package'
|
||||||
import { existsAsync } from './utils'
|
|
||||||
import { VersionCommand } from './version'
|
import { VersionCommand } from './version'
|
||||||
|
|
||||||
const debug = debugFactory('prepublish')
|
const debug = debugFactory('prepublish')
|
||||||
|
@ -69,7 +69,7 @@ export class PrePublishCommand extends Command {
|
||||||
const dstPath = join(pkgDir, filename)
|
const dstPath = join(pkgDir, filename)
|
||||||
|
|
||||||
if (!this.isDryRun) {
|
if (!this.isDryRun) {
|
||||||
if (!(await existsAsync(dstPath))) {
|
if (!existsSync(dstPath)) {
|
||||||
console.warn(`[${chalk.yellowBright(dstPath)}] is not existed`)
|
console.warn(`[${chalk.yellowBright(dstPath)}] is not existed`)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -89,12 +89,19 @@ export class PrePublishCommand extends Command {
|
||||||
owner: owner!,
|
owner: owner!,
|
||||||
tag: pkgInfo.tag!,
|
tag: pkgInfo.tag!,
|
||||||
})
|
})
|
||||||
|
const dstFileStats = statSync(dstPath)
|
||||||
const assetInfo = await octokit!.repos.uploadReleaseAsset({
|
const assetInfo = await octokit!.repos.uploadReleaseAsset({
|
||||||
owner: owner!,
|
owner: owner!,
|
||||||
repo: repo!,
|
repo: repo!,
|
||||||
data: dstPath,
|
|
||||||
name: filename,
|
name: filename,
|
||||||
release_id: releaseInfo.data.id,
|
release_id: releaseInfo.data.id,
|
||||||
|
mediaType: { format: 'raw' },
|
||||||
|
headers: {
|
||||||
|
'content-length': dstFileStats.size,
|
||||||
|
'content-type': 'application/octet-stream',
|
||||||
|
},
|
||||||
|
// @ts-expect-error
|
||||||
|
data: createReadStream(dstPath),
|
||||||
})
|
})
|
||||||
console.info(`${chalk.green(dstPath)} upload success`)
|
console.info(`${chalk.green(dstPath)} upload success`)
|
||||||
console.info(
|
console.info(
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
import { readFile, writeFile, exists, copyFile, mkdir, unlink } from 'fs'
|
import { readFile, writeFile, copyFile, mkdir, unlink } from 'fs'
|
||||||
import { promisify } from 'util'
|
import { promisify } from 'util'
|
||||||
|
|
||||||
export const readFileAsync = promisify(readFile)
|
export const readFileAsync = promisify(readFile)
|
||||||
export const writeFileAsync = promisify(writeFile)
|
export const writeFileAsync = promisify(writeFile)
|
||||||
export const existsAsync = promisify(exists)
|
|
||||||
export const unlinkAsync = promisify(unlink)
|
export const unlinkAsync = promisify(unlink)
|
||||||
export const copyFileAsync = promisify(copyFile)
|
export const copyFileAsync = promisify(copyFile)
|
||||||
export const mkdirAsync = promisify(mkdir)
|
export const mkdirAsync = promisify(mkdir)
|
||||||
|
|
Loading…
Add table
Reference in a new issue