rvm
Version:
Ruff Version Manager.
105 lines • 4.65 kB
JavaScript
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
var Path = require('path');
var Chalk = require('chalk');
var clime_1 = require('clime');
var core_1 = require('../core');
var utils_1 = require('../utils');
var config = require('../config');
var InstallOptions = (function (_super) {
__extends(InstallOptions, _super);
function InstallOptions() {
_super.apply(this, arguments);
}
__decorate([
clime_1.option({
flag: 'l',
description: 'Install Ruff SDK into local `.ruff` folder.',
toggle: true
}),
__metadata('design:type', Boolean)
], InstallOptions.prototype, "local", void 0);
return InstallOptions;
}(clime_1.Options));
exports.InstallOptions = InstallOptions;
var default_1 = (function (_super) {
__extends(default_1, _super);
function default_1() {
_super.apply(this, arguments);
}
default_1.prototype.execute = function (range, options) {
var _this = this;
utils_1.log('FETCHING', 'SDK package metadata...');
var version;
var targetPath = options.local ? Path.resolve('.ruff') : config.sdkPath;
return core_1.getPackageMetadata(range)
.then(function (metadata) {
version = metadata.version;
utils_1.log('DOWNLOADING', "SDK package (version " + version + ")...");
return core_1.downloadPackage('sdk', metadata);
})
.then(function (packagePath) {
utils_1.log('EXTRACTING', 'SDK package...');
return core_1.extractPackage('sdk', packagePath, targetPath);
})
.then(function () {
if (options.local) {
_this.createNpmBinScripts();
return;
}
else {
return _this.checkPath();
}
})
.then(function () { return utils_1.log("Ruff SDK (version " + version + ") has been successfully installed."); });
};
default_1.prototype.createNpmBinScripts = function () {
utils_1.log('CREATING', 'executable scripts under `node_modules/.bin`...');
utils_1.createNpmBinScript('ruff');
utils_1.createNpmBinScript('rap');
};
default_1.prototype.checkPath = function () {
utils_1.log('CHECKING', '`PATH` environment variable...');
return utils_1.checkPath('sdk')
.then(function (pathConfigured) {
if (!pathConfigured) {
utils_1.log(Chalk.yellow("It seems that environment variable `PATH` has not yet been configured, please refer to the link below for how:\n https://ruff.io/zh-cn/docs/environment-variables.html\nYou might need the SDK path to walk through the configuration steps:\n " + config.sdkPath));
}
});
};
__decorate([
__param(0, clime_1.param({
name: 'version',
description: 'Version of the Ruff SDK to install.'
})),
__metadata('design:type', Function),
__metadata('design:paramtypes', [String, InstallOptions]),
__metadata('design:returntype', void 0)
], default_1.prototype, "execute", null);
default_1 = __decorate([
clime_1.command({
description: 'Install Ruff SDK on this computer.'
}),
__metadata('design:paramtypes', [])
], default_1);
return default_1;
}(clime_1.Command));
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = default_1;
//# sourceMappingURL=install.js.map
;