diff --git a/package.json b/package.json index 00c5244a..a8928990 100644 --- a/package.json +++ b/package.json @@ -107,11 +107,11 @@ "definitelyTyped": [ "dotenv", "http-proxy", - "js-yaml ", + "js-yaml", "lodash.*", "prettier", - "vhost ", - "yargs " + "vhost", + "yargs" ] } } diff --git a/packages/@clc/nx/src/create-nodes.ts b/packages/@clc/nx/src/create-nodes.ts index 90c1dece..9ce3315d 100644 --- a/packages/@clc/nx/src/create-nodes.ts +++ b/packages/@clc/nx/src/create-nodes.ts @@ -48,6 +48,7 @@ export const createNodes: CreateNodes = [ ], packageName: projectName, }, + outputs: ['{projectRoot}/package.json'], }); addTarget(targets, 'codegen', 'executors', { diff --git a/packages/@code-like-a-carpenter/tool-deps/src/deps.ts b/packages/@code-like-a-carpenter/tool-deps/src/deps.ts index c9366131..2fbb6b15 100644 --- a/packages/@code-like-a-carpenter/tool-deps/src/deps.ts +++ b/packages/@code-like-a-carpenter/tool-deps/src/deps.ts @@ -87,7 +87,7 @@ export async function processSinglePackage( if (depsToAdd.size) { assert( !dryRun, - `${packageName} is missing at least one dependency. Please "npm run cli -- deps" and commit the changes` + `${packageName} is missing the following dependencies: ${Array.from(depsToAdd).join(', ')}. Please "npm run cli -- deps" and commit the changes` ); assert(awsSdkVersion, 'awsSdkVersion is required'); @@ -102,7 +102,7 @@ export async function processSinglePackage( if (devDepsToAdd.size) { assert( !dryRun, - `${packageName} is missing at least one dev dependency. Please "npm run cli -- deps" and commit the changes` + `${packageName} is missing the following dependencies: ${Array.from(devDepsToAdd).join(', ')}. Please "npm run cli -- deps" and commit the changes` ); assert(awsSdkVersion, 'awsSdkVersion is required'); @@ -117,7 +117,7 @@ export async function processSinglePackage( if (localDepsToAdd.size) { assert( !dryRun, - `${packageName} is missing at least one local dependency. Please "npm run cli -- deps" and commit the changes` + `${packageName} is missing the following dependencies: ${Array.from(localDepsToAdd).join(', ')}. Please "npm run cli -- deps" and commit the changes` ); await addMissingLocalPackages( @@ -130,7 +130,7 @@ export async function processSinglePackage( if (localDevDepsToAdd.size) { assert( !dryRun, - `${packageName} is missing at least one local dev dependency. Please "npm run cli -- deps" and commit the changes` + `${packageName} is missing the following dependencies: ${Array.from(localDevDepsToAdd).join(', ')}. Please "npm run cli -- deps" and commit the changes` ); await addMissingLocalPackages( @@ -156,6 +156,7 @@ export async function addMissingLocalPackages( dependencies: string[], dev: boolean ) { + console.log('Adding missing local packages', packageName, dependencies, dev); assert(dependencies.length > 0, 'Received empty dependencies list'); spawnSync( @@ -184,6 +185,7 @@ export async function addMissingNodeModules({ readonly dev: boolean; readonly packageName: string; }) { + console.log('Adding missing node modules', packageName, dependencies, dev); assert(dependencies.length > 0, 'Received empty dependencies list'); const awsDeps = dependencies @@ -232,6 +234,7 @@ export async function removeExtraneousPackages( packageName: string, dependencies: string[] ) { + console.log('Removing extraneous packages', packageName, dependencies); assert(dependencies.length > 0, 'Received empty dependencies list'); spawnSync('npm', ['uninstall', '--workspace', packageName, ...dependencies], { diff --git a/packages/@code-like-a-carpenter/tool-stack/src/proxy.ts b/packages/@code-like-a-carpenter/tool-stack/src/proxy.ts index 865ab826..14e75603 100644 --- a/packages/@code-like-a-carpenter/tool-stack/src/proxy.ts +++ b/packages/@code-like-a-carpenter/tool-stack/src/proxy.ts @@ -10,6 +10,7 @@ import {findLocalPackages} from '@code-like-a-carpenter/tooling-common'; import type {StackProxySchema} from './__generated__/proxy-types.ts'; import {findEndpoints, findStacks} from './stacks'; +// eslint-disable-next-line complexity export async function handler(args: StackProxySchema): Promise { let stacks: string[] = []; @@ -36,6 +37,11 @@ export async function handler(args: StackProxySchema): Promise { assert(typeof endpoint === 'string', 'endpoint must be a string'); endpoints.set(`stack${index}`, endpoint); }); + + if (endpoints.size === 1 && args.endpoint) { + makeProxy(endpoints.values().next().value).listen(args.port ?? 3000); + return; + } } await startAllProxies({ @@ -141,10 +147,6 @@ export async function startAllProxies({ function makeProxy(endpoint: string): Server { const endpointUrl = new URL(endpoint); - // There's a bug in http-proxy that prevents it from handling redirects when - // the target is an object, so we need to convert the url the the desired - // string. - // https://github.com/http-party/node-http-proxy/issues/1338 endpointUrl.protocol = 'https:'; endpointUrl.port = '443'; diff --git a/packages/@code-like-a-carpenter/tooling-common/src/index.ts b/packages/@code-like-a-carpenter/tooling-common/src/index.ts index 74661421..83e12507 100644 --- a/packages/@code-like-a-carpenter/tooling-common/src/index.ts +++ b/packages/@code-like-a-carpenter/tooling-common/src/index.ts @@ -1,3 +1,4 @@ export * from './filesystem'; export * from './find-local-packages'; +export * from './format-stack-name'; export * from './get-stack-name';