Browse Source

Bump to v 1.1.0 MVP

master
Muthu Kumar 7 years ago
parent
commit
fcb1a908ca
  1. 2
      LICENSE
  2. 24
      README.md
  3. 33
      lib/api.js
  4. 8
      package.json
  5. 19
      utils/extract.js
  6. 9
      utils/npminstall.js

2
LICENSE

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2017 CodeFeathers Copyright (c) 2017 Muthu Kumar / Anu Rahul Nandhan @ CodeFeathers
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

24
README.md

@ -1,9 +1,31 @@
# w # w
w is a cli application to spin up WordBox instances. Unstable, but in active development. w-cli is a cli application to spin up WordBox instances.
[WordBox](https://github.com/codefeathers/WordBox) is a quick development (and deployment) environment for PHP. [WordBox](https://github.com/codefeathers/WordBox) is a quick development (and deployment) environment for PHP.
## Install
> Before you install! `p7zip` must be in your PATH. `7z --help` to verify. On Debian or Ubuntu, use `sudo apt-get install p7zip`. Currently `w-cli` only works in Linux.
Install `w` from npm!
`npm install w --global`
## Usage
`w new <appname>`
Creates a new project at current folder with name `appname`. Downloads WordBox and extracts it to the folder and does `npm install` to resolve dependencies. You should download or compile `php` and `php-cgi` binaries and place them at `appname/php`. Place your public `.php` files at `appname/public`. Check `config.js` to see if all's perfect, then do `node .` to start a new Express server that runs PHP.
You should probably use `nginx` to reverse-proxy the server in production. Check out my other project `up-serve` [[npm]](https://npmjs.com/package/up-serve) [[Github]](https://github.com/codefeathers/up-serve) to setup nginx servers with a single command.
## Version
Current version is `v 1.1.0`. This is an MVP.
> Note: Because npm versions are immutable, our public version number starts directly from v.1.0.1. The project should be considered unstable until v.2.0.0 which will be `w-cli`'s first stable release version.
### Credits ### Credits
I humbly thank [@wbhob](https://github.com/wbhob) for donating the package name `w` on npm. I humbly thank [@wbhob](https://github.com/wbhob) for donating the package name `w` on npm.

33
lib/api.js

@ -6,22 +6,29 @@ const normalize = require('path').normalize;
const axios = require('axios'); const axios = require('axios');
const extract = require('../utils/extract'); const extract = require('../utils/extract');
const npminstall = require('../utils/npminstall');
const newapp = async (appname, options) => { const newapp = (appname, options) => {
console.log(`Spinning up a new WordBox app at ${appname}...`); console.log(`Spinning up a new WordBox app at ${appname}...`);
//const stream = fs.createWriteStream; const tmp = normalize(process.cwd() + '/wordbox.zip');
// const stream = normalize(process.cwd() + '/temp.zip'); console.log(`Downloading wordbox.zip`);
// console.log(stream) axios({
// const responseStream = await axios({ method: 'get',
// method: 'get', url: 'https://github.com/codefeathers/WordBox/archive/master.zip',
// url: 'https://github.com/codefeathers/up-serve/archive/master.zip', responseType: 'stream'
// responseType: 'stream' })
// }) .then(responseStream => new Promise((resolve, reject) => {
// await responseStream.data.pipe(fs.createWriteStream(stream)) responseStream.data.once('error', reject);
// const extractResponse = await extract(stream, normalize(process.cwd() + '/' + appname)) let fileStream = fs.createWriteStream(tmp);
// console.log(extractResponse) fileStream.once('error', reject);
// fs.unlink(stream, (err, res) => console.log(err, res)) fileStream.once('finish', resolve);
return responseStream.data.pipe(fileStream);
}))
.then(() => extract(tmp, normalize(process.cwd() + '/' + appname)))
.then(() => fs.unlink(tmp, (err) => { if(err) throw new Error(err) }))
.then(() => npminstall(appname))
.catch((err) => { if(err) throw new Error(err) });
}; };
module.exports.newapp = newapp; module.exports.newapp = newapp;

8
package.json

@ -1,8 +1,9 @@
{ {
"name": "w", "name": "w",
"version": "1.0.2", "version": "1.1.0",
"description": "WordBox cli to quickly spin up PHP dev environments.", "description": "WordBox cli to quickly spin up PHP dev environments.",
"main": "app.js", "main": "lib/api.js",
"bin": "cli.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
@ -26,7 +27,6 @@
"homepage": "https://github.com/codefeathers/w#readme", "homepage": "https://github.com/codefeathers/w#readme",
"dependencies": { "dependencies": {
"axios": "^0.17.1", "axios": "^0.17.1",
"commander": "^2.13.0", "commander": "^2.13.0"
"node-7z": "^0.4.0"
} }
} }

19
utils/extract.js

@ -1,11 +1,12 @@
var sevenZip = require('node-7z') 'use strict';
var Zip = new sevenZip()
const extract = (filename, destination) => { const child = require('child_process');
Zip.extractFull(filename, destination) const { normalize } = require('path');
.progress((files) => console.log('Some files are extracted: %s', files))
.then(() => console.log('Extracting done!'))
.catch((err) => console.error(err))
}
module.exports = extract function extract(source, destination) {
child.execSync(`7z x ${source} -o${destination}`);
child.execSync(`mv ${normalize(destination + '/WordBox-master/*')} ${destination}`);
child.execSync(`rm -rf ${normalize(destination + '/WordBox-master/')}`);
};
module.exports = extract;

9
utils/npminstall.js

@ -0,0 +1,9 @@
'use strict';
const child = require('child_process');
function npminstall(projectFolder) {
return std = child.execSync(`cd ${projectFolder} && npm install`);
};
module.exports = npminstall;
Loading…
Cancel
Save