Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for partial export #927

Merged
merged 5 commits into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ export async function ExportRun (
user,
password,
injectExtraHeader,
branch
branch,
rootExportPath
) {

if (fs.existsSync(exeCmd)) {
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,20 @@ var injectExtraHeader = tl.getBoolInput("injectExtraHeader");
var cloneRepo = tl.getBoolInput("cloneRepo");
var overrideExePath = tl.getInput("overrideExePath");
var workingFolder = tl.getVariable("Agent.TempDirectory");
var rootExportPath = tl.getInput("rootExportPath");

// make sure that we support older configs where these two parameter were a single setting
if (!rootExportPath) {
console.log(`Defaulting variable rootExportPath as not defined`);
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}]`);
Expand All @@ -55,7 +63,8 @@ GetExePath(
user,
password,
injectExtraHeader,
branch
branch,
rootExportPath
);
} else {
logError(`Cannot find the 'azuredevops-export-wiki.exe' tool`);
Expand Down
10 changes: 9 additions & 1 deletion Extensions/WikiPDFExport/WikiPDFExportTask/task/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,15 @@
"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 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"
},
{
"name": "outputFile",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,5 +37,6 @@ ExportRun(
user,
password,
injectExtraHeader,
branch
branch,
rootExportPath
);
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand All @@ -35,5 +37,6 @@ ExportRun(
user,
password,
injectExtraHeader,
branch
branch,
rootExportPath
);
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const password = "<PAT>";

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";
Expand All @@ -44,5 +45,6 @@ ExportRun(
user,
password,
injectExtraHeader,
branch
branch,
rootExportPath
);
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const password = "<PAT>";
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";
Expand All @@ -40,5 +41,6 @@ ExportRun(
user,
password,
injectExtraHeader,
branch
branch,
rootExportPath
);
10 changes: 10 additions & 0 deletions Extensions/WikiPDFExport/azure-pipelines-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,16 @@ 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\AzrepoFilter.pdf'
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()
Expand Down
3 changes: 2 additions & 1 deletion Extensions/WikiPDFExport/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 clone the repo into and hence the folder structure containing the file(s) to export
- 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
Expand Down