Merge pull request #111 from github/thyeggman/json-import-assertions
Add json import assertions
This commit is contained in:
@@ -37,7 +37,7 @@
|
|||||||
"watch": "tsc --build tsconfig.build.json --watch"
|
"watch": "tsc --build tsconfig.build.json --watch"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 16"
|
"node": ">= 16.15"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist/**/*"
|
"dist/**/*"
|
||||||
|
|||||||
@@ -46,7 +46,7 @@
|
|||||||
"yaml": "^2.1.3"
|
"yaml": "^2.1.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 16"
|
"node": ">= 16.15"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist/**/*"
|
"dist/**/*"
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
"yaml": "^2.1.1"
|
"yaml": "^2.1.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 16"
|
"node": ">= 16.15"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist/**/*"
|
"dist/**/*"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import descriptions from "./descriptions.json";
|
import descriptions from "./descriptions.json" assert {type: "json"};
|
||||||
|
|
||||||
export const RootContext = "root";
|
export const RootContext = "root";
|
||||||
|
|
||||||
|
|||||||
@@ -1,54 +1,54 @@
|
|||||||
import check_run from "./check_run.json";
|
import check_run from "./check_run.json" assert {type: "json"};
|
||||||
import check_suite from "./check_suite.json";
|
import check_suite from "./check_suite.json" assert {type: "json"};
|
||||||
import commit_comment from "./commit_comment.json";
|
import commit_comment from "./commit_comment.json" assert {type: "json"};
|
||||||
import content_reference from "./content_reference.json";
|
import content_reference from "./content_reference.json" assert {type: "json"};
|
||||||
import create from "./create.json";
|
import create from "./create.json" assert {type: "json"};
|
||||||
import deletePayload from "./delete.json";
|
import deletePayload from "./delete.json" assert {type: "json"};
|
||||||
import deploy_key from "./deploy_key.json";
|
import deploy_key from "./deploy_key.json" assert {type: "json"};
|
||||||
import deployment from "./deployment.json";
|
import deployment from "./deployment.json" assert {type: "json"};
|
||||||
import deployment_status from "./deployment_status.json";
|
import deployment_status from "./deployment_status.json" assert {type: "json"};
|
||||||
import fork from "./fork.json";
|
import fork from "./fork.json" assert {type: "json"};
|
||||||
import github_app_authorization from "./github_app_authorization.json";
|
import github_app_authorization from "./github_app_authorization.json" assert {type: "json"};
|
||||||
import gollum from "./gollum.json";
|
import gollum from "./gollum.json" assert {type: "json"};
|
||||||
import installation from "./installation.json";
|
import installation from "./installation.json" assert {type: "json"};
|
||||||
import installation_repositories from "./installation_repositories.json";
|
import installation_repositories from "./installation_repositories.json" assert {type: "json"};
|
||||||
import issue_comment from "./issue_comment.json";
|
import issue_comment from "./issue_comment.json" assert {type: "json"};
|
||||||
import issues from "./issues.json";
|
import issues from "./issues.json" assert {type: "json"};
|
||||||
import label from "./label.json";
|
import label from "./label.json" assert {type: "json"};
|
||||||
import marketplace_purchase from "./marketplace_purchase.json";
|
import marketplace_purchase from "./marketplace_purchase.json" assert {type: "json"};
|
||||||
import member from "./member.json";
|
import member from "./member.json" assert {type: "json"};
|
||||||
import membership from "./membership.json";
|
import membership from "./membership.json" assert {type: "json"};
|
||||||
import merge_group from "./merge_group.json";
|
import merge_group from "./merge_group.json" assert {type: "json"};
|
||||||
import meta from "./meta.json";
|
import meta from "./meta.json" assert {type: "json"};
|
||||||
import milestone from "./milestone.json";
|
import milestone from "./milestone.json" assert {type: "json"};
|
||||||
import org_block from "./org_block.json";
|
import org_block from "./org_block.json" assert {type: "json"};
|
||||||
import organization from "./organization.json";
|
import organization from "./organization.json" assert {type: "json"};
|
||||||
import packagePayload from "./package_payload.json";
|
import packagePayload from "./package_payload.json" assert {type: "json"};
|
||||||
import page_build from "./page_build.json";
|
import page_build from "./page_build.json" assert {type: "json"};
|
||||||
import ping from "./ping.json";
|
import ping from "./ping.json" assert {type: "json"};
|
||||||
import project from "./project.json";
|
import project from "./project.json" assert {type: "json"};
|
||||||
import project_card from "./project_card.json";
|
import project_card from "./project_card.json" assert {type: "json"};
|
||||||
import project_column from "./project_column.json";
|
import project_column from "./project_column.json" assert {type: "json"};
|
||||||
import publicPayload from "./public.json";
|
import publicPayload from "./public.json" assert {type: "json"};
|
||||||
import pull_request from "./pull_request.json";
|
import pull_request from "./pull_request.json" assert {type: "json"};
|
||||||
import pull_request_review from "./pull_request_review.json";
|
import pull_request_review from "./pull_request_review.json" assert {type: "json"};
|
||||||
import pull_request_review_comment from "./pull_request_review_comment.json";
|
import pull_request_review_comment from "./pull_request_review_comment.json" assert {type: "json"};
|
||||||
import push from "./push.json";
|
import push from "./push.json" assert {type: "json"};
|
||||||
import release from "./release.json";
|
import release from "./release.json" assert {type: "json"};
|
||||||
import repository from "./repository.json";
|
import repository from "./repository.json" assert {type: "json"};
|
||||||
import repository_dispatch from "./repository_dispatch.json";
|
import repository_dispatch from "./repository_dispatch.json" assert {type: "json"};
|
||||||
import repository_import from "./repository_import.json";
|
import repository_import from "./repository_import.json" assert {type: "json"};
|
||||||
import repository_vulnerability_alert from "./repository_vulnerability_alert.json";
|
import repository_vulnerability_alert from "./repository_vulnerability_alert.json" assert {type: "json"};
|
||||||
import schedule from "./schedule.json";
|
import schedule from "./schedule.json" assert {type: "json"};
|
||||||
import security_advisory from "./security_advisory.json";
|
import security_advisory from "./security_advisory.json" assert {type: "json"};
|
||||||
import sponsorship from "./sponsorship.json";
|
import sponsorship from "./sponsorship.json" assert {type: "json"};
|
||||||
import star from "./star.json";
|
import star from "./star.json" assert {type: "json"};
|
||||||
import status from "./status.json";
|
import status from "./status.json" assert {type: "json"};
|
||||||
import team from "./team.json";
|
import team from "./team.json" assert {type: "json"};
|
||||||
import team_add from "./team_add.json";
|
import team_add from "./team_add.json" assert {type: "json"};
|
||||||
import watch from "./watch.json";
|
import watch from "./watch.json" assert {type: "json"};
|
||||||
import workflow_dispatch from "./workflow_dispatch.json";
|
import workflow_dispatch from "./workflow_dispatch.json" assert {type: "json"};
|
||||||
import workflow_run from "./workflow_run.json";
|
import workflow_run from "./workflow_run.json" assert {type: "json"};
|
||||||
|
|
||||||
export const eventPayloads: {[key: string]: Object} = {
|
export const eventPayloads: {[key: string]: Object} = {
|
||||||
check_run,
|
check_run,
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ function testHoverConfig(tokenValue: string, tokenKey: string, description?: str
|
|||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
} satisfies DescriptionProvider
|
} satisfies DescriptionProvider
|
||||||
} satisfies HoverConfig
|
} satisfies HoverConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
describe("hover", () => {
|
describe("hover", () => {
|
||||||
@@ -146,7 +146,8 @@ jobs:
|
|||||||
expect(result).not.toBeUndefined();
|
expect(result).not.toBeUndefined();
|
||||||
|
|
||||||
// The `ref` is a `string` definition and inherits the context from `step-with`
|
// 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);
|
expect(result?.contents).toEqual(expected);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -164,11 +165,15 @@ jobs:
|
|||||||
ref|: main
|
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();
|
expect(result).not.toBeUndefined();
|
||||||
|
|
||||||
const expected = "The branch, tag or SHA to checkout.\n\n" +
|
const expected =
|
||||||
"**Context:** github, inputs, vars, needs, strategy, matrix, secrets, steps, job, runner, env, hashFiles(1,255)"
|
"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);
|
expect(result?.contents).toEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -184,6 +189,8 @@ jobs:
|
|||||||
|
|
||||||
const result = await hover(...getPositionFromCursor(input), testHoverConfig("uses", "non-empty-string", undefined));
|
const result = await hover(...getPositionFromCursor(input), testHoverConfig("uses", "non-empty-string", undefined));
|
||||||
expect(result).not.toBeUndefined();
|
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."
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ export async function hover(document: TextDocument, position: Position, config?:
|
|||||||
info(`Calculating hover for token with definition ${token.definition.key}`);
|
info(`Calculating hover for token with definition ${token.definition.key}`);
|
||||||
|
|
||||||
if (tokenResult.parent && isCronMappingValue(tokenResult)) {
|
if (tokenResult.parent && isCronMappingValue(tokenResult)) {
|
||||||
const tokenValue = (token as StringToken).value
|
const tokenValue = (token as StringToken).value;
|
||||||
let description = getCronDescription(tokenValue);
|
let description = getCronDescription(tokenValue);
|
||||||
if (description) {
|
if (description) {
|
||||||
return {
|
return {
|
||||||
@@ -82,7 +82,9 @@ async function getDescription(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isCronMappingValue(tokenResult: TokenResult): boolean {
|
function isCronMappingValue(tokenResult: TokenResult): boolean {
|
||||||
return tokenResult.parent?.definition?.key === "cron-mapping" &&
|
return (
|
||||||
|
tokenResult.parent?.definition?.key === "cron-mapping" &&
|
||||||
isString(tokenResult.token!) &&
|
isString(tokenResult.token!) &&
|
||||||
tokenResult.token.value !== "cron"
|
tokenResult.token.value !== "cron"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
"yaml": "^2.0.0-8"
|
"yaml": "^2.0.0-8"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 16"
|
"node": ">= 16.15"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist/**/*"
|
"dist/**/*"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {JSONObjectReader} from "../templates/json-object-reader";
|
import {JSONObjectReader} from "../templates/json-object-reader";
|
||||||
import {TemplateSchema} from "../templates/schema";
|
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;
|
let schema: TemplateSchema;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user