Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env node
/**
* JENKINS DISCOVERY SCRIPT
*
* This script inspects a Jenkins job to discover ALL available data fields
* in the build responses. Use this to understand what data your Jenkins
* instance provides, then write a custom extraction script based on the results.
*
* USAGE:
#!/usr/bin/env node
/**
* SELF-CONTAINED GITHUB TIME TO GREEN (TTG) DATA COLLECTION SCRIPT
*
* This script collects Time to Green metrics from GitHub by fetching Pull Requests
* and their associated workflow runs (CI builds). It provides comprehensive TTG data
* for analyzing development velocity and CI performance.
*
* USAGE:
import { ServeFullstackExecutorSchema } from './schema';
import { ExecutorContext } from '@nrwl/devkit';
import { ChildProcess, exec } from 'child_process';
import * as chalk from 'chalk';
const LARGE_BUFFER = 1024 * 1000000;
export default async function runExecutor(
options: ServeFullstackExecutorSchema,
_context: ExecutorContext
import { ServeFullstackExecutorSchema } from './schema';
import { ExecutorContext } from '@nrwl/devkit';
import { ChildProcess, exec } from 'child_process';
const LARGE_BUFFER = 1024 * 1000000;
export default async function runExecutor(
options: ServeFullstackExecutorSchema,
_context: ExecutorContext
) {
async function startBackendServer(options: ServeFullstackExecutorSchema) {
let frontendServerStarted = false;
return new Promise(() => {
const childProcess = exec(`npx nx serve ${options.backendProject}`, {
maxBuffer: LARGE_BUFFER,
});
process.on('exit', () => childProcess.kill());
process.on('SIGTERM', () => childProcess.kill());
childProcess.stdout.on('data', (data) => {
if (!frontendServerStarted && data.includes('build succeeded, watching for changes...')) {
async function startBackendServer(options: ServeFullstackExecutorSchema) {
let frontendServerStarted = false;
return new Promise(() => {
const childProcess = exec(`npx nx serve ${options.backendProject}`, {
maxBuffer: LARGE_BUFFER,
});
process.on('exit', () => childProcess.kill());
process.on('SIGTERM', () => childProcess.kill());
childProcess.stdout.on('data', (data) => {
if (!frontendServerStarted && data.includes('build succeeded, watching for changes...')) {
import { applicationGenerator as nodeAppGenerator } from '@nrwl/node';
// ...
async function createNodeApplication(
tree: Tree,
options: AppGeneratorSchema,
serverName: string,
webAppName: string
) {
import { getWorkspaceLayout, names, Tree, updateJson } from '@nrwl/devkit'
// ...
function adjustDefaultDevPort(tree: Tree, options: AppGeneratorSchema) {
const { fileName } = names(options.name);
updateJson(tree, `apps/${fileName}-web/project.json`, (json) => ({
...json,
targets: {
...json.targets,
import { names, Tree } from '@nrwl/devkit';
import { AppGeneratorSchema } from './schema';
const defaultPorts = {
frontendPort: 3000,
backendPort: 3333,
};
export default async function (tree: Tree, options: AppGeneratorSchema) {
const optionsWithDefaults = {
import { ServeFullstackExecutorSchema } from './schema';
import { ExecutorContext } from '@nrwl/devkit';
import { ChildProcess, exec } from 'child_process';
const LARGE_BUFFER = 1024 * 1000000;
export default async function runExecutor(
options: ServeFullstackExecutorSchema,
_context: ExecutorContext
) {