Allow for custom schema (#317)
* the basics: can specify a schema file * small code cleanup * give up and throw a dialog * update schema file * update readme
This commit is contained in:
Родитель
b7d6776e17
Коммит
62ee334744
|
@ -3,6 +3,12 @@ All notable changes to the Azure Pipelines extension will be documented in this
|
|||
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/). Versioning follows an internal Azure DevOps format that is not compatible with SemVer.
|
||||
|
||||
## 1.170.0
|
||||
### Added
|
||||
- Added an option to use a custom schema file
|
||||
### Fixed
|
||||
- updated schema to M169
|
||||
|
||||
## 1.165.1
|
||||
### Fixed
|
||||
- update a few dependencies
|
||||
|
|
39
README.md
39
README.md
|
@ -6,15 +6,7 @@
|
|||
|
||||
This VS Code extension adds syntax highlighting and autocompletion for Azure Pipelines YAML to VS Code. It also helps you set up continuous build and deployment for Azure WebApps without leaving VS Code.
|
||||
|
||||
![Configure Pipeline Demo](https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/master/resources/configure-pipeline.gif)
|
||||
|
||||
To set up a pipeline, choose *Azure Pipelines: Configure Pipeline* from the command palette (Ctrl/Cmd + Shift + P) or right-click in the file explorer. The guided workflow will generate a starter YAML file defining the build and deploy process.
|
||||
|
||||
You can customize the pipeline using all the features offered by [Azure Pipelines.](https://azure.microsoft.com/services/devops/pipelines/).
|
||||
|
||||
Once the setup is completed, an automatic CI/CD trigger will fire for every code push. To set this up, the extension will ask for a GitHub PAT with *repo* and *admin:repo_hook* scope.
|
||||
|
||||
![GitHub PAT scope](resources/gitHubPatScope.png)
|
||||
## Validation
|
||||
|
||||
Basic YAML validation is built in to VS Code, but now you can have syntax highlighting that's aware of the Pipelines YAML schema. This means that you get red squigglies if you say tasks: where you meant task:. IntelliSense is also schema-aware. Wherever you are in the file, press Ctrl-Space to see what options you have at that point.
|
||||
|
||||
|
@ -28,6 +20,35 @@ By default, the extension will highlight known Azure Pipelines files in the root
|
|||
}
|
||||
```
|
||||
|
||||
### Specific schema
|
||||
|
||||
Out of the box, the extension has a generic schema file that includes only in-box tasks.
|
||||
You probably have custom tasks installed in your organization.
|
||||
To teach the extension about those, grab a copy of your schema and tell the extension where to find it.
|
||||
|
||||
1. Visit `https://dev.azure.com/YOU-ORG-HERE/_apis/distributedtask/yamlschema` and save the output as `my-schema.json`.
|
||||
2. Edit your workspace's `settings.json` to include this:
|
||||
```json
|
||||
{
|
||||
"[azure-pipelines].customSchemaFile": "/full/path/to/my-schema.json"
|
||||
}
|
||||
```
|
||||
3. Restart VS Code.
|
||||
The extension will now validate against your schema.
|
||||
It'll give you autocompletes for your custom tasks.
|
||||
|
||||
## Pipeline configuration
|
||||
|
||||
![Configure Pipeline Demo](https://raw.githubusercontent.com/microsoft/azure-pipelines-vscode/master/resources/configure-pipeline.gif)
|
||||
|
||||
To set up a pipeline, choose *Azure Pipelines: Configure Pipeline* from the command palette (Ctrl/Cmd + Shift + P) or right-click in the file explorer. The guided workflow will generate a starter YAML file defining the build and deploy process.
|
||||
|
||||
You can customize the pipeline using all the features offered by [Azure Pipelines.](https://azure.microsoft.com/services/devops/pipelines/).
|
||||
|
||||
Once the setup is completed, an automatic CI/CD trigger will fire for every code push. To set this up, the extension will ask for a GitHub PAT with *repo* and *admin:repo_hook* scope.
|
||||
|
||||
![GitHub PAT scope](resources/gitHubPatScope.png)
|
||||
|
||||
## Telemetry
|
||||
|
||||
VS Code collects usage data and sends it to Microsoft to help improve our products and services. Read our [privacy statement](https://go.microsoft.com/fwlink/?LinkID=528096&clcid=0x409) to learn more. If you don’t wish to send usage data to Microsoft, you can set the `telemetry.enableTelemetry` setting to `false`. Learn more in our [FAQ](https://code.visualstudio.com/docs/supporting/faq#_how-to-disable-telemetry-reporting).
|
||||
|
|
11
package.json
11
package.json
|
@ -2,7 +2,7 @@
|
|||
"name": "azure-pipelines",
|
||||
"displayName": "Azure Pipelines",
|
||||
"description": "Syntax highlighting, IntelliSense, and more for Azure Pipelines YAML",
|
||||
"version": "1.165.1",
|
||||
"version": "1.170.0",
|
||||
"publisher": "ms-azure-devops",
|
||||
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217",
|
||||
"repository": {
|
||||
|
@ -70,12 +70,17 @@
|
|||
}
|
||||
],
|
||||
"configuration": {
|
||||
"title": "Azure Pipelines extension configuration.",
|
||||
"title": "Azure Pipelines",
|
||||
"properties": {
|
||||
"[azure-pipelines].configure": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Enable to opt-in for Configure Pipeline feature."
|
||||
"description": "Enable 'Configure Pipeline' feature"
|
||||
},
|
||||
"[azure-pipelines].customSchemaFile": {
|
||||
"type": ["string", "null"],
|
||||
"default": null,
|
||||
"description": "Use a different schema file"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
52176
service-schema.json
52176
service-schema.json
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -11,8 +11,8 @@ import * as languageclient from 'vscode-languageclient';
|
|||
import { activateConfigurePipeline } from './configure/activate';
|
||||
import { extensionVariables } from './configure/model/models';
|
||||
import * as logger from './logger';
|
||||
import * as schemaassociationservice from './schema-association-service';
|
||||
import * as schemacontributor from './schema-contributor';
|
||||
import { SchemaAssociationService, SchemaAssociationNotification } from './schema-association-service';
|
||||
import { schemaContributor, CUSTOM_SCHEMA_REQUEST, CUSTOM_CONTENT_REQUEST } from './schema-contributor';
|
||||
import { telemetryHelper } from './configure/helper/telemetryHelper';
|
||||
import { TelemetryKeys } from './configure/resources/telemetryKeys';
|
||||
|
||||
|
@ -37,7 +37,7 @@ export async function activate(context: vscode.ExtensionContext) {
|
|||
});
|
||||
|
||||
logger.log('Extension has been activated!', 'ExtensionActivated');
|
||||
return schemacontributor.schemaContributor;
|
||||
return schemaContributor;
|
||||
}
|
||||
|
||||
function registerUiVariables(context: vscode.ExtensionContext) {
|
||||
|
@ -53,32 +53,32 @@ function registerUiVariables(context: vscode.ExtensionContext) {
|
|||
async function activateYmlContributor(context: vscode.ExtensionContext) {
|
||||
const serverOptions: languageclient.ServerOptions = getServerOptions(context);
|
||||
const clientOptions: languageclient.LanguageClientOptions = getClientOptions();
|
||||
const client = new languageclient.LanguageClient('azure-pipelines', 'Azure Pipelines Support', serverOptions, clientOptions);
|
||||
const client = new languageclient.LanguageClient('azure-pipelines', 'Azure Pipelines Language', serverOptions, clientOptions);
|
||||
|
||||
const schemaAssociationService: schemaassociationservice.ISchemaAssociationService = new schemaassociationservice.SchemaAssociationService(context.extensionPath);
|
||||
const schemaAssociationService = new SchemaAssociationService(context.extensionPath);
|
||||
|
||||
const disposable = client.start();
|
||||
context.subscriptions.push(disposable);
|
||||
|
||||
const initialSchemaAssociations: schemaassociationservice.ISchemaAssociations = schemaAssociationService.getSchemaAssociation();
|
||||
const initialSchemaAssociations = schemaAssociationService.getSchemaAssociation();
|
||||
|
||||
await client.onReady().then(() => {
|
||||
//logger.log(`${JSON.stringify(initialSchemaAssociations)}`, 'SendInitialSchemaAssociation');
|
||||
client.sendNotification(schemaassociationservice.SchemaAssociationNotification.type, initialSchemaAssociations);
|
||||
client.sendNotification(SchemaAssociationNotification.type, initialSchemaAssociations);
|
||||
|
||||
// TODO: Should we get rid of these events and handle other events like Ctrl + Space? See when this event gets fired and send updated schema on that event.
|
||||
client.onRequest(schemacontributor.CUSTOM_SCHEMA_REQUEST, (resource: any) => {
|
||||
client.onRequest(CUSTOM_SCHEMA_REQUEST, (resource: any) => {
|
||||
//logger.log('Custom schema request. Resource: ' + JSON.stringify(resource), 'CustomSchemaRequest');
|
||||
|
||||
// TODO: Can this return the location of the new schema file?
|
||||
return schemacontributor.schemaContributor.requestCustomSchema(resource); // TODO: Have a single instance for the extension but dont return a global from this namespace.
|
||||
return schemaContributor.requestCustomSchema(resource); // TODO: Have a single instance for the extension but dont return a global from this namespace.
|
||||
});
|
||||
|
||||
// TODO: Can we get rid of this? Never seems to happen.
|
||||
client.onRequest(schemacontributor.CUSTOM_CONTENT_REQUEST, (uri: any) => {
|
||||
client.onRequest(CUSTOM_CONTENT_REQUEST, (uri: any) => {
|
||||
//logger.log('Custom content request.', 'CustomContentRequest');
|
||||
|
||||
return schemacontributor.schemaContributor.requestCustomSchemaContent(uri);
|
||||
return schemaContributor.requestCustomSchemaContent(uri);
|
||||
});
|
||||
})
|
||||
.catch((reason) => {
|
||||
|
@ -88,6 +88,19 @@ async function activateYmlContributor(context: vscode.ExtensionContext) {
|
|||
|
||||
// TODO: Can we get rid of this since it's set in package.json?
|
||||
vscode.languages.setLanguageConfiguration('azure-pipelines', { wordPattern: /("(?:[^\\\"]*(?:\\.)?)*"?)|[^\s{}\[\],:]+/ });
|
||||
|
||||
// when config changes, refresh the schema
|
||||
vscode.workspace.onDidChangeConfiguration(e => {
|
||||
schemaAssociationService.locateSchemaFile();
|
||||
const newSchema = schemaAssociationService.getSchemaAssociation();
|
||||
if (newSchema != initialSchemaAssociations)
|
||||
{
|
||||
vscode.window.showInformationMessage("Azure Pipelines schema changed. Restart VS Code to see the changes.");
|
||||
// this _should_ cause the language server to refresh its config
|
||||
// but that doesn't seem to be happening
|
||||
client.sendNotification(SchemaAssociationNotification.type, newSchema);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getServerOptions(context: vscode.ExtensionContext): languageclient.ServerOptions {
|
||||
|
|
|
@ -9,16 +9,23 @@ import * as languageclient from 'vscode-languageclient';
|
|||
|
||||
export interface ISchemaAssociationService {
|
||||
getSchemaAssociation(): ISchemaAssociations;
|
||||
locateSchemaFile(): void;
|
||||
}
|
||||
|
||||
// TODO: I think we can remove this class. Make it simpler?
|
||||
export class SchemaAssociationService implements ISchemaAssociationService {
|
||||
|
||||
/* Where the schema file is on disk. This is packaged with the extension, in the root, at service-schema.json. */
|
||||
extensionPath: string;
|
||||
schemaFilePath: string;
|
||||
|
||||
constructor(extensionPath: string) {
|
||||
this.schemaFilePath = vscode.Uri.file(path.join(extensionPath, './service-schema.json')).toString();
|
||||
this.extensionPath = extensionPath;
|
||||
this.locateSchemaFile();
|
||||
}
|
||||
|
||||
public locateSchemaFile() {
|
||||
const alternateSchema = vscode.workspace.getConfiguration('[azure-pipelines]', null).get<string>('customSchemaFile');
|
||||
const schemaPath = alternateSchema || path.join(this.extensionPath, './service-schema.json');
|
||||
this.schemaFilePath = vscode.Uri.file(schemaPath).toString();
|
||||
}
|
||||
|
||||
public getSchemaAssociation(): ISchemaAssociations {
|
||||
|
|
Загрузка…
Ссылка в новой задаче