Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ansible/ansible-language-server

Package Overview
Dependencies
Maintainers
4
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ansible/ansible-language-server - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

0001-Release-0.2.5-from-GitHub-Actions-CI-CD.patch

9

out/server/src/providers/validationProvider.js

@@ -54,3 +54,10 @@ "use strict";

console.debug('Validating using ansible syntax-check');
diagnosticsByFile = yield context.ansiblePlaybook.doValidate(textDocument);
if ((0, yaml_1.isPlaybook)(textDocument)) {
console.log('is playbook...');
diagnosticsByFile = yield context.ansiblePlaybook.doValidate(textDocument);
}
else {
console.log('not a playbook...');
diagnosticsByFile = new Map();
}
}

@@ -57,0 +64,0 @@ if (!diagnosticsByFile.has(textDocument.uri)) {

@@ -97,2 +97,5 @@ "use strict";

else {
if (progressTracker) {
progressTracker.done();
}
this.connection.window.showErrorMessage(execError.message);

@@ -99,0 +102,0 @@ return -1;

@@ -91,1 +91,7 @@ import { Position, TextDocument } from 'vscode-languageserver-textdocument';

export declare function parseAllDocuments(str: string, options?: Options): Document[];
/**
* For a given yaml file that is recognised as Ansible file, the function
* checks whether the file is a playbook or not
* @param textDocument the text document to check
*/
export declare function isPlaybook(textDocument: TextDocument): boolean;

@@ -12,3 +12,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.parseAllDocuments = exports.getOrigRange = exports.getYamlMapKeys = exports.findProvidedModule = exports.isRoleParam = exports.isBlockParam = exports.isPlayParam = exports.getDeclaredCollections = exports.isTaskParam = exports.tasksKey = exports.getPathAtOffset = exports.contains = exports.getPathAt = exports.AncestryBuilder = void 0;
exports.isPlaybook = exports.parseAllDocuments = exports.getOrigRange = exports.getYamlMapKeys = exports.findProvidedModule = exports.isRoleParam = exports.isBlockParam = exports.isPlayParam = exports.getDeclaredCollections = exports.isTaskParam = exports.tasksKey = exports.getPathAtOffset = exports.contains = exports.getPathAt = exports.AncestryBuilder = void 0;
const _ = require("lodash");

@@ -18,2 +18,3 @@ const yaml_1 = require("yaml");

const ansible_1 = require("./ansible");
const ansible_2 = require("../utils/ansible");
/**

@@ -377,2 +378,39 @@ * A helper class used for building YAML path assertions and retrieving parent

exports.parseAllDocuments = parseAllDocuments;
/**
* For a given yaml file that is recognised as Ansible file, the function
* checks whether the file is a playbook or not
* @param textDocument the text document to check
*/
function isPlaybook(textDocument) {
// Check for empty file
if (textDocument.getText().trim().length === 0) {
return false;
}
const yamlDocs = parseAllDocuments(textDocument.getText());
const path = getPathAt(textDocument, { line: 1, character: 1 }, yamlDocs);
// Check if keys are present or not
if (!path) {
return false;
}
// A playbook is always YAML sequence
if (!(path[0] instanceof types_1.YAMLSeq)) {
return false;
}
const playbookKeysSet = new Set();
const playbookJSON = path[0].toJSON();
Object.keys(playbookJSON).forEach(function (key) {
Object.keys(playbookJSON[key]).forEach((item) => playbookKeysSet.add(item));
});
const playbookKeys = [...playbookKeysSet];
const playKeywordsList = [...ansible_2.playKeywords.keys()];
const taskKeywordsList = [...ansible_2.taskKeywords.keys()];
// Filters out all play keywords that are task keywords
const filteredList = playKeywordsList.filter((value) => !taskKeywordsList.includes(value));
// Check if any top-level key of the ansible file is a part of filtered list
// If it is: The file is a playbook
// Else: The file is not a playbook
const isPlaybookValue = playbookKeys.some((r) => filteredList.includes(r));
return isPlaybookValue;
}
exports.isPlaybook = isPlaybook;
//# sourceMappingURL=yaml.js.map

2

package.json

@@ -7,3 +7,3 @@ {

"license": "MIT",
"version": "0.2.4",
"version": "0.2.5",
"contributors": [

@@ -10,0 +10,0 @@ {

@@ -13,3 +13,3 @@ # Ansible Language Server

![Syntax highlighting](images/syntax-highlighting.png)
![Syntax highlighting](https://github.com/ansible/ansible-language-server/raw/main/images/syntax-highlighting.png)

@@ -29,3 +29,3 @@ **Ansible keywords**, **module names** and **module options**, as well as

![YAML validation](images/yaml-validation.gif)
![YAML validation](https://github.com/ansible/ansible-language-server/raw/main/images/yaml-validation.gif)

@@ -37,3 +37,3 @@ While you type, the syntax of your Ansible scripts is verified and any feedback

![Linter support](images/ansible-lint.gif)
![Linter support](https://github.com/ansible/ansible-language-server/raw/main/images/ansible-lint.gif)

@@ -57,3 +57,3 @@ On opening and saving a document, `ansible-lint` is executed in the background

![Autocompletion](images/smart-completions.gif)
![Autocompletion](https://github.com/ansible/ansible-language-server/raw/main/images/smart-completions.gif)

@@ -74,3 +74,3 @@ The extension tries to detect whether the cursor is on a play, block or task

![Easier Jinja expression typing](images/jinja-expression.gif)
![Easier Jinja expression typing](https://github.com/ansible/ansible-language-server/raw/main/images/jinja-expression.gif)

@@ -84,3 +84,3 @@ When writing a Jinja expression, you only need to type `"{{<space>`, and it

![Documentation on hover](images/hover-documentation-module.png)
![Documentation on hover](https://github.com/ansible/ansible-language-server/raw/main/images/hover-documentation-module.png)

@@ -93,3 +93,3 @@ Documentation is available on hover for Ansible keywords, modules and module

![Go to code on Ctrl+click](images/go-to-definition.gif)
![Go to code on Ctrl+click](https://github.com/ansible/ansible-language-server/raw/main/images/go-to-definition.gif)

@@ -96,0 +96,0 @@ You may also open the implementation of any module using the standard *Go to

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc