Skip to content

Commit

Permalink
organize example code
Browse files Browse the repository at this point in the history
  • Loading branch information
BioPhoton committed Sep 9, 2024
1 parent 7704a45 commit 7a0e6d0
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 41 deletions.
21 changes: 0 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,27 +59,6 @@ The plugins registered in `nx.json` are used to derive dynamic targets for diffe

@TODO

## Example projects and plugins

This repository maintains the following example projects and plugins to showcase a refactoring from existing E2E setup to a more maintainable and scalable setup:

- Run original: `nx original-cli-e2e:original-e2e`
- project `e2e-example/original-e2e`
- setup script `e2e-example/original-e2e/setup/global-setup.e2e.ts`
- plugin `tools/e2e-example-plugins/original.plugin.ts`
- Run env: `nx env-cli-e2e:env-e2e`
- project `e2e-example/env-e2e`
- setup script `e2e-example/env-e2e/setup/global-setup.e2e.ts`
- plugin `tools/e2e-example-plugins/env.plugin.ts`
- Run graph: `nx graph-cli-e2e:graph-e2e`
- project `e2e-example/graph-e2e`
- setup script `e2e-example/graph-e2e/setup/global-setup.e2e.ts`
- plugin `tools/e2e-example-plugins/graph.plugin.ts`
- Run pretarget: `nx pretarget-cli-e2e:pretarget-e2e`
- project `e2e-example/pretarget-e2e`
- setup script `e2e-example/pretarget-e2e/setup/global-setup.e2e.ts`
- plugin `tools/e2e-example-plugins/pretarget.plugin.ts`

## TODO

- remove usage of generatePackageJson in esbuild build targets
Expand Down
31 changes: 31 additions & 0 deletions e2e-examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Example projects and plugins

This folder maintains the following example projects and plugins to showcase a refactoring from existing E2E setup to a more maintainable and scalable setup:

**`cli-e2e-original`**

- target: `nx run original-cli-e2e:original-e2e`
- project `e2e-example/original-e2e`
- setup script `e2e-example/original-e2e/setup/global-setup.e2e.ts`
- plugin `tools/e2e-example-plugins/original.plugin.ts`

**`cli-e2e-env`**

- Run env: `nx env-cli-e2e:env-e2e`
- project `e2e-example/env-e2e`
- setup script `e2e-example/env-e2e/setup/global-setup.e2e.ts`
- plugin `tools/e2e-example-plugins/env.plugin.ts`

**`cli-e2e-graph`**

- run `nx run graph-cli-e2e:graph-e2e`
- project `e2e-example/graph-e2e`
- setup script `e2e-example/graph-e2e/setup/global-setup.e2e.ts`
- plugin `tools/e2e-example-plugins/graph.plugin.ts`

**`cli-e2e-pretarget`**

- run `nx run pretarget-cli-e2e:pretarget-e2e`
- project `e2e-example/pretarget-e2e`
- setup script `e2e-example/pretarget-e2e/setup/global-setup.e2e.ts`
- plugin `tools/e2e-example-plugins/pretarget.plugin.ts`
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
verdaccioEnvLogger,
StartVerdaccioAndSetupEnvOptions,
} from '../lib/verdaccio/verdaccio-npm-env';
import yargs, { Options } from 'yargs';
import { rm } from 'node:fs/promises';
import { join } from 'node:path';
import yargs, { Options } from 'yargs';
import { readJsonFile } from '@nx/devkit';
import { VercaddioServerResult } from '../lib/verdaccio/verdaccio-registry';
import { rm } from 'node:fs/promises';
import {
StartVerdaccioAndSetupEnvOptions,
VercaddioServerResult,
verdaccioEnvLogger,
} from '@org/tools-utils';

const isVerbose: boolean =
process.env['NX_VERBOSE_LOGGING'] === 'true' ?? false;
Expand Down
2 changes: 1 addition & 1 deletion e2e-examples/cli-e2e-pretarget/tooling/pretarget.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function verdaccioTargets(
},
'pretarget-teardown-env': {
command:
'tsx --tsconfig=tools/tsconfig.tools.json tools/tools-utils/src/bin/stop-verdaccio.ts --workspaceRoot={args.workspaceRoot}',
'tsx --tsconfig=e2e-examples/cli-e2e-pretarget/tsconfig.tools.json e2e-examples/cli-e2e-pretarget/tooling/bin/stop-verdaccio.ts --workspaceRoot={args.workspaceRoot}',
options: {
workspaceRoot: join(tmpEnv, projectName),
},
Expand Down
2 changes: 1 addition & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"./e2e-examples/cli-e2e-env/tooling/env.plugin.ts",
"./e2e-examples/cli-e2e-graph/tooling/graph.plugin.ts",
"./e2e-examples/cli-e2e-pretarget/tooling/pretarget.plugin.ts",
"./tooling/build-env/src/plugin/verdaccio-env.plugin.ts"
"@org/build-env"
],
"release": {
"version": {
Expand Down
11 changes: 1 addition & 10 deletions tooling/build-env/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
# @org/build-env

## To Code

**Executor:**

- build (to stop verdaccio server process)
- kill-process (to stop verdaccio server process)
- install-env (to install NPM packages from within environments)

## To Research

- Store Verdaccio state under .nx?
- Project usage across existing Nx projects (popular open-source libraries?)
- Keep custom npm-publish or use Nx release Node.js API?
- Cache node_modules??
- Research if we can use Nx release Node.js API instead of custom target?
- How to ensure the setup will work in Nx Agents?

**What can be cached**
Expand Down
2 changes: 1 addition & 1 deletion tooling/build-env/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { getEnvironmentsRoot, getEnvironmentRoot } from './shared/setup';
export { createNodes } from './plugin/verdaccio-env.plugin';
export { createNodes } from './plugin/plugin';
File renamed without changes.

0 comments on commit 7a0e6d0

Please sign in to comment.