Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/dns-scripts-package-manager.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bunny.net/cli": patch
---

fix(dns): `dns scripts init` detects and uses any installed package manager (bun, pnpm, yarn, npm) instead of assuming bun, and warns clearly when none is on PATH
32 changes: 32 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
cli-version: ${{ steps.check-cli.outputs.version }}
database-shell-version: ${{ steps.check-database-shell.outputs.version }}
openapi-client-version: ${{ steps.check-openapi-client.outputs.version }}
scriptable-dns-types-version: ${{ steps.check-scriptable-dns-types.outputs.version }}
steps:
- uses: actions/checkout@v5
- name: Check openapi-client version
Expand All @@ -52,6 +53,17 @@ jobs:
else
echo "No version change: $VERSION"
fi
- name: Check scriptable-dns-types version
id: check-scriptable-dns-types
run: |
VERSION=$(node -p "require('./packages/scriptable-dns-types/package.json').version")
PUBLISHED=$(npm view @bunny.net/scriptable-dns-types version 2>/dev/null || echo "0.0.0")
if [ "$VERSION" != "$PUBLISHED" ]; then
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "New version detected: $VERSION (published: $PUBLISHED)"
else
echo "No version change: $VERSION"
fi
- name: Check CLI version
id: check-cli
run: |
Expand Down Expand Up @@ -415,3 +427,23 @@ jobs:
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

publish-scriptable-dns-types:
name: Publish scriptable-dns-types
runs-on: ubuntu-latest
needs: version
if: needs.version.outputs.scriptable-dns-types-version
steps:
- uses: actions/checkout@v5

- uses: actions/setup-node@v5
with:
node-version: "22"
registry-url: "https://registry.npmjs.org"

- name: Publish @bunny.net/scriptable-dns-types
run: |
cd packages/scriptable-dns-types
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
46 changes: 27 additions & 19 deletions packages/cli/src/commands/dns/scripts/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { defineCommand } from "../../../core/define-command.ts";
import { UserError } from "../../../core/errors.ts";
import { logger } from "../../../core/logger.ts";
import { saveManifestAt } from "../../../core/manifest.ts";
import { pickPackageManager } from "../../../core/package-manager.ts";
import { confirm, spinner } from "../../../core/ui.ts";
import { createDnsScript } from "./api.ts";
import {
Expand Down Expand Up @@ -157,29 +158,36 @@ export const dnsScriptsInitCommand = defineCommand<InitArgs>({

if (args[ARG_SKIP_INSTALL] !== true) {
const install = interactive
? await confirm("Install editor type dependencies with bun?")
? await confirm("Install editor type dependencies?")
: false;
if (install) {
const spin = spinner("Installing dependencies (bun)...");
spin.start();
let code = 1;
try {
const proc = Bun.spawn(["bun", "install"], {
cwd: dirPath,
stdout: "ignore",
stderr: "ignore",
});
code = await proc.exited;
} catch {
// bun missing or vanished; warn below.
}
spin.stop();
if (code === 0) {
logger.success("Dependencies installed.");
} else {
const pm = await pickPackageManager(dirPath);
if (!pm) {
logger.warn(
"Could not install dependencies. Run `bun install` later.",
"No package manager found on PATH. Install bun, npm, pnpm, or yarn, then install dependencies in the new project.",
);
Comment thread
jamie-at-bunny marked this conversation as resolved.
} else {
const spin = spinner(`Installing dependencies (${pm})...`);
spin.start();
let code = 1;
try {
const proc = Bun.spawn([pm, "install"], {
cwd: dirPath,
stdout: "ignore",
stderr: "ignore",
});
code = await proc.exited;
} catch {
// Binary vanished between detection and spawn; warn below.
}
spin.stop();
if (code === 0) {
logger.success("Dependencies installed.");
} else {
logger.warn(
`Could not install dependencies. Run \`${pm} install\` later.`,
);
}
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions packages/cli/src/commands/scripts/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import { UserError } from "../../core/errors.ts";
import { normalizeHostname } from "../../core/hostnames/index.ts";
import { logger } from "../../core/logger.ts";
import { saveManifestAt } from "../../core/manifest.ts";
import {
detectFromLockfile,
pickPackageManager,
} from "../../core/package-manager.ts";
import { confirm, spinner } from "../../core/ui.ts";
import { promptOpenInBrowser } from "./api.ts";
import {
Expand All @@ -18,7 +22,6 @@ import {
type Template,
} from "./constants.ts";
import { createScript, setupCustomDomain } from "./create.ts";
import { detectFromLockfile, pickPackageManager } from "./package-manager.ts";

const COMMAND = "init";
const DESCRIPTION = "Create a new Edge Script project.";
Expand Down Expand Up @@ -308,7 +311,7 @@ export const scriptsInitCommand = defineCommand<InitArgs>({
const pm = await pickPackageManager(dirPath);
if (!pm) {
logger.warn(
"No package manager found on PATH. Install bun, npm, pnpm, or yarn, then run `<pm> install` in the new project.",
"No package manager found on PATH. Install bun, npm, pnpm, or yarn, then install dependencies in the new project.",
);
} else {
const lockfilePm = detectFromLockfile(dirPath);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, test } from "bun:test";
import { writeFileSync } from "node:fs";
import { join } from "node:path";
import { useTempDir } from "../../test-utils/temp-dir.ts";
import { useTempDir } from "../test-utils/temp-dir.ts";
import { detectFromLockfile, detectFromUserAgent } from "./package-manager.ts";

describe("detectFromLockfile", () => {
Expand Down