more optional props

This commit is contained in:
SamKirkland 2020-08-30 00:05:41 -05:00
parent fc9de49cd2
commit 4fe6844638
3 changed files with 68 additions and 26 deletions

View File

@ -74,6 +74,7 @@ I strongly recommend you store your `password` as a secret.
| `include` | No | | `` | :warning: not implemented yet - An array of glob patterns, these files will always be included in the publish/delete process - even if no change occurred | | `include` | No | | `` | :warning: not implemented yet - An array of glob patterns, these files will always be included in the publish/delete process - even if no change occurred |
| `exclude` | No | | `.git*` `.git*/**` `node_modules/**` `node_modules/**/*` | An array of glob patterns, these files will not be included in the publish/delete process | | `exclude` | No | | `.git*` `.git*/**` `node_modules/**` `node_modules/**/*` | An array of glob patterns, these files will not be included in the publish/delete process |
| `log-level` | No | `info` | `info` | `warn`: only important/warning info, `info`: default, log important/warning info & progress info, `debug`: log everything for debugging | | `log-level` | No | `info` | `info` | `warn`: only important/warning info, `info`: default, log important/warning info & progress info, `debug`: log everything for debugging |
| `security` | No | `strict` | `loose` | `strict`: Reject any connection which is not authorized with the list of supplied CAs. `loose`: Allow connection even when the domain is not certificate |
# Common Examples # Common Examples

41
dist/index.js vendored
View File

@ -6803,14 +6803,15 @@ async function runDeployment() {
password: core.getInput("password", { required: true }), password: core.getInput("password", { required: true }),
protocol: optionalProtocol("protocol", core.getInput("protocol")), protocol: optionalProtocol("protocol", core.getInput("protocol")),
port: optionalInt("port", core.getInput("port")), port: optionalInt("port", core.getInput("port")),
"local-dir": core.getInput("local-dir"), "local-dir": optionalString(core.getInput("local-dir")),
"server-dir": core.getInput("server-dir"), "server-dir": optionalString(core.getInput("server-dir")),
"state-name": core.getInput("state-name"), "state-name": optionalString(core.getInput("state-name")),
"dry-run": optionalBoolean("dry-run", core.getInput("dry-run")), "dry-run": optionalBoolean("dry-run", core.getInput("dry-run")),
"dangerous-clean-slate": optionalBoolean("dangerous-clean-slate", core.getInput("dangerous-clean-slate")), "dangerous-clean-slate": optionalBoolean("dangerous-clean-slate", core.getInput("dangerous-clean-slate")),
"include": optionalStringArray("include", core.getInput("include")), "include": optionalStringArray("include", core.getInput("include")),
"exclude": optionalStringArray("exclude", core.getInput("exclude")), "exclude": optionalStringArray("exclude", core.getInput("exclude")),
"log-level": optionalLogLevel("log-level", core.getInput("log-level")) "log-level": optionalLogLevel("log-level", core.getInput("log-level")),
"security": optionalSecurity("security", core.getInput("security"))
}; };
try { try {
await ftp_deploy_1.deploy(args); await ftp_deploy_1.deploy(args);
@ -6820,8 +6821,14 @@ async function runDeployment() {
} }
} }
runDeployment(); runDeployment();
function optionalString(rawValue) {
if (rawValue.length === 0) {
return undefined;
}
return rawValue;
}
function optionalBoolean(argumentName, rawValue) { function optionalBoolean(argumentName, rawValue) {
if (rawValue === undefined) { if (rawValue.length === 0) {
return undefined; return undefined;
} }
const cleanValue = rawValue.toLowerCase(); const cleanValue = rawValue.toLowerCase();
@ -6834,7 +6841,7 @@ function optionalBoolean(argumentName, rawValue) {
core.setFailed(`${argumentName}: invalid parameter - please use a boolean, you provided "${rawValue}". Try true or false instead.`); core.setFailed(`${argumentName}: invalid parameter - please use a boolean, you provided "${rawValue}". Try true or false instead.`);
} }
function optionalProtocol(argumentName, rawValue) { function optionalProtocol(argumentName, rawValue) {
if (rawValue === undefined) { if (rawValue.length === 0) {
return undefined; return undefined;
} }
const cleanValue = rawValue.toLowerCase(); const cleanValue = rawValue.toLowerCase();
@ -6850,7 +6857,7 @@ function optionalProtocol(argumentName, rawValue) {
core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try "ftp", "ftps", or "ftps-legacy" instead.`); core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try "ftp", "ftps", or "ftps-legacy" instead.`);
} }
function optionalLogLevel(argumentName, rawValue) { function optionalLogLevel(argumentName, rawValue) {
if (rawValue === undefined) { if (rawValue.length === 0) {
return undefined; return undefined;
} }
const cleanValue = rawValue.toLowerCase(); const cleanValue = rawValue.toLowerCase();
@ -6865,19 +6872,31 @@ function optionalLogLevel(argumentName, rawValue) {
} }
core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try "warn", "info", or "debug" instead.`); core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try "warn", "info", or "debug" instead.`);
} }
function optionalInt(argumentName, rawValue) { function optionalSecurity(argumentName, rawValue) {
if (rawValue === undefined) { if (rawValue.length === 0) {
return undefined; return undefined;
} }
const cleanValue = rawValue.toLowerCase(); const cleanValue = rawValue.toLowerCase();
const valueAsNumber = parseFloat(cleanValue); if (cleanValue === "loose") {
return "loose";
}
if (cleanValue === "strict") {
return "strict";
}
core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try "loose" or "strict" instead.`);
}
function optionalInt(argumentName, rawValue) {
if (rawValue.length === 0) {
return undefined;
}
const valueAsNumber = parseFloat(rawValue);
if (Number.isInteger(valueAsNumber)) { if (Number.isInteger(valueAsNumber)) {
return valueAsNumber; return valueAsNumber;
} }
core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try a whole number (no decimals) instead like 1234`); core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try a whole number (no decimals) instead like 1234`);
} }
function optionalStringArray(argumentName, rawValue) { function optionalStringArray(argumentName, rawValue) {
if (rawValue === undefined) { if (rawValue.length === 0) {
return undefined; return undefined;
} }
// split value by space and comma // split value by space and comma

View File

@ -9,14 +9,15 @@ async function runDeployment() {
password: core.getInput("password", { required: true }), password: core.getInput("password", { required: true }),
protocol: optionalProtocol("protocol", core.getInput("protocol")), protocol: optionalProtocol("protocol", core.getInput("protocol")),
port: optionalInt("port", core.getInput("port")), port: optionalInt("port", core.getInput("port")),
"local-dir": core.getInput("local-dir"), "local-dir": optionalString(core.getInput("local-dir")),
"server-dir": core.getInput("server-dir"), "server-dir": optionalString(core.getInput("server-dir")),
"state-name": core.getInput("state-name"), "state-name": optionalString(core.getInput("state-name")),
"dry-run": optionalBoolean("dry-run", core.getInput("dry-run")), "dry-run": optionalBoolean("dry-run", core.getInput("dry-run")),
"dangerous-clean-slate": optionalBoolean("dangerous-clean-slate", core.getInput("dangerous-clean-slate")), "dangerous-clean-slate": optionalBoolean("dangerous-clean-slate", core.getInput("dangerous-clean-slate")),
"include": optionalStringArray("include", core.getInput("include")), "include": optionalStringArray("include", core.getInput("include")),
"exclude": optionalStringArray("exclude", core.getInput("exclude")), "exclude": optionalStringArray("exclude", core.getInput("exclude")),
"log-level": optionalLogLevel("log-level", core.getInput("log-level")) "log-level": optionalLogLevel("log-level", core.getInput("log-level")),
"security": optionalSecurity("security", core.getInput("security"))
}; };
@ -36,10 +37,16 @@ runDeployment();
function optionalString(rawValue: string): string | undefined {
if (rawValue.length === 0) {
return undefined;
}
return rawValue;
}
function optionalBoolean(argumentName: string, rawValue: string | undefined): boolean | undefined { function optionalBoolean(argumentName: string, rawValue: string): boolean | undefined {
if (rawValue === undefined) { if (rawValue.length === 0) {
return undefined; return undefined;
} }
@ -54,8 +61,8 @@ function optionalBoolean(argumentName: string, rawValue: string | undefined): bo
core.setFailed(`${argumentName}: invalid parameter - please use a boolean, you provided "${rawValue}". Try true or false instead.`); core.setFailed(`${argumentName}: invalid parameter - please use a boolean, you provided "${rawValue}". Try true or false instead.`);
} }
function optionalProtocol(argumentName: string, rawValue: string | undefined): "ftp" | "ftps" | "ftps-legacy" | undefined { function optionalProtocol(argumentName: string, rawValue: string): "ftp" | "ftps" | "ftps-legacy" | undefined {
if (rawValue === undefined) { if (rawValue.length === 0) {
return undefined; return undefined;
} }
@ -73,8 +80,8 @@ function optionalProtocol(argumentName: string, rawValue: string | undefined): "
core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try "ftp", "ftps", or "ftps-legacy" instead.`); core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try "ftp", "ftps", or "ftps-legacy" instead.`);
} }
function optionalLogLevel(argumentName: string, rawValue: string | undefined): "warn" | "info" | "debug" | undefined { function optionalLogLevel(argumentName: string, rawValue: string): "warn" | "info" | "debug" | undefined {
if (rawValue === undefined) { if (rawValue.length === 0) {
return undefined; return undefined;
} }
@ -92,13 +99,28 @@ function optionalLogLevel(argumentName: string, rawValue: string | undefined): "
core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try "warn", "info", or "debug" instead.`); core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try "warn", "info", or "debug" instead.`);
} }
function optionalInt(argumentName: string, rawValue: string | undefined): number | undefined { function optionalSecurity(argumentName: string, rawValue: string): "loose" | "strict" | undefined {
if (rawValue === undefined) { if (rawValue.length === 0) {
return undefined; return undefined;
} }
const cleanValue = rawValue.toLowerCase(); const cleanValue = rawValue.toLowerCase();
const valueAsNumber = parseFloat(cleanValue); if (cleanValue === "loose") {
return "loose";
}
if (cleanValue === "strict") {
return "strict";
}
core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try "loose" or "strict" instead.`);
}
function optionalInt(argumentName: string, rawValue: string): number | undefined {
if (rawValue.length === 0) {
return undefined;
}
const valueAsNumber = parseFloat(rawValue);
if (Number.isInteger(valueAsNumber)) { if (Number.isInteger(valueAsNumber)) {
return valueAsNumber; return valueAsNumber;
@ -107,8 +129,8 @@ function optionalInt(argumentName: string, rawValue: string | undefined): number
core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try a whole number (no decimals) instead like 1234`); core.setFailed(`${argumentName}: invalid parameter - you provided "${rawValue}". Try a whole number (no decimals) instead like 1234`);
} }
function optionalStringArray(argumentName: string, rawValue: string | undefined): string[] | undefined { function optionalStringArray(argumentName: string, rawValue: string): string[] | undefined {
if (rawValue === undefined) { if (rawValue.length === 0) {
return undefined; return undefined;
} }