From 87b0964beb8a52cbf16f88ccf4d51d49d3246919 Mon Sep 17 00:00:00 2001 From: Craigory Coppola Date: Tue, 23 Apr 2024 16:31:51 -0400 Subject: [PATCH] feat(misc): label react + angular projects --- packages/angular/package.json | 1 + packages/angular/plugin.ts | 1 + packages/angular/plugins/nx-plugin.ts | 23 +++++++++++++++++++++++ packages/react/plugin.ts | 1 + packages/react/plugins/nx-plugin.ts | 23 +++++++++++++++++++++++ 5 files changed, 49 insertions(+) create mode 100644 packages/angular/plugin.ts create mode 100644 packages/angular/plugins/nx-plugin.ts create mode 100644 packages/react/plugin.ts create mode 100644 packages/react/plugins/nx-plugin.ts diff --git a/packages/angular/package.json b/packages/angular/package.json index 474eac86de09c..24f61231c3c0d 100644 --- a/packages/angular/package.json +++ b/packages/angular/package.json @@ -21,6 +21,7 @@ "./executors.json": "./executors.json", "./generators": "./generators.js", "./executors": "./executors.js", + "./plugin": "./plugin.js", "./tailwind": "./tailwind.js", "./module-federation": "./module-federation/index.js", "./src/utils": "./src/utils/index.js", diff --git a/packages/angular/plugin.ts b/packages/angular/plugin.ts new file mode 100644 index 0000000000000..873a15c3188ee --- /dev/null +++ b/packages/angular/plugin.ts @@ -0,0 +1 @@ +export * from './plugins/nx-plugin'; diff --git a/packages/angular/plugins/nx-plugin.ts b/packages/angular/plugins/nx-plugin.ts new file mode 100644 index 0000000000000..4c85b1586f2a0 --- /dev/null +++ b/packages/angular/plugins/nx-plugin.ts @@ -0,0 +1,23 @@ +import { CreateMetadata, ProjectsMetadata } from '@nx/devkit'; + +export const createMetadata: CreateMetadata = (graph) => { + const metadata: ProjectsMetadata = {}; + + function isAngularProject(projectName: string) { + return graph.dependencies[projectName].some((dep) => + dep.target.startsWith('npm:@angular') + ); + } + + for (const projectName in graph.nodes) { + if (isAngularProject(projectName)) { + metadata[projectName] = { + metadata: { + technologies: ['angular'], + }, + }; + } + } + + return metadata; +}; diff --git a/packages/react/plugin.ts b/packages/react/plugin.ts new file mode 100644 index 0000000000000..873a15c3188ee --- /dev/null +++ b/packages/react/plugin.ts @@ -0,0 +1 @@ +export * from './plugins/nx-plugin'; diff --git a/packages/react/plugins/nx-plugin.ts b/packages/react/plugins/nx-plugin.ts new file mode 100644 index 0000000000000..a7366070154a2 --- /dev/null +++ b/packages/react/plugins/nx-plugin.ts @@ -0,0 +1,23 @@ +import { CreateMetadata, ProjectsMetadata } from '@nx/devkit'; + +export const createMetadata: CreateMetadata = (graph) => { + const metadata: ProjectsMetadata = {}; + + function isReactProject(projectName: string) { + return graph.dependencies[projectName].some((dep) => + dep.target.startsWith('npm:react') + ); + } + + for (const projectName in graph.nodes) { + if (isReactProject(projectName)) { + metadata[projectName] = { + metadata: { + technologies: ['react'], + }, + }; + } + } + + return metadata; +};