Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cordova-angularjs/.bowerrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"directory": "src/client/bower_components",
"strict-ssl": false
}
21 changes: 21 additions & 0 deletions cordova-angularjs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Mac OS X files that are not needed.
*.DS_Store

# IDE specific files (Web Storm, VS code, etc.)
.idea/*
!.idea/runConfigurations/
.settings
.vscode/*

# All log files
*.log

# Git conflict file backups
*.orig

# All packages
node_modules/
bower_components/

# All cordova built files
/cordova
103 changes: 103 additions & 0 deletions cordova-angularjs/.jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
// JSHint configuration for client-side development
// See http://jshint.com/docs/ for more details

"esversion" : 6,
"maxerr" : 50, // {int} Maximum error before stopping

// Enforcing
"bitwise" : true, // true: Prohibit bitwise operators (&, |, ^, etc.)
"camelcase" : true, // true: Identifiers must be in camelCase
"curly" : true, // true: Require {} for every new block or scope
"eqeqeq" : true, // true: Require triple equals (===) for comparison
"forin" : true, // true: Require filtering for..in loops with obj.hasOwnProperty()
"immed" : true, // true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
"indent" : 4, // {int} Number of spaces to use for indentation
"latedef" : false, // true: Require variables/functions to be defined before being used
"newcap" : true, // true: Require capitalization of all constructor functions e.g. `new F()`
"noarg" : true, // true: Prohibit use of `arguments.caller` and `arguments.callee`
"noempty" : true, // true: Prohibit use of empty blocks
"nonew" : false, // true: Prohibit use of constructors for side-effects (without assignment)
"plusplus" : false, // true: Prohibit use of `++` & `--`
"quotmark" : false, // Quotation mark consistency:
// false : do nothing (default)
// true : ensure whatever is used is consistent
// "single" : require single quotes
// "double" : require double quotes
"undef" : true, // true: Require all non-global variables to be declared (prevents global leaks)
"unused" : true, // true: Require all defined variables be used
"strict" : true, // true: Requires all functions run in ES5 Strict Mode
"trailing" : true, // true: Prohibit trailing whitespaces
"maxparams" : false, // {int} Max number of formal params allowed per function
"maxdepth" : false, // {int} Max depth of nested blocks (within functions)
"maxstatements" : false, // {int} Max number statements per function
"maxcomplexity" : false, // {int} Max cyclomatic complexity per function
"maxlen" : 120, // {int} Max number of characters per line

// Relaxing
"asi" : false, // true: Tolerate Automatic Semicolon Insertion (no semicolons)
"boss" : false, // true: Tolerate assignments where comparisons would be expected
"debug" : false, // true: Allow debugger statements e.g. browser breakpoints.
"eqnull" : false, // true: Tolerate use of `== null`
"esnext" : false, // true: Allow ES.next (ES6) syntax (ex: `const`)
"moz" : false, // true: Allow Mozilla specific syntax (ex: `for each`, multiple try/catch, function expression…)
"evil" : false, // true: Tolerate use of `eval` and `new Function()`
"expr" : false, // true: Tolerate `ExpressionStatement` as Programs
"funcscope" : false, // true: Tolerate defining variables inside control statements
"globalstrict" : false, // true: Allow global "use strict" (also enables 'strict')
"iterator" : false, // true: Tolerate using the `__iterator__` property
"lastsemic" : false, // true: Tolerate omitting a semicolon for the last statement of a 1-line block
"laxbreak" : false, // true: Tolerate possibly unsafe line breakings
"laxcomma" : false, // true: Tolerate comma-first style coding
"loopfunc" : false, // true: Tolerate functions being defined in loops
"multistr" : false, // true: Tolerate multi-line strings
"proto" : false, // true: Tolerate using the `__proto__` property
"scripturl" : false, // true: Tolerate script-targeted URLs
"smarttabs" : false, // true: Tolerate mixed tabs/spaces when used for alignment
"shadow" : false, // true: Allows re-define variables later in code e.g. `var x=1; x=2;`
"sub" : false, // true: Tolerate using `[]` notation when it can still be expressed in dot notation
"supernew" : false, // true: Tolerate `new function () { ... };` and `new Object;`
"validthis" : false, // true: Tolerate using this in a non-constructor function

// Environments
"browser" : true, // Web Browser (window, document, etc)
"couch" : false, // CouchDB
"devel" : true, // Development/debugging (alert, confirm, etc)
"dojo" : false, // Dojo Toolkit
"jquery" : true, // jQuery
"mootools" : false, // MooTools
"node" : true, // Node.js
"nonstandard" : false, // Widely adopted globals (escape, unescape, etc)
"prototypejs" : false, // Prototype and Scriptaculous
"rhino" : false, // Rhino
"worker" : false, // Web Workers
"wsh" : false, // Windows Scripting Host
"yui" : false, // Yahoo User Interface

// Legacy
"nomen" : false, // true: Prohibit dangling `_` in variables
"onevar" : false, // true: Allow only one `var` statement per function
"passfail" : false, // true: Stop on first error
"white" : true, // true: Check against strict whitespace and indentation rules

// Custom Globals
"predef" : [
"angular",
"_",
"describe",
"xdescribe",
"it",
"fail",
"xit",
"expect",
"spyOn",
"beforeEach",
"beforeAll",
"afterEach",
"afterAll",
"module",
"inject",
"jasmine",
"cordova"
]
}
1 change: 1 addition & 0 deletions cordova-angularjs/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.7.0
92 changes: 92 additions & 0 deletions cordova-angularjs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# NodeJs Mobile Example Cordova App with AngularJs

An AngularJs Cordova project that uses the [Node.js for Mobile Apps Cordova](https://github.com/janeasystems/nodejs-mobile-cordova) plugin library.

The sample app runs the Node.js engine in the Cordova to start an `HTTP` and `socket.io` server on port 8081 and sends data periodically.

## Pre-requisites

Note the instructions for the Cordova app on [Janea's site](https://code.janeasystems.com/nodejs-mobile/getting-started-cordova)

This sample also uses `bower`, `gulp` and `ios-deploy` to build and run. These can be installed through npm:
```
$ npm install -g bower
$ npm install -g gulp-cli
$ npm install -g ios-deploy
```

## How to run: Clone and Install Dependencies

Clone this repository and install the development dependencies (e.g. gulp), NodeJs mobile packages, and AngularJs packages.

NOTE: All commands in the next sections should be executed on macOS, using a Terminal in the `nodejs-mobile-samples/cordova-angularjs` unless otherwise noted.

```
$ npm install
```

## Dev and Test

You can develop and test the AngularJs and NodeJs code in a web browser and standard NodeJs server.
Several gulp scripts are provided to help with development and testing:

- `gulp serve:sync`
- Starts a "normal" NodeJs server and launches the AngularJs app in a web browser
- Uses browser sync and nodemon for live reload of both the server and app

- `gulp build`
- Builds the NodeJs server and AngularJs app into the `cordova/www` folder

- `gulp clean`
- Cleans the NodeJs server and AngularJs app from the `cordova/www` folder

- `npm run jshint`
- Runs jshint on the NodeJs and AngularJs code

## Setup and Build Cordova App

Setup the Cordova App using the same instructions for the Cordova app on [Janea's site](https://code.janeasystems.com/nodejs-mobile/getting-started-cordova)

A script is provided for these steps:

```
$ npm run setup-cordova
```

If you get a `Plugin doesn't support this project's cordova-ios version. cordova-ios: X.X.X, failed version requirement: <4.5.0` warning for `cordova-plugin-console`, the plugin will be skipped but the sample will still work, as the plugin was integrated in `cordova-ios` versions `>=4.5.0`.

The output app is in the `./cordova/ExampleCordovaAngular` folder.

Next, run a build to copy the NodeJs and AngularJs files to the `cordova/www` folder:

```
$ gulp build
```

Open the Cordova app project in Xcode:

```
$ open cordova/ExampleCordovaAngular/platforms/ios/HelloCordova.xcodeproj
```

In Xcode:

- Select HelloCordova to view the project settings
- In the General settings:
- In the Signing section, select a team to sign the app
- In the Deployment Info section, select Deployment Target 11.0 or higher

Go back to the Terminal window to build the Cordova app.

```
$ cd cordova/ExampleCordovaAngular
$ cordova build ios --device
```

Go back to Xcode:

- Select a target device for the project
- Run the project
- The app itself will show the sequence of events; these events are also output to the console

If you want to clean out the cordova app and start over, use `gulp clean:cordova`. Then start over with the instructions in this section.
31 changes: 31 additions & 0 deletions cordova-angularjs/bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "example_nodejs_mobile_app",
"description": "Example app for NodeJS Mobile",
"main": "app.js",
"authors": [
"Ken P"
],
"license": "MIT",
"keywords": [
"nodejs",
"mobile"
],
"homepage": "",
"private": false,
"ignore": [
"**/.*",
"node_modules",
"bower_components"
],
"dependencies": {
"jquery": "2.1.1",
"angular": "1.6.5",
"bootstrap": "3.3.7",
"angular-bootstrap": "2.5.0",
"angular-animate": "1.6.5",
"font-awesome": "4.7.0"
},
"resolutions": {
"angular": "1.6.5"
}
}
94 changes: 94 additions & 0 deletions cordova-angularjs/gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
"use strict";

var gulp = require('gulp'),
livereload = require('gulp-livereload'),
browserSync = require('browser-sync').create(),
path = require('path'),
nodemon = require('nodemon'),
del = require('del');

var client = {
cordova: './cordova/',
dist: './cordova/ExampleCordovaAngular/www/',
src: './src/client/**/*'
};

var server = {
dist: './cordova/ExampleCordovaAngular/www/nodejs-project/',
src: './src/server/**/*'
};

var deps = {
bower: './src/client/bower_components/**/*',
node: './src/server/node_modules/**/*',
root: './node_modules/**/*',
rootb: './node_modules/.bin'
};

var binaries = {
dist: server.dist + 'node_modules/uws/build/'
};

gulp.task('clean', function (cb) {
return del([client.dist + '**/*'], {force: true}, cb);
});

gulp.task('clean:dev', function (cb) {
return del([deps.bower, deps.node, deps.root, deps.rootb], {force: true}, cb);
});

gulp.task('clean:cordova', function (cb) {
return del([client.cordova], {force: true}, cb);
});

gulp.task('remove-binaries', ['build-server'], function (cb) {
return del([binaries.dist + '**/*'], {force: true}, cb);
});

gulp.task('build-client', ['clean'], function () {
return gulp.src(client.src).pipe(gulp.dest(client.dist));
});

gulp.task('build-server', ['clean'], function () {
return gulp.src(server.src).pipe(gulp.dest(server.dist));
});

gulp.task('build', ['clean', 'build-client', 'build-server', 'remove-binaries']);

gulp.task('default', ['build']);

var nodeApp = path.join(__dirname, 'src', 'server', 'main.js');
var staticDir = path.join(__dirname, 'src', 'client');
var defaultPort = 3001;

gulp.task('serve:sync', function() {
var tasks = ['sync-build'];

browserSync.init({
port: defaultPort,
server: {
baseDir: staticDir
}
});

livereload.listen();
gulp.watch(client.src, tasks);

startSeparateServer();
});

gulp.task('sync-build', function() {
browserSync.reload();
});

function startSeparateServer() {
nodemon({
script: nodeApp,
execMap: {
js: 'node'
},
watch: [
path.join(__dirname, 'src', 'server')
]
});
}
Loading