Skip to content

Commit

Permalink
dist update
Browse files Browse the repository at this point in the history
  • Loading branch information
arturcic committed Dec 10, 2024
1 parent bc3a470 commit a9a4d49
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 225 deletions.
134 changes: 15 additions & 119 deletions dist/tools/libs/gitreleasemanager.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from 'path';
import { S as SettingsProvider, D as DotnetTool } from './tools.mjs';
import { S as SettingsProvider, D as DotnetTool, R as RunnerBase } from './tools.mjs';
import 'node:crypto';
import 'node:fs/promises';
import 'node:os';
Expand Down Expand Up @@ -204,12 +204,13 @@ class GitReleaseManagerTool extends DotnetTool {
}
}

class Runner {
class Runner extends RunnerBase {
constructor(buildAgent) {
super(buildAgent);
this.buildAgent = buildAgent;
this.gitReleaseManagerTool = new GitReleaseManagerTool(this.buildAgent);
this.tool = new GitReleaseManagerTool(this.buildAgent);
}
gitReleaseManagerTool;
tool;
async run(command) {
switch (command) {
case "setup":
Expand All @@ -229,133 +230,28 @@ class Runner {
}
}
async setup() {
try {
this.disableTelemetry();
this.buildAgent.debug("Installing GitReleaseManager");
const toolPath = await this.gitReleaseManagerTool.install();
const pathVariable = this.gitReleaseManagerTool.toolPathVariable;
this.buildAgent.info(`Set ${pathVariable} to ${toolPath}`);
this.buildAgent.setVariable(pathVariable, toolPath);
this.buildAgent.setSucceeded("GitReleaseManager installed successfully", true);
return {
code: 0
};
} catch (error) {
if (error instanceof Error) {
this.buildAgent.setFailed(error.message, true);
}
return {
code: -1,
error
};
}
return this.safeExecute(async () => {
await this.tool.install();
return { code: 0 };
}, "GitReleaseManager setup successfully");
}
async create() {
try {
this.disableTelemetry();
this.buildAgent.debug("Creating release");
const result = await this.gitReleaseManagerTool.create();
this.buildAgent.setSucceeded("GitReleaseManager created release successfully", true);
return result;
} catch (error) {
if (error instanceof Error) {
this.buildAgent.setFailed(error.message, true);
}
return {
code: -1,
error
};
}
return this.safeExecute(async () => await this.tool.create(), "GitReleaseManager created release successfully");
}
async discard() {
try {
this.disableTelemetry();
this.buildAgent.debug("Discarding release");
const result = await this.gitReleaseManagerTool.discard();
this.buildAgent.setSucceeded("GitReleaseManager discarded release successfully", true);
return result;
} catch (error) {
if (error instanceof Error) {
this.buildAgent.setFailed(error.message, true);
}
return {
code: -1,
error
};
}
return this.safeExecute(async () => await this.tool.discard(), "GitReleaseManager discarded release successfully");
}
async close() {
try {
this.disableTelemetry();
this.buildAgent.debug("Closing release");
const result = await this.gitReleaseManagerTool.close();
this.buildAgent.setSucceeded("GitReleaseManager closed release successfully", true);
return result;
} catch (error) {
if (error instanceof Error) {
this.buildAgent.setFailed(error.message, true);
}
return {
code: -1,
error
};
}
return this.safeExecute(async () => await this.tool.close(), "GitReleaseManager closed release successfully");
}
async open() {
try {
this.disableTelemetry();
this.buildAgent.debug("Opening release");
const result = await this.gitReleaseManagerTool.open();
this.buildAgent.setSucceeded("GitReleaseManager opened release successfully", true);
return result;
} catch (error) {
if (error instanceof Error) {
this.buildAgent.setFailed(error.message, true);
}
return {
code: -1,
error
};
}
return this.safeExecute(async () => await this.tool.open(), "GitReleaseManager opened release successfully");
}
async publish() {
try {
this.disableTelemetry();
this.buildAgent.debug("Publishing release");
const result = await this.gitReleaseManagerTool.publish();
this.buildAgent.setSucceeded("GitReleaseManager published release successfully", true);
return result;
} catch (error) {
if (error instanceof Error) {
this.buildAgent.setFailed(error.message, true);
}
return {
code: -1,
error
};
}
return this.safeExecute(async () => await this.tool.publish(), "GitReleaseManager published release successfully");
}
async addAsset() {
try {
this.disableTelemetry();
this.buildAgent.debug("Adding asset to release");
const result = await this.gitReleaseManagerTool.addAsset();
this.buildAgent.setSucceeded("GitReleaseManager added assets to release successfully", true);
return result;
} catch (error) {
if (error instanceof Error) {
this.buildAgent.setFailed(error.message, true);
}
return {
code: -1,
error
};
}
}
disableTelemetry() {
this.buildAgent.info(`Running on: '${this.buildAgent.agentName}'`);
this.buildAgent.debug("Disabling telemetry");
this.gitReleaseManagerTool.disableTelemetry();
return this.safeExecute(async () => await this.tool.addAsset(), "GitReleaseManager added assets to release successfully");
}
}

Expand Down
2 changes: 1 addition & 1 deletion dist/tools/libs/gitreleasemanager.mjs.map

Large diffs are not rendered by default.

128 changes: 29 additions & 99 deletions dist/tools/libs/gitversion.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { S as SettingsProvider, D as DotnetTool, k as keysOf } from './tools.mjs';
import { S as SettingsProvider, D as DotnetTool, k as keysOf, R as RunnerBase } from './tools.mjs';
import 'node:crypto';
import 'node:fs/promises';
import 'node:os';
Expand Down Expand Up @@ -93,7 +93,7 @@ class GitVersionTool extends DotnetTool {
return await super.getRepoPath(settings.targetPath);
}
async getExecuteArguments(workDir, options) {
const args = [workDir, "/output", "json"];
const args = [workDir, "/output", "json", "/l", "console"];
const {
useConfigFile,
disableCache,
Expand Down Expand Up @@ -211,12 +211,13 @@ class GitVersionTool extends DotnetTool {
}
}

class Runner {
class Runner extends RunnerBase {
constructor(buildAgent) {
super(buildAgent);
this.buildAgent = buildAgent;
this.gitVersionTool = new GitVersionTool(this.buildAgent);
this.tool = new GitVersionTool(this.buildAgent);
}
gitVersionTool;
tool;
async run(command) {
switch (command) {
case "setup":
Expand All @@ -228,109 +229,38 @@ class Runner {
}
}
async setup() {
try {
this.disableTelemetry();
this.buildAgent.debug("Installing GitVersion");
const toolPath = await this.gitVersionTool.install();
const pathVariable = this.gitVersionTool.toolPathVariable;
this.buildAgent.info(`Set ${pathVariable} to ${toolPath}`);
this.buildAgent.setVariable(pathVariable, toolPath);
this.buildAgent.setSucceeded("GitVersion installed successfully", true);
return {
code: 0
};
} catch (error) {
if (error instanceof Error) {
this.buildAgent.setFailed(error.message, true);
}
return {
code: -1,
error
};
}
return this.safeExecute(async () => {
await this.tool.install();
return { code: 0 };
}, "GitVersion setup successfully");
}
async execute() {
try {
this.disableTelemetry();
this.buildAgent.info("Executing GitVersion");
const result = await this.gitVersionTool.executeJson();
if (result.code === 0) {
this.buildAgent.info("GitVersion executed successfully");
const stdout = result.stdout;
this.buildAgent.info("GitVersion output:");
this.buildAgent.info("-------------------");
this.buildAgent.info(stdout);
this.buildAgent.info("-------------------");
this.buildAgent.debug("Parsing GitVersion output");
if (stdout.lastIndexOf("{") === -1 || stdout.lastIndexOf("}") === -1) {
this.buildAgent.debug("GitVersion output is not valid JSON");
this.buildAgent.setFailed("GitVersion output is not valid JSON", true);
return {
code: -1,
error: new Error("GitVersion output is not valid JSON")
};
} else {
const jsonOutput = stdout.substring(stdout.lastIndexOf("{"), stdout.lastIndexOf("}") + 1);
const gitVersionOutput = JSON.parse(jsonOutput);
this.gitVersionTool.writeGitVersionToAgent(gitVersionOutput);
this.buildAgent.setSucceeded("GitVersion executed successfully", true);
return result;
}
} else {
this.buildAgent.debug("GitVersion failed");
const error = result.error;
if (error instanceof Error) {
this.buildAgent.setFailed(error.message, true);
}
return result;
}
} catch (error) {
if (error instanceof Error) {
this.buildAgent.setFailed(error.message, true);
}
return {
code: -1,
error
};
}
return this.safeExecute(async () => {
const result = await this.tool.executeJson();
this.buildAgent.debug("Parsing GitVersion output");
return this.processGitVersionOutput(result);
}, "GitVersion executed successfully");
}
async command() {
try {
this.disableTelemetry();
this.buildAgent.info("Executing GitVersion");
const result = await this.gitVersionTool.executeCommand();
if (result.code === 0) {
this.buildAgent.info("GitVersion executed successfully");
const stdout = result.stdout;
this.buildAgent.info("GitVersion output:");
this.buildAgent.info("-------------------");
this.buildAgent.info(stdout);
this.buildAgent.info("-------------------");
this.buildAgent.setSucceeded("GitVersion executed successfully", true);
return result;
} else {
this.buildAgent.debug("GitVersion failed");
const error = result.error;
if (error instanceof Error) {
this.buildAgent.setFailed(error.message, true);
}
return result;
}
} catch (error) {
if (error instanceof Error) {
this.buildAgent.setFailed(error.message, true);
}
return this.safeExecute(async () => await this.tool.executeCommand(), "GitVersion executed successfully");
}
processGitVersionOutput(result) {
const stdout = result.stdout;
if (stdout.lastIndexOf("{") === -1 || stdout.lastIndexOf("}") === -1) {
this.buildAgent.debug("GitVersion output is not valid JSON");
this.buildAgent.setFailed("GitVersion output is not valid JSON", true);
return {
code: -1,
error
error: new Error("GitVersion output is not valid JSON")
};
} else {
const jsonOutput = stdout.substring(stdout.lastIndexOf("{"), stdout.lastIndexOf("}") + 1);
const gitVersionOutput = JSON.parse(jsonOutput);
this.tool.writeGitVersionToAgent(gitVersionOutput);
this.buildAgent.setSucceeded("GitVersion executed successfully", true);
return result;
}
}
disableTelemetry() {
this.buildAgent.info(`Running on: '${this.buildAgent.agentName}'`);
this.buildAgent.debug("Disabling telemetry");
this.gitVersionTool.disableTelemetry();
}
}

export { Runner };
Expand Down
2 changes: 1 addition & 1 deletion dist/tools/libs/gitversion.mjs.map

Large diffs are not rendered by default.

Loading

0 comments on commit a9a4d49

Please sign in to comment.