UNPKG

sleeveforarm

Version:
115 lines 5.43 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const fs = require("fs-extra"); const Path = require("path"); const CommonUtilities = require("./common-utilities"); const Data = require("./data"); /* * In our code we take DC names returned by AZ and * use it to generate enum values. So it's important * that the enum values are just the DC name with * spaces removed. */ /** * The names of data centers supported by Azure. Please * note that not all Azure Accounts have access to all data centers. */ var DataCenterNames; (function (DataCenterNames) { DataCenterNames["EastAsia"] = "East Asia"; DataCenterNames["SoutheastAsia"] = "Southeast Asia"; DataCenterNames["CentralUS"] = "Central US"; DataCenterNames["EastUS"] = "East US"; DataCenterNames["EastUS2"] = "East US 2"; DataCenterNames["WestUS"] = "West US"; DataCenterNames["NorthCentralUS"] = "North Central US"; DataCenterNames["SouthCentralUS"] = "South Central US"; DataCenterNames["NorthEurope"] = "North Europe"; DataCenterNames["WestEurope"] = "West Europe"; DataCenterNames["JapanWest"] = "Japan West"; DataCenterNames["JapanEast"] = "Japan East"; DataCenterNames["BrazilSouth"] = "Brazil South"; DataCenterNames["AustraliaEast"] = "Australia East"; DataCenterNames["AustraliaSoutheast"] = "Australia Southeast"; DataCenterNames["SouthIndia"] = "South India"; DataCenterNames["CentralIndia"] = "Central India"; DataCenterNames["WestIndia"] = "West India"; DataCenterNames["CanadaCentral"] = "Canada Central"; DataCenterNames["CanadaEast"] = "Canada East"; DataCenterNames["UKSouth"] = "UK South"; DataCenterNames["UKWest"] = "UK West"; DataCenterNames["WestCentralUS"] = "West Central US"; DataCenterNames["WestUS2"] = "West US 2"; DataCenterNames["KoreaCentral"] = "Korea Central"; DataCenterNames["KoreaSouth"] = "Korea South"; })(DataCenterNames = exports.DataCenterNames || (exports.DataCenterNames = {})); /** * We use the first character of the string value * as part of our names so make sure each type has a * different first character. */ var DeployType; (function (DeployType) { DeployType["LocalDevelopment"] = "dev"; DeployType["Production"] = "prod"; })(DeployType = exports.DeployType || (exports.DeployType = {})); var ResourcesWeSupportSettingUp; (function (ResourcesWeSupportSettingUp) { ResourcesWeSupportSettingUp["MySqlAzure"] = "mySqlAzure"; ResourcesWeSupportSettingUp["WebAppNode"] = "webapp-node"; })(ResourcesWeSupportSettingUp = exports.ResourcesWeSupportSettingUp || (exports.ResourcesWeSupportSettingUp = {})); class Resource { static internalSetup(fileName, targetDirectoryPath, maximumNameLength, isAResourceGroup = false) { return __awaiter(this, void 0, void 0, function* () { const serviceName = Path.basename(targetDirectoryPath); const availableChars = maximumNameLength - Data.data.DataCenterAcronymLength - Data.data.DeploymentTypeIdLength - (isAResourceGroup ? 0 : Data.data.ResourceGroupLength); if (!(yield CommonUtilities.validateResource((serviceName), availableChars))) { throw new Error(`The name of the resource ${Path.basename(targetDirectoryPath)}\ should be less than ${availableChars} characters,\ contains only alphanumeric characters and start with a letter\n`); } if (yield fs.pathExists(targetDirectoryPath)) { console.log(`Directory with name ${serviceName} already exists.`); process.exit(-1); } yield fs.ensureDir(targetDirectoryPath); const assetPath = Path.join(__dirname, "..", "assets", Path.basename(fileName, ".js")); yield fs.copy(assetPath, targetDirectoryPath); yield CommonUtilities.npmSetup(targetDirectoryPath); }); } initialize(resource, targetDirectoryPath) { this.targetDirectoryPath = targetDirectoryPath; if (this.baseName === undefined) { this.setBaseName(Path.basename(this.targetDirectoryPath)); } return this; } hydrate(resourcesInEnvironment, deploymentType) { return __awaiter(this, void 0, void 0, function* () { this.resourcesInEnvironment = resourcesInEnvironment; this.deploymentType = deploymentType; return this; }); } get baseName() { return this.baseNameProperty; } setBaseName(baseName) { this.baseNameProperty = baseName; return this; } } exports.Resource = Resource; //# sourceMappingURL=resource.js.map