From 76c72108eeda4a52fd00ae127f5e0fdad8b7d98a Mon Sep 17 00:00:00 2001 From: Roman Date: Sat, 13 Dec 2025 00:39:32 +0000 Subject: [PATCH 1/2] add bun support [WIP] --- src/cli.ts | 31 ++++++++++++++++++++++- src/main.ts | 2 +- src/templates.ts | 13 ++++++++-- src/types.ts | 1 + templates/changesets+bun.yml | 49 ++++++++++++++++++++++++++++++++++++ 5 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 templates/changesets+bun.yml diff --git a/src/cli.ts b/src/cli.ts index 23b690f..8b234ea 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -165,6 +165,34 @@ const templateSummaries: Record = { }; async function runInteractive(opts: CLIOptions): Promise { + const pm = await prompts.select({ + message: 'What package manager do you use?', + options: [ + { + value: 'npm', + label: 'Node + npm', + }, + { + value: 'bun', + label: 'Bun', + }, + { + value: 'pnpm', + label: 'pnpm', + } + ], + initialValue: opts.template + }); + + if (prompts.isCancel(pm)) { + cancelInteractive(); + } + + if (pm === "pnpm") { + prompts.log.error(`pnpm is not supported at the moment`); + return cancelInteractive(); + } + const template = await prompts.select({ message: 'Select a changelog tool', options: [ @@ -184,7 +212,7 @@ async function runInteractive(opts: CLIOptions): Promise { hint: 'Automate changelog generation and releases using changesets' } ], - initialValue: opts.template + initialValue: opts.template, }); if (prompts.isCancel(template)) { @@ -223,6 +251,7 @@ async function runInteractive(opts: CLIOptions): Promise { return { ...opts, template, + pm, ...userOptions }; } diff --git a/src/main.ts b/src/main.ts index 9c65d56..02d6836 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,7 +2,7 @@ import sade from 'sade'; import {runCLI} from './cli.js'; const cli = sade('@e18e/setup-publish', true); -const CLI_VERSION = '0.0.0-dev'; +const CLI_VERSION = '0.0.10'; /* * - changesets diff --git a/src/templates.ts b/src/templates.ts index 0cf4d76..e7974d3 100644 --- a/src/templates.ts +++ b/src/templates.ts @@ -32,11 +32,20 @@ export async function createTemplate(opts: CLIOptions): Promise { const templates = await getAvailableTemplates(); // Shouldn't ever happen but just in case - if (!templates.includes(opts.template)) { + if (!opts.pm && !templates.includes(opts.template)) { + prompts.log.error(`❌ Template for current configuration not found. Please open an issue on GitHub`); return; } - const templatePath = path.join(templatesDir, `${opts.template}.yml`); + if (!templates.includes(`${opts.template}+${opts.pm}`)) { + prompts.log.error(`❌ Template for current configuration not found. Please open an issue on GitHub`); + return; + } + + const templatePath = opts.pm + ? path.join(templatesDir, `${opts.template}.yml`) + : path.join(templatesDir, `${opts.template}+${opts.pm}.yml`); + let templateContent: string; try { diff --git a/src/types.ts b/src/types.ts index c77c97a..3c8a1cb 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3,4 +3,5 @@ export interface CLIOptions { env: string | undefined; interactive: boolean; template: string; + pm: string; } diff --git a/templates/changesets+bun.yml b/templates/changesets+bun.yml new file mode 100644 index 0000000..b12faf6 --- /dev/null +++ b/templates/changesets+bun.yml @@ -0,0 +1,49 @@ +name: Publish to npm +permissions: {} +on: + push: + branches: + - main +jobs: + test: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + - name: Install dependencies + run: bun install --frozen-lockfile --ignore-scripts + - name: Run tests + run: bun run test + publish: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + id-token: write + outputs: + tarball: ${{ steps.pack.outputs.tarball }} + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + - name: Install dependencies + run: bun install --frozen-lockfile --ignore-scripts + - run: bun run build + - name: Create Release or Publish + uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3 + with: + publish: bunx changeset publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: "" # Workaround. See https://github.com/changesets/changesets/issues/1152#issuecomment-3190884868 From 8217dad4703cc83fa9a60f73e209c5002ed07a2e Mon Sep 17 00:00:00 2001 From: Roman Date: Sun, 14 Dec 2025 15:08:48 +0000 Subject: [PATCH 2/2] Update --- src/cli.ts | 13 +++--- src/templates.ts | 10 ++--- templates/changesets+bun.yml | 4 +- templates/changesets.yml | 17 +++++--- templates/default+bun.yaml | 76 ++++++++++++++++++++++++++++++++++++ templates/default.yml | 18 ++++++--- 6 files changed, 114 insertions(+), 24 deletions(-) create mode 100644 templates/default+bun.yaml diff --git a/src/cli.ts b/src/cli.ts index 8b234ea..2b9c65c 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -169,8 +169,8 @@ async function runInteractive(opts: CLIOptions): Promise { message: 'What package manager do you use?', options: [ { - value: 'npm', - label: 'Node + npm', + value: '', + label: 'npm', }, { value: 'bun', @@ -179,6 +179,10 @@ async function runInteractive(opts: CLIOptions): Promise { { value: 'pnpm', label: 'pnpm', + }, + { + value: 'yarn', + label: 'yarn', } ], initialValue: opts.template @@ -188,11 +192,6 @@ async function runInteractive(opts: CLIOptions): Promise { cancelInteractive(); } - if (pm === "pnpm") { - prompts.log.error(`pnpm is not supported at the moment`); - return cancelInteractive(); - } - const template = await prompts.select({ message: 'Select a changelog tool', options: [ diff --git a/src/templates.ts b/src/templates.ts index e7974d3..0bffaab 100644 --- a/src/templates.ts +++ b/src/templates.ts @@ -32,14 +32,14 @@ export async function createTemplate(opts: CLIOptions): Promise { const templates = await getAvailableTemplates(); // Shouldn't ever happen but just in case - if (!opts.pm && !templates.includes(opts.template)) { - prompts.log.error(`❌ Template for current configuration not found. Please open an issue on GitHub`); + if (!templates.includes(opts.template)) { + prompts.log.error(`❌ Template for current configuration not found`); return; } - if (!templates.includes(`${opts.template}+${opts.pm}`)) { - prompts.log.error(`❌ Template for current configuration not found. Please open an issue on GitHub`); - return; + if (opts.pm && !templates.includes(`${opts.template}+${opts.pm}`)) { + prompts.log.warn(`⚠️ Template for your package manager does not exist. Falling back to npm`); + opts.pm = ''; } const templatePath = opts.pm diff --git a/templates/changesets+bun.yml b/templates/changesets+bun.yml index b12faf6..dbe0e39 100644 --- a/templates/changesets+bun.yml +++ b/templates/changesets+bun.yml @@ -20,8 +20,10 @@ jobs: - name: Install dependencies run: bun install --frozen-lockfile --ignore-scripts - name: Run tests - run: bun run test + run: bun test publish: + needs: + - test runs-on: ubuntu-latest permissions: contents: read diff --git a/templates/changesets.yml b/templates/changesets.yml index 2d56d36..c5a58a4 100644 --- a/templates/changesets.yml +++ b/templates/changesets.yml @@ -13,13 +13,18 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + - name: Setup Node + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 with: node-version: 24 cache: npm - - run: npm ci --ignore-scripts - - run: npm test + - name: Install dependencies + run: npm ci --ignore-scripts + - name: Run tests + run: npm test publish: + needs: + - test runs-on: ubuntu-latest permissions: contents: read @@ -31,11 +36,13 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + - name: Setup Node + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 with: node-version: 24 package-manager-cache: false - - run: npm ci --ignore-scripts + - name: Install dependencies + run: npm ci --ignore-scripts - run: npm run build - name: Create Release or Publish uses: changesets/action@e0145edc7d9d8679003495b11f87bd8ef63c0cba # v1.5.3 diff --git a/templates/default+bun.yaml b/templates/default+bun.yaml new file mode 100644 index 0000000..9d6a6be --- /dev/null +++ b/templates/default+bun.yaml @@ -0,0 +1,76 @@ +name: Publish to npm +permissions: {} +on: + release: + types: + - published +jobs: + test: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + - name: Install dependencies + run: bun install --frozen-lockfile --ignore-scripts + - name: Run tests + run: bun test + build: + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + tarball: ${{ steps.pack.outputs.tarball }} + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + persist-credentials: false + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + - name: Install dependencies + run: bun install --frozen-lockfile --ignore-scripts + - run: bun run build + - run: bun pm version $TAG_NAME --git-tag-version=false + env: + TAG_NAME: ${{ github.ref_name }} + - id: pack + run: |- + TARBALL=$(bun pm pack) + echo "tarball=$TARBALL" >> $GITHUB_OUTPUT + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: tarball + path: ${{ steps.pack.outputs.tarball }} + publish: + needs: + - test + - build + runs-on: ubuntu-latest + permissions: + id-token: write + env: + TARBALL: ${{ needs.build.outputs.tarball }} + steps: + - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 + with: + name: tarball + - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + with: + node-version: 24 + package-manager-cache: false + - run: bun publish --provenance --access public --tag next $TARBALL + if: github.event.release.prerelease + env: + TARBALL: ${{ needs.build.outputs.tarball }} + - run: bun publish --provenance --access public $TARBALL + if: "!github.event.release.prerelease" + env: + TARBALL: ${{ needs.build.outputs.tarball }} diff --git a/templates/default.yml b/templates/default.yml index 31e0bd1..f5bc040 100644 --- a/templates/default.yml +++ b/templates/default.yml @@ -13,12 +13,15 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + - name: Setup Node + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 with: node-version: 24 cache: npm - - run: npm ci --ignore-scripts - - run: npm test + - name: Install dependencies + run: npm ci --ignore-scripts + - name: Run tests + run: npm test build: runs-on: ubuntu-latest permissions: @@ -29,11 +32,13 @@ jobs: - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 with: persist-credentials: false - - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + - name: Setup Node + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 with: node-version: 24 package-manager-cache: false - - run: npm ci --ignore-scripts + - name: Install dependencies + run: npm ci --ignore-scripts - run: npm run build - run: npm version $TAG_NAME --git-tag-version=false env: @@ -59,7 +64,8 @@ jobs: - uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0 with: name: tarball - - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 + - name: Setup Node + uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 # v5.0.0 with: node-version: 24 package-manager-cache: false