diff --git a/packages/pulumi/src/executors/preview/preview.impl.ts b/packages/pulumi/src/executors/preview/preview.impl.ts index 81e41a49..76d78c39 100644 --- a/packages/pulumi/src/executors/preview/preview.impl.ts +++ b/packages/pulumi/src/executors/preview/preview.impl.ts @@ -1,10 +1,12 @@ -import { ExecutorContext } from '@nx/devkit' +import { ExecutorContext, workspaceRoot } from '@nx/devkit' import { buildCommand } from '@nx-extend/core' import { execSync } from 'child_process' import { which } from 'shelljs' +import { join } from 'path' export interface PreviewOptions { stack?: string + root?: string } export default async function creatExecutor( @@ -24,7 +26,7 @@ export default async function creatExecutor( options.stack && `--stack=${options.stack}` ]), { - cwd: sourceRoot, + cwd: join(workspaceRoot, options.root ?? sourceRoot), stdio: 'inherit' } ) diff --git a/packages/pulumi/src/executors/preview/schema.json b/packages/pulumi/src/executors/preview/schema.json index 7125dc7d..1c0ed2f3 100644 --- a/packages/pulumi/src/executors/preview/schema.json +++ b/packages/pulumi/src/executors/preview/schema.json @@ -5,5 +5,10 @@ "type": "object", "title": "Preview executor", "description": "Preview", - "properties": {} + "properties": { + "root": { + "type": "string", + "description": "The working directory to run Pulumi commands from, if specified." + } + } } diff --git a/packages/pulumi/src/executors/refresh/refresh.impl.ts b/packages/pulumi/src/executors/refresh/refresh.impl.ts index d6db7a45..b5a90653 100644 --- a/packages/pulumi/src/executors/refresh/refresh.impl.ts +++ b/packages/pulumi/src/executors/refresh/refresh.impl.ts @@ -1,12 +1,14 @@ import { buildCommand } from '@nx-extend/core' -import { ExecutorContext } from '@nx/devkit' +import { ExecutorContext, workspaceRoot } from '@nx/devkit' import { execSync } from 'child_process' import { which } from 'shelljs' +import { join } from 'path' export interface RefreshOptions { stack?: string, skipPreview?: boolean, yes?: boolean, + root?: string, } export default async function createExecutor( @@ -28,7 +30,7 @@ export default async function createExecutor( options.yes && '--yes' ]), { - cwd: sourceRoot, + cwd: join(workspaceRoot, options.root ?? sourceRoot), stdio: 'inherit' } ) diff --git a/packages/pulumi/src/executors/refresh/schema.json b/packages/pulumi/src/executors/refresh/schema.json index 7777ddce..5935b0c2 100644 --- a/packages/pulumi/src/executors/refresh/schema.json +++ b/packages/pulumi/src/executors/refresh/schema.json @@ -5,5 +5,10 @@ "type": "object", "title": "Refresh executor", "description": "Refresh", - "properties": {} + "properties": { + "root": { + "type": "string", + "description": "The working directory to run Pulumi commands from, if specified." + } + } } diff --git a/packages/pulumi/src/executors/up/schema.json b/packages/pulumi/src/executors/up/schema.json index e79194e7..24acb526 100644 --- a/packages/pulumi/src/executors/up/schema.json +++ b/packages/pulumi/src/executors/up/schema.json @@ -5,5 +5,10 @@ "type": "object", "title": "Apply executor", "description": "Apply", - "properties": {} + "properties": { + "root": { + "type": "string", + "description": "The working directory to run Pulumi commands from, if specified." + } + } } diff --git a/packages/pulumi/src/executors/up/up.impl.ts b/packages/pulumi/src/executors/up/up.impl.ts index d87b97b6..cf4e82c9 100644 --- a/packages/pulumi/src/executors/up/up.impl.ts +++ b/packages/pulumi/src/executors/up/up.impl.ts @@ -1,7 +1,8 @@ import { buildCommand, USE_VERBOSE_LOGGING_MINIMAL } from '@nx-extend/core' -import { ExecutorContext } from '@nx/devkit' +import { ExecutorContext, workspaceRoot } from '@nx/devkit' import { execSync } from 'child_process' import { which } from 'shelljs' +import { join } from 'path' export interface UpOptions { stack?: string, @@ -9,6 +10,7 @@ export interface UpOptions { yes?: boolean suppressOutputs?: boolean json?: boolean + root?: string } export default async function createExecutor( @@ -32,7 +34,7 @@ export default async function createExecutor( options.json && '--json' ]), { - cwd: sourceRoot, + cwd: join(workspaceRoot, options.root ?? sourceRoot), stdio: 'inherit' } )