Sha256: e14405de9b36ff21c86bd17255bbe919b659f4182b256f1bb78a69901ec877b9

Contents?: true

Size: 1.04 KB

Versions: 21

Compression:

Stored size: 1.04 KB

Contents

const { promises: fsp } = require('fs');
const { queue } = require('async');
const { glob } = require('glob');
const { parseHTTPServerRequests } = require('./util');
const Model = require('./model');

class SwaggerCommand {
  constructor(directory) {
    this.directory = directory;
  }

  async execute() {
    this.count = 0;
    this.model = new Model();
    const q = queue(this.collectAppMap.bind(this), 5);
    q.pause();
    const files = await new Promise((resolve, reject) => {
      glob(`${this.directory}/**/*.appmap.json`, (err, globFiles) => {
        if (err) {
          return reject(err);
        }
        return resolve(globFiles);
      });
    });
    files.forEach((f) => q.push(f));
    await new Promise((resolve, reject) => {
      q.drain(resolve);
      q.error(reject);
      q.resume();
    });
    return this.model.swagger();
  }

  async collectAppMap(file) {
    this.count += 1;
    parseHTTPServerRequests(JSON.parse(await fsp.readFile(file)), (e) =>
      this.model.addRequest(e)
    );
  }
}

module.exports = SwaggerCommand;

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
appmap-0.72.2 ./node_modules/@appland/appmap/src/swagger/command.js
appmap-0.72.1 ./node_modules/@appland/appmap/src/swagger/command.js
appmap-0.72.0 ./node_modules/@appland/appmap/src/swagger/command.js
appmap-0.71.0 ./node_modules/@appland/appmap/src/swagger/command.js
appmap-0.70.2 ./node_modules/@appland/appmap/src/swagger/command.js
appmap-0.70.1 ./node_modules/@appland/appmap/src/swagger/command.js
appmap-0.70.0 ./node_modules/@appland/appmap/src/swagger/command.js
appmap-0.69.0 ./node_modules/@appland/appmap/src/swagger/command.js
appmap-0.68.2 ./node_modules/@appland/appmap/src/swagger/command.js
appmap-0.68.1 ./node_modules/@appland/appmap/src/swagger/command.js
appmap-0.68.0 ./node_modules/@appland/appmap/src/swagger/command.js
appmap-0.67.1 ./node_modules/@appland/appmap/src/swagger/command.js
appmap-0.67.0 ./node_modules/@appland/appmap/src/swagger/command.js
appmap-0.66.2 ./node_modules/@appland/appmap/src/swagger/command.js
appmap-0.66.1 ./node_modules/@appland/appmap/src/swagger/command.js
appmap-0.66.0 ./node_modules/@appland/appmap/src/swagger/command.js
appmap-0.65.1 ./node_modules/@appland/appmap/src/swagger/command.js
appmap-0.65.0 ./node_modules/@appland/appmap/src/swagger/command.js
appmap-0.64.0 ./node_modules/@appland/appmap/src/swagger/command.js
appmap-0.63.0 ./node_modules/@appland/appmap/src/swagger/command.js