From 0a2299b8140c839f5fee5f3896c180bff52bc746 Mon Sep 17 00:00:00 2001 From: Takuya Matsuyama Date: Mon, 9 Mar 2026 14:50:20 +0900 Subject: [PATCH 1/3] fix(windows): convert path to file url --- src/commands/publish.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/commands/publish.ts b/src/commands/publish.ts index cd88f58..737be42 100644 --- a/src/commands/publish.ts +++ b/src/commands/publish.ts @@ -1,6 +1,7 @@ import { rm } from 'fs/promises' import * as fs from 'fs/promises' import path from 'path' +import { pathToFileURL } from 'url' import axios, { isAxiosError } from 'axios' import FormData from 'form-data' import * as tar from 'tar' @@ -49,7 +50,7 @@ export class CommandPublish { try { const { default: pkg } = await import( - path.join(repoDir, 'package.json'), + pathToFileURL(path.join(repoDir, 'package.json')).href, { with: { type: 'json' } } ) const repository = this.getRepositoryId(pkg) From e0f9475e68a4fb740a154e11dc76c7ae6d30ceb9 Mon Sep 17 00:00:00 2001 From: Takuya Matsuyama Date: Mon, 9 Mar 2026 14:56:09 +0900 Subject: [PATCH 2/3] fix(windows): avoid using dynamic import statement --- src/commands/publish.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/commands/publish.ts b/src/commands/publish.ts index 737be42..8cd46cf 100644 --- a/src/commands/publish.ts +++ b/src/commands/publish.ts @@ -1,7 +1,6 @@ -import { rm } from 'fs/promises' +import { readFile, rm } from 'fs/promises' import * as fs from 'fs/promises' import path from 'path' -import { pathToFileURL } from 'url' import axios, { isAxiosError } from 'axios' import FormData from 'form-data' import * as tar from 'tar' @@ -49,9 +48,8 @@ export class CommandPublish { const repoDir = packagePath || process.cwd() try { - const { default: pkg } = await import( - pathToFileURL(path.join(repoDir, 'package.json')).href, - { with: { type: 'json' } } + const pkg = JSON.parse( + await readFile(path.join(repoDir, 'package.json'), 'utf-8') ) const repository = this.getRepositoryId(pkg) From 44bb30f8d25f540f3d7f3ac97ed87b4075c5bc47 Mon Sep 17 00:00:00 2001 From: Takuya Matsuyama Date: Mon, 9 Mar 2026 15:05:48 +0900 Subject: [PATCH 3/3] chore(publish): remove redundant imports --- src/commands/publish.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/commands/publish.ts b/src/commands/publish.ts index 8cd46cf..e589e04 100644 --- a/src/commands/publish.ts +++ b/src/commands/publish.ts @@ -1,4 +1,3 @@ -import { readFile, rm } from 'fs/promises' import * as fs from 'fs/promises' import path from 'path' import axios, { isAxiosError } from 'axios' @@ -49,7 +48,7 @@ export class CommandPublish { try { const pkg = JSON.parse( - await readFile(path.join(repoDir, 'package.json'), 'utf-8') + await fs.readFile(path.join(repoDir, 'package.json'), 'utf-8') ) const repository = this.getRepositoryId(pkg) @@ -65,7 +64,7 @@ export class CommandPublish { await this.uploadTarball(pkg, filePath, repository!, dryrun) // Step 4 - Clean up the created tarball file - await rm(filePath, { force: true }) + await fs.rm(filePath, { force: true }) logger.info('Cleaned up temporary tarball') logger.info(`Successfully published ${pkg.name}@${pkg.version}`) @@ -196,7 +195,7 @@ export class CommandPublish { const stats = await fs.stat(tarballPath) if (stats.size > PACKAGE_MAX_SIZE) { - await rm(tarballPath, { force: true }) + await fs.rm(tarballPath, { force: true }) throw new Error( `Package tarball size (${(stats.size / 1024 / 1024).toFixed(2)}MB) exceeds the 30MB limit` )