diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 77b3deb..3999e9a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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: diff --git a/package.json b/package.json index 5eb12dd..7204924 100644 --- a/package.json +++ b/package.json @@ -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" ] } -} +} \ No newline at end of file diff --git a/scripts/cli-pkg-alias.ts b/scripts/cli-pkg-alias.ts new file mode 100644 index 0000000..a87bc26 --- /dev/null +++ b/scripts/cli-pkg-alias.ts @@ -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()