Skip to content

Commit

Permalink
Run Prettier 3 on all remaining files
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenwerk committed Aug 21, 2023
1 parent 5d98e01 commit e1bb63d
Show file tree
Hide file tree
Showing 72 changed files with 590 additions and 545 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pr-boxel-host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ name: CI [boxel-host]
on:
pull_request:
paths:
- "packages/host/**"
- ".github/workflows/pr-boxel-host.yml"
- "package.json"
- "pnpm-lock.yaml"
- 'packages/host/**'
- '.github/workflows/pr-boxel-host.yml'
- 'package.json'
- 'pnpm-lock.yaml'

permissions:
contents: read
Expand Down
30 changes: 23 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@

## Running the Host App

There exists a "dev" mode in which we can use ember-cli to host the card runtime host application which includes live reloads. Additionally, you can also use the realm server to host the app, which is how it will be served in production.
There exists a "dev" mode in which we can use ember-cli to host the card runtime host application which includes live reloads. Additionally, you can also use the realm server to host the app, which is how it will be served in production.

### ember-cli Hosted App

In order to run the ember-cli hosted app:

1. `pnpm start` in the host/ workspace to serve the ember app. Note that this script includes the environment variable `OWN_REALM_URL=http://localhost:4201/draft/` which configures the host to point to the draft realm's cards realm by default.
Expand All @@ -38,11 +39,13 @@ In order to run the ember-cli hosted app:
The app is available at http://localhost:4200. It will serve the draft realm (configurable with OWN_REALM_URL, as mentioned above). You can open the base and draft cards workspace directly by entering http://localhost:4201/base or http://localhost:4201/draft in the browser (and additionally the published realm by entering http://localhost:4201/published).

When you are done running the app you can stop the synapse server by running the following from the `packages/matrix` workspace:

```
pnpm stop:synapse
```

### Realm server Hosted App

In order to run the realm server hosted app:

1. `pnpm start:build` in the host/ workspace to re-build the host app (this step can be omitted if you do not want host app re-builds)
Expand Down Expand Up @@ -79,15 +82,19 @@ In order to support server-side rendered cards, this project incorporates FastBo
The realm server also uses FastBoot to pre-render card html. The realm server boots up the host app in a FastBoot container. The realm server will automatically look for the host app's `dist/` output to use when booting up the infrastructure for pre-rendering cards. Make sure to start to the host app first before starting the realm server so that the host app's `dist/` output will be generated. If you are making changes that effect the `/render` route in the host app, you'll want to restart the host app (or run `pnpm build`) in order for the realm server to pick up your changes.

### Matrix Server
The boxel platform leverages a Matrix server called Synapse in order to support identity, workflow, and chat behaviors. This project uses a dockerized Matrix server. We have multiple matrix server configurations (currently one for development that uses a persistent DB, and one for testing that uses an in-memory DB). You can find and configure these matrix servers at `packages/matrix/docker/synapse/*`.

The boxel platform leverages a Matrix server called Synapse in order to support identity, workflow, and chat behaviors. This project uses a dockerized Matrix server. We have multiple matrix server configurations (currently one for development that uses a persistent DB, and one for testing that uses an in-memory DB). You can find and configure these matrix servers at `packages/matrix/docker/synapse/*`.

This server is automatically started as part of the `pnpm start:all` script, but if you wish to control it separately, from `packages/matrix`, execute:

```
pnpm start:synapse
```
The local Matrix server will be running at `http://localhost:8008`.

The local Matrix server will be running at `http://localhost:8008`.

To stop the matrix server, from `packages/matrix`, execute:

```
pnpm stop:synapse
```
Expand All @@ -97,6 +104,7 @@ pnpm stop:synapse
Matrix administration requires an administrative user and a special client in order to use. Matrix administration is used for creating users, creating rooms, creating registration tokens, managing media, viewing events, etc. Note that you will need to use the matrix administration UI to create tokens to register new matrix users.

First you must create an administrative user:

1. start the matrix server `pnpm start:synapse`
2. run a script to create an administrative user:
```
Expand All @@ -108,6 +116,7 @@ First you must create an administrative user:
```

After you have created an administrative user and have created the docker container you can start the admin console by executing the following in the packages/matrix workspace:

```
pnpm start:admin
```
Expand All @@ -117,6 +126,7 @@ Then visit `http://localhost:8080`, and enter the admin user's username (`admin`
Note you can use this same administrative interface to login to the staging and production matrix server. The credentials are available in AWS secrets manager.

To stop the admin console run the following in the packages/matrix workspace:

```
pnpm stop:admin
```
Expand Down Expand Up @@ -150,7 +160,6 @@ To run the `packages/host/` workspace tests start the following servers:

The tests are available at `http://localhost:4200/tests`


### Realm Server Node tests

First make sure to generate the host app's `dist/` output in order to support card pre-rendering by first starting the host app (instructions above). If you want to make the host app's `dist/` output without starting the host app, you can run `pnpm build` in the host app's workspace.
Expand All @@ -161,6 +170,7 @@ To run the `packages/realm-server/` workspace tests start:
2. Run `pnpm test` in the `packages/realm-server/` workspace to run the realm node tests

### Realm Server DOM tests

This test suite contains acceptance tests for asserting that the Realm server is capable of hosting its own app. To run these tests in the browser execute the following in the `packages/realm-server` workspace:

1. `pnpm start:all`
Expand All @@ -173,30 +183,36 @@ Visit `http://localhost:4205` after the realms have finished starting up
2. `pnpm test` (or `pnpm start` and visit http://localhost:4200/tests to run tests in the browser)

### Matrix tests

This test suite contains tests that exercise matrix functionality. These tests are located at `packages/matrix/tests`, and are executed using the [Playwright](https://playwright.dev/) test runner. To run the tests from the command line, first make sure that the matrix server is not already running. You can stop the matrix server by executing the following from `packages/matrix`

```
pnpm stop:synapse
```

The matrix client relies upon the host app and the realm servers. Start the host app from the `packages/host` folder:

```
pnpm start
```

Then start the realm server (minus the matrix server). From the `packages/realm-server` folder:

```
pnpm start:without-matrix
```

Then to run the tests from the CLI execute the following from `packages/matrix`:

```
pnpm start:test
```
```

Alternatively you can also run these tests from VS Code using the VS Code Playwright plugin (which is very strongly recommended). From the "test tube" icon, you can click on the play button to run a single test or all the tests.
Alternatively you can also run these tests from VS Code using the VS Code Playwright plugin (which is very strongly recommended). From the "test tube" icon, you can click on the play button to run a single test or all the tests.

![Screenshot_20230427_161250](https://user-images.githubusercontent.com/61075/234980198-fe049b61-917d-4dc8-a9eb-ddc54b36b160.png)

or click on the play button in the left margin next to the test itself to run a test:
![Screenshot_20230428_150147](https://user-images.githubusercontent.com/61075/235231663-6fabfc41-8294-4674-adf1-f3793b83e516.png)

you can additionally set a breakpoint in code, and playwright will break at the breakpoint.
you can additionally set a breakpoint in code, and playwright will break at the breakpoint.
6 changes: 5 additions & 1 deletion docs/card-serialization-deserialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ The mechanism employed for this procedure is facilitated by the `serializeCard`
- `contains` Field: Values can be single primitive types or JSON objects. If the field comprises a non-primitive card, it will be represented as a JSON object within the `attributes` field.

Example:

```
{
"data": {
Expand Down Expand Up @@ -106,6 +107,7 @@ Example:
- `containsMany` Field: Values can be arrays of primitive types or JSON arrays. Similar to `contains`, if the field involves a non-primitive card, it becomes a JSON array within the `attributes` field.

Example:

```
{
"data": {
Expand All @@ -121,6 +123,7 @@ Example:
- `linksTo` Field: Unlike `contains`/`containsMany` fields, the field value isn't stored directly. Instead, the JSON file's file path is saved. The file path is extracted from the ID of the field value. The `relativeTo` value is employed to determine whether the URL is relative or absolute.

Example:

```
{
"data": {
Expand All @@ -140,6 +143,7 @@ Example:
- `linksToMany` Field: Similar to `linksTo` fields, the value of this field is displayed as a file path. However, the value is not an array; instead, it's an object where index numbers are included in the property names.

Example:

```
{
"data": {
Expand Down Expand Up @@ -170,4 +174,4 @@ The process is facilitated by the `createFromSerialized` function. This function
- `contains` Field: Values are stored within the data bucket, which functions as a map linking field names to their respective values. The content of 'contains' fields comprises a singular value. This value can be either a primitive value or a card instance, contingent on the card type assigned to that field.
- `containsMany` Field: The values within this field consist of an array, which can encompass either an array of primitive values or an array of card instances.
- `linksTo` Field: The values associated with the `linksTo` field are exclusively card instances. This is because linked fields refer to other card instances. A crucial distinction between card instances in linked fields and those in contained fields lies in their identity – card instance values within linked fields possess identity.
- `linksToMany` Field: This field's value takes the form of an array of card instances.
- `linksToMany` Field: This field's value takes the form of an array of card instances.
12 changes: 6 additions & 6 deletions docs/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ let { data: matching } = await indexer.search({
```

```js
let { data: matching } = await indexer.search({
filter: {
on: { module: `https://my.realm/person`, name: 'Person' },
contains: { firstName : 'Carl' },
},
});
let { data: matching } = await indexer.search({
filter: {
on: { module: `https://my.realm/person`, name: 'Person' },
contains: { firstName: 'Carl' },
},
});
```

### Sort Order
Expand Down
26 changes: 13 additions & 13 deletions packages/ai-bot/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "@cardstack/ai-bot",
"devDependencies": {
"matrix-js-sdk": "^25.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.1.6",
"openai": "4.0.0-beta.4"
},
"scripts": {
"start": "NODE_NO_WARNINGS=1 ts-node --transpileOnly main"
},
"volta": {
"extends": "../../package.json"
}
"name": "@cardstack/ai-bot",
"devDependencies": {
"matrix-js-sdk": "^25.0.0",
"ts-node": "^10.9.1",
"typescript": "^5.1.6",
"openai": "4.0.0-beta.4"
},
"scripts": {
"start": "NODE_NO_WARNINGS=1 ts-node --transpileOnly main"
},
"volta": {
"extends": "../../package.json"
}
}
4 changes: 3 additions & 1 deletion packages/boxel-ui/addon/styles/variables.css
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@

--boxel-highlight: var(--boxel-teal);
--boxel-highlight-hover: var(--boxel-dark-teal);
--boxel-danger: var(--boxel-red); /* formerly boxel-error-100: the latest design docs (8/16/2023) use this color for danger instead */
--boxel-danger: var(
--boxel-red
); /* formerly boxel-error-100: the latest design docs (8/16/2023) use this color for danger instead */
--boxel-danger-hover: #fa1521;

/* Boxel purples */
Expand Down
8 changes: 4 additions & 4 deletions packages/matrix/docker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function dockerRun(args: {
reject(err);
}
resolve(stdout.trim());
}
},
);
});
}
Expand All @@ -56,7 +56,7 @@ export function dockerExec(args: {
return;
}
resolve();
}
},
);
});
}
Expand All @@ -76,7 +76,7 @@ export function dockerCreateNetwork(args: {
if (err) {
if (
stderr.includes(
`network with name ${args.networkName} already exists`
`network with name ${args.networkName} already exists`,
)
) {
// Don't consider this as error
Expand All @@ -86,7 +86,7 @@ export function dockerCreateNetwork(args: {
return;
}
resolve();
}
},
);
});
}
Expand Down
20 changes: 11 additions & 9 deletions packages/matrix/docker/synapse/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function randB64Bytes(numBytes: number): string {

async function cfgDirFromTemplate(
template: string,
dataDir?: string
dataDir?: string,
): Promise<SynapseConfig> {
const templateDir = path.join(__dirname, template);

Expand Down Expand Up @@ -63,7 +63,7 @@ async function cfgDirFromTemplate(
console.log(`Gen ${path.join(templateDir, 'homeserver.yaml')}`);
let hsYaml = await fse.readFile(
path.join(templateDir, 'homeserver.yaml'),
'utf8'
'utf8',
);
hsYaml = hsYaml.replace(/{{REGISTRATION_SECRET}}/g, registrationSecret);
hsYaml = hsYaml.replace(/{{MACAROON_SECRET_KEY}}/g, macaroonSecret);
Expand All @@ -79,7 +79,7 @@ async function cfgDirFromTemplate(
console.log(`Gen ${path.join(templateDir, 'localhost.signing.key')}`);
await fse.writeFile(
path.join(configDir, 'localhost.signing.key'),
`ed25519 x ${signingKey}`
`ed25519 x ${signingKey}`,
);

return {
Expand All @@ -98,11 +98,11 @@ interface StartOptions {
dataDir?: string;
}
export async function synapseStart(
opts?: StartOptions
opts?: StartOptions,
): Promise<SynapseInstance> {
const synCfg = await cfgDirFromTemplate(
opts?.template ?? 'test',
opts?.dataDir
opts?.dataDir,
);
console.log(`Starting synapse with config dir ${synCfg.configDir}...`);
await dockerCreateNetwork({ networkName: 'boxel' });
Expand Down Expand Up @@ -183,7 +183,7 @@ export async function registerUser(
username: string,
password: string,
admin = false,
displayName?: string
displayName?: string,
): Promise<Credentials> {
const url = `http://localhost:${SYNAPSE_PORT}/_synapse/admin/v1/register`;
const context = await request.newContext({ baseURL: url });
Expand Down Expand Up @@ -220,7 +220,7 @@ export async function registerUser(
export async function createRegistrationToken(
adminAccessToken: string,
registrationToken: string,
usesAllowed = 1000
usesAllowed = 1000,
) {
let res = await fetch(
`http://localhost:${SYNAPSE_PORT}/_synapse/admin/v1/registration_tokens/new`,
Expand All @@ -233,11 +233,13 @@ export async function createRegistrationToken(
token: registrationToken,
uses_allowed: usesAllowed,
}),
}
},
);
if (!res.ok) {
throw new Error(
`could not create registration token: ${res.status} - ${await res.text()}`
`could not create registration token: ${
res.status
} - ${await res.text()}`,
);
}
}
Loading

0 comments on commit e1bb63d

Please sign in to comment.