function writeSchemasToFile()

in src/schema/firefox-schemas-import.js [652:689]


function writeSchemasToFile(basePath, importedPath, loadedSchemas) {
  const ids = Object.keys(loadedSchemas);
  // Write out the schemas.
  ids.forEach((currId) => {
    const { file, schema } = loadedSchemas[currId];
    const { id, ...rest } = schema;
    writeSchema(
      importedPath,
      file,
      // Normalize schema to draft7 spec
      // (required for ajv v8).
      { $id: id, ...rest }
    );
  });
  // Write out the index.js to easily import all schemas.
  const imports = ids
    .filter((id) => {
      return id !== 'manifest';
    })
    .map((id) => {
      const { file } = loadedSchemas[id];
      const basename = path.basename(file);
      return `import ${id} from './${basename}'`;
    })
    .join(';\n');
  const fileContents = `// This file is generated by the schema import script.

${imports};
export default [
  ${ids
    .filter((id) => {
      return id !== 'manifest';
    })
    .join(',\n  ')},
];
`;
  fs.writeFileSync(path.join(importedPath, 'index.js'), fileContents);
}