From ff52749b6df1d76d2aebf43048aec9ec8c48eacf Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 23 Oct 2024 18:15:19 +0200 Subject: [PATCH 1/3] fix: add skipTeardown to env-teardown executor --- .../src/executors/env-teardown/executor.ts | 42 +++++++++++-------- .../src/executors/env-teardown/schema.json | 5 +++ .../src/executors/env-teardown/schema.ts | 7 ++-- 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/projects/nx-verdaccio/src/executors/env-teardown/executor.ts b/projects/nx-verdaccio/src/executors/env-teardown/executor.ts index c7958b22..1307fad0 100644 --- a/projects/nx-verdaccio/src/executors/env-teardown/executor.ts +++ b/projects/nx-verdaccio/src/executors/env-teardown/executor.ts @@ -1,15 +1,17 @@ -import { type ExecutorContext, logger } from '@nx/devkit'; -import type { TeardownExecutorOptions } from './schema'; -import { teardownEnvironment } from './teardown-env'; -import { PACKAGE_NAME } from '../../plugin/constants'; -import { EXECUTOR_ENVIRONMENT_TEARDOWN } from './constants'; -import { type ExecutorOutput } from '../internal/executor-output'; +import {type ExecutorContext, logger} from '@nx/devkit'; +import type {TeardownExecutorOptions} from './schema'; +import {teardownEnvironment} from './teardown-env'; +import {PACKAGE_NAME} from '../../plugin/constants'; +import {EXECUTOR_ENVIRONMENT_TEARDOWN} from './constants'; +import {type ExecutorOutput} from '../internal/executor-output'; +import {getEnvironmentRoot} from "../../internal/environment-root"; export async function teardownExecutor( options: TeardownExecutorOptions, context: ExecutorContext ): Promise { - const { environmentRoot, verbose } = options; + const {verbose, skipTeardown} = options; + const environmentRoot = getEnvironmentRoot(context, options); if (verbose) { logger.info( @@ -20,17 +22,21 @@ export async function teardownExecutor( )}` ); } - try { - await teardownEnvironment(context, { - environmentRoot, - verbose, - }); - } catch (error) { - logger.error(error); - return { - success: false, - command: error?.message ?? (error as Error).toString(), - }; + if (!skipTeardown) { + try { + await teardownEnvironment(context, { + environmentRoot, + verbose, + }); + } catch (error) { + logger.error(error); + return { + success: false, + command: error?.message ?? (error as Error).toString(), + }; + } + } else { + logger.info(`Skip teardown environment in ${environmentRoot}`); } return { diff --git a/projects/nx-verdaccio/src/executors/env-teardown/schema.json b/projects/nx-verdaccio/src/executors/env-teardown/schema.json index 581dd218..02b9a940 100644 --- a/projects/nx-verdaccio/src/executors/env-teardown/schema.json +++ b/projects/nx-verdaccio/src/executors/env-teardown/schema.json @@ -12,6 +12,11 @@ "verbose": { "type": "boolean", "description": "Print additional logs" + }, + "skipTeardown": { + "type": "boolean", + "description": "Skip cleanup folders and files generated by nx-verdaccio", + "default": false } }, "additionalProperties": true, diff --git a/projects/nx-verdaccio/src/executors/env-teardown/schema.ts b/projects/nx-verdaccio/src/executors/env-teardown/schema.ts index c42b3cce..98adb54c 100644 --- a/projects/nx-verdaccio/src/executors/env-teardown/schema.ts +++ b/projects/nx-verdaccio/src/executors/env-teardown/schema.ts @@ -1,7 +1,8 @@ -import { type Environment } from '../env-bootstrap/npm'; +import {type Environment} from '../env-bootstrap/npm'; export type TeardownExecutorOptions = Partial< Environment & { - verbose: boolean; - } + verbose: boolean; + skipTeardown: boolean; +} >; From b97d4d4e7143d60c86702c9d9efa0789594a0472 Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 23 Oct 2024 18:19:42 +0200 Subject: [PATCH 2/3] test: add windows-latest to unit and e2e tests --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b24cd03..c29fe33e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] # @TODO add windows-latest after we have the os agnostic macher + os: [ubuntu-latest, macos-latest, windows-latest] # @TODO add windows-latest after we have the os agnostic macher name: Unit tests runs-on: ${{ matrix.os }} steps: @@ -72,7 +72,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest] # @TODO add windows-latest after we know why it is running forever + os: [ubuntu-latest, macos-latest, windows-latest] # @TODO add windows-latest after we know why it is running forever name: E2E tests runs-on: ${{ matrix.os }} steps: From f257ebb904bbd125dce79211dcd42f0e126937df Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 23 Oct 2024 18:21:53 +0200 Subject: [PATCH 3/3] revert --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c29fe33e..8b24cd03 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,7 +48,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] # @TODO add windows-latest after we have the os agnostic macher + os: [ubuntu-latest, macos-latest] # @TODO add windows-latest after we have the os agnostic macher name: Unit tests runs-on: ${{ matrix.os }} steps: @@ -72,7 +72,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] # @TODO add windows-latest after we know why it is running forever + os: [ubuntu-latest, macos-latest] # @TODO add windows-latest after we know why it is running forever name: E2E tests runs-on: ${{ matrix.os }} steps: