Skip to content

Commit

Permalink
BW-596 #comment add read me for command
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutec authored and ashutec committed Jul 8, 2019
1 parent 207f84d commit 911ad81
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 130 deletions.
53 changes: 27 additions & 26 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const firebaseProject = [ "trivia-dev",
"bitwiser-edu-staging",
"bitwiser-edu-production"
];
const schedularEnv = ['dev', 'prod'];

let argv;
let executableCmd = '';
Expand All @@ -34,7 +35,7 @@ const commandList = {
},
"environment" : {
"demand" : true,
"description": 'environment',
"description": 'project environment e.g. production',
"type": 'string',
"choices": env
}
Expand All @@ -46,7 +47,7 @@ const commandList = {
"options" : {
"projectName" : {
"demand" : true,
"description": 'configuration project name defined in angular.json e.g. trivia',
"description": 'project Name from .firebaserc e.g. trivia-staging',
"type": 'string',
"choices": firebaseProject
}
Expand All @@ -71,7 +72,7 @@ const commandList = {
}
}
},
"prod:deploy-functions":
"prod-deploy-functions":
{
"command" : "ng build trivia --configuration=configProject-production && ng build trivia-admin --configuration=configProject-production && ng build trivia-editor --configuration=configProject-production && ng run trivia:server && npx rimraf functions/server && tsc --project functions && npm install [email protected] && npx webpack --config webpack.server.config.js && npx cpx dist/index.html functions/dist && npx rimraf dist/index.html && npm run firebase -P projectName functions:config:set environment.production=true && npx rimraf functions/index.js && cp functions/app-functions.js functions/index.js && firebase deploy -P projectName --only functions && npx rimraf functions/index.js && cp functions/ssr-functions.js functions/index.js && firebase deploy -P projectName --only functions:ssr && firebase deploy -P projectName --only hosting && npm install [email protected]",
"description" : "deploy firebase functions to production",
Expand All @@ -92,10 +93,10 @@ const commandList = {
},
"dev-android":
{
"command" : "tns run android --bundle --env.package_name=packageName --env.project=projectName",
"description" : "run android app in dev environment",
"command" : "tns run android --bundle --env.package_name=packageName --env.project=configProject",
"description" : "run android app in staging environment",
"options" : {
"projectName" : {
"configProject" : {
"demand" : true,
"description": 'project Name e.g. trivia',
"type": 'string',
Expand All @@ -110,10 +111,10 @@ const commandList = {
}
},
"prod-android": {
"command" : "tns run android --bundle --env.prod --env.aot --env.uglify --env.package_name=packageName --env.project=projectName",
"command" : "tns run android --bundle --env.prod --env.aot --env.uglify --env.package_name=packageName --env.project=configProject",
"description" : "run android app in production environment",
"options" : {
"projectName" : {
"configProject" : {
"demand" : true,
"description": 'project Name e.g. trivia',
"type": 'string',
Expand All @@ -128,10 +129,10 @@ const commandList = {
}
},
"release-dev-android": {
"command" : "sh release/projectName/dev-android.sh",
"command" : "sh release/configProject/dev-android.sh",
"description" : "release android app for staging environment",
"options" : {
"projectName" : {
"configProject" : {
"demand" : true,
"description": 'project Name e.g. trivia',
"type": 'string',
Expand All @@ -140,10 +141,10 @@ const commandList = {
}
},
"release-prod-android": {
"command" : "sh release/projectName/prod-android.sh",
"command" : "sh release/configProject/prod-android.sh",
"description" : "release android app in production environment",
"options" : {
"projectName" : {
"configProject" : {
"demand" : true,
"description": 'project Name e.g. trivia',
"type": 'string',
Expand All @@ -152,10 +153,10 @@ const commandList = {
}
},
"dev-ios": {
"command" : "tns run ios --bundle --env.package_name=packageName --env.project=projectName",
"command" : "tns run ios --bundle --env.package_name=packageName --env.project=configProject",
"description" : "run ios app in staging environment",
"options" : {
"projectName" : {
"configProject" : {
"demand" : true,
"description": 'project Name e.g. trivia',
"type": 'string',
Expand All @@ -170,10 +171,10 @@ const commandList = {
}
},
"prod-ios": {
"command" : "tns run ios --bundle --env.prod --env.aot --env.uglify --for-device --env.package_name=packageName --env.project=projectName",
"command" : "tns run ios --bundle --env.prod --env.aot --env.uglify --for-device --env.package_name=packageName --env.project=configProject",
"description" : "run ios app in production environment",
"options" : {
"projectName" : {
"configProject" : {
"demand" : true,
"description": 'project Name e.g. trivia',
"type": 'string',
Expand All @@ -188,10 +189,10 @@ const commandList = {
}
},
"release-dev-ios": {
"command" : "rm -rf platforms/ios && tns prepare ios --bundle --release --env.aot --env.uglify --for-device --env.package_name=packageName --env.project=projectName",
"command" : "rm -rf platforms/ios && tns prepare ios --bundle --release --env.aot --env.uglify --for-device --env.package_name=packageName --env.project=configProject",
"description" : "release ios app in staging environment",
"options" : {
"projectName" : {
"configProject" : {
"demand" : true,
"description": 'project Name e.g. trivia',
"type": 'string',
Expand All @@ -206,10 +207,10 @@ const commandList = {
}
},
"release-prod-ios": {
"command" : "rm -rf platforms/ios && tns prepare ios --bundle --release --env.prod --env.aot --env.uglify --for-device --env.package_name=packageName --env.project=projectName",
"command" : "rm -rf platforms/ios && tns prepare ios --bundle --release --env.prod --env.aot --env.uglify --for-device --env.package_name=packageName --env.project=configProject",
"description" : "release ios app in production environment",
"options" : {
"projectName" : {
"configProject" : {
"demand" : true,
"description": 'project Name e.g. trivia',
"type": 'string',
Expand All @@ -224,14 +225,14 @@ const commandList = {
}
},
"run-schedular": {
"command" : "npx rimraf functions/server & tsc --project scheduler && node scheduler/server/run-scheduler.js environment",
"command" : "npx rimraf scheduler/server & tsc --project scheduler && node scheduler/server/run-scheduler.js schedularEnv",
"description" : "run schedular for given environment",
"options" : {
"environment" : {
"schedularEnv" : {
"demand" : true,
"description": 'environment',
"description": 'schedular environment dev/prod',
"type": 'string',
"choices": env
"choices": schedularEnv
}
}
}
Expand Down Expand Up @@ -266,8 +267,8 @@ function escapeRegExp(string){

function executeCommand(){
try {
// console.log(executableCmd, 'executableCmd');
execSync(executableCmd, {stdio: 'inherit'});
// console.log(executableCmd, 'executableCmd');
execSync(executableCmd, {stdio: 'inherit'});
} catch(error) {
// console.error(error);
}
Expand Down
110 changes: 110 additions & 0 deletions commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
Goal : To reduce redunduncy and unneccessary complexity in commands while we setup new project we have made
script to run the commands with node, this script will be also useful when we want to run a script
before any command.

1) add command "cli": "node cli.js" to run the script

2) to pass the arguments to script we need to prepand "--" to the arguments.
e.g. npm run cli serve -- --projectName=trivia --configProject=trivia --environment=dev

3) to add new command
add command in cli.js
in given format
"command-name" : {
"type" : string
"command" : {
"type" : string
"description" : "add command to be run and use arguments name in command string to replace with command line arguments"
}
"description" : {
"type" : string
}
"options" : {
"type" : Object
"description" : "use to get argument from command line and will be replaced in 'command' string
use demand: true for required argument
use type: for type of argument required from command line
use choices: array of valid argument values"
}
}

Commands :

1) command: start
description: this command is used to start web application (trivia, trivia-admin, trivia-editor)
e.g. : npm run cli start -- --projectName trivia-admin --configProject bitwiser-edu --environment production
arguments : projectName = the project to be run e.g. trivia-admin
configProject and enviroment = configuration project name defined in angular.json e.g. bitwiser-edu-dev
where bitwiser-edu is configProject and dev is environment

2) command: deploy-functions-local
e.g. : npm run cli deploy-functions-local -- --projectName trivia-staging
description: this command is used to start firebase functions in local
arguments : projectName = project Name from .firebaserc e.g. trivia-staging


3) command: deploy-functions
e.g. : npm run cli deploy-functions -- --projectName trivia-staging --configProject trivia
description: deploy firebase functions to staging env
arguments : projectName = project Name from .firebaserc e.g. trivia-staging
configProject = configuration project name defined in angular.json e.g. trivia

4) command: prod-deploy-functions
e.g. : npm run cli prod-deploy-functions -- --projectName trivia-staging --configProject trivia
description: deploy firebase functions to production env
arguments : projectName = project Name from .firebaserc e.g. trivia-staging
configProject = configuration project name defined in angular.json e.g. trivia

5) command: dev-android
description: run android app in staging environment
e.g. : npm run cli dev-android -- --configProject trivia --packageName io.bitwiser.trivia.dev
arguments : configProject = project Name e.g. trivia
packageName = project package name defined in firebase e.g. io.bitwiser.trivia.dev

6) command: prod-android
e.g. : npm run cli prod-android -- --configProject trivia --packageName io.bitwiser.trivia
description: run android app in production environment
arguments : configProject = project Name e.g. trivia
packageName = project package name defined in firebase e.g. io.bitwiser.trivia

7) command: release-dev-android
e.g. : npm run cli release-dev-android -- --configProject trivia
description: release android app for staging environment
arguments : configProject = project Name e.g. trivia

8) command: release-prod-android
e.g. : npm run cli release-prod-android -- --configProject trivia
description: release android app in production environment
arguments : configProject = project Name e.g. trivia

9) command: dev-ios
e.g. : npm run cli dev-ios -- --configProject trivia --packageName io.bitwiser.trivia.dev
description: run ios app in staging environment
arguments : configProject = project Name e.g. trivia
packageName = project package name defined in firebase e.g. io.bitwiser.trivia.dev

10) command: prod-ios
e.g. : npm run cli prod-ios -- --configProject trivia --packageName io.bitwiser.trivia
description: run ios app in production environment
arguments : configProject = project Name e.g. trivia
packageName = project package name defined in firebase e.g. io.bitwiser.trivia


11) command: release-dev-ios
e.g. : npm run cli release-dev-ios -- --configProject trivia --packageName io.bitwiser.trivia.dev
description: release ios app in staging environment
arguments : configProject = project Name e.g. trivia
packageName = project package name defined in firebase e.g. io.bitwiser.trivia.dev


12) command: release-prod-ios
e.g. : npm run cli release-prod-ios -- --configProject trivia --packageName io.bitwiser.trivia
description: release ios app in production environment
arguments : configProject = project Name e.g. trivia
packageName = project package name defined in firebase e.g. io.bitwiser.trivia

13) command: run-schedular
e.g. : npm run cli run-schedular -- --schedularEnv prod
description: run schedular for given environment
arguments : schedularEnv = schedular environment dev/prod

Loading

0 comments on commit 911ad81

Please sign in to comment.