Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(buildStatus): use sessionSecret instead of token #4

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,21 @@ const mapProjectDirToExpoInfo = async (dir) => {
};

const logDeprecatedCommand = (cmd, replacementCmd) => {
console.log('');
console.log(chalk.red(`"${chalk.bold(`exptool ${cmd}`)}" is deprecated.`));
if (replacementCmd) {
console.log(chalk.red(`Try using ${chalk.bold(replacementCmd)} instead.`));
}
console.log(`See ${chalk.underline('https://github.com/mglagola/exptool/wiki/Deprecations')} for more info on deprecations.`);
console.log('');
// console.log('');
// console.log(chalk.red(`"${chalk.bold(`exptool ${cmd}`)}" is deprecated.`));
// if (replacementCmd) {
// console.log(chalk.red(`Try using ${chalk.bold(replacementCmd)} instead.`));
// }
// console.log(`See ${chalk.underline('https://github.com/mglagola/exptool/wiki/Deprecations')} for more info on deprecations.`);
// console.log('');
};

program
.command('url:expo [project-dir]')
.description('Prints the expo url for a given project and [optional] release channel')
.option('-r, --release-channel [channel]', 'Specify release channel (staging, production, etc)')
.action(act(async (dir, { releaseChannel }) => {
const { expoState, projectManifest } = await mapProjectDirToExpoInfo(dir);
const { expoState, projectManifest } = await mapProjectDirToExpoInfo(dir);
const job = F.head(await fetchArtifactJobs(projectManifest, expoState));
const url = `https://expo.io/${job.fullExperienceName}${F.isNil(releaseChannel) ? '' : `?release-channel=${releaseChannel}`}`;
console.log(url);
Expand All @@ -83,7 +83,7 @@ program
console.log(chalk.red(message));
return false;
}
console.log(packageName);
console.log(packageName);
return true;
}, true));

Expand Down Expand Up @@ -125,20 +125,20 @@ program
program
.command('wait:build [project-dir]')
.description('[Deprecated] Wait for active build to complete')
.option('-i, --interval [sleep-interval-seconds]', 'Sleep interval between checks')
.option('-i, --interval [sleep-interval-seconds]', 'Sleep interval between checks')
.option('-t, --timeout [timeout-seconds]', 'Max amount of seconds to wait before timing out')
.action(act(async (dir, options) => {
logDeprecatedCommand('wait:build', 'exp build:{ios|android}');
const { expoState, projectManifest } = await mapProjectDirToExpoInfo(dir);
const { expoState, projectManifest } = await mapProjectDirToExpoInfo(dir);
return await checkIfBuilt(projectManifest, expoState, options);
}));

program
.command('download:artifact [project-dir]')
.description('[Deprecated] Downloads the most recent artifact for a given project')
.description('[Deprecated] Downloads the most recent artifact for a given project')
.option('-t, --to-dir [dir]', 'Specify dir to download artifact to. Default is current directory')
.action(act(async (dir, { toDir }) => {
const { expoState, projectManifest } = await mapProjectDirToExpoInfo(dir);
const { expoState, projectManifest } = await mapProjectDirToExpoInfo(dir);
const artifacts = await fetchArtifactJobs(projectManifest, expoState);
const downloadToDir = toDir || process.cwd();
await Promise.all(artifacts.map(job => downloadArtifact(resolveHome(downloadToDir), job)));
Expand All @@ -147,9 +147,9 @@ program

program
.command('url:artifact [project-dir]')
.description('[Deprecated] Prints the latest url artifact for a given project')
.description('[Deprecated] Prints the latest url artifact for a given project')
.action(act(async (dir, options) => {
const { expoState, projectManifest } = await mapProjectDirToExpoInfo(dir);
const { expoState, projectManifest } = await mapProjectDirToExpoInfo(dir);
const job = F.head(await fetchArtifactJobs(projectManifest, expoState));
console.log(job.artifacts.url);
return true;
Expand Down
12 changes: 7 additions & 5 deletions lib/expo.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ async function buildStatus (projectManifest, expState = {}) {
const res = await rp({
url: 'https://exp.host/--/api/build/[]',
headers: {
'Exp-ClientId': accessToken,
'Authorization': `Bearer ${auth.idToken}`,
'Exp-Access-Token': auth.accessToken,
'Expo-Session': auth.sessionSecret,
'Exp-Access-Token': accessToken,
'Content-Type': 'application/json',
},
method: 'put',
Expand Down Expand Up @@ -101,9 +100,12 @@ async function checkIfBuilt (projectManifest, expState, { timeout = ARTIFACT_BUI
case 'in-progress':
console.log(`Artifact still building, checking again in ${interval}s ...`);
break;
case 'pending':
console.log(`Artifact building is pending, checking again in ${interval}s ...`);
break;
default:
console.log(chalk.red(`Unknown status: ${jobStatus} - aborting!`));
return false;
console.log(chalk.red(`Unknown status: ${jobStatus}, checking again in ${interval}s ...`));
break;
}
startTime = new Date().getTime();
await sleep(secondsToMilliseconds(interval));
Expand Down