Comparing version 1.0.3 to 1.0.4
@@ -11,2 +11,3 @@ /** | ||
var runSequence = require('run-sequence'); | ||
var env = require('./env'); | ||
@@ -21,11 +22,9 @@ function getPlatformPaths(srcpath) { | ||
_.each(platforms, function (platformName) { | ||
platforms.forEach(function (platformName) { | ||
var platformPath = __dirname + '/platforms/' + platformName; | ||
fs.readdirSync(platformPath).forEach(function (task) { | ||
if (task === 'gulpfile.js'){ | ||
console.log('path:', path.join(platformPath, task)); | ||
require(path.join(platformPath, task)); | ||
} | ||
}); | ||
}); | ||
@@ -40,14 +39,9 @@ | ||
gulp.task('build-clean', function() { | ||
return del(['./build']); | ||
return del([env.buildPath + '/*']); | ||
}); | ||
gulp.task('copy-app-config', function() { | ||
var appConfigPath = './example/app_definition.json'; | ||
return gulp.src(appConfigPath) | ||
.pipe(rename('app_config.json')) | ||
.pipe(gulp.dest('./build')) | ||
gulp.task('build', function(cb) { | ||
runSequence('build-clean', 'platform:android', cb); | ||
}); | ||
gulp.task('build', function(cb) { | ||
runSequence('build-clean', 'copy-app-config', 'platform:android', cb); | ||
}); | ||
module.exports = gulp; |
/** | ||
* Created by anthony on 13/09/2016. | ||
*/ | ||
var _ = require('lodash'); | ||
var env = require('../env'); | ||
var Promise = require('bluebird'); | ||
var fs = require('fs'); | ||
var readFile = Promise.promisify(fs.readFile); | ||
var app = null; | ||
function getAppConfig() { | ||
var contents = fs.readFileSync('./build/app_config.json', 'utf8'); | ||
var contents = fs.readFileSync(env.appDefinitionPath, 'utf8'); | ||
return JSON.parse(contents); | ||
@@ -15,2 +17,10 @@ } | ||
exports.getAppConfig = getAppConfig; | ||
exports.app = getAppConfig(); | ||
Object.defineProperty(exports, 'app', { | ||
get: function () { | ||
if (app === null) { | ||
app = getAppConfig(); | ||
} | ||
return app; | ||
} | ||
}); |
{ | ||
"name": "jennifer", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "cross platform application generator", | ||
@@ -31,2 +31,3 @@ "main": "index.js", | ||
"bluebird": "^3.4.6", | ||
"chalk": "^1.1.3", | ||
"gulp": "^3.9.1", | ||
@@ -33,0 +34,0 @@ "lodash": "^4.15.0", |
@@ -6,3 +6,3 @@ /** | ||
var tap = require('gulp-tap'); | ||
var app; | ||
var jnLib = require('../../lib'); | ||
var path = require('path'); | ||
@@ -13,4 +13,6 @@ var _ = require('lodash'); | ||
var merge = require('merge-stream'); | ||
var appName; | ||
var appBuildPath; | ||
var env = require('../../env'); | ||
var templatesPath = path.join(__dirname, './templates'); | ||
var platformName = 'android'; | ||
var chalk = require('chalk'); | ||
@@ -34,12 +36,10 @@ function template(options) { | ||
gulp.task('android:copy-project', function () { | ||
app = require('../../lib').app; | ||
appName = _.snakeCase(app.name); | ||
appBuildPath = './build/' + appName; | ||
return gulp.src('./templates/project/**/*', {cwd: 'platforms/android'}) | ||
.pipe(gulp.dest(appBuildPath)); | ||
var appName = _.snakeCase(jnLib.app.name); | ||
return gulp.src(templatesPath + '/project/**/*') | ||
.pipe(gulp.dest(path.join(env.buildPath, platformName, appName))); | ||
}); | ||
gulp.task('android:create-activities', ['android:copy-project'], function () { | ||
var appName = _.snakeCase(jnLib.app.name); | ||
var app = jnLib.app; | ||
var destPath = path.join('app/src/main/java', _.chain(app.package_id).split('.').join('/').value()); | ||
@@ -56,6 +56,6 @@ var opts = { | ||
var className = _.startCase(pageName).replace(/\s/g, ''); | ||
var pipe = gulp.src('./templates/activity.txt', {cwd: 'platforms/android'}) | ||
var pipe = gulp.src(path.join(templatesPath, './activity.txt')) | ||
.pipe(rename(className + '.java')) | ||
.pipe(template(_.extend({activity_name: className, page_name:pageName}, opts))) | ||
.pipe(gulp.dest(path.join(appBuildPath, destPath))); | ||
.pipe(gulp.dest(path.join(env.buildPath, platformName, appName, destPath))); | ||
@@ -71,2 +71,4 @@ streams.push(pipe); | ||
var activities = []; | ||
var app = jnLib.app; | ||
var appName = _.snakeCase(jnLib.app.name); | ||
var allPages = _.without(_.keys(app.screens.default), 'main'); | ||
@@ -78,3 +80,3 @@ _.each(allPages, function (pageName) { | ||
var env = { | ||
var appEnv = { | ||
package_id: app.package_id, | ||
@@ -84,3 +86,4 @@ runtime_library: 'de.fluidco.jnandroidruntime:jn-android-runtime:0.1.2', | ||
app_definition_json: JSON.stringify(app, null, '\t'), | ||
activities: activities | ||
activities: activities, | ||
sdk_dir: path.join(process.env.HOME, '/Library/Android/sdk') | ||
}; | ||
@@ -91,6 +94,7 @@ var resDir = 'app/src/main/res/'; | ||
'app/src/main/AndroidManifest.xml', | ||
'app/build.gradle']; | ||
'app/build.gradle', | ||
'local.properties']; | ||
return gulp.src(filesNames, {cwd: appBuildPath}) | ||
.pipe(template(env)) | ||
return gulp.src(filesNames, {cwd: path.join(env.buildPath, platformName, appName)}) | ||
.pipe(template(appEnv)) | ||
.pipe(gulp.dest(function (file) { | ||
@@ -102,4 +106,10 @@ return file.base; | ||
gulp.task('platform:android', ['android:expand-project-templates'], function () { | ||
console.log('app name:', appName); | ||
var projectPath = path.join(env.buildPath, platformName, _.snakeCase(jnLib.app.name)); | ||
console.log(chalk.green('Android project created at', projectPath)); | ||
if (require('yargs').alias('o', 'open').argv.o) { | ||
console.log(chalk.green('Launching project...')); | ||
require('child_process').spawn('open', ['-a', 'Android Studio', projectPath], {detached: true}); | ||
} | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
106756
33
304
5
8
1
+ Addedchalk@^1.1.3