Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

liferay-npm-build-tools-common

Package Overview
Dependencies
Maintainers
17
Versions
117
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

liferay-npm-build-tools-common - npm Package Compare versions

Comparing version 2.24.3 to 2.25.0

src/project/__tests__/__fixtures__/project/scoped/.npmbundlerrc

2

lib/project/index.d.ts

@@ -127,2 +127,4 @@ /**

toolResolve(moduleName: string): any;
_findAutopresets(): string[];
_loadDefaultPreset(): string;
_loadNpmbundlerrc(): void;

@@ -129,0 +131,0 @@ _loadPkgJson(): void;

@@ -277,2 +277,41 @@ "use strict";

}
_findAutopresets() {
const { dependencies = {}, devDependencies = {} } = this._pkgJson;
return Object.keys({
...dependencies,
...devDependencies,
}).reduce((autoPresets, pkgName) => {
try {
const { dependencies } = this.require(pkgName + '/package.json');
if (dependencies && dependencies['liferay-npm-bundler']) {
autoPresets.push(pkgName);
}
}
catch (err) {
// ignore
}
return autoPresets;
}, []);
}
_loadDefaultPreset() {
let presetFilePath;
const autoPresets = this._findAutopresets();
if (autoPresets.length > 1) {
throw new Error('Multiple autopreset dependencies found in project (' +
autoPresets +
'): please remove the invalid ones or ' +
'explicitly define the preset to be used in the ' +
'.npmbundlerrc file');
}
else if (autoPresets.length) {
presetFilePath = this.resolve(autoPresets[0]);
this._toolsDir = new file_path_1.default(path_1.default.dirname(this.resolve(autoPresets[0] + '/package.json')));
}
else {
// If no preset was found, use the default one
presetFilePath = require.resolve('liferay-npm-bundler-preset-standard');
this._toolsDir = new file_path_1.default(path_1.default.dirname(require.resolve('liferay-npm-bundler-preset-standard/package.json')));
}
return presetFilePath;
}
_loadNpmbundlerrc() {

@@ -286,4 +325,3 @@ const npmbundlerrcPath = this._configFile.asNative;

if (config.preset === undefined) {
presetFilePath = require.resolve('liferay-npm-bundler-preset-standard');
this._toolsDir = new file_path_1.default(path_1.default.dirname(require.resolve('liferay-npm-bundler-preset-standard/package.json')));
presetFilePath = this._loadDefaultPreset();
}

@@ -290,0 +328,0 @@ else if (config.preset === '' || config.preset === false) {

10

lib/project/jar.js

@@ -86,5 +86,9 @@ "use strict";

if (this._outputFilename === undefined) {
this._outputFilename = dot_prop_1.default.get(npmbundlerrc, 'create-jar.output-filename', this.supported
? pkgJson['name'] + '-' + pkgJson['version'] + '.jar'
: undefined);
let defaultValue;
if (this.supported) {
defaultValue =
pkgJson['name'] + '-' + pkgJson['version'] + '.jar';
defaultValue = defaultValue.replace(/\//g, '_');
}
this._outputFilename = dot_prop_1.default.get(npmbundlerrc, 'create-jar.output-filename', defaultValue);
}

@@ -91,0 +95,0 @@ return this._outputFilename;

@@ -7,3 +7,3 @@ {

"escape-string-regexp": "^2.0.0",
"liferay-npm-bundler-preset-standard": "2.24.3",
"liferay-npm-bundler-preset-standard": "2.25.0",
"merge": "^1.2.1",

@@ -26,3 +26,4 @@ "properties": "^1.2.1",

},
"version": "2.24.3"
"version": "2.25.0",
"gitHead": "5501d9e5c15145cfd4d9d45bcc26fff1fd3420ba"
}

@@ -161,2 +161,10 @@ /**

});
it('returns a correct file name for scoped packages', () => {
const project = new Project(
path.join(__dirname, '__fixtures__', 'project', 'scoped')
);
expect(project.jar.outputFilename).toBe('@scoped_project-1.0.0.jar');
});
});

@@ -768,2 +776,39 @@

describe('handles autopresets', () => {
it('loads autopresets', () => {
const project = new Project(
path.join(__dirname, '__fixtures__', 'project', 'with-autopreset')
);
expect(project.buildDir.asPosix).toBe('./autopreset-build');
});
it('fails on multiple autopresets', () => {
expect(
() =>
new Project(
path.join(
__dirname,
'__fixtures__',
'project',
'with-two-autopresets'
)
)
).toThrowError(/Multiple autopreset.*autopreset.*autopreset2.*/);
});
it('ignores autopresets on explicitly configured preset', () => {
const project = new Project(
path.join(
__dirname,
'__fixtures__',
'project',
'with-ignored-autopreset'
)
);
expect(project.buildDir.asPosix).toBe('./preset-build');
});
});
describe('loads plugins as modules (as opposed to packages)', () => {

@@ -770,0 +815,0 @@ let project;

@@ -365,14 +365,51 @@ /**

_loadNpmbundlerrc(): void {
const npmbundlerrcPath = this._configFile.asNative;
_findAutopresets(): string[] {
const {dependencies = {}, devDependencies = {}} = this._pkgJson;
const config = fs.existsSync(npmbundlerrcPath)
? readJsonSync(npmbundlerrcPath)
: {};
return Object.keys({
...dependencies,
...devDependencies,
}).reduce((autoPresets, pkgName) => {
try {
const {dependencies} = this.require(pkgName + '/package.json');
// Apply preset if necessary
if (dependencies && dependencies['liferay-npm-bundler']) {
autoPresets.push(pkgName);
}
}
catch (err) {
// ignore
}
return autoPresets;
}, []);
}
_loadDefaultPreset(): string {
let presetFilePath;
if (config.preset === undefined) {
const autoPresets = this._findAutopresets();
if (autoPresets.length > 1) {
throw new Error(
'Multiple autopreset dependencies found in project (' +
autoPresets +
'): please remove the invalid ones or ' +
'explicitly define the preset to be used in the ' +
'.npmbundlerrc file'
);
}
else if (autoPresets.length) {
presetFilePath = this.resolve(autoPresets[0]);
this._toolsDir = new FilePath(
path.dirname(this.resolve(autoPresets[0] + '/package.json'))
);
}
else {
// If no preset was found, use the default one
presetFilePath = require.resolve(

@@ -390,2 +427,20 @@ 'liferay-npm-bundler-preset-standard'

}
return presetFilePath;
}
_loadNpmbundlerrc(): void {
const npmbundlerrcPath = this._configFile.asNative;
const config = fs.existsSync(npmbundlerrcPath)
? readJsonSync(npmbundlerrcPath)
: {};
// Apply preset if necessary
let presetFilePath;
if (config.preset === undefined) {
presetFilePath = this._loadDefaultPreset();
}
else if (config.preset === '' || config.preset === false) {

@@ -442,3 +497,3 @@

private _npmbundlerrc: object;
private _pkgJson: object;
private _pkgJson: {dependencies: object; devDependencies: object};
private _pkgManager: PkgManager;

@@ -445,0 +500,0 @@

@@ -128,8 +128,15 @@ /**

if (this._outputFilename === undefined) {
let defaultValue;
if (this.supported) {
defaultValue =
pkgJson['name'] + '-' + pkgJson['version'] + '.jar';
defaultValue = defaultValue.replace(/\//g, '_');
}
this._outputFilename = prop.get(
npmbundlerrc,
'create-jar.output-filename',
this.supported
? pkgJson['name'] + '-' + pkgJson['version'] + '.jar'
: undefined
defaultValue
);

@@ -136,0 +143,0 @@ }

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