This commit is contained in:
qiaozha 2021-01-15 14:53:12 +08:00
Родитель 4514199e01
Коммит 2c8015ec25
24 изменённых файлов: 182 добавлений и 182 удалений

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

@ -3,83 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*-------------------------------------------------------------------------------------------- */
import { Operation, OperationGroup, Parameter, Property, Schema } from '@azure-tools/codemodel';
import { Operation, OperationGroup, Parameter, Schema } from '@azure-tools/codemodel';
import { CodeModelTypes, DataGraph, GenerationMode, RenderInput } from '../utils/models';
import { ResourcePool } from './renders/tests/ScenarioTool';
export class MethodParam {
public value: any;
public isList: boolean;
public isSimpleListOrArray: boolean;
public submethodparameters: Property[];
public inBody: boolean;
public constructor(value, isList, isSimpleListOrArray, submethodparameters, inBody) {
this.value = value;
this.isList = isList;
this.isSimpleListOrArray = isSimpleListOrArray;
this.submethodparameters = submethodparameters;
this.inBody = inBody;
}
}
export enum KeyValueType {
No,
Classic,
PositionalKey,
ShorthandSyntax,
SimpleArray,
}
export class ExampleParam {
name: string;
value: any;
isJson: boolean;
keyValue: KeyValueType;
keys: string[];
defaultName: string;
methodParam: MethodParam;
ancestors: string[];
replacedValue: any;
rawValue: any;
public constructor(
name: string,
value: any,
isJson: boolean,
keyValue: KeyValueType,
keys: string[],
defaultName: string,
methodParam: MethodParam,
ancestors: string[],
rawValue: any,
) {
this.name = name;
this.value = value;
this.isJson = isJson;
this.keyValue = keyValue;
this.keys = keys;
this.defaultName = defaultName;
this.methodParam = methodParam;
this.ancestors = ancestors;
this.rawValue = rawValue;
}
}
export class CommandExample {
// this should be "create", "update", "list", "show", or custom name
public Method: string;
public Id: string;
public Title: string;
public Parameters: ExampleParam[];
// public MethodName: string;
public Path: string;
public ResourceClassName: string;
public HttpMethod: string; // Get, Post, Put ...
public MethodResponses: any[];
public Method_IsLongRun: boolean;
public MethodParams: MethodParam[];
public ExampleObj: any;
public CommandString: string;
public WaitCommandString: string;
}
import { CommandExample } from './climodels/ExampleType';
export interface CodeModelAz {
init(): any;

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

@ -40,13 +40,8 @@ import {
RenderInput,
DataGraph,
} from '../utils/models';
import {
CodeModelAz,
CommandExample,
ExampleParam,
MethodParam,
KeyValueType,
} from './CodeModelAz';
import { CodeModelAz } from './CodeModelAz';
import { CommandExample, ExampleParam, MethodParam, KeyValueType } from './climodels/ExampleType';
import {
azOptions,
GenerateDefaultTestScenario,

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

@ -4,7 +4,7 @@ import { EOL } from 'os';
import * as path from 'path';
import { isNullOrUndefined } from '../utils/helper';
import { CodeGenConstants, PathConstants, AzConfiguration } from '../utils/models';
import { AzGeneratorFactory } from './AzGeneratorFactory';
import { AzGeneratorFactory } from './generators/AzGeneratorFactory';
import { CodeModelCliImpl } from './CodeModelAzImpl';
import { openInplaceGen, closeInplaceGen } from '../utils/inplace';

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

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

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

@ -0,0 +1,75 @@
import { Property } from '@azure-tools/codemodel';
export class MethodParam {
public value: any;
public isList: boolean;
public isSimpleListOrArray: boolean;
public submethodparameters: Property[];
public inBody: boolean;
public constructor(value, isList, isSimpleListOrArray, submethodparameters, inBody) {
this.value = value;
this.isList = isList;
this.isSimpleListOrArray = isSimpleListOrArray;
this.submethodparameters = submethodparameters;
this.inBody = inBody;
}
}
export enum KeyValueType {
No,
Classic,
PositionalKey,
ShorthandSyntax,
SimpleArray,
}
export class ExampleParam {
name: string;
value: any;
isJson: boolean;
keyValue: KeyValueType;
keys: string[];
defaultName: string;
methodParam: MethodParam;
ancestors: string[];
replacedValue: any;
rawValue: any;
public constructor(
name: string,
value: any,
isJson: boolean,
keyValue: KeyValueType,
keys: string[],
defaultName: string,
methodParam: MethodParam,
ancestors: string[],
rawValue: any,
) {
this.name = name;
this.value = value;
this.isJson = isJson;
this.keyValue = keyValue;
this.keys = keys;
this.defaultName = defaultName;
this.methodParam = methodParam;
this.ancestors = ancestors;
this.rawValue = rawValue;
}
}
export class CommandExample {
// this should be "create", "update", "list", "show", or custom name
public Method: string;
public Id: string;
public Title: string;
public Parameters: ExampleParam[];
// public MethodName: string;
public Path: string;
public ResourceClassName: string;
public HttpMethod: string; // Get, Post, Put ...
public MethodResponses: any[];
public Method_IsLongRun: boolean;
public MethodParams: MethodParam[];
public ExampleObj: any;
public CommandString: string;
public WaitCommandString: string;
}

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

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

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

@ -1,27 +1,27 @@
import * as path from 'path';
import { SystemType, PathConstants } from '../utils/models';
import { SystemType, PathConstants } from '../../utils/models';
import { AzGeneratorBase } from './AzGeneratorBase';
import { CodeModelAz } from './CodeModelAz';
import { GenerateNamespaceInit } from './renders/CliNamespaceInit';
import { CliReport } from './renders/CliReport';
import { CliTopAction } from './renders/CliTopAction';
import { CliTopCustom } from './renders/CliTopCustom';
import { CliTopInit } from './renders/CliTopInit';
import { CliMainDocSourceJsonMap } from './renders/extraMain/CliMainDocSourceJsonMap';
import { CliMainRequirement } from './renders/extraMain/CliMainRequirement';
import { CliMainSetupPy } from './renders/extraMain/CliMainSetupPy';
import { GenerateAzureCliActions } from './renders/generated/CliActions';
import { GenerateAzureCliClientFactory } from './renders/generated/CliClientFactory';
import { GenerateAzureCliCommands } from './renders/generated/CliCommands';
import { GenerateAzureCliCustom } from './renders/generated/CliCustom';
import { GenerateAzureCliHelp } from './renders/generated/CliHelp';
import { GenerateAzureCliParams } from './renders/generated/CliParams';
import { GenerateAzureCliValidators } from './renders/generated/CliValidators';
import { CliTestInit } from './renders/tests/CliTestInit';
import { CliTestPrepare } from './renders/tests/CliTestPrepare';
import { CliTestScenario } from './renders/tests/CliTestScenario';
import { CliTestStep, NeedPreparer } from './renders/tests/CliTestStep';
import { GenerateMetaFile } from './renders/CliMeta';
import { CodeModelAz } from '../CodeModelAz';
import { GenerateNamespaceInit } from '../renders/CliNamespaceInit';
import { CliReport } from '../renders/CliReport';
import { CliTopAction } from '../renders/CliTopAction';
import { CliTopCustom } from '../renders/CliTopCustom';
import { CliTopInit } from '../renders/CliTopInit';
import { CliMainDocSourceJsonMap } from '../renders/extraMain/CliMainDocSourceJsonMap';
import { CliMainRequirement } from '../renders/extraMain/CliMainRequirement';
import { CliMainSetupPy } from '../renders/extraMain/CliMainSetupPy';
import { GenerateAzureCliActions } from '../renders/generated/CliActions';
import { GenerateAzureCliClientFactory } from '../renders/generated/CliClientFactory';
import { GenerateAzureCliCommands } from '../renders/generated/CliCommands';
import { GenerateAzureCliCustom } from '../renders/generated/CliCustom';
import { GenerateAzureCliHelp } from '../renders/generated/CliHelp';
import { GenerateAzureCliParams } from '../renders/generated/CliParams';
import { GenerateAzureCliValidators } from '../renders/generated/CliValidators';
import { CliTestInit } from '../renders/tests/CliTestInit';
import { CliTestPrepare } from '../renders/tests/CliTestPrepare';
import { CliTestScenario } from '../renders/tests/CliTestScenario';
import { CliTestStep, NeedPreparer } from '../renders/tests/CliTestStep';
import { GenerateMetaFile } from '../renders/CliMeta';
export class AzCoreFullGenerator extends AzGeneratorBase {
constructor(model: CodeModelAz, isDebugMode: boolean) {
super(model, isDebugMode);

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

@ -4,29 +4,29 @@
*-------------------------------------------------------------------------------------------- */
import * as fs from 'fs';
import * as path from 'path';
import { PathConstants, SystemType } from '../utils/models';
import { PathConstants, SystemType } from '../../utils/models';
import { AzGeneratorBase } from './AzGeneratorBase';
import { CodeModelAz } from './CodeModelAz';
import { GenerateNamespaceInit } from './renders/CliNamespaceInit';
import { CliReport } from './renders/CliReport';
import { CliTopAction } from './renders/CliTopAction';
import { CliTopCustom } from './renders/CliTopCustom';
import { CliTopHelp } from './renders/CliTopHelp';
import { CliTopInit } from './renders/CliTopInit';
import { CliMainRequirement } from './renders/extraMain/CliMainRequirement';
import { CliMainSetupPy } from './renders/extraMain/CliMainSetupPy';
import { GenerateAzureCliActions } from './renders/generated/CliActions';
import { GenerateAzureCliClientFactory } from './renders/generated/CliClientFactory';
import { GenerateAzureCliCommands } from './renders/generated/CliCommands';
import { GenerateAzureCliCustom } from './renders/generated/CliCustom';
import { GenerateAzureCliHelp } from './renders/generated/CliHelp';
import { GenerateAzureCliParams } from './renders/generated/CliParams';
import { GenerateAzureCliValidators } from './renders/generated/CliValidators';
import { CliTestInit } from './renders/tests/CliTestInit';
import { CliTestPrepare } from './renders/tests/CliTestPrepare';
import { CliTestScenario } from './renders/tests/CliTestScenario';
import { CliTestStep, NeedPreparer } from './renders/tests/CliTestStep';
import { GenerateMetaFile } from './renders/CliMeta';
import { CodeModelAz } from '../CodeModelAz';
import { GenerateNamespaceInit } from '../renders/CliNamespaceInit';
import { CliReport } from '../renders/CliReport';
import { CliTopAction } from '../renders/CliTopAction';
import { CliTopCustom } from '../renders/CliTopCustom';
import { CliTopHelp } from '../renders/CliTopHelp';
import { CliTopInit } from '../renders/CliTopInit';
import { CliMainRequirement } from '../renders/extraMain/CliMainRequirement';
import { CliMainSetupPy } from '../renders/extraMain/CliMainSetupPy';
import { GenerateAzureCliActions } from '../renders/generated/CliActions';
import { GenerateAzureCliClientFactory } from '../renders/generated/CliClientFactory';
import { GenerateAzureCliCommands } from '../renders/generated/CliCommands';
import { GenerateAzureCliCustom } from '../renders/generated/CliCustom';
import { GenerateAzureCliHelp } from '../renders/generated/CliHelp';
import { GenerateAzureCliParams } from '../renders/generated/CliParams';
import { GenerateAzureCliValidators } from '../renders/generated/CliValidators';
import { CliTestInit } from '../renders/tests/CliTestInit';
import { CliTestPrepare } from '../renders/tests/CliTestPrepare';
import { CliTestScenario } from '../renders/tests/CliTestScenario';
import { CliTestStep, NeedPreparer } from '../renders/tests/CliTestStep';
import { GenerateMetaFile } from '../renders/CliMeta';
export class AzCoreIncrementalGenerator extends AzGeneratorBase {
constructor(model: CodeModelAz, isDebugMode: boolean) {

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

@ -4,30 +4,30 @@
*-------------------------------------------------------------------------------------------- */
import * as path from 'path';
import { AzGeneratorBase } from './AzGeneratorBase';
import { CodeModelAz } from './CodeModelAz';
import { GenerateNamespaceInit } from './renders/CliNamespaceInit';
import { CliReport } from './renders/CliReport';
import { CliTopAction } from './renders/CliTopAction';
import { CliTopCustom } from './renders/CliTopCustom';
import { CliTopInit } from './renders/CliTopInit';
import { GenerateAzureCliHistory } from './renders/extraExt/CliExtHistory';
import { CliTopMetadata } from './renders/extraExt/CliExtMetadata';
import { CliExtReadme } from './renders/extraExt/CliExtReadme';
import { GenerateAzureCliSetupCfg } from './renders/extraExt/CliExtSetupCfg';
import { CliExtSetupPy } from './renders/extraExt/CliExtSetupPy';
import { GenerateAzureCliActions } from './renders/generated/CliActions';
import { GenerateAzureCliClientFactory } from './renders/generated/CliClientFactory';
import { GenerateAzureCliCommands } from './renders/generated/CliCommands';
import { GenerateAzureCliCustom } from './renders/generated/CliCustom';
import { GenerateAzureCliHelp } from './renders/generated/CliHelp';
import { GenerateAzureCliParams } from './renders/generated/CliParams';
import { GenerateAzureCliValidators } from './renders/generated/CliValidators';
import { CliTestInit } from './renders/tests/CliTestInit';
import { CliTestPrepare } from './renders/tests/CliTestPrepare';
import { CliTestScenario } from './renders/tests/CliTestScenario';
import { PathConstants } from '../utils/models';
import { CliTestStep, NeedPreparer } from './renders/tests/CliTestStep';
import { GenerateMetaFile } from './renders/CliMeta';
import { CodeModelAz } from '../CodeModelAz';
import { GenerateNamespaceInit } from '../renders/CliNamespaceInit';
import { CliReport } from '../renders/CliReport';
import { CliTopAction } from '../renders/CliTopAction';
import { CliTopCustom } from '../renders/CliTopCustom';
import { CliTopInit } from '../renders/CliTopInit';
import { GenerateAzureCliHistory } from '../renders/extraExt/CliExtHistory';
import { CliTopMetadata } from '../renders/extraExt/CliExtMetadata';
import { CliExtReadme } from '../renders/extraExt/CliExtReadme';
import { GenerateAzureCliSetupCfg } from '../renders/extraExt/CliExtSetupCfg';
import { CliExtSetupPy } from '../renders/extraExt/CliExtSetupPy';
import { GenerateAzureCliActions } from '../renders/generated/CliActions';
import { GenerateAzureCliClientFactory } from '../renders/generated/CliClientFactory';
import { GenerateAzureCliCommands } from '../renders/generated/CliCommands';
import { GenerateAzureCliCustom } from '../renders/generated/CliCustom';
import { GenerateAzureCliHelp } from '../renders/generated/CliHelp';
import { GenerateAzureCliParams } from '../renders/generated/CliParams';
import { GenerateAzureCliValidators } from '../renders/generated/CliValidators';
import { CliTestInit } from '../renders/tests/CliTestInit';
import { CliTestPrepare } from '../renders/tests/CliTestPrepare';
import { CliTestScenario } from '../renders/tests/CliTestScenario';
import { PathConstants } from '../../utils/models';
import { CliTestStep, NeedPreparer } from '../renders/tests/CliTestStep';
import { GenerateMetaFile } from '../renders/CliMeta';
export class AzExtensionFullGenerator extends AzGeneratorBase {
constructor(model: CodeModelAz, isDebugMode: boolean) {

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

@ -4,29 +4,29 @@
*-------------------------------------------------------------------------------------------- */
import * as fs from 'fs';
import * as path from 'path';
import { PathConstants } from '../utils/models';
import { PathConstants } from '../../utils/models';
import { AzGeneratorBase } from './AzGeneratorBase';
import { CodeModelAz } from './CodeModelAz';
import { GenerateNamespaceInit } from './renders/CliNamespaceInit';
import { CliTopAction } from './renders/CliTopAction';
import { CliTopCustom } from './renders/CliTopCustom';
import { CliTopHelp } from './renders/CliTopHelp';
import { CliReport } from './renders/CliReport';
import { CliTopInit } from './renders/CliTopInit';
import { CliTopMetadata } from './renders/extraExt/CliExtMetadata';
import { CliExtSetupPy } from './renders/extraExt/CliExtSetupPy';
import { GenerateAzureCliActions } from './renders/generated/CliActions';
import { GenerateAzureCliClientFactory } from './renders/generated/CliClientFactory';
import { GenerateAzureCliCommands } from './renders/generated/CliCommands';
import { GenerateAzureCliCustom } from './renders/generated/CliCustom';
import { GenerateAzureCliHelp } from './renders/generated/CliHelp';
import { GenerateAzureCliParams } from './renders/generated/CliParams';
import { GenerateAzureCliValidators } from './renders/generated/CliValidators';
import { CliTestInit } from './renders/tests/CliTestInit';
import { CliTestPrepare } from './renders/tests/CliTestPrepare';
import { CliTestScenario } from './renders/tests/CliTestScenario';
import { CliTestStep, NeedPreparer } from './renders/tests/CliTestStep';
import { GenerateMetaFile } from './renders/CliMeta';
import { CodeModelAz } from '../CodeModelAz';
import { GenerateNamespaceInit } from '../renders/CliNamespaceInit';
import { CliTopAction } from '../renders/CliTopAction';
import { CliTopCustom } from '../renders/CliTopCustom';
import { CliTopHelp } from '../renders/CliTopHelp';
import { CliReport } from '../renders/CliReport';
import { CliTopInit } from '../renders/CliTopInit';
import { CliTopMetadata } from '../renders/extraExt/CliExtMetadata';
import { CliExtSetupPy } from '../renders/extraExt/CliExtSetupPy';
import { GenerateAzureCliActions } from '../renders/generated/CliActions';
import { GenerateAzureCliClientFactory } from '../renders/generated/CliClientFactory';
import { GenerateAzureCliCommands } from '../renders/generated/CliCommands';
import { GenerateAzureCliCustom } from '../renders/generated/CliCustom';
import { GenerateAzureCliHelp } from '../renders/generated/CliHelp';
import { GenerateAzureCliParams } from '../renders/generated/CliParams';
import { GenerateAzureCliValidators } from '../renders/generated/CliValidators';
import { CliTestInit } from '../renders/tests/CliTestInit';
import { CliTestPrepare } from '../renders/tests/CliTestPrepare';
import { CliTestScenario } from '../renders/tests/CliTestScenario';
import { CliTestStep, NeedPreparer } from '../renders/tests/CliTestStep';
import { GenerateMetaFile } from '../renders/CliMeta';
export class AzExtensionIncrementalGenerator extends AzGeneratorBase {
constructor(model: CodeModelAz, isDebugMode: boolean) {

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

@ -4,9 +4,9 @@
*-------------------------------------------------------------------------------------------- */
import * as fs from 'fs';
import * as path from 'path';
import { CodeModelAz } from './CodeModelAz';
import { TemplateBase } from './renders/TemplateBase';
import { inplaceGen } from '../utils/inplace';
import { CodeModelAz } from '../CodeModelAz';
import { TemplateBase } from '../renders/TemplateBase';
import { inplaceGen } from '../../utils/inplace';
export abstract class AzGeneratorBase {
model: CodeModelAz;

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

@ -3,13 +3,13 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*-------------------------------------------------------------------------------------------- */
import { GenerationMode } from '../utils/models';
import { GenerationMode } from '../../utils/models';
import { AzCoreFullGenerator } from './AzCoreFullGenerator';
import { AzCoreIncrementalGenerator } from './AzCoreIncrementalGenerator';
import { AzExtensionFullGenerator } from './AzExtensionFullGenerator';
import { AzExtensionIncrementalGenerator } from './AzExtensionIncrementalGenerator';
import { AzGeneratorBase } from './AzGeneratorBase';
import { CodeModelCliImpl } from './CodeModelAzImpl';
import { CodeModelCliImpl } from '../CodeModelAzImpl';
export class AzGeneratorFactory {
static async createAzGenerator(

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

@ -5,8 +5,9 @@
import { HttpMethod } from '@azure-tools/codemodel';
import { CmdToMultiLines, isNullOrUndefined } from '../../../utils/helper';
import { PathConstants } from '../../../utils/models';
import { CodeModelAz, CommandExample } from '../../CodeModelAz';
import { CodeModelAz } from '../../CodeModelAz';
import { TemplateBase } from '../TemplateBase';
import { CommandExample } from '../../climodels/ExampleType';
export class CliExtReadme extends TemplateBase {
constructor(model: CodeModelAz, isDebugMode: boolean) {

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

@ -3,12 +3,13 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*-------------------------------------------------------------------------------------------- */
import * as path from 'path';
import { CodeModelAz, CommandExample } from '../../CodeModelAz';
import { CodeModelAz } from '../../CodeModelAz';
import { CliTestStep } from './CliTestStep';
import { ToMultiLine, Capitalize } from '../../../utils/helper';
import { HeaderGenerator } from '../../Header';
import { TemplateBase } from '../TemplateBase';
import { PathConstants } from '../../../utils/models';
import { CommandExample } from '../../climodels/ExampleType';
export class CliTestScenario extends TemplateBase {
constructor(

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

@ -3,12 +3,13 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*-------------------------------------------------------------------------------------------- */
import * as path from 'path';
import { CodeModelAz, CommandExample } from '../../CodeModelAz';
import { CodeModelAz } from '../../CodeModelAz';
import { PreparerEntity, getResourceKey } from './ScenarioTool';
import { ToMultiLine, deepCopy, isNullOrUndefined } from '../../../utils/helper';
import { HeaderGenerator } from '../../Header';
import { TemplateBase } from '../TemplateBase';
import { PathConstants } from '../../../utils/models';
import { CommandExample } from '../../climodels/ExampleType';
let usePreparers: boolean, shortToLongName, funcNames, allSteps, stepBuff: any;

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

@ -1,4 +1,4 @@
import { CommandExample, ExampleParam, KeyValueType } from '../../CodeModelAz';
import { CommandExample, ExampleParam, KeyValueType } from '../../climodels/ExampleType';
import {
deepCopy,
isDict,