bicep-assets
Version:
52 lines (51 loc) • 2.49 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
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) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SpecDeployCommand = void 0;
const clipanion_1 = require("clipanion");
const cross_spawn_1 = require("cross-spawn");
const fs_1 = require("fs");
const path_1 = require("path");
class SpecDeployCommand extends clipanion_1.Command {
constructor() {
super();
this.resourceGroup = clipanion_1.Option.String('-g,--resource-group', {
required: true,
});
this.prefix = clipanion_1.Option.String('-p,--prefix', 'bicep-assets');
const json = JSON.parse((0, fs_1.readFileSync)((0, path_1.resolve)(__dirname, '../../package.json'), 'utf-8'));
this.version = json.version;
}
execute() {
return __awaiter(this, void 0, void 0, function* () {
this.deploySpec((0, path_1.resolve)(__dirname, '../../res/asset-copy.bicep'), 'copy');
this.deploySpec((0, path_1.resolve)(__dirname, '../../res/asset-extract.bicep'), 'extract');
this.deploySpec((0, path_1.resolve)(__dirname, '../../res/asset-sas-url.bicep'), 'sas-url');
this.deploySpec((0, path_1.resolve)(__dirname, '../../res/asset-types.bicep'), 'types');
});
}
deploySpec(bicep, name) {
// TODO: Use an SDK way of working which can reuse the functionality of other commands
console.log(`Deploying '${this.prefix}-${name}' to '${this.resourceGroup}'`);
(0, cross_spawn_1.sync)('az', [
'ts',
'create',
'--name', `${this.prefix}-${name}`,
'--version', this.version,
'--resource-group', this.resourceGroup,
'--template-file', bicep,
]);
}
}
exports.SpecDeployCommand = SpecDeployCommand;
SpecDeployCommand.paths = [
['spec', 'deploy'],
];
;