From ac6b939e44273416aef6cbba49959f9b79d9d308 Mon Sep 17 00:00:00 2001 From: Tycho Bokdam Date: Sun, 5 May 2024 18:20:20 +0200 Subject: [PATCH] feat(pulumi): Move setup of typescript to package --- .../src/generators/init/files/index.ts.template | 14 +------------- .../generators/init/files/tsconfig.json.template | 3 --- packages/pulumi/src/generators/init/init.impl.ts | 14 +++++++------- packages/pulumi/src/index.ts | 5 +++++ packages/pulumi/src/init.ts | 14 ++++++++++++++ 5 files changed, 27 insertions(+), 23 deletions(-) delete mode 100644 packages/pulumi/src/generators/init/files/tsconfig.json.template create mode 100644 packages/pulumi/src/init.ts diff --git a/packages/pulumi/src/generators/init/files/index.ts.template b/packages/pulumi/src/generators/init/files/index.ts.template index 5d0da025..f06f00c6 100644 --- a/packages/pulumi/src/generators/init/files/index.ts.template +++ b/packages/pulumi/src/generators/init/files/index.ts.template @@ -1,17 +1,5 @@ /* eslint-disable */ -import { loadConfig, register } from 'tsconfig-paths' - -const config = loadConfig('.') -if (config.resultType === 'failed') { - console.log('Could not load tsconfig to map paths, aborting.') - process.exit(1) -} - -register({ - baseUrl: config.absoluteBaseUrl, - paths: config.paths -}) - +import '@nx-extend/pulumi' import './pulumi' export * from './pulumi' diff --git a/packages/pulumi/src/generators/init/files/tsconfig.json.template b/packages/pulumi/src/generators/init/files/tsconfig.json.template deleted file mode 100644 index ecad9d75..00000000 --- a/packages/pulumi/src/generators/init/files/tsconfig.json.template +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "<%= offsetFromRoot %>tsconfig.base.json" -} diff --git a/packages/pulumi/src/generators/init/init.impl.ts b/packages/pulumi/src/generators/init/init.impl.ts index 1273fe6f..fbd0d785 100644 --- a/packages/pulumi/src/generators/init/init.impl.ts +++ b/packages/pulumi/src/generators/init/init.impl.ts @@ -1,10 +1,3 @@ -import { - buildCommand, - DefaultGeneratorOptions, - execCommand, - NormalizedSchema, - normalizeOptions -} from '@nx-extend/core' import { addDependenciesToPackageJson, addProjectConfiguration, @@ -16,6 +9,13 @@ import { runTasksInSerial, Tree } from '@nx/devkit' +import { + buildCommand, + DefaultGeneratorOptions, + execCommand, + NormalizedSchema, + normalizeOptions +} from '@nx-extend/core' import { readFileSync, unlinkSync } from 'fs' import { join } from 'path' import { which } from 'shelljs' diff --git a/packages/pulumi/src/index.ts b/packages/pulumi/src/index.ts index e69de29b..20f9f92c 100644 --- a/packages/pulumi/src/index.ts +++ b/packages/pulumi/src/index.ts @@ -0,0 +1,5 @@ +import { workspaceRoot } from '@nx/devkit' + +import { setupTypescript } from './init' + +setupTypescript(workspaceRoot) diff --git a/packages/pulumi/src/init.ts b/packages/pulumi/src/init.ts new file mode 100644 index 00000000..124bcf30 --- /dev/null +++ b/packages/pulumi/src/init.ts @@ -0,0 +1,14 @@ +import { loadConfig, register } from 'tsconfig-paths' + +export function setupTypescript(directory: string): void { + const config = loadConfig(directory) + if (config.resultType === 'failed') { + console.log('Could not load tsconfig to map paths, aborting.') + process.exit(1) + } + + register({ + baseUrl: config.absoluteBaseUrl, + paths: config.paths + }) +}