-
-
Save zhigang1992/6e28de154cd8104ef08b9264d4364ee4 to your computer and use it in GitHub Desktop.
swiping firebase env and application env
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!./node_modules/.bin/ts-node | |
import chalk from "chalk"; | |
import * as meow from "meow"; | |
import * as fs from "fs"; | |
import * as ora from "ora"; | |
import * as path from "path"; | |
import { run } from "./utils/run"; | |
(async () => { | |
const cli = meow( | |
` | |
Usage: | |
./use.ts [dev|staging|prod] | |
` | |
); | |
const env: string | undefined = cli.input[0]; | |
if (!env) { | |
try { | |
const currentEnv = fs | |
.readFileSync(path.resolve(__dirname, "./.current_project"), "utf-8") | |
.trim(); | |
console.log(`Current project: ${chalk.bold(currentEnv)}`); | |
} catch { | |
cli.showHelp(); | |
} | |
} else { | |
const spinner = ora(`Set env to: ${chalk.bold(env)}\n`).start(); | |
try { | |
await run(`../node_modules/.bin/firebase use ${env}`); | |
await run( | |
`ln -f ./configs/${env}/GoogleService-Info.plist ../app/ios/GoogleService-Info.plist` | |
); | |
await run( | |
`ln -f ./configs/${env}/google-services.json ../app/android/app/google-services.json` | |
); | |
await run( | |
`ln -f ./configs/${env}/Info.plist ../app/ios/mercy/Info.plist` | |
); | |
await run( | |
`echo ${env} > ${path.resolve(__dirname, "./.current_project")}` | |
); | |
spinner.succeed(`Successfully set project to: ${chalk.bold(env)}`); | |
} catch { | |
spinner.fail(`Failed set project to: ${chalk.bold(env)}`); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@iamqinglong https://github.com/tappollo/booster/blob/master/scripts/utils/run.ts
Where did you find this gist?