Skip to content

Commit

Permalink
Merge pull request #245 from SamKirkland/v4.2.0-beta
Browse files Browse the repository at this point in the history
V4.2.0
  • Loading branch information
SamKirkland authored Nov 22, 2021
2 parents 65c6a8f + 825d1b8 commit a964461
Show file tree
Hide file tree
Showing 8 changed files with 2,103 additions and 2,410 deletions.
64 changes: 38 additions & 26 deletions README.md

Large diffs are not rendered by default.

1,423 changes: 1,277 additions & 146 deletions dist/index.js

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions migration.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# Migrating from v4.1.0 to v4.2.0

`v4.2.0` parses the `exclude` option in a more standard way.

Going forward the `exclude` option **must** be in the following format
```yml
exclude: |
**/.git*
**/.git*/**
**/node_modules/**
fileToExclude.txt
```
---
# Migrating from v3 to v4
Migrating from v3 to v4 should be fairly straightforward. Version 4 was designed with speed and ease of initial setup in mind. Going forward version 4 will be the only supported version.
Expand Down
2,933 changes: 756 additions & 2,177 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ftp-deploy-action",
"version": "4.1.0",
"version": "4.2.0",
"private": true,
"description": "Automate deploying websites and more with this GitHub action",
"main": "dist/index.js",
Expand All @@ -22,20 +22,20 @@
"author": "Sam Kirkland",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.4.0",
"@samkirkland/ftp-deploy": "^1.1.0",
"@types/jest": "^26.0.23",
"jest": "^27.0.5",
"ts-jest": "^27.0.3",
"ts-node-dev": "^1.1.6"
"@actions/core": "^1.6.0",
"@samkirkland/ftp-deploy": "^1.1.1",
"@types/jest": "^27.0.2",
"jest": "^27.2.5",
"ts-jest": "^27.0.5",
"ts-node-dev": "^1.1.8"
},
"devDependencies": {
"@types/node": "^14.0.27",
"@typescript-eslint/eslint-plugin": "^4.28.0",
"@typescript-eslint/parser": "^4.28.0",
"@vercel/ncc": "^0.28.6",
"@typescript-eslint/parser": "^4.33.0",
"@vercel/ncc": "^0.31.1",
"eslint": "^7.29.0",
"eslint-plugin-jest": "^24.3.6",
"typescript": "^4.3.4"
"typescript": "^4.4.3"
}
}
32 changes: 1 addition & 31 deletions src/main.test.ts
Original file line number Diff line number Diff line change
@@ -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", () => {
Expand Down Expand Up @@ -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"]);
});
});
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
22 changes: 4 additions & 18 deletions src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,10 @@ 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 {
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 !== "");
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`);
}

// 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;
}

0 comments on commit a964461

Please sign in to comment.