@fedify/cli 2.0.0-pr.479.1903 → 2.0.0-pr.479.1919
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/deno.json +1 -1
- package/dist/deno.js +1 -1
- package/dist/init/action/configs.js +2 -1
- package/dist/init/command.js +6 -6
- package/dist/init/test/action.js +4 -2
- package/dist/init/test/fill.js +13 -7
- package/dist/init/test/lookup.js +6 -5
- package/dist/init/test/run.js +5 -6
- package/package.json +5 -5
- package/src/init/action/configs.ts +3 -1
- package/src/init/command.ts +23 -14
- package/src/init/test/action.ts +5 -2
- package/src/init/test/fill.ts +12 -6
- package/src/init/test/lookup.ts +6 -5
- package/src/init/test/run.ts +16 -19
- package/src/init/test/types.ts +8 -15
package/deno.json
CHANGED
package/dist/deno.js
CHANGED
|
@@ -9,6 +9,7 @@ import { PACKAGES_PATH } from "./const.js";
|
|
|
9
9
|
import { getDependencies, getDevDependencies, joinDepsReg } from "./deps.js";
|
|
10
10
|
import { join, relative } from "node:path";
|
|
11
11
|
import { uniq } from "es-toolkit";
|
|
12
|
+
import { realpathSync } from "node:fs";
|
|
12
13
|
import { concat, filter, keys, map, pick, pipe, toArray } from "@fxts/core/index.js";
|
|
13
14
|
|
|
14
15
|
//#region src/init/action/configs.ts
|
|
@@ -30,7 +31,7 @@ const loadDenoConfig = (data) => ({
|
|
|
30
31
|
}
|
|
31
32
|
});
|
|
32
33
|
const getUnstable = ({ kv: { denoUnstable: kv = [] }, mq: { denoUnstable: mq = [] } }) => pipe(["temporal"], concat(kv), concat(mq), toArray, uniq);
|
|
33
|
-
const getLinks = ({ kv, mq, initializer, dir }) => pipe({ "@fedify/fedify": "" }, merge(initializer.dependencies), merge(kv.dependencies), merge(mq.dependencies), keys, filter((dep) => dep.includes("@fedify/")), map((dep) => dep.replace("@fedify/", "")), map((dep) => join(PACKAGES_PATH, dep)), map((absolutePath) => relative(dir,
|
|
34
|
+
const getLinks = ({ kv, mq, initializer, dir }) => pipe({ "@fedify/fedify": "" }, merge(initializer.dependencies), merge(kv.dependencies), merge(mq.dependencies), keys, filter((dep) => dep.includes("@fedify/")), map((dep) => dep.replace("@fedify/", "")), map((dep) => join(PACKAGES_PATH, dep)), map((absolutePath) => realpathSync(absolutePath)), map((realAbsolutePath) => relative(realpathSync(dir), realAbsolutePath)), toArray);
|
|
34
35
|
/**
|
|
35
36
|
* Loads TypeScript configuration object for Node.js/Bun projects.
|
|
36
37
|
* Uses compiler options from the framework initializer.
|
package/dist/init/command.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { debugOption } from "../globals.js";
|
|
5
5
|
import { KV_STORE, MESSAGE_QUEUE, PACKAGE_MANAGER, WEB_FRAMEWORK } from "./const.js";
|
|
6
|
-
import { argument, choice, command, constant, message, multiple, object, option, optionNames, optional } from "@optique/core";
|
|
6
|
+
import { argument, choice, command, constant, merge, message, multiple, object, option, optionNames, optional, or } from "@optique/core";
|
|
7
7
|
import { path } from "@optique/run";
|
|
8
8
|
|
|
9
9
|
//#region src/init/command.ts
|
|
@@ -19,7 +19,7 @@ const initCommand = command("init", object("Initialization options", {
|
|
|
19
19
|
packageManager,
|
|
20
20
|
kvStore,
|
|
21
21
|
messageQueue,
|
|
22
|
-
dryRun: option("
|
|
22
|
+
dryRun: option("--dry-run", { description: message`Perform a trial run with no changes made.` }),
|
|
23
23
|
debugOption,
|
|
24
24
|
testMode
|
|
25
25
|
}), {
|
|
@@ -30,16 +30,16 @@ By default, it initializes the current directory. You can specify a different d
|
|
|
30
30
|
|
|
31
31
|
Unless you specify all options (${optionNames(["-w", "--web-framework"])}, ${optionNames(["-p", "--package-manager"])}, ${optionNames(["-k", "--kv-store"])}, and ${optionNames(["-m", "--message-queue"])}), it will prompt you to select the options interactively.`
|
|
32
32
|
});
|
|
33
|
-
const
|
|
33
|
+
const noHydRun = object({ noHydRun: option("--no-hyd-run", { description: message`Log outputs without creating files.` }) });
|
|
34
|
+
const noDryRun = object({ noDryRun: option("--no-dry-run", { description: message`Test with files creations and installations.` }) });
|
|
35
|
+
const testInitCommand = command("test-init", merge(object("Initialization options", {
|
|
34
36
|
command: constant("test-init"),
|
|
35
37
|
webFramework: multiple(webFramework),
|
|
36
38
|
packageManager: multiple(packageManager),
|
|
37
39
|
kvStore: multiple(kvStore),
|
|
38
40
|
messageQueue: multiple(messageQueue),
|
|
39
|
-
hydRun: option("-h", "--hyd-run", { description: message`Test with files creations and installations.` }),
|
|
40
|
-
dryRun: option("-d", "--dry-run", { description: message`Log outputs without creating files.` }),
|
|
41
41
|
debugOption
|
|
42
|
-
}), {
|
|
42
|
+
}), optional(or(noHydRun, noDryRun))), {
|
|
43
43
|
brief: message`Test an initializing command .`,
|
|
44
44
|
description: message`Test an initializing command on temporary directories.
|
|
45
45
|
|
package/dist/init/test/action.js
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
|
|
4
4
|
import { set } from "../../utils.js";
|
|
5
5
|
import { fillEmptyOptions } from "./fill.js";
|
|
6
|
-
import
|
|
6
|
+
import run_default from "./run.js";
|
|
7
7
|
import { emptyTestDir, genRunId, genTestDirPrefix, logTestDir } from "./utils.js";
|
|
8
8
|
import { pipe, tap, when } from "@fxts/core";
|
|
9
9
|
|
|
10
10
|
//#region src/init/test/action.ts
|
|
11
|
-
const runTestInit = (options) => pipe(options, set("runId", genRunId), set("testDirPrefix", genTestDirPrefix), tap(emptyTestDir), fillEmptyOptions, tap(when(
|
|
11
|
+
const runTestInit = (options) => pipe(options, set("runId", genRunId), set("testDirPrefix", genTestDirPrefix), tap(emptyTestDir), fillEmptyOptions, tap(when(isDryRun, run_default(true))), tap(when(isHydRun, run_default(false))), tap(logTestDir));
|
|
12
|
+
const isDryRun = ({ dryRun }) => dryRun;
|
|
13
|
+
const isHydRun = ({ hydRun }) => hydRun;
|
|
12
14
|
var action_default = runTestInit;
|
|
13
15
|
|
|
14
16
|
//#endregion
|
package/dist/init/test/fill.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
|
|
4
4
|
import { KV_STORE, MESSAGE_QUEUE, PACKAGE_MANAGER, WEB_FRAMEWORK } from "../const.js";
|
|
5
|
-
import { isEmpty, pipe } from "@fxts/core";
|
|
5
|
+
import { isEmpty, omit, pipe } from "@fxts/core";
|
|
6
6
|
|
|
7
7
|
//#region src/init/test/fill.ts
|
|
8
8
|
const fillEmptyOptions = (options) => pipe(options, fillWebFramework, fillPackageManager, fillKVStore, fillMessageQueue, fillRunMode);
|
|
@@ -14,12 +14,18 @@ const fillWebFramework = fillOption("webFramework", WEB_FRAMEWORK);
|
|
|
14
14
|
const fillPackageManager = fillOption("packageManager", PACKAGE_MANAGER);
|
|
15
15
|
const fillKVStore = fillOption("kvStore", KV_STORE);
|
|
16
16
|
const fillMessageQueue = fillOption("messageQueue", MESSAGE_QUEUE);
|
|
17
|
-
const fillRunMode = (options) => ({
|
|
18
|
-
...options,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
const fillRunMode = (options) => pipe(options, (options$1) => "noHydRun" in options$1 ? {
|
|
18
|
+
...omit(["noHydRun"], options$1),
|
|
19
|
+
hydRun: !options$1.noHydRun
|
|
20
|
+
} : {
|
|
21
|
+
...options$1,
|
|
22
|
+
hydRun: true
|
|
23
|
+
}, (options$1) => "noDryRun" in options$1 ? {
|
|
24
|
+
...omit(["noDryRun"], options$1),
|
|
25
|
+
dryRun: !options$1.noDryRun
|
|
26
|
+
} : {
|
|
27
|
+
...options$1,
|
|
28
|
+
dryRun: true
|
|
23
29
|
});
|
|
24
30
|
|
|
25
31
|
//#endregion
|
package/dist/init/test/lookup.js
CHANGED
|
@@ -9,6 +9,7 @@ import { values } from "@optique/core";
|
|
|
9
9
|
import process from "node:process";
|
|
10
10
|
import { spawn } from "node:child_process";
|
|
11
11
|
import { createWriteStream } from "node:fs";
|
|
12
|
+
import { isEmpty } from "@fxts/core/index.js";
|
|
12
13
|
|
|
13
14
|
//#region src/init/test/lookup.ts
|
|
14
15
|
const HANDLE = "john";
|
|
@@ -39,9 +40,9 @@ async function runServerAndLookupUser(dirs) {
|
|
|
39
40
|
function filterWebFrameworks(dirs) {
|
|
40
41
|
const wfs = new Set(dirs.map((dir) => dir.split(sep).slice(-4, -3)[0]));
|
|
41
42
|
const hasBanned = BANNED_WFS.filter((wf) => wfs.has(wf));
|
|
42
|
-
if (
|
|
43
|
+
if (isEmpty(hasBanned)) return dirs;
|
|
43
44
|
const bannedLabels = hasBanned.map((wf) => webframeworks_default[wf]["label"]);
|
|
44
|
-
printErrorMessage`\n${values(bannedLabels)} is not supported in test
|
|
45
|
+
printErrorMessage`\n${values(bannedLabels)} is not supported in lookup test yet.`;
|
|
45
46
|
return dirs.filter((dir) => !BANNED_WFS.includes(dir.split(sep).slice(-4, -3)[0]));
|
|
46
47
|
}
|
|
47
48
|
/**
|
|
@@ -146,9 +147,9 @@ function determinePort(server) {
|
|
|
146
147
|
/listening on.*:(\d+)/i,
|
|
147
148
|
/server.*:(\d+)/i,
|
|
148
149
|
/port\s*:?\s*(\d+)/i,
|
|
149
|
-
/https
|
|
150
|
-
/https
|
|
151
|
-
/https
|
|
150
|
+
/https?:\/\/localhost:(\d+)/i,
|
|
151
|
+
/https?:\/\/0\.0\.0\.0:(\d+)/i,
|
|
152
|
+
/https?:\/\/127\.0\.0\.1:(\d+)/i,
|
|
152
153
|
/https?:\/\/[^:]+:(\d+)/i
|
|
153
154
|
];
|
|
154
155
|
const checkForPort = (data) => {
|
package/dist/init/test/run.js
CHANGED
|
@@ -9,11 +9,10 @@ import { optionNames } from "@optique/core";
|
|
|
9
9
|
import { always, filter, map as map$1, pipe, tap, unless } from "@fxts/core";
|
|
10
10
|
|
|
11
11
|
//#region src/init/test/run.ts
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
Init Test start!
|
|
12
|
+
const runTests = (dry) => ({ testDirPrefix, dryRun, hydRun,...options }) => pipe(options, printStartMessage(dry), generateTestCases, filter(filterOptions), map$1(create_default(join(testDirPrefix, getMid(dryRun, hydRun, dry)), dry)), Array.fromAsync, unless(always(dry), runServerAndLookupUser));
|
|
13
|
+
var run_default = runTests;
|
|
14
|
+
const printStartMessage = (dry) => tap(() => printMessage`\n
|
|
15
|
+
Init ${dry ? "Dry" : "Hyd"} Test start!
|
|
17
16
|
Options: ${optionNames([
|
|
18
17
|
"Web Framework",
|
|
19
18
|
"Package Manager",
|
|
@@ -23,4 +22,4 @@ Options: ${optionNames([
|
|
|
23
22
|
const getMid = (dryRun, hydRun, dry) => dryRun === hydRun ? dry ? "dry" : "hyd" : "";
|
|
24
23
|
|
|
25
24
|
//#endregion
|
|
26
|
-
export {
|
|
25
|
+
export { run_default as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fedify/cli",
|
|
3
|
-
"version": "2.0.0-pr.479.
|
|
3
|
+
"version": "2.0.0-pr.479.1919+bc910fb5",
|
|
4
4
|
"description": "CLI toolchain for Fedify and debugging ActivityPub",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fedify",
|
|
@@ -71,10 +71,10 @@
|
|
|
71
71
|
"ora": "^8.2.0",
|
|
72
72
|
"shiki": "^1.6.4",
|
|
73
73
|
"srvx": "^0.8.7",
|
|
74
|
-
"@fedify/fedify": "2.0.0-pr.479.
|
|
75
|
-
"@fedify/vocab-
|
|
76
|
-
"@fedify/
|
|
77
|
-
"@fedify/
|
|
74
|
+
"@fedify/fedify": "2.0.0-pr.479.1919+bc910fb5",
|
|
75
|
+
"@fedify/vocab-tools": "2.0.0-pr.479.1919+bc910fb5",
|
|
76
|
+
"@fedify/vocab-runtime": "2.0.0-pr.479.1919+bc910fb5",
|
|
77
|
+
"@fedify/sqlite": "2.0.0-pr.479.1919+bc910fb5"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@types/bun": "^1.2.23",
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
toArray,
|
|
9
9
|
} from "@fxts/core/index.js";
|
|
10
10
|
import { uniq } from "es-toolkit";
|
|
11
|
+
import { realpathSync } from "node:fs";
|
|
11
12
|
import { join as joinPath, relative } from "node:path";
|
|
12
13
|
import { merge } from "../../utils.ts";
|
|
13
14
|
import biome from "../json/biome.json" with { type: "json" };
|
|
@@ -65,7 +66,8 @@ const getLinks = <
|
|
|
65
66
|
filter((dep) => dep.includes("@fedify/")),
|
|
66
67
|
map((dep) => dep.replace("@fedify/", "")),
|
|
67
68
|
map((dep) => joinPath(PACKAGES_PATH, dep)),
|
|
68
|
-
map((absolutePath) =>
|
|
69
|
+
map((absolutePath) => realpathSync(absolutePath)),
|
|
70
|
+
map((realAbsolutePath) => relative(realpathSync(dir), realAbsolutePath)),
|
|
69
71
|
toArray,
|
|
70
72
|
);
|
|
71
73
|
|
package/src/init/command.ts
CHANGED
|
@@ -4,12 +4,14 @@ import {
|
|
|
4
4
|
command,
|
|
5
5
|
constant,
|
|
6
6
|
type InferValue,
|
|
7
|
+
merge,
|
|
7
8
|
message,
|
|
8
9
|
multiple,
|
|
9
10
|
object,
|
|
10
11
|
option,
|
|
11
12
|
optional,
|
|
12
13
|
optionNames,
|
|
14
|
+
or,
|
|
13
15
|
} from "@optique/core";
|
|
14
16
|
import { path } from "@optique/run";
|
|
15
17
|
import { debugOption } from "../globals.ts";
|
|
@@ -73,7 +75,7 @@ export const initCommand = command(
|
|
|
73
75
|
packageManager,
|
|
74
76
|
kvStore,
|
|
75
77
|
messageQueue,
|
|
76
|
-
dryRun: option("
|
|
78
|
+
dryRun: option("--dry-run", {
|
|
77
79
|
description: message`Perform a trial run with no changes made.`,
|
|
78
80
|
}),
|
|
79
81
|
debugOption,
|
|
@@ -95,22 +97,29 @@ Unless you specify all options (${optionNames(["-w", "--web-framework"])}, ${
|
|
|
95
97
|
|
|
96
98
|
export type InitCommand = InferValue<typeof initCommand>;
|
|
97
99
|
|
|
100
|
+
const noHydRun = object({
|
|
101
|
+
noHydRun: option("--no-hyd-run", {
|
|
102
|
+
description: message`Log outputs without creating files.`,
|
|
103
|
+
}),
|
|
104
|
+
});
|
|
105
|
+
const noDryRun = object({
|
|
106
|
+
noDryRun: option("--no-dry-run", {
|
|
107
|
+
description: message`Test with files creations and installations.`,
|
|
108
|
+
}),
|
|
109
|
+
});
|
|
98
110
|
export const testInitCommand = command(
|
|
99
111
|
"test-init",
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
112
|
+
merge(
|
|
113
|
+
object("Initialization options", {
|
|
114
|
+
command: constant("test-init"),
|
|
115
|
+
webFramework: multiple(webFramework),
|
|
116
|
+
packageManager: multiple(packageManager),
|
|
117
|
+
kvStore: multiple(kvStore),
|
|
118
|
+
messageQueue: multiple(messageQueue),
|
|
119
|
+
debugOption,
|
|
108
120
|
}),
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}),
|
|
112
|
-
debugOption,
|
|
113
|
-
}),
|
|
121
|
+
optional(or(noHydRun, noDryRun)),
|
|
122
|
+
),
|
|
114
123
|
{
|
|
115
124
|
brief: message`Test an initializing command .`,
|
|
116
125
|
description: message`Test an initializing command on temporary directories.
|
package/src/init/test/action.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { pipe, tap, when } from "@fxts/core";
|
|
|
2
2
|
import { set } from "../../utils.ts";
|
|
3
3
|
import type { TestInitCommand } from "../command.ts";
|
|
4
4
|
import { fillEmptyOptions } from "./fill.ts";
|
|
5
|
-
import
|
|
5
|
+
import runTests from "./run.ts";
|
|
6
6
|
import {
|
|
7
7
|
emptyTestDir,
|
|
8
8
|
genRunId,
|
|
@@ -17,9 +17,12 @@ const runTestInit = (options: TestInitCommand) =>
|
|
|
17
17
|
set("testDirPrefix", genTestDirPrefix),
|
|
18
18
|
tap(emptyTestDir),
|
|
19
19
|
fillEmptyOptions,
|
|
20
|
-
tap(when(isHydRun, runTests(false))),
|
|
21
20
|
tap(when(isDryRun, runTests(true))),
|
|
21
|
+
tap(when(isHydRun, runTests(false))),
|
|
22
22
|
tap(logTestDir),
|
|
23
23
|
);
|
|
24
24
|
|
|
25
|
+
const isDryRun = <T extends { dryRun: boolean }>({ dryRun }: T) => dryRun;
|
|
26
|
+
const isHydRun = <T extends { hydRun: boolean }>({ hydRun }: T) => hydRun;
|
|
27
|
+
|
|
25
28
|
export default runTestInit;
|
package/src/init/test/fill.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isEmpty, pipe } from "@fxts/core";
|
|
1
|
+
import { isEmpty, omit, pipe } from "@fxts/core";
|
|
2
2
|
import type { TestInitCommand } from "../command.ts";
|
|
3
3
|
import {
|
|
4
4
|
KV_STORE,
|
|
@@ -54,8 +54,14 @@ const fillKVStore = fillOption("kvStore", KV_STORE);
|
|
|
54
54
|
const fillMessageQueue = fillOption("messageQueue", MESSAGE_QUEUE);
|
|
55
55
|
|
|
56
56
|
const fillRunMode = <T extends TestInitCommand>(
|
|
57
|
-
options:
|
|
58
|
-
): DefineAllOptions<T> =>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
options: T,
|
|
58
|
+
): DefineAllOptions<T> =>
|
|
59
|
+
pipe(
|
|
60
|
+
options,
|
|
61
|
+
(options) => ("noHydRun" in options
|
|
62
|
+
? ({ ...omit(["noHydRun"], options), hydRun: !options.noHydRun })
|
|
63
|
+
: ({ ...options, hydRun: true })),
|
|
64
|
+
(options) => ("noDryRun" in options
|
|
65
|
+
? ({ ...omit(["noDryRun"], options), dryRun: !options.noDryRun })
|
|
66
|
+
: ({ ...options, dryRun: true })),
|
|
67
|
+
) as DefineAllOptions<T>;
|
package/src/init/test/lookup.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isEmpty } from "@fxts/core/index.js";
|
|
1
2
|
import { values } from "@optique/core";
|
|
2
3
|
import type { ChildProcessByStdio } from "node:child_process";
|
|
3
4
|
import { spawn } from "node:child_process";
|
|
@@ -55,13 +56,13 @@ function filterWebFrameworks(
|
|
|
55
56
|
dirs.map((dir) => dir.split(sep).slice(-4, -3)[0] as WebFramework),
|
|
56
57
|
);
|
|
57
58
|
const hasBanned = BANNED_WFS.filter((wf) => wfs.has(wf));
|
|
58
|
-
if (
|
|
59
|
+
if (isEmpty(hasBanned)) {
|
|
59
60
|
return dirs;
|
|
60
61
|
}
|
|
61
62
|
const bannedLabels = hasBanned.map((wf) => webFrameworks[wf]["label"]);
|
|
62
63
|
printErrorMessage`\n${
|
|
63
64
|
values(bannedLabels)
|
|
64
|
-
} is not supported in test
|
|
65
|
+
} is not supported in lookup test yet.`;
|
|
65
66
|
return dirs.filter((dir) =>
|
|
66
67
|
!BANNED_WFS.includes(dir.split(sep).slice(-4, -3)[0] as WebFramework)
|
|
67
68
|
);
|
|
@@ -204,9 +205,9 @@ function determinePort(
|
|
|
204
205
|
/listening on.*:(\d+)/i,
|
|
205
206
|
/server.*:(\d+)/i,
|
|
206
207
|
/port\s*:?\s*(\d+)/i,
|
|
207
|
-
/https
|
|
208
|
-
/https
|
|
209
|
-
/https
|
|
208
|
+
/https?:\/\/localhost:(\d+)/i,
|
|
209
|
+
/https?:\/\/0\.0\.0\.0:(\d+)/i,
|
|
210
|
+
/https?:\/\/127\.0\.0\.1:(\d+)/i,
|
|
210
211
|
/https?:\/\/[^:]+:(\d+)/i,
|
|
211
212
|
];
|
|
212
213
|
|
package/src/init/test/run.ts
CHANGED
|
@@ -6,37 +6,34 @@ import createTestApp, { filterOptions, generateTestCases } from "./create.ts";
|
|
|
6
6
|
import runServerAndLookupUser from "./lookup.ts";
|
|
7
7
|
import type { InitTestData } from "./types.ts";
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
dryRun;
|
|
11
|
-
export const isHydRun = <T extends { hydRun: boolean }>({ hydRun }: T) =>
|
|
12
|
-
hydRun;
|
|
13
|
-
|
|
14
|
-
export const runTests =
|
|
9
|
+
const runTests =
|
|
15
10
|
(dry: boolean) =>
|
|
16
11
|
<T extends InitTestData>({ testDirPrefix, dryRun, hydRun, ...options }: T) =>
|
|
17
12
|
pipe(
|
|
18
13
|
options,
|
|
19
|
-
printStartMessage,
|
|
14
|
+
printStartMessage(dry),
|
|
20
15
|
generateTestCases,
|
|
21
16
|
filter(filterOptions),
|
|
22
17
|
map(createTestApp(join(testDirPrefix, getMid(dryRun, hydRun, dry)), dry)),
|
|
23
18
|
Array.fromAsync<string>,
|
|
24
19
|
unless(always(dry), runServerAndLookupUser),
|
|
25
20
|
);
|
|
21
|
+
export default runTests;
|
|
26
22
|
|
|
27
|
-
const printStartMessage: <T>(t: T) => T =
|
|
28
|
-
(
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
const printStartMessage: (dry: boolean) => <T>(t: T) => T = (dry: boolean) =>
|
|
24
|
+
tap(
|
|
25
|
+
() =>
|
|
26
|
+
printMessage`\n
|
|
27
|
+
Init ${dry ? "Dry" : "Hyd"} Test start!
|
|
31
28
|
Options: ${
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
);
|
|
29
|
+
optionNames([
|
|
30
|
+
"Web Framework",
|
|
31
|
+
"Package Manager",
|
|
32
|
+
"KV Store",
|
|
33
|
+
"Message Queue",
|
|
34
|
+
])
|
|
35
|
+
}`,
|
|
36
|
+
);
|
|
40
37
|
|
|
41
38
|
const getMid = (dryRun: boolean, hydRun: boolean, dry: boolean) =>
|
|
42
39
|
dryRun === hydRun ? dry ? "dry" : "hyd" : "";
|
package/src/init/test/types.ts
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import type { TestInitCommand } from "../command.ts";
|
|
2
2
|
|
|
3
|
-
export interface InitTestData extends
|
|
3
|
+
export interface InitTestData extends DefineAllOptions<TestInitCommand> {
|
|
4
4
|
runId: string;
|
|
5
5
|
testDirPrefix: string;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export interface AllDefinedTestInitCommand extends TestInitCommand {
|
|
9
|
-
webFramework: (TestInitCommand["webFramework"][number] & string)[];
|
|
10
|
-
packageManager: (TestInitCommand["packageManager"][number] & string)[];
|
|
11
|
-
kvStore: (TestInitCommand["kvStore"][number] & string)[];
|
|
12
|
-
messageQueue: (TestInitCommand["messageQueue"][number] & string)[];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
8
|
export type MultipleOption =
|
|
16
9
|
| "webFramework"
|
|
17
10
|
| "packageManager"
|
|
@@ -21,14 +14,14 @@ export type MultipleOption =
|
|
|
21
14
|
export type DefineOption<T extends TestInitCommand, K extends MultipleOption> =
|
|
22
15
|
& Omit<T, K>
|
|
23
16
|
& {
|
|
24
|
-
[Key in MultipleOption]: Key extends K ?
|
|
17
|
+
[Key in MultipleOption]: Key extends K ? TestInitCommand[Key] & string[]
|
|
25
18
|
: T[Key];
|
|
26
19
|
};
|
|
27
20
|
|
|
21
|
+
type NoRunMode = "noHydRun" | "noDryRun";
|
|
22
|
+
type RunMode = "hydRun" | "dryRun";
|
|
23
|
+
|
|
28
24
|
export type DefineAllOptions<T extends TestInitCommand> =
|
|
29
|
-
& Omit<T, MultipleOption>
|
|
30
|
-
& {
|
|
31
|
-
|
|
32
|
-
? AllDefinedTestInitCommand[K]
|
|
33
|
-
: never;
|
|
34
|
-
};
|
|
25
|
+
& Omit<T, MultipleOption | NoRunMode>
|
|
26
|
+
& { [K in MultipleOption]: (TestInitCommand[K][number] & string)[] }
|
|
27
|
+
& { [R in RunMode]: boolean };
|