Skip to content

Commit 6dcf9a7

Browse files
authored
Merge pull request #113 from thefrontside/npx
add bin script to auth0-simulator so it can be started via npx
2 parents 2730793 + 71d4af7 commit 6dcf9a7

File tree

9 files changed

+93
-27
lines changed

9 files changed

+93
-27
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,4 @@ jobs:
1515
run: npm ci
1616

1717
- name: Run linters
18-
uses: wearerequired/lint-action@v1
19-
with:
20-
eslint: true
21-
auto_fix: true
18+
run: npm run lint

package-lock.json

Lines changed: 43 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/auth0/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ This quick start assumes you have your own app with auth0. Check out [`nextjs wi
2828
Let's start our server.
2929

3030
```bash
31-
npm install
32-
cd ./packages/auth0 # when running from the simulacrum repo
33-
PORT=4000 npm run start # this will start a test simulacrum server at http://localhost:4000
31+
PORT=4000 npx auth0-simulator # this will start a test simulacrum server at http://localhost:4000
3432
```
3533

3634
Open a browser at [http://localhost:4000](http://localhost:4000).
@@ -96,8 +94,14 @@ You now have a running auth0 server!
9694

9795
An auth0 simulator can be created using the `@simulacrum/client` package. This is how you would apply the mutations programmatically.
9896

97+
```bash
98+
npm install @simulacrum/client
99+
npm install @simulacrum/auth0-simulator
100+
```
101+
99102
The following examples are written in Typescript, but using Typescript is not a requirement. The Auth0 simulator creates a server with a graphql interface. This means that your interactions with the server can be written in any language or framework that can communicate over http / graphql.
100103

104+
101105
```ts
102106
import { main } from "effection";
103107
import { createSimulationServer, Server } from "@simulacrum/server";

packages/auth0/bin/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#! /usr/bin/env node
2+
require('@simulacrum/auth0-simulator/dist/start');

packages/auth0/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@
88
"test": "NODE_EXTRA_CA_CERTS=\"$(mkcert -CAROOT)/rootCA.pem\" mocha -r ts-node/register --timeout 10000 test/**/*.test.ts",
99
"prepack": "tsc --build tsconfig.dist.json && copy \"./src/views/**/*.png\" ./dist/views/",
1010
"build": "npm run prepack",
11-
"lint": "eslint src test",
11+
"lint": "eslint src bin test",
1212
"start": "node dist/start.js",
1313
"watch": "ts-node -P ./tsconfig.watch.json ./watch.ts"
1414
},
1515
"repository": {
1616
"type": "git",
1717
"url": "git+https://github.com/thefrontside/simulacrum.git"
1818
},
19+
"files": [
20+
"bin/**/*",
21+
"dist/**/*"
22+
],
1923
"keywords": [
2024
"simulation",
2125
"emulation",
@@ -35,6 +39,7 @@
3539
"assert-ts": "^0.3.2",
3640
"base64-url": "^2.3.3",
3741
"cookie-session": "^1.4.0",
42+
"dedent": "^0.7.0",
3843
"effection": "^2.0.0-beta.5",
3944
"html-entities": "^2.3.2",
4045
"jsesc": "^3.0.2",
@@ -45,8 +50,9 @@
4550
"@effection/mocha": "^2.0.0-beta.5",
4651
"@frontside/eslint-config": "^2.0.0",
4752
"@frontside/tsconfig": "^1.2.0",
48-
"@frontside/typescript": "^1.1.1",
53+
"@frontside/typescript": "^2.0.0",
4954
"@simulacrum/client": "0.5.0",
55+
"@types/dedent": "^0.7.0",
5056
"@types/base64-url": "^2.2.0",
5157
"@types/cookie-session": "^2.0.42",
5258
"@types/jsesc": "^2.5.1",

packages/auth0/src/start.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { main } from 'effection';
22
import { createSimulationServer, Server } from '@simulacrum/server';
33
import { auth0 } from '.';
4+
import dedent from 'dedent';
45

56
const port = process.env.PORT ? parseInt(process.env.PORT) : undefined;
67

@@ -14,7 +15,34 @@ main(function*() {
1415

1516
let url = `http://localhost:${server.address.port}`;
1617

17-
console.log(`simulation server running at ${url}`);
18+
console.log(dedent`Started Simulacrum simulation server on ${url}.
19+
GraphiQL interface is running on ${url}/graphql.
20+
21+
To start auth0 simulator send the following mutation to GraphQL server.
22+
23+
mutation CreateSimulation {
24+
createSimulation(simulator: "auth0",
25+
options: {
26+
options:{
27+
audience: "[your audience]",
28+
scope: "[your scope]",
29+
clientId: "[your client-id]"
30+
},
31+
services:{
32+
auth0:{
33+
port: 4400
34+
}
35+
}
36+
}) {
37+
id
38+
status
39+
services {
40+
url
41+
name
42+
}
43+
}
44+
}
45+
`);
1846

1947
yield;
2048
});

packages/client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"devDependencies": {
2020
"@frontside/eslint-config": "^2.0.0",
2121
"@frontside/tsconfig": "^1.2.0",
22-
"@frontside/typescript": "^1.1.1",
22+
"@frontside/typescript": "^2.0.0",
2323
"ts-node": "^9.1.1",
2424
"typescript": "^4.2.3"
2525
},

packages/server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@effection/mocha": "^2.0.0-beta.5",
4949
"@frontside/eslint-config": "^2.0.0",
5050
"@frontside/tsconfig": "^1.2.0",
51-
"@frontside/typescript": "^1.1.1",
51+
"@frontside/typescript": "^2.0.0",
5252
"@simulacrum/client": "0.5.0",
5353
"@types/cors": "^2.8.10",
5454
"@types/express": "^4.17.11",

packages/ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"devDependencies": {
3030
"@frontside/eslint-config": "^2.0.0",
3131
"@frontside/tsconfig": "^1.2.0",
32-
"@frontside/typescript": "^1.1.1",
32+
"@frontside/typescript": "^2.0.0",
3333
"graphiql": "^1.4.0",
3434
"parcel": "next",
3535
"react": "^16.8.0",

0 commit comments

Comments
 (0)