From fc66ad6c5a60a5d239c06867687f71deeae8f0b1 Mon Sep 17 00:00:00 2001 From: Richard Fennell Date: Thu, 7 Jan 2021 15:49:01 +0000 Subject: [PATCH 1/5] Add support for partial export --- .../WikiPDFExport/WikiPDFExportTask/task/task.json | 2 +- Extensions/WikiPDFExport/azure-pipelines-build.yml | 9 +++++++++ Extensions/WikiPDFExport/readme.md | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Extensions/WikiPDFExport/WikiPDFExportTask/task/task.json b/Extensions/WikiPDFExport/WikiPDFExportTask/task/task.json index 462db2989..dd44a1084 100644 --- a/Extensions/WikiPDFExport/WikiPDFExportTask/task/task.json +++ b/Extensions/WikiPDFExport/WikiPDFExportTask/task/task.json @@ -97,7 +97,7 @@ "label": "Local folder", "defaultValue": "$(System.DefaultWorkingDirectory)\\repo", "required": true, - "helpMarkDown": "The Path to clone the repo into, or the folder containing the single file to export" + "helpMarkDown": "The path to the root of the cloned the repo if exporting the whole repo, a folder within the repo to export part of the repo or finally the folder containing a single file to export. For this final option the filename must be specified below" }, { "name": "outputFile", diff --git a/Extensions/WikiPDFExport/azure-pipelines-build.yml b/Extensions/WikiPDFExport/azure-pipelines-build.yml index 661b0728e..fc3dad0f4 100644 --- a/Extensions/WikiPDFExport/azure-pipelines-build.yml +++ b/Extensions/WikiPDFExport/azure-pipelines-build.yml @@ -168,6 +168,15 @@ stages: repo: 'https://dev.azure.com/richardfennell/GitHub/_git/GitHub.wiki' useAgentToken: true outputFile: '$(Build.ArtifactStagingDirectory)\PDF\Azrepo.pdf' + - task: richardfennellBM.BM-VSTS-WikiPDFExport-Tasks-DEV.WikiPDFExportTask.WikiPdfExportTask@1 + displayName: 'Export part of the Azure DevOps WIKI' + condition: succeededOrFailed() + inputs: + cloneRepo: true + repo: 'https://dev.azure.com/richardfennell/GitHub/_git/GitHub.wiki' + useAgentToken: true + outputFile: '$(Build.ArtifactStagingDirectory)\PDF\Azrepo.pdf' + localpath: '$(System.DefaultWorkingDirectory)\repo\folder' - task: richardfennellBM.BM-VSTS-WikiPDFExport-Tasks-DEV.WikiPDFExportTask.WikiPdfExportTask@1 displayName: 'Export Azure DevOps WIKI without downloading tool' condition: succeededOrFailed() diff --git a/Extensions/WikiPDFExport/readme.md b/Extensions/WikiPDFExport/readme.md index 175742382..efcd0bc6f 100644 --- a/Extensions/WikiPDFExport/readme.md +++ b/Extensions/WikiPDFExport/readme.md @@ -18,7 +18,7 @@ __Note:__ If you see problems such as `Error: spawn git ENOENT` when cloning a r #### General - CloneRepo - a boolean flag whether to clone the repo or not - Repo - The repo URL to update e.g in the form **https://dev.azure.com/richardfennell/Git%20project/_git/Git-project.wiki** (see the URL section below as to how to find this URL) -- LocalPath - The Path to clone the repo into and hence the folder structure containing the file(s) to export +- LocalPath - The path to the root of the cloned the repo if exporting the whole repo, a folder within the repo to export part of the repo or finally the folder containing a single file to export. For this final option the filename must be specified below - SingleFile - Optional single file to export in the localPath folder e.g. page.md - ExtraParameters - Any optional extra as defined at [WikiPDFExport](https://github.com/MaxMelcher/AzureDevOps.WikiPDFExport/) you wish to pass to the command line tool - the task automatically managed the -p, -s, -c and -v parameters #### Git Clone Specific From 8e9798adb136f922c73a10e7fe31d43afcff8852 Mon Sep 17 00:00:00 2001 From: Richard Fennell Date: Thu, 7 Jan 2021 15:59:01 +0000 Subject: [PATCH 2/5] Alter the file name --- Extensions/WikiPDFExport/azure-pipelines-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Extensions/WikiPDFExport/azure-pipelines-build.yml b/Extensions/WikiPDFExport/azure-pipelines-build.yml index fc3dad0f4..c215abbe5 100644 --- a/Extensions/WikiPDFExport/azure-pipelines-build.yml +++ b/Extensions/WikiPDFExport/azure-pipelines-build.yml @@ -175,7 +175,7 @@ stages: cloneRepo: true repo: 'https://dev.azure.com/richardfennell/GitHub/_git/GitHub.wiki' useAgentToken: true - outputFile: '$(Build.ArtifactStagingDirectory)\PDF\Azrepo.pdf' + outputFile: '$(Build.ArtifactStagingDirectory)\PDF\AzrepoFilter.pdf' localpath: '$(System.DefaultWorkingDirectory)\repo\folder' - task: richardfennellBM.BM-VSTS-WikiPDFExport-Tasks-DEV.WikiPDFExportTask.WikiPdfExportTask@1 displayName: 'Export Azure DevOps WIKI without downloading tool' From 7c4cdb4152f957e7a88f3908e71b7e0c1c33e298 Mon Sep 17 00:00:00 2001 From: Richard Fennell Date: Thu, 7 Jan 2021 16:41:57 +0000 Subject: [PATCH 3/5] Split the clone and the export filters --- .../WikiPDFExportTask/src/ExportFunctions.ts | 11 ++++++----- .../WikiPDFExportTask/src/WikiPDFExportTask.ts | 10 +++++++++- .../WikiPDFExport/WikiPDFExportTask/task/task.json | 8 ++++++++ .../WikiPDFExportTask/test/testrunnerForSingleFile.ts | 4 +++- .../test/testrunnerForWikiWithNoClone.ts | 5 ++++- .../test/testrunnerToCloneFromAzureDevOps.ts | 4 +++- .../test/testrunnerToCloneFromGitHub.ts | 4 +++- Extensions/WikiPDFExport/azure-pipelines-build.yml | 2 +- Extensions/WikiPDFExport/readme.md | 3 ++- 9 files changed, 39 insertions(+), 12 deletions(-) diff --git a/Extensions/WikiPDFExport/WikiPDFExportTask/src/ExportFunctions.ts b/Extensions/WikiPDFExport/WikiPDFExportTask/src/ExportFunctions.ts index 007fb25f9..e2f2bc654 100644 --- a/Extensions/WikiPDFExport/WikiPDFExportTask/src/ExportFunctions.ts +++ b/Extensions/WikiPDFExport/WikiPDFExportTask/src/ExportFunctions.ts @@ -165,7 +165,8 @@ export async function ExportRun ( user, password, injectExtraHeader, - branch + branch, + rootExportPath ) { if (fs.existsSync(exeCmd)) { @@ -190,10 +191,10 @@ export async function ExportRun ( } if (singleFile && singleFile.length > 0) { - console.log(`A filename ${singleFile} has been passed so only processing that file `); - ExportPDF (exeCmd, localpath, singleFile, outputFile, extraParams, logInfo, logError); + console.log(`A filename ${singleFile} in the folder ${rootExportPath} has been requested so only processing that file `); + ExportPDF (exeCmd, rootExportPath, singleFile, outputFile, extraParams, logInfo, logError); } else { - console.log(`No filename has been passed so cloning the repo `); - ExportPDF (exeCmd, localpath, "" , outputFile, extraParams, logInfo, logError); + console.log(`Processing the contents of the folder ${rootExportPath} `); + ExportPDF (exeCmd, rootExportPath, "" , outputFile, extraParams, logInfo, logError); } } \ No newline at end of file diff --git a/Extensions/WikiPDFExport/WikiPDFExportTask/src/WikiPDFExportTask.ts b/Extensions/WikiPDFExport/WikiPDFExportTask/src/WikiPDFExportTask.ts index d397ae7f2..c99957e5e 100644 --- a/Extensions/WikiPDFExport/WikiPDFExportTask/src/WikiPDFExportTask.ts +++ b/Extensions/WikiPDFExport/WikiPDFExportTask/src/WikiPDFExportTask.ts @@ -26,12 +26,19 @@ var injectExtraHeader = tl.getBoolInput("injectExtraHeader"); var cloneRepo = tl.getBoolInput("cloneRepo"); var overrideExePath = tl.getInput("overrideExePath"); var workingFolder = tl.getVariable("Agent.TempDirectory"); +var rootExportPath = tl.getVariable("rootExportPath"); + +// make sure that we support older configs where these two parameter were a single setting +if (rootExportPath.trim().length === 0) { + rootExportPath = localpath; +} console.log(`Variable: Repo [${repo}]`); console.log(`Variable: Use Agent Token [${useAgentToken}]`); console.log(`Variable: Username [${user}]`); console.log(`Variable: Password [${password}]`); console.log(`Variable: LocalPath [${localpath}]`); +console.log(`Variable: rootExportPath [${rootExportPath}]`); console.log(`Variable: SingleFile [${singleFile}]`); console.log(`Variable: OutputFile [${outputFile}]`); console.log(`Variable: Branch [${branch}]`); @@ -55,7 +62,8 @@ GetExePath( user, password, injectExtraHeader, - branch + branch, + rootExportPath ); } else { logError(`Cannot find the 'azuredevops-export-wiki.exe' tool`); diff --git a/Extensions/WikiPDFExport/WikiPDFExportTask/task/task.json b/Extensions/WikiPDFExport/WikiPDFExportTask/task/task.json index dd44a1084..4852cb505 100644 --- a/Extensions/WikiPDFExport/WikiPDFExportTask/task/task.json +++ b/Extensions/WikiPDFExport/WikiPDFExportTask/task/task.json @@ -97,6 +97,14 @@ "label": "Local folder", "defaultValue": "$(System.DefaultWorkingDirectory)\\repo", "required": true, + "helpMarkDown": "The path to clone the repo into" + }, + { + "name": "rootExportPath", + "type": "string", + "label": "Local folder", + "defaultValue": "", + "required": false, "helpMarkDown": "The path to the root of the cloned the repo if exporting the whole repo, a folder within the repo to export part of the repo or finally the folder containing a single file to export. For this final option the filename must be specified below" }, { diff --git a/Extensions/WikiPDFExport/WikiPDFExportTask/test/testrunnerForSingleFile.ts b/Extensions/WikiPDFExport/WikiPDFExportTask/test/testrunnerForSingleFile.ts index 36dd4f82e..e53d176e5 100644 --- a/Extensions/WikiPDFExport/WikiPDFExportTask/test/testrunnerForSingleFile.ts +++ b/Extensions/WikiPDFExport/WikiPDFExportTask/test/testrunnerForSingleFile.ts @@ -12,6 +12,7 @@ function logError (msg: string) { // const singleFile = `${__dirname}\\..\\..\\..\\readme.md`; const localpath = `C:\\projects\\github\\AzurePipelines.wiki`; +const rootExportPath = `C:\\projects\\github\\AzurePipelines.wiki`; const singleFile = `C:\\projects\\github\\AzurePipelines.wiki\\ArtifactDescription-Tasks.md`; const outputFile = "c:\\tmp\\test\\new\\output.pdf"; const injectExtraHeader = false; @@ -36,5 +37,6 @@ ExportRun( user, password, injectExtraHeader, - branch + branch, + rootExportPath ); diff --git a/Extensions/WikiPDFExport/WikiPDFExportTask/test/testrunnerForWikiWithNoClone.ts b/Extensions/WikiPDFExport/WikiPDFExportTask/test/testrunnerForWikiWithNoClone.ts index 510c54257..53ce15d3e 100644 --- a/Extensions/WikiPDFExport/WikiPDFExportTask/test/testrunnerForWikiWithNoClone.ts +++ b/Extensions/WikiPDFExport/WikiPDFExportTask/test/testrunnerForWikiWithNoClone.ts @@ -11,6 +11,8 @@ function logError (msg: string) { } const localpath = `${__dirname}\\..\\..\\..\\..\\..\\..\\AzurePipelines.wiki`; +const rootExportPath = `${__dirname}\\..\\..\\..\\..\\..\\..\\AzurePipelines.wiki`; + const outputFile = "c:\\tmp\\test\\output.pdf"; const injectExtraHeader = false; const singleFile = ""; @@ -35,5 +37,6 @@ ExportRun( user, password, injectExtraHeader, - branch + branch, + rootExportPath ); diff --git a/Extensions/WikiPDFExport/WikiPDFExportTask/test/testrunnerToCloneFromAzureDevOps.ts b/Extensions/WikiPDFExport/WikiPDFExportTask/test/testrunnerToCloneFromAzureDevOps.ts index 2a2769e3e..25efed620 100644 --- a/Extensions/WikiPDFExport/WikiPDFExportTask/test/testrunnerToCloneFromAzureDevOps.ts +++ b/Extensions/WikiPDFExport/WikiPDFExportTask/test/testrunnerToCloneFromAzureDevOps.ts @@ -21,6 +21,7 @@ const password = ""; const repo = "dev.azure.com/richardfennell/Git%20project/_git/Git-project.wiki"; const localpath = "c:\\tmp\\test\\repo"; +const rootExportPath = "c:\\tmp\\test\\repo"; const injectExtraHeaders = false; const branch = ""; const protocol = "https"; @@ -44,5 +45,6 @@ ExportRun( user, password, injectExtraHeader, - branch + branch, + rootExportPath ); diff --git a/Extensions/WikiPDFExport/WikiPDFExportTask/test/testrunnerToCloneFromGitHub.ts b/Extensions/WikiPDFExport/WikiPDFExportTask/test/testrunnerToCloneFromGitHub.ts index 89a3dd66f..c4ea72dd6 100644 --- a/Extensions/WikiPDFExport/WikiPDFExportTask/test/testrunnerToCloneFromGitHub.ts +++ b/Extensions/WikiPDFExport/WikiPDFExportTask/test/testrunnerToCloneFromGitHub.ts @@ -17,6 +17,7 @@ const password = ""; const repo = "github.com/rfennell/demorepo.wiki"; const localpath = "c:\\tmp\\test\\repo"; +const rootExportPath = "c:\\tmp\\test\\repo"; const injectExtraHeaders = false; const branch = ""; const protocol = "https"; @@ -40,5 +41,6 @@ ExportRun( user, password, injectExtraHeader, - branch + branch, + rootExportPath ); diff --git a/Extensions/WikiPDFExport/azure-pipelines-build.yml b/Extensions/WikiPDFExport/azure-pipelines-build.yml index c215abbe5..59d5f6917 100644 --- a/Extensions/WikiPDFExport/azure-pipelines-build.yml +++ b/Extensions/WikiPDFExport/azure-pipelines-build.yml @@ -176,7 +176,7 @@ stages: repo: 'https://dev.azure.com/richardfennell/GitHub/_git/GitHub.wiki' useAgentToken: true outputFile: '$(Build.ArtifactStagingDirectory)\PDF\AzrepoFilter.pdf' - localpath: '$(System.DefaultWorkingDirectory)\repo\folder' + rootExportPath: '$(System.DefaultWorkingDirectory)\repo\folder' - task: richardfennellBM.BM-VSTS-WikiPDFExport-Tasks-DEV.WikiPDFExportTask.WikiPdfExportTask@1 displayName: 'Export Azure DevOps WIKI without downloading tool' condition: succeededOrFailed() diff --git a/Extensions/WikiPDFExport/readme.md b/Extensions/WikiPDFExport/readme.md index efcd0bc6f..e192a75ba 100644 --- a/Extensions/WikiPDFExport/readme.md +++ b/Extensions/WikiPDFExport/readme.md @@ -18,7 +18,8 @@ __Note:__ If you see problems such as `Error: spawn git ENOENT` when cloning a r #### General - CloneRepo - a boolean flag whether to clone the repo or not - Repo - The repo URL to update e.g in the form **https://dev.azure.com/richardfennell/Git%20project/_git/Git-project.wiki** (see the URL section below as to how to find this URL) -- LocalPath - The path to the root of the cloned the repo if exporting the whole repo, a folder within the repo to export part of the repo or finally the folder containing a single file to export. For this final option the filename must be specified below +- LocalPath - The path to clone the repo into +- RootExportPath - The path to the root of the cloned the repo if exporting the whole repo, a folder within the repo to export part of the repo or finally the folder containing a single file to export. For this final option the filename must be specified below - SingleFile - Optional single file to export in the localPath folder e.g. page.md - ExtraParameters - Any optional extra as defined at [WikiPDFExport](https://github.com/MaxMelcher/AzureDevOps.WikiPDFExport/) you wish to pass to the command line tool - the task automatically managed the -p, -s, -c and -v parameters #### Git Clone Specific From 7450f430a59e0dd10c5f425e9002524fa038ecff Mon Sep 17 00:00:00 2001 From: Richard Fennell Date: Thu, 7 Jan 2021 17:02:42 +0000 Subject: [PATCH 4/5] Fixed empty check --- .../WikiPDFExport/WikiPDFExportTask/src/WikiPDFExportTask.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Extensions/WikiPDFExport/WikiPDFExportTask/src/WikiPDFExportTask.ts b/Extensions/WikiPDFExport/WikiPDFExportTask/src/WikiPDFExportTask.ts index c99957e5e..fbe2f076a 100644 --- a/Extensions/WikiPDFExport/WikiPDFExportTask/src/WikiPDFExportTask.ts +++ b/Extensions/WikiPDFExport/WikiPDFExportTask/src/WikiPDFExportTask.ts @@ -29,7 +29,8 @@ var workingFolder = tl.getVariable("Agent.TempDirectory"); var rootExportPath = tl.getVariable("rootExportPath"); // make sure that we support older configs where these two parameter were a single setting -if (rootExportPath.trim().length === 0) { +if (!rootExportPath) { + console.log(`Defaulting variable rootExportPath as not defined`); rootExportPath = localpath; } From e5c5a9429c204f868eaf70fb70fc93fffd3de307 Mon Sep 17 00:00:00 2001 From: Richard Fennell Date: Thu, 7 Jan 2021 17:21:35 +0000 Subject: [PATCH 5/5] Fix the paths --- .../WikiPDFExport/WikiPDFExportTask/src/WikiPDFExportTask.ts | 2 +- Extensions/WikiPDFExport/azure-pipelines-build.yml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Extensions/WikiPDFExport/WikiPDFExportTask/src/WikiPDFExportTask.ts b/Extensions/WikiPDFExport/WikiPDFExportTask/src/WikiPDFExportTask.ts index fbe2f076a..26bde5fb1 100644 --- a/Extensions/WikiPDFExport/WikiPDFExportTask/src/WikiPDFExportTask.ts +++ b/Extensions/WikiPDFExport/WikiPDFExportTask/src/WikiPDFExportTask.ts @@ -26,7 +26,7 @@ var injectExtraHeader = tl.getBoolInput("injectExtraHeader"); var cloneRepo = tl.getBoolInput("cloneRepo"); var overrideExePath = tl.getInput("overrideExePath"); var workingFolder = tl.getVariable("Agent.TempDirectory"); -var rootExportPath = tl.getVariable("rootExportPath"); +var rootExportPath = tl.getInput("rootExportPath"); // make sure that we support older configs where these two parameter were a single setting if (!rootExportPath) { diff --git a/Extensions/WikiPDFExport/azure-pipelines-build.yml b/Extensions/WikiPDFExport/azure-pipelines-build.yml index 59d5f6917..6a4776037 100644 --- a/Extensions/WikiPDFExport/azure-pipelines-build.yml +++ b/Extensions/WikiPDFExport/azure-pipelines-build.yml @@ -176,7 +176,8 @@ stages: repo: 'https://dev.azure.com/richardfennell/GitHub/_git/GitHub.wiki' useAgentToken: true outputFile: '$(Build.ArtifactStagingDirectory)\PDF\AzrepoFilter.pdf' - rootExportPath: '$(System.DefaultWorkingDirectory)\repo\folder' + localpath: '$(System.DefaultWorkingDirectory)\repopartial' + rootExportPath: '$(System.DefaultWorkingDirectory)\repopartial\folder' - task: richardfennellBM.BM-VSTS-WikiPDFExport-Tasks-DEV.WikiPDFExportTask.WikiPdfExportTask@1 displayName: 'Export Azure DevOps WIKI without downloading tool' condition: succeededOrFailed()