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
35 changes: 13 additions & 22 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion powershell/generators/gitignore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { Host } from '@autorest/extension-base';
import { AutorestExtensionHost as Host } from '@autorest/extension-base';
import { Project } from '../internal/project';

export async function generateGitIgnore(project: Project) {
Expand Down
2 changes: 1 addition & 1 deletion powershell/generators/nuspec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { Host } from '@autorest/extension-base';
import { AutorestExtensionHost as Host } from '@autorest/extension-base';
import { Project } from '../internal/project';

function removeCd(path: string): string {
Expand Down
2 changes: 1 addition & 1 deletion powershell/generators/psm1.custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { Host } from '@autorest/extension-base';
import { AutorestExtensionHost as Host } from '@autorest/extension-base';
import { Project } from '../internal/project';
import { PSScriptFile } from '../file-formats/psscript-file';
import { relative } from 'path';
Expand Down
2 changes: 1 addition & 1 deletion powershell/generators/psm1.internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { Host } from '@autorest/extension-base';
import { AutorestExtensionHost as Host } from '@autorest/extension-base';
import { Project } from '../internal/project';
import { PSScriptFile } from '../file-formats/psscript-file';
import { relative } from 'path';
Expand Down
6 changes: 3 additions & 3 deletions powershell/internal/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { pwshHeaderText } from '../utils/powershell-comment';

import { ModuleNamespace } from '../module/module-namespace';
import { CmdletNamespace } from '../cmdlets/namespace';
import { Host } from '@autorest/extension-base';
import { AutorestExtensionHost as Host } from '@autorest/extension-base';
import {
codemodel,
PropertyDetails,
Expand Down Expand Up @@ -236,7 +236,7 @@ export class Project extends codeDomProject {
pwshLicenseHeader
? pwshHeaderText(
pwshLicenseHeader,
await this.service.GetValue('header-definitions')
await this.service.getValue('header-definitions')
)
: this.license,
'#'
Expand All @@ -249,7 +249,7 @@ export class Project extends codeDomProject {
pwshLicenseHeader
? pwshHeaderText(
pwshLicenseHeader,
await this.service.GetValue('header-definitions')
await this.service.getValue('header-definitions')
)
: this.license,
'//'
Expand Down
2 changes: 1 addition & 1 deletion powershell/internal/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { codemodel } from '@azure-tools/codemodel-v3';

import { Host, JsonPath, Session } from '@autorest/extension-base';
import { AutorestExtensionHost as Host, JsonPointerSegments as JsonPath, Session } from '@autorest/extension-base';
import { Project } from './project';
import { DeepPartial } from '@azure-tools/codegen';
import { PwshModel } from '../utils/PwshModel';
Expand Down
2 changes: 1 addition & 1 deletion powershell/llcsharp/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { codeModelSchema } from '@autorest/codemodel';
import { Model } from './code-model';
import { Host, JsonPath, Session, startSession } from '@autorest/extension-base';
import { AutorestExtensionHost as Host, JsonPointerSegments as JsonPath, Session, startSession } from '@autorest/extension-base';

import { Project } from './project';
import { Dictionary } from '@azure-tools/linq';
Expand Down
2 changes: 1 addition & 1 deletion powershell/llcsharp/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { Host } from '@autorest/extension-base';
import { AutorestExtensionHost as Host } from '@autorest/extension-base';
import { items, values, keys, Dictionary, length } from '@azure-tools/linq';
import { Project as codeDomProject } from '@azure-tools/codegen-csharp';

Expand Down
2 changes: 1 addition & 1 deletion powershell/llcsharp/schema/schema-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { Uuid } from './Uuid';
import { EnhancedTypeDeclaration } from './extended-type-declaration';
import { PwshModel } from '../../utils/PwshModel';
import { ModelState } from '../../utils/model-state';
import { Channel, Host, Session, startSession } from '@autorest/extension-base';
import { Channel, AutorestExtensionHost as Host, Session, startSession } from '@autorest/extension-base';
import { schemaHasEnum } from '../validations';
import { Password } from './password';

Expand Down
4 changes: 2 additions & 2 deletions powershell/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@
"@typescript-eslint/eslint-plugin": "~5.29.0",
"@typescript-eslint/parser": "~5.29.0",
"@microsoft.azure/autorest.testserver": "~2.9.3",
"autorest": "~3.0.6118",
"autorest": "~3.6.3",
"eslint": "~8.12.0"
},
"dependencies": {
"js-yaml": "3.13.1",
"@azure-tools/codegen": "~2.5.276",
"@azure-tools/codegen-csharp": "~3.0.0",
"@azure-tools/codemodel-v3": "~3.1.0",
"@autorest/extension-base": "~3.3.2",
"@autorest/extension-base": "~3.5.2",
"@autorest/codemodel": "~4.19.3",
"@azure-tools/linq": "~3.1.0",
"@azure-tools/tasks": "~3.0.0",
Expand Down
4 changes: 2 additions & 2 deletions powershell/plugins/add-azure-completers-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { values } from '@azure-tools/linq';
import { Host } from '@autorest/extension-base';
import { AutorestExtensionHost as Host } from '@autorest/extension-base';
import { PwshModel } from '../utils/PwshModel';
import { ModelState } from '../utils/model-state';
import { serialize } from '@azure-tools/codegen';
Expand Down Expand Up @@ -46,5 +46,5 @@ async function tweakModel(state: State): Promise<PwshModel> {

export async function addCompleterV2(service: Host) {
const state = await new ModelState<PwshModel>(service).init();
await service.WriteFile('code-model-v4-add-azure-completers-v2.yaml', serialize(await tweakModel(state)), undefined, 'code-model-v4');
await service.writeFile({filename: 'code-model-v4-add-azure-completers-v2.yaml', content: serialize(await tweakModel(state)), sourceMap: undefined, artifactType: 'code-model-v4'});
}
4 changes: 2 additions & 2 deletions powershell/plugins/create-commands-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { HttpMethod, codeModelSchema, CodeModel, ObjectSchema, GroupSchema, isOb
import { deconstruct, fixLeadingNumber, pascalCase, EnglishPluralizationService, fail, removeSequentialDuplicates, serialize, includeXDash } from '@azure-tools/codegen';
import { items, values, keys, Dictionary, length } from '@azure-tools/linq';
import { Schema } from '../llcsharp/exports';
import { Channel, Host, Session, startSession } from '@autorest/extension-base';
import { Channel, AutorestExtensionHost as Host, Session, startSession } from '@autorest/extension-base';
import { Lazy } from '@azure-tools/tasks';
import { clone } from '@azure-tools/linq';
import { verbs } from '../internal/verbs';
Expand Down Expand Up @@ -617,7 +617,7 @@ export async function createCommandsV2(service: Host) {
//const session = await startSession<PwshModel>(service, {}, codeModelSchema);
//const result = tweakModelV2(session);
const state = await new ModelState<PwshModel>(service).init();
await service.WriteFile('code-model-v4-createcommands-v2.yaml', serialize(await (await new Inferrer(state).init()).createCommands()), undefined, 'code-model-v4');
await service.writeFile({ filename: 'code-model-v4-createcommands-v2.yaml', content: serialize(await (await new Inferrer(state).init()).createCommands()), sourceMap: undefined, artifactType: 'code-model-v4'});

// return processCodeModel(async (state) => {
// return await (await new Inferrer(state).init()).createCommands();
Expand Down
4 changes: 2 additions & 2 deletions powershell/plugins/cs-namer-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { camelCase, deconstruct, excludeXDash, fixLeadingNumber, pascalCase, low
import { items, values, keys, Dictionary, length } from '@azure-tools/linq';
import { System } from '@azure-tools/codegen-csharp';

import { Channel, Host, Session, startSession } from '@autorest/extension-base';
import { Channel, AutorestExtensionHost as Host, Session, startSession } from '@autorest/extension-base';
import { SchemaDetails } from '../llcsharp/code-model';
import { SchemaDefinitionResolver } from '../llcsharp/schema/schema-resolver';
import { PwshModel } from '../utils/PwshModel';
Expand Down Expand Up @@ -271,6 +271,6 @@ export async function csnamerV2(service: Host) {
//const session = await startSession<PwshModel>(service, {}, codeModelSchema);
//const result = tweakModelV2(session);
const state = await new ModelState<PwshModel>(service).init();
await service.WriteFile('code-model-v4-csnamer-v2.yaml', serialize(await nameStuffRight(state)), undefined, 'code-model-v4');
await service.writeFile({ filename: 'code-model-v4-csnamer-v2.yaml', content: serialize(await nameStuffRight(state)), sourceMap: undefined, artifactType: 'code-model-v4'});
}

14 changes: 7 additions & 7 deletions powershell/plugins/llcsharp-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Host, startSession } from '@autorest/extension-base';
import { AutorestExtensionHost as Host, startSession } from '@autorest/extension-base';
import { codeModelSchema } from '@autorest/codemodel';
import { applyOverrides, copyResources, deserialize, serialize, } from '@azure-tools/codegen';
import { join } from 'path';
Expand All @@ -18,17 +18,17 @@ export async function llcsharpV2(service: Host) {
return await project.state.resolveVariables(input);
};

await project.writeFiles(async (fname, content) => service.WriteFile(join(project.apifolder, fname), applyOverrides(content, project.overrides), undefined, 'source-file-csharp'));
await project.writeFiles(async (fname, content) => service.writeFile({ filename: join(project.apifolder, fname), content: applyOverrides(content, project.overrides), sourceMap: undefined, artifactType: 'source-file-csharp'}));

// recursive copy resources
await copyResources(join(resources, 'runtime', 'csharp', 'client'), async (fname, content) => service.WriteFile(join(project.runtimefolder, fname), content, undefined, 'source-file-csharp'), project.overrides);
await copyResources(join(resources, 'runtime', 'csharp', 'pipeline'), async (fname, content) => service.WriteFile(join(project.runtimefolder, fname), content, undefined, 'source-file-csharp'), project.overrides, transformOutput);
await copyResources(join(resources, 'runtime', 'csharp', 'client'), async (fname, content) => service.writeFile({ filename: join(project.runtimefolder, fname), content: content, sourceMap: undefined, artifactType: 'source-file-csharp'}), project.overrides);
await copyResources(join(resources, 'runtime', 'csharp', 'pipeline'), async (fname, content) => service.writeFile({ filename: join(project.runtimefolder, fname), content: content, sourceMap: undefined, artifactType: 'source-file-csharp'}), project.overrides, transformOutput);
// Note:
// we are using the Carbon.Json library, but we don't *really* want to expose that as public members where we don't have to
// and I don't want to make code changes in the source repository, so I can keep merging from upstream as simple as possible.
// so, we're converting as much as possible to internal, and exposing only what must be exposed to make the code compile.

await copyResources(join(resources, 'runtime', 'csharp', 'json'), async (fname, content) => service.WriteFile(join(project.runtimefolder, fname), content, undefined, 'source-file-csharp'), {
await copyResources(join(resources, 'runtime', 'csharp', 'json'), async (fname, content) => service.writeFile({ filename: join(project.runtimefolder, fname), content: content, sourceMap: undefined, artifactType: 'source-file-csharp'}), {
...project.overrides,
'public': 'internal',
'internal (.*) class JsonNumber': 'public $1 class JsonNumber',
Expand Down Expand Up @@ -65,11 +65,11 @@ export async function llcsharpV2(service: Host) {
});

if (project.xmlSerialization) {
await copyResources(join(resources, 'runtime', 'csharp', 'xml'), async (fname, content) => service.WriteFile(join(project.runtimefolder, fname), content, undefined, 'source-file-csharp'), project.overrides);
await copyResources(join(resources, 'runtime', 'csharp', 'xml'), async (fname, content) => service.writeFile({ filename: join(project.runtimefolder, fname), content: content, sourceMap: undefined, artifactType: 'source-file-csharp'}), project.overrides);
}

if (project.azure) {
await copyResources(join(resources, 'runtime', 'csharp.azure'), async (fname, content) => service.WriteFile(join(project.runtimefolder, fname), content, undefined, 'source-file-csharp'), project.overrides);
await copyResources(join(resources, 'runtime', 'csharp.azure'), async (fname, content) => service.writeFile({ filename: join(project.runtimefolder, fname), content: content, sourceMap: undefined, artifactType: 'source-file-csharp'}), project.overrides);
}

} catch (E) {
Expand Down
6 changes: 3 additions & 3 deletions powershell/plugins/modifiers-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { Host, Channel } from '@autorest/extension-base';
import { AutorestExtensionHost as Host, Channel } from '@autorest/extension-base';
import { pascalCase, serialize, safeEval } from '@azure-tools/codegen';
import { VirtualParameter } from '@autorest/codemodel';
import { items, values, keys, Dictionary, length } from '@azure-tools/linq';
Expand Down Expand Up @@ -951,7 +951,7 @@ See https://github.com/Azure/autorest.powershell/blob/main/docs/directives.md#de

export async function applyModifiersV2(service: Host) {
// dolauli implement directives
const allDirectives = await service.GetValue('directive');
const allDirectives = await service.getValue<any>('directive');
directives = values(allDirectives)
// .select(directive => directive)
.where(directive => isWhereCommandDirective(directive) || isWhereModelDirective(directive) || isWhereEnumDirective(directive) || isRemoveCommandDirective(directive))
Expand All @@ -960,5 +960,5 @@ export async function applyModifiersV2(service: Host) {
const state = await new ModelState<PwshModel>(service).init();
const result = await tweakModel(state);

await service.WriteFile('code-model-v4-modifiers-v2.yaml', serialize(result), undefined, 'code-model-v4');
await service.writeFile({ filename: 'code-model-v4-modifiers-v2.yaml', content: serialize(result), sourceMap: undefined, artifactType: 'code-model-v4'});
}
4 changes: 2 additions & 2 deletions powershell/plugins/plugin-create-inline-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { codeModelSchema, Property, CodeModel, ObjectSchema, ConstantSchema, GroupSchema, isObjectSchema, SchemaType, GroupProperty, ParameterLocation, Operation, Parameter, ImplementationLocation, OperationGroup, Request, SchemaContext } from '@autorest/codemodel';
import { getPascalIdentifier, removeSequentialDuplicates, pascalCase, fixLeadingNumber, deconstruct, selectName, EnglishPluralizationService, serialize } from '@azure-tools/codegen';
import { length, values, } from '@azure-tools/linq';
import { Host, Session, startSession } from '@autorest/extension-base';
import { AutorestExtensionHost as Host, Session, startSession } from '@autorest/extension-base';
import { CommandOperation } from '../utils/command-operation';
import { PwshModel } from '../utils/PwshModel';
import { ModelState } from '../utils/model-state';
Expand Down Expand Up @@ -454,6 +454,6 @@ export async function createInlinedPropertiesPlugin(service: Host) {
//const session = await startSession<PwshModel>(service, {}, codeModelSchema);
//const result = tweakModelV2(session);
const state = await new ModelState<PwshModel>(service).init();
await service.WriteFile('code-model-v4-create-virtual-properties-v2.yaml', serialize(await createVirtuals(state)), undefined, 'code-model-v4');
await service.writeFile({ filename: 'code-model-v4-create-virtual-properties-v2.yaml', content: serialize(await createVirtuals(state)), sourceMap: undefined, artifactType: 'code-model-v4'});
//return processCodeModel(createVirtuals, service, 'create-virtual-properties-v2');
}
Loading