From 8d6b0f657e25fc7a1bbd6abd99602d27b983d2f8 Mon Sep 17 00:00:00 2001 From: Klenty Date: Wed, 24 Jan 2018 16:55:21 +0530 Subject: [PATCH] Added extract.js and started working on WordBox-cli --- IDEA.md | 80 ---------------------------------------------------------- README.md | 5 ++-- cli.js | 10 ++++++++ lib/extract.js | 11 ++++++++ package.json | 14 +++++----- 5 files changed, 32 insertions(+), 88 deletions(-) delete mode 100644 IDEA.md create mode 100755 cli.js create mode 100644 lib/extract.js diff --git a/IDEA.md b/IDEA.md deleted file mode 100644 index e2cf77e..0000000 --- a/IDEA.md +++ /dev/null @@ -1,80 +0,0 @@ -# Core idea - -The idea behind `w` is that web pages should be easily composable. Yes, there are a lot of other template engines out there, but some times you just don't want all that complexity in your life. You want something simple. Let's take an example. - -You start a simple static website. You make an `index.html` file. After a while, you add CSS, JS, and assets. - -``` -/project ⬎ - index.html - css/ ⬎ - style.css - js/ ⬎ - main.js - assets/ ⬎ - logo.png - banner-img.jpg -``` - -Everything looks good so far. Now in your `index.html`, you probably have a `header`, `nav` and `footer` element each. You create a new page, `about`. - -``` -/project ⬎ - index.html - /css ⬎ - style.css - /js ⬎ - main.js - /assets ⬎ - logo.png - banner-img.jpg - /about ⬎ - index.html -``` - -You probably want the same `header`, `nav` and `footer` in `about/index.html` as well. The only way to do this as of now is to make a copy of them. This isn't ideal of course because if anything changes in them, it has to be changed across all the index files. You'll also want to link to the CSS, JS, and static files. Enter `w`. - -The idea is that instead of `html` files, you'll make `w` files. Oh no, I need to learn ANOTHER syntax, you ask? Not at all. `w` files are just `html` with templates built in. Let's go with the earlier example. What will this look like with `w`? - -``` -/project ⬎ - w.json - /comps ⬎ - header.w - nav.w - footer.w - /source ⬎ - index.w - about.w - contact.w - /assets ⬎ - logo.png - banner-img.jpg - /css ⬎ - style.css - /js ⬎ - main.js -``` - -Now in `/source/index.w`, you add this: - -``` - - - - ... - - - - - -
- Some normal HTML content -
- - - - -``` - -A command like `w build .` in the root should now be able to load your `w.json` file, read the list and build the website at `/public`. Once this is done, you can simply publish your `/public` folder to the web! Anything else in the project root other than `/comps` and `/source` are simply placed in the `/public`, but with the advantage that you don't have to use relative or absolute paths for them. Simply use `w~assets/logo.png` to refer to the logo. \ No newline at end of file diff --git a/README.md b/README.md index d62494c..f4aeec4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # w -A very minimal web templater. -Will be soon in development. +w is a cli application to spin up WordBox instances. + +[WordBox](https://github.com/codefeathers/WordBox) is a quick development (and deployment) environment for PHP. ### Credits diff --git a/cli.js b/cli.js new file mode 100755 index 0000000..09343d9 --- /dev/null +++ b/cli.js @@ -0,0 +1,10 @@ +#!/usr/bin/env node + +var program = require('commander'); + +program + .version('0.1.0') + .option('-h, --help', 'Show w-cli help') + .parse(process.argv); + +if (program.help) console.log('w -v for version number'); diff --git a/lib/extract.js b/lib/extract.js new file mode 100644 index 0000000..bc1ad55 --- /dev/null +++ b/lib/extract.js @@ -0,0 +1,11 @@ +var sevenZip = require('node-7z') +var Zip = new sevenZip() + +const extract = (filename, destination) => { +Zip.extractFull(filenames, destination) + .progress((files) => console.log('Some files are extracted: %s', files)) + .then(() => console.log('Extracting done!')) + .catch(function (err) => console.error(err)) +} + +module.exports = extract diff --git a/package.json b/package.json index 0b21f16..451a88d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "w", - "version": "1.0.1", - "description": "A very minimal web templater.", + "version": "1.0.2", + "description": "WordBox cli to quickly spin up PHP dev environments.", "main": "app.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -11,10 +11,12 @@ "url": "git+https://github.com/codefeathers/w.git" }, "keywords": [ - "web", - "templater", - "node", - "w" + "w", + "wordbox", + "cli", + "php", + "development", + "tools" ], "author": "Muthu Kumar", "license": "MIT",