Skip to content

Commit

Permalink
docs: update README
Browse files Browse the repository at this point in the history
Closes #9

This is rudimentary. I'll get a better method to update README docs (mainly for npm) at a later date.
  • Loading branch information
nartc committed Sep 13, 2023
1 parent 446afc1 commit 568935e
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 49 deletions.
68 changes: 23 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,44 @@
# NgxtensionPlatform
# NG Extension Platform

<p><em>(Read as ng + extension)</em></p>

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)

<!-- ALL-CONTRIBUTORS-BADGE:END -->

<a alt="Nx logo" href="https://nx.dev" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="45"></a>

**This workspace has been generated by [Nx, a Smart, fast and extensible build system.](https://nx.dev)**

## Generate code

If you happen to use Nx plugins, you can leverage code generators that might come with it.

Run `nx list` to get a list of available plugins and whether they have generators. Then run `nx list <plugin-name>` to see what generators are available.
A collection of utilities for [Angular](https://angular.io)

Learn more about [Nx generators on the docs](https://nx.dev/plugin-features/use-code-generators).

## Running tasks

To execute tasks with Nx use the following syntax:
## Installation

```shell
npm install ngxtension
```
nx <target> <project> <...options>
```

You can also run multiple targets:

```shell
yarn add ngxtension
```
nx run-many -t <target1> <target2>
```

..or add `-p` to filter specific projects

```shell
pnpm install ngxtension
```
nx run-many -t <target1> <target2> -p <proj1> <proj2>
```

Targets can be defined in the `package.json` or `projects.json`. Learn more [in the docs](https://nx.dev/core-features/run-tasks).

## Want better Editor Integration?

Have a look at the [Nx Console extensions](https://nx.dev/nx-console). It provides autocomplete support, a UI for exploring and running tasks & generators, and more! Available for VSCode, IntelliJ and comes with a LSP for Vim users.

## Ready to deploy?

Just run `nx build demoapp` to build the application. The build artifacts will be stored in the `dist/` directory, ready to be deployed.

## Set up CI!

Nx comes with local caching already built-in (check your `nx.json`). On CI you might want to go a step further.
## Utilities

- [Set up remote caching](https://nx.dev/core-features/share-your-cache)
- [Set up task distribution across multiple machines](https://nx.dev/core-features/distribute-task-execution)
- [Learn more how to setup CI](https://nx.dev/recipes/ci)
<!-- UTILITIES:START -->

## Connect with us!
| name | link |
| ------------------------ | ------------------------------------------------------------ |
| `resize` | [README](./libs/ngxtension/resize/README.md) |
| `create-injection-token` | [README](./libs/ngxtension/create-injection-token/README.md) |
| `assert-injector` | [README](./libs/ngxtension/assert-injector/README.md) |
| `repeat` | [README](./libs/ngxtension/repeat/README.md) |
| `computed-from` | [README](./libs/ngxtension/computed-from/README.md) |
| `inject-destroy` | [README](./libs/ngxtension/inject-destroy/README.md) |
| `connect` | [README](./libs/ngxtension/connect/README.md) |

- [Join the community](https://nx.dev/community)
- [Subscribe to the Nx Youtube Channel](https://www.youtube.com/@nxdevtools)
- [Follow us on Twitter](https://twitter.com/nxdevtools)
<!-- UTILITIES:END -->

## Contributors ✨

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"@angular/language-service": "~16.2.0",
"@nx/angular": "^16.8.1",
"@nx/cypress": "16.8.1",
"@nx/devkit": "^16.8.1",
"@nx/eslint-plugin": "16.8.1",
"@nx/jest": "16.8.1",
"@nx/js": "16.8.1",
Expand Down
11 changes: 7 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions tools/scripts/generate-ngxtension-readme.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// THIS WILL BE MOVED INTO A LOCAL PLUGIN

import devkit from '@nx/devkit';
import { readFileSync, writeFileSync } from 'node:fs';

const { readCachedProjectGraph, readProjectsConfigurationFromProjectGraph } =
devkit;

const LIB_NAME = 'ngxtension';
const START_MARKER = '<!-- UTILITIES:START -->\n';
const END_MARKER = '\n\n<!-- UTILITIES:END -->\n';
const PATTERN = new RegExp(`${START_MARKER}([\\s\\S]*?)${END_MARKER}`, 'g');

(async () => {
const projectGraph = readCachedProjectGraph();
const projects = readProjectsConfigurationFromProjectGraph(projectGraph);

const projectConfiguration = projects.projects[LIB_NAME];
const entryPoints = getEntryPoints(projectConfiguration);
console.log(entryPoints);

if (!entryPoints.length) return;

let utilitiesMarkdown = `
|name|link|
|---|---|`;

for (const entryPoint of entryPoints) {
utilitiesMarkdown += `
|\`${entryPoint}\`|[README](./libs/${LIB_NAME}/${entryPoint}/README.md)|`;
}

const readmeContent = readFileSync('README.md', { encoding: 'utf8' });
const updatedContent = readmeContent.replace(
PATTERN,
`${START_MARKER}${utilitiesMarkdown}${END_MARKER}`
);

writeFileSync('README.md', updatedContent);
})();

function getEntryPoints(projectConfiguration) {
const lintTarget = projectConfiguration.targets['lint'];
const lintFilePatterns = lintTarget.options.lintFilePatterns;
const entryPoints = new Set();

for (const filePattern of lintFilePatterns.slice(3)) {
const entryPoint = filePattern.split('/')[2];
if (entryPoints.has(entryPoint)) {
continue;
}
entryPoints.add(entryPoint);
}

return Array.from(entryPoints.values());
}

0 comments on commit 568935e

Please sign in to comment.