Skip to content
This repository has been archived by the owner on Feb 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #119 from UnleashedMind/master
Browse files Browse the repository at this point in the history
misc.
  • Loading branch information
UnleashedMind authored Apr 30, 2018
2 parents 6a42a45 + 0ff6e59 commit d8ecce1
Show file tree
Hide file tree
Showing 20 changed files with 6,618 additions and 1,320 deletions.
6 changes: 3 additions & 3 deletions __tests__/lib/utils/starter-config-mapping.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ describe('feature-yaml-template-mapping', () => {
test('feature-yaml-template-mapping defined', () => {
expect(starterConfigMapping['react']).toBeDefined()
expect(starterConfigMapping['react-native']).toBeDefined()
expect(starterConfigMapping['angular']).toBeDefined()
expect(starterConfigMapping['ionic']).toBeDefined()
expect(starterConfigMapping['vue']).toBeDefined()
// expect(starterConfigMapping['angular']).toBeDefined()
// expect(starterConfigMapping['ionic']).toBeDefined()
// expect(starterConfigMapping['vue']).toBeDefined()
})
})
1 change: 0 additions & 1 deletion bin/awsmobile-features
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"use strict";
const program = require('commander')
const inquirer = require('inquirer')
const _ = require('lodash')
const chalk = require('chalk')

const projectInfoManager = require('../lib/project-info-manager.js')
Expand Down
5 changes: 2 additions & 3 deletions bin/feature-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
const fs = require('fs-extra')
const program = require('commander')
const chalk = require('chalk')
const _ = require('lodash')

const projectInfoManager = require('../lib/project-info-manager.js')
const pathManager = require('../lib/utils/awsmobilejs-path-manager.js')
Expand Down Expand Up @@ -123,10 +122,10 @@ function displayGeneralHelp(){
console.log()
console.log(' Commands:' )
console.log()
_.keys(_commonCommands).forEach(function(command) {
Object.keys(_commonCommands).forEach(function(command) {
console.log(' ' + (command + ' ').slice(0,12) + _commonCommands[command].replace('{featureName}', _featureName))
}, this)
_.keys(_featureOps.featureCommands).forEach(function(command) {
Object.keys(_featureOps.featureCommands).forEach(function(command) {
console.log(' ' + (command + ' ').slice(0,12) + _featureOps.featureCommands[command])
}, this)
}
Expand Down
4 changes: 2 additions & 2 deletions lib/aws-operations/mobile-exportjs-file-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ function updateCurrentAWSExportFiles(sourceFilePath){
let awsExportFilePath = pathManager.getAWSExportFilePath(_projectInfo.ProjectPath)
if(awsExportFilePath){
fs.copySync(sourceFilePath, awsExportFilePath)
console.log('awsmobile project\'s access information logged at: ' +
chalk.blue(pathManager.getAWSExportFilePath_relative(_projectInfo.ProjectPath) ))
console.log('awsmobile project\'s access information logged at: ')
console.log(' ' + chalk.blue(pathManager.getAWSExportFilePath_relative(_projectInfo.ProjectPath) ))
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/aws-operations/mobile-project-export-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ function downloadCurrentBackendProjectSpec(downloadUrl, projectInfo, callback) {
if(ymlFilePath){
let destinationPath = pathManager.getCurrentBackendYamlFilePath(projectInfo.ProjectPath)
fs.copySync(ymlFilePath, destinationPath)
console.log('awsmobile project\'s specifications logged at: ' +
chalk.blue(pathManager.getCurrentBackendYamlFilePath_Relative(projectInfo.ProjectPath)))
console.log('awsmobile project\'s specifications logged at:')
console.log(' ' + chalk.blue(pathManager.getCurrentBackendYamlFilePath_Relative(projectInfo.ProjectPath)))
fs.removeSync(tempExtractDirPath)
fs.removeSync(tempZipFilePath)
if(callback){
Expand Down
5 changes: 2 additions & 3 deletions lib/aws-operations/mobile-yaml-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
"use strict";
const jsyaml = require('js-yaml')
const _= require('lodash')

const typeProperty = 'backend-class'

Expand Down Expand Up @@ -520,7 +519,7 @@ function dressObject(obj){
}

function recursiveDressObject(obj){
_.keys(obj).forEach(function(key){
Object.keys(obj).forEach(function(key){
let propertyType = typeof obj[key]
if(typeof obj[key] === 'object'){
obj[key] = recursiveDressObject(obj[key])
Expand All @@ -537,7 +536,7 @@ function trimObject(obj){
}

function recursiveTrimObject(obj){
_.keys(obj).forEach(function(key){
Object.keys(obj).forEach(function(key){
if(typeof obj[key] === 'object'){
obj[key] = recursiveTrimObject(obj[key])
}
Expand Down
1 change: 0 additions & 1 deletion lib/awsm-base-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
const fs = require('fs-extra')
const path = require('path')
const moment = require('moment')
const _ = require('lodash')

const pathManager = require('./utils/awsmobilejs-path-manager.js')
const awsmobilejsConstant = require('./utils/awsmobilejs-constant.js')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const path = require('path')
const chalk = require('chalk')
const moment = require('moment')
const util = require('util')
const _ = require('lodash')

const _featureName = 'appsync'

Expand Down
8 changes: 4 additions & 4 deletions lib/backend-operations/backend-info-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ function updateAWSExportFile(projectInfo, awsDetails, callback){
if(srcDir && fs.existsSync(srcDir)){
let srcDirExportFilePath = pathManager.getSrcDirExportFilePath(projectInfo)
fs.copySync(awsExportFilePath, srcDirExportFilePath)
console.log('awsmobile project\'s access information copied to: ' +
chalk.blue(pathManager.getSrcDirExportFilePath_relative(projectInfo)))
console.log('awsmobile project\'s access information copied to: ')
console.log(' ' + chalk.blue(pathManager.getSrcDirExportFilePath_relative(projectInfo)))
}
if(callback){
callback()
Expand Down Expand Up @@ -121,8 +121,8 @@ function setBackendDetails(projectPath, backendDetails, silentFlag) {
let jsonString = JSON.stringify(backendDetails, null, '\t')
fs.writeFileSync(backendDetailsFilePath, jsonString, 'utf8')
if(!silentFlag){
console.log('awsmobile project\'s details logged at: ' +
chalk.blue(pathManager.getCurrentBackendDetailsFilePath_Relative(projectPath)))
console.log('awsmobile project\'s details logged at:')
console.log(' ' + chalk.blue(pathManager.getCurrentBackendDetailsFilePath_Relative(projectPath)))
}
}catch(e){
console.log(chalk.red('failed to write backend details'))
Expand Down
3 changes: 1 addition & 2 deletions lib/backend-operations/backend-spec-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
"use strict";
const fs = require('fs-extra')
const _ = require('lodash')
const chalk = require('chalk')
const inquirer = require('inquirer')

Expand Down Expand Up @@ -70,7 +69,7 @@ function getEnabledFeaturesFromObject(backendProject){
if(backendProject){
result = []
if(backendProject.features){
let ymlFeatures = _.keys(backendProject.features)
let ymlFeatures = Object.keys(backendProject.features)
if(ymlFeatures && ymlFeatures.length > 0){
ymlFeatures.forEach(function(ymlFeatureName) {
let featureName = getFeatureName(ymlFeatureName)
Expand Down
15 changes: 7 additions & 8 deletions lib/backend-operations/cloud-api-lambda-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const path = require('path')
const chalk = require('chalk')
const archiver = require('archiver')
const moment = require('moment')
const _ = require('lodash')

const backendSpecManager = require('./backend-spec-manager.js')
const dfops = require('../utils/directory-file-ops.js')
Expand Down Expand Up @@ -66,8 +65,8 @@ function validateCodebase(){
getLambdaFunDirs()
getExistingZipFiles()

let paths = _.keys(_cloudApiPaths)
let srcDirs = _.keys(_lambdaFuncSrcDirs)
let paths = Object.keys(_cloudApiPaths)
let srcDirs = Object.keys(_lambdaFuncSrcDirs)

for(let i = 0; i<paths.length; i++){
let lambdaFunc = _cloudApiPaths[paths[i]]
Expand All @@ -88,12 +87,12 @@ function getCloudApiPaths(){
_cloudApiPaths = {}
_lambdaFuncNames = []
let components = _backendProject.features.cloudlogic.components
let apiNames = _.keys(components)
let apiNames = Object.keys(components)

for(let i = 0; i<apiNames.length; i++){
let api = components[apiNames[i]]
if(api.paths){
let pathNames = _.keys(api.paths)
let pathNames = Object.keys(api.paths)
for(let j = 0; j < pathNames.length; j++){
let key = api.attributes.name + pathNames[j]
let lambdaFunc = api.paths[pathNames[j]]
Expand Down Expand Up @@ -146,7 +145,7 @@ function getExistingZipFiles(){
function buildLambdaFunctions(callback){
let isNewBuildExecuted = false
let zipFileNameSuffix = '-' + moment().format(awsmobilejsConstant.DateTimeFormatStringCompact)
let srcFuncNames = _.keys(_lambdaFuncSrcDirs)
let srcFuncNames = Object.keys(_lambdaFuncSrcDirs)
if(srcFuncNames.length > 0){
let count = 0
for(let i = 0; i<srcFuncNames.length; i++){
Expand Down Expand Up @@ -201,12 +200,12 @@ function buildLambdaFunctions(callback){

function updateLambdaFuncCodeName(){
let codeFileNameUpdated = false
let lambdaWithZipFiles = _.keys(_lambdaFuncZipFiles)
let lambdaWithZipFiles = Object.keys(_lambdaFuncZipFiles)
for(let i = 0; i<lambdaWithZipFiles.length; i++){
let lambdaFuncName = lambdaWithZipFiles[i]
let zipFileName = path.basename(_lambdaFuncZipFiles[lambdaFuncName])

let apiPaths = _.keys(_cloudApiPaths)
let apiPaths = Object.keys(_cloudApiPaths)
for(let i = 0; i<apiPaths.length; i++){
let lambdaFunc = _cloudApiPaths[apiPaths[i]]
let codeFileName = 'uploads/' + zipFileName
Expand Down
1 change: 0 additions & 1 deletion lib/build-backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
* and limitations under the License.
*/
"use strict";
const _ = require('lodash')
const chalk = require('chalk')
const moment = require('moment')
const fs = require('fs-extra')
Expand Down
5 changes: 2 additions & 3 deletions lib/build-frontend.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const fs = require('fs-extra')
const ora = require('ora')
const moment = require('moment')
const chalk = require('chalk')
const _ = require('lodash')

const { spawn } = require('child_process')

Expand Down Expand Up @@ -109,8 +108,8 @@ function isNpmInstallNeeded(){
let packageInfo = JSON.parse(fs.readFileSync(packageJsonFilePath, 'utf8'))
if(packageInfo){

let hasDependency = (packageInfo.dependencies && ! _.isEmpty(packageInfo.dependencies)) ||
(packageInfo.devDependencies && !_.isEmpty(packageInfo.devDependencies))
let hasDependency = (packageInfo.dependencies && Object.keys(packageInfo.dependencies).length>0) ||
(packageInfo.devDependencies && Object.keys(packageInfo.devDependencies).length>0)
if(hasDependency){
if(!fs.existsSync(npm_modules_DirPath)){
result = true
Expand Down
7 changes: 3 additions & 4 deletions lib/project-info-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const chalk = require('chalk')
const fs = require('fs-extra')
const moment = require('moment')
const util = require('util')
const _ = require('lodash')

const projectValidator = require('./project-validator.js')
const projectConfigManager = require('./project-config-manager.js')
Expand Down Expand Up @@ -140,11 +139,11 @@ function trimProjectInfo(projectInfo){

function updateBackendProjectDetails(projectInfo, backendProjectDetails){
if(backendProjectDetails && backendProjectDetails.projectId && backendProjectDetails.projectId.length > 0){
_.keys(backendPropertyMappings).forEach(function(propertyName){
Object.keys(backendPropertyMappings).forEach(function(propertyName){
projectInfo[propertyName] = backendProjectDetails[backendPropertyMappings[propertyName]]
})
}else{
_.keys(backendPropertyMappings).forEach(function(propertyName){
Object.keys(backendPropertyMappings).forEach(function(propertyName){
projectInfo[propertyName] = ''
})
}
Expand All @@ -153,7 +152,7 @@ function updateBackendProjectDetails(projectInfo, backendProjectDetails){
}

function onClearBackend(projectInfo){
_.keys(backendPropertyMappings).forEach(function(propertyName){
Object.keys(backendPropertyMappings).forEach(function(propertyName){
projectInfo[propertyName] = ''
})
setProjectInfo(projectInfo)
Expand Down
19 changes: 8 additions & 11 deletions lib/utils/dependency-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ function setupAmplifyDependency(initInfo){
})
break
case 'angular':
result = yarnAddAmplify(projectPath)
.then(yarnAddAmplifyAngular)
case 'ionic':
result = npmInstallAmplify(projectPath)
.then(npmInstallAmplifyAngular)
.then((cwd)=>{
return initInfo
})
Expand All @@ -99,6 +100,10 @@ function npmInstallAmplify(cwd){
return spawnChildProcess(npm, ['install', 'aws-amplify'], cwd)
}

function npmInstallAmplifyAngular(cwd){
return spawnChildProcess(npm, ['install', 'aws-amplify-angular'], cwd)
}

function yarnAddAmplify(cwd){
if(isYarnInstalled()){
return spawnChildProcess(yarn, ['add', 'aws-amplify'], cwd)
Expand All @@ -123,18 +128,10 @@ function yarnAddAmplifyReactNative(cwd){
}
}

function yarnAddAmplifyAngular(cwd){
if(isYarnInstalled()){
return spawnChildProcess(yarn, ['add', 'aws-amplify-angular'], cwd)
}else{
return spawnChildProcess(npm, ['install', 'aws-amplify-angular'], cwd)
}
}

function isYarnInstalled(){
var isYarnInstalled
try {
execSync('yarn -h')
execSync('yarn --version', {stdio: 'ignore'})
isYarnInstalled = true
} catch (err) {
isYarnInstalled = false
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/git-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function getGitIgnoreAppendString(){
'appsync-info.json' + os.EOL +
'aws-info.json' + os.EOL +
'project-info.json' + os.EOL +
'aws-exports.js' + os.EOL +
'aws-exports.*' + os.EOL +
'awsmobilejs/.awsmobile/backend-build' + os.EOL +
'awsmobilejs/\\#current-backend-info' + os.EOL +
'~awsmobilejs-*/'
Expand Down
6 changes: 3 additions & 3 deletions lib/utils/starter-config-mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const vueConfig = frameworkConfigMappings['vue']
module.exports = {
'react': reactConfig,
'react-native': reactNativeConfig,
'angular': angularConfig,
'ionic': ionicConfig,
'vue': vueConfig
// 'angular': angularConfig,
// 'ionic': ionicConfig,
// 'vue': vueConfig
}
Loading

0 comments on commit d8ecce1

Please sign in to comment.