From ec0eca8cabfe99458a742daa92484a41d2527fb9 Mon Sep 17 00:00:00 2001 From: John Martin Date: Sun, 24 Nov 2024 01:39:12 +0000 Subject: [PATCH] docs: update document --- README.md | 2 +- packages/nx-devkit/README.md | 48 +++++++++++++++++++++++++++++---- packages/nx-devkit/package.json | 2 +- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b463475..7beb4cd 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ This project is mainly used internally within ebizbase projects but we have deci ### npm packages | Name | Description| | ---------- | ---------- | -| [nx-devkit][nx-devkit-readme] | The NX plugin to build, push and analyze image | +| [nx-devkit][nx-devkit-readme] | It contains many utility functions for interactive with nx workspace and projects | ### nx plugins | Name | Description| diff --git a/packages/nx-devkit/README.md b/packages/nx-devkit/README.md index 8f00241..53214f2 100644 --- a/packages/nx-devkit/README.md +++ b/packages/nx-devkit/README.md @@ -1,11 +1,49 @@ # nx-devkit -This library was generated with [Nx](https://nx.dev). +It contains many utility functions for interactive with nx workspace and projects -## Building -Run `nx build nx-devkit` to build the library. +## Installation -## Running unit tests +To install the package, run: -Run `nx test nx-devkit` to execute the unit tests via [Jest](https://jestjs.io). +```bash +npm install @ebizbase/nx-devkit +``` + +## Usage + +Here is an example of how to use the `DockerUtils`: + +```typescript +import { DockerUtils } from '@ebizbase/nx-devkit'; + +const dockerService = new DockerUtils(); + +// Check docker installed and docker daemon is running +if (!dockerService.checkDockerInstalled(context.isVerbose)) { + logger.error('Docker is not installed or docker daemon is not running'); + return { success: false }; +} + +// Determine using build or buildx for building Docker image +const isBuildxInstalled = dockerService.checkBuildxInstalled(context.isVerbose); +if (!isBuildxInstalled) { + logger.warn( + 'Buildx is not installed falling back to docker build. Docker buildx is not installed so performance may be degraded' + ); +} +const buildCommand = isBuildxInstalled ? ['docker', 'buildx', 'build'] : ['docker', 'build']; +``` + + +Here is an example of how to use the `DockerUtils`: + +```typescript +import { ProjectUtils } from '@ebizbase/nx-devkit'; +const executor: PromiseExecutor = async (options, context) => { + const projectUtils = new ProjectUtils(context); + const projectRoot: projectUtils.getProjectRoot(); + const projectName: projectUtils.getProjectName(); +}; +``` diff --git a/packages/nx-devkit/package.json b/packages/nx-devkit/package.json index 221314f..be6c11e 100644 --- a/packages/nx-devkit/package.json +++ b/packages/nx-devkit/package.json @@ -2,7 +2,7 @@ "name": "@ebizbase/nx-devkit", "version": "1.0.0", "private": false, - "description": "The nx devkit utils", + "description": "It contains many utility functions for interactive with nx workspace and projects", "bugs": "https://github.com/ebizbase/dev-infras/issues", "repository": { "type": "git",