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
4 changes: 4 additions & 0 deletions tools/spec-gen-sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release

## 2025-01-27 - 0.1.5

- Introduced a root folder to save all the logs and artifacts

## 2025-01-22 - 0.1.4

- Deprecated 'azure-sdk-for-net-track2' and repurposed 'azure-sdk-for-net' for the .NET track2 SDK
Expand Down
2 changes: 1 addition & 1 deletion tools/spec-gen-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"email": "azsdkteam@microsoft.com",
"url": "https://github.com/Azure/azure-sdk-tools"
},
"version": "0.1.4",
"version": "0.1.5",
"description": "A TypeScript implementation of the API specification to SDK tool",
"tags": [
"spec-gen-sdk"
Expand Down
28 changes: 16 additions & 12 deletions tools/spec-gen-sdk/src/automation/entrypoint.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as fs from 'fs';
import {existsSync, mkdirSync, readFileSync, rmSync} from 'fs';
import * as winston from 'winston';
import { getRepoKey, RepoKey } from '../utils/repo';
import {
Expand Down Expand Up @@ -67,18 +67,22 @@ export const getSdkAutoContext = async (options: SdkAutoOptions): Promise<SdkAut
logger.add(loggerTestTransport());
}

const fullLogFileName = path.join(options.workingFolder, 'full.log');
const filteredLogFileName = path.join(options.workingFolder, 'filtered.log');
const logFolder = path.join(options.workingFolder, 'out/logs');
if (!existsSync(logFolder)) {
mkdirSync(logFolder, { recursive: true });
}
const fullLogFileName = path.join(logFolder, 'full.log');
const filteredLogFileName = path.join(logFolder, 'filtered.log');
// eg: spec-gen-sdk-java-result.html
const htmlLogFileName = path.join(options.workingFolder, `spec-gen-sdk-${options.sdkName.substring("azure-sdk-for-".length)}-result.html`);
if (fs.existsSync(fullLogFileName)) {
fs.rmSync(fullLogFileName);
const htmlLogFileName = path.join(logFolder, `spec-gen-sdk-${options.sdkName.substring("azure-sdk-for-".length)}-result.html`);
if (existsSync(fullLogFileName)) {
rmSync(fullLogFileName);
}
if (fs.existsSync(filteredLogFileName)) {
fs.rmSync(filteredLogFileName);
if (existsSync(filteredLogFileName)) {
rmSync(filteredLogFileName);
}
if (fs.existsSync(htmlLogFileName)) {
fs.rmSync(htmlLogFileName);
if (existsSync(htmlLogFileName)) {
rmSync(htmlLogFileName);
}
logger.add(loggerFileTransport(fullLogFileName));
logger.info(`Log to ${fullLogFileName}`);
Expand All @@ -92,11 +96,11 @@ export const getSdkAutoContext = async (options: SdkAutoOptions): Promise<SdkAut
const swaggerToSdkConfig = getSwaggerToSdkConfig(swaggerToSdkConfigContent);

return {
htmlLogFileName,
config: options,
logger,
fullLogFileName,
filteredLogFileName,
htmlLogFileName,
specRepoConfig,
sdkRepoConfig,
swaggerToSdkConfig,
Expand Down Expand Up @@ -152,7 +156,7 @@ export const getLanguageByRepoName = (repoName: string) => {
export const loadConfigContent = (fileName: string, logger: winston.Logger) => {
logger.info(`Load config file: ${fileName}`);
try {
const fileContent = fs.readFileSync(fileName).toString();
const fileContent = readFileSync(fileName).toString();
const result = JSON.parse(fileContent);
return result;
}
Expand Down
6 changes: 3 additions & 3 deletions tools/spec-gen-sdk/src/automation/workflowPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const workflowPkgDetectArtifacts = async (context: WorkflowContext, pkg: Package
* @param context
* @param pkg
*
* Copy sdk artifact path to {work_dir}/generatedSdkArtifacts
* Copy sdk artifact path to {work_dir}/out/generatedSdkArtifacts
*/
const workflowPkgSaveSDKArtifact = async (context: WorkflowContext, pkg: PackageData) => {
context.logger.info(`Save ${pkg.artifactPaths.length} artifact to Azure devOps.`);
Expand All @@ -126,7 +126,7 @@ const workflowPkgSaveSDKArtifact = async (context: WorkflowContext, pkg: Package
return;
}

const destination = path.join(context.config.workingFolder, 'generatedSdkArtifacts');
const destination = path.join(context.config.workingFolder, 'out/generatedSdkArtifacts');
if (!existsSync(destination)) {
fs.mkdirSync(destination, { recursive: true });
}
Expand All @@ -152,7 +152,7 @@ const workflowPkgSaveApiViewArtifact = async (context: WorkflowContext, pkg: Pac
}

const language = pkg.language ?? getLanguageByRepoName(context.sdkRepoConfig.mainRepository.name);
const destination = path.join(context.config.workingFolder, 'sdkApiViewArtifacts');
const destination = path.join(context.config.workingFolder, 'out/sdkApiViewArtifacts');
if (!existsSync(destination)) {
fs.mkdirSync(destination, { recursive: true });
}
Expand Down