Skip to content

Commit

Permalink
fixed cannot find package.json error
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Duda committed May 24, 2024
1 parent 76713f0 commit c70012e
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scope-tags",
"version": "0.3.1",
"version": "0.3.2",
"description": "Output human readable test scope report for QA",
"main": "dist/scope.js",
"types": "dist/scope.d.ts",
Expand Down
2 changes: 0 additions & 2 deletions src/Commands/runFindReferencesCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export function runFindReferencesCommand(args: Array<string>, root: string) {

const tsReferenceFinder = new TSReferenceFinder(root, "tsconfig.json");

debugger;

const references = tsReferenceFinder.findReferences(filePath, Relevancy.HIGH);

if (!references.length) {
Expand Down
5 changes: 4 additions & 1 deletion src/Commands/runReportForCommitCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { TagsDefinitionFile } from "../Scope/TagsDefinitionFile";
import { fileExists } from "../FileSystem/fileSystemUtils";
import { RelevancyManager } from "../Relevancy/RelevancyManager";
import { ADFValidator } from "../Report/ADFValidator";
import { JiraBuilder } from "../Report/JiraBuilder";

export function runReportForCommitCommand(args: Array<string>, root: string) {
// Checks if all files from the commit are present in database (or excluded)
Expand Down Expand Up @@ -56,7 +57,9 @@ export function runReportForCommitCommand(args: Array<string>, root: string) {
return;
}

return generator.getReportAsJiraComment(report, true);
const jiraBuilder = new JiraBuilder();

return generator.getReportAsJiraComment(report, jiraBuilder, true);
}).then(async commentReport => {
if (!commentReport) {
return;
Expand Down
5 changes: 4 additions & 1 deletion src/Commands/runReportForCommitListCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { RelevancyManager } from "../Relevancy/RelevancyManager";
import { ConfigurationProperty, Logger } from "../Logger/Logger";
import { ConfigFile } from "../Scope/ConfigFile";
import { ADFValidator } from "../Report/ADFValidator";
import { JiraBuilder } from "../Report/JiraBuilder";

const os = require("os");

Expand Down Expand Up @@ -100,7 +101,9 @@ export async function runReportForCommitListCommand(args: Array<string>, root: s
continue;
}

const commentReport = generator.getReportAsJiraComment(report, false);
const jiraBuilder = new JiraBuilder();

const commentReport = generator.getReportAsJiraComment(report, jiraBuilder, false);
const commentReportADF = `{adf:display=block}${commentReport.comment}{adf}`;

console.log(`[Scope tags]: Validating ADF of report for issue '${issue}'...'`);
Expand Down
4 changes: 2 additions & 2 deletions src/Report/JiraBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ReferencedFileInfo } from "../References/IReferenceFinder";
import { TagIdentifier } from "../Scope/FileTagsDatabase";
import { FileInfo } from "./ReportGenerator";
import { Relevancy } from "../Relevancy/Relevancy";
import { Utils } from "../Scope/Utils";
import { getScriptVersion } from "../scope";

export type TagIdentifierWithRelevancy = TagIdentifier & {
relevancy: Relevancy;
Expand Down Expand Up @@ -60,7 +60,7 @@ export class JiraBuilder {
adfDocument: string,
comment: string
} {
let tableTitle = `'${projectName}' scope tags v${Utils.getScriptVersion()}${formatDate(date, "Europe/Warsaw")}`;
let tableTitle = `'${projectName}' scope tags v${getScriptVersion()}${formatDate(date, "Europe/Warsaw")}`;
tableTitle += buildTag ? ` │ ${buildTag}` : "";

let reportTable = {
Expand Down
3 changes: 1 addition & 2 deletions src/Report/ReportGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ export class ReportGenerator {
}
};

public getReportAsJiraComment(report: Report, printToConsole = false) {
public getReportAsJiraComment(report: Report, jiraBuilder: JiraBuilder, printToConsole = false) {
const finalReportTableData: Array<ReportTableRow> = report.allModules
.map(moduleReport => {
const modulesAndTagsInfo = this._getReferencedTags(moduleReport);
Expand Down Expand Up @@ -375,7 +375,6 @@ export class ReportGenerator {
unusedReferences: untaggedFilesTableRowInfo.unusedReferences,
};

const jiraBuilder = new JiraBuilder();
return jiraBuilder.parseReport(
finalReportTableData,
untaggedFilesTableRow,
Expand Down
4 changes: 0 additions & 4 deletions src/Scope/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,4 @@ export class Utils {
public static getEnumKeyByEnumValue(enumObj: any, value: any) {
return Object.keys(enumObj).find(x => enumObj[x] === value);
}

public static getScriptVersion(): string {
return require('../package.json').version;
}
}
11 changes: 7 additions & 4 deletions src/scope.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env node
import { runUntagCommand } from "./Commands/runUntagCommand";
#!/usr/bin/env nodeimport { runUntagCommand } from "./Commands/runUntagCommand";
import { runCommitCommand } from "./Commands/runCommitCommand";
import { runAddCommand } from "./Commands/runAddCommand";
import { runVerifyCommand } from "./Commands/runVerifyCommand";
Expand All @@ -14,7 +13,7 @@ import { getGitProjectRoot } from "./Git/Project";
import { runSkipVerificationForCommits } from "./Commands/runSkipVerificationAndPushCommand";
import { runLogCommitCommand } from "./Commands/runLogCommitCommand";
import { runSeeCommand } from "./Commands/runSeeCommand";
import { Utils } from "./Scope/Utils";
import { runUntagCommand } from "./Commands/runUntagCommand";

// Will be needed to get output from script
const [, , ...args] = process.argv;
Expand All @@ -30,7 +29,7 @@ if (!root) {

switch (args[0]) {
case "--version": {
console.log(Utils.getScriptVersion());
console.log(getScriptVersion());
break;
}
case "--tag": {
Expand Down Expand Up @@ -89,4 +88,8 @@ switch (args[0]) {
runStartCommandLineInterfaceCommand(args, root);
break;
}
}

export function getScriptVersion(): string {
return require('../package.json').version;
}

0 comments on commit c70012e

Please sign in to comment.