*/
class CRM_Utils_Check_Component_Cms extends CRM_Utils_Check_Component {
+ /**
+ * For sites running from Composer, ensure public assets have been correctly installed.
+ *
+ * @return CRM_Utils_Check_Message[]
+ */
+ public static function checkPublicAssets(): array {
+ $checks = [];
+ $assetDir = $GLOBALS['civicrm_asset_map']['civicrm/civicrm-core']['dest'] ?? NULL;
+ // No asset directory so this is not a composer-based install
+ if (!$assetDir) {
+ return [];
+ }
+ $errorMsg = NULL;
+ $versionFile = $assetDir . '/js/version.json';
+ if (!file_exists($versionFile)) {
+ $errorMsg = ts('Assets missing from public web directory.');
+ }
+ else {
+ $currentVersion = CRM_Utils_System::version();
+ $assetVersion = json_decode(file_get_contents($versionFile), TRUE);
+ if ($assetVersion !== $currentVersion) {
+ $errorMsg = ts('Wrong version of assets in public web directory: expected %1 but found %2.', [1 => $currentVersion, 2 => $assetVersion]);
+ }
+ }
+ if ($errorMsg) {
+ $checks[] = new CRM_Utils_Check_Message(
+ __FUNCTION__,
+ "$errorMsg " .
+ ts('Use the command %1 to resolve.', [1 => '<code>composer civicrm:publish</code>']) .
+ ' ' .
+ CRM_Utils_System::docURL2('sysadmin/upgrade/drupal8/#additional-cleanup'),
+ ts('Public Assets Not Published'),
+ \Psr\Log\LogLevel::ERROR,
+ 'fa-code'
+ );
+ }
+ return $checks;
+ }
+
/**
* For sites running in WordPress, make sure the configured base page exists.
*
return str_replace($oldVersion, $newVersion, $content);
});
+updateFile("js/version.json", function () use ($newVersion) {
+ return json_encode($newVersion) . '\n';
+});
+
// Update core extensions if this is a stable release
$infoXmls = isPreReleaseIncrement($newVersion) ? [] : findCoreInfoXml();
foreach ($infoXmls as $infoXml) {