Skip to content

Commit

Permalink
wip build executor 5
Browse files Browse the repository at this point in the history
  • Loading branch information
BioPhoton committed Sep 4, 2024
1 parent 3184a04 commit b2751ea
Show file tree
Hide file tree
Showing 18 changed files with 201 additions and 431 deletions.
15 changes: 10 additions & 5 deletions tools/build-env/executors.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@
"schema": "./src/executors/setup-env/schema.json",
"description": "Generate and install test environments in your workspace. Cached and ready for use."
},
"build": {
"implementation": "./src/executors/build/executor",
"schema": "./src/executors/build/schema.json",
"description": "Generate test environments in your workspace. Cached and ready for use."
"bootstrap": {
"implementation": "./src/executors/bootstrap/executor",
"schema": "./src/executors/bootstrap/schema.json",
"description": "Bootstraps a test environments in your workspace. Cached and ready for use."
},
"kill-process": {
"implementation": "./src/executors/kill-process/executor",
"schema": "./src/executors/kill-process/schema.json",
"description": "´Kills process by PID, command or file path."
"description": "Kills process by PID, command or file path."
},
"npm-install": {
"implementation": "./src/executors/npm-install/executor",
"schema": "./src/executors/npm-install/schema.json",
"description": "Installs npm packages in your workspace."
}
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { type ExecutorContext, logger } from '@nx/devkit';
import type { BuildExecutorOptions } from './schema';
import { setupNpmEnv } from '../../internal/verdaccio/verdaccio-npm-env';
import type { BootstrapExecutorOptions } from './schema';
import { bootstrapEnvironment } from '../../internal/verdaccio/verdaccio-npm-env';
import { join } from 'node:path';
import * as process from 'process';
import { DEFAULT_ENVIRONMENTS_OUTPUT_DIR } from '../../internal/constants';

export type ExecutorOutput = {
export type BootstrapExecutorOutput = {
success: boolean;
command?: string;
error?: Error;
};

export default async function runBuildExecutor(
terminalAndExecutorOptions: BuildExecutorOptions,
export default async function runBootstrapExecutor(
terminalAndExecutorOptions: BootstrapExecutorOptions,
context: ExecutorContext
) {
const { projectName } = context;
const normalizedOptions = {
...terminalAndExecutorOptions,
workspaceRoot: join('tmp', 'environments', projectName),
environmentRoot: join(DEFAULT_ENVIRONMENTS_OUTPUT_DIR, projectName),
};
logger.info(
`Execute @org/build-env:build with options: ${JSON.stringify(
Expand All @@ -29,7 +29,7 @@ export default async function runBuildExecutor(

let envResult;
try {
envResult = await setupNpmEnv({
envResult = await bootstrapEnvironment({
...normalizedOptions,
projectName,
readyWhen: 'Environment ready under',
Expand All @@ -46,5 +46,5 @@ export default async function runBuildExecutor(
return Promise.resolve({
success: true,
command: JSON.stringify(envResult, null, 2),
} satisfies ExecutorOutput);
} satisfies BootstrapExecutorOutput);
}
21 changes: 21 additions & 0 deletions tools/build-env/src/executors/bootstrap/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "http://json-schema.org/schema",
"$id": "BootstrapExecutorOptions",
"title": "Environment bootstrap executor options",
"type": "object",
"properties": {
"workspaceRoot": {
"type": "string",
"description": "The root directory of the environment"
},
"dryRun": {
"type": "boolean",
"description": "Print the commands that would be run, but don't actually run them"
},
"verbose": {
"type": "boolean",
"description": "Print additional logs"
}
},
"additionalProperties": true
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export type BuildExecutorOptions = Partial<{
export type BootstrapExecutorOptions = Partial<{
workspaceRoot: string;
dryRun: boolean;
progress: boolean;
verbose: boolean;
}>;
57 changes: 0 additions & 57 deletions tools/build-env/src/executors/build/README.md

This file was deleted.

114 changes: 0 additions & 114 deletions tools/build-env/src/executors/build/executor.unit.test.ts

This file was deleted.

31 changes: 0 additions & 31 deletions tools/build-env/src/executors/build/schema.json

This file was deleted.

53 changes: 0 additions & 53 deletions tools/build-env/src/executors/kill-process/README.md

This file was deleted.

1 change: 0 additions & 1 deletion tools/build-env/src/executors/kill-process/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { type ExecutorContext, logger } from '@nx/devkit';
import type { KillProcessExecutorOptions } from './schema';
import { join } from 'node:path';
import { killProcessFromPid } from '../../internal/utils/process';
import * as process from 'process';

export type ExecutorOutput = {
success: boolean;
Expand Down
Loading

0 comments on commit b2751ea

Please sign in to comment.