Socket
Socket
Sign inDemoInstall

boxedjs

Package Overview
Dependencies
6
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.2 to 0.3.0

.eslintrc

70

index.js
#!/usr/bin/env node
const fs = require('fs-extra');
const watch = require('node-watch');
const program = require('commander');
const boxed = require('./lib/boxed');
const {isFileValidForWatch} = require('./lib/utils');
const packagejson = require('./package.json');
main = () => {
let pages = {};
let templates = {};
console.log('Welcome to boxedjs.');
console.log('-- Removing old dist/ folder');
fs.removeSync('dist');
fs.mkdir('dist');
program
.version(packagejson.version)
.option('-w, --watch', 'Watch functionality. It will rebuild the website '
+ 'whenever a file changes.')
.option('-n, --new <name>', 'Create new project')
.parse(process.argv);
console.log('-- Loading pages...');
fs.readdirSync('./pages')
.filter((item) => {
return item.indexOf('.html') > -1;
}).forEach((item) => {
const itemKey = item.substring(0, item.length - 5);
pages[itemKey] = fs.readFileSync(`./pages/${item}`, 'utf8');
});
console.log('-- Loading templates...');
fs.readdirSync('./templates')
.filter((item) => {
return item.indexOf('.html') > -1;
}).forEach((item) => {
const itemKey = item.substring(0, item.length - 5);
templates[itemKey] = fs.readFileSync(`./templates/${item}`, 'utf8');
});
console.log('-- Generating Pages...');
Object.keys(pages).forEach((pageKey) => {
let templatedPage = pages[pageKey];
Object.keys(templates).forEach((templateKey) => {
templatedPage = templatedPage.replace(`[[${templateKey}]]`, templates[templateKey])
});
fs.writeFile(`dist/${pageKey}.html`, templatedPage, (err) => {
if(err) {
console.log(err);
process.exit()
}
});
});
if (fs.pathExistsSync('assets')) {
console.log('-- Copying asset folder');
fs.copySync('assets', 'dist');
}
console.log();
console.log('Finished! You can find your website in the dist/ folder.');
if (program.new) {
boxed.createNewProject(program.new);
process.exit(0);
}
program
.version('0.1.1')
.option('-w, --watch', 'Watch functionality. It will rebuild the website whenever a file changes.')
.parse(process.argv);
if (program.watch) {
watch('.', { recursive: true, filter: name => !/node_modules/.test(name) && !/dist/.test(name) }, (evt, name) => {
watch('.', {recursive: true, filter: isFileValidForWatch}, (evt, name) => {
console.log('%s changed.', name);
main();
boxed.compile();
});
} else {
main();
boxed.compile();
}
{
"name": "boxedjs",
"version": "0.2.2",
"version": "0.3.0",
"description": "A simple static HTML templating engine.",

@@ -11,2 +11,3 @@ "main": "index.js",

"compile": "node index.js",
"lint": "esw -w **/*.js index.js --ignore-pattern node_modules/",
"test": "echo \"Error: no test specified\" && exit 1"

@@ -37,3 +38,8 @@ },

"node-watch": "^0.5.5"
},
"devDependencies": {
"eslint": "^4.7.0",
"eslint-config-google": "^0.9.1",
"eslint-watch": "^3.1.2"
}
}

@@ -19,2 +19,13 @@ # boxedjs

### Create a new project
You can run either of the following:
```bash
boxed -n project-name
boxed --new project-name
```
in the folder where you want to start a new project.
This will create a new project called "project-name" in the current directory, containing a basic template and the right folder structure.
### Project structure

@@ -65,2 +76,3 @@ The script needs to be run in the root folder of the project and it expects the following project structure:

### TODO:

@@ -67,0 +79,0 @@ - Add example folder

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc