Merge pull request #111 from github/thyeggman/json-import-assertions

Add json import assertions
This commit is contained in:
Jacob Wallraff
2023-01-30 11:02:46 -08:00
committed by GitHub
9 changed files with 74 additions and 65 deletions
+1 -1
View File
@@ -37,7 +37,7 @@
"watch": "tsc --build tsconfig.build.json --watch"
},
"engines": {
"node": ">= 16"
"node": ">= 16.15"
},
"files": [
"dist/**/*"
+1 -1
View File
@@ -46,7 +46,7 @@
"yaml": "^2.1.3"
},
"engines": {
"node": ">= 16"
"node": ">= 16.15"
},
"files": [
"dist/**/*"
+1 -1
View File
@@ -45,7 +45,7 @@
"yaml": "^2.1.1"
},
"engines": {
"node": ">= 16"
"node": ">= 16.15"
},
"files": [
"dist/**/*"
@@ -1,4 +1,4 @@
import descriptions from "./descriptions.json";
import descriptions from "./descriptions.json" assert {type: "json"};
export const RootContext = "root";
@@ -1,54 +1,54 @@
import check_run from "./check_run.json";
import check_suite from "./check_suite.json";
import commit_comment from "./commit_comment.json";
import content_reference from "./content_reference.json";
import create from "./create.json";
import deletePayload from "./delete.json";
import deploy_key from "./deploy_key.json";
import deployment from "./deployment.json";
import deployment_status from "./deployment_status.json";
import fork from "./fork.json";
import github_app_authorization from "./github_app_authorization.json";
import gollum from "./gollum.json";
import installation from "./installation.json";
import installation_repositories from "./installation_repositories.json";
import issue_comment from "./issue_comment.json";
import issues from "./issues.json";
import label from "./label.json";
import marketplace_purchase from "./marketplace_purchase.json";
import member from "./member.json";
import membership from "./membership.json";
import merge_group from "./merge_group.json";
import meta from "./meta.json";
import milestone from "./milestone.json";
import org_block from "./org_block.json";
import organization from "./organization.json";
import packagePayload from "./package_payload.json";
import page_build from "./page_build.json";
import ping from "./ping.json";
import project from "./project.json";
import project_card from "./project_card.json";
import project_column from "./project_column.json";
import publicPayload from "./public.json";
import pull_request from "./pull_request.json";
import pull_request_review from "./pull_request_review.json";
import pull_request_review_comment from "./pull_request_review_comment.json";
import push from "./push.json";
import release from "./release.json";
import repository from "./repository.json";
import repository_dispatch from "./repository_dispatch.json";
import repository_import from "./repository_import.json";
import repository_vulnerability_alert from "./repository_vulnerability_alert.json";
import schedule from "./schedule.json";
import security_advisory from "./security_advisory.json";
import sponsorship from "./sponsorship.json";
import star from "./star.json";
import status from "./status.json";
import team from "./team.json";
import team_add from "./team_add.json";
import watch from "./watch.json";
import workflow_dispatch from "./workflow_dispatch.json";
import workflow_run from "./workflow_run.json";
import check_run from "./check_run.json" assert {type: "json"};
import check_suite from "./check_suite.json" assert {type: "json"};
import commit_comment from "./commit_comment.json" assert {type: "json"};
import content_reference from "./content_reference.json" assert {type: "json"};
import create from "./create.json" assert {type: "json"};
import deletePayload from "./delete.json" assert {type: "json"};
import deploy_key from "./deploy_key.json" assert {type: "json"};
import deployment from "./deployment.json" assert {type: "json"};
import deployment_status from "./deployment_status.json" assert {type: "json"};
import fork from "./fork.json" assert {type: "json"};
import github_app_authorization from "./github_app_authorization.json" assert {type: "json"};
import gollum from "./gollum.json" assert {type: "json"};
import installation from "./installation.json" assert {type: "json"};
import installation_repositories from "./installation_repositories.json" assert {type: "json"};
import issue_comment from "./issue_comment.json" assert {type: "json"};
import issues from "./issues.json" assert {type: "json"};
import label from "./label.json" assert {type: "json"};
import marketplace_purchase from "./marketplace_purchase.json" assert {type: "json"};
import member from "./member.json" assert {type: "json"};
import membership from "./membership.json" assert {type: "json"};
import merge_group from "./merge_group.json" assert {type: "json"};
import meta from "./meta.json" assert {type: "json"};
import milestone from "./milestone.json" assert {type: "json"};
import org_block from "./org_block.json" assert {type: "json"};
import organization from "./organization.json" assert {type: "json"};
import packagePayload from "./package_payload.json" assert {type: "json"};
import page_build from "./page_build.json" assert {type: "json"};
import ping from "./ping.json" assert {type: "json"};
import project from "./project.json" assert {type: "json"};
import project_card from "./project_card.json" assert {type: "json"};
import project_column from "./project_column.json" assert {type: "json"};
import publicPayload from "./public.json" assert {type: "json"};
import pull_request from "./pull_request.json" assert {type: "json"};
import pull_request_review from "./pull_request_review.json" assert {type: "json"};
import pull_request_review_comment from "./pull_request_review_comment.json" assert {type: "json"};
import push from "./push.json" assert {type: "json"};
import release from "./release.json" assert {type: "json"};
import repository from "./repository.json" assert {type: "json"};
import repository_dispatch from "./repository_dispatch.json" assert {type: "json"};
import repository_import from "./repository_import.json" assert {type: "json"};
import repository_vulnerability_alert from "./repository_vulnerability_alert.json" assert {type: "json"};
import schedule from "./schedule.json" assert {type: "json"};
import security_advisory from "./security_advisory.json" assert {type: "json"};
import sponsorship from "./sponsorship.json" assert {type: "json"};
import star from "./star.json" assert {type: "json"};
import status from "./status.json" assert {type: "json"};
import team from "./team.json" assert {type: "json"};
import team_add from "./team_add.json" assert {type: "json"};
import watch from "./watch.json" assert {type: "json"};
import workflow_dispatch from "./workflow_dispatch.json" assert {type: "json"};
import workflow_run from "./workflow_run.json" assert {type: "json"};
export const eventPayloads: {[key: string]: Object} = {
check_run,
+13 -6
View File
@@ -17,7 +17,7 @@ function testHoverConfig(tokenValue: string, tokenKey: string, description?: str
return description;
}
} satisfies DescriptionProvider
} satisfies HoverConfig
} satisfies HoverConfig;
}
describe("hover", () => {
@@ -146,7 +146,8 @@ jobs:
expect(result).not.toBeUndefined();
// The `ref` is a `string` definition and inherits the context from `step-with`
const expected = "**Context:** github, inputs, vars, needs, strategy, matrix, secrets, steps, job, runner, env, hashFiles(1,255)"
const expected =
"**Context:** github, inputs, vars, needs, strategy, matrix, secrets, steps, job, runner, env, hashFiles(1,255)";
expect(result?.contents).toEqual(expected);
});
});
@@ -164,11 +165,15 @@ jobs:
ref|: main
`;
const result = await hover(...getPositionFromCursor(input), testHoverConfig("ref", "string", "The branch, tag or SHA to checkout."));
const result = await hover(
...getPositionFromCursor(input),
testHoverConfig("ref", "string", "The branch, tag or SHA to checkout.")
);
expect(result).not.toBeUndefined();
const expected = "The branch, tag or SHA to checkout.\n\n" +
"**Context:** github, inputs, vars, needs, strategy, matrix, secrets, steps, job, runner, env, hashFiles(1,255)"
const expected =
"The branch, tag or SHA to checkout.\n\n" +
"**Context:** github, inputs, vars, needs, strategy, matrix, secrets, steps, job, runner, env, hashFiles(1,255)";
expect(result?.contents).toEqual(expected);
});
@@ -184,6 +189,8 @@ jobs:
const result = await hover(...getPositionFromCursor(input), testHoverConfig("uses", "non-empty-string", undefined));
expect(result).not.toBeUndefined();
expect(result?.contents).toEqual("Selects an action to run as part of a step in your job. An action is a reusable unit of code. You can use an action defined in the same repository as the workflow, a public repository, or in a published Docker container image.");
expect(result?.contents).toEqual(
"Selects an action to run as part of a step in your job. An action is a reusable unit of code. You can use an action defined in the same repository as the workflow, a public repository, or in a published Docker container image."
);
});
});
+4 -2
View File
@@ -39,7 +39,7 @@ export async function hover(document: TextDocument, position: Position, config?:
info(`Calculating hover for token with definition ${token.definition.key}`);
if (tokenResult.parent && isCronMappingValue(tokenResult)) {
const tokenValue = (token as StringToken).value
const tokenValue = (token as StringToken).value;
let description = getCronDescription(tokenValue);
if (description) {
return {
@@ -82,7 +82,9 @@ async function getDescription(
}
function isCronMappingValue(tokenResult: TokenResult): boolean {
return tokenResult.parent?.definition?.key === "cron-mapping" &&
return (
tokenResult.parent?.definition?.key === "cron-mapping" &&
isString(tokenResult.token!) &&
tokenResult.token.value !== "cron"
);
}
+1 -1
View File
@@ -45,7 +45,7 @@
"yaml": "^2.0.0-8"
},
"engines": {
"node": ">= 16"
"node": ">= 16.15"
},
"files": [
"dist/**/*"
@@ -1,6 +1,6 @@
import {JSONObjectReader} from "../templates/json-object-reader";
import {TemplateSchema} from "../templates/schema";
import WorkflowSchema from "../workflow-v1.0.json";
import WorkflowSchema from "../workflow-v1.0.json" assert { type: 'json' };
let schema: TemplateSchema;