All files / src/platformTools/apple fastlane.js

27.5% Statements 11/40
0% Branches 0/18
0% Functions 0/4
24.24% Lines 8/33

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 802x 2x 2x             2x 2x 2x   2x                                                                                                                                 2x  
import path from 'path';
import chalk from 'chalk';
import {
    logTask,
    logWarning,
    logSuccess,
    getConfigProp,
    getAppId
} from '../../common';
import { executeAsync } from '../../systemTools/exec';
import { IOS, TVOS } from '../../constants';
import { setAppConfig } from '../../configTools/configParser';
 
export const updateProfile = (c, appConfigId) => new Promise((resolve, reject) => {
    logTask(`updateProfile:${appConfigId}`, chalk.grey);
 
    // TODO: run trough all schemes
    // const schemes = c.buildConfig.platforms?.[c.platform]?.buildSchemes
    // const currScheme = c.program.scheme
    // for(k in schemes) {
    //   c.program.scheme = k
    // }
 
    if (appConfigId) setAppConfig(c, appConfigId);
 
    if (c.platform !== IOS && c.platform !== TVOS) {
        reject(`updateProfile:platform ${c.platform} not supported`);
        return;
    }
    const { scheme } = c.program;
 
 
    const { platform } = c;
 
    const { appId } = c.runtime;
 
    const id = getAppId(c, platform);
    const teamID = getConfigProp(c, platform, 'teamID');
    const pMethod = getConfigProp(c, platform, 'exportOptions')?.method;
    const runScheme = getConfigProp(c, platform, 'runScheme');
    let provisioning;
    if (pMethod === 'ad-hoc') provisioning = 'adhoc';
    if (pMethod === 'development' || runScheme === 'Debug') provisioning = 'development';
 
    const certsPath = path.join(c.paths.workspace.appConfig.dir, 'certs');
 
    let args = [
        'sigh',
        '--app_identifier',
        id,
        '--team_id',
        teamID,
        '--output_path',
        certsPath,
        '--force',
        '--platform',
        platform
    ];
    if (process.env.APPLE_DEVELOPER_USERNAME) {
        args = args.concat([
            '--username',
            process.env.APPLE_DEVELOPER_USERNAME
        ]);
    }
    if (provisioning) {
        args.push(`--${provisioning}`);
    }
 
    executeAsync(c, `fastlane ${args.join(' ')}`, { shell: true, stdio: 'inherit', silent: true })
        .then(() => {
            logSuccess(`Succesfully updated provisioning profile for ${appId}:${scheme}:${id}`);
 
            resolve();
        })
        .catch((e) => {
            logWarning(e);
            resolve();
        });
});