Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PixelsCommander committed May 6, 2016
0 parents commit d5a3d13
Show file tree
Hide file tree
Showing 195 changed files with 19,225 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
node_modules
48 changes: 48 additions & 0 deletions cli.js
@@ -0,0 +1,48 @@
#!/usr/bin/env node
'use strict';

var TerminalAdapter = require('yeoman-environment/lib/adapter.js');
var yeoman = require('yeoman-environment');
var path = require('path');
var Promise = require('promise');
var argv = require('minimist')(process.argv.slice(2));

class CreateSuppressingTerminalAdapter extends TerminalAdapter {
constructor() {
super();
// suppress 'create' output generated by yeoman
this.log.create = function() {};
}
}

function init(argsOrName) {
console.log('Initializing new Polymer Native app');
var env = yeoman.createEnv(
undefined,
undefined,
new TerminalAdapter()
);

env.register(
require.resolve(path.join(__dirname, 'ios-generator/app')),
'ios-generator:app'
);

// argv is for instance
// ['node', 'react-native', 'init', 'AwesomeApp', '--verbose']
// args should be ['AwesomeApp', '--verbose']
var args = Array.isArray(argsOrName)
? argsOrName
: [argsOrName].concat(process.argv.slice(4));

var generator = env.create('ios-generator:app', {args: args});
generator.destinationRoot(__dirname);
generator.run();
}

var args = process.argv.slice(3);

if (argv._ && argv._.indexOf('init') > -1) {
console.log(argv._[1]);
init(args);
}
68 changes: 68 additions & 0 deletions gulpfile.js
@@ -0,0 +1,68 @@
var BUNDLE_NAME = 'polymer-native',
gulp = require('gulp'),
gutil = require('gulp-util'),
path = require('path'),
concat = require('gulp-concat'),
uglify = require('gulp-uglifyjs'),
watch = require('gulp-watch'),
karma = require('karma'),
karmaParseConfig = require('karma/lib/config').parseConfig;

gulp.task('build', function () {
gulp.src(['node_modules/webcomponents.js/webcomponents-lite.min.js', './libraries/js/src/pn-utils.js', './libraries/js/src/pn-base-element.js', './libraries/js/src/elements/*.js'])
.pipe(concat(BUNDLE_NAME + '.js'))
.pipe(gulp.dest('dist'))
.pipe(uglify(BUNDLE_NAME + '.min.js'))
.pipe(gulp.dest('dist'));
});

function runKarma(configFilePath, options, cb) {

configFilePath = path.resolve(configFilePath);

var server = karma.server;
var log=gutil.log, colors=gutil.colors;
var config = karmaParseConfig(configFilePath, {});

Object.keys(options).forEach(function(key) {
config[key] = options[key];
});

server.start(config, function(exitCode) {
log('Karma has exited with ' + colors.red(exitCode));
cb();
process.exit(exitCode);
});
}

/** actual tasks */

/** single run */
gulp.task('test', function(cb) {
runKarma('karma.conf.js', {
autoWatch: false,
singleRun: true
}, cb);
});

/** continuous ... using karma to watch (feel free to circumvent that;) */
gulp.task('test-dev', function(cb) {
runKarma('karma.conf.js', {
autoWatch: true,
singleRun: false
}, cb);
});

gulp.task('develop', function() {
watch('./libraries/js/src/*.js', function(){
gulp.run(['build'/*, 'test'*/])
});
});

gulp.task('copylibrary', function() {
watch('./libraries/js/src/*.js', function(){
gulp.run(['build'/*, 'test'*/])
});
});

gulp.task('default', ['test-dev', 'develop']);
72 changes: 72 additions & 0 deletions ios-generator/app/index.js
@@ -0,0 +1,72 @@
'use strict';
var yeoman = require('yeoman-generator');
var chalk = require('chalk');
var yosay = require('yosay');
var path = require('path');

module.exports = yeoman.Base.extend({

constructor: function () {
yeoman.Base.apply(this, arguments);
this.argument('name', {type: String, required: true});
},

writing: function () {
var templateVars = {name: this.name};

console.log('Application name', this.name);

this.fs.copy(
[this.templatePath(path.join('./project/Pods', '**', '*'))],
this.destinationPath(path.join('./ios/Pods'))
);

this.fs.copyTpl(
[this.templatePath(path.join('./project/', '*'))],
this.destinationPath(path.join('./ios/')),
this
);

this.fs.copyTpl(
[this.templatePath(path.join('./npm/', '*'))],
this.destinationPath(),
this
);

this.fs.copy(
this.templatePath(path.join('./project', 'projectName', '**', '*.png')),
this.destinationPath(path.join('./ios/', this.name))
);

this.fs.copyTpl(
[this.templatePath(path.join('./project/', 'projectName', '**', '*')), '!**/*.png'],
this.destinationPath(path.join('./ios/', this.name)),
this
);

this.fs.copyTpl(
this.templatePath(path.join('./project/', 'projectName.xcodeproj', '**', '*')),
this.destinationPath(path.join('./ios/', this.name + '.xcodeproj')),
this
);

this.fs.copyTpl(
this.templatePath(path.join('./project/', 'projectName.xcworkspace', '**', '*')),
this.destinationPath(path.join('./ios/', this.name + '.xcworkspace')),
this
);
},

install: function () {
//this.installDependencies();
},

end: function () {
var projectPath = path.resolve(this.destinationRoot(), 'ios', this.name);
this.log(chalk.white.bold('Now you may run your app by:'));
this.log(chalk.white(' cd ' + this.destinationRoot()));
this.log(chalk.white(' polymer-native run'));
this.log(chalk.white(' or'));
this.log(chalk.white(' Open ' + projectPath + '.xcworkspace in Xcode and run it then'));
}
});
11 changes: 11 additions & 0 deletions ios-generator/app/templates/npm/package.json
@@ -0,0 +1,11 @@
{
"name": "<%= name %>",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node_modules/polymer-native/build/build.sh"
},
"dependencies": {
"polymer-native": "*"
}
}
4 changes: 4 additions & 0 deletions ios-generator/app/templates/project/Podfile
@@ -0,0 +1,4 @@
platform :ios, '8.1'
use_frameworks!
pod 'XWebView', '~> 0.9.5'
pod 'ActionKit', '~> 1.0'
13 changes: 13 additions & 0 deletions ios-generator/app/templates/project/Podfile.lock
@@ -0,0 +1,13 @@
PODS:
- ActionKit (1.0)
- XWebView (0.9.5)

DEPENDENCIES:
- ActionKit (~> 1.0)
- XWebView (~> 0.9.5)

SPEC CHECKSUMS:
ActionKit: 6c45e3d92252dd34b18e7c3d8e9f811ee52558b1
XWebView: 0db7b6e207fe0911a9f2badbe40acf5ad2d4ddad

COCOAPODS: 0.39.0

0 comments on commit d5a3d13

Please sign in to comment.