경고
실험적 기능
이는 실험적인 기능입니다. MongoDB는 스니펫을 지원하지 않습니다. 이 기능은 사전 통지 없이 변경되거나 제거될 수 있습니다.
버그가 예상되지는 않지만 발생할 수 있습니다. 발생 시 이 프로젝트의 GitHub 리포지토리에서 문의를 접수하세요.
이 페이지에서는 레지스트리 인덱스 파일을 수동으로 만드는 방법에 대해 설명합니다. 스크립트를 사용하여 레지스트리 인덱스 파일을 생성하려면 레지스트리 인덱스 파일 생성을 참조 하세요.
레지스트리 인덱스 파일을 생성하려면 다음을 수행합니다.
다음 TypeScript 템플릿을 복사하여
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))); 스니펫 패키지에 대해 필요에 따라
make-index.ts를 편집합니다. 댓글을 가이드로 삼아 필수 정보를 입력하세요.ts-node make-index.ts을 실행하여index.bson.br file을 만듭니다.index.bson.br을(를) GitHub 리포지토리에 업로드합니다.index.bson.br을(를) 참고하는 URL을 포함하도록snippetIndexSourceURLs을(를) 업데이트합니다.