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 csv as an export type for rehearsal graph #1190

Open
robostheimer opened this issue Jul 27, 2023 · 3 comments
Open

Add csv as an export type for rehearsal graph #1190

robostheimer opened this issue Jul 27, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@robostheimer
Copy link
Contributor

Adding csv as an export type for rehearsal graph would make it easier to organize the data into spreadsheets which in turn will make it easier to track the migration progress. I believe that the json2csv library could be leveraged to make this happen.

@egorio
Copy link
Contributor

egorio commented Jul 31, 2023

Hi @robostheimer, this is a good idea. Would you mind to propose a format of file (columns) you would like to see?

@egorio egorio added the enhancement New feature or request label Jul 31, 2023
@egorio egorio added this to the Self Service milestone Jul 31, 2023
@robostheimer
Copy link
Contributor Author

I think the best case would be:
package name | external | file.name | file.hasTypes | file.edges.packageName | file.edges.hasTypes | file.edges.FileName.

Essentially just unwind the rehearsal graph json export and make it useable in spreadsheet format.

I plan to look into this myself if I can find the time.

@lynchbomb
Copy link
Contributor

@robostheimer you could easily add type of formatter https://github.com/rehearsal-js/rehearsal-js/tree/master/packages/reporter/src/formatters

eg.

// packages/reporter/src/formatters/csv-formatter.ts

import { Parser } from '@json2csv/plainjs';
import { unwind } from '@json2csv/transforms';
import type { Report, FormatterBase } from '../types.js';

export class CSVFormatter implements FormatterBase {
  static extension = '.csv';
  static getReport(report: Report): string {
    const jsonData = JSON.stringify(report, null, 2);
    try {
      const opts = {
         transforms: [
           unwind({ paths: ['colors'] })
          ]
      };
      
     const parser = new Parser(opts);
     return parser.parse(jsonData);
    } catch (err) {
       // handle err
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants