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 53 deletions
+1 -5
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,6 +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 name of the package manager to install and run wrangler. If not provided, it will be detected via the lock file. Valid values: [npm, pnpm, yarn]"
required: false
+10 -48
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.
*/
@@ -2860,22 +2861,9 @@ function checkWorkingDirectory(workingDirectory = ".") {
throw new Error(`Directory ${workingDirectory} does not exist.`);
}
}
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";
}
return null;
}
function isValidPackageManager(name) {
return name === "npm" || name === "yarn" || name === "pnpm";
}
;// CONCATENATED MODULE: external "node:util"
const external_node_util_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:util");
;// CONCATENATED MODULE: ./src/index.ts
@@ -2883,20 +2871,6 @@ function isValidPackageManager(name) {
const execAsync = external_node_util_namespaceObject.promisify(external_node_child_process_namespaceObject.exec);
const DEFAULT_WRANGLER_VERSION = "3.5.1";
const PACKAGE_MANAGER_COMMANDS = {
npm: {
install: "npm i",
exec: "npx",
},
yarn: {
install: "yarn add",
exec: "yarn",
},
pnpm: {
install: "pnpm add",
exec: "pnpm exec",
},
};
/**
* A configuration object that contains all the inputs & immutable state for the action.
*/
@@ -2910,19 +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"),
};
function realPackageManager() {
if (isValidPackageManager(config.PACKAGE_MANAGER)) {
return config.PACKAGE_MANAGER;
}
const packageManager = detectPackageManager(config.workingDirectory);
if (packageManager !== null) {
return packageManager;
}
throw new Error("Package manager is not detected");
}
const pkgManagerCmd = PACKAGE_MANAGER_COMMANDS[realPackageManager()];
function info(message, bypass) {
if (!config.QUIET_MODE || bypass) {
(0,core.info)(message);
@@ -2976,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 = `${pkgManagerCmd.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);
@@ -2994,7 +2956,7 @@ async function execCommands(commands, cmdType) {
try {
const arrPromises = commands.map(async (command) => {
const cmd = command.startsWith("wrangler")
? `${pkgManagerCmd.exec} ${command}`
? `${getNpxCmd()} ${command}`
: command;
info(`🚀 Executing command: ${cmd}`);
return await runProcess(cmd, {
@@ -3024,7 +2986,7 @@ function getSecret(secret) {
async function legacyUploadSecrets(secrets, environment, workingDirectory) {
const arrPromises = secrets
.map((secret) => {
const command = `echo ${getSecret(secret)} | ${pkgManagerCmd.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, {
@@ -3051,7 +3013,7 @@ async function uploadSecrets() {
const environmentSuffix = !environment.length
? ""
: ` --env ${environment}`;
const secretCmd = `echo "${JSON.stringify(secretObj).replaceAll('"', '\\"')}" | ${pkgManagerCmd.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,
@@ -3095,7 +3057,7 @@ async function wranglerCommands() {
if (environment.length > 0 && !command.includes(`--env`)) {
command = command.concat(` --env ${environment}`);
}
const cmd = `${pkgManagerCmd.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();