Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Added support for different package managers #125

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22070,6 +22070,7 @@ try {
const branch = (0, import_core.getInput)("branch", { required: false });
const workingDirectory = (0, import_core.getInput)("workingDirectory", { required: false });
const wranglerVersion = (0, import_core.getInput)("wranglerVersion", { required: false });
const packageManager = (0, import_core.getInput)("packageManager", { required: false });
const getProject = async () => {
const response = await (0, import_undici.fetch)(
`https://api.cloudflare.com/client/v4/accounts/${accountId}/pages/projects/${projectName}`,
Expand All @@ -22088,13 +22089,19 @@ try {
return result;
};
const createPagesDeployment = async () => {
let packageRunner = "npx";
if (packageManager === "pnpm") {
packageRunner = "pnpm dlx";
} else if (packageManager === "bun") {
packageRunner = "bunx";
}
await src_default.in(import_node_path.default.join(process.cwd(), workingDirectory))`
$ export CLOUDFLARE_API_TOKEN="${apiToken}"
if ${accountId} {
$ export CLOUDFLARE_ACCOUNT_ID="${accountId}"
}

$$ npx wrangler@${wranglerVersion} pages publish "${directory}" --project-name="${projectName}" --branch="${branch}"
$$ ${packageRunner} wrangler@${wranglerVersion} pages publish "${directory}" --project-name="${projectName}" --branch="${branch}"
`;
const response = await (0, import_undici.fetch)(
`https://api.cloudflare.com/client/v4/accounts/${accountId}/pages/projects/${projectName}/deployments`,
Expand Down
10 changes: 9 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ try {
const branch = getInput("branch", { required: false });
const workingDirectory = getInput("workingDirectory", { required: false });
const wranglerVersion = getInput("wranglerVersion", { required: false });
const packageManager = getInput("packageManager", { required: false });

const getProject = async () => {
const response = await fetch(
Expand All @@ -39,14 +40,21 @@ try {
};

const createPagesDeployment = async () => {
let packageRunner = "npx"
if(packageManager === "pnpm") {
packageRunner = "pnpm dlx"
} else if (packageManager === "bun") {
packageRunner = "bunx"
}

// TODO: Replace this with an API call to wrangler so we can get back a full deployment response object
await shellac.in(path.join(process.cwd(), workingDirectory))`
$ export CLOUDFLARE_API_TOKEN="${apiToken}"
if ${accountId} {
$ export CLOUDFLARE_ACCOUNT_ID="${accountId}"
}

$$ npx wrangler@${wranglerVersion} pages publish "${directory}" --project-name="${projectName}" --branch="${branch}"
$$ ${packageRunner} wrangler@${wranglerVersion} pages publish "${directory}" --project-name="${projectName}" --branch="${branch}"
`;

const response = await fetch(
Expand Down