Sha256: 8d63bde45357afd9e53bdb0b0b1e2a8af088a3983c435b2cc763c1c4c025b109

Contents?: true

Size: 1.07 KB

Versions: 21

Compression:

Stored size: 1.07 KB

Contents

const fsp = require('fs').promises;
const { baseName, listAppMapFiles } = require('./utils');

/**
 * appMapCatalog creates a lookup table of all the AppMap metadata in a directory (recursively).
 *
 * @param {string} directory path to the directory.
 * @returns {Object<String,Metadata>} Map of AppMap names to metadata objects.
 */
async function appMapCatalog(directory) {
  const appMapsByName = {};
  const appMapFiles = [];
  await listAppMapFiles(directory, (file) => {
    appMapFiles.push(file);
  });

  await Promise.all(
    // eslint-disable-next-line prefer-arrow-callback
    appMapFiles.map(async (file) => {
      const data = await fsp.readFile(`${baseName(file)}.metadata.json`);
      const metadata = JSON.parse(data);
      const entry = {
        fileName: file,
        metadata,
      };
      if (appMapsByName[metadata.name]) {
        console.warn(
          `AppMap name ${metadata.name} is not unique in the mapset`
        );
      } else {
        appMapsByName[metadata.name] = entry;
      }
    })
  );

  return appMapsByName;
}

module.exports = appMapCatalog;

Version data entries

21 entries across 21 versions & 1 rubygems

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