Skip to content

Instantly share code, notes, and snippets.

@zhigang1992

zhigang1992/use.ts Secret

Last active Jul 30, 2020
Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@iamqinglong iamqinglong commented Jul 29, 2020

hello @zhigang1992,

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

@zhigang1992

This comment has been minimized.

Copy link
Owner Author

@zhigang1992 zhigang1992 commented Jul 30, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.