feat(gpt-runner-cli): add alias publish to gptr

This commit is contained in:
JinmingYang
2023-06-19 22:07:05 +08:00
parent ef532c6551
commit 719067a254
3 changed files with 28 additions and 1 deletions

View File

@@ -33,6 +33,9 @@ jobs:
- name: Install Dependencies And Build
run: pnpm i
- name: Package Alias Copy
run: pnpm pkg:alias
- name: Publish to NPM
run: pnpm -r publish --access public --no-git-checks
env:

View File

@@ -14,6 +14,7 @@
"play": "npm -C playground run dev",
"lint": "eslint --cache .",
"lint:fix": "pnpm lint --fix",
"pkg:alias": "esno ./scripts/cli-pkg-alias.ts",
"postinstall": "pnpm build",
"release": "bumpp -r",
"stub": "pnpm -r --filter=./packages/* --parallel run stub",
@@ -75,4 +76,4 @@
"eslint --cache --fix"
]
}
}
}

23
scripts/cli-pkg-alias.ts Normal file
View File

@@ -0,0 +1,23 @@
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import fs from 'fs-extra'
const dirname = path.dirname(fileURLToPath(import.meta.url))
const root = path.join(dirname, '..')
const gptRunnerCliPkgPath = path.join(root, './packages/gpt-runner-cli')
const gptrPkgPath = path.join(root, './packages/gptr')
async function cloneToGptrAliasPkg() {
const pkgJsonPath = path.join(gptRunnerCliPkgPath, 'package.json')
const gptrPkgJsonPath = path.join(gptrPkgPath, 'package.json')
const rawJSON = await fs.readFile(pkgJsonPath, 'utf-8')
const pkg = JSON.parse(rawJSON)
pkg.name = 'gptr'
await fs.ensureDir(gptrPkgPath)
await fs.copy(gptRunnerCliPkgPath, gptrPkgPath)
await fs.writeJSON(gptrPkgJsonPath, pkg, { spaces: 2 })
}
cloneToGptrAliasPkg()