Skip to content

Instantly share code, notes, and snippets.

@zhigang1992
Last active January 12, 2021 20:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zhigang1992/6e28de154cd8104ef08b9264d4364ee4 to your computer and use it in GitHub Desktop.
Save zhigang1992/6e28de154cd8104ef08b9264d4364ee4 to your computer and use it in GitHub Desktop.
swiping firebase env and application env
#!./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)}`);
}
}
})();
@iamqinglong
Copy link

hello @zhigang1992,

Can I have the import { run } from "./utils/run"; ?

@zhigang1992
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment