Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/disable identity auto creation #281

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .dev/Dockerfile.debug
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ WORKDIR /usr/app
# Webserver, Debugger
EXPOSE 80 9229

ENTRYPOINT ["npx", "nodemon", "-e", "js,json,yml", "--watch", "./dist", "--watch", "./config", "--inspect=0.0.0.0:9229", "--nolazy", "./dist/index.js"]
ENTRYPOINT ["npx", "nodemon", "-e", "js,json,yml", "--watch", "./dist", "--watch", "./config", "--inspect=0.0.0.0:9229", "--nolazy", "./dist/cli/index.js","strat"]
75 changes: 75 additions & 0 deletions .dev/scripts/updateCliReadme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import { spawnSync } from "child_process";
import { readFile, writeFile } from "fs/promises";
import _ from "lodash";

(async function () {
let readmeFileContent = (await readFile("CLI-README.md")).toString();

const helpTextReturn = spawnSync("node", ["dist/cli/index.js", "--help"]);
const helpText = helpTextReturn.stdout.toString();
let readMeReplace = `
# Usage

\`\`\`
${helpText}
\`\`\`
`;

const commands = getAllCommandNames(helpText);

for (const command of commands) {
readMeReplace = await extendHelpText(readMeReplace, command);
}

const replaceRegex = new RegExp("<!-- generated start -->(.|\\n)*<!-- generated end -->");

readmeFileContent = readmeFileContent.replace(
replaceRegex,
`<!-- generated start -->
${readMeReplace}
<!-- generated end -->`
);

await writeFile("CLI-README.md", readmeFileContent);
})().catch((err) => {
console.error(err);
});

async function extendHelpText(readMeReplace: string, commandName: string, depth: number = 0): Promise<string> {
const subCommandHelpReturn = spawnSync("node", ["dist/cli/index.js", ...commandName.split(" "), "--help"]);
const subCommandHelp = subCommandHelpReturn.stdout.toString();
readMeReplace += `
##${"#".repeat(depth)} ${_.startCase(commandName)}

\`\`\`
${subCommandHelp}
\`\`\`
`;
const childCommands = getAllCommandNames(subCommandHelp);
for (const command of childCommands) {
readMeReplace = await extendHelpText(readMeReplace, command, depth + 1);
}

return readMeReplace;
}

function getAllCommandNames(helpText: string) {
if (!helpText.includes("Commands:")) {
return [];
}

const onlyCommandLines = helpText
.replace(/(.|\n)*Commands:\n/gm, "")
.replace(/Options:\n(.|\n)*/, "")
.trim()
.split("\n")
.map((s) => s.trim());

return onlyCommandLines.map((line) =>
line
.replace(/connector (.*? ).*/, "$1")
.trim()
.replace(/(^\w*?\s+?\w*).*/, "$1")
.trim()
);
}
49 changes: 49 additions & 0 deletions CLI-README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@


<!-- toc -->

- [Installation](#installation)
- [Usage](#usage)
* [Start](#start)

<!-- tocstop -->

# Installation

```
npm i -g @nmshd/connector-admin-cli
```

<!-- generated start -->

# Usage

```
connector <command>

Commands:
connector start start the connector

Options:
--version Show version number [boolean]
-h, --help Show help [boolean]

```

## Start

```
connector start

start the connector

Options:
--version Show version number [boolean]
-h, --help Show help [boolean]
-c, --config Path to the custom configuration file
Can also be set via the CUSTOM_CONFIG_LOCATION env variable
[string]

```

<!-- generated end -->
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ RUN npm ci --omit=dev

COPY --from=builder /usr/app/dist/ dist/

RUN npm link .

LABEL org.opencontainers.image.source="https://github.com/nmshd/connector"

USER node

ENTRYPOINT ["/sbin/tini", "--"]
CMD ["node", "/usr/app/dist/index.js"]
CMD ["nmshd-connector", "start"]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This monorepo consolidates the following packages / applications:
| [The Connector docker images](./) | [see ghcr.io](https://github.com/nmshd/connector/pkgs/container/connector) |
| [The Connector helm charts](./helmChart) | [see ghcr.io](https://github.com/nmshd/connector/pkgs/container/connector-helm-chart) and [![Artifact Hub](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/enmeshed-connector)](https://artifacthub.io/packages/search?repo=enmeshed-connector) |
| [TypeScript Connector SDK](packages/sdk/) | [![npm version](https://badge.fury.io/js/@nmshd%2fconnector-sdk.svg)](https://www.npmjs.com/package/@nmshd/connector-sdk) |
| [Connector admin CLI](packages/admin-cli/) | [![npm version](https://badge.fury.io/js/@nmshd%2fconnector-admin-cli.svg)](https://www.npmjs.com/package/@nmshd/connector-admin-cli) |

## Documentation

Expand Down
17 changes: 11 additions & 6 deletions README_dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ npm run test:local -- testSuiteName
2. change into the directory `cd connector`
3. install the npm dependencies `npm i`
4. build the connector `npm run build`
5. create a config file (for example `local.config.json`)
5. install the connector as cli locally `npm link .`
6. create a config file (for example `local.config.json`)

```
{
"debug": true,
Expand All @@ -128,14 +130,17 @@ npm run test:local -- testSuiteName
"platformClientId": "...",
"platformClientSecret": "..."
},
"database": { "driver": "lokijs", "folder": "./" },
"database": { "driver": "lokijs", "folder": "./", "dbName": "local", "dbNamePrefix": "l" },
"logging": { "categories": { "default": { "appenders": ["console"] } } },
"infrastructure": { "httpServer": { "apiKey": "xxx", port: 8080 } },
"modules": { "coreHttpApi": { "docs": { "enabled": true } } }
"infrastructure": { "httpServer": { "apiKey": "xxx", "port": 8080 } },
"modules": { "coreHttpApi": { "docs": { "enabled": true } } },
"transportLibrary": { "allowIdentityCreation": true }
}

```
6. replace ... in the config with real values
7. start the connector using `CUSTOM_CONFIG_LOCATION=./local.config.json node dist/index.js`

7. replace ... in the config with real values
8. start the connector using `nmshd-connector start --config ./local.config.json`

It's now possible to access the connector on port 8080. Validating this is possible by accessing `http://localhost:8080/docs/swagger` in the browser.

Expand Down
4 changes: 3 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"debug": false,
"transportLibrary": {},
"transportLibrary": {
"allowIdentityCreation": false
},
"database": {
"driver": "mongodb",
"dbName": "default",
Expand Down
3 changes: 2 additions & 1 deletion config/test.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"debug": true,
"transportLibrary": {
"debug": true
"debug": true,
"allowIdentityCreation": true
},
"logging": {
"appenders": {
Expand Down
Loading