Skip to content
Prev Previous commit
Next Next commit
[spec-gen-sdk-runner] organize imports
  • Loading branch information
mikeharder committed Jul 24, 2025
commit 436f4ecfb01f33674f9395f9b9cbd28c6d6f971f
16 changes: 8 additions & 8 deletions eng/tools/spec-gen-sdk-runner/src/command-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import {
findReadmeFiles,
getArgumentValue,
getAllTypeSpecPaths,
objectToMap,
SpecConfigs,
} from "./utils.js";
import { LogIssueType, LogLevel, logMessage, setVsoVariable, vsoLogIssue } from "./log.js";
import { groupSpecConfigPaths } from "./spec-helpers.js";
import {
APIViewRequestData,
SdkName,
Expand All @@ -17,7 +11,13 @@ import {
SpecGenSdkRequiredSettings,
VsoLogs,
} from "./types.js";
import { groupSpecConfigPaths } from "./spec-helpers.js";
import {
findReadmeFiles,
getAllTypeSpecPaths,
getArgumentValue,
objectToMap,
SpecConfigs,
} from "./utils.js";

/**
* Load execution-report.json.
Expand Down
8 changes: 4 additions & 4 deletions eng/tools/spec-gen-sdk-runner/src/commands.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import fs from "node:fs";
import path from "node:path";
import { runSpecGenSdkCommand, resetGitRepo, SpecConfigs } from "./utils.js";
import { LogLevel, logMessage, vsoAddAttachment, vsoLogIssue } from "./log.js";
import { APIViewRequestData, SpecGenSdkCmdInput } from "./types.js";
import { detectChangedSpecConfigFiles } from "./spec-helpers.js";
import {
generateArtifact,
getBreakingChangeInfo,
Expand All @@ -15,6 +11,10 @@ import {
prepareSpecGenSdkCommand,
setPipelineVariables,
} from "./command-helpers.js";
import { LogLevel, logMessage, vsoAddAttachment, vsoLogIssue } from "./log.js";
import { detectChangedSpecConfigFiles } from "./spec-helpers.js";
import { APIViewRequestData, SpecGenSdkCmdInput } from "./types.js";
import { resetGitRepo, runSpecGenSdkCommand, SpecConfigs } from "./utils.js";

/**
* Generate SDK for a single spec.
Expand Down
6 changes: 3 additions & 3 deletions eng/tools/spec-gen-sdk-runner/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { exit } from "node:process";
import path from "node:path";
import { existsSync, mkdirSync } from "node:fs";
import { getArgumentValue } from "./utils.js";
import path from "node:path";
import { exit } from "node:process";
import {
generateSdkForBatchSpecs,
generateSdkForSingleSpec,
generateSdkForSpecPr,
} from "./commands.js";
import { getArgumentValue } from "./utils.js";

export async function main() {
// Get the arguments passed to the script
Expand Down
14 changes: 7 additions & 7 deletions eng/tools/spec-gen-sdk-runner/src/spec-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import path from "node:path";
import { logMessage } from "./log.js";
import { SpecGenSdkCmdInput } from "./types.js";
import {
createCombinedSpecs,
getChangedFiles,
getLastPathSegment,
groupPathsByService,
searchRelatedParentFolders,
searchSharedLibrary,
searchRelatedTypeSpecProjectBySharedLibrary,
groupPathsByService,
createCombinedSpecs,
type SpecResults,
searchSharedLibrary,
type ChangedSpecs,
type SpecConfigs,
getLastPathSegment,
type SpecResults,
} from "./utils.js";
import { logMessage } from "./log.js";
import { SpecGenSdkCmdInput } from "./types.js";

export const readmeMdRegex = /^readme.md$/;
export const typespecProjectRegex = /^tspconfig.yaml$/;
Expand Down
6 changes: 3 additions & 3 deletions eng/tools/spec-gen-sdk-runner/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { spawn, spawnSync, exec } from "node:child_process";
import path from "node:path";
import { exec, spawn, spawnSync } from "node:child_process";
import fs from "node:fs";
import { LogLevel, logMessage } from "./log.js";
import path from "node:path";
import { promisify } from "node:util";
import { LogLevel, logMessage } from "./log.js";

type Dirent = fs.Dirent;

Expand Down
12 changes: 6 additions & 6 deletions eng/tools/spec-gen-sdk-runner/test/command-helpers.test.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { describe, test, expect, vi, beforeEach } from "vitest";
import * as log from "../src/log.js";
import * as utils from "../src/utils.js";
import * as specHelpers from "../src/spec-helpers.js";
import { fileURLToPath } from "node:url";
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { beforeEach, describe, expect, test, vi } from "vitest";
import {
generateArtifact,
getBreakingChangeInfo,
getRequiredSettingValue,
getSpecPaths,
logIssuesToPipeline,
parseArguments,
prepareSpecGenSdkCommand,
generateArtifact,
setPipelineVariables,
} from "../src/command-helpers.js";
import * as log from "../src/log.js";
import { LogLevel } from "../src/log.js";
import * as specHelpers from "../src/spec-helpers.js";
import { APIViewRequestData } from "../src/types.js";
import * as utils from "../src/utils.js";

// Get the absolute path to the repo root
const currentFilePath = fileURLToPath(import.meta.url);
Expand Down
12 changes: 6 additions & 6 deletions eng/tools/spec-gen-sdk-runner/test/commands.test.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { describe, test, expect, vi, beforeEach, type Mock } from "vitest";
import * as utils from "../src/utils.js";
import fs from "node:fs";
import path from "node:path";
import { beforeEach, describe, expect, test, vi, type Mock } from "vitest";
import * as commandHelpers from "../src/command-helpers.js";
import {
generateSdkForBatchSpecs,
generateSdkForSingleSpec,
generateSdkForSpecPr,
} from "../src/commands.js";
import * as commandHelpers from "../src/command-helpers.js";
import * as log from "../src/log.js";
import * as changeFiles from "../src/spec-helpers.js";
import fs from "node:fs";
import path from "node:path";
import { LogLevel } from "../src/log.js";
import * as changeFiles from "../src/spec-helpers.js";
import * as utils from "../src/utils.js";

function getNormalizedFsCalls(mockFn: Mock): unknown[][] {
return mockFn.mock.calls.map((args: unknown[]) => {
Expand Down
8 changes: 4 additions & 4 deletions eng/tools/spec-gen-sdk-runner/test/log.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { describe, test, expect, vi, beforeEach, afterEach } from "vitest";
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
import {
logMessage,
LogLevel,
LogIssueType,
LogLevel,
logMessage,
setVsoVariable,
vsoAddAttachment,
vsoLogIssue,
setVsoVariable,
} from "../src/log.js";

const logSpy = vi.spyOn(console, "log").mockImplementation(() => {
Expand Down
8 changes: 4 additions & 4 deletions eng/tools/spec-gen-sdk-runner/test/spec-helpers.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { describe, test, expect, vi, beforeEach } from "vitest";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { beforeEach, describe, expect, test, vi } from "vitest";
import {
detectChangedSpecConfigFiles,
groupSpecConfigPaths,
processTypeSpecProjectsV2FolderStructure,
} from "../src/spec-helpers.js";
import { SpecGenSdkCmdInput } from "../src/types.js";
import { fileURLToPath } from "node:url";
import path from "node:path";
import {
type ChangedSpecs,
type SpecConfigs,
normalizePath,
getChangedFiles,
normalizePath,
} from "../src/utils.js";

vi.mock("../src/utils.js", async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, test, expect } from "vitest";
import { createCombinedSpecs, type SpecResults } from "../../src/utils.js";
import path from "node:path";
import { describe, expect, test } from "vitest";
import { createCombinedSpecs, type SpecResults } from "../../src/utils.js";

describe("createCombinedSpecs", () => {
test("combines specs from readme and typespec paths", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, test, expect } from "vitest";
import { describe, expect, test } from "vitest";
import { extractServiceName } from "../../src/utils";

describe("extractServiceName", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { describe, test, expect } from "vitest";
import { findParentWithFile } from "../../src/utils.js";
import { fileURLToPath } from "node:url";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { describe, expect, test } from "vitest";
import { typespecProjectRegex } from "../../src/spec-helpers.js";
import { findParentWithFile } from "../../src/utils.js";

describe("findParentWithFile", () => {
// Get the absolute path to the repo root
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, test, expect } from "vitest";
import { describe, expect, test } from "vitest";
import { getLastPathSegment } from "../../src/utils.js";

describe("getLastPathSegment", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, test, expect } from "vitest";
import { describe, expect, test } from "vitest";
import { groupPathsByService } from "../../src/utils.js";

describe("groupPathsByService", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { describe, test, expect } from "vitest";
import { searchRelatedParentFolders } from "../../src/utils.js";
import { fileURLToPath } from "node:url";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { describe, expect, test } from "vitest";
import { readmeMdRegex, typespecProjectRegex } from "../../src/spec-helpers.js";
import { searchRelatedParentFolders } from "../../src/utils.js";

describe("searchRelatedParentFolders", () => {
// Get the absolute path to the repo root
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, test, expect } from "vitest";
import { searchRelatedTypeSpecProjectBySharedLibrary } from "../../src/utils.js";
import { fileURLToPath } from "node:url";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { describe, expect, test } from "vitest";
import { searchRelatedTypeSpecProjectBySharedLibrary } from "../../src/utils.js";

describe("searchRelatedTypeSpecProjectBySharedLibrary", () => {
// Get the absolute path to the repo root
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { describe, test, expect } from "vitest";
import { searchSharedLibrary } from "../../src/utils.js";
import { fileURLToPath } from "node:url";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { describe, expect, test } from "vitest";
import { typespecProjectSharedLibraryRegex } from "../../src/spec-helpers.js";
import { searchSharedLibrary } from "../../src/utils.js";

describe("searchSharedLibrary", () => {
// Get the absolute path to the repo root
Expand Down
10 changes: 5 additions & 5 deletions eng/tools/spec-gen-sdk-runner/test/utils/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { describe, test, expect, beforeEach, vi } from "vitest";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { beforeEach, describe, expect, test, vi } from "vitest";
import {
findFilesRecursive,
findReadmeFiles,
getRelativePathFromSpecification,
getArgumentValue,
getRelativePathFromSpecification,
mapToObject,
objectToMap,
normalizePath,
objectToMap,
} from "../../src/utils.js";
import { fileURLToPath } from "node:url";
import path from "node:path";

// Get the absolute path to the repo root
const currentFilePath = fileURLToPath(import.meta.url);
Expand Down