From df86ee2f48dadf05cbc5b7221ae0d3a0195caf5e Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 16 Sep 2024 00:19:05 +0200 Subject: [PATCH] isolate original setup code --- .../cli-e2e-original/setup/global-setup.ts | 22 +++++------ .../tooling/original.plugin.ts | 2 +- .../tooling}/utils/build-target-helper.ts | 0 .../tooling}/utils/logging.ts | 0 .../cli-e2e-original/tooling}/utils/npm.ts | 0 .../cli-e2e-original/tooling}/utils/utils.ts | 0 .../tooling/utils}/verdaccio-npm-env.ts | 0 .../tooling/utils}/verdaccio-registry.ts | 0 tooling/tools-utils/.eslintrc.json | 30 --------------- tooling/tools-utils/README.md | 3 -- tooling/tools-utils/package.json | 10 ----- tooling/tools-utils/project.json | 37 ------------------- tooling/tools-utils/src/index.ts | 24 ------------ tooling/tools-utils/tsconfig.json | 22 ----------- tooling/tools-utils/tsconfig.lib.json | 10 ----- tooling/tools-utils/tsconfig.spec.json | 27 -------------- tooling/tools-utils/vite.config.ts | 32 ---------------- tsconfig.base.json | 1 - 18 files changed, 12 insertions(+), 208 deletions(-) rename {tooling/tools-utils/src/lib => e2e-examples/cli-e2e-original/tooling}/utils/build-target-helper.ts (100%) rename {tooling/tools-utils/src/lib => e2e-examples/cli-e2e-original/tooling}/utils/logging.ts (100%) rename {tooling/tools-utils/src/lib => e2e-examples/cli-e2e-original/tooling}/utils/npm.ts (100%) rename {tooling/tools-utils/src/lib => e2e-examples/cli-e2e-original/tooling}/utils/utils.ts (100%) rename {tooling/tools-utils/src/lib/verdaccio => e2e-examples/cli-e2e-original/tooling/utils}/verdaccio-npm-env.ts (100%) rename {tooling/tools-utils/src/lib/verdaccio => e2e-examples/cli-e2e-original/tooling/utils}/verdaccio-registry.ts (100%) delete mode 100644 tooling/tools-utils/.eslintrc.json delete mode 100644 tooling/tools-utils/README.md delete mode 100644 tooling/tools-utils/package.json delete mode 100644 tooling/tools-utils/project.json delete mode 100644 tooling/tools-utils/src/index.ts delete mode 100644 tooling/tools-utils/tsconfig.json delete mode 100644 tooling/tools-utils/tsconfig.lib.json delete mode 100644 tooling/tools-utils/tsconfig.spec.json delete mode 100644 tooling/tools-utils/vite.config.ts diff --git a/e2e-examples/cli-e2e-original/setup/global-setup.ts b/e2e-examples/cli-e2e-original/setup/global-setup.ts index 34d10fcb..8d604f62 100644 --- a/e2e-examples/cli-e2e-original/setup/global-setup.ts +++ b/e2e-examples/cli-e2e-original/setup/global-setup.ts @@ -1,15 +1,17 @@ import { rm } from 'node:fs/promises'; import { executeProcess, objectToCliArgs } from '@org/test-utils'; import { - configureRegistry, RegistryResult, startVerdaccioServer, +} from '../tooling/utils/verdaccio-registry'; +import { + configureRegistry, unconfigureRegistry, -} from '@org/tools-utils'; +} from '../tooling/utils/verdaccio-npm-env'; const isVerbose = process.env['NX_VERBOSE_LOGGING'] === 'true' ?? false; const projectName = process.env['NX_TASK_TARGET_PROJECT']; -let stopFn: () => void +let stopFn: () => void; export async function setup() { if (projectName == null) { @@ -32,9 +34,9 @@ export async function setup() { targets: 'original-npm-publish', exclude: 'tag:type:testing', skipNxCache: true, - verbose: isVerbose + verbose: isVerbose, }), - verbose: isVerbose + verbose: isVerbose, }); // package install all projects @@ -46,20 +48,18 @@ export async function setup() { exclude: 'tag:type:testing', skipNxCache: true, parallel: 1, - verbose: isVerbose + verbose: isVerbose, }), - verbose: isVerbose + verbose: isVerbose, }); // @TODO figure out why named exports don't work https://vitest.dev/config/#globalsetup - stopFn = () => teardownSetup(registryResult) + stopFn = () => teardownSetup(registryResult); return () => stopFn(); } - - export async function teardown() { - stopFn() + stopFn(); } export async function teardownSetup({ registry, stop }: RegistryResult) { console.info(`Teardown ${projectName}`); diff --git a/e2e-examples/cli-e2e-original/tooling/original.plugin.ts b/e2e-examples/cli-e2e-original/tooling/original.plugin.ts index ce3ce3d6..b587da56 100644 --- a/e2e-examples/cli-e2e-original/tooling/original.plugin.ts +++ b/e2e-examples/cli-e2e-original/tooling/original.plugin.ts @@ -5,7 +5,7 @@ import { } from '@nx/devkit'; import { dirname, join } from 'node:path'; import type { ProjectConfiguration } from 'nx/src/config/workspace-json-project-json'; -import { getBuildOutputPathFromBuildTarget } from '@org/tools-utils'; +import { getBuildOutputPathFromBuildTarget } from './utils/build-target-helper'; export const createNodes: CreateNodes = [ '**/project.json', diff --git a/tooling/tools-utils/src/lib/utils/build-target-helper.ts b/e2e-examples/cli-e2e-original/tooling/utils/build-target-helper.ts similarity index 100% rename from tooling/tools-utils/src/lib/utils/build-target-helper.ts rename to e2e-examples/cli-e2e-original/tooling/utils/build-target-helper.ts diff --git a/tooling/tools-utils/src/lib/utils/logging.ts b/e2e-examples/cli-e2e-original/tooling/utils/logging.ts similarity index 100% rename from tooling/tools-utils/src/lib/utils/logging.ts rename to e2e-examples/cli-e2e-original/tooling/utils/logging.ts diff --git a/tooling/tools-utils/src/lib/utils/npm.ts b/e2e-examples/cli-e2e-original/tooling/utils/npm.ts similarity index 100% rename from tooling/tools-utils/src/lib/utils/npm.ts rename to e2e-examples/cli-e2e-original/tooling/utils/npm.ts diff --git a/tooling/tools-utils/src/lib/utils/utils.ts b/e2e-examples/cli-e2e-original/tooling/utils/utils.ts similarity index 100% rename from tooling/tools-utils/src/lib/utils/utils.ts rename to e2e-examples/cli-e2e-original/tooling/utils/utils.ts diff --git a/tooling/tools-utils/src/lib/verdaccio/verdaccio-npm-env.ts b/e2e-examples/cli-e2e-original/tooling/utils/verdaccio-npm-env.ts similarity index 100% rename from tooling/tools-utils/src/lib/verdaccio/verdaccio-npm-env.ts rename to e2e-examples/cli-e2e-original/tooling/utils/verdaccio-npm-env.ts diff --git a/tooling/tools-utils/src/lib/verdaccio/verdaccio-registry.ts b/e2e-examples/cli-e2e-original/tooling/utils/verdaccio-registry.ts similarity index 100% rename from tooling/tools-utils/src/lib/verdaccio/verdaccio-registry.ts rename to e2e-examples/cli-e2e-original/tooling/utils/verdaccio-registry.ts diff --git a/tooling/tools-utils/.eslintrc.json b/tooling/tools-utils/.eslintrc.json deleted file mode 100644 index 9f709c87..00000000 --- a/tooling/tools-utils/.eslintrc.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "extends": ["../../.eslintrc.json", "../../.eslintrc.base.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.ts", "*.tsx"], - "rules": {} - }, - { - "files": ["*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["*.json"], - "parser": "jsonc-eslint-parser", - "rules": { - "@nx/dependency-checks": [ - "error", - { - "ignoredFiles": ["{projectRoot}/vite.config.{js,ts,mjs,mts}"] - } - ] - } - } - ] -} diff --git a/tooling/tools-utils/README.md b/tooling/tools-utils/README.md deleted file mode 100644 index 0848502f..00000000 --- a/tooling/tools-utils/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# tools-utils - -This package contains utility functions that are used across multiple packages depending on tools. diff --git a/tooling/tools-utils/package.json b/tooling/tools-utils/package.json deleted file mode 100644 index a38cb110..00000000 --- a/tooling/tools-utils/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "@org/tools-utils", - "version": "0.0.1", - "dependencies": { - "ansis": "^3.3.2", - "@nx/devkit": "18.2.4", - "nx": "18.2.4", - "yargs": "^17.7.2" - } -} diff --git a/tooling/tools-utils/project.json b/tooling/tools-utils/project.json deleted file mode 100644 index fc225436..00000000 --- a/tooling/tools-utils/project.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "tools-utils", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "projects/tools-utils/src", - "projectType": "library", - "release": { - "version": { - "generatorOptions": { - "packageRoot": "dist/{projectRoot}", - "currentVersionResolver": "git-tag" - } - } - }, - "tags": ["scope:tooling"], - "targets": { - "lint": {}, - "build": { - "executor": "@nx/esbuild:esbuild", - "outputs": ["{options.outputPath}"], - "options": { - "outputPath": "dist/tooling/tools-utils", - "main": "tooling/tools-utils/src/index.ts", - "tsConfig": "tooling/tools-utils/tsconfig.lib.json", - "assets": ["tooling/tools-utils/*.md"], - - "format": ["esm"] - } - }, - "test": { - "executor": "@nx/vite:test", - "outputs": ["{options.reportsDirectory}"], - "options": { - "reportsDirectory": "../../coverage/projects/tools-utils" - } - } - } -} diff --git a/tooling/tools-utils/src/index.ts b/tooling/tools-utils/src/index.ts deleted file mode 100644 index 61d1b8c2..00000000 --- a/tooling/tools-utils/src/index.ts +++ /dev/null @@ -1,24 +0,0 @@ -export * from './lib/utils/logging'; -export * from './lib/utils/utils'; -export * from './lib/utils/build-target-helper'; -export { setupNpmWorkspace } from './lib/utils/npm'; - -export { - parseRegistryData, - type RegistryResult, - type VercaddioServerResult, - type VerdaccioProcessResult, - startVerdaccioServer, - type StarVerdaccioOptions, - type StarVerdaccioOnlyOptions, -} from './lib/verdaccio/verdaccio-registry'; -export { - type NpmTestEnvResult, - type VerdaccioEnv, - type StartVerdaccioAndSetupEnvOptions, - setupNpmEnv, - stopVerdaccioAndTeardownEnv, - configureRegistry, - unconfigureRegistry, - verdaccioEnvLogger, -} from './lib/verdaccio/verdaccio-npm-env'; diff --git a/tooling/tools-utils/tsconfig.json b/tooling/tools-utils/tsconfig.json deleted file mode 100644 index 330b9970..00000000 --- a/tooling/tools-utils/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "module": "esnext", - "forceConsistentCasingInFileNames": true, - "strict": true, - "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true - }, - "files": [], - "include": [], - "references": [ - { - "path": "./tsconfig.lib.json" - }, - { - "path": "./tsconfig.spec.json" - } - ] -} diff --git a/tooling/tools-utils/tsconfig.lib.json b/tooling/tools-utils/tsconfig.lib.json deleted file mode 100644 index 3a557089..00000000 --- a/tooling/tools-utils/tsconfig.lib.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "declaration": true, - "types": ["node"] - }, - "include": ["src/**/*.ts", "bin/**/*.ts"], - "exclude": ["vite.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] -} diff --git a/tooling/tools-utils/tsconfig.spec.json b/tooling/tools-utils/tsconfig.spec.json deleted file mode 100644 index 6680b091..00000000 --- a/tooling/tools-utils/tsconfig.spec.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "../../dist/out-tsc", - "types": [ - "vitest/globals", - "vitest/importMeta", - "vite/client", - "node", - "tslib", - "vitest" - ] - }, - "include": [ - "vite.config.ts", - "vitest.config.ts", - "src/**/*.test.ts", - "src/**/*.spec.ts", - "src/**/*.test.tsx", - "src/**/*.spec.tsx", - "src/**/*.test.js", - "src/**/*.spec.js", - "src/**/*.test.jsx", - "src/**/*.spec.jsx", - "src/**/*.d.ts" - ] -} diff --git a/tooling/tools-utils/vite.config.ts b/tooling/tools-utils/vite.config.ts deleted file mode 100644 index bd7b8fda..00000000 --- a/tooling/tools-utils/vite.config.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { defineConfig } from 'vite'; - -import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; - -export default defineConfig({ - root: __dirname, - cacheDir: '../../node_modules/.vite/projects/tools-utils', - - plugins: [nxViteTsPaths()], - - // Uncomment this if you are using workers. - // worker: { - // plugins: [ nxViteTsPaths() ], - // }, - - test: { - globals: true, - cache: { dir: '../../node_modules/.vitest' }, - environment: 'node', - include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], - reporters: ['default'], - setupFiles: [ - 'testing/test-setup/src/lib/console.mock.ts', - 'testing/test-setup/src/lib/fs.mock.ts', - 'testing/test-setup/src/lib/reset.mock.ts', - ], - coverage: { - reportsDirectory: '../../coverage/projects/tools-utils', - provider: 'v8', - }, - }, -}); diff --git a/tsconfig.base.json b/tsconfig.base.json index 1d4efa73..7f2446cd 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -21,7 +21,6 @@ "@org/models": ["projects/models/src/index.ts"], "@org/test-setup": ["testing/test-setup/src/index.ts"], "@org/test-utils": ["testing/test-utils/src/index.ts"], - "@org/tools-utils": ["tooling/tools-utils/src/index.ts"], "@org/utils": ["projects/utils/src/index.ts"] } },