Skip to content

Commit

Permalink
Added after build task in build-module generation (#1331)
Browse files Browse the repository at this point in the history
* after build

* after build

* add root module

* add default after build

* Update project.ts

* revert

* after build

* add diusable

* update

* update
  • Loading branch information
NoriZC committed May 9, 2024
1 parent c117b33 commit 228c6ae
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion powershell/cmdlets/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2323,7 +2323,7 @@ export class CmdletClass extends Class {
if (operation.details.default.externalDocs) {
this.add(new Attribute(ExternalDocsAttribute, {
parameters: [`${new StringExpression(this.operation.details.default.externalDocs?.url ?? '')}`,
`${new StringExpression(this.operation.details.default.externalDocs?.description ?? '')}`]
`${new StringExpression(this.operation.details.default.externalDocs?.description ?? '')}`]
}));
}

Expand Down
8 changes: 7 additions & 1 deletion powershell/internal/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ export class Project extends codeDomProject {
public gitAttributes!: string;
public propertiesExcludedForTableview!: string;
public readme!: string;
public afterBuildTasksPath!: string;
public afterBuildTasksArgs!: string;
public dllName!: string;
public dll!: string;
public psd1!: string;
Expand Down Expand Up @@ -327,6 +329,10 @@ export class Project extends codeDomProject {
this.gitIgnore = `${this.baseFolder}/.gitignore`;
this.gitAttributes = `${this.baseFolder}/.gitattributes`;
this.readme = `${this.baseFolder}/README.md`;
this.afterBuildTasksPath = await this.state.getValue('after-build-tasks-path', '');

const afterBuildTasksArgsDictionary: Dictionary<string> = await this.state.getValue<Dictionary<string>>('after-build-tasks-args', {});
this.afterBuildTasksArgs = JSON.stringify(afterBuildTasksArgsDictionary);

// excluded properties in table view
const excludedList = <Array<string>>(
Expand Down Expand Up @@ -411,4 +417,4 @@ export class Project extends codeDomProject {
private convertToPsListAsString(items: Array<string>): string {
return items ? items.map((i) => `'${i}'`).join(', ') : 'undefined';
}
}
}
12 changes: 11 additions & 1 deletion powershell/resources/assets/build-module.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ----------------------------------------------------------------------------------
${$project.pwshCommentHeader}
# ----------------------------------------------------------------------------------
param([switch]$NotIsolated, [switch]$Run, [switch]$Test, [switch]$Docs, [switch]$Pack, [switch]$Code, [switch]$Release, [switch]$Debugger, [switch]$NoDocs, [switch]$UX)
param([switch]$NotIsolated, [switch]$Run, [switch]$Test, [switch]$Docs, [switch]$Pack, [switch]$Code, [switch]$Release, [switch]$Debugger, [switch]$NoDocs, [switch]$UX, [Switch]$DisableAfterBuildTasks)
$ErrorActionPreference = 'Stop'

if($PSEdition -ne 'Core') {
Expand Down Expand Up @@ -166,4 +166,14 @@ if (Test-Path (Join-Path $PSScriptRoot 'generate-portal-ux.ps1'))
. (Join-Path $PSScriptRoot 'generate-portal-ux.ps1')
}

if (-not $DisableAfterBuildTasks){
$afterBuildTasksPath = Join-Path $PSScriptRoot '${$project.afterBuildTasksPath}'
$afterBuildTasksArgs = ConvertFrom-Json '${$project.afterBuildTasksArgs}' -AsHashtable
if(Test-Path -Path $afterBuildTasksPath -PathType leaf){
Write-Host -ForegroundColor Green 'Running after build tasks...'
. $afterBuildTasksPath @afterBuildTasksArgs
}
}


Write-Host -ForegroundColor Green '-------------Done-------------'

0 comments on commit 228c6ae

Please sign in to comment.