@autorest/go
Version:
AutoRest Go Generator
75 lines • 2.46 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as path from 'path';
///////////////////////////////////////////////////////////////////////////////////////////////////
// helpers
///////////////////////////////////////////////////////////////////////////////////////////////////
/**
* returns the package name for the specified input.
* for module github.com/contoso/module, 'module' is returned.
* any major version suffix on the module is removed.
*
* @param pkg is the package source
* @returns the package name for pkg
*/
export function getPackageName(pkg) {
switch (pkg.kind) {
case 'fake':
return pkg.kind;
case 'module':
return path.basename(pkg.identity.replace(/\/v\d+$/, ''));
case 'package':
return pkg.name;
case 'test':
return `${getPackageName(pkg.src)}_test`;
}
}
class PackageBase {
constructor() {
this.clients = new Array();
this.constants = new Array();
this.interfaces = new Array();
this.models = new Array();
this.packages = new Array();
this.paramGroups = new Array();
this.responseEnvelopes = new Array();
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
export class ContainingModule {
constructor(identity) {
this.kind = 'containingModule';
this.identity = identity;
}
}
export class FakePackage {
constructor(parent) {
this.kind = 'fake';
this.parent = parent;
}
}
export class Module extends PackageBase {
constructor(identity) {
super();
this.kind = 'module';
this.identity = identity;
}
}
export class Package extends PackageBase {
constructor(name, parent) {
super();
this.kind = 'package';
this.name = name;
this.parent = parent;
}
}
export class TestPackage {
constructor(src) {
this.kind = 'test';
this.src = src;
}
}
//# sourceMappingURL=module.js.map