UNPKG

@gravityforms/gulp-tasks

Version:
45 lines (38 loc) 1.63 kB
#!/usr/bin/env node const fs = require( 'fs/promises' ); const getConfig = require('../../config'); const { config } = getConfig(); const { isGravityFormsAddon } = require( '../utils/tools' ); const sendSlackMessage = require( '../utils/send-slack-message' ); const getPluginVersion = require( '../utils/get-plugin-version' ); const slackUpdate = async () => { // Check if not in production mode and exit early if ( process.env.GULP_PRODUCTION_MODE !== 'true' ) { console.log( 'Skipping updating slack because GULP_PRODUCTION_MODE is not set to true.' ); return; } const { friendlyName, slug, rootPluginFile } = config.settings; const version = process.env.GRAVITY_PLUGIN_VERSION || getPluginVersion( config.paths.root, rootPluginFile ); const branch = process.env.GRAVITY_CURRENT_BRANCH; const isMasterOrMain = branch === 'master' || branch === 'main'; const attachments = []; const configFile = await fs.readFile( 'process_data.json', 'utf8' ); const { googleDriveLink } = JSON.parse( configFile ); attachments.push( { color: '#00f', text: `<@${ process.env.SLACK_USER_ID }> I have built ${ isMasterOrMain ? '' : `the ${ branch } branch of ${ slug }: ${ ! isGravityFormsAddon( config ) ? '' : 'the ' }` }<${ googleDriveLink }|*${ friendlyName } v${ version }*>`, } ); await sendSlackMessage( '', 'success', attachments ); } ( async () => { try { await slackUpdate(); if ( process.env.GULP_PRODUCTION_MODE === 'true' ) { console.log( 'Updated slack with build information successfully.' ); } } catch ( err ) { console.error( 'An error occurred during slack messaging:', err ); } } )();