build/src/index.js
/**
     * Deploy the current application using the given opts.
     */
Deploy the current application using the given opts.
Deploy the current application using the given opts .
async deploy() {
        this.emit(ProgressEvent.STARTING);
        const gcf = await this._getGCFClient();
        const projectId = await this._auth.getProjectId();
        const region = this._options.region || 'us-central1';
        const parent = `projects/${projectId}/locations/${region}`;
        const name = `${parent}/functions/${this._options.name}`;
        const fns = gcf.projects.locations.functions;
        const res = await fns.generateUploadUrl({ parent });
        const sourceUploadUrl = res.data.uploadUrl;
        this.emit(ProgressEvent.PACKAGING);
        const zipPath = await this._pack();
        this.emit(ProgressEvent.UPLOADING);
        await this._upload(zipPath, sourceUploadUrl);
        this.emit(ProgressEvent.DEPLOYING);
        const body = this._buildRequest(parent, sourceUploadUrl);
        const exists = await this._exists(name);
        let result;
        if (exists) {
            const updateMask = this._getUpdateMask();
            result = await fns.patch({ name, updateMask, requestBody: body });
        }
        else {
            result = await fns.create({ location: parent, requestBody: body });
        }
        const operation = result.data;
        await this._poll(operation.name);
        this.emit(ProgressEvent.COMPLETE);
    }
async deploy ( ) { this . emit ( ProgressEvent . STARTING ) ; const gcf = await this . _getGCFClient ( ) ; const projectId = await this . _auth . getProjectId ( ) ; const region = this . _options . region || 'us-central1' ; const parent = ` ${ projectId } ${ region } ` ; const name = ` ${ parent } ${ this . _options . name } ` ; const fns = gcf . projects . locations . functions ; const res = await fns . generateUploadUrl ( { parent } ) ; const sourceUploadUrl = res . data . uploadUrl ; this . emit ( ProgressEvent . PACKAGING ) ; const zipPath = await this . _pack ( ) ; this . emit ( ProgressEvent . UPLOADING ) ; await this . _upload ( zipPath , sourceUploadUrl ) ; this . emit ( ProgressEvent . DEPLOYING ) ; const body = this . _buildRequest ( parent , sourceUploadUrl ) ; const exists = await this . _exists ( name ) ; let result ; if ( exists ) { const updateMask = this . _getUpdateMask ( ) ; result = await fns . patch ( { name , updateMask , requestBody : body } ) ; } else { result = await fns . create ( { location : parent , requestBody : body } ) ; } const operation = result . data ; await this . _poll ( operation . name ) ; this . emit ( ProgressEvent . COMPLETE ) ; }
Deploy the current application using the given opts.
Deploy the current application using the given opts .