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

polymer-project-config

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

polymer-project-config - npm Package Compare versions

Comparing version 3.4.0 to 3.5.0

5

CHANGELOG.md

@@ -8,5 +8,8 @@ # Change Log

## Unreleased
<!-- ## Unreleased -->
<!-- Add new, unreleased changes here. -->
## [3.5.0] - 2017-11-21
* Added static methods for constructing a ProjectConfig directly from an unvalidated JSON object, in addition to the methods for reading it from disk.
## [3.4.0] - 2017-06-21

@@ -13,0 +16,0 @@ * Modified the `bundle` property in project build options to support the subset of `polymer-bundler` options which can be serialized in a JSON file.

@@ -83,2 +83,13 @@ import { ProjectBuildOptions } from './builds';

/**
* Returns the given configJsonObject if it is a valid ProjectOptions object,
* otherwise throws an informative error message.
*/
static validateOptions(configJsonObject: {}): ProjectOptions;
/**
* Returns a new ProjectConfig from the given JSON object if it's valid.
*
* Throws if the given JSON object is an invalid ProjectOptions.
*/
static validateAndCreate(configJsonObject: {}): ProjectConfig;
/**
* constructor - given a ProjectOptions object, create the correct project

@@ -85,0 +96,0 @@ * configuration for those options. This involves setting the correct

37

lib/index.js

@@ -177,11 +177,3 @@ "use strict";

const contents = JSON.parse(configContent);
const validator = new jsonschema.Validator();
const result = validator.validate(contents, getSchema());
if (result.throwError) {
throw result.throwError;
}
if (result.errors.length > 0) {
throw result.errors[0];
}
return contents;
return this.validateOptions(contents);
}

@@ -203,3 +195,3 @@ catch (error) {

static loadConfigFromFile(filepath) {
let configParsed = ProjectConfig.loadOptionsFromFile(filepath);
const configParsed = ProjectConfig.loadOptionsFromFile(filepath);
if (!configParsed) {

@@ -210,2 +202,27 @@ return null;

}
/**
* Returns the given configJsonObject if it is a valid ProjectOptions object,
* otherwise throws an informative error message.
*/
static validateOptions(configJsonObject) {
const validator = new jsonschema.Validator();
const result = validator.validate(configJsonObject, getSchema());
if (result.errors.length > 0) {
throw result.errors[0];
}
if (result.throwError) {
throw new Error(`An error was encountered while validating the ` +
`Polymer Project Config.`);
}
return configJsonObject;
}
/**
* Returns a new ProjectConfig from the given JSON object if it's valid.
*
* Throws if the given JSON object is an invalid ProjectOptions.
*/
static validateAndCreate(configJsonObject) {
const options = this.validateOptions(configJsonObject);
return new this(options);
}
isFragment(filepath) {

@@ -212,0 +229,0 @@ return this.allFragments.indexOf(filepath) !== -1;

{
"name": "polymer-project-config",
"version": "3.4.0",
"version": "3.5.0",
"description": "reads, validates, and shapes your polymer.json project configuration",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -170,11 +170,3 @@ /**

const contents = JSON.parse(configContent);
const validator = new jsonschema.Validator();
const result = validator.validate(contents, getSchema());
if (result.throwError) {
throw result.throwError;
}
if (result.errors.length > 0) {
throw result.errors[0];
}
return contents;
return this.validateOptions(contents);
} catch (error) {

@@ -196,3 +188,3 @@ // swallow "not found" errors because they are so common / expected

static loadConfigFromFile(filepath: string): ProjectConfig|null {
let configParsed = ProjectConfig.loadOptionsFromFile(filepath);
const configParsed = ProjectConfig.loadOptionsFromFile(filepath);
if (!configParsed) {

@@ -205,2 +197,30 @@ return null;

/**
* Returns the given configJsonObject if it is a valid ProjectOptions object,
* otherwise throws an informative error message.
*/
static validateOptions(configJsonObject: {}): ProjectOptions {
const validator = new jsonschema.Validator();
const result = validator.validate(configJsonObject, getSchema());
if (result.errors.length > 0) {
throw result.errors[0];
}
if (result.throwError) {
throw new Error(
`An error was encountered while validating the ` +
`Polymer Project Config.`);
}
return configJsonObject;
}
/**
* Returns a new ProjectConfig from the given JSON object if it's valid.
*
* Throws if the given JSON object is an invalid ProjectOptions.
*/
static validateAndCreate(configJsonObject: {}) {
const options = this.validateOptions(configJsonObject);
return new this(options);
}
/**
* constructor - given a ProjectOptions object, create the correct project

@@ -207,0 +227,0 @@ * configuration for those options. This involves setting the correct

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