### Install Dependencies for Nightly Build Source: https://github.com/microsoft/vscode-pull-request-github/wiki/Nightly-Build Installs project dependencies and the 'vsce' tool, which is required for publishing extensions from the command line. ```shell yarn yarn vsce ``` -------------------------------- ### Example Code for Suggestion Source: https://github.com/microsoft/vscode-pull-request-github/blob/main/documentation/suggestAChange.md This is an example of a line of code for which a suggestion can be made. The 'Make a Suggestion' button will use this context to generate the suggestion template. ```typescript console.log('hello world'); ``` -------------------------------- ### Configure GitHub PR Queries Source: https://github.com/microsoft/vscode-pull-request-github/blob/main/README.md Customize the pull request tree categories by defining custom labels and GitHub search queries. This example adds a 'Mentioned Me' category. ```json "githubPullRequests.queries": [ { "label": "Waiting For My Review", "query": "is:open review-requested:${user}" }, { "label": "Assigned To Me", "query": "is:open assignee:${user}" }, { "label": "Created By Me", "query": "is:open author:${user}" }, { "label": "Mentioned Me", "query": "is:open mentions:${user}" } ] ``` -------------------------------- ### Insert Suggestion Template Source: https://github.com/microsoft/vscode-pull-request-github/blob/main/documentation/suggestAChange.md This is the template that gets inserted into the comment input when using the 'Make a Suggestion' button. Modify the content within the `suggestion` block to demonstrate your proposed code changes. ```markdown ```suggestion console.log('hello world'); ``` ``` -------------------------------- ### Publish Extension using Personal Access Token Source: https://github.com/microsoft/vscode-pull-request-github/wiki/Nightly-Build Publishes the extension via the command line by passing a Personal Access Token (PAT) through an environment variable. The PAT should not be stored directly in the source code. Instructions for generating and updating the PAT are provided. ```text To publish through command line, we need to pass in [Personal Access Token](https://code.visualstudio.com/api/working-with-extensions/publishing-extension#get-a-personal-access-token) through Environment Variable again. Apparently we don't want to put the PAT in source code. The current token has a lifetime of a year, and will expire on 3/11/2021. When this happens, generate a new token using [these instructions](https://code.visualstudio.com/api/working-with-extensions/publishing-extension#get-a-personal-access-token). From the pipeline's page, click edit, variables, and then update the value of `vsce.token` to the new string. ``` -------------------------------- ### Call create_pull_request Tool Source: https://github.com/microsoft/vscode-pull-request-github/blob/main/src/lm/skills/create-pull-request/SKILL.md Use this tool to create a pull request. Specify title, head branch, body, and optionally base branch, draft status, head owner, and repository details. Omit optional parameters to use defaults. ```javascript github-pull-request_create_pull_request({ title: '', head: '', // branch name only, not owner:branch body: '', // optional but recommended base: '', // optional; omit to use repo default draft: false, // set true for work-in-progress headOwner: '', // optional; omit if same as repo owner repo: { owner: '', name: '' } // optional }) ``` -------------------------------- ### Construct Mock Pull Request with Basic Properties Source: https://github.com/microsoft/vscode-pull-request-github/blob/main/src/test/builders/README.md Use the PullRequestBuilder to create a mock PullRequest object. Populate only the necessary properties for the test case. Unspecified fields will be set to valid default values. ```typescript import { PullRequestBuilder } from '../builders/example/pullRequestBuilder'; describe('Some model that uses PullRequest responses', function () { it('does something based on the PR number and title', function () { // PullRequestBuilder has a fluent interface with a setter method corresponding to each // property of the PullRequest interface. Its .build() method returns a fully-constructed // PullRequest object. const pr = new PullRequestBuilder().number(1234).title('This is the title').build(); // The fields we populated directly will be set to the values we gave them. assert.strictEqual(pr.number, 1234); assert.strictEqual(pr.title, 'This is the title'); // Fields we didn't specify will be set to *some* valid value. This is guaranteed to be // the correct type, but we shouldn't rely on its value! assert(pr.description instanceof string); // This is true recursively within nested objects as well. assert(pr.author); assert(pr.author.login instanceof string); }); }); ``` -------------------------------- ### Customize GitHub Issue Queries Source: https://github.com/microsoft/vscode-pull-request-github/blob/main/documentation/IssueFeatures.md Configure custom queries to filter and display issues in the VS Code Issues view. This allows for tailored views based on assignees, states, repositories, and sorting preferences. ```json { "githubIssues.queries": [ { "label": "My Issues", "query": "default" }, { "label": "Remote Release", "query": "assignee:alexr00 state:open repo:Microsoft/vscode-remote-release sort:updated-desc" } ] } ``` -------------------------------- ### Define Repository Builder Class with Linked User Source: https://github.com/microsoft/vscode-pull-request-github/blob/main/src/test/builders/README.md Define a Repository builder class using `createBuilderClass`. Linked fields, such as 'owner', are specified using `{linked: BuilderClass}`. The type of the linked builder is checked against the field's type at compile time, and its template is used for default value construction if the field is unspecified. ```typescript // src/test/builders/example/repositoryBuilder.ts import { createBuilderClass } from '../base'; import { Repository } from '../../../../src/common/interfaces'; import { UserBuilder } from './userBuilder'; export const RepositoryBuilder = createBuilderClass()({ // A field that should be constructed by a different builder is specified as "{linked: BuilderClass}". // // The type constructed by UserBuilder is checked against the type of the "owner" field on Repository // at compile time. The template used to define UserBuilder in user.ts is used to construct a default // value for this field if unspecified. owner: { linked: UserBuilder }, name: { default: 'some-default' }, viewerCanAdmin: { default: false }, }); export type RepositoryBuilder = InstanceType; ``` -------------------------------- ### Update Extension ID and Version for Nightly Build Source: https://github.com/microsoft/vscode-pull-request-github/wiki/Nightly-Build Modifies the extension ID to 'vscode-pull-request-github-insiders' and sets a unique, incrementing version for the nightly build. The version format is YEAR.MONTH.MINUTES-IN-MONTH to ensure uniqueness. ```text Update. The version will be YEAR.MONTH.MINUTES-IN-MONTH, so we can generate an unique version for every minute, even if we attempt to publish a new release manually, the version is still guaranteed correct. ``` -------------------------------- ### Simplify Nested Builder Creation with createLink Source: https://github.com/microsoft/vscode-pull-request-github/blob/main/src/test/builders/README.md Use `createLink` to simplify the creation of intermediate builder classes for deeply nested fields, reducing boilerplate code. This function shares the same double-function-call signature as `createBuilderClass` for type inference. ```typescript interface DeeplyNested { stepOne: { stepTwo: { stepThree: { attr: number; } } }; } import { createBuilderClass, createLink } from '../base'; // You still need to name the intermediate types, unfortunately. I use type aliases to make this somewhat more concise. type StepOne = DeeplyNested["stepOne"]; type StepTwo = StepOne["stepTwo"]; type StepThree = StepTwo["stepThree"]; // createLink() uses the same double-function-call signature to infer the type of its template correctly. export const DeeplyNestedBuilder = createBuilderClass()({ stepOne: createLink()({ stepTwo: createLink()({ stepTwo: createLink(){ attr: {default: 10}, }, }), }); }); ``` -------------------------------- ### Define Pull Request Builder Class with Linked Builders Source: https://github.com/microsoft/vscode-pull-request-github/blob/main/src/test/builders/README.md Define a PullRequest builder class using `createBuilderClass`, linking to UserBuilder and RepositoryBuilder for 'author', 'head', and 'base' fields. This demonstrates how to compose builders for complex, nested object structures. ```typescript // src/test/builders/example/pullRequestBuilder.ts import { createBuilderClass } from '../base'; import { PullRequest } from '../../../../src/common/interfaces'; import { UserBuilder } from './userBuilder'; import { RepositoryBuilder } from './repositoryBuilder'; export const PullRequestBuilder = createBuilderClass()({ number: { default: 100 }, title: { default: 'default title' }, description: { default: 'default description' }, author: { linked: UserBuilder }, head: { linked: RepositoryBuilder }, base: { linked: RepositoryBuilder }, }); export type PullRequestBuilder = InstanceType; ``` -------------------------------- ### Define User Builder Class Source: https://github.com/microsoft/vscode-pull-request-github/blob/main/src/test/builders/README.md Use `createBuilderClass` to dynamically generate a JavaScript class for constructing User objects. TypeScript enforces type safety by checking properties and default value types against the User interface. The double-function-call signature infers the template object's type while explicitly specifying the generic type parameter. ```typescript // src/test/builders/example/userBuilder.ts import { createBuilderClass } from '../base'; import { User } from '../../../../src/common/interfaces'; // "UserBuilder" is a dynamically generated JavaScript class that will construct "User" objects. // The convention is to name a builder that constructs X instances as "XBuilder". // // Note that TypeScript will generate a compile-time error if: // * The "User" type contains any properties not provided in the template object. // * The type of a default value is not assignable to the corresponding "User" property. // // The odd double-function-call usage here is done so that the type of the template object may be // inferred while explicitly specifying the type parameter. export const UserBuilder = createBuilderClass()({ login: { default: 'me' }, avatarUrl: { default: 'https://avatars-r-us.com/me.jpg' }, }); // Exporting the instance type is useful in cases when you wish to create custom builders that reference // generated ones in their type signatures, or refactor out functions that operate on a builder to set // common fields. export type UserBuilder = InstanceType; ``` -------------------------------- ### Construct Mock Pull Request with Nested Object Properties Source: https://github.com/microsoft/vscode-pull-request-github/blob/main/src/test/builders/README.md Populate nested object properties by passing a callback function to the corresponding setter. This function receives the builder for the nested object, allowing you to configure its properties. ```typescript import { PullRequestBuilder } from '../builders/example/pullRequestBuilder'; describe('Some model that uses PullRequest responses', function () { it('needs to specify some deep property, like the owner of the base repository', function () { // Setter methods that construct other objects that have builders work a little differently. // // The "setter" for each instead accepts a function that will be called with an instance of // that type's builder. You can call setters on that builder to populate any fields that you // care about on that object. Then, the parent setter function will call "build()" for you // and set the field to the constructed instance. // // The type of the builder argument can be inferred from the setter function's signature, // which saves you from needing to import a builder for every nested type. const pr = new PullRequestBuilder() .base(b => { b.owner(o => o.login('someone')); }) .build(); assert.strictEqual(pr.base.owner.login, 'someone'); // Unspecified fields within nested types are also constructed to some valid default value. assert(pr.base.owner.avatarUrl instanceof string); }); }); ``` -------------------------------- ### Define Interfaces for API Responses Source: https://github.com/microsoft/vscode-pull-request-github/blob/main/src/test/builders/README.md These interfaces define the structure of expected API response objects. They are used to ensure type safety when constructing mock data. ```typescript interface User { login: string; avatarUrl: string; } interface Repository { owner: User; name: string; viewerCanAdmin: boolean; } interface PullRequest { number: number; title: string; description: string; author: User; head: Repository; // Yeah, these are Refs in the real schema. base: Repository; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.