@ioffice/tc-builder
Advanced tools
Comparing version 2.1.2 to 2.1.3-beta.1807161157
{ | ||
"name": "@ioffice/tc-builder", | ||
"version": "2.1.2", | ||
"version": "2.1.3-beta.1807161157", | ||
"description": "iOFFICE TeamCity Builder", | ||
@@ -8,2 +8,3 @@ "main": "index.js", | ||
"bin": { | ||
"tc-install": "./TCBuilderInstallCLI.js", | ||
"tc-builder": "./TCBuilderCLI.js" | ||
@@ -10,0 +11,0 @@ }, |
@@ -99,2 +99,5 @@ "use strict"; | ||
} | ||
if (!gitUrl) { | ||
throw new Error('ERROR: missing "repository" field in "package.json"'); | ||
} | ||
var _a = gitUrl.match(/(.*)\/(.*)\/(.*)\.git$/), owner = _a[2], repo = _a[3]; | ||
@@ -101,0 +104,0 @@ return { owner: owner, repo: repo }; |
@@ -1,5 +0,3 @@ | ||
declare function setupFiles(fileName?: string): void; | ||
declare function installDevTools(pkg: object): void; | ||
declare function updateDevTools(): void; | ||
declare function runSetup(tcPkg: object): number; | ||
export { setupFiles, installDevTools, updateDevTools, runSetup, }; | ||
declare function setupFiles(replacements: object, fileName?: string): void; | ||
declare function runSetup(): number; | ||
export { setupFiles, runSetup, }; |
@@ -5,3 +5,2 @@ "use strict"; | ||
var path = require("path"); | ||
var child_process_1 = require("child_process"); | ||
var Util_1 = require("../Util"); | ||
@@ -35,10 +34,26 @@ var services_1 = require("../services"); | ||
} | ||
function setupFiles(fileName) { | ||
var env = services_1.Provider.getInstance().env; | ||
var replacements = { | ||
packageName: env.packageName, | ||
repo: env.repo, | ||
owner: env.owner, | ||
upperCasePkgName: env.packageName.toLocaleUpperCase(), | ||
}; | ||
/** | ||
* Write any of the files stored in `./projectFiles`. If only a string is given | ||
* then the file will be copied as is (with replacements in the content) to the root directory | ||
* of the project. If we need to specify a different directory then you may specify | ||
* | ||
* ``` | ||
* ['someFileInProjectFiles', 'some/path/to/be/copied/to'] | ||
* ``` | ||
*/ | ||
function writeFiles(fileList, replacements) { | ||
fileList.forEach(function (item) { | ||
var fileName = Array.isArray(item) ? item[0] : item; | ||
var destFileName = Array.isArray(item) ? item[1] : item; | ||
var contents = getFileContents(fileName, replacements); | ||
if (fs.existsSync(destFileName)) { | ||
log("[SKIP]: " + destFileName); | ||
} | ||
else { | ||
log("[WRITING]: " + destFileName); | ||
fs.writeFileSync(destFileName, contents); | ||
} | ||
}); | ||
} | ||
function setupFiles(replacements, fileName) { | ||
var projectFiles = [ | ||
@@ -48,11 +63,12 @@ '.editorconfig', | ||
'.npmignore', | ||
'.teamcity.json', | ||
'CHANGELOG.md', | ||
'CONTRIBUTING.md', | ||
'Makefile', | ||
'tsconfig.dev.json', | ||
'tsconfig.json', | ||
'tslint.dev.json', | ||
'tslint.json', | ||
]; | ||
if (fileName) { | ||
if (projectFiles.indexOf(fileName) === -1) { | ||
if (!fs.existsSync(rel("./projectFiles/" + fileName + ".tpl"))) { | ||
log("[ERROR]: invalid file " + fileName); | ||
@@ -65,42 +81,123 @@ } | ||
} | ||
projectFiles.forEach(function (fileName) { | ||
var contents = getFileContents(fileName, replacements); | ||
if (fs.existsSync(fileName)) { | ||
log("[SKIP]: " + fileName); | ||
} | ||
else { | ||
log("[WRITING]: " + fileName); | ||
fs.writeFileSync(fileName, contents); | ||
} | ||
}); | ||
writeFiles(projectFiles, replacements); | ||
verifySourceDirectory(); | ||
} | ||
exports.setupFiles = setupFiles; | ||
function installDevTools(pkg) { | ||
var devDeps = pkg['devDependencies']; | ||
var depsArray = Object.keys(devDeps).map(function (x) { return x + "@" + devDeps[x]; }); | ||
var cmd = "yarn add -D -E " + depsArray.join(' '); | ||
log("$ " + cmd); | ||
child_process_1.execSync(cmd); | ||
function teamcitySetup(replacements) { | ||
log('[TEAMCITY SETUP]'); | ||
writeFiles([ | ||
['teamcity/.teamcity.json', '.teamcity.json'], | ||
], replacements); | ||
} | ||
exports.installDevTools = installDevTools; | ||
function updateDevTools() { | ||
var pkg = Util_1.util.readJSON('./package.json', '.') || {}; | ||
var devDeps = pkg['devDependencies']; | ||
var depsArray = Object.keys(devDeps).map(function (x) { return x + "@latest"; }); | ||
var cmd = "yarn add -D -E " + depsArray.join(' '); | ||
log("$ " + cmd); | ||
child_process_1.execSync(cmd); | ||
function travisSetup(replacements) { | ||
log('[TRAVIS SETUP]'); | ||
writeFiles([ | ||
['travis/.travis.yml', '.travis.yml'], | ||
], replacements); | ||
} | ||
exports.updateDevTools = updateDevTools; | ||
function runSetup(tcPkg) { | ||
function webpackSetup(replacements) { | ||
log('[WEBPACK SETUP]'); | ||
var directory = process.argv[process.argv.indexOf('webpack') + 1]; | ||
var skipDeps = process.argv.indexOf('--skip-deps'); | ||
if (!directory) { | ||
log('ERROR: usage: tc-builder setup webpack (dirname) [--skip-deps]'); | ||
} | ||
writeFiles([ | ||
['webpack/webpack.config.ts', directory + "/webpack.config.ts"], | ||
], replacements); | ||
if (skipDeps) { | ||
return; | ||
} | ||
var packages = [ | ||
'@types/webpack', | ||
'webpack', | ||
'webpack-cli', | ||
'css-loader', | ||
'bundle-loader', | ||
'file-loader', | ||
'html-loader', | ||
'less-loader', | ||
'less', | ||
'raw-loader', | ||
'style-loader', | ||
'ts-loader', | ||
'url-loader', | ||
'webpack-bundle-analyzer', | ||
]; | ||
packages.forEach(function (name) { | ||
var cmd = "yarn add -E -D " + name + "@latest"; | ||
process.stdout.write("$ " + cmd + "\n"); | ||
Util_1.util.execCmd(cmd, true); | ||
}); | ||
} | ||
function angularSetup(replacements) { | ||
log('[ANGULAR SETUP]'); | ||
var directory = process.argv[process.argv.indexOf('angular') + 1]; | ||
var skipDeps = process.argv.indexOf('--skip-deps'); | ||
if (!directory) { | ||
log('ERROR: usage: tc-builder setup angular (dirname) [--skip-deps]'); | ||
} | ||
writeFiles([ | ||
['angular/App.bundle.ts', directory + "/App.bundle.ts"], | ||
['angular/App.component.ts', directory + "/App.component.ts"], | ||
['angular/App.module.ts', directory + "/App.module.ts"], | ||
], replacements); | ||
if (skipDeps) { | ||
return; | ||
} | ||
var packages = [ | ||
'@angular/animations', | ||
'@angular/common', | ||
'@angular/compiler', | ||
'@angular/compiler-cli', | ||
'@angular/core', | ||
'@angular/forms', | ||
'@angular/http', | ||
'@angular/platform-browser', | ||
'@angular/platform-browser-dynamic', | ||
'@angular/platform-server', | ||
'@angular/router', | ||
'@angular/upgrade', | ||
'zone.js', | ||
'core-js', | ||
'reflect-metadata', | ||
]; | ||
packages.forEach(function (name) { | ||
var cmd = "yarn add -E -D " + name + "@latest"; | ||
process.stdout.write("$ " + cmd + "\n"); | ||
Util_1.util.execCmd(cmd, true); | ||
}); | ||
} | ||
function runSetup() { | ||
var env = services_1.Provider.getInstance().env; | ||
var replacements = { | ||
packageName: env.packageName, | ||
repo: env.repo, | ||
owner: env.owner, | ||
upperCasePkgName: env.packageName.toLocaleUpperCase(), | ||
}; | ||
var projectPkg = Util_1.util.readJSON('./package.json', '.'); | ||
if (projectPkg) { | ||
var fileName = process.argv[process.argv.indexOf('setup') + 1]; | ||
if (fileName) { | ||
setupFiles(fileName); | ||
var fileName_1 = process.argv[process.argv.indexOf('setup') + 1]; | ||
var environments = [ | ||
'teamcity', | ||
'travis', | ||
'webpack', | ||
'angular', | ||
]; | ||
var env_1 = environments.find(function (x) { return x === fileName_1; }); | ||
if (env_1) { | ||
var envMap = { | ||
teamcity: teamcitySetup, | ||
travis: travisSetup, | ||
webpack: webpackSetup, | ||
angular: angularSetup, | ||
}; | ||
envMap[env_1](replacements); | ||
} | ||
else if (fileName_1) { | ||
setupFiles(replacements, fileName_1); | ||
} | ||
else { | ||
installDevTools(tcPkg); | ||
setupFiles(); | ||
setupFiles(replacements); | ||
} | ||
@@ -107,0 +204,0 @@ } |
@@ -7,8 +7,7 @@ #!/usr/bin/env node | ||
var Setup_1 = require("./setup/Setup"); | ||
var compiler_1 = require("./compiler"); | ||
var builders_1 = require("./builders"); | ||
var Compiler_1 = require("./compiler/Compiler"); | ||
var slack_1 = require("./slack"); | ||
var commands = [ | ||
'setup', | ||
'update-tools', | ||
'compile', | ||
@@ -19,2 +18,3 @@ 'run', | ||
var options = [ | ||
'--dev', | ||
'--no-lint', | ||
@@ -29,8 +29,8 @@ '--verbose', | ||
]; | ||
var _a = commands.map(function (x) { return process.argv.indexOf(x) > -1; }), setup = _a[0], updateTools = _a[1], compile = _a[2], run = _a[3], slackNotify = _a[4]; | ||
var _b = options.map(function (x) { return process.argv.indexOf(x) > -1; }), noLint = _b[0], verbose = _b[1], help = _b[2], h = _b[3], version = _b[4], v = _b[5], ci = _b[6], noMsgDump = _b[7]; | ||
var _a = commands.map(function (x) { return process.argv.indexOf(x) > -1; }), setup = _a[0], compile = _a[1], run = _a[2], slackNotify = _a[3]; | ||
var _b = options.map(function (x) { return process.argv.indexOf(x) > -1; }), dev = _b[0], noLint = _b[1], verbose = _b[2], help = _b[3], h = _b[4], version = _b[5], v = _b[6], ci = _b[7], noMsgDump = _b[8]; | ||
var tcPkg = Util_1.util.readJSON('./package.json', __dirname) || {}; | ||
var tcPkgVersion = tcPkg['version']; | ||
var log = function (msg) { return process.stdout.write(msg + "\n"); }; | ||
var usage = "usage: tc-builder <command> [--options]\n\nThe following commands are supported:\n\n - setup: Installs all the same dependencies as the ones in the tc-builder and creates\n configuration files if they do not exists. This command should be run when starting\n a new project or updating tc-builder.\n\n If there are any new updates to the configuration files and you wish to see them you\n can provide the name of the file right after the command.\n - update-tools: Installs all the latest devDependencies.\n - compile: Looks at the 'tsconfig.json' file to compile the project. By default it will also\n lint the files unless we use the '--no-lint' option.\n - run: Main command to be run in team city. It will make sure to run all the tests and publish\n to npm if necessary.\n - slack-notify: If you have provided the appropiate slack environment variables then this will\n get slack to send a message.\n\nOptions:\n\n --no-lint: Skip linting.\n --verbose: Print messages of the steps for the 'compile' command.\n --ci: Continous Integration flag, minimizes the output in case there are too many errors.\n --help, -h: Print this message.\n --version, -v: Print the version.\n --no-msg-dump: Skip dumping error and warning messages to './tcBuilderMessages.json'.\n\ntc-builder@" + tcPkgVersion + "\n"; | ||
var usage = "usage: tc-builder (command) [--options]\n\nThe following commands are supported:\n\n - setup: Installs all the same dependencies as the ones in the tc-builder and creates\n configuration files if they do not exists. This command should be run when starting\n a new project or updating tc-builder.\n\n If there are any new updates to the configuration files and you wish to see them you\n can provide the name of the file right after the command.\n - update-tools: Installs all the latest devDependencies.\n - compile: Looks at the 'tsconfig.json' file to compile the project. By default it will also\n lint the files unless we use the '--no-lint' option.\n - run: Main command to be run in team city. It will make sure to run all the tests and publish\n to npm if necessary.\n - slack-notify: If you have provided the appropiate slack environment variables then this will\n get slack to send a message.\n\nOptions:\n\n --dev: Uses tsconfig.dev.json and tslint.dev.json\n --no-lint: Skip linting.\n --verbose: Print messages of the steps for the 'compile' command.\n --ci: Continous Integration flag, minimizes the output in case there are too many errors.\n --help, -h: Print this message.\n --version, -v: Print the version.\n --no-msg-dump: Skip dumping error and warning messages to './tcBuilderMessages.json'.\n\ntc-builder@" + tcPkgVersion + "\n"; | ||
function main() { | ||
@@ -45,41 +45,37 @@ return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
log(usage); | ||
return [3 /*break*/, 10]; | ||
return [3 /*break*/, 9]; | ||
case 1: | ||
if (!(version || v)) return [3 /*break*/, 2]; | ||
log(tcPkgVersion); | ||
return [3 /*break*/, 10]; | ||
return [3 /*break*/, 9]; | ||
case 2: | ||
if (!((+setup) + (+updateTools) + (+compile) + (+run) + (+slackNotify) !== 1)) return [3 /*break*/, 3]; | ||
if (!((+setup) + (+compile) + (+run) + (+slackNotify) !== 1)) return [3 /*break*/, 3]; | ||
log("usage: tc-builder <" + commands.join(' | ') + "> [-h]"); | ||
exitNumber = 1; | ||
return [3 /*break*/, 10]; | ||
return [3 /*break*/, 9]; | ||
case 3: | ||
if (!setup) return [3 /*break*/, 4]; | ||
exitNumber = Setup_1.runSetup(tcPkg); | ||
return [3 /*break*/, 10]; | ||
exitNumber = Setup_1.runSetup(); | ||
return [3 /*break*/, 9]; | ||
case 4: | ||
if (!updateTools) return [3 /*break*/, 5]; | ||
Setup_1.updateDevTools(); | ||
return [3 /*break*/, 10]; | ||
case 5: | ||
if (!compile) return [3 /*break*/, 6]; | ||
if (!compile) return [3 /*break*/, 5]; | ||
projectPkg = Util_1.util.readJSON('./package.json', '.'); | ||
tcBuilderOptions = projectPkg ? projectPkg['tcBuilder'] || {} : {}; | ||
messageMap = tcBuilderOptions['allowed'] || {}; | ||
exitNumber = Compiler_1.compileCLI('tsconfig.json', noLint ? '' : './tslint.json', verbose, messageMap, ci, !noMsgDump); | ||
return [3 /*break*/, 10]; | ||
exitNumber = compiler_1.compileCLI(dev ? 'tsconfig.dev.json' : 'tsconfig.json', noLint ? '' : (dev ? './tslint.dev.json' : './tslint.json'), verbose, messageMap, ci, !noMsgDump); | ||
return [3 /*break*/, 9]; | ||
case 5: | ||
if (!run) return [3 /*break*/, 7]; | ||
return [4 /*yield*/, builders_1.runBuilder(builders_1.NPMBuilder, !noMsgDump)]; | ||
case 6: | ||
if (!run) return [3 /*break*/, 8]; | ||
return [4 /*yield*/, builders_1.runBuilder(builders_1.NPMBuilder, !noMsgDump)]; | ||
case 7: | ||
code = (_a.sent()).code; | ||
exitNumber = code; | ||
return [3 /*break*/, 10]; | ||
return [3 /*break*/, 9]; | ||
case 7: | ||
if (!slackNotify) return [3 /*break*/, 9]; | ||
return [4 /*yield*/, slack_1.runSlacker(slack_1.TravisSlack)]; | ||
case 8: | ||
if (!slackNotify) return [3 /*break*/, 10]; | ||
return [4 /*yield*/, slack_1.runSlacker(slack_1.TravisSlack)]; | ||
exitNumber = _a.sent(); | ||
_a.label = 9; | ||
case 9: | ||
exitNumber = _a.sent(); | ||
_a.label = 10; | ||
case 10: | ||
process.on('exit', function () { | ||
@@ -86,0 +82,0 @@ process.exit(exitNumber); |
19
Util.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var fs_1 = require("fs"); | ||
@@ -80,18 +79,4 @@ var pth = require("path"); | ||
Util.prototype.getModifiedFiles = function () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var result, err_1; | ||
return tslib_1.__generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.execCmd('git status -s')]; | ||
case 1: | ||
result = _a.sent(); | ||
return [2 /*return*/, result.split('\n').map(function (x) { return x.trim(); }).filter(function (x) { return x; })]; | ||
case 2: | ||
err_1 = _a.sent(); | ||
return [2 /*return*/, Promise.reject(err_1)]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
return this.execCmd('git status -s').then(function (result) { | ||
return result.split('\n').map(function (x) { return x.trim(); }).filter(function (x) { return x; }); | ||
}); | ||
@@ -98,0 +83,0 @@ }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
120283
60
2788
1
2