Compare commits

..

1 Commits

Author SHA1 Message Date
github-actions[bot] 09fc6b5045 Automatic compilation 2023-08-31 16:02:19 +00:00
2 changed files with 11 additions and 65 deletions
+1 -6
View File
@@ -4,8 +4,7 @@ branding:
color: "orange"
description: "Deploy your Cloudflare projects from GitHub using Wrangler"
runs:
# Possible values: https://github.com/actions/runner/blob/main/src/Runner.Common/Util/NodeUtil.cs#L9
using: "node20"
using: "node16"
main: "dist/index.mjs"
inputs:
apiToken:
@@ -41,7 +40,3 @@ inputs:
vars:
description: "A string of environment variable names, separated by newlines. These will be bound to your Worker using the values of matching environment variables declared in `env` of this workflow."
required: false
packageManager:
description: "The package manager you'd like to use to install and run wrangler. If not specified, a value will be inferred based on the presence of a lockfile. Valid values: [npm, pnpm, yarn, bun]"
required: false
default: npm
+10 -59
View File
@@ -2826,8 +2826,6 @@ __nccwpck_require__.d(__webpack_exports__, {
var core = __nccwpck_require__(186);
;// CONCATENATED MODULE: external "node:child_process"
const external_node_child_process_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:child_process");
;// CONCATENATED MODULE: external "node:util"
const external_node_util_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:util");
;// CONCATENATED MODULE: external "node:fs"
const external_node_fs_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:fs");
;// CONCATENATED MODULE: external "node:path"
@@ -2835,6 +2833,9 @@ const external_node_path_namespaceObject = __WEBPACK_EXTERNAL_createRequire(impo
;// CONCATENATED MODULE: ./src/utils.ts
function getNpxCmd() {
return process.env.RUNNER_OS === "Windows" ? "npx.cmd" : "npx";
}
/**
* A helper function to compare two semver versions. If the second arg is greater than the first arg, it returns true.
*/
@@ -2861,59 +2862,13 @@ function checkWorkingDirectory(workingDirectory = ".") {
}
}
;// CONCATENATED MODULE: ./src/packageManagers.ts
const PACKAGE_MANAGERS = {
npm: {
install: "npm i",
exec: "npx",
},
yarn: {
install: "yarn add",
exec: "yarn",
},
pnpm: {
install: "pnpm add",
exec: "pnpm exec",
},
bun: {
install: "bun i",
exec: "bunx"
},
};
function detectPackageManager(workingDirectory = ".") {
if ((0,external_node_fs_namespaceObject.existsSync)(external_node_path_namespaceObject.join(workingDirectory, "package-lock.json"))) {
return "npm";
}
if ((0,external_node_fs_namespaceObject.existsSync)(external_node_path_namespaceObject.join(workingDirectory, "yarn.lock"))) {
return "yarn";
}
if ((0,external_node_fs_namespaceObject.existsSync)(external_node_path_namespaceObject.join(workingDirectory, "pnpm-lock.yaml"))) {
return "pnpm";
}
if ((0,external_node_fs_namespaceObject.existsSync)(external_node_path_namespaceObject.join(workingDirectory, "bun.lockb"))) {
return "bun";
}
return null;
}
function assertValidPackageManagerValue(name) {
if (name && !Object.keys(PACKAGE_MANAGERS).includes(name)) {
throw new TypeError(`invalid value provided for "packageManager": ${name}
Value must be one of: [${Object.keys(PACKAGE_MANAGERS).join(", ")}]`);
}
}
function getPackageManager(name, { workingDirectory = "." } = {}) {
assertValidPackageManagerValue(name);
return PACKAGE_MANAGERS[name || detectPackageManager(workingDirectory) || "npm"];
}
;// CONCATENATED MODULE: external "node:util"
const external_node_util_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:util");
;// CONCATENATED MODULE: ./src/index.ts
const execAsync = external_node_util_namespaceObject.promisify(external_node_child_process_namespaceObject.exec);
const DEFAULT_WRANGLER_VERSION = "3.5.1";
/**
@@ -2929,11 +2884,7 @@ const config = {
VARS: (0,core.getMultilineInput)("vars"),
COMMANDS: (0,core.getMultilineInput)("command"),
QUIET_MODE: (0,core.getBooleanInput)("quiet"),
PACKAGE_MANAGER: (0,core.getInput)("packageManager"),
};
const packageManager = getPackageManager(config.PACKAGE_MANAGER, {
workingDirectory: config.workingDirectory,
});
function info(message, bypass) {
if (!config.QUIET_MODE || bypass) {
(0,core.info)(message);
@@ -2987,7 +2938,7 @@ function installWrangler() {
throw new Error(`Wrangler v1 is no longer supported by this action. Please use major version 2 or greater`);
}
startGroup("📥 Installing Wrangler");
const command = `${packageManager.install} wrangler@${config["WRANGLER_VERSION"]}`;
const command = `npm install wrangler@${config["WRANGLER_VERSION"]}`;
info(`Running command: ${command}`);
(0,external_node_child_process_namespaceObject.execSync)(command, { cwd: config["workingDirectory"], env: process.env });
info(`✅ Wrangler installed`, true);
@@ -3005,7 +2956,7 @@ async function execCommands(commands, cmdType) {
try {
const arrPromises = commands.map(async (command) => {
const cmd = command.startsWith("wrangler")
? `${packageManager.exec} ${command}`
? `${getNpxCmd()} ${command}`
: command;
info(`🚀 Executing command: ${cmd}`);
return await runProcess(cmd, {
@@ -3035,7 +2986,7 @@ function getSecret(secret) {
async function legacyUploadSecrets(secrets, environment, workingDirectory) {
const arrPromises = secrets
.map((secret) => {
const command = `echo ${getSecret(secret)} | ${packageManager.exec} wrangler secret put ${secret}`;
const command = `echo ${getSecret(secret)} | ${getNpxCmd()} wrangler secret put ${secret}`;
return environment ? command.concat(` --env ${environment}`) : command;
})
.map(async (command) => await execAsync(command, {
@@ -3062,7 +3013,7 @@ async function uploadSecrets() {
const environmentSuffix = !environment.length
? ""
: ` --env ${environment}`;
const secretCmd = `echo "${JSON.stringify(secretObj).replaceAll('"', '\\"')}" | ${packageManager.exec} wrangler secret:bulk ${environmentSuffix}`;
const secretCmd = `echo "${JSON.stringify(secretObj).replaceAll('"', '\\"')}" | ${getNpxCmd()} wrangler secret:bulk ${environmentSuffix}`;
(0,external_node_child_process_namespaceObject.execSync)(secretCmd, {
cwd: workingDirectory,
env: process.env,
@@ -3106,7 +3057,7 @@ async function wranglerCommands() {
if (environment.length > 0 && !command.includes(`--env`)) {
command = command.concat(` --env ${environment}`);
}
const cmd = `${packageManager.exec} wrangler ${command} ${(command.startsWith("deploy") || command.startsWith("publish")) &&
const cmd = `${getNpxCmd()} wrangler ${command} ${(command.startsWith("deploy") || command.startsWith("publish")) &&
!command.includes(`--var`)
? getVarArgs()
: ""}`.trim();