mirror of
https://github.com/SamKirkland/FTP-Deploy-Action.git
synced 2026-04-10 12:32:17 +02:00
v4.2.0 beta
- fixes for 550 folder issue - updated excludes option format
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { optionalBoolean, optionalInt, optionalLogLevel, optionalProtocol, optionalSecurity, optionalString, optionalStringArray } from "./parse";
|
||||
import { optionalBoolean, optionalInt, optionalLogLevel, optionalProtocol, optionalSecurity, optionalString } from "./parse";
|
||||
|
||||
describe("boolean", () => {
|
||||
test("false", () => {
|
||||
@@ -103,33 +103,3 @@ describe("security", () => {
|
||||
expect(optionalSecurity("test", "strict")).toBe("strict");
|
||||
});
|
||||
});
|
||||
|
||||
describe("array", () => {
|
||||
test("empty", () => {
|
||||
expect(optionalStringArray("test", "")).toEqual(undefined);
|
||||
});
|
||||
|
||||
test("empty array", () => {
|
||||
expect(optionalStringArray("test", "[]")).toEqual([]);
|
||||
});
|
||||
|
||||
test(`["test.txt"]`, () => {
|
||||
expect(optionalStringArray("test", "[test.txt]")).toEqual(["test.txt"]);
|
||||
});
|
||||
|
||||
test(`[ "test.txt" ]`, () => {
|
||||
expect(optionalStringArray("test", "[ test.txt ]")).toEqual(["test.txt"]);
|
||||
});
|
||||
|
||||
test(`["test.txt", "folder/**/*"]`, () => {
|
||||
expect(optionalStringArray("test", "[test.txt, folder/**/*]")).toEqual(["test.txt", "folder/**/*"]);
|
||||
});
|
||||
|
||||
test(`["test.txt", "folder/**/*", "*other"]`, () => {
|
||||
expect(optionalStringArray("test", `test.txt\n - folder/**/*\n - *other`)).toEqual(["test.txt", "folder/**/*", "*other"]);
|
||||
});
|
||||
|
||||
test(`["test.txt", "folder/**/*", "*other"]`, () => {
|
||||
expect(optionalStringArray("test", `\n - test.txt\n - folder/**/*\n - *other`)).toEqual(["test.txt", "folder/**/*", "*other"]);
|
||||
});
|
||||
});
|
||||
@@ -16,14 +16,14 @@ async function runDeployment() {
|
||||
"state-name": optionalString(core.getInput("state-name")),
|
||||
"dry-run": optionalBoolean("dry-run", core.getInput("dry-run")),
|
||||
"dangerous-clean-slate": optionalBoolean("dangerous-clean-slate", core.getInput("dangerous-clean-slate")),
|
||||
"exclude": optionalStringArray("exclude", core.getInput("exclude")),
|
||||
"exclude": optionalStringArray("exclude", core.getMultilineInput("exclude")),
|
||||
"log-level": optionalLogLevel("log-level", core.getInput("log-level")),
|
||||
"security": optionalSecurity("security", core.getInput("security"))
|
||||
};
|
||||
|
||||
await deploy(args);
|
||||
}
|
||||
catch (error) {
|
||||
catch (error: any) {
|
||||
core.setFailed(error);
|
||||
}
|
||||
}
|
||||
|
||||
22
src/parse.ts
22
src/parse.ts
@@ -90,24 +90,14 @@ export function optionalInt(argumentName: string, rawValue: string): number | un
|
||||
throw new Error(`${argumentName}: invalid parameter - you provided "${rawValue}". Try a whole number (no decimals) instead like 1234`);
|
||||
}
|
||||
|
||||
export function optionalStringArray(argumentName: string, rawValue: string): string[] | undefined {
|
||||
export function optionalStringArray(argumentName: string, rawValue: string[]): string[] | undefined {
|
||||
if (typeof rawValue === "string") {
|
||||
throw new Error(`${argumentName}: invalid parameter - you provided "${rawValue}". This option expects an list in the EXACT format described in the readme`);
|
||||
}
|
||||
|
||||
if (rawValue.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const valueTrim = rawValue.trim();
|
||||
|
||||
if (valueTrim.startsWith("[")) {
|
||||
// remove [ and ] - then convert to array
|
||||
return rawValue.replace(/[\[\]]/g, "").trim().split(", ").filter(str => str !== "");
|
||||
}
|
||||
|
||||
// split value by space and comma
|
||||
const valueAsArrayDouble = rawValue.split(" - ").map(str => str.trim()).filter(str => str !== "");
|
||||
|
||||
if (valueAsArrayDouble.length) {
|
||||
return valueAsArrayDouble;
|
||||
}
|
||||
|
||||
throw new Error(`${argumentName}: invalid parameter - you provided "${rawValue}". This option excepts an array in the format [val1, val2] or val1\/n - val2`);
|
||||
return rawValue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user