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

@smartface/builder

Package Overview
Dependencies
Maintainers
3
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smartface/builder - npm Package Compare versions

Comparing version 0.10.7-alpha.0 to 0.10.7-alpha.1

assets/ts/RouteHelper.ts

4

package.json
{
"name": "@smartface/builder",
"version": "0.10.7-alpha.0",
"version": "0.10.7-alpha.1",
"description": "Smartface Builder",

@@ -42,3 +42,3 @@ "bin": {

},
"gitHead": "53677cf33152a135848534edf9004e2943c22404"
"gitHead": "770843a13981bd999c1a57e66f8a7428a4202e15"
}

@@ -27,2 +27,3 @@ const path = require('path');

STYLER_UTIL_FILE: path.join(__dirname, '..', 'assets', 'styler-builder.js'),
ROUTEHELPER_SRC_FILE: path.join(__dirname, '..', 'assets', 'ts', 'RouteHelper.ts'),
LIBRARY_FILE_NAME: '__library__.pgx',

@@ -39,2 +40,3 @@ LIBRARY_PAGE_NAME: '__library__',

PGX_FOLDER: path.join(workspacePath, '.ui'),
ROUTER_FOLDER: path.join(workspacePath, '.ui/router'),
SCRIPTS_FOLDER: path.join(workspacePath, 'scripts'),

@@ -93,3 +95,3 @@ UI_FOLDER: path.join(workspacePath, 'scripts', 'ui'),

UPDATED_PATHS.ROUTER_UI_FOLDER = pathJoinWithWorkspace(defaultPaths.routerUiFolder || 'scripts/generated/router');
UPDATED_PATHS.ROUTER_UUSER_FOLDER = pathJoinWithWorkspace(defaultPaths.routerUserFolder || 'scripts/router');
UPDATED_PATHS.ROUTER_USER_FOLDER = pathJoinWithWorkspace(defaultPaths.routerUserFolder || 'scripts/router');
if (defaultPaths.pagesFolder) {

@@ -96,0 +98,0 @@ UPDATED_PATHS.PAGES_FOLDER = pathJoinWithWorkspace(defaultPaths.pagesFolder);

@@ -1,30 +0,35 @@

const fs = require("fs");
const fs = require('fs');
const prettier = require("prettier");
const Handlebars = require("handlebars");
const prettier = require('prettier');
const Handlebars = require('handlebars');
const getFormatterSettings = require("../config").getFormatterSettings;
const getProjectType = require("../config").getProjectType;
const getFormatterSettings = require('../config').getFormatterSettings;
const getProjectType = require('../config').getProjectType;
function readModuleFile(path) {
return fs.readFileSync(__dirname + "/" + path, 'utf8');
return fs.readFileSync(__dirname + '/' + path, 'utf8');
}
const src = {
header: (projectType) => `../template/${projectType}/_header.hbs`,
body: (projectType) => `../template/${projectType}/_body.hbs`,
footer: (projectType) => `../template/${projectType}/_footer.hbs`,
onLoad: (projectType) => `../template/${projectType}/_onLoad.hbs`,
page: (projectType) => `../template/${projectType}/page.hbs`,
repeatboxExampleData: (projectType) => `../template/${projectType}/_repeatBoxExampleData.hbs`,
require: (projectType) => `../template/${projectType}/_require.hbs`,
font: (projectType) => `../template/${projectType}/_font.hbs`,
component: (projectType) => `../template/${projectType}/component.hbs`,
userFile: (projectType) => `../template/${projectType}/userFile.hbs`,
eachHelper: (projectType) => `../template/${projectType}/_eachHelper.hbs`,
userPage: (projectType) => `../template/${projectType}/userPage.hbs`,
onRowCreate: (projectType) => `../template/${projectType}/_onRowCreate.hbs`,
gridViewBody: (projectType) => `../template/${projectType}/_gridViewBody.hbs`,
bottomTabbarRouter: (projectType) => `../template/${projectType}/_bottomTabbarRouter.hbs`,
idXml: () => `../template/idXml.hbs`
header: projectType => `../template/${projectType}/_header.hbs`,
body: projectType => `../template/${projectType}/_body.hbs`,
footer: projectType => `../template/${projectType}/_footer.hbs`,
onLoad: projectType => `../template/${projectType}/_onLoad.hbs`,
page: projectType => `../template/${projectType}/page.hbs`,
repeatboxExampleData: projectType => `../template/${projectType}/_repeatBoxExampleData.hbs`,
require: projectType => `../template/${projectType}/_require.hbs`,
font: projectType => `../template/${projectType}/_font.hbs`,
component: projectType => `../template/${projectType}/component.hbs`,
userFile: projectType => `../template/${projectType}/userFile.hbs`,
eachHelper: projectType => `../template/${projectType}/_eachHelper.hbs`,
eachRoutes: projectType => `../template/${projectType}/_eachRoutes.hbs`,
userPage: projectType => `../template/${projectType}/userPage.hbs`,
onRowCreate: projectType => `../template/${projectType}/_onRowCreate.hbs`,
gridViewBody: projectType => `../template/${projectType}/_gridViewBody.hbs`,
bottomTabbarRouter: projectType => `../template/${projectType}/_bottomTabbarRouter.hbs`,
idXml: () => `../template/idXml.hbs`,
router: projectType => `../template/${projectType}/_router.hbs`,
libRouter: projectType => `../template/${projectType}/_libRouter.hbs`,
userRouter: projectType => `../template/${projectType}/_userRouter.hbs`,
userLibRouter: projectType => `../template/${projectType}/_userLibRouter.hbs`
};

@@ -40,11 +45,10 @@

module.exports = function compile(templateName) {
return (data) => {
return data => {
const compiler = Handlebars.compile(__template[templateName], COMPILER_OPTIONS);
try {
if(data.name === '')
return;
return prettier.format(compiler(data), getFormatterSettings());
if (data.name === '') return;
return prettier.format(compiler(data), getFormatterSettings());
} catch (error) {
console.log("Error on compile : ", error.message, templateName, data);
console.log('Error on compile : ', error.stack || error.message);
return 'Template Compile ERROR: ' + error.stack || error.message;
}

@@ -55,43 +59,47 @@ };

module.exports.getIdXmlCompiler = () => {
return Handlebars.compile(readModuleFile(src.idXml()), COMPILER_OPTIONS);
}
return Handlebars.compile(readModuleFile(src.idXml()), COMPILER_OPTIONS);
};
module.exports.init = () => {
const projectType = getProjectType();
__template = {
header: readModuleFile(src.header(projectType)),
body: readModuleFile(src.body(projectType)),
footer: readModuleFile(src.footer(projectType)),
onLoad: readModuleFile(src.onLoad(projectType)),
page: readModuleFile(src.page(projectType)),
repeatboxExampleData: readModuleFile(src.repeatboxExampleData(projectType)),
require: readModuleFile(src.require(projectType)),
font: readModuleFile(src.font(projectType)),
component: readModuleFile(src.component(projectType)),
userFile: readModuleFile(src.userFile(projectType)),
eachHelper: readModuleFile(src.eachHelper(projectType)),
userPage: readModuleFile(src.userPage(projectType)),
onRowCreate: readModuleFile(src.onRowCreate(projectType)),
gridViewBody: readModuleFile(src.gridViewBody(projectType)),
bottomTabbarRouter: readModuleFile(src.bottomTabbarRouter(projectType)),
};
__compiler = {
repeatboxExampleData: Handlebars.compile(__template.repeatboxExampleData, COMPILER_OPTIONS),
require: Handlebars.compile(__template.require, COMPILER_OPTIONS),
font: Handlebars.compile(__template.font, COMPILER_OPTIONS)
};
const helper = require(`./templateHelpers/${getProjectType()}`)(__compiler);
// Register partials
Handlebars.registerPartial(__template);
// Register Helpers
Handlebars.registerHelper(helper);
//Register require helper.
Handlebars.registerHelper('require', function requireHelper(components, footer, isComponent) {
const rqrdMdl = helper.getRequiredModules(components, footer, isComponent);
return __compiler.require({
modules: rqrdMdl.filter(type => !isComponent ? type != "View" : true)
});
const projectType = getProjectType();
__template = {
header: readModuleFile(src.header(projectType)),
body: readModuleFile(src.body(projectType)),
footer: readModuleFile(src.footer(projectType)),
onLoad: readModuleFile(src.onLoad(projectType)),
page: readModuleFile(src.page(projectType)),
repeatboxExampleData: readModuleFile(src.repeatboxExampleData(projectType)),
require: readModuleFile(src.require(projectType)),
font: readModuleFile(src.font(projectType)),
component: readModuleFile(src.component(projectType)),
userFile: readModuleFile(src.userFile(projectType)),
eachHelper: readModuleFile(src.eachHelper(projectType)),
eachRoutes: readModuleFile(src.eachRoutes(projectType)),
userPage: readModuleFile(src.userPage(projectType)),
onRowCreate: readModuleFile(src.onRowCreate(projectType)),
gridViewBody: readModuleFile(src.gridViewBody(projectType)),
bottomTabbarRouter: readModuleFile(src.bottomTabbarRouter(projectType)),
router: readModuleFile(src.router(projectType)),
libRouter: readModuleFile(src.libRouter(projectType)),
userRouter: readModuleFile(src.userRouter(projectType)),
userLibRouter: readModuleFile(src.userLibRouter(projectType))
};
__compiler = {
repeatboxExampleData: Handlebars.compile(__template.repeatboxExampleData, COMPILER_OPTIONS),
require: Handlebars.compile(__template.require, COMPILER_OPTIONS),
font: Handlebars.compile(__template.font, COMPILER_OPTIONS)
};
const helper = require(`./templateHelpers/${getProjectType()}`)(__compiler);
// Register partials
Handlebars.registerPartial(__template);
// Register Helpers
Handlebars.registerHelper(helper);
//Register require helper.
Handlebars.registerHelper('require', function requireHelper(components, footer, isComponent) {
const rqrdMdl = helper.getRequiredModules(components, footer, isComponent);
return __compiler.require({
modules: rqrdMdl.filter(type => (!isComponent ? type != 'View' : true))
});
module.exports.helper = helper;
});
module.exports.helper = helper;
};

@@ -301,2 +301,4 @@ const path = require('path');

if (val && Object.keys(val).length > 0) return options.inverse(this);
} else if ( !val || Number(val.length) === 0) {
return options.fn(this);
} else if (val) {

@@ -316,2 +318,9 @@ return options.inverse(this);

function isValidArray(val, options) {
if (val instanceof Array && ['number', 'string'].includes(typeof val[0])) {
return options.fn(this);
}
return options.inverse(this);
}
function isEqual(left, right, options) {

@@ -395,2 +404,3 @@ if (left === right) {

return {
isValidArray,
getStatusBarProp,

@@ -397,0 +407,0 @@ capitalizeFirstLetter,

@@ -1,9 +0,9 @@

const path = require("path");
const path = require('path');
const nsfw = require('@smartface/nsfw-prebuild');
const util = require("../util");
const intervalChecker = require("../util/intervalChecker");
const styleGeneration = require("./generateStyles");
const util = require('../util');
const intervalChecker = require('../util/intervalChecker');
const styleGeneration = require('./generateStyles');
const isExistsFileDir = util.isExistsFileDir;
const getPath = require("../config").getPath;
const getPath = require('../config').getPath;
const EVENT_TYPE = require('./event-type');

@@ -17,160 +17,189 @@ const WATCHER_DELAY = 400; //ms

*/ const WATCHER_STATUS = {
"READY": "READY",
"RUNNING": "RUNNING",
"STOPPED": "STOPPED"
READY: 'READY',
RUNNING: 'RUNNING',
STOPPED: 'STOPPED'
};
function Watcher(callBack) {
let watcherThemes;
let watcherPgxFolder;
let status = WATCHER_STATUS.READY;
let pgxTimer;
let themesTimer;
let themesGeneratorTaskCounter = 0;
let libTranspilerTaskCounter = 0;
let watcherThemes;
let watcherPgxFolder;
let status = WATCHER_STATUS.READY;
let pgxTimer;
let themesTimer;
let themesGeneratorTaskCounter = 0;
let libTranspilerTaskCounter = 0;
const themesFolder = getPath("THEMES_FOLDER");
const pgxFolder = getPath("PGX_FOLDER");
const uiFolder = getPath("UI_FOLDER");
const libraryFolder = path.join(pgxFolder, 'library');
let watcherEnabled = true;
const themesFolder = getPath('THEMES_FOLDER');
const pgxFolder = getPath('PGX_FOLDER');
const uiFolder = getPath('UI_FOLDER');
const libraryFolder = path.join(pgxFolder, 'library');
let watcherEnabled = true;
this.start = watcherHandler => {
let taskCount = 2;
pgxTimer = intervalChecker(pgxFolder, false, startHelper, stop);
themesTimer = intervalChecker(themesFolder, false, startHelper, stop);
this.start = (watcherHandler, routerWatcherHandler) => {
let taskCount = 2;
pgxTimer = intervalChecker(pgxFolder, false, startHelper, stop);
themesTimer = intervalChecker(themesFolder, false, startHelper, stop);
function startHelper() {
if (--taskCount === 0) {
_start(watcherHandler);
}
}
};
function startHelper() {
if (--taskCount === 0) {
_start(watcherHandler, routerWatcherHandler);
}
}
};
const _start = watcherHandler => {
watcherHandler.setWatcherEnabledStatusFunc((enabled) => {
watcherEnabled = enabled;
});
const _start = (watcherHandler, routerWatcherHandler) => {
watcherHandler.setWatcherEnabledStatusFunc(enabled => {
watcherEnabled = enabled;
});
styleGeneration.initFolderPaths();
status = WATCHER_STATUS.RUNNING;
styleGeneration.initFolderPaths();
status = WATCHER_STATUS.RUNNING;
nsfw(themesFolder,
(events) => {
events.forEach(e => this.themesWatcherHandler(e));
}, {
errorCallback(errors) {
util.writeError(errors, "Watcher Themes Error");
stop();
}
})
.then((watcher) => {
watcherThemes = watcher;
return watcher.start();
})
.then(() => {
});
nsfw(
themesFolder,
events => {
events.forEach(e => this.themesWatcherHandler(e));
},
{
errorCallback(errors) {
util.writeError(errors, 'Watcher Themes Error');
stop();
}
}
)
.then(watcher => {
watcherThemes = watcher;
return watcher.start();
})
.then(() => {});
nsfw(pgxFolder,
(events) => {
let cachedEvents = {};
events
.filter( e => {
let label = e.action + e.directory + e.file;
if(cachedEvents[label]){
return false;
}
cachedEvents[label] = 1;
return true;
})
.forEach(e => this.pgxWatcherHandler(e));
}, {
errorCallback(errors) {
util.writeError(err, "Watcher Pgx Error");
stop();
},
excludedPaths: [libraryFolder]
})
.then((watcher) => {
watcherPgxFolder = watcher;
return watcher.start();
})
.then(() => {
});
this.pgxWatcherHandler = (event) => {
const filename = path.join(event.directory || event.newDirectory, event.file || event.newFile);
if (!watcherEnabled) {
return console.warn('├─> Ignore Change > ', EVENT_TYPE[event.action], filename);
nsfw(
pgxFolder,
events => {
let cachedEvents = {};
events
.filter(e => {
let label = e.action + e.directory + e.file;
if (cachedEvents[label]) {
return false;
}
if (event.action === nsfw.actions.DELETED && filename === pgxFolder)
return stop();
if (filename === pgxFolder)
return;
if (new RegExp(`library${'\\' + path.sep}.*\.(pgx|cpx)`).test(filename)) {
return; //skip library folder.
} else if (!util.isSmartfaceDesignFile(filename)) {
return console.warn('├─> Skip Change > ', EVENT_TYPE[event.action], filename);
}
console.log('├─ ⏰ 📄 »', EVENT_TYPE[event.action], '« ', filename);
//console.log('eventTrype:' + eventType + ' filename provided:' + filename);
isExistsFileDir(uiFolder).then(res => {
if (res.existing && res.dir) {
if (event.action === nsfw.actions.DELETED) {
watcherHandler.deleteScriptFile(filename);
}
else if (event.action === nsfw.actions.MODIFIED || event.action === nsfw.actions.RENAMED || event.action === nsfw.actions.CREATED) {
watcherHandler.changeHandler(filename).then(res => res);
}
}
else {
watcherHandler.transpileAllPgxFiles();
}
}, err => util.writeError(err, "isExistsFileDir"));
};
cachedEvents[label] = 1;
return true;
})
.forEach(e => this.pgxWatcherHandler(e));
},
{
errorCallback(errors) {
util.writeError(err, 'Watcher Pgx Error');
stop();
},
excludedPaths: [libraryFolder]
}
)
.then(watcher => {
watcherPgxFolder = watcher;
return watcher.start();
})
.then(() => {});
this.themesWatcherHandler = (event) => {
const filename = path.join(event.directory || event.newDirectory, event.file || event.newFile);
if (event.action === nsfw.actions.DELETED && event.directory === themesFolder)
return stop();
if (!util.isStyleDesignFile(filename)) {
return console.warn('├─> Skip Change > ', EVENT_TYPE[event.action], filename);
this.pgxWatcherHandler = event => {
const filename = path.join(
event.directory || event.newDirectory,
event.file || event.newFile
);
//console.log('Filename: ', filename);
if (!watcherEnabled) {
return console.warn('├─> Ignore Change > ', EVENT_TYPE[event.action], filename);
}
if (event.action === nsfw.actions.DELETED && filename === pgxFolder) return stop();
if (filename === pgxFolder) return;
if (new RegExp(`library${'\\' + path.sep}.*\.(pgx|cpx)`).test(filename)) {
return; //skip library folder.
} else if (!util.isSmartfaceRouterDesignFile(filename)) {
console.log('├─ ⏰ 🔀 »', EVENT_TYPE[event.action], '« ', filename);
return routerWatcherHandler.transpileAllRouterFiles();
} else if (!util.isSmartfaceDesignFile(filename)) {
return console.warn('├─> Skip Change > ', EVENT_TYPE[event.action], filename);
}
console.log('├─ ⏰ 📄 »', EVENT_TYPE[event.action], '« ', filename);
//console.log('eventTrype:' + eventType + ' filename provided:' + filename);
isExistsFileDir(uiFolder).then(
res => {
if (res.existing && res.dir) {
if (event.action === nsfw.actions.DELETED) {
watcherHandler.deleteScriptFile(filename);
} else if (
event.action === nsfw.actions.MODIFIED ||
event.action === nsfw.actions.RENAMED ||
event.action === nsfw.actions.CREATED
) {
watcherHandler.changeHandler(filename).then(res => res);
}
++themesGeneratorTaskCounter;
setTimeout(_ => {
if (--themesGeneratorTaskCounter === 0) {
console.log('├─ ⏰ 🎨 »', EVENT_TYPE[event.action], '« ', path.relative(path.dirname(themesFolder), filename));
generateStyles();
}
}, WATCHER_DELAY);
};
//First generations...
// watcherHandler.transpileLibraryPgx(path.join(pgxFolder, LIBRARY_FILE_NAME));
// watcherHandler.transpileAllPgxFiles();
generateStyles();
} else {
watcherHandler.transpileAllPgxFiles();
routerWatcherHandler.transpileAllRouterFiles();
}
},
err => util.writeError(err, 'isExistsFileDir')
);
};
const stop = (opt) => {
var _opt = opt || {};
if (status === WATCHER_STATUS.STOPPED) {
return console.log("Watcher has already been stopped!");
} !_opt.silent && util.writeError(new Error(`Check Following Folders Exist\n - ${pgxFolder}\n - ${themesFolder}`),
status === WATCHER_STATUS.RUNNING ? "Watcher Unlink Error" : "Watcher Starting Error");
status = WATCHER_STATUS.STOPPED;
watcherPgxFolder.stop();
watcherThemes.stop()
pgxTimer && clearInterval(pgxTimer);
themesTimer && clearInterval(themesTimer);
libTranspilerTaskCounter = 0;
themesGeneratorTaskCounter = 0;
return !_opt.silent && callBack(null, status);
this.themesWatcherHandler = event => {
const filename = path.join(
event.directory || event.newDirectory,
event.file || event.newFile
);
if (event.action === nsfw.actions.DELETED && event.directory === themesFolder) return stop();
if (!util.isStyleDesignFile(filename)) {
return console.warn('├─> Skip Change > ', EVENT_TYPE[event.action], filename);
}
++themesGeneratorTaskCounter;
setTimeout(_ => {
if (--themesGeneratorTaskCounter === 0) {
console.log(
'├─ ⏰ 🎨 »',
EVENT_TYPE[event.action],
'« ',
path.relative(path.dirname(themesFolder), filename)
);
generateStyles();
}
}, WATCHER_DELAY);
};
//First generations...
// watcherHandler.transpileLibraryPgx(path.join(pgxFolder, LIBRARY_FILE_NAME));
// watcherHandler.transpileAllPgxFiles();
generateStyles();
};
this.stop = stop;
const stop = opt => {
var _opt = opt || {};
if (status === WATCHER_STATUS.STOPPED) {
return console.log('Watcher has already been stopped!');
}
!_opt.silent &&
util.writeError(
new Error(`Check Following Folders Exist\n - ${pgxFolder}\n - ${themesFolder}`),
status === WATCHER_STATUS.RUNNING ? 'Watcher Unlink Error' : 'Watcher Starting Error'
);
status = WATCHER_STATUS.STOPPED;
watcherPgxFolder.stop();
watcherThemes.stop();
pgxTimer && clearInterval(pgxTimer);
themesTimer && clearInterval(themesTimer);
libTranspilerTaskCounter = 0;
themesGeneratorTaskCounter = 0;
return !_opt.silent && callBack(null, status);
};
function generateStyles() {
styleGeneration.generateStyles().then(res => { }, err => util.writeError(err, "Watcher -> Generating Styles Error"));
}
this.stop = stop;
function generateStyles() {
styleGeneration.generateStyles().then(
res => {},
err => util.writeError(err, 'Watcher -> Generating Styles Error')
);
}
}
module.exports = Watcher;

@@ -1,34 +0,37 @@

const fs = require("fs");
const path = require("path");
const WatcherHandler = require("./watcherHandler");
const Watcher = require("./core/watcher");
const util = require("./util");
const getPath = require("./config").getPath;
const fs = require('fs');
const path = require('path');
const WatcherHandler = require('./watcherHandler');
const RouterWatcherHandler = require('./routerWatcherHandler');
const Watcher = require('./core/watcher');
const util = require('./util');
const getPath = require('./config').getPath;
function run(callBack, isStandalone = false) {
const scriptsFolder = getPath("UI_FOLDER");
const watcherHandler = new WatcherHandler(isStandalone);
const watcher = isStandalone ? null : new Watcher(callBack);
// first phase.
util.mkdirpSync(scriptsFolder);
util.createClearDir(scriptsFolder).then(res => {
watcherHandler.init();
watcher && watcher.start(watcherHandler); // start to watch
});
const scriptsFolder = getPath('UI_FOLDER');
const watcherHandler = new WatcherHandler(isStandalone);
const routerWatcherHandler = new RouterWatcherHandler(isStandalone);
const watcher = isStandalone ? null : new Watcher(callBack);
// first phase.
util.mkdirpSync(scriptsFolder);
util.createClearDir(scriptsFolder).then(res => {
watcherHandler.init();
watcher && watcher.start(watcherHandler, routerWatcherHandler); // start to watch
routerWatcherHandler.transpileAllRouterFiles();
});
watcherHandler.on("readyFileContent", (content, filePath, isChanged) => {
if (!isChanged) {
//return console.log("├─ " + path.basename(filePath) + " has already been generated");
}
util.mkdirpSync(path.dirname(filePath));
fs.writeFileSync(filePath, content, "utf8");
console.log("├─ 📄 Generated " + path.relative(path.dirname(scriptsFolder), filePath));
});
watcherHandler.on('readyFileContent', (content, filePath, isChanged) => {
if (!isChanged) {
//return console.log("├─ " + path.basename(filePath) + " has already been generated");
}
util.mkdirpSync(path.dirname(filePath));
fs.writeFileSync(filePath, content, 'utf8');
console.log('├─ 📄 Generated ' + path.relative(path.dirname(scriptsFolder), filePath));
});
watcherHandler.on("libraryFileChanged", pgx => {
//console.log("libraryFileChanged ", pgx);
});
return watcher;
watcherHandler.on('libraryFileChanged', pgx => {
//console.log("libraryFileChanged ", pgx);
});
return watcher;
}
module.exports = run;

@@ -223,2 +223,33 @@ const fs = require("fs-extra");

function readRouterFile(filePath) {
return new Promise((resolve, reject) => {
isExistsFileDir(filePath)
.then(res => {
if (res.existing && res.file) {
fs.readFile(filePath, "utf8", (err, data) => {
if (!err) {
if (!data)
return resolve(null);
try {
resolve(jsonlint.parse(data));
}
catch (ex) {
reject(Object.assign(new Error('Router JSON Parse Error \n' + ex.toString().replace(/\n/gm, "\n\t")), { file: filePath }));
}
}
else {
reject(Object.assign(new Error("Router readFile"), { file: filePath }));
}
});
}
else {
reject(new Error("Router File ENOENT" + filePath));
}
}, err => {
console.log(err.toString());
return resolve(null);
});
});
}
function removeFile(filePath) {

@@ -363,2 +394,6 @@ return new Promise((resolve, reject) => {

function isSmartfaceRouterDesignFile(filename) {
return SMARTFACE_DESİGN_REGEXP.test(filename);
}
function isStyleDesignFile(filename) {

@@ -377,2 +412,3 @@ return STYLE_DESIGN_REGEXP.test(filename)

readPgx: readPgx,
readRouterFile,
writeError: writeError,

@@ -388,3 +424,4 @@ removeFile: removeFile,

isSmartfaceDesignFile,
isSmartfaceRouterDesignFile,
isStyleDesignFile
};

Sorry, the diff of this file is not supported yet

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