@stoplight/analyzer
Discovery: Repo Analyzer
Last updated 10 days ago by marbemac .
UNLICENSED · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @stoplight/analyzer 
SYNC missed versions from official npm registry.

Discovery: Repo Analyzer (@stoplight/analyzer)

Maintainability Test Coverage

Overview

Analyzer will generate changes between two git commits. We will load in two commits, traverse the repositry and load any specifications into stoplight graph. With the two graphs we will find the modifid, deleted and added nodes between two commits.

The output of analyzing two commits will be inserted into postgres so that a stoplight user can query how a resouce changes over time. A Stoplight user should be able to understand how a http operation, http server, http service, model, and article change overtime. Discovery should enable teams to collebrate/iterate faster and more effiently.

This is going to be the backbone of Discovery.

Setting up Locally

  1. The Gitlab webhook that triggers an Analyzer Tasker Job should be setup automatically by the API. You can view your local webhooks by logging into your local gitlab instance as an admin and going to Admin Area (wrench icon) > System Hooks
  2. Get Tasker running. Make sure the REPO_ANALYZER_ROOT environment variable is set to the location of the analyzer repo on your computer and passed into the command to start Tasker. Analyzer code will be run by a Tasker job.
  3. Look at the Influx DB instructions on Tasker's README if you'd like to log metrics to your local Influx DB. If you don't set this up, no metrics will be logged.
  4. Get the API running.
  5. Make sure the 20190116182055_add_discovery_tables.rb database migration has successfully run on your local postgres database

Once all of this is successfully setup, when you make changes to spec files in next, they will be analyzed and processed into the postgres database.

Algorithm / Approach

  • Given one commmit hash(target).

    • get source commit hash by looking at the git history.
    • clone/checkout out the git repo at source commit.
    • clone/checkout out the git repo at target commit.
  • Create two graphs based on the folder location of source and target.

    • graphs will load plugings for json, yaml, file and oas nodes.

Find all modified and deleted http operations between commits.

  • Loop over all http operations in source graph.
    • search search for source http operation in target graph.
    • if operation is found in target graph, compare source and target node contents
      • if equal then the http operation was not changed between commits, so ignore node
      • if not equal then the http operation was changed between commits, so save node to return latter.
    • Else If source operation isn't found in target graph.
      • then it was removed between commits, so save node to return latter.

Find all new http operations between commits.

  • Loop over all http operations in target graph.

    • if target http operation doesn't exist in the source graph.
      • then it is a new http operation, so add to results
  • return results

Installation

Supported in modern browsers and node.

# latest stable
yarn add @stoplight/analyzer

Usage

import { Library } from "@stoplight/analyzer";

// ...example

Contributing

  1. Clone repo.
  2. Create / checkout feature/{name}, chore/{name}, or fix/{name} branch.
  3. Install deps: yarn.
  4. Make your changes.
  5. Run tests: yarn test.prod.
  6. Stage relevant files to git.
  7. Commit: yarn commit. NOTE: Commits that don't follow the conventional format will be rejected. yarn commit creates this format for you, or you can put it together manually and then do a regular git commit.
  8. Push: git push.
  9. Open PR targeting the develop branch.

Current Tags

  • 0.0.7-alpha.34                                ...           alpha (2 months ago)
  • 0.0.1-beta.7                                ...           beta (3 months ago)
  • 0.4.1                                ...           latest (10 days ago)

65 Versions

  • 0.4.1                                ...           10 days ago
  • 0.4.0                                ...           23 days ago
  • 0.3.1                                ...           a month ago
  • 0.3.0                                ...           a month ago
  • 0.2.7                                ...           a month ago
  • 0.2.6                                ...           a month ago
  • 0.2.5                                ...           a month ago
  • 0.2.4                                ...           a month ago
  • 0.2.3                                ...           a month ago
  • 0.2.2                                ...           a month ago
  • 0.2.1                                ...           a month ago
  • 0.2.0                                ...           a month ago
  • 0.1.0                                ...           2 months ago
  • 0.0.3                                ...           2 months ago
  • 0.0.2                                ...           2 months ago
  • 0.0.1                                ...           2 months ago
  • 0.0.7-alpha.34                                ...           2 months ago
  • 0.0.7-alpha.33                                ...           2 months ago
  • 0.0.7-alpha.32                                ...           2 months ago
  • 0.0.7-alpha.31                                ...           3 months ago
  • 0.0.1-beta.7                                ...           3 months ago
  • 0.0.7-alpha.30                                ...           3 months ago
  • 0.0.7-alpha.29                                ...           3 months ago
  • 0.0.1-beta.6                                ...           3 months ago
  • 0.0.7-alpha.28                                ...           3 months ago
  • 0.0.1-beta.5                                ...           3 months ago
  • 0.0.7-alpha.27                                ...           3 months ago
  • 0.0.1-beta.4                                ...           3 months ago
  • 0.0.7-alpha.26                                ...           3 months ago
  • 0.0.1-beta.3                                ...           3 months ago
  • 0.0.7-alpha.25                                ...           3 months ago
  • 0.0.7-alpha.24                                ...           3 months ago
  • 0.0.7-alpha.23                                ...           3 months ago
  • 0.0.1-beta.2                                ...           3 months ago
  • 0.0.7-alpha.22                                ...           3 months ago
  • 0.0.7-alpha.21                                ...           3 months ago
  • 0.0.7-alpha.20                                ...           3 months ago
  • 0.0.7-alpha.19                                ...           3 months ago
  • 0.0.7-alpha.18                                ...           3 months ago
  • 0.0.7-alpha.17                                ...           3 months ago
  • 0.0.7-alpha.16                                ...           3 months ago
  • 0.0.7-alpha.15                                ...           3 months ago
  • 0.0.7-alpha.14                                ...           3 months ago
  • 0.0.7-alpha.13                                ...           3 months ago
  • 0.0.1-beta.1                                ...           3 months ago
  • 0.0.7-alpha.12                                ...           3 months ago
  • 0.0.1-beta.0                                ...           3 months ago
  • 0.0.7-alpha.11                                ...           4 months ago
  • 0.0.7-alpha.10                                ...           4 months ago
  • 0.0.7-alpha.9                                ...           4 months ago
  • 0.0.7-alpha.8                                ...           4 months ago
  • 0.0.7-alpha.7                                ...           4 months ago
  • 0.0.7-alpha.6                                ...           4 months ago
  • 0.0.7-alpha.5                                ...           4 months ago
  • 0.0.7-alpha.4                                ...           4 months ago
  • 0.0.7-alpha.3                                ...           4 months ago
  • 0.0.7-alpha.2                                ...           4 months ago
  • 0.0.7-alpha.1                                ...           4 months ago
  • 0.0.6-alpha.1                                ...           4 months ago
  • 0.0.5-alpha.1                                ...           4 months ago
  • 0.0.4-alpha.1                                ...           4 months ago
  • 0.0.3-alpha.1                                ...           4 months ago
  • 0.0.2-alpha.1                                ...           4 months ago
  • 0.0.1-alpha.1                                ...           4 months ago
  • 0.0.0                                ...           4 months ago
Downloads
Today 0
This Week 0
This Month 13
Last Day 0
Last Week 13
Last Month 1,184
Dependencies (23)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2017 © taobao.org |