generated from unplugin/unplugin-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #313 from ryoppippi/feature/jsr-mirror-npm
mirror jsr to npm
- Loading branch information
Showing
9 changed files
with
59 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env bun | ||
|
||
import { $ } from 'bun'; | ||
import { join } from 'node:path'; | ||
import {tmpdir} from 'node:os'; | ||
|
||
function getTagName() { | ||
const githubRef = Bun.env.GITHUB_REF; | ||
if (githubRef && githubRef.startsWith("refs/tags/")) { | ||
return githubRef.replace("refs/tags/", ""); | ||
} else { | ||
return undefined; | ||
} | ||
} | ||
|
||
const tagName = getTagName(); | ||
if (tagName == null) { | ||
throw new Error("Could not get tag name from GITHUB_REF"); | ||
} | ||
|
||
const versionStr = tagName.replace(/^v/, ""); | ||
const pkgName = `@jsr/ryoppippi__unplugin-typia@${versionStr}`; | ||
|
||
/* create tmp dir */ | ||
const tmpDir = tmpdir(); | ||
|
||
$.cwd(tmpDir); | ||
|
||
/* clone the repo */ | ||
await $`echo '@jsr:registry=https://npm.jsr.io' >> .npmrc` | ||
|
||
await $`bun init -y && bun add ${pkgName}`; | ||
|
||
$.cwd(join(tmpDir, 'node_modules', '@jsr', 'ryoppippi__unplugin-typia')); | ||
|
||
const pkgJson = await $`cat ./package.json`.json(); | ||
|
||
if(pkgJson.version !== versionStr) { | ||
throw new Error(`Version mismatch: ${pkgJson.version} !== ${versionStr}`); | ||
} | ||
|
||
pkgJson.name = "@ryoppippi/unplugin-typia"; | ||
pkgJson.description = "unplugin for typia"; | ||
pkgJson.repository = `https://github.com/ryoppippi/unplugin-typia.git`; | ||
pkgJson.license = "MIT"; | ||
pkgJson.author = "ryoppippi"; | ||
|
||
await $`echo '${JSON.stringify(pkgJson, null, 2)}' > ./package.json`; | ||
|
||
await $`npm publish --access public --provenance`; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.