Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
b946513
Added `test-init` CLI
2chanhaeng Oct 22, 2025
21b310b
Fixed type error
2chanhaeng Oct 23, 2025
12d9df2
Added `--test-mode` to `init` CLI
2chanhaeng Oct 23, 2025
3363102
Fixed some error
2chanhaeng Oct 23, 2025
5a58b8a
Fixed `@fedify/vocab-runtime` deps
2chanhaeng Oct 27, 2025
04220f8
Fixed subcommand to create Next.js app
2chanhaeng Oct 27, 2025
b310bb4
Fixed `runSubCommand` to reject if the command close with code not 0
2chanhaeng Oct 27, 2025
3304370
Fixed `getLinks` using relative path
2chanhaeng Oct 27, 2025
66181e2
Fixed `getDependencies` to process deno and other pms
2chanhaeng Oct 27, 2025
de6d57c
Moved `printMessage`, `printErrorMessage` to `cli/src/utils.ts`
2chanhaeng Oct 27, 2025
4c9ba66
Fixed to enhance kv and mq handling with test mode support and error …
2chanhaeng Oct 27, 2025
e0daf28
Added `packageManagerToRuntime` apply to read templates
2chanhaeng Oct 27, 2025
4152e1f
Improved `runSubCommand` using `CommandError`
2chanhaeng Oct 27, 2025
9d1e6bd
Fixed `getDependencies` using `normalizePackageNames`
2chanhaeng Oct 27, 2025
da34a85
Improved some codes
2chanhaeng Oct 27, 2025
6ae5360
Fixed `joinDepsReg`
2chanhaeng Oct 27, 2025
795f7b6
Fixed `getDevDependencies` using `normalizePackageNames`
2chanhaeng Oct 27, 2025
57123f8
Fixed `mergeJson` using `removeJsonComments` when JSON has comments
2chanhaeng Oct 27, 2025
06ffa04
Removed unused dev-deps
2chanhaeng Nov 3, 2025
80aa652
Replaced `forEach` with `Array.fromAsync`
2chanhaeng Nov 3, 2025
5089e95
Applied `replaceAll` to `removeJsonComments`
2chanhaeng Nov 3, 2025
02b2401
Converted `WebFrameworkInitializer.federationFile` as string
2chanhaeng Nov 3, 2025
b014a0b
Got `tsconfig.json` when it is needed
2chanhaeng Nov 3, 2025
eaedbb2
Cleansed code
2chanhaeng Nov 3, 2025
da7e396
Banned `bun` and `yarn
2chanhaeng Nov 3, 2025
c339662
Replaced with `printMessage`
2chanhaeng Nov 3, 2025
881b62e
Modularized `createTestApp`
2chanhaeng Nov 3, 2025
7d22bc3
Added `port` for `WebFrameworkInitializer`
2chanhaeng Nov 3, 2025
31337e1
Removed registry from package name
2chanhaeng Nov 3, 2025
37f0de8
Added `defaultPort` to `WebFrameworkDescription`
2chanhaeng Nov 3, 2025
f2d6a7b
Added `runServerAndReadUser`
2chanhaeng Nov 3, 2025
3387484
Added `serverClosure`
2chanhaeng Nov 5, 2025
ffdecc2
Fixed `runSubCommand` to run several command join with "&&"
2chanhaeng Nov 5, 2025
ed13efe
FIxed `--test-mode` option
2chanhaeng Nov 5, 2025
a13546a
Replaced `nitro.config.ts` from generated file to template file
2chanhaeng Nov 5, 2025
beb1394
Fixed `saveOutputs` to append
2chanhaeng Nov 5, 2025
71c565e
Rearrange comments
2chanhaeng Nov 5, 2025
df1a7af
Fixed `WebFrameworkDescription.init` params
2chanhaeng Nov 5, 2025
e20289d
Added env for nitro in test mode
2chanhaeng Nov 5, 2025
9a0ddd6
Improved log messages
2chanhaeng Nov 5, 2025
51b87aa
Removed unused imports
2chanhaeng Nov 5, 2025
bb3df26
Renamed `read.ts` to `lookup.ts`
2chanhaeng Nov 5, 2025
5dd4bed
Killed server process immediately
2chanhaeng Nov 6, 2025
913ff98
Fixed `express` initializer
2chanhaeng Nov 6, 2025
0bc84b6
Added `filterOptions`
2chanhaeng Nov 6, 2025
d98e1dd
Added `determinePort`
2chanhaeng Nov 6, 2025
6d065b2
Added `filterWebFrameworks`
2chanhaeng Nov 6, 2025
e4c4d56
Added docs about `fedify test-init`
2chanhaeng Nov 6, 2025
b7198ec
Fixed docs about `init`
2chanhaeng Nov 6, 2025
d8d663a
Added changelog about `fedify test-init`
2chanhaeng Nov 6, 2025
c17c5ec
Fixed docs about `test-init`
2chanhaeng Nov 6, 2025
77555d3
Fixed some errors
2chanhaeng Nov 6, 2025
8e8263e
Fixed `webFrameworks.express.packageManagers`
2chanhaeng Nov 6, 2025
125107f
Added links to docs about Redis, Postgres, RabbitMQ
2chanhaeng Nov 13, 2025
9ec9c52
Improved error messages and patterns to get port
2chanhaeng Nov 13, 2025
409927b
Avoid lookup test on dry mode
2chanhaeng Nov 13, 2025
f98030b
Correct condition check for banned web frameworks
2chanhaeng Nov 13, 2025
1447174
Removed short option for `fedify init`
2chanhaeng Nov 14, 2025
231deb3
Replaced `dryRun`/`hydRun` commands to `noDryRun`/`noHydRun`
2chanhaeng Nov 17, 2025
e59a677
Fixed dry/hyd test order, show test mode and
2chanhaeng Nov 17, 2025
64f6487
Fixed error message
2chanhaeng Nov 17, 2025
52f2ebd
Removed unused code
2chanhaeng Nov 17, 2025
acff2f1
Fixed relative dir calculation error
2chanhaeng Nov 17, 2025
c9fa703
Fixed regex pattern to get port
2chanhaeng Nov 18, 2025
2649c9b
Fixed order to log dir first
2chanhaeng Nov 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ To be released.
`-t`/`--traverse` option, allowing users to traverse multiple collections
in a single command. [[#408], [#449] by Jiwon Kwon]

- Added `fedify test-init` command to test `fedify init` command. This
command create test server with various combinations of options and test
the server using `fedify lookup` command. This command is for
contributors who make integration with various frameworks. [[#461] by
Chanhaeng Lee]

[#374]: https://github.com/fedify-dev/fedify/issues/374
[#397]: https://github.com/fedify-dev/fedify/issues/397
[#408]: https://github.com/fedify-dev/fedify/issues/408
Expand All @@ -134,6 +140,7 @@ To be released.
[#456]: https://github.com/fedify-dev/fedify/issues/456
[#457]: https://github.com/fedify-dev/fedify/pull/457
[#458]: https://github.com/fedify-dev/fedify/pull/458
[#461]: https://github.com/fedify-dev/fedify/issues/461

### @fedify/relay

Expand Down
906 changes: 330 additions & 576 deletions deno.lock

Large diffs are not rendered by default.

82 changes: 78 additions & 4 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,8 @@ fedify init my-fedify-project
The above command will start the interactive prompt to initialize a new Fedify
project. It will ask you a few questions to set up the project:

- JavaScript runtime: [Deno], [Bun], or [Node.js]
- Package manager (if Node.js): [npm], [pnpm], or [Yarn]
- Web framework: Bare-bones, [Fresh] (if Deno), [Hono], [Express] (unless
Deno), or [Nitro] (unless Deno)
- Package manager: [Deno], [Bun], [npm], [pnpm], or [Yarn]
- Web framework: [Hono], [Express], [Nitro], or [Next.js]
- key–value store: In-memory, [Redis], [PostgreSQL], or [Deno KV] (if Deno)
- Message queue: In-memory, [Redis], [PostgreSQL], [AMQP] (e.g., [RabbitMQ]),
or [Deno KV] (if Deno)
Expand All @@ -138,6 +136,7 @@ interactive prompts:
[Hono]: https://hono.dev/
[Express]: https://expressjs.com/
[Nitro]: https://nitro.unjs.io/
[Next.js]: https://nextjs.org/
[Redis]: https://redis.io/
[PostgreSQL]: https://www.postgresql.org/
[AMQP]: https://www.amqp.org/
Expand Down Expand Up @@ -225,6 +224,81 @@ This option works with all other initialization options, allowing you to preview
different configurations before making a decision.


`fedify test-init`: Testing ActivityPub initialization
------------------------------------------------------

*This command is available since Fedify 2.0.0.*

> [!WARNING]
> `bun`, `yarn` runtime and `Next.js` web framework are not supported in this
> command yet.

> [!NOTE]
> You need to install and run [Redis server], [PostgreSQL server], and AMQP
> server (e.g., [RabbitMQ server])locally to test those integrations.


The `fedify test-init` command is used to test the `fedify init` command.
It creates a temporary Fedify project with various combinations of options and
tests the server using `lookup` command. This command is for contributors who
make integration with various frameworks.

~~~~ sh
fedify test-init
~~~~

The above command will start testing the `fedify init` command with various
combinations of options and configurations. It will create temporary
directories for each test case, initialize a Fedify project with the specified
options, start the server, and run the `fedify lookup` command to verify that
the server is functioning correctly.

If you want to test a specific combination of options, you can specify them
with `fedify init` options. For example, the below command tests the `fedify
init` command with Deno runtime and Hono web framework:

~~~~ sh
fedify test-init -r deno -w hono
~~~~

If you do not specify some options, it will test all the available options for
those. So the above command will test all combinations of key–value stores and
message queues with Deno runtime and Hono web framework.

You can also specify several options in a single category. For example, the
below command tests the `fedify init` command with both Redis and PostgreSQL as
key–value stores:

~~~~ sh
fedify test-init -k redis -k postgres
~~~~


[Redis server]: https://redis.io/docs/latest/operate/oss_and_stack/install/archive/install-redis/
[PostgreSQL server]: https://www.postgresql.org/download/
[RabbitMQ server]: https://www.rabbitmq.com/docs/download

### `-h`/`--hyd-run`: Create temporary project and `lookup` an object

If you want to test except `--dry-run` option, you can use the `-h`/`--hyd-run` option. This will create a temporary project and run the `lookup` command on it.

~~~~ sh
fedify test-init -h
~~~~

### `-d`/`--dry-run`: Preview without creating files

If you want to test dry-run only, you can use the `-d`/`--dry-run` option.
This will save outputs and errors to text files instead of creating a
temporary project.

~~~~ sh
fedify test-init -d
~~~~

If you did not specify `-h` or `-d` option, it will run both options by
default.

`fedify lookup`: Looking up an ActivityPub object
-------------------------------------------------

Expand Down
71 changes: 58 additions & 13 deletions packages/cli/src/init/action/configs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
import { join as joinPath } from "node:path";
import {
concat,
filter,
keys,
map,
pick,
pipe,
toArray,
} from "@fxts/core/index.js";
import { uniq } from "es-toolkit";
import { realpathSync } from "node:fs";
import { join as joinPath, relative } from "node:path";
import { merge } from "../../utils.ts";
import biome from "../json/biome.json" with { type: "json" };
import vscodeSettingsForDeno from "../json/vscode-settings-for-deno.json" with {
type: "json",
Expand All @@ -7,6 +19,8 @@ import vscodeSettings from "../json/vscode-settings.json" with {
type: "json",
};
import type { InitCommandData } from "../types.ts";
import { PACKAGES_PATH } from "./const.ts";
import { getDependencies, getDevDependencies, joinDepsReg } from "./deps.ts";

/**
* Loads Deno configuration object with compiler options, unstable features, and tasks.
Expand All @@ -16,20 +30,47 @@ import type { InitCommandData } from "../types.ts";
* @returns Configuration object with path and Deno-specific settings
*/
export const loadDenoConfig = (
{ kv, mq, initializer, dir }: InitCommandData,
data: InitCommandData,
) => ({
path: joinPath(dir, "deno.json"),
path: "deno.json",
data: {
compilerOptions: initializer.compilerOptions,
...pick(["compilerOptions", "tasks"], data.initializer),
unstable: getUnstable(data),
nodeModulesDir: "auto",
imports: joinDepsReg("deno")(getDependencies(data)),
...(data.testMode ? { links: getLinks(data) } : {}),
},
unstable: [
"temporal",
...kv.denoUnstable ?? [],
...mq.denoUnstable ?? [],
],
tasks: initializer.tasks,
});

const getUnstable = <T extends Pick<InitCommandData, "kv" | "mq">>({
kv: { denoUnstable: kv = [] },
mq: { denoUnstable: mq = [] },
}: T) =>
pipe(
["temporal"],
concat(kv),
concat(mq),
toArray,
uniq,
);

const getLinks = <
T extends Pick<InitCommandData, "kv" | "mq" | "initializer" | "dir">,
>({ kv, mq, initializer, dir }: T) =>
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) => joinPath(PACKAGES_PATH, dep)),
map((absolutePath) => realpathSync(absolutePath)),
map((realAbsolutePath) => relative(realpathSync(dir), realAbsolutePath)),
toArray,
);

/**
* Loads TypeScript configuration object for Node.js/Bun projects.
* Uses compiler options from the framework initializer.
Expand All @@ -51,11 +92,15 @@ export const loadTsConfig = ({ initializer, dir }: InitCommandData) => ({
* @param param0 - Destructured initialization data containing initializer and directory
* @returns Configuration object with path and package.json settings
*/
export const loadPackageJson = ({ initializer, dir }: InitCommandData) => ({
path: joinPath(dir, "package.json"),
export const loadPackageJson = (
data: InitCommandData,
) => ({
path: "package.json",
data: {
type: "module",
scripts: initializer.tasks,
scripts: data.initializer.tasks,
dependencies: getDependencies(data),
devDependencies: getDevDependencies(data),
},
});

Expand Down
9 changes: 9 additions & 0 deletions packages/cli/src/init/action/const.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { join as joinPath } from "node:path";

export const PACKAGES_PATH = joinPath(
import.meta.dirname!, // action
"..", // init
"..", // src
"..", // cli
"..", // packages
);
Loading
Loading