oss-mariner
Advanced tools
Comparing version 0.3.1-alpha to 0.3.2-alpha
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DataFetcher = void 0; | ||
class DataFetcher { | ||
@@ -4,0 +5,0 @@ process(requestParams, ownerDataCollection, requestQueue) { |
@@ -15,2 +15,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.DependencyDetailsRetriever = void 0; | ||
const moment_1 = __importDefault(require("moment")); | ||
@@ -17,0 +18,0 @@ const request_queue_1 = require("./request-queue"); |
@@ -0,1 +1,2 @@ | ||
import { Config } from './config'; | ||
export interface Edge { | ||
@@ -14,2 +15,4 @@ node: GitHubIssue; | ||
export declare class GitHubIssueFetcher { | ||
private readonly config; | ||
constructor(config: Config); | ||
fetchMatchingIssues(token: string, label: string, repositoryIdentifiers: string[]): Promise<GitHubIssue[]>; | ||
@@ -16,0 +19,0 @@ private splitArray; |
@@ -12,2 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GitHubIssueFetcher = void 0; | ||
const graphql_1 = require("@octokit/graphql"); | ||
@@ -51,6 +52,9 @@ const tab_level_logger_1 = require("./tab-level-logger"); | ||
class GitHubIssueFetcher { | ||
constructor(config) { | ||
this.config = config; | ||
} | ||
fetchMatchingIssues(token, label, repositoryIdentifiers) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const pageSize = 100; | ||
const numberOfReposPerCall = 1000; | ||
const numberOfReposPerCall = this.config.numberOfReposPerCall; | ||
const reposForEachCall = this.splitArray(repositoryIdentifiers, numberOfReposPerCall); | ||
@@ -57,0 +61,0 @@ const edgeArray = []; |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FetchHttpClient = void 0; | ||
const node_fetch_1 = __importDefault(require("node-fetch")); | ||
@@ -8,0 +9,0 @@ const tab_level_logger_1 = require("./tab-level-logger"); |
@@ -0,1 +1,2 @@ | ||
import { Config } from './config'; | ||
export interface Issue { | ||
@@ -8,7 +9,8 @@ title: string; | ||
export declare class IssueFinder { | ||
private readonly config; | ||
private readonly fetcher; | ||
constructor(); | ||
findIssues(token: string, labels: string[], repositoryIdentifiers: string[]): Promise<Map<string, Issue[]>>; | ||
constructor(config: Config); | ||
findIssues(token: string, repositoryIdentifiers: string[]): Promise<Map<string, Issue[]>>; | ||
private convertFromGitHubIssue; | ||
private omitDuplicates; | ||
} |
@@ -12,11 +12,13 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.IssueFinder = void 0; | ||
const gitHubIssueFetcher_1 = require("./gitHubIssueFetcher"); | ||
class IssueFinder { | ||
constructor() { | ||
this.fetcher = new gitHubIssueFetcher_1.GitHubIssueFetcher(); | ||
constructor(config) { | ||
this.config = config; | ||
this.fetcher = new gitHubIssueFetcher_1.GitHubIssueFetcher(this.config); | ||
} | ||
findIssues(token, labels, repositoryIdentifiers) { | ||
findIssues(token, repositoryIdentifiers) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const gitHubIssues = []; | ||
for (const label of labels) { | ||
for (const label of this.config.labelsToSearch) { | ||
const result = yield this.fetcher.fetchMatchingIssues(token, label, repositoryIdentifiers); | ||
@@ -23,0 +25,0 @@ gitHubIssues.push(...result); |
export { DependencyDetailsRetriever } from '../dependency-details-retriever'; | ||
export { readConfigFile, Config } from '../config'; | ||
export { Issue, IssueFinder } from '../issueFinder'; | ||
export { Logger, getLogger, setLogger } from '../tab-level-logger'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var dependency_details_retriever_1 = require("../dependency-details-retriever"); | ||
exports.DependencyDetailsRetriever = dependency_details_retriever_1.DependencyDetailsRetriever; | ||
Object.defineProperty(exports, "DependencyDetailsRetriever", { enumerable: true, get: function () { return dependency_details_retriever_1.DependencyDetailsRetriever; } }); | ||
var config_1 = require("../config"); | ||
Object.defineProperty(exports, "readConfigFile", { enumerable: true, get: function () { return config_1.readConfigFile; } }); | ||
var issueFinder_1 = require("../issueFinder"); | ||
exports.IssueFinder = issueFinder_1.IssueFinder; | ||
Object.defineProperty(exports, "IssueFinder", { enumerable: true, get: function () { return issueFinder_1.IssueFinder; } }); | ||
var tab_level_logger_1 = require("../tab-level-logger"); | ||
exports.getLogger = tab_level_logger_1.getLogger; | ||
exports.setLogger = tab_level_logger_1.setLogger; | ||
Object.defineProperty(exports, "getLogger", { enumerable: true, get: function () { return tab_level_logger_1.getLogger; } }); | ||
Object.defineProperty(exports, "setLogger", { enumerable: true, get: function () { return tab_level_logger_1.setLogger; } }); |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OwnerDataCollection = void 0; | ||
const fs_1 = __importDefault(require("fs")); | ||
@@ -8,0 +9,0 @@ const tab_level_logger_1 = require("./tab-level-logger"); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RequestQueue = exports.RequesteQueueEntry = void 0; | ||
const utils_1 = require("./utils"); | ||
@@ -4,0 +5,0 @@ const tab_level_logger_1 = require("./tab-level-logger"); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TabDepthLogger = exports.setLogger = exports.getLogger = void 0; | ||
const TAB = ' '; | ||
@@ -4,0 +5,0 @@ class ConsoleLogger { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OrderedMap = exports.sleep = void 0; | ||
function sleep(ms) { | ||
@@ -4,0 +5,0 @@ return new Promise((resolve) => setTimeout(resolve, ms)); |
{ | ||
"name": "oss-mariner", | ||
"version": "0.3.1-alpha", | ||
"version": "0.3.2-alpha", | ||
"description": "A node.js library for analyzing open source library dependencies", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/mariner/index.js", |
123
README.md
@@ -10,4 +10,3 @@ # Mariner | ||
Mariner takes an input list of dependencies, fetches details about them from GitHub, | ||
and outputs a file containing funding information for each project owner, and a list | ||
of issues for each project. | ||
and outputs a file containing a list of issues for each project. | ||
@@ -17,4 +16,11 @@ NOTE: This library is in the experimental stage, so expect breaking changes | ||
### Renaming the default branch from master | ||
### REST vs. GraphQL | ||
The first couple alpha versions of Mariner only supported calls via GitHub's REST API. More | ||
recently, we added the ability to invoke GitHub's GraphQL API. The GraphQL API is hundreds of | ||
times faster, so the REST-related calls are now deprecated, and will be removed "soon". The | ||
GraphQL approach is shown in the `runFasterCode.ts` example. | ||
### Plans to rename the default branch from master | ||
We anticipate renaming the default branch of this repository from `master` to `main`. | ||
@@ -34,72 +40,20 @@ GitHub is planning to have a smooth easy conversion process/tool for later this year. | ||
1. Create a new project folder and use `npm init` to make it a node project. | ||
1. Copy the contents of `runFasterCode.ts` into `index.js` in the new project. | ||
1.1. <https://github.com/indeedeng/Mariner/blob/master/examples/runFasterCode.ts> | ||
1. Comment out the existing line that imports mariner. | ||
1. Uncomment the line saying how mariner would normally be imported. | ||
1. Convert the TypeScript code to JavaScript by | ||
1.1. Remove the `public` keywords from class members. | ||
1.1. Remove the `implements Xxxx` from the FancyLogger class declaration. | ||
1.1. Remove all the type declarations (like `: string`). | ||
1. Replace the path.join lines with simple hard-coded filenames: `exampleData.json` and `output.json`. | ||
1. Create an exampleData.json file or copy it in from Mariner. | ||
1. Copy the contents of `runFasterCode.ts` into `index.js` and copy `config.json`, `exampleData.json` | ||
in the new project. | ||
- <https://github.com/indeedeng/Mariner/blob/master/examples/runFasterCode.ts> | ||
- <https://github.com/indeedeng/Mariner/blob/master/examples/config.json> | ||
- <https://github.com/indeedeng/Mariner/blob/master/examples/exampleData.json> | ||
1. In `index.js` comment out the existing line that imports mariner. | ||
1. Also in `index.js` uncomment the line saying how mariner would normally be imported. | ||
1. Mariner supports TypeScript, but we don't have step-by-step instructions for the TypeScript example. | ||
For now, you can convert the runFasterCode.ts example code to JavaScript: | ||
- Remove the `public` keywords from class members. | ||
- Remove the `implements Xxxx` from the FancyLogger class declaration. | ||
- Remove all the type declarations (like `: string`). | ||
1. Run `npm install oss-mariner` | ||
1. Add `"type": "module"` to `package.json`. | ||
1. Add `"type": "module"` to `package.json` to allow using "import" rather than "require". | ||
1. Run `node index.js`. | ||
### More details (possibly outdated) | ||
### Input File Format | ||
Mariner can be called from Javascript or from Typescript. You can see an example here: | ||
<https://github.com/indeedeng/Mariner/blob/master/examples/runOldCode.ts> | ||
Mariner is in transition from the old way of accessing GitHub data (REST) to the new way (GraphQL) | ||
To invoke mariner using the new GraphQL code you can see an example here: | ||
<https://github.com/indeedeng/Mariner/blob/master/examples/runFasterCode.ts> | ||
If you are using mariner with the new GraphQL code, Invoke the finder(), passing the | ||
appropiate parameters in finder.findIssues(), | ||
``` | ||
const token = getFromEnvOrThrow('MARINER_GITHUB_TOKEN'); // from an environment variable | ||
const inputFilePath = process.env.MARINER_INPUT_FILE_PATH || path.join(__dirname, '..', '..', 'examples', 'exampleData.json'); | ||
const outputFilePath = process.env.MARINER_OUTPUT_FILE_PATH || path.join(__dirname, '..', '..', 'examples', 'output.json'); | ||
const finder = new IssueFinder(logger); | ||
finder.findIssues(token, labels, repositoryLookupName) | ||
.then((issues) => { | ||
let issueCount = 0; | ||
issues.forEach((issuesForRepo) => { | ||
issueCount += issuesForRepo.length; | ||
}); | ||
convertToRecord(issues); | ||
logger.info(`Found ${issueCount} issues in ${issues.size} projects\n`); | ||
logger.info(`Saved issue results to: ${outputFilePath}`); | ||
}) | ||
.catch((err) => { | ||
logger.error(err.message); | ||
console.log(err); | ||
}); | ||
``` | ||
If you are using the examples/runOldCode.ts file, (using the old REST code that is very slow) | ||
invoke the DependencyDetailsRetriever.run() method, passing appropriate parameters: | ||
``` | ||
const ddr = new DependencyDetailsRetriever(); | ||
const githubToken = Process.env.GITHUB_TOKEN; // from an environment variable | ||
const inputFilePath = '<full path to your input file>'; | ||
const outputFilePath = '<full path to the file that ddr should create>'; | ||
const abbreviated = false; // OPTIONAL; default is false; true will exclude some dependencies | ||
ddr.run(githubToken, inputFilePath, outputFilePath, abbreviated); | ||
``` | ||
For both the runOldCode.ts and runFasterCode.ts files you must create a token. | ||
The GitHub token must be a valid personal access token. It does not require any permissions beyond | ||
the default, so when you create it you can leave all the boxes unchecked. Be careful not to | ||
share your token with anyone. If it gets exposed, revoke it and create a replacement. | ||
See https://github.com/settings/tokens/new for how to create a token. | ||
The input file is a JSON file in the format: | ||
@@ -115,2 +69,4 @@ | ||
### Output File Format | ||
The output file is a JSON file in the format: | ||
@@ -121,2 +77,26 @@ | ||
## Token | ||
To run Mariner, you must create a token. The GitHub token must be a valid personal access token. | ||
It does not require any permissions beyond the default, so when you create it you can leave all | ||
the boxes unchecked. Be careful not to share your token with anyone. If it gets exposed, revoke | ||
it and create a replacement. | ||
See <https://github.com/settings/tokens/new> for how to create a token. | ||
### More details (possibly outdated) | ||
Mariner can be called from Javascript or from Typescript. You can see an example here: | ||
<https://github.com/indeedeng/Mariner/blob/master/examples/runOldCode.ts> | ||
Mariner is in transition from the old way of accessing GitHub data (REST) to the new way (GraphQL) | ||
To invoke mariner using the new GraphQL code, Invoke the finder(), passing the | ||
appropiate parameters in finder.findIssues() you can see an example here: | ||
<https://github.com/indeedeng/Mariner/blob/master/examples/runFasterCode.ts> | ||
If you are using the `examples/runOldCode.ts file`, (using the old REST code that is very slow) | ||
invoke the DependencyDetailsRetriever.run() method, passing appropriate parameters. Please | ||
see the [examples/runOldCode.ts](https://github.com/indeedeng/Mariner/blob/master/examples/runOldCode.ts) file | ||
for more information. | ||
We don't recommend using the `abbreviated` feature. | ||
@@ -167,8 +147,9 @@ It will omit entries that have fewer than a hard-coded number of projects that depend on them. | ||
1. Run `npm install` to update package-lock.json | ||
- Search package-lock.json to be sure there are no references to 'nexus' | ||
1. Run `npm run build` and `npm run lint` to make sure there are no errors | ||
1. Submit and merge a PR to bump the version number | ||
1. Commit and push the changes, create a PR, have it approved, and merge it into the main branch | ||
1. Login to npm if you haven’t already: `npm login` | ||
1. Do a dry run to make sure the package looks good: `npm publish --dry-run` | ||
1. Publish: `npm publish` | ||
1. Verify: <https://www.npmjs.com/package/oss-mariner> | ||
1. Verify that the new version appears at: <https://www.npmjs.com/package/oss-mariner> | ||
@@ -175,0 +156,0 @@ ## Code of Conduct |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58643
25
920
157
2