Skip to content

Commit

Permalink
Merge branch 'master' into feat/angular-use-provide-router-for-standa…
Browse files Browse the repository at this point in the history
…lone-remotes
  • Loading branch information
jnabrdalik authored Aug 3, 2023
2 parents a4b7623 + e9d50af commit 7c03643
Show file tree
Hide file tree
Showing 38 changed files with 2,644 additions and 457 deletions.
23 changes: 22 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE/COMMUNITY_PLUGIN.MD
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ _[Please make sure you have read the submission guidelines before posting an PR]
Thanks for submitting your Nx Plugin to our community plugins list. Make sure to follow these steps to ensure that your PR is approved in a timely manner.
## Plugin Requirements
Before you submit your plugin to be listed in our registry, it needs to meet the following requirements:
- Run some kind of automated e2e tests in your repository
- Include `@nx/devkit` as a `dependency` in the plugin's `package.json`
- List a `repository.url` in the plugin's `package.json`
i.e.
```
{
"repository": {
"type": "git",
"url": "https://github.com/nrwl/nx.git",
"directory": "packages/web"
}
}
```
Note: We reserve the right to remove unmaintained plugins from the registry. If the plugins become maintained again, they can be resubmitted to the registry.
## Steps to Submit Your Plugin
- Use the following commit message template: `chore(core): nx plugin submission [PLUGIN_NAME]`
- Update the `community/approved-plugins.json` file with a new entry for your plugin that includes `name`, `url`, `description`:
Expand All @@ -21,7 +42,7 @@ Example:
}]
```
Once merged, your will plugin will be available when running the `nx list` command, and will also be available in the Plugin browser on [nx.dev](https://nx.dev)
Once merged, your plugin will be available when running the `nx list` command, and will also be available in the Plugin Registry on [nx.dev](https://nx.dev/extending-nx/registry)
-->

# Community Plugin Submission
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/generate-embeddings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Generate embeddings

on:
schedule:
- cron: "0 5 * * 0,4" # sunday, thursday 5AM
workflow_dispatch:
jobs:
cache-and-install:
if: github.repository == 'nrwl/nx'
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18]

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install pnpm
uses: pnpm/action-setup@v2
id: pnpm-install
with:
version: 7
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install --no-frozen-lockfile

- name: Run embeddings script
run: pnpm exec nx run tools-documentation-create-embeddings:run-node
env:
NX_NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NX_NEXT_PUBLIC_SUPABASE_URL }}
NX_SUPABASE_SERVICE_ROLE_KEY: ${{ secrets.NX_SUPABASE_SERVICE_ROLE_KEY }}
NX_OPENAI_KEY: ${{ secrets.NX_OPENAI_KEY }}
47 changes: 16 additions & 31 deletions community/approved-plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,24 @@
"url": "https://github.com/nxkit/nxkit"
},
{
"name": "nx-plugins",
"description": "Nx plugin integrations with ESBuild / Vite / Snowpack / Prisma, with derived ESBuild / Snowpack / ... plugins.",
"name": "nx-plugin-esbuild",
"description": "Nx plugin integrations with ESBuild.",
"url": "https://nx-plugins.netlify.app/"
},
{
"name": "@codebrew/nx-aws-cdk",
"description": "An Nx plugin for aws cdk develop.",
"url": "https://github.com/codebrewlab/nx-plugins/tree/main/packages/nx-aws-cdk"
"name": "nx-plugin-vite",
"description": "Nx plugin integrations with Vite.",
"url": "https://nx-plugins.netlify.app/"
},
{
"name": "nx-plugin-snowpack",
"description": "Nx plugin integrations with Snowpack.",
"url": "https://nx-plugins.netlify.app/"
},
{
"name": "nx-plugin-prisma",
"description": "Nx plugin integrations with Snowpack.",
"url": "https://nx-plugins.netlify.app/"
},
{
"name": "@ago-dev/nx-aws-cdk-v2",
Expand Down Expand Up @@ -74,21 +84,11 @@
"description": "An Nx plugin for developing cross-platform applications using Capacitor",
"url": "https://github.com/nxext/nx-extensions/tree/main/packages/capacitor"
},
{
"name": "@nxtend/firebase",
"description": "An Nx plugin for developing applications using Firebase",
"url": "https://github.com/nxtend-team/nxtend/tree/main/packages/firebase"
},
{
"name": "@angular-architects/ddd",
"description": "Nx plugin for structuring a monorepo with domains and layers",
"url": "https://github.com/angular-architects/nx-ddd-plugin"
},
{
"name": "@offeringsolutions/nx-karma-to-jest",
"description": "Nx plugin for replacing karma with jest in an Nx workspace",
"url": "https://github.com/FabianGosebrink/nx-karma-to-jest"
},
{
"name": "@flowaccount/nx-serverless",
"description": "Nx plugin for node/angular-universal schematics and deployment builders in an Nx workspace",
Expand All @@ -109,21 +109,6 @@
"description": "Nx plugin to run playwright e2e tests in an Nx workspace",
"url": "https://github.com/Bielik20/nx-plugins/tree/master/packages/nx-playwright"
},
{
"name": "@dev-thought/nx-deploy-it",
"description": "Nx plugin to deploy applications on your favorite cloud provider",
"url": "https://github.com/Dev-Thought/nx-plugins/tree/master/libs/nx-deploy-it"
},
{
"name": "@offeringsolutions/nx-protractor-to-cypress",
"description": "Nx plugin to replace protractor with cypress in an nx workspace",
"url": "https://github.com/FabianGosebrink/nx-protractor-to-cypress"
},
{
"name": "@angular-custom-builders/lite-serve",
"description": "Nx plugin to run the e2e test on an existing dist folder",
"url": "https://github.com/mauriziovitale/angular-plugins/tree/master/libs/lite-serve"
},
{
"name": "@nx-plus/nuxt",
"description": "Nx plugin adding first class support for Nuxt in your Nx workspace.",
Expand Down Expand Up @@ -235,7 +220,7 @@
"url": "https://github.com/trafilea/nx-shopify"
},
{
"name": "nx-dotnet",
"name": "@nx-dotnet/core",
"description": "Nx plugin for developing and housing .NET projects within an Nx workspace.",
"url": "https://github.com/nx-dotnet/nx-dotnet"
},
Expand Down
3 changes: 2 additions & 1 deletion docs/generated/packages/react/generators/application.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@
},
"e2eTestRunner": {
"type": "string",
"enum": ["cypress", "none"],
"enum": ["cypress", "playwright", "none"],
"description": "Test runner to use for end to end (E2E) tests.",
"x-prompt": "Which E2E test runner would you like to use?",
"default": "cypress"
},
"tags": {
Expand Down
2 changes: 1 addition & 1 deletion docs/generated/packages/react/generators/init.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"e2eTestRunner": {
"description": "Adds the specified E2E test runner.",
"type": "string",
"enum": ["cypress", "none"],
"enum": ["cypress", "playwright", "none"],
"default": "cypress"
},
"skipFormat": {
Expand Down
7 changes: 3 additions & 4 deletions docs/shared/monorepo-ci-github-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ jobs:
pids+=($!)
# run all commands in parallel and bail if one of them fails
for pid in \${pids[*]}; do
for pid in ${pids[*]}; do
if ! wait $pid; then
exit 1
fi
Expand All @@ -168,8 +168,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
agent:
- [1, 2, 3]
agent: [1, 2, 3]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -193,7 +192,7 @@ jobs:
- name: Start Nx Agent ${{ matrix.agent }}
run: npx nx-cloud start-agent
env:
NX_AGENT_NAME: ${{matrix.agent}}
NX_AGENT_NAME: ${{ matrix.agent }}
```

{% /nx-cloud-section %}
22 changes: 21 additions & 1 deletion docs/shared/plugins/maintain-published-plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,27 @@ After that, you can then install your plugin like any other npm package,

## List your Nx Plugin

Nx provides a utility (`nx list`) that lists both core and community plugins. To submit your plugin, please follow the steps below:
Nx provides a utility (`nx list`) that lists both core and community plugins. You can submit your plugin to be added to this list, but it needs to meet a few criteria first:

- Run some kind of automated e2e tests in your repository
- Include `@nx/devkit` as a `dependency` in the plugin's `package.json`
- List a `repository.url` in the plugin's `package.json`

```jsonc {% fileName="package.json" %}
{
"repository": {
"type": "git",
"url": "https://github.com/nrwl/nx.git",
"directory": "packages/web"
}
}
```

{% callout type="warning" title="Unmaintained Plugins" %}
We reserve the right to remove unmaintained plugins from the registry. If the plugins become maintained again, they can be resubmitted to the registry.
{% /callout %}

Once those criteria are met, you can submit your plugin by following the steps below:

- Fork the [Nx repo](https://github.com/nrwl/nx/fork) (if you haven't already)
- Update the [`community/approved-plugins.json` file](https://github.com/nrwl/nx/blob/master/community/approved-plugins.json) with a new entry for your plugin that includes name, url and description
Expand Down
31 changes: 22 additions & 9 deletions nx-dev/data-access-ai/src/lib/data-access-ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ import {
ChatCompletionRequestMessageRoleEnum,
CreateCompletionResponseUsage,
} from 'openai';
import { getMessageFromResponse, sanitizeLinksInResponse } from './utils';
import {
PageSection,
getListOfSources,
getMessageFromResponse,
sanitizeLinksInResponse,
toMarkdownList,
} from './utils';

const openAiKey = process.env['NX_OPENAI_KEY'];
const supabaseUrl = process.env['NX_NEXT_PUBLIC_SUPABASE_URL'];
Expand All @@ -21,9 +27,12 @@ const config = new Configuration({
});
const openai = new OpenAIApi(config);

export async function nxDevDataAccessAi(
query: string
): Promise<{ textResponse: string; usage?: CreateCompletionResponseUsage }> {
export async function nxDevDataAccessAi(query: string): Promise<{
textResponse: string;
usage?: CreateCompletionResponseUsage;
sources: { heading: string; url: string }[];
sourcesMarkdown: string;
}> {
try {
if (!openAiKey) {
throw new ApplicationError('Missing environment variable NX_OPENAI_KEY');
Expand Down Expand Up @@ -80,11 +89,11 @@ export async function nxDevDataAccessAi(
}: CreateEmbeddingResponse = embeddingResponse.data;

const { error: matchError, data: pageSections } = await supabaseClient.rpc(
'match_page_sections',
'match_page_sections_2',
{
embedding,
match_threshold: 0.78,
match_count: 10,
match_count: 15,
min_content_length: 50,
}
);
Expand All @@ -97,13 +106,13 @@ export async function nxDevDataAccessAi(
let tokenCount = 0;
let contextText = '';

for (let i = 0; i < pageSections.length; i++) {
const pageSection = pageSections[i];
for (let i = 0; i < (pageSections as PageSection[]).length; i++) {
const pageSection: PageSection = pageSections[i];
const content = pageSection.content;
const encoded = tokenizer.encode(content);
tokenCount += encoded.text.length;

if (tokenCount >= 1500) {
if (tokenCount >= 2500) {
break;
}

Expand Down Expand Up @@ -163,9 +172,13 @@ export async function nxDevDataAccessAi(

const responseWithoutBadLinks = await sanitizeLinksInResponse(message);

const sources = getListOfSources(pageSections);

return {
textResponse: responseWithoutBadLinks,
usage: response.data.usage,
sources,
sourcesMarkdown: toMarkdownList(sources),
};
} catch (err: unknown) {
if (err instanceof UserError) {
Expand Down
37 changes: 37 additions & 0 deletions nx-dev/data-access-ai/src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import { CreateChatCompletionResponse } from 'openai';
export interface PageSection {
id: number;
page_id: number;
content: string;
heading: string;
similarity: number;
slug: string;
url_partial: string | null;
}

export function getMessageFromResponse(
response: CreateChatCompletionResponse
Expand All @@ -11,6 +20,34 @@ export function getMessageFromResponse(
return response.choices[0].message?.content ?? '';
}

export function getListOfSources(
pageSections: PageSection[]
): { heading: string; url: string }[] {
const uniqueUrlPartials = new Set<string | null>();
const result = pageSections
.filter((section) => {
if (section.url_partial && !uniqueUrlPartials.has(section.url_partial)) {
uniqueUrlPartials.add(section.url_partial);
return true;
}
return false;
})
.map((section) => ({
heading: section.heading,
url: `https://nx.dev${section.url_partial}`,
}));

return result;
}

export function toMarkdownList(
sections: { heading: string; url: string }[]
): string {
return sections
.map((section) => `- [${section.heading}](${section.url})`)
.join('\n');
}

export async function sanitizeLinksInResponse(
response: string
): Promise<string> {
Expand Down
Loading

0 comments on commit 7c03643

Please sign in to comment.