Sha256: 17ab41db116dce0bc48e893981a3cefdbfd9c14d3f1d3c91aaf0be9a8ee3ac2b

Contents?: true

Size: 1.48 KB

Versions: 21

Compression:

Stored size: 1.48 KB

Contents

const { join: joinPath } = require('path');
const { promises: fsp } = require('fs');
const { verbose, listAppMapFiles, baseName } = require('./utils');

class InventoryCommand {
  constructor(directory) {
    this.directory = directory;
    this.print = true;
  }

  async execute() {
    if (verbose()) {
      console.warn(`Collecting query info from ${this.directory}`);
    }

    const result = {
      packages: new Set(),
      classes: new Set(),
      labels: new Set(),
      packageDependencies: new Set(),
      sqlTables: new Set(),
      sqlNormalized: new Set(),
      httpServerRequests: new Set(),
      // httpClientRequests: new Set(),
    };

    await this.files(async (appMapFileName) => {
      if (verbose()) {
        console.warn(`Collecting query info from ${appMapFileName}`);
      }
      const indexDir = baseName(appMapFileName);

      await Promise.all(
        Object.keys(result).map(async (algorithmName) => {
          const items = JSON.parse(
            await fsp.readFile(
              joinPath(indexDir, `canonical.${algorithmName}.json`)
            )
          );

          items.forEach((item) =>
            result[algorithmName].add(JSON.stringify(item))
          );
        })
      );
    });

    return Object.keys(result).reduce((memo, key) => {
      memo[key] = [...result[key]].sort().map((i) => JSON.parse(i));
      return memo;
    }, {});
  }

  async files(fn) {
    return listAppMapFiles(this.directory, fn);
  }
}

module.exports = InventoryCommand;

Version data entries

21 entries across 21 versions & 1 rubygems

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