Skip to content

Commit

Permalink
Merge branch 'main' into filter-plugin-webview
Browse files Browse the repository at this point in the history
  • Loading branch information
shatakshiiii committed Dec 17, 2024
2 parents 929ddad + afa8ac7 commit c58bf7e
Show file tree
Hide file tree
Showing 11 changed files with 221 additions and 191 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ jobs:
flags: als
disable_search: true
fail_ci_if_error: true
use_oidc: true # cspell:ignore oidc
use_oidc: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }} # cspell:ignore oidc

- name: Upload unit test coverage data [2/4]
uses: codecov/[email protected]
Expand All @@ -354,7 +354,7 @@ jobs:
flags: unit
disable_search: true
fail_ci_if_error: true
use_oidc: true # cspell:ignore oidc
use_oidc: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }} # cspell:ignore oidc

- name: Upload ui test coverage data [3/4]
uses: codecov/[email protected]
Expand All @@ -364,7 +364,7 @@ jobs:
flags: ui
disable_search: true
fail_ci_if_error: true
use_oidc: true # cspell:ignore oidc
use_oidc: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }} # cspell:ignore oidc

- name: Upload e2e test coverage data [4/4]
uses: codecov/[email protected]
Expand All @@ -374,7 +374,7 @@ jobs:
flags: e2e
disable_search: true
fail_ci_if_error: true
use_oidc: true # cspell:ignore oidc
use_oidc: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }} # cspell:ignore oidc

- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -913,12 +913,12 @@
"dependencies": {
"@ansible/ansible-language-server": "workspace:^",
"@redhat-developer/vscode-redhat-telemetry": "^0.9.1",
"@shikijs/core": "^1.24.1",
"@shikijs/core": "^1.24.2",
"@types/ini": "^4.1.1",
"@vscode/webview-ui-toolkit": "^1.4.0",
"axios": "^1.7.9",
"ini": "^5.0.0",
"marked": "^15.0.3",
"marked": "^15.0.4",
"minimatch": "^10.0.1",
"semver": "^7.6.3",
"uuid": "^11.0.3",
Expand All @@ -928,7 +928,7 @@
},
"description": "Ansible language support",
"devDependencies": {
"@eslint/js": "^9.16.0",
"@eslint/js": "^9.17.0",
"@types/chai": "^4.3.20",
"@types/express": "^5.0.0",
"@types/glob": "^8.1.0",
Expand All @@ -937,22 +937,22 @@
"@types/minimatch": "^5.1.2",
"@types/mocha": "^10.0.10",
"@types/morgan": "^1.9.9",
"@types/node": "^22.10.1",
"@types/node": "^22.10.2",
"@types/selenium-webdriver": "^4.1.27",
"@types/sinon": "^17.0.3",
"@types/tmp": "^0.2.6",
"@types/uuid": "^10.0.0",
"@types/vscode": "^1.85.0",
"@types/vscode-webview": "^1.57.5",
"@types/yargs": "^17.0.33",
"@typescript-eslint/eslint-plugin": "^8.17.0",
"@typescript-eslint/parser": "^8.17.0",
"@typescript-eslint/eslint-plugin": "^8.18.0",
"@typescript-eslint/parser": "^8.18.0",
"@vscode/test-electron": "^2.4.1",
"@vscode/vsce": "^3.2.1",
"axios": "^1.7.9",
"chai": "^4.5.0",
"depcheck": "^1.4.7",
"eslint": "^9.16.0",
"eslint": "^9.17.0",
"eslint-config-prettier": "^9.1.0",
"eslint-formatter-gha": "^1.5.2",
"eslint-formatter-unix": "^8.40.0",
Expand All @@ -975,12 +975,12 @@
"react": "^19.0.0",
"rimraf": "^6.0.1",
"selenium-webdriver": "^4.27.0",
"shiki": "^1.24.1",
"shiki": "^1.24.2",
"sinon": "^19.0.2",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"typescript": "^5.7.2",
"typescript-eslint": "^8.17.0",
"typescript-eslint": "^8.18.0",
"vscode-extension-tester": "^8.10.0",
"warnings-to-errors-webpack-plugin": "^2.3.0",
"webpack": "^5.97.1",
Expand Down
14 changes: 7 additions & 7 deletions packages/ansible-language-server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/ansible-language-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"@types/ini": "^4.1.1",
"@types/lodash": "^4.17.13",
"@types/mocha": "^10.0.10",
"@types/node": "^22.10.1",
"@types/node": "^22.10.2",
"@types/uuid": "^10.0.0",
"@types/vscode": "^1.85.0",
"chai": "^4.5.0",
Expand Down
2 changes: 2 additions & 0 deletions src/definitions/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export const ANSIBLE_LIGHTSPEED_API_TIMEOUT = 28000;

export const ANSIBLE_CREATOR_VERSION_MIN = "24.10.1";

export const ANSIBLE_CREATOR_COLLECTION_VERSION_MIN = "24.7.1";

export const DevfileImages = {
Upstream: "ghcr.io/ansible/ansible-workspace-env-reference:latest",
};
57 changes: 41 additions & 16 deletions src/features/contentCreator/createAnsibleCollectionPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ import { getNonce } from "../utils/getNonce";
import { AnsibleCollectionFormInterface, PostMessageEvent } from "./types";
import { withInterpreter } from "../utils/commandRunner";
import { SettingsManager } from "../../settings";
import { expandPath, getBinDetail, runCommand } from "./utils";
import { ANSIBLE_CREATOR_VERSION_MIN } from "../../definitions/constants";
import {
expandPath,
getBinDetail,
getCreatorVersion,
runCommand,
} from "./utils";
import {
ANSIBLE_CREATOR_COLLECTION_VERSION_MIN,
ANSIBLE_CREATOR_VERSION_MIN,
} from "../../definitions/constants";

export class CreateAnsibleCollection {
public static currentPanel: CreateAnsibleCollection | undefined;
Expand Down Expand Up @@ -334,12 +342,20 @@ export class CreateAnsibleCollection {
return;
}

private async getCreatorVersion(): Promise<string> {
const creatorVersion = (
await getBinDetail("ansible-creator", "--version")
).toString();
console.log("ansible-creator version: ", creatorVersion);
return creatorVersion;
public async getCollectionCreatorCommand(
namespaceName: string,
collectionName: string,
initPathUrl: string,
): Promise<string> {
let command = "";
const creatorVersion = await getCreatorVersion();

if (semver.gte(creatorVersion, ANSIBLE_CREATOR_COLLECTION_VERSION_MIN)) {
command = `ansible-creator init collection ${namespaceName}.${collectionName} ${initPathUrl} --no-ansi`;
} else {
command = `ansible-creator init ${namespaceName}.${collectionName} --init-path=${initPathUrl} --no-ansi`;
}
return command;
}

public async runInitCommand(
Expand All @@ -363,7 +379,11 @@ export class CreateAnsibleCollection {
? initPath
: `${os.homedir()}/.ansible/collections/ansible_collections`;

let ansibleCreatorInitCommand = `ansible-creator init collection ${namespaceName}.${collectionName} ${initPathUrl} --no-ansi`;
let ansibleCreatorInitCommand = await this.getCollectionCreatorCommand(
namespaceName,
collectionName,
initPathUrl,
);

// adjust collection url for using it in ade and opening it in workspace
// NOTE: this is done in order to synchronize the behavior of ade and extension
Expand All @@ -386,13 +406,18 @@ export class CreateAnsibleCollection {

let adeCommand = `ade install --venv ${venvPathUrl} --editable ${collectionUrl} --no-ansi`;

const creatorVersion = await this.getCreatorVersion();
if (isOverwritten) {
if (semver.gte(creatorVersion, ANSIBLE_CREATOR_VERSION_MIN)) {
ansibleCreatorInitCommand += " --overwrite";
} else {
ansibleCreatorInitCommand += " --force";
}
const creatorVersion = await getCreatorVersion();
const exceedMinVersion = semver.gte(
creatorVersion,
ANSIBLE_CREATOR_VERSION_MIN,
);

if (exceedMinVersion && isOverwritten) {
ansibleCreatorInitCommand += " --overwrite";
} else if (!exceedMinVersion && isOverwritten) {
ansibleCreatorInitCommand += " --force";
} else if (exceedMinVersion && !isOverwritten) {
ansibleCreatorInitCommand += " --no-overwrite";
}

switch (verbosity) {
Expand Down
35 changes: 16 additions & 19 deletions src/features/contentCreator/createAnsibleProjectPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { getNonce } from "../utils/getNonce";
import { AnsibleProjectFormInterface, PostMessageEvent } from "./types";
import { withInterpreter } from "../utils/commandRunner";
import { SettingsManager } from "../../settings";
import { expandPath, getBinDetail, runCommand } from "./utils";
import { expandPath, getCreatorVersion, runCommand } from "./utils";
import { ANSIBLE_CREATOR_VERSION_MIN } from "../../definitions/constants";

export class CreateAnsibleProject {
Expand Down Expand Up @@ -280,21 +280,13 @@ export class CreateAnsibleProject {
);
}

private async getCreatorVersion(): Promise<string> {
const creatorVersion = (
await getBinDetail("ansible-creator", "--version")
).toString();
console.log("ansible-creator version: ", creatorVersion);
return creatorVersion;
}

public async getCreatorCommand(
public async getPlaybookCreatorCommand(
namespace: string,
collection: string,
url: string,
): Promise<string> {
let command = "";
const creatorVersion = await this.getCreatorVersion();
const creatorVersion = await getCreatorVersion();

if (semver.gte(creatorVersion, ANSIBLE_CREATOR_VERSION_MIN)) {
command = `ansible-creator init playbook ${namespace}.${collection} ${url} --no-ansi`;
Expand Down Expand Up @@ -345,19 +337,24 @@ export class CreateAnsibleProject {
? destinationPath
: `${os.homedir()}/${namespaceName}-${collectionName}`;

let ansibleCreatorInitCommand = await this.getCreatorCommand(
let ansibleCreatorInitCommand = await this.getPlaybookCreatorCommand(
namespaceName,
collectionName,
destinationPathUrl,
);

const creatorVersion = await this.getCreatorVersion();
if (isOverwritten) {
if (semver.gte(creatorVersion, ANSIBLE_CREATOR_VERSION_MIN)) {
ansibleCreatorInitCommand += " --overwrite";
} else {
ansibleCreatorInitCommand += " --force";
}
const creatorVersion = await getCreatorVersion();
const exceedMinVersion = semver.gte(
creatorVersion,
ANSIBLE_CREATOR_VERSION_MIN,
);

if (exceedMinVersion && isOverwritten) {
ansibleCreatorInitCommand += " --overwrite";
} else if (!exceedMinVersion && isOverwritten) {
ansibleCreatorInitCommand += " --force";
} else if (exceedMinVersion && !isOverwritten) {
ansibleCreatorInitCommand += " --no-overwrite";
}

switch (verbosity) {
Expand Down
8 changes: 8 additions & 0 deletions src/features/contentCreator/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ export async function getBinDetail(cmd: string, arg: string) {
}
}

export async function getCreatorVersion(): Promise<string> {
const creatorVersion = (
await getBinDetail("ansible-creator", "--version")
).toString();
console.log("ansible-creator version: ", creatorVersion);
return creatorVersion;
}

export async function runCommand(
command: string,
runEnv: NodeJS.ProcessEnv | undefined,
Expand Down
4 changes: 2 additions & 2 deletions src/features/lightspeed/utils/multiLinePromptForMultiTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ export function shouldRequestForPromptPosition(
documentContent: string,
promptLine: number,
): boolean {
const documentLines = documentContent.trim().split("\n");
const documentLines = documentContent.split("\n").map((l) => l.trim());
if (documentLines.length > 0 && promptLine > 0) {
const promptLineText = documentLines[promptLine - 1].trim();
const promptLineText = documentLines[promptLine - 1];
if (promptLineText.startsWith("# ") && promptLineText.endsWith(" &")) {
// should do not make request for prompt that ends with "&"
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ tasks:
});

describe("Test shouldRequestForPromptPosition", () => {
it("should trigger request even when document starts with empty line", () => {
const promptContent = `
---
# Create a key-pair called lightspeed-key-pair &
# create a vpc & create vpc_id var `;
const shouldRequest = shouldRequestForPromptPosition(promptContent, 4);
assert.equal(shouldRequest, true);
});

it("should not make request when prompt line start with '# ' and end with ' &' for tasks", () => {
const promptContent = `---
# Create a key-pair called lightspeed-key-pair &
Expand Down
Loading

0 comments on commit c58bf7e

Please sign in to comment.