wjs-cli:
CLI for making web and android apps with HTML , CSS and JS (ES7)
Under development.
$ wjs helpwjs remove <file-name> - Remove an installed wjs packagewjs publish <path-to-module> --type=<task|module> - Publish a wjs packagewjs add <package> - Add any installed package to current projectwjs init <App-name> <option> - Initialize a project of the option type - options: --javascript --typescript --react --vue --taskwjs install <module> - Install third party modulewjs tasks - List task runners installedwjs run <task-alias> - run wjs tasks to see installed task runnerswjs development - Run the code compiler in watch modewjs build <platform?> - Compiles the code into a website
Getting started
-
First get node and npm
-
Run
npm install wjs-cli -g
-
Run
wjs -v
to confirm installation -
Run
wjs init <app-name> <app-type>
where app type can be any of--typescript
,--vue
,--javascript
,--react
-
Run
cd <app-name> && wjs development
to start the development server -
Open http://localhost:3100 in your browser to view the app
-
To add a dependency run
wjs add <module>
where the module can be a default module or a third party module Check out how to make a module -
Use
wjs install <package-name>
to install a package, which is either a module or task runner -
To create an app with an android project in its directory use
wjs init <app-name> <app-type> --local
which makes a native project directory in your app folder, and to allow editing the android source code usewjs init <app-name> <app-type> --local --package=<app-package-name>
which generates the default wjs android source -
Use
wjs tasks
to see installed task runners -
Use
wjs run <task-alias>
to run the task -
To build the app run
wjs build
and usewjs build --android
to build the android app, but first make sureANDROID_HOME
is set.
Note
Vue projects dont have modules yet.
Javascript
The default wjs hello world app entry point looks like this.
; { rootinnerHTML = "<h1>Hello World</h1>"; } { console } app;
All it does is set "Hello world" as the root innerHTML
But you can also do more, like add html templates by extending the class with the TemplatePage
class in the app module
//Declare imports here. TemplatePage { //Call the super class super; thistemplate = //HTML code in a string, most preferably use backticks to fully express the html } //Template load is used for template pages because the TemplateApplication class comes with its own onViewLoad { //Code to run after the html renders } app;
A page controller looks something like this
//Imports can be made here just like any other module /* Notice the class was exported beacause it needs to be imported in the app entry point. */ { //Code to run before the page loads } { //Code to run after the page loads }
A page controller can also be a page if you use app.load(ROOT_ELEMENT,PAGE_NAME);
Using pages as modules is as easy as adding the new keyword to invoke the class e.g
//Declare imports here.; { //Code to run before the app loads var page = ; } //Your apps entry point { page } app;
Typescript
A typescript app is not much different from a javascript app.
Vue
For vue apps just go ahead and read the docs at the vue js site
; /* eslint-disable no-new */ el: '#app' template: "<App/>";
But vue specific modules are not ready yet so follow the vue docs only.
Modules
app
the app module has features like
-
jsx function
-
load function
-
events
-
socket
-
streams
-
TemplatePage
streams, sockets and events
//Declare imports here. { /* Socket demo */ var socket = app; this_socket = socket } //Your apps entry point { //Send message this_socket //Load emit function and on listener to the element appevents; //Listen for the event document this_socket //And you can remove event the element listeners by using app.events.strip(<element>); } app;
load and JSX functions
//Declare imports here. { //Code to run before the page loads } //Your apps entry point { //JSX function accepts a funtion that returns a html string which the jsx function uses to create the html elements var div = app documentbody; }//Load function that bootstraps the applicationsapp;
TemplatePages
//Declare imports here. TemplatePage { //Call the super class super; thistemplate = //HTML code in a string, most preferably use backticks to fully express the html } //Template load is used for template pages because the TemplateApplication class comes with its own onViewLoad { //Code to run after the html renders } app;
material
the material module has many features like
-
createElementClass
-
setElementClass
-
colors
-
icons
createElementClass and setElementClass
This gives you the ability to add css classes in javascript!!! ikr
//Declare imports here. { /* Create class with the following syntax material.createElementClass(<class-name>,{ "<property-name>": "<property-value>" }) Set class with the following syntax material.setElementClass(<element>,<class-name>) */ material } //Your apps entry point { var paragraph = document; material documentbody } app;
icons and colors
All material standard colors and icons are present and ready to use
//Declare imports here. { /* Create an icon The string argument is the name of the icon as if it were defined in html var face = material.icons("face"); Set color face.style.color = material.colors.blue; */ } //Your apps entry point { //Create an icon var face = material; //Set color facestylecolor = materialcolorsblue; documentbody } app;
Android
First of all you need to make android project definitions in your wjs-config.json
like this
Android functions are available as native
and that syntax is planned to be maintained in the future on other operating systems.
//Declare imports here.{}//Your apps entry point{/*** NOTE: native does not work on the web because of obvious reasons like the browser not running Android OS**///Toastnative;//Call activitynative;//Sms activitynative;//Exit appnative;}app;
TODO (More docs)
Changelog
wjs-cli@0.0.1
- Published wjs-cli on npm
wjs-cli@0.0.2
- Added install feature to allow installation of any third party module
wjs-cli@0.0.3
-
Created wjs-config.json file to allow specification of compile procedure and dependencies
-
Added
add
command to define project dependencies -
Changed bootstrap procedure to load
Application.onViewLoad
instead ofApplication.main
-
Conducted unit tests for:
- Config file
- Compile procedure
- module installation
- Typescript application support
-
Made basic typescript modules namely
app.ts
,web.ts (core)
,http.ts
,definitions.ts
,material.ts
wjs-cli@0.0.4
-
Bug fixes
-
Fixed errors in docs
-
Vue support
wjs-cli@0.0.5
- More bug fixes
wjs-cli@0.0.6
- Added android build
wjs-cli@0.0.7
- Critical bug fix
wjs-cli@0.0.8
- Critical bug fix
wjs-cli@0.0.9
- Fix typos
wjs-cli@0.1.0
- Bug fix
wjs-cli@0.1.1
- Bug fix
wjs-cli@0.1.2
-
Added update feature
-
Bug fix
wjs-cli@0.1.3
-
Support for Android ^5.0.0
-
Added module publishinng
wjs-cli@0.1.4
-
Fixed change-log error in readme
-
Added task runner features
-
Modularized source code
-
Added option to initialize a local (Personal) android project option
-
Added contributing.md
wjs-cli@0.1.5
- Bug fixes
wjs-cli@1.0.0
- Bug fixes
wjs-cli@2.0.0
-
Bug fixes
-
Performance improvements
-
NPM package support
Coming soon
- iOS support
Feel free to open an issue at the github repo