Fix: `entrypoints` folder not included in bundle and e2e tests (#2076)

This commit is contained in:
Timothee Guerin 2023-06-15 16:58:58 -07:00 коммит произвёл GitHub
Родитель 40ea9c3c5e
Коммит 14012019ff
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
5 изменённых файлов: 32 добавлений и 22 удалений

Просмотреть файл

@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@typespec/compiler",
"comment": "Fix: `entrypoints` folder wasn't included in package causing failure to resolve cli.js",
"type": "none"
}
],
"packageName": "@typespec/compiler"
}

Просмотреть файл

@ -1,2 +1,4 @@
import "@typespec/rest";
import "@typespec/openapi3";
op ping(): void;

Просмотреть файл

@ -41,24 +41,24 @@ function packPackages() {
console.log("Built packages:", files);
function resolvePackage(start) {
return join(
outputFolder,
// @ts-ignore
files.find((x) => x.startsWith(start))
);
const pkgName = files.find((x) => x.startsWith(start));
if (pkgName === undefined) {
throw new Error(`Cannot resolve package starting with "${start}"`);
}
return join(outputFolder, pkgName);
}
return {
"@typespec/compiler": resolvePackage("typespec-lang-compiler-"),
"@typespec/openapi": resolvePackage("typespec-lang-openapi-"),
"@typespec/openapi3": resolvePackage("typespec-lang-openapi3-"),
"@typespec/rest": resolvePackage("typespec-lang-rest-"),
"@typespec/versioning": resolvePackage("typespec-lang-versioning-"),
"@typespec/compiler": resolvePackage("typespec-compiler-"),
"@typespec/openapi": resolvePackage("typespec-openapi-"),
"@typespec/openapi3": resolvePackage("typespec-openapi3-"),
"@typespec/rest": resolvePackage("typespec-rest-"),
"@typespec/versioning": resolvePackage("typespec-versioning-"),
};
}
function runTypeSpec(compilerTgz, args, options) {
run(npxCmd, ["-p", compilerTgz, "typespec", ...args], { ...options });
run(npxCmd, ["-y", "-p", compilerTgz, "tsp", ...args], { ...options });
}
function testBasicLatest(packages) {
@ -78,11 +78,7 @@ function testBasicLatest(packages) {
});
console.log("Completed tsp compile .");
if (existsSync(join(outputDir, "openapi.json"))) {
console.log("Output created successfully.");
} else {
throw new Error("Test basic latest failed to produce output openapi.json");
}
expectOpenApiOutput(outputDir);
}
function testBasicCurrentTgz(packages) {
@ -117,9 +113,14 @@ function testBasicCurrentTgz(packages) {
});
console.log("Completed tsp compile .");
if (existsSync(join(outputDir, "openapi.json"))) {
expectOpenApiOutput(outputDir);
}
function expectOpenApiOutput(outputDir) {
const expectedOutputFile = join(outputDir, "@typespec/openapi3/openapi.yaml");
if (existsSync(expectedOutputFile)) {
console.log("Output created successfully.");
} else {
throw new Error("Test basic latest failed to produce output openapi.json");
throw new Error(`Test failed to produce openapi output at "${expectedOutputFile}"`);
}
}

Просмотреть файл

@ -58,10 +58,6 @@ steps:
- script: node common/scripts/install-run-rush.js e2e
displayName: E2E Tests
# Skipping the e2e test on the prepare publish branch as there is a bug in the npm version installed on node 16
# causing npx to try to download the unpublished version of the cli.
condition: eq('${{ parameters.nodeVersion }}', '18.x')
# condition: and(not(startsWith(variables['System.PullRequest.SourceBranch'], 'publish/')), not(eq('${{ parameters.nodeVersion }}', '16.x')))
# Unlink node_modules folders to significantly improve performance of subsequent tasks
# which need to walk the directory tree (and are hardcoded to follow symlinks).

Просмотреть файл

@ -53,6 +53,7 @@
"files": [
"lib/*.tsp",
"dist/**",
"entrypoints",
"!dist/test/**"
],
"scripts": {