generator-theia
Version:
Theia Generator
96 lines • 5.08 kB
JavaScript
;
/*
* Copyright (C) 2017 TypeFox and others.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });
var common_1 = require("../common");
var ExtensionPackageGenerator = (function (_super) {
__extends(ExtensionPackageGenerator, _super);
function ExtensionPackageGenerator() {
return _super !== null && _super.apply(this, arguments) || this;
}
ExtensionPackageGenerator.prototype.generate = function (fs) {
fs.writeJSON('package.json', this.compilePackage());
if (!fs.exists('compile.tsconfig.json')) {
fs.writeJSON('compile.tsconfig.json', this.compileTsConfig());
}
};
ExtensionPackageGenerator.prototype.compilePackage = function () {
var pck = this.compileCommonPackage();
if (!this.model.extensionConfig.testSupport) {
return pck;
}
return __assign({}, pck, { "nyc": pck.nyc || {
"extends": "../nyc.json"
}, "scripts": __assign({}, pck.scripts, { "clean": "yarn run compile:clean && yarn run test:clean", "test": "nyc mocha --opts ../mocha.opts src/**/*.spec.ts", "test:watch": "mocha -w --opts ../mocha.opts src/**/*.spec.ts", "test:clean": "rimraf .nyc_output && rimraf coverage" }, this.model.pck.scripts), "devDependencies": common_1.sortByKey(__assign({}, pck.devDependencies, { "@types/chai": "^4.0.1", "@types/chai-as-promised": "0.0.31", "@types/mocha": "^2.2.41", "chai": "^4.1.0", "chai-as-promised": "^7.1.1", "mocha": "^3.4.2", "nyc": "^11.0.3", "ts-node": "^3.2.0" }, this.model.pck.devDependencies)) });
};
ExtensionPackageGenerator.prototype.compileCommonPackage = function () {
var keywords = new Set(this.model.pck.keywords || []);
keywords.add(this.model.extensionConfig.extensionKeyword);
return __assign({}, this.model.pck, { "keywords": __spread(keywords), "license": this.model.pck.license || "Apache-2.0", "repository": this.model.pck.repository || {
"type": "git",
"url": "https://github.com/theia-ide/theia.git"
}, "bugs": this.model.pck.bugs || {
"url": "https://github.com/theia-ide/theia/issues"
}, "homepage": this.model.pck.homepage || "https://github.com/theia-ide/theia", "files": this.model.pck.files || [
"lib",
"src"
], "scripts": __assign({ "clean": "yarn run compile:clean", "build": "concurrently -n compile,lint -c blue,green \"yarn run compile\" \"yarn run lint\"", "compile": "tsc -p compile.tsconfig.json", "compile:clean": "rimraf lib", "lint": "tslint -c ../tslint.json --project compile.tsconfig.json", "watch": "tsc -w -p compile.tsconfig.json" }, this.model.pck.scripts), "devDependencies": common_1.sortByKey(__assign({ "concurrently": "^3.5.0", "rimraf": "^2.6.1", "tslint": "^5.5.0", "typescript": "^2.4.1" }, this.model.pck.devDependencies)) });
};
ExtensionPackageGenerator.prototype.compileTsConfig = function () {
return {
"extends": "../base.tsconfig",
"compilerOptions": {
"rootDir": "src",
"outDir": "lib"
},
"include": [
"src"
]
};
};
return ExtensionPackageGenerator;
}(common_1.AbstractGenerator));
exports.ExtensionPackageGenerator = ExtensionPackageGenerator;
//# sourceMappingURL=extension-package-generator.js.map