Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,115 changes: 2,135 additions & 980 deletions tools/tsp-client/package-lock.json

Large diffs are not rendered by default.

16 changes: 4 additions & 12 deletions tools/tsp-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"purge": "rimraf ./node_modules package-lock.json",
"example": "npx tsx src/index.ts update -o ./test/examples/sdk/contosowidgetmanager/contosowidgetmanager-rest/",
"prepack": "npm run build",
"test": "mocha",
"test": "vitest run",
"test:commands": "npx tsx ./test/run_commands.ts",
"tsp-client": "node cmd/tsp-client.js",
"watch": "tsc -p . --watch"
Expand All @@ -38,24 +38,23 @@
],
"devDependencies": {
"@types/chai": "^4.3.5",
"@types/mocha": "^10.0.1",
"@types/node": "^20.4.8",
"@types/prompt-sync": "^4.2.1",
"@typespec/compiler": "^0.58.0",
"chai": "^4.3.7",
"mocha": "^10.5.2",
"prettier": "^3.0.1",
"rimraf": "^5.0.1",
"ts-node": "^10.9.1",
"tsx": "^4.16.2",
"typescript": "^5.1.6"
"typescript": "^5.1.6",
"vitest": "^2.1.4"
},
"dependencies": {
"@autorest/core": "^3.10.2",
"@autorest/openapi-to-typespec": "0.10.3",
"@azure-tools/rest-api-diff": ">=0.1.0 <1.0.0",
"@azure-tools/typespec-autorest": ">=0.44.0 <1.0.0",
"@azure/core-rest-pipeline": "^1.12.0",
"@azure-tools/rest-api-diff": ">=0.1.0 <1.0.0",
"@types/yargs": "^17.0.32",
"autorest": "^3.7.1",
"chalk": "^5.3.0",
Expand All @@ -67,12 +66,5 @@
},
"peerDependencies": {
"@typespec/compiler": ">=0.58.0 <1.0.0"
},
"mocha": {
"extension": [
"ts"
],
"spec": "test/*.spec.ts",
"loader": "ts-node/esm"
}
}
37 changes: 19 additions & 18 deletions tools/tsp-client/test/commands.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,44 @@ import {
updateCommand,
generateLockFileCommand,
} from "../src/commands.js";
import { after, before, describe, it } from "node:test";
import { afterAll, beforeAll, describe, it } from "vitest";
import { assert } from "chai";
import { getRepoRoot } from "../src/git.js";
import { cwd } from "node:process";
import { joinPaths } from "@typespec/compiler";

describe("Verify commands", async function () {
before(async function () {
describe.sequential("Verify commands", () => {
let repoRoot;
beforeAll(async () => {
repoRoot = await getRepoRoot(cwd());
await cp(
"./test/utils/emitter-package.json",
joinPaths(await getRepoRoot(cwd()), "eng", "emitter-package.json"),
joinPaths(repoRoot, "eng", "emitter-package.json"),
);
});

after(async function () {
await rm(joinPaths(await getRepoRoot(cwd()), "eng", "emitter-package.json"));
afterAll(async () => {
await rm(joinPaths(repoRoot, "eng", "emitter-package.json"));
// This is generated in the first test using the command
await rm(joinPaths(await getRepoRoot(cwd()), "eng", "emitter-package-lock.json"));
await rm(joinPaths(repoRoot, "eng", "emitter-package-lock.json"));
await rm(
"./test/examples/sdk/contosowidgetmanager/contosowidgetmanager-rest/TempTypeSpecFiles/",
{ recursive: true },
);
await rm("./test/examples/sdk/local-spec-sdk/TempTypeSpecFiles/", { recursive: true });
});

await it("Generate lock file", async function () {
it("Generate lock file", async () => {
try {
await generateLockFileCommand({});

const repoRoot = await getRepoRoot(cwd());
assert.isTrue((await stat(joinPaths(repoRoot, "eng", "emitter-package-lock.json"))).isFile());
} catch (error) {
assert.fail(`Failed to generate lock file. Error: ${error}`);
}
});

await it("Sync example sdk", async function () {
it("Sync example sdk", async () => {
try {
const args = {
"output-dir": joinPaths(
Expand All @@ -60,7 +61,7 @@ describe("Verify commands", async function () {
assert.isTrue(dir.isDirectory());
});

await it("Sync example sdk with local spec", async function () {
it("Sync example sdk with local spec", async () => {
try {
const args = {
"output-dir": joinPaths(cwd(), "./test/examples/sdk/local-spec-sdk"),
Expand All @@ -75,7 +76,7 @@ describe("Verify commands", async function () {
assert.isTrue(dir.isDirectory());
});

await it("Generate example sdk", async function () {
it("Generate example sdk", async () => {
try {
const args = {
"output-dir": joinPaths(
Expand All @@ -94,7 +95,7 @@ describe("Verify commands", async function () {
assert.isTrue(dir.isFile());
});

await it("Update example sdk", async function () {
it("Update example sdk", async () => {
try {
const args = {
"output-dir": joinPaths(
Expand All @@ -109,7 +110,7 @@ describe("Verify commands", async function () {
}
});

await it("Update example sdk & pass tspconfig.yaml", async function () {
it("Update example sdk & pass tspconfig.yaml", async () => {
try {
const args = {
"output-dir": joinPaths(
Expand All @@ -126,7 +127,7 @@ describe("Verify commands", async function () {
}
});

await it("Update example sdk & pass commit", async function () {
it("Update example sdk & pass commit", async () => {
try {
const args = {
"output-dir": joinPaths(
Expand All @@ -142,7 +143,7 @@ describe("Verify commands", async function () {
}
});

await it("Update example sdk & pass only --repo", async function () {
it("Update example sdk & pass only --repo", async () => {
try {
const args = {
"output-dir": joinPaths(
Expand All @@ -162,7 +163,7 @@ describe("Verify commands", async function () {
}
});

await it.skip("Init example sdk", async function () {
it.skip("Init example sdk", async () => {
try {
const args = {
"output-dir": joinPaths(cwd(), "./test/examples/"),
Expand All @@ -184,7 +185,7 @@ describe("Verify commands", async function () {
}
});

await it.skip("Init with --skip-sync-and-generate", async function () {
it.skip("Init with --skip-sync-and-generate", async () => {
try {
const args = {
"output-dir": joinPaths(cwd(), "./test/examples/"),
Expand Down
2 changes: 1 addition & 1 deletion tools/tsp-client/test/network.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it } from "node:test";
import { describe, it } from "vitest";
import { doesFileExist, isValidUrl } from "../src/network.js";
import { assert } from "chai";

Expand Down
2 changes: 1 addition & 1 deletion tools/tsp-client/test/tspLocation.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assert } from "chai";
import { normalizeDirectory, readTspLocation } from "../src/fs.js";
import { describe, it } from "node:test";
import { describe, it } from "vitest";
import { writeTspLocationYaml } from "../src/utils.js";
import { stat } from "node:fs/promises";

Expand Down
2 changes: 1 addition & 1 deletion tools/tsp-client/test/typespec.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert } from "chai";
import { describe, it } from "node:test";
import { describe, it } from "vitest";
import { compileTsp, discoverMainFile } from "../src/typespec.js";
import { joinPaths, resolvePath } from "@typespec/compiler";

Expand Down
2 changes: 1 addition & 1 deletion tools/tsp-client/test/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it } from "node:test";
import { describe, it } from "vitest";
import {
formatAdditionalDirectories,
getAdditionalDirectoryName,
Expand Down
8 changes: 8 additions & 0 deletions tools/tsp-client/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
testTimeout: 60_000,
exclude: ["test/examples/**", "dist/**", "**/node_modules/**"],
},
});