Skip to content

Commit

Permalink
feat(pulumi): Move setup of typescript to package
Browse files Browse the repository at this point in the history
  • Loading branch information
TriPSs committed May 5, 2024
1 parent 47739a1 commit ac6b939
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
14 changes: 1 addition & 13 deletions packages/pulumi/src/generators/init/files/index.ts.template
Original file line number Diff line number Diff line change
@@ -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'

This file was deleted.

14 changes: 7 additions & 7 deletions packages/pulumi/src/generators/init/init.impl.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
import {
buildCommand,
DefaultGeneratorOptions,
execCommand,
NormalizedSchema,
normalizeOptions
} from '@nx-extend/core'
import {
addDependenciesToPackageJson,
addProjectConfiguration,
Expand All @@ -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'
Expand Down
5 changes: 5 additions & 0 deletions packages/pulumi/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { workspaceRoot } from '@nx/devkit'

import { setupTypescript } from './init'

setupTypescript(workspaceRoot)
14 changes: 14 additions & 0 deletions packages/pulumi/src/init.ts
Original file line number Diff line number Diff line change
@@ -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
})
}

0 comments on commit ac6b939

Please sign in to comment.