Docs Menu
Docs Home
/ /

Crear un archivo de índice de registro manualmente

Advertencia

Funcionalidad experimental

Esta función es experimental. MongoDB no admite fragmentos. Esta función puede modificarse o eliminarse en cualquier momento sin previo aviso.

No se esperan errores, sin embargo, si encuentra alguno, abra un problema en el Repositorio de GitHub para este proyecto.

Esta página explica cómo crear manualmente un archivo de índice de registro. Para generar el archivo de índice de registro mediante un script, consulte Crear un archivo de índice de registro.

Para crear el archivo de índice de registro:

  1. Copie la siguiente plantilla de TypeScript y guárdela como make-index.ts:

    import bson from 'bson';
    import zlib from 'zlib';
    interface ErrorMatcher {
    // Add additional information to shell errors matching one of the regular.
    // expressions. The message can point to a snippet helping solve that error.
    matches: RegExp[];
    message: string;
    }
    interface SnippetDescription {
    // The *npm* package name. Users do not interact with this.
    name: string;
    // The snippet name. This is what users interact with.
    snippetName: string;
    // An optional install specifier that can be used to point npm towards
    // packages that are not uploaded to the registry. For example,
    // this could be an URL to a git repository or a tarball.
    installSpec?: string;
    // A version field. Users do not interact with this, as currently, `snippet`
    // always installs the latest versions of snippets.
    version: string;
    description: string;
    readme: string;
    // License should be a SPDX license identifier.
    license: string;
    errorMatchers?: ErrorMatcher[];
    }
    interface SnippetIndexFile {
    // This must be 1 currently.
    indexFileVersion: 1;
    index: SnippetDescription[];
    metadata: { homepage: string };
    }
    const indexFileContents: SnippetIndexFile = {
    indexFileVersion: 1,
    index: [ /* ... */ ],
    metadata: { homepage: 'https://example.com' }
    };
    // Serialize, compress and store the index file:
    fs.writeFileSync('index.bson.br',
    zlib.brotliCompressSync(
    bson.serialize(indexFileContents)));
  2. Edite make-index.ts según sea necesario para su paquete de fragmentos. Use los comentarios como guía para completar la información requerida.

  3. Ejecute ts-node make-index.ts para crear el index.bson.br file.

  4. Sube index.bson.br a tu repositorio de GitHub.

  5. Actualice snippetIndexSourceURLs para incluir una URL que haga referencia a su index.bson.br.

Volver

Manejadores de errores