UNPKG

@gravityforms/gulp-tasks

Version:
49 lines (39 loc) 1.75 kB
import fs from 'node:fs'; import path from 'node:path'; import getConfig from '../../config.js'; import getPluginVersion from './get-plugin-version.js'; const { config } = getConfig(); /** * @description Build the Google Drive upload configuration for the current package release artifacts. * * @since 8.4.0 * * @return {Promise<Object>} Returns the destination path and list of files to upload. */ async function getGoogleDriveConfig() { const { slug, rootPluginSlug, googleDriveRootFolder, rootPluginFile } = config.settings; const version = process.env.GRAVITY_PLUGIN_VERSION || getPluginVersion( config.paths.root, rootPluginFile ); const isMasterOrMain = process.env.GRAVITY_CURRENT_BRANCH === 'master' || process.env.GRAVITY_CURRENT_BRANCH === 'main'; const obj = { path: '', files: [], }; if ( googleDriveRootFolder ) { obj.path = `${ googleDriveRootFolder }/${ isMasterOrMain ? 'Releases' : `Branches/${ process.env.GRAVITY_CURRENT_BRANCH }` }`; } else if ( slug === 'gravityforms' ) { obj.path = `Gravity Forms/${ isMasterOrMain ? 'Releases' : `Branches/${ process.env.GRAVITY_CURRENT_BRANCH }` }`; } else { obj.path = `Gravity Forms/Addons/${ rootPluginSlug }${ ! isMasterOrMain ? `/branches/${ process.env.GRAVITY_CURRENT_BRANCH }` : '' }`; } const basePath = path.join( config.paths.root, slug ); const potentialFiles = [ `${ basePath }_${ version }.zip`, `${ basePath }_${ version }_wpcom.zip`, ]; if ( isMasterOrMain && process.env.GRAVITY_GULP_TASK === 'publish' ) { potentialFiles.push( path.join( config.paths.root, `checksums/${ slug }_${ version }.md5` ) ); } obj.files = potentialFiles.filter( ( file ) => fs.existsSync( file ) ); return obj; } export default getGoogleDriveConfig;