protected function getNewAppId($oldAppId)
    {
        if (empty($oldAppId)) {
            return null;
        }

        $apps = $this->package->getResourceFromZip('system/app.json');
        $appName = null;
        foreach ($apps as $app) {
            if ($oldAppId === $app['id']) {
                $appName = $app['name'];
                break;
            }
        }

        if (!empty($appName)) {
            $newApp = App::whereName($appName)->first(['id']);
            if (!empty($newApp)) {
                return $newApp->id;
            }
        } else {
            $existingApp = App::find($oldAppId);
            if (!empty($existingApp)) {
                $appName = $existingApp->name;

                if (in_array($appName, ['admin', 'api_docs', 'file_manager'])) {
                    // If app is one of the pre-defined system apps
                    // then new id is most likely the same as the old id.
                    return $oldAppId;
                }
            }
        }

        return null;
    }