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

fepper-utils

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fepper-utils - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0-rc.0

149

index.js

@@ -16,3 +16,3 @@ 'use strict';

// Do not JSDoc.
exports.conf = (isHeaded = false) => {
exports.conf = () => {
const rootDir = global.rootDir;

@@ -40,20 +40,7 @@

// Set appDir.
let appDir;
if (conf.app_dir) {
// Using exports.pathResolve() in case there are double-dots in conf.app_dir.
appDir = global.appDir = conf.app_dir = exports.pathResolve(rootDir, conf.app_dir);
}
else {
appDir = global.appDir;
}
// Retrieve custom values for UI.
try {
const defaultsStr = fs.readFileSync(`${rootDir}/patternlab-config.json`, enc);
conf.ui = JSON5.parse(defaultsStr);
const confUiStr = fs.readFileSync(`${rootDir}/patternlab-config.json`, enc);
conf.ui = JSON5.parse(confUiStr);
// TODO: enumerate required settings and fail with console error if not present.
// Update Pattern Lab paths.

@@ -69,10 +56,4 @@ exports.uiConfigNormalize(conf.ui, rootDir);

if (!exports.deepGet(conf, 'ui.paths')) {
exports.error('patternlab-config.json is missing paths, a critical value! Exiting!');
const appDir = global.appDir;
return;
}
conf.ui.paths.core = `${appDir}/ui/core`;
// Set defaults.

@@ -95,4 +76,4 @@ let defaults;

try {
const defaultsStr = fs.readFileSync(`${appDir}/excludes/patternlab-config.json`, enc);
defaults.ui = JSON5.parse(defaultsStr);
const defaultsUiStr = fs.readFileSync(`${appDir}/excludes/patternlab-config.json`, enc);
defaults.ui = JSON5.parse(defaultsUiStr);

@@ -120,4 +101,2 @@ // Update Pattern Lab paths.

conf.headed = isHeaded;
// HTML scraper confs. Defining here because they should never be exposed to end-users.

@@ -200,6 +179,2 @@ conf.scrape = {

exports.deepGet = (obj, path) => {
if (!(obj instanceof Object)) {
return null;
}
let pathElements;

@@ -214,2 +189,16 @@

else {
// This case will return the obj parameter if a path wasn't submitted.
// A possible user-error would be `exports.deepGet(nest.egg.yolk)` instead of `exports.deepGet(nest, 'egg.yolk')`.
// Alert the user when this is the case and provide a stack trace.
try {
throw new Error('fepper-utils deepGet() requires a valid path parameter, i.e. `deepGet(nest, \'egg.yolk\')`');
}
catch (err) {
exports.error(err);
}
return obj;
}
if (!(obj instanceof Object)) {
return null;

@@ -398,17 +387,17 @@ }

*
* @param {...string} ...pathSegments - Path or path segments.
* @return {string} Path.
*/
// Need to use the old function statement syntax so the arguments object works correctly.
exports.pathResolve = function () {
let pathname = '';
exports.pathResolve = (...pathSegments) => {
let pathName = '';
for (let i = 0; i < arguments.length; i++) {
for (let i = 0, l = pathSegments.length; i < l; i++) {
if (i) {
pathname += '/';
pathName += '/';
}
pathname += arguments[i];
pathName += pathSegments[i];
}
return slash(path.normalize(pathname));
return slash(path.normalize(pathName));
};

@@ -425,5 +414,7 @@

* @param {string} workDir - The absolute path to the directory directly above the relative paths in the uiObj.
* @param {string} [appDir] - The absolute path to the fepper-npm directory. Only necessary when Pattern Lab is
* instantiated without Fepper.
* @return {object} The mutated uiObj.
*/
exports.uiConfigNormalize = (uiObj, workDir) => {
exports.uiConfigNormalize = (uiObj, workDir, appDir) => {
if (!uiObj || !uiObj.paths || !uiObj.paths.source) {

@@ -434,11 +425,44 @@ throw 'Missing or malformed paths.source property!';

if (!uiObj.paths.public) {
throw 'Missing or malformed paths.source property!';
throw 'Missing or malformed paths.public property!';
}
// Fepper automatically sets global.appDir. Pattern Lab without Fepper needs to set it here.
if (appDir) {
global.appDir = appDir;
}
if (process.env.DEBUG) {
uiObj.debug = true;
}
const pathsSource = uiObj.paths.source;
const pathsPublic = uiObj.paths.public;
const pathsSource = uiObj.paths.source;
uiObj.paths.core = uiObj.paths.core || `${global.appDir}/ui/core`;
pathsPublic.styleguide = pathsPublic.styleguide || 'public/node_modules/fepper-ui';
// gulp.watch() will not trigger on file creation if watching an absolute path, so save normalized relative paths.
uiObj.pathsRelative = uiObj.pathsRelative || {source: {}, public: {}};
for (let i in pathsSource) {
if (!pathsSource.hasOwnProperty(i)) {
continue;
}
let pathSource = pathsSource[i];
if (pathSource.slice(0, 2) === './') {
pathSource = pathSource.slice(2);
}
if (pathSource.slice(-1) === '/') {
pathSource = pathSource.slice(0, -1);
}
if (pathsSource[i].indexOf(workDir) !== 0) {
uiObj.pathsRelative.source[i] = pathSource;
pathsSource[i] = `${workDir}/${pathSource}`;
}
}
for (let i in pathsPublic) {

@@ -465,21 +489,19 @@ if (!pathsPublic.hasOwnProperty(i)) {

for (let i in pathsSource) {
if (!pathsSource.hasOwnProperty(i)) {
// We also need paths relative to the public directory. This is so names for directories within the UI's document root
// can be user-configured, and not hard-coded.
uiObj.pathsPublic = uiObj.pathsPublic || {};
const regex = new RegExp('^' + uiObj.pathsRelative.public.root + '\\/');
for (let i in uiObj.pathsRelative.public) {
if (!uiObj.pathsRelative.public.hasOwnProperty(i)) {
continue;
}
let pathSource = pathsSource[i];
if (pathSource.slice(0, 2) === './') {
pathSource = pathSource.slice(2);
if (i === 'root') {
continue;
}
if (pathSource.slice(-1) === '/') {
pathSource = pathSource.slice(0, -1);
}
let pathPublic = uiObj.pathsRelative.public[i];
if (pathsSource[i].indexOf(workDir) !== 0) {
uiObj.pathsRelative.source[i] = pathSource;
pathsSource[i] = `${workDir}/${pathSource}`;
}
uiObj.pathsPublic[i] = uiObj.pathsRelative.public[i].replace(regex, '');
}

@@ -615,3 +637,3 @@

for (let i = 0; i < webservedDirsFull.length; i++) {
for (let i = 0, l = webservedDirsFull.length; i < l; i++) {
const webservedDirSplit = webservedDirsFull[i].split('/');

@@ -634,8 +656,15 @@ webservedDirSplit.shift();

exports.webservedDirsCopy = (webservedDirsFull, webservedDirsShort, staticDir) => {
for (let i = 0; i < webservedDirsFull.length; i++) {
fs.copySync(
`${global.conf.backend_dir}/${webservedDirsFull[i]}`,
`${staticDir}/${webservedDirsShort[i]}`
);
try {
for (let i = 0, l = webservedDirsFull.length; i < l; i++) {
fs.copySync(
`${global.conf.backend_dir}/${webservedDirsFull[i]}`,
`${staticDir}/${webservedDirsShort[i]}`
);
}
}
catch (err) {
exports.error(err);
return;
}
};
{
"name": "fepper-utils",
"version": "1.0.4",
"version": "1.1.0-rc.0",
"description": "Fepper utilities",

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

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