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

build-front-container

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

build-front-container - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

39

lib/index.js

@@ -12,2 +12,3 @@ var fs = require('fs');

var packApp = require('./packers').packApp;
var Promise = require('bluebird');

@@ -32,5 +33,5 @@ module.exports.build = function(args) {

packing.push(packApp(OUTPUT_DIR, args['project-build-dir']));
Promise.all(packing).then(() => {
Promise.all(packing).then(function() {
buildContainer(OUTPUT_DIR, args);
}).catch(err => { console.log(err); });
}).catch(function(err) { console.log(err); });
};

@@ -49,3 +50,3 @@

if (!fs.existsSync(dockerFile)) {
shell.exec(`cp ${path.join(__dirname, '..', 'Dockerfile')} ${dockerFile}`);
shell.exec('cp ' + path.join(__dirname, '..', 'Dockerfile') + ' ' + dockerFile);
}

@@ -55,3 +56,3 @@

if (!fs.existsSync(buildScriptDest)) {
shell.exec(`cp ${getBuildScriptPath(buildScriptPath, projectType)} ${buildScriptDest}`);
shell.exec('cp ' + getBuildScriptPath(buildScriptPath, projectType) + ' ' + buildScriptDest);
}

@@ -64,3 +65,3 @@ }

} else {
var scriptFileName = `${projectType ? projectType : 'webpack'}.sh`;
var scriptFileName = (projectType ? projectType : 'webpack') + '.sh';
return path.join(__dirname, '..', 'build-scripts', scriptFileName);

@@ -73,5 +74,5 @@ }

shell.exec(`cd ${outputDir}`);
shell.exec(`docker build -t ${args['docker-registry']}/${args['container-name']}:${version} .`);
shell.exec(`docker push ${args['docker-registry']}/${args['container-name']}:${version}`);
shell.exec('cd ' + outputDir);
shell.exec('docker build -t ' + args['docker-registry'] + '/' + args['container-name'] + ':' + version + ' .');
shell.exec('docker push ' + args['docker-registry'] + '/' + args['container-name'] + ':' + version);
}

@@ -88,5 +89,5 @@

Object.keys(args).filter(k => k !== '_').forEach(k => {
Object.keys(args).filter(function(k) { return k !== '_'; }).forEach(function(k) {
if (typeof args[k] !== 'string' && typeof args[k] !== 'boolean') {
throw new Error(`option ${k} is not correct. Maybe it is duplicated`);
throw new Error('option ' + k + ' is not correct. Maybe it is duplicated');
}

@@ -99,10 +100,10 @@ });

help: '\tOutput usage information',
'output-dir': `\tYou can specify the path in your project where to put build process artifacts. "${DEFAULT_OUTPUT_DIR}" by default`,
'docker-registry': 'docker registry host. *Required*.',
'container-name': 'name of the container. *Required*.',
'output-dir': '\tYou can specify the path in your project where to put build process artifacts. ' + DEFAULT_OUTPUT_DIR + ' by default',
'build-script-path': 'You can specify your own build.sh script',
'project-type': 'Could be "bem" or "webpack"(by default) - if defined than one of predefined scripts would be picked up.',
'build-on-host': 'Do not use docker-container to build the project. It works with npm@2',
'build-on-host': 'Do not use docker-container to build the project.',
'app-version': '\tversion of application',
'container-name': 'name of the container. *Required*.',
'project-build-dir': 'the directory that contains building artifacts. "dist" by default',
'docker-registry': 'docker registry host. *Required*.',
};

@@ -129,7 +130,7 @@

var NAME='docker-front-build'
shell.exec(`docker rm -f ${NAME} || true`);
shell.exec(`docker pull ${dockerRegistry}/${NAME}:latest`);
shell.exec(`docker run -d -v $(pwd):/app-source --name=${NAME} --net=host ${dockerRegistry}/${NAME}:latest`);
shell.exec(`docker wait ${NAME}`);
shell.exec(`docker logs ${NAME}`);
shell.exec('docker rm -f ' + NAME + ' || true');
shell.exec('docker pull ' + dockerRegistry + '/' + NAME + ':' + 'latest');
shell.exec('docker run -d -v $(pwd):/app-source --name=' + NAME + ' --net=host ' + dockerRegistry + '/' + NAME + ':latest');
shell.exec('docker wait ' + NAME);
shell.exec('docker logs ' + NAME);
}

@@ -10,6 +10,6 @@ var shell = require('shelljs');

var npmDiff;
var npmLs = shell.exec(`npm ls | tail -n +2 > ${currentNpmLsFile}`);
var npmLs = shell.exec('npm ls | tail -n +2 > ' + currentNpmLsFile);
if (fs.existsSync(prevNpmLsFile)) {
npmDiff = shell.exec(`diff ${currentNpmLsFile} ${prevNpmLsFile}`).output;
npmDiff = shell.exec('diff ' + currentNpmLsFile + ' ' + prevNpmLsFile).output;
} else {

@@ -19,5 +19,5 @@ npmDiff = true;

shell.exec(`mv ${currentNpmLsFile} ${prevNpmLsFile}`);
shell.exec('mv ' + currentNpmLsFile + ' ' + prevNpmLsFile);
return !!npmDiff;
};

@@ -5,5 +5,6 @@ var fs = require('fs');

var shell = require('shelljs');
var Promise = require('bluebird');
module.exports.packDeps = function(outputDir) {
return new Promise((resolve, reject) => {
return new Promise(function(resolve, reject) {
console.log('Create tar archive with deps...');

@@ -34,6 +35,6 @@ console.log(process.cwd());

.split('\n')
.map(d => d.replace(cwd, ''))
.filter(d => !!d)
.map(d => /\/node_modules\/([^/]*).*/.exec(d)[1])
.reduce((acc, cur) => {
.map(function(d) { return d.replace(cwd, ''); })
.filter(function(d) { return !!d })
.map(function(d) { return /\/node_modules\/([^/]*).*/.exec(d)[1]; })
.reduce(function(acc, cur) {
if (acc.indexOf(cur) === -1) {

@@ -59,3 +60,3 @@ acc.push(cur);

return new Promise((resolve, reject) => {
return new Promise(function(resolve, reject) {
console.log('Create tar archive with app...');

@@ -95,2 +96,2 @@ var output = fs.createWriteStream(path.join(outputDir, 'app.tar.gz'));

});
}
};
{
"name": "build-front-container",
"version": "0.0.5",
"version": "0.0.6",
"description": "",

@@ -14,2 +14,3 @@ "scripts": {

"archiver": "^1.0.0",
"bluebird": "^3.4.0",
"minimist": "^1.2.0",

@@ -16,0 +17,0 @@ "shelljs": "^0.6.0"

@@ -19,6 +19,6 @@ var builder = require('../lib');

describe('build front container', () => {
describe('build front container', function() {
afterEach(() => {
shell.exec(`rm -rf ${OUTPUT_DIR}`);
afterEach(function() {
shell.exec('rm -rf ' + OUTPUT_DIR);
shell.exec('rm -rf test/output');

@@ -28,3 +28,3 @@ shell.exec('rm -f ./build.sh');

it('should print help info', () => {
it('should print help info', function() {
var log = [];

@@ -45,3 +45,3 @@ var consoleLogOriginal = console.log;

it('should check if container-name option is passed', () => {
it('should check if container-name option is passed', function() {
var catched = false;

@@ -58,3 +58,3 @@ try {

it('should check if docker-registry option is passed', () => {
it('should check if docker-registry option is passed', function() {
var catched = false;

@@ -71,11 +71,11 @@ try {

it('should create build env', () => {
it('should create build env', function() {
createBuildEnv(OUTPUT_DIR, './test/build-test.sh');
expect(fs.existsSync(OUTPUT_DIR)).toBe(true);
expect(fs.existsSync(`${OUTPUT_DIR}/Dockerfile`)).toBe(true);
expect(fs.readFileSync('./build.sh')).toEqual(fs.readFileSync('./test/build-test.sh'));
expect(fs.existsSync(OUTPUT_DIR + '/Dockerfile')).toBe(true);
expect(fs.readFileSync('./build.sh').toString()).toEqual(fs.readFileSync('./test/build-test.sh').toString());
});
it('should choose prepared build.sh script for BEM project', () => {
it('should choose prepared build.sh script for BEM project', function() {
var res = getBuildScriptPath(null, 'bem');

@@ -85,3 +85,3 @@ expect(res).toBe(path.resolve(CWD, 'build-scripts/bem.sh'));

it('should choose prepared build.sh script for Webpack project', () => {
it('should choose prepared build.sh script for Webpack project', function() {
var res = getBuildScriptPath(null, 'webpack');

@@ -91,3 +91,3 @@ expect(res).toBe(path.resolve(CWD, 'build-scripts/webpack.sh'));

it('should choose build.sh script for Webpack project by default', () => {
it('should choose build.sh script for Webpack project by default', function() {
var res = getBuildScriptPath();

@@ -97,3 +97,3 @@ expect(res).toBe(path.resolve(CWD, 'build-scripts/webpack.sh'));

it('should exec build.sh to build project if build-on-host was passed', () => {
it('should exec build.sh to build project if build-on-host was passed', function() {
createBuildEnv(OUTPUT_DIR, './test/build-test.sh');

@@ -105,3 +105,4 @@ buildProject(true);

it('should check if deps changed', () => {
it('should check if deps changed', function() {
this.timeout(3000);
createBuildEnv(OUTPUT_DIR);

@@ -118,9 +119,9 @@ var prevNpmLs = '└── m1@0.0.1';

it('should pack deps', (done) => {
it('should pack deps', function(done) {
createBuildEnv(OUTPUT_DIR);
process.chdir('./test/project');
packDeps('../build').then(() => {
packDeps('../build').then(function() {
var res = shell.exec('tar -ztvf ../build/public-modules.tar.gz');
['m1/package.json', 'm2/package.json'].forEach(file => {
['m1/package.json', 'm2/package.json'].forEach(function(file) {
expect(res.stdout.indexOf(file)).toNotBe(-1);

@@ -135,9 +136,9 @@ });

it('should pack app', (done) => {
it('should pack app', function(done) {
createBuildEnv(OUTPUT_DIR);
process.chdir('./test/project');
packApp('../build', 'my-project-build-dir').then(() => {
packApp('../build', 'my-project-build-dir').then(function() {
var res = shell.exec('tar -ztvf ../build/app.tar.gz');
['my-project-build-dir/hi-there', 'package.json', 'config'].forEach(file => {
['my-project-build-dir/hi-there', 'package.json', 'config'].forEach(function(file) {
expect(res.stdout.indexOf(file)).toNotBe(-1);

@@ -144,0 +145,0 @@ });

Sorry, the diff of this file is not supported yet

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