New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ioffice/tc-builder

Package Overview
Dependencies
Maintainers
2
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ioffice/tc-builder - npm Package Compare versions

Comparing version 1.3.0-beta.1806070241 to 1.3.0-beta.1806141356

builders/AbstractBuilder.d.ts

2

Compiler.d.ts

@@ -22,2 +22,2 @@ import { TypedObject, ExitCode, IProjectResults, IProjectStatus, IFileMessages } from './Interfaces';

declare function getProjectStatus(projectResults: IProjectResults, messageMap: TypedObject<number>): IProjectStatus;
export { compile, compileProject, compileCLI, getProjectStatus };
export { compile, compileProject, compileCLI, getProjectStatus, };

@@ -16,2 +16,3 @@ "use strict";

function getDiagnosticCategory(category) {
var _a;
var map = (_a = {},

@@ -23,3 +24,2 @@ _a[ts.DiagnosticCategory.Error] = 'error',

return map[category];
var _a;
}

@@ -124,4 +124,3 @@ function compile(program, tsOptions, tsLintConfigPath, verbose) {

};
var parsed = ts.parseJsonConfigFileContent(project.config, parseConfigHost, pth.resolve(process.cwd()), {} // noEmit: true
);
var parsed = ts.parseJsonConfigFileContent(project.config, parseConfigHost, pth.resolve(process.cwd()), {});
if (parsed.errors !== undefined) {

@@ -224,3 +223,3 @@ // ignore warnings and 'TS18003: No inputs were found in config file ...'

count: 0,
references: []
references: [],
};

@@ -227,0 +226,0 @@ var sample = message.references[0];

import { TypedObject, IFileMessages, IProjectStatus, IProjectResults } from './Interfaces';
declare function formatResults(results: TypedObject<IFileMessages>): string;
declare function formatProjectResults(projectStatus: IProjectStatus, projectResults: IProjectResults, ci?: boolean, ciLimit?: number): string;
export { formatResults, formatProjectResults };
export { formatResults, formatProjectResults, };

@@ -1,5 +0,5 @@

import { TCBuilder, resolution } from './TCBuilder';
import { AbstractBuilder, NPMBuilder } from './builders';
import { compile, compileProject, getProjectStatus } from './Compiler';
import { move, replaceStrings, changePackageVersion, readJSON } from './Util';
import { formatResults, formatProjectResults } from './Formatter';
export { resolution, TCBuilder, compile, compileProject, getProjectStatus, move, replaceStrings, changePackageVersion, readJSON, formatResults, formatProjectResults };
export { AbstractBuilder, NPMBuilder, compile, compileProject, getProjectStatus, move, replaceStrings, changePackageVersion, readJSON, formatResults, formatProjectResults, };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var TCBuilder_1 = require("./TCBuilder");
exports.TCBuilder = TCBuilder_1.TCBuilder;
var builders_1 = require("./builders");
exports.AbstractBuilder = builders_1.AbstractBuilder;
exports.NPMBuilder = builders_1.NPMBuilder;
var Compiler_1 = require("./Compiler");

@@ -6,0 +7,0 @@ exports.compile = Compiler_1.compile;

@@ -12,3 +12,3 @@ declare type MessageCategory = 'error' | 'warning' | 'info' | 'log' | 'debug';

NODE_ERROR = 5,
NEEDS_READJUSTMENT = 6,
NEEDS_READJUSTMENT = 6
}

@@ -56,2 +56,2 @@ interface ITSMessage {

}
export { MessageCategory, TypedObject, ExitCode, ITSMessage, IFileInfo, IFileMessages, IMessageInfo, IMessageReference, IProjectResults, IProjectStatus };
export { MessageCategory, TypedObject, ExitCode, ITSMessage, IFileInfo, IFileMessages, IMessageInfo, IMessageReference, IProjectResults, IProjectStatus, };
{
"name": "@ioffice/tc-builder",
"version": "1.3.0-beta.1806070241",
"version": "1.3.0-beta.1806141356",
"description": "iOFFICE TeamCity Builder",

@@ -20,3 +20,3 @@ "main": "index.js",

"devDependencies": {
"@ioffice/tslint-config-ioffice": "0.2.0",
"@ioffice/tslint-config-ioffice": "0.4.1",
"@types/chai": "4.1.2",

@@ -38,6 +38,6 @@ "@types/mocha": "2.2.48",

"sinon": "4.4.8",
"tslint": "5.9.1",
"tslint-eslint-rules": "5.0.0",
"tslint": "5.10.0",
"tslint-eslint-rules": "5.3.1",
"typedoc": "0.11.1",
"typescript": "2.7.2"
"typescript": "2.9.1"
},

@@ -44,0 +44,0 @@ "publishConfig": {

declare function setupFiles(pkgName: string, fileName?: string): void;
export { setupFiles };
export { setupFiles, };

@@ -1,5 +0,6 @@

/// <reference types="request-promise" />
import { RequestPromise } from 'request-promise';
import { Util } from './Util';
import { Tasks } from './Tasks';
/**
* A resolution is simply a function that takes in a string. These are used by the team city builder
* A resolution is a function that takes in a string. These are used by the team city builder
* to define the fulfill and reject functions of a promise.

@@ -11,10 +12,8 @@ */

*
* The `TCBuilder` object requires no parameters to be instantiated. Just know that we can affect
* its behavior by using environment variables:
* The `TCBuilder` object requires no parameters to be instantiated but its behaviour is affected
* by the following environment variables:
*
* - `BRANCH`: Team city handles it.
* - `TOKEN`: Team city will pass it, don't worry.
* - `BRANCH`: The name of the Github branch.
* - `GITHUB_TOKEN`: An auth token provided by Github.
* - `PRERELEASE`: Set it to something and a pre-release will happen.
*
* Besides that please make sure that the `package.json` has the `repository.url` field.
*/

@@ -32,4 +31,12 @@ declare class TCBuilder {

private failed;
util: Util;
tasks: Tasks;
constructor();
run(): Promise<number>;
/**
* Create a standard pre-release of the current state of the project. This command
* will work on any machine that has the valid credentials.
*/
createPreRelease(): Promise<string>;
/**
* Return the raw object obtained from reading the project's `package.json` file.

@@ -83,3 +90,3 @@ */

* Make sure to have the Makefile target `docs`. This will make `make docs` and pass in the
* enviromental variable `VERSION`.
* environment variable `VERSION`.
* @param fulfill Called if successful.

@@ -113,7 +120,2 @@ * @param reject Called if something went wrong.

/**
* Create a standard pre-release of the current state of the project. This command
* will work on any machine that has the valid credentials.
*/
makePreRelease(): void;
/**
* Make a call to the GitHub api.

@@ -138,14 +140,14 @@ *

build(): void;
private runTests();
private verifyRelease();
private verifyNonRelease();
private beforeNpmPublish();
private npmPublish();
private publishDocs();
private handleMasterBranch();
private handlePullRequest();
private writeVersionFile(version);
private abort(msg);
private setFailure(msg);
private runTests;
private verifyRelease;
private verifyNonRelease;
private beforeNpmPublish;
private npmPublish;
private publishDocs;
private handleMasterBranch;
private handlePullRequest;
private writeVersionFile;
private abort;
private setFailure;
}
export { resolution, TCBuilder };
export { resolution, TCBuilder, };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
/**

@@ -14,13 +15,21 @@ * This module provides the `TCBuilder` class. This object is in charge of building and releasing

var Util_1 = require("./Util");
var Tasks_1 = require("./Tasks");
var MSG = {
createPreRelease: {
init: 'Creating pre-release.',
failureCommit: function (files) {
return "Commit the following files before preReleasing:\n " + files.join('\n ');
},
success: function (version) { return version ? "Pre-released version " + version : ''; },
},
};
/**
* ### TCBuilder
*
* The `TCBuilder` object requires no parameters to be instantiated. Just know that we can affect
* its behavior by using environment variables:
* The `TCBuilder` object requires no parameters to be instantiated but its behaviour is affected
* by the following environment variables:
*
* - `BRANCH`: Team city handles it.
* - `TOKEN`: Team city will pass it, don't worry.
* - `BRANCH`: The name of the Github branch.
* - `GITHUB_TOKEN`: An auth token provided by Github.
* - `PRERELEASE`: Set it to something and a pre-release will happen.
*
* Besides that please make sure that the `package.json` has the `repository.url` field.
*/

@@ -30,2 +39,4 @@ var TCBuilder = /** @class */ (function () {

this.failed = false;
this.util = new Util_1.Util();
this.tasks = new Tasks_1.Tasks(this.util);
this.branch = process.env['BRANCH'] || '';

@@ -47,3 +58,114 @@ this.token = process.env['TOKEN'] || '';

}
TCBuilder.prototype.run = function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var err_1;
var _this = this;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!this.preRelease) return [3 /*break*/, 4];
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, this.createPreRelease()];
case 2:
_a.sent();
return [2 /*return*/, 0];
case 3:
err_1 = _a.sent();
return [2 /*return*/, this.tasks.failure(err_1)];
case 4: return [2 /*return*/, this.runTests().then(function (msg) {
// Lets make sure that `version.json` was not generated by the tests, if so, delete it
if (fs.existsSync('version.json')) {
fs.unlinkSync('version.json');
}
_this.log(msg);
if (_this.branch && _this.token) {
if (_this.branch === 'refs/heads/master') {
_this.handleMasterBranch();
}
else if (_this.branch.indexOf('pull/') === 0) {
_this.handlePullRequest();
}
else {
_this.log("Nothing else to do on the '" + _this.branch + "' branch.");
_this.onEnd();
}
}
else {
_this.log('No branch/token provided. Process is done.');
}
return _this.tasks.success(0, msg);
}, function (err) { return _this.tasks.success(1, err); })];
}
});
});
};
/**
* Create a standard pre-release of the current state of the project. This command
* will work on any machine that has the valid credentials.
*/
TCBuilder.prototype.createPreRelease = function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var files, branch, err_2, failure, version, err_3, err_4;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
this.log(MSG.createPreRelease.init);
return [4 /*yield*/, this.util.getChangedFiles()];
case 1:
files = _a.sent();
if (files.length > 0) {
return [2 /*return*/, this.tasks.failure(MSG.createPreRelease.failureCommit(files))];
}
_a.label = 2;
case 2:
_a.trys.push([2, 5, , 6]);
return [4 /*yield*/, this.tasks.getGitBranch()];
case 3:
branch = _a.sent();
return [4 /*yield*/, this.tasks.switchGitBranch('build', true)];
case 4:
_a.sent();
return [3 /*break*/, 6];
case 5:
err_2 = _a.sent();
return [2 /*return*/, this.tasks.failure(err_2)];
case 6:
failure = '';
version = '';
_a.label = 7;
case 7:
_a.trys.push([7, 10, , 11]);
return [4 /*yield*/, this.beforeNpmPublish()];
case 8:
_a.sent();
return [4 /*yield*/, this.npmPublish()];
case 9:
version = _a.sent();
return [3 /*break*/, 11];
case 10:
err_3 = _a.sent();
failure = err_3;
return [3 /*break*/, 11];
case 11:
_a.trys.push([11, 13, , 14]);
return [4 /*yield*/, this.tasks.switchAndDelete(branch, 'build')];
case 12:
_a.sent();
return [3 /*break*/, 14];
case 13:
err_4 = _a.sent();
this.tasks.error(err_4);
return [3 /*break*/, 14];
case 14:
if (failure) {
return [2 /*return*/, this.tasks.failure(failure)];
}
return [2 /*return*/, this.tasks.success(MSG.createPreRelease.success(version))];
}
});
});
};
/**
* Return the raw object obtained from reading the project's `package.json` file.

@@ -163,3 +285,4 @@ */

Util_1.changePackageVersion(finalVersion);
this.exec("npm publish" + options + " --tag next").then(fulfill, reject);
this.exec('echo npm publish --tag next').then(fulfill, reject);
// this.exec(`npm publish${options} --tag next`).then(fulfill, reject);
}

@@ -175,3 +298,3 @@ else {

draft: false,
prerelease: false
prerelease: false,
}).then(fulfill, reject);

@@ -183,3 +306,3 @@ }, reject);

* Make sure to have the Makefile target `docs`. This will make `make docs` and pass in the
* enviromental variable `VERSION`.
* environment variable `VERSION`.
* @param fulfill Called if successful.

@@ -235,52 +358,2 @@ * @param reject Called if something went wrong.

/**
* Create a standard pre-release of the current state of the project. This command
* will work on any machine that has the valid credentials.
*/
TCBuilder.prototype.makePreRelease = function () {
var _this = this;
this.log('Creating pre-release');
this.exec("git symbolic-ref HEAD | sed 's!refs/heads/!!'").then(function (original) {
var branch = original.trim();
var checkoutOriginal = function () {
_this.exec("git add . && git stash && git stash drop; git checkout " + branch + " -q").then(function () {
_this.log("Switching to " + branch);
_this.exec('git branch -D build -q').then(function () {
_this.log('Deleting build branch');
_this.onEnd();
});
});
};
_this.exec('git checkout -b build -q').then(function () {
_this.log('On "build" branch');
_this.beforeNpmPublish()
.then(function (beforeNpmPublishMsg) {
_this.log(beforeNpmPublishMsg);
_this.npmPublish()
.then(function (npmPublishMsg) {
_this.log(npmPublishMsg);
_this.log('Clean up');
checkoutOriginal();
}, function (npmPublishErr) {
_this.log(npmPublishErr);
_this.log('Clean up');
checkoutOriginal();
});
}, function (beforeNpmPublishErr) {
_this.log(beforeNpmPublishErr);
_this.log('Clean up');
checkoutOriginal();
});
}, function (msg) {
_this.log('Unable to checkout the build branch - ', msg);
checkoutOriginal();
_this.setFailure(msg);
_this.onEnd();
});
}, function (msg) {
_this.log('Unable to obtain the branch name - ', msg);
_this.setFailure(msg);
_this.onEnd();
});
};
/**
* Make a call to the GitHub api.

@@ -337,3 +410,4 @@ *

if (this.preRelease) {
return this.makePreRelease();
this.createPreRelease();
return;
}

@@ -340,0 +414,0 @@ this.runTests().then(function (msg) {

@@ -0,1 +1,2 @@

#!/usr/bin/env node
export {};
#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var child_process_1 = require("child_process");

@@ -14,48 +15,79 @@ var Util_1 = require("./Util");

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 - 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\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\ntc-builder@" + pkgVersion + "\n";
var exitNumber = 0;
if (help || h) {
console.log(usage);
function main() {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var exitNumber, projectPkg, fileName, devDeps_1, depsArray, cmd, compileCLI, projectPkg, tcBuilderOptions, messageMap, NPMBuilder, pb, err_1;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
exitNumber = 0;
if (!(help || h)) return [3 /*break*/, 1];
console.log(usage);
return [3 /*break*/, 9];
case 1:
if (!(version || v)) return [3 /*break*/, 2];
console.log(pkgVersion);
return [3 /*break*/, 9];
case 2:
if (!((+setup) + (+compile) + (+run) !== 1)) return [3 /*break*/, 3];
console.error("usage: tc-builder <" + commands.join(' | ') + "> [-h]");
exitNumber = 1;
return [3 /*break*/, 9];
case 3:
if (!setup) return [3 /*break*/, 4];
projectPkg = Util_1.readJSON('./package.json', '.');
if (projectPkg) {
fileName = process.argv[process.argv.indexOf('setup') + 1];
if (fileName) {
Setup_1.setupFiles(projectPkg['name'], fileName);
}
else {
devDeps_1 = pkg['devDependencies'];
depsArray = Object.keys(devDeps_1).map(function (x) { return x + "@" + devDeps_1[x]; });
cmd = "yarn add -D -E " + depsArray.join(' ');
console.log('Running: ', cmd);
child_process_1.execSync(cmd);
Setup_1.setupFiles(projectPkg['name']);
}
}
else {
console.error('Npm project has not yet been initialized.');
exitNumber = 1;
}
return [3 /*break*/, 9];
case 4:
if (!compile) return [3 /*break*/, 5];
compileCLI = require('./Compiler').compileCLI;
projectPkg = Util_1.readJSON('./package.json', '.');
tcBuilderOptions = projectPkg ? projectPkg['tcBuilder'] || {} : {};
messageMap = tcBuilderOptions['allowed'] || {};
exitNumber = compileCLI('tsconfig.json', noLint ? '' : './tslint.json', verbose, messageMap, ci);
return [3 /*break*/, 9];
case 5:
if (!run) return [3 /*break*/, 9];
NPMBuilder = require('./builders/NPMBuilder').NPMBuilder;
pb = new NPMBuilder();
_a.label = 6;
case 6:
_a.trys.push([6, 8, , 9]);
return [4 /*yield*/, pb.run()];
case 7:
_a.sent();
exitNumber = 0;
pb.tasks.log('Process is done.');
return [3 /*break*/, 9];
case 8:
err_1 = _a.sent();
pb.tasks.error(err_1);
pb.tasks.log('Process has failed.');
exitNumber = 1;
return [3 /*break*/, 9];
case 9:
process.on('exit', function () {
process.exit(exitNumber);
});
return [2 /*return*/];
}
});
});
}
else if (version || v) {
console.log(pkgVersion);
}
else if ((+setup) + (+compile) + (+run) !== 1) {
console.error("usage: tc-builder <" + commands.join(' | ') + "> [-h]");
exitNumber = 1;
}
else if (setup) {
var projectPkg = Util_1.readJSON('./package.json', '.');
if (projectPkg) {
var fileName = process.argv[process.argv.indexOf('setup') + 1];
if (fileName) {
Setup_1.setupFiles(projectPkg['name'], fileName);
}
else {
var devDeps_1 = pkg['devDependencies'];
var depsArray = Object.keys(devDeps_1).map(function (x) { return x + "@" + devDeps_1[x]; });
var cmd = "yarn add -D -E " + depsArray.join(' ');
console.log('Running: ', cmd);
child_process_1.execSync(cmd);
Setup_1.setupFiles(projectPkg['name']);
}
}
else {
console.error('Npm project has not yet been initialized.');
exitNumber = 1;
}
}
else if (compile) {
var compileCLI = require('./Compiler').compileCLI;
var projectPkg = Util_1.readJSON('./package.json', '.');
var tcBuilderOptions = projectPkg ? projectPkg['tcBuilder'] || {} : {};
var messageMap = tcBuilderOptions['allowed'] || {};
exitNumber = compileCLI('tsconfig.json', noLint ? '' : './tslint.json', verbose, messageMap, ci);
}
else if (run) {
var TCBuilder = require('./TCBuilder').TCBuilder;
var pb = new TCBuilder();
pb.build();
}
process.on('exit', function () {
process.exit(exitNumber);
});
main();

@@ -0,1 +1,27 @@

/**
* Collection of utility methods. These methods have been attached to the `Util` class as opposed
* to the `Tasks` class because they do not print to the console. They simply return a value.
*/
declare class Util {
/**
* Execute a system command such as `pwd`. Returns a promise
* @param cmd The command to execute
*/
execCmd(cmd: string): Promise<string>;
/**
* Returns a list of all the files that have not yet been committed.
*/
getChangedFiles(): Promise<string[]>;
/**
* Read the json contents from a file. Returns null if there is an issue while parsing.
*/
readJSON(name: string, path?: string): object | null;
/**
* Move files and/or directories recursively. If the `src` parameter ends with `/` then only
* the contents of the directory will be moved to the destination. Otherwise the whole `src`
* directory will be moved to the destination.
*/
move(src: string, dest: string): string[];
changePackageVersion(version: string): void;
}
declare function changePackageVersion(version: string): void;

@@ -16,2 +42,2 @@ /**

declare function replaceStrings(template: string, properties: object): string;
export { move, changePackageVersion, readJSON, replaceStrings };
export { Util, move, changePackageVersion, readJSON, replaceStrings, };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var child_process_1 = require("child_process");
var fs_1 = require("fs");
var pth = require("path");
/**
* Collection of utility methods. These methods have been attached to the `Util` class as opposed
* to the `Tasks` class because they do not print to the console. They simply return a value.
*/
var Util = /** @class */ (function () {
function Util() {
}
/**
* Execute a system command such as `pwd`. Returns a promise
* @param cmd The command to execute
*/
Util.prototype.execCmd = function (cmd) {
return new Promise(function (fulfill, reject) {
child_process_1.exec(cmd, function (error, stdout, stderr) {
if (error) {
return reject(error.toString());
}
if (stderr && !stdout) {
return reject(stderr.toString());
}
fulfill(stdout.toString().trim());
});
});
};
/**
* Returns a list of all the files that have not yet been committed.
*/
Util.prototype.getChangedFiles = function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var result;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: 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; })];
}
});
});
};
/**
* Read the json contents from a file. Returns null if there is an issue while parsing.
*/
Util.prototype.readJSON = function (name, path) {
var base = path || process.cwd();
return _parseJSONFile(base + "/" + name);
};
/**
* Move files and/or directories recursively. If the `src` parameter ends with `/` then only
* the contents of the directory will be moved to the destination. Otherwise the whole `src`
* directory will be moved to the destination.
*/
Util.prototype.move = function (src, dest) {
var buf = [];
_move(src, dest, buf);
return buf;
};
Util.prototype.changePackageVersion = function (version) {
var contents = fs_1.readFileSync('package.json', 'utf8');
var lines = contents.split('\n');
var newLines = lines.map(function (line) {
if (line.trim().startsWith('"version"')) {
return " \"version\": \"" + version + "\",";
}
return line;
});
fs_1.writeFileSync('package.json', newLines.join('\n'));
};
return Util;
}());
exports.Util = Util;
function _move(src, dest, buf) {

@@ -6,0 +79,0 @@ var stats = fs_1.statSync(src);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc