Skip to content

Commit

Permalink
[@typespec/spector] Update start server scenario paths (#5309)
Browse files Browse the repository at this point in the history
With my earlier PRs, I have already moved all the `scenarioPath`
parameters to `scenarioPaths` parameter i.e. made that parameter from a
single value to an array of values.

But, this start script was missed earlier. But, the Go SDK generator
uses this script and need this to be updated. This PR acoomplishes that.

Please review and approve this PR. Thanks
  • Loading branch information
sarangan12 authored Dec 10, 2024
1 parent 4f95f63 commit 2a03294
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@typespec/spector"
---

Update `server start` script parameter - `scenarioPath` to `scenarioPaths`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@typespec/spec-coverage-sdk"
---

Added packageName property to metadata
4 changes: 4 additions & 0 deletions packages/spec-coverage-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log - @typespec/spec-coverage-sdk

## 0.1.0-alpha.2

- Added `packageName` to `scenariosMetadata`.

## 0.1.0-alpha.1

No changes, version bump only.
Expand Down
2 changes: 1 addition & 1 deletion packages/spec-coverage-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typespec/spec-coverage-sdk",
"version": "0.1.0-alpha.1",
"version": "0.1.0-alpha.2",
"description": "Spec utility to manage the reported coverage",
"main": "dist/index.js",
"type": "module",
Expand Down
1 change: 1 addition & 0 deletions packages/spec-coverage-sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export interface ResolvedCoverageReport extends CoverageReport {
export interface ScenariosMetadata {
version: string;
commit: string;
packageName: string;
}

export interface GeneratorMetadata {
Expand Down
36 changes: 20 additions & 16 deletions packages/spec-dashboard/src/apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,31 @@ import {
const storageAccountName = "typespec";

export type GeneratorNames =
| "python"
| "typescript/rlc"
| "typescript/modular"
| "csharp"
| "@typespec/http-client-python"
| "@azure-tools/typespec-python"
| "@azure-tools/typespec-go"
| "@azure-tools/typespec-csharp"
| "@typespec/http-client-csharp"
| "java"
| "go"
| "cpp"
| "rust"
| "@azure-tools/typespec-ts-rlc"
| "@azure-tools/typespec-ts-modular"
| "@azure-tools/typespec-java"
| "@typespec/http-client-java"
| "@azure-tools/typespec-cpp"
| "@azure-tools/typespec-rust"
| "test";
const query = new URLSearchParams(window.location.search);
const generatorNames: GeneratorNames[] = [
"python",
"typescript/rlc",
"typescript/modular",
"csharp",
"@typespec/http-client-python",
"@azure-tools/typespec-python",
"@azure-tools/typespec-go",
"@azure-tools/typespec-csharp",
"@typespec/http-client-csharp",
"java",
"go",
"cpp",
"rust",
"@azure-tools/typespec-ts-rlc",
"@azure-tools/typespec-ts-modular",
"@azure-tools/typespec-java",
"@typespec/http-client-java",
"@azure-tools/typespec-cpp",
"@azure-tools/typespec-rust",
...(query.has("showtest") ? (["test"] as const) : []),
];

Expand Down
4 changes: 4 additions & 0 deletions packages/spector/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log - @typespec/spector

## 0.1.0-alpha.4

- Update `server start` script parameter - `scenarioPath` to `scenarioPaths`.

## 0.1.0-alpha.3

No changes, version bump only.
Expand Down
2 changes: 1 addition & 1 deletion packages/spector/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@typespec/spector",
"version": "0.1.0-alpha.3",
"version": "0.1.0-alpha.4",
"description": "Typespec Core Tool to validate, run mock api, collect coverage.",
"exports": {
".": {
Expand Down
6 changes: 3 additions & 3 deletions packages/spector/src/actions/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ export async function startInBackground(config: ServeConfig) {
const [nodeExe, entrypoint] = process.argv;
logger.info(`Starting server in background at port ${config.port}`);
const scenariosPath = Array.isArray(config.scenariosPath)
? config.scenariosPath.join(" ")
: config.scenariosPath;
? config.scenariosPath
: [config.scenariosPath];
const cp = spawn(
nodeExe,
[
entrypoint,
"serve",
scenariosPath,
...scenariosPath,
"--port",
config.port.toString(),
"--coverageFile",
Expand Down
9 changes: 5 additions & 4 deletions packages/spector/src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,14 @@ async function main() {
.command("server", "Server management", (cmd) => {
cmd
.command(
"start <scenariosPath>",
"start <scenariosPaths..>",
"Start the server in the background.",
(cmd) => {
return cmd
.positional("scenariosPath", {
description: "Path to the scenarios and mock apis",
.positional("scenariosPaths", {
description: "Path(s) to the scenarios and mock apis",
type: "string",
array: true,
demandOption: true,
})
.option("port", {
Expand All @@ -115,7 +116,7 @@ async function main() {
},
async (args) =>
startInBackground({
scenariosPath: resolve(process.cwd(), args.scenariosPath),
scenariosPath: args.scenariosPaths,
port: args.port,
coverageFile: args.coverageFile,
}),
Expand Down
1 change: 1 addition & 0 deletions packages/spector/src/coverage/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ export async function getScenarioMetadata(scenariosPath: string): Promise<Scenar
return {
commit: getCommit(scenariosPath),
version: pkg?.version ?? "?",
packageName: pkg?.name ?? "@typespec/http-specs",
};
}

0 comments on commit 2a03294

Please sign in to comment.