796j2yr1lh 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.devcontainer/devcontainer.json +4 -0
- package/.devcontainer/setup.sh +11 -0
- package/.dockerignore +2 -0
- package/.github/CONTRIBUTING.md +52 -0
- package/.github/FUNDING.yml +3 -0
- package/.github/ISSUE_TEMPLATE/bug_report.yml +59 -0
- package/.github/ISSUE_TEMPLATE/config.yml +5 -0
- package/.github/ISSUE_TEMPLATE/feature_request.yml +43 -0
- package/.github/dependabot.yml +17 -0
- package/.github/workflows/codeql.yml +76 -0
- package/.github/workflows/publish_docs.yml +25 -0
- package/.github/workflows/test.yml +78 -0
- package/.nvmrc +1 -0
- package/.prettierignore +1 -0
- package/.prettierrc +1 -0
- package/.vscode/launch.json +42 -0
- package/CODE_OF_CONDUCT.md +76 -0
- package/Dockerfile +17 -0
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/SECURITY.md +5 -0
- package/__tests__/actions/cacheTest.ts +58 -0
- package/__tests__/actions/randomNumber.ts +26 -0
- package/__tests__/actions/recursiveAction.ts +16 -0
- package/__tests__/actions/sleepTest.ts +24 -0
- package/__tests__/actions/status.ts +17 -0
- package/__tests__/actions/swagger.ts +76 -0
- package/__tests__/actions/validationTest.ts +63 -0
- package/__tests__/cli/cli.ts +126 -0
- package/__tests__/core/api.ts +632 -0
- package/__tests__/core/cache.ts +400 -0
- package/__tests__/core/chatRoom.ts +589 -0
- package/__tests__/core/cli.ts +349 -0
- package/__tests__/core/cluster.ts +132 -0
- package/__tests__/core/config.ts +78 -0
- package/__tests__/core/errors.ts +112 -0
- package/__tests__/core/log.ts +23 -0
- package/__tests__/core/middleware.ts +427 -0
- package/__tests__/core/plugins/partialPlugin.ts +94 -0
- package/__tests__/core/plugins/withPlugin.ts +88 -0
- package/__tests__/core/plugins/withoutPlugin.ts +81 -0
- package/__tests__/core/process.ts +42 -0
- package/__tests__/core/specHelper.ts +330 -0
- package/__tests__/core/staticFile/compression.ts +99 -0
- package/__tests__/core/staticFile/staticFile.ts +180 -0
- package/__tests__/core/tasks/customQueueFunction.ts +67 -0
- package/__tests__/core/tasks/fullWorkerFlow.ts +199 -0
- package/__tests__/core/tasks/tasks.ts +605 -0
- package/__tests__/integration/browser.ts +133 -0
- package/__tests__/integration/ioredis-mock.ts +194 -0
- package/__tests__/integration/sendBuffer.ts +97 -0
- package/__tests__/integration/sendFile.ts +24 -0
- package/__tests__/integration/sharedFingerprint.ts +82 -0
- package/__tests__/integration/taskFlow.ts +110 -0
- package/__tests__/jest.ts +5 -0
- package/__tests__/modules/action.ts +103 -0
- package/__tests__/modules/config.ts +19 -0
- package/__tests__/modules/utils/ensureNoTsHeaderOrSpecFiles.ts +24 -0
- package/__tests__/servers/web/allowedRequestHosts.ts +88 -0
- package/__tests__/servers/web/enableMultiples.ts +83 -0
- package/__tests__/servers/web/fileUpload.ts +79 -0
- package/__tests__/servers/web/jsonp.ts +57 -0
- package/__tests__/servers/web/nonMultiples.ts +83 -0
- package/__tests__/servers/web/rawBody.ts +208 -0
- package/__tests__/servers/web/returnErrorCodes.ts +55 -0
- package/__tests__/servers/web/routes/deepRoutes.ts +96 -0
- package/__tests__/servers/web/routes/routes.ts +579 -0
- package/__tests__/servers/web/routes/veryDeepRoutes.ts +92 -0
- package/__tests__/servers/web/web.ts +1031 -0
- package/__tests__/servers/websocket.ts +795 -0
- package/__tests__/tasks/runAction.ts +37 -0
- package/__tests__/template.ts.example +20 -0
- package/__tests__/testCliCommands/hello.ts +44 -0
- package/__tests__/testPlugin/public/plugin.html +1 -0
- package/__tests__/testPlugin/src/actions/pluginAction.ts +14 -0
- package/__tests__/testPlugin/src/bin/hello.ts +22 -0
- package/__tests__/testPlugin/src/initializers/pluginInitializer.ts +17 -0
- package/__tests__/testPlugin/src/tasks/pluginTask.ts +15 -0
- package/__tests__/testPlugin/tsconfig.json +10 -0
- package/__tests__/utils/utils.ts +492 -0
- package/app.json +23 -0
- package/bin/deploy-docs +39 -0
- package/client/ActionheroWebsocketClient.js +277 -0
- package/docker-compose.yml +73 -0
- package/package.json +24 -0
- package/public/chat.html +194 -0
- package/public/css/cosmo.css +12 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +115 -0
- package/public/javascript/.gitkeep +0 -0
- package/public/linkedSession.html +80 -0
- package/public/logo/actionhero-small.png +0 -0
- package/public/logo/actionhero.png +0 -0
- package/public/pixel.gif +0 -0
- package/public/simple.html +2 -0
- package/public/swagger.html +32 -0
- package/public/websocketLoadTest.html +322 -0
- package/src/actions/cacheTest.ts +58 -0
- package/src/actions/createChatRoom.ts +20 -0
- package/src/actions/randomNumber.ts +17 -0
- package/src/actions/recursiveAction.ts +13 -0
- package/src/actions/sendFile.ts +12 -0
- package/src/actions/sleepTest.ts +40 -0
- package/src/actions/status.ts +73 -0
- package/src/actions/swagger.ts +155 -0
- package/src/actions/validationTest.ts +36 -0
- package/src/bin/actionhero.ts +225 -0
- package/src/bin/methods/actions/list.ts +30 -0
- package/src/bin/methods/console.ts +26 -0
- package/src/bin/methods/generate/action.ts +58 -0
- package/src/bin/methods/generate/cli.ts +51 -0
- package/src/bin/methods/generate/initializer.ts +54 -0
- package/src/bin/methods/generate/plugin.ts +57 -0
- package/src/bin/methods/generate/server.ts +38 -0
- package/src/bin/methods/generate/task.ts +68 -0
- package/src/bin/methods/generate.ts +176 -0
- package/src/bin/methods/task/enqueue.ts +35 -0
- package/src/classes/action.ts +98 -0
- package/src/classes/actionProcessor.ts +463 -0
- package/src/classes/api.ts +51 -0
- package/src/classes/cli.ts +67 -0
- package/src/classes/config.ts +15 -0
- package/src/classes/connection.ts +321 -0
- package/src/classes/exceptionReporter.ts +9 -0
- package/src/classes/initializer.ts +59 -0
- package/src/classes/initializers.ts +5 -0
- package/src/classes/input.ts +9 -0
- package/src/classes/inputs.ts +34 -0
- package/src/classes/process/actionheroVersion.ts +15 -0
- package/src/classes/process/env.ts +16 -0
- package/src/classes/process/id.ts +34 -0
- package/src/classes/process/pid.ts +32 -0
- package/src/classes/process/projectRoot.ts +16 -0
- package/src/classes/process/typescript.ts +47 -0
- package/src/classes/process.ts +479 -0
- package/src/classes/server.ts +251 -0
- package/src/classes/task.ts +87 -0
- package/src/config/api.ts +107 -0
- package/src/config/errors.ts +162 -0
- package/src/config/logger.ts +113 -0
- package/src/config/plugins.ts +37 -0
- package/src/config/redis.ts +78 -0
- package/src/config/routes.ts +44 -0
- package/src/config/tasks.ts +84 -0
- package/src/config/web.ts +136 -0
- package/src/config/websocket.ts +62 -0
- package/src/index.ts +46 -0
- package/src/initializers/actions.ts +125 -0
- package/src/initializers/chatRoom.ts +214 -0
- package/src/initializers/connections.ts +124 -0
- package/src/initializers/exceptions.ts +155 -0
- package/src/initializers/params.ts +52 -0
- package/src/initializers/redis.ts +191 -0
- package/src/initializers/resque.ts +248 -0
- package/src/initializers/routes.ts +229 -0
- package/src/initializers/servers.ts +134 -0
- package/src/initializers/specHelper.ts +195 -0
- package/src/initializers/staticFile.ts +253 -0
- package/src/initializers/tasks.ts +188 -0
- package/src/modules/action.ts +89 -0
- package/src/modules/cache.ts +326 -0
- package/src/modules/chatRoom.ts +321 -0
- package/src/modules/config.ts +246 -0
- package/src/modules/log.ts +62 -0
- package/src/modules/redis.ts +93 -0
- package/src/modules/route.ts +59 -0
- package/src/modules/specHelper.ts +182 -0
- package/src/modules/task.ts +527 -0
- package/src/modules/utils/argv.ts +3 -0
- package/src/modules/utils/arrayStartingMatch.ts +21 -0
- package/src/modules/utils/arrayUnique.ts +15 -0
- package/src/modules/utils/collapseObjectToArray.ts +33 -0
- package/src/modules/utils/deepCopy.ts +3 -0
- package/src/modules/utils/ensureNoTsHeaderOrSpecFiles.ts +19 -0
- package/src/modules/utils/eventLoopDelay.ts +34 -0
- package/src/modules/utils/fileUtils.ts +119 -0
- package/src/modules/utils/filterObjectForLogging.ts +51 -0
- package/src/modules/utils/filterResponseForLogging.ts +53 -0
- package/src/modules/utils/getExternalIPAddress.ts +17 -0
- package/src/modules/utils/hashMerge.ts +63 -0
- package/src/modules/utils/isPlainObject.ts +45 -0
- package/src/modules/utils/isRunning.ts +7 -0
- package/src/modules/utils/parseCookies.ts +20 -0
- package/src/modules/utils/parseHeadersForClientAddress.ts +53 -0
- package/src/modules/utils/parseIPv6URI.ts +24 -0
- package/src/modules/utils/replaceDistWithSrc.ts +9 -0
- package/src/modules/utils/safeGlob.ts +6 -0
- package/src/modules/utils/sleep.ts +8 -0
- package/src/modules/utils/sortGlobalMiddleware.ts +17 -0
- package/src/modules/utils/sourceRelativeLinkPath.ts +29 -0
- package/src/modules/utils.ts +66 -0
- package/src/server.ts +20 -0
- package/src/servers/web.ts +894 -0
- package/src/servers/websocket.ts +304 -0
- package/src/tasks/runAction.ts +29 -0
- package/tea.yaml +9 -0
- package/templates/README.md.template +17 -0
- package/templates/action.ts.template +15 -0
- package/templates/boot.js.template +9 -0
- package/templates/cli.ts.template +15 -0
- package/templates/gitignore.template +23 -0
- package/templates/initializer.ts.template +17 -0
- package/templates/package-plugin.json.template +12 -0
- package/templates/package.json.template +45 -0
- package/templates/projectMap.txt +39 -0
- package/templates/projectServer.ts.template +20 -0
- package/templates/server.ts.template +37 -0
- package/templates/task.ts.template +16 -0
- package/templates/test/action.ts.template +13 -0
- package/templates/test/task.ts.template +20 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Process, specHelper } from "./../../src/index";
|
|
2
|
+
import { RecursiveAction } from "../../src/actions/recursiveAction";
|
|
3
|
+
|
|
4
|
+
describe("Action: recursiveAction", () => {
|
|
5
|
+
const actionhero = new Process();
|
|
6
|
+
beforeAll(async () => await actionhero.start());
|
|
7
|
+
afterAll(async () => await actionhero.stop());
|
|
8
|
+
|
|
9
|
+
test("merges its own response with the randomNumber response", async () => {
|
|
10
|
+
const response =
|
|
11
|
+
await specHelper.runAction<RecursiveAction>("recursiveAction");
|
|
12
|
+
expect(response.local).toEqual(true);
|
|
13
|
+
expect(response.randomNumber).toBeGreaterThanOrEqual(0);
|
|
14
|
+
expect(response.stringRandomNumber).toMatch(/Your random number is/);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Process, specHelper } from "./../../src/index";
|
|
2
|
+
import { SleepTest } from "../../src/actions/sleepTest";
|
|
3
|
+
|
|
4
|
+
describe("Action: sleepTest", () => {
|
|
5
|
+
const actionhero = new Process();
|
|
6
|
+
beforeAll(async () => await actionhero.start());
|
|
7
|
+
afterAll(async () => await actionhero.stop());
|
|
8
|
+
|
|
9
|
+
test("will return data from an async action", async () => {
|
|
10
|
+
const { sleepDuration } =
|
|
11
|
+
await specHelper.runAction<SleepTest>("sleepTest");
|
|
12
|
+
expect(sleepDuration).toEqual(1000);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
test("can change sleepDuration", async () => {
|
|
16
|
+
const { sleepDuration } = await specHelper.runAction<SleepTest>(
|
|
17
|
+
"sleepTest",
|
|
18
|
+
{
|
|
19
|
+
sleepDuration: 100,
|
|
20
|
+
},
|
|
21
|
+
);
|
|
22
|
+
expect(sleepDuration).toEqual(100);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Process, specHelper } from "./../../src/index";
|
|
2
|
+
import { Status } from "../../src/actions/status";
|
|
3
|
+
|
|
4
|
+
describe("Action: status", () => {
|
|
5
|
+
const actionhero = new Process();
|
|
6
|
+
beforeAll(async () => await actionhero.start());
|
|
7
|
+
afterAll(async () => await actionhero.stop());
|
|
8
|
+
|
|
9
|
+
test("returns node status", async () => {
|
|
10
|
+
const { id, problems, name, error } =
|
|
11
|
+
await specHelper.runAction<Status>("status");
|
|
12
|
+
expect(error).toBeUndefined();
|
|
13
|
+
expect(problems).toHaveLength(0);
|
|
14
|
+
expect(id).toEqual(`test-server-${process.env.JEST_WORKER_ID || 0}`);
|
|
15
|
+
expect(name).toEqual("actionhero");
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
process.env.AUTOMATIC_ROUTES = "get";
|
|
2
|
+
|
|
3
|
+
import { Process, specHelper, config, api } from "./../../src/index";
|
|
4
|
+
import { Swagger } from "../../src/actions/swagger";
|
|
5
|
+
|
|
6
|
+
describe("Action: swagger", () => {
|
|
7
|
+
const actionhero = new Process();
|
|
8
|
+
let originalRoutes: typeof api.routes.routes;
|
|
9
|
+
|
|
10
|
+
beforeAll(async () => {
|
|
11
|
+
await actionhero.start();
|
|
12
|
+
|
|
13
|
+
originalRoutes = api.routes.routes;
|
|
14
|
+
api.actions.versions.multiParamTestAction = [1];
|
|
15
|
+
api.actions.actions.multiParamTestAction = {
|
|
16
|
+
// @ts-ignore
|
|
17
|
+
1: {
|
|
18
|
+
name: "multiParamTestAction",
|
|
19
|
+
description: "I am a multiple param test action",
|
|
20
|
+
inputs: {
|
|
21
|
+
one: { required: true },
|
|
22
|
+
two: { required: true },
|
|
23
|
+
three: { required: true },
|
|
24
|
+
four: { required: true },
|
|
25
|
+
},
|
|
26
|
+
outputExample: {},
|
|
27
|
+
run: async (data) => {
|
|
28
|
+
if (data.response) data.response.success = true;
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
api.routes.loadRoutes({
|
|
34
|
+
get: [
|
|
35
|
+
{
|
|
36
|
+
path: "/v:apiVersion/one/:one/two/:two/three/:three/four/:four",
|
|
37
|
+
action: "multiParamTestAction",
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
afterAll(async () => {
|
|
44
|
+
await actionhero.stop();
|
|
45
|
+
|
|
46
|
+
api.routes.routes = originalRoutes;
|
|
47
|
+
delete api.actions.versions.multiParamTestAction;
|
|
48
|
+
delete api.actions.actions.multiParamTestAction;
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("automatic routes is enabled", () => {
|
|
52
|
+
config.web && expect(config.web.automaticRoutes).toEqual(["get"]);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test("returns the correct parts", async () => {
|
|
56
|
+
const { paths, basePath, host } =
|
|
57
|
+
await specHelper.runAction<Swagger>("swagger");
|
|
58
|
+
|
|
59
|
+
expect(basePath).toBe("/api/");
|
|
60
|
+
expect(host).toMatch(/localhost/);
|
|
61
|
+
expect(Object.keys(paths).length).toEqual(11); // 10 actions + custom multiParamTestAction path
|
|
62
|
+
|
|
63
|
+
const multiParamPath =
|
|
64
|
+
paths["/one/{one}/two/{two}/three/{three}/four/{four}"];
|
|
65
|
+
expect(multiParamPath).toBeDefined();
|
|
66
|
+
expect(multiParamPath.get.summary).toBe(
|
|
67
|
+
"I am a multiple param test action",
|
|
68
|
+
);
|
|
69
|
+
expect(multiParamPath.get.parameters.map((p) => p.name).sort()).toEqual([
|
|
70
|
+
"four",
|
|
71
|
+
"one",
|
|
72
|
+
"three",
|
|
73
|
+
"two",
|
|
74
|
+
]);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Process, specHelper } from "./../../src/index";
|
|
2
|
+
import { ValidationTest } from "../../src/actions/validationTest";
|
|
3
|
+
|
|
4
|
+
describe("Action: validationTest", () => {
|
|
5
|
+
const actionhero = new Process();
|
|
6
|
+
beforeAll(async () => await actionhero.start());
|
|
7
|
+
afterAll(async () => await actionhero.stop());
|
|
8
|
+
|
|
9
|
+
test("fails with no params", async () => {
|
|
10
|
+
const { error } = await specHelper.runAction<ValidationTest>(
|
|
11
|
+
"validationTest",
|
|
12
|
+
{},
|
|
13
|
+
);
|
|
14
|
+
expect(error).toEqual(
|
|
15
|
+
"Error: string is a required parameter for this action",
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("fails with a number", async () => {
|
|
20
|
+
const { error } = await specHelper.runAction<ValidationTest>(
|
|
21
|
+
"validationTest",
|
|
22
|
+
{
|
|
23
|
+
string: 87,
|
|
24
|
+
},
|
|
25
|
+
);
|
|
26
|
+
expect(error).toEqual(
|
|
27
|
+
'Error: Input for parameter "string" failed validation!',
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
test("fails with generalized validation error message", async () => {
|
|
32
|
+
const { error } = await specHelper.runAction<ValidationTest>(
|
|
33
|
+
"validationTest",
|
|
34
|
+
{
|
|
35
|
+
string: "hello",
|
|
36
|
+
number: "invalid number",
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
expect(error).toEqual("Error: Param number is not a valid number!");
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("fails with generalized formatter error message", async () => {
|
|
43
|
+
const { error } = await specHelper.runAction<ValidationTest>(
|
|
44
|
+
"validationTest",
|
|
45
|
+
{
|
|
46
|
+
string: "hello",
|
|
47
|
+
number: 123,
|
|
48
|
+
},
|
|
49
|
+
);
|
|
50
|
+
expect(error).toEqual("Error: Failed formatting number correctly!");
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test("works with a string", async () => {
|
|
54
|
+
const { string } = await specHelper.runAction<ValidationTest>(
|
|
55
|
+
"validationTest",
|
|
56
|
+
{
|
|
57
|
+
string: "hello",
|
|
58
|
+
ValidationTest,
|
|
59
|
+
},
|
|
60
|
+
);
|
|
61
|
+
expect(string).toEqual("hello");
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import * as ChildProcess from "child_process";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
|
|
4
|
+
async function exec(
|
|
5
|
+
command: string,
|
|
6
|
+
args: Record<string, any>,
|
|
7
|
+
): Promise<{
|
|
8
|
+
error?: NodeJS.ErrnoException;
|
|
9
|
+
stdout?: string;
|
|
10
|
+
}> {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
ChildProcess.exec(command, args, (error, stdout, stderr) => {
|
|
13
|
+
if (error) return reject(error);
|
|
14
|
+
if (stderr) return reject(stderr);
|
|
15
|
+
return resolve({ stdout: stdout.toString() });
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
describe("cli commands", () => {
|
|
21
|
+
const env = {
|
|
22
|
+
...process.env,
|
|
23
|
+
ACTIONHERO_CONFIG_OVERRIDES: JSON.stringify({
|
|
24
|
+
general: {
|
|
25
|
+
paths: {
|
|
26
|
+
cli: [path.join(__dirname, "..", "testCliCommands")],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
test(
|
|
33
|
+
"new commands appear in help",
|
|
34
|
+
async () => {
|
|
35
|
+
const { stdout } = await exec(
|
|
36
|
+
"./node_modules/.bin/ts-node ./src/bin/actionhero.ts help",
|
|
37
|
+
{ env },
|
|
38
|
+
);
|
|
39
|
+
expect(stdout).toContain("hello");
|
|
40
|
+
},
|
|
41
|
+
30 * 1000,
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
test(
|
|
45
|
+
"can run",
|
|
46
|
+
async () => {
|
|
47
|
+
const { stdout } = await exec(
|
|
48
|
+
"./node_modules/.bin/ts-node ./src/bin/actionhero.ts hello",
|
|
49
|
+
{ env },
|
|
50
|
+
);
|
|
51
|
+
expect(stdout).toContain("Hello, Dr. World");
|
|
52
|
+
},
|
|
53
|
+
30 * 1000,
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
test(
|
|
57
|
+
"can format inputs",
|
|
58
|
+
async () => {
|
|
59
|
+
const { stdout } = await exec(
|
|
60
|
+
"./node_modules/.bin/ts-node ./src/bin/actionhero.ts hello -t Mr --name Worldwide ",
|
|
61
|
+
{ env },
|
|
62
|
+
);
|
|
63
|
+
expect(stdout).toContain("Hello, Mr. Worldwide");
|
|
64
|
+
},
|
|
65
|
+
30 * 1000,
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
test(
|
|
69
|
+
"can require a value when optional inputs are specified",
|
|
70
|
+
async () => {
|
|
71
|
+
await expect(
|
|
72
|
+
exec(
|
|
73
|
+
"./node_modules/.bin/ts-node ./src/bin/actionhero.ts hello --name",
|
|
74
|
+
{
|
|
75
|
+
env,
|
|
76
|
+
},
|
|
77
|
+
),
|
|
78
|
+
).rejects.toThrow(/error: option '--name <name>' argument missing/);
|
|
79
|
+
},
|
|
80
|
+
30 * 1000,
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
test(
|
|
84
|
+
"can validate inputs",
|
|
85
|
+
async () => {
|
|
86
|
+
await expect(
|
|
87
|
+
exec(
|
|
88
|
+
"./node_modules/.bin/ts-node ./src/bin/actionhero.ts hello -t Esq. --name Worldwide ",
|
|
89
|
+
{ env },
|
|
90
|
+
),
|
|
91
|
+
).rejects.toThrow(
|
|
92
|
+
/error: option '-t, --title <title>' argument 'Esq.' is invalid. too many periods/,
|
|
93
|
+
);
|
|
94
|
+
},
|
|
95
|
+
30 * 1000,
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
test(
|
|
99
|
+
"can format variadic inputs individually",
|
|
100
|
+
async () => {
|
|
101
|
+
const { stdout } = await exec(
|
|
102
|
+
"./node_modules/.bin/ts-node ./src/bin/actionhero.ts hello --title Mr --name Worldwide --countries France Italy Germany USA",
|
|
103
|
+
{ env },
|
|
104
|
+
);
|
|
105
|
+
expect(stdout).toContain(
|
|
106
|
+
"Hello, Mr. Worldwide (France! Italy! Germany! USA!)",
|
|
107
|
+
);
|
|
108
|
+
},
|
|
109
|
+
30 * 1000,
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
test(
|
|
113
|
+
"can validate variadic inputs individually",
|
|
114
|
+
async () => {
|
|
115
|
+
await expect(
|
|
116
|
+
exec(
|
|
117
|
+
"./node_modules/.bin/ts-node ./src/bin/actionhero.ts hello --title Mr --name Worldwide --countries France italy",
|
|
118
|
+
{ env },
|
|
119
|
+
),
|
|
120
|
+
).rejects.toThrow(
|
|
121
|
+
/error: option '--countries \[countries...\]' argument 'italy' is invalid. country not capitalized/,
|
|
122
|
+
);
|
|
123
|
+
},
|
|
124
|
+
30 * 1000,
|
|
125
|
+
);
|
|
126
|
+
});
|