@embrace-io/react-native
Version:
A React Native wrapper for the Embrace SDK
85 lines (84 loc) • 3.38 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.packageJSON = exports.iosProjectFolderName = exports.apiToken = exports.androidAppID = exports.iosAppID = exports.Platform = void 0;
const asker_1 = require("../util/asker");
var Platform;
(function (Platform) {
Platform["Android"] = "Android";
Platform["IOS"] = "iOS";
})(Platform || (exports.Platform = Platform = {}));
const appIDQuestion = (platform) => ({
name: `emb${platform}AppID`,
message: `What is your ${platform} Embrace App ID? (5-character value)`,
});
const apiTokenQuestion = () => ({
name: "embAPIToken",
message: "What is your Embrace API token? (32-digit hex number)",
});
const iosFolderNameQuestion = () => ({
name: "iosFolderName",
message: "What is the name of the iOS project? Leave it empty if the project's name is the same as the name declared in 'package.json'",
});
const asker = new asker_1.default();
const iosAppID = {
name: "iOS App ID",
fetch: () => __awaiter(void 0, void 0, void 0, function* () {
const question = appIDQuestion(Platform.IOS);
return asker
.ask(question)
.then((answers) => answers[question.name]);
}),
};
exports.iosAppID = iosAppID;
const androidAppID = {
name: "Android App ID",
fetch: () => __awaiter(void 0, void 0, void 0, function* () {
const question = appIDQuestion(Platform.Android);
return asker
.ask(question)
.then((answers) => answers[question.name]);
}),
};
exports.androidAppID = androidAppID;
const apiToken = {
name: "API Token",
fetch: () => __awaiter(void 0, void 0, void 0, function* () {
const question = apiTokenQuestion();
return asker
.ask(question)
.then((answers) => answers[question.name]);
}),
};
exports.apiToken = apiToken;
const iosProjectFolderName = {
name: "iOS directory Name",
fetch: () => __awaiter(void 0, void 0, void 0, function* () {
const folderName = iosFolderNameQuestion();
return asker
.ask(folderName)
.then((answers) => answers[folderName.name]);
}),
};
exports.iosProjectFolderName = iosProjectFolderName;
const packageJSON = {
name: "App Name",
fetch: () => {
try {
const packageJson = require("../../../../../../package.json");
return Promise.resolve(packageJson);
}
catch (_a) {
return Promise.reject("Could not find package.json file. Try running this script from the root of the repo, where package.json is placed in a regular React Native app.");
}
},
};
exports.packageJSON = packageJSON;