spip-cli: documentation, bug, automation

Hello All,

1. I get the following error running spip up via spip-cli:

Installing dependencies from lock file
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.

Problem 1
- spip-league/composer-installer is locked to version 0.8.2 and an update of this package was not requested.
- spip-league/composer-installer 0.8.2 requires composer-plugin-api ^2.6 → found composer-plugin-api[2.3.0] but it does not match the constraint.

[INFO] Départ nettoyage plugins-dist de la 4.2


2. Moving from spip_loader.php to spip-cli
I also wanted to request if you can add to the documentation the steps needed to migrate from spip_loader.php to spip-cli. I think this would involve removing all files/folders, except IMG, config, plugins, local, tmp and then run spip up. Is that correct?

Sometimes I already have my own git repo at the root of the SPIP folder, it seems this one I would need to move out of the way when using spip-cli.


3. Automatic Updates via spip-cli
. I am interested in spip-cli to automate updates. Nowadays you need to be so quick to apply the updates that I’d rather have a broken site than an exploited one.

Is using spip-cli via a cronjob possible, recommended?

Thank you for the great work.

My best,
Urs

You need to update your Composer it-self ! :

  • composer self-update

Thank you! That worked (had to install via Composer instead of package manager.

That’s what I’ve done with Gilles Vincent / spip-auto-update · GitLab
It updates SPIP and the plugins to their latest version
I use a patched version of spip_cli (required to update the plugins)
You can follow the development with the already-merged Merge Requests ; I try to make their description as exhaustive as possible.

Thanks @epilibre but I want to first get spip cli up and running, and normally if I can have a few idempotent spip-cli crons this would be all that’s needed to auto update, right?

I get very strange output when doin this on the first site. It has a custom module, that normalyl works fine, but installig a plugin is somehow also disabling saisies, very strange.

Do all plugins need to be installed through spip-cli to be updateable with spip-cli?

Sorry for the bad formatting. this is the output I get, in bold the commands :

spip plugins:svp:telecharger waf

Télécharger des plugins

! 25 plugins actifs
:heavy_check_mark: Tous les préfixes demandés sont déjà actifs

  • waf

// Plugin en cours d’installation : waf

// Pour l’installation du plugin waf les actions suivantes sont prévues :

// Plugin « SPIP WAF » (Version: 1.2.19) deaktivieren

// Plugin « SPIP WAF » (Version: 1.2.19) herunterladen und aktivieren

// SPIP WAF action réalisée : off

// SPIP WAF action réalisée : geton

Résultat :

  • waf 1.2.19 plugins/auto/waf/v1.2.19
    ! 24 plugins actifs

spip plugins:svp:telecharger saisies

Télécharger des plugins

! 24 plugins actifs
:heavy_check_mark: Tous les préfixes demandés sont déjà actifs

  • saisies

// Plugin en cours d’installation : saisies

// Pour l’installation du plugin saisies les actions suivantes sont prévues :

// Plugin « Eingabefelder für Formulare » (Version: 6.3.6) deaktivieren

// Plugin « Eingabefelder für Formulare » (Version: 6.3.6) herunterladen und aktivieren

// Eingabefelder für Formulare action réalisée : off

// Eingabefelder für Formulare action réalisée : geton

Résultat :

  • saisies 6.3.6 plugins/auto/saisies/v6.3.6
  • wj 1.0.0 plugins/weidejournal
    ! 22 plugins actifs

[ERROR] Des erreurs sont présentes

✘ Das Plugin plugins/weidejournal kann nicht aktiviert werden.

  • Benötigt das Plugin SAISIES

spip plugins:svp:telecharger waf

Télécharger des plugins

! 22 plugins actifs
Liste des plugins à activer :

  • waf

Les plugins listés au-dessus seront activés. Confirmez-vous ? (yes/no) [no]:

yes

// Plugin en cours d’installation : waf

// Pour l’installation du plugin waf les actions suivantes sont prévues :

// Plugin « SPIP WAF » (Version: 1.2.19) herunterladen und aktivieren

// SPIP WAF action réalisée : geton

! Aucune modification des plugins actifs

[ERROR] Des erreurs sont présentes

✘ Das Plugin plugins/weidejournal kann nicht aktiviert werden.

  • Benötigt das Plugin SAISIES

I guess this is a custom plugin…
Maybe, have a look in the necessite section into its paquet.xml. It might require a (too) specific version of saisies ?!

You just need spip_cli to be patched to manage plugins correctly

Then it handles everything fine

Precisions about my dev, and why I need it : spip-cli cannot directly update an existing plugin. Its plugins:svp:telecharger command mainly requests an installation (geton), not an update (upon). For that I use the more generic php:run command instead

My process works as follows:

  1. The absolute path to spip-cli is read from parc.json:
     {
         "spip_cli": "/opt/spip-cli/bin/spip"
     }
  1. Before doing anything, spip-auto-update checks that the binary exists, is executable, and, for plugin updates, contains the required patches: src/PreflightGlobal.php:33.

  2. To inspect the plugins, a temporary sonde.php payload is copied into the site and executed with:
    /opt/spip-cli/bin/spip php:run --include tmp/spip_auto_update/sonde.php

    The command runs from the site’s root directory. Because php:run initializes SPIP first, the payload can query SVP, plugin repositories, and the spip_plugins and spip_paquets tables: src/Sonde.php:35.

  3. When updates are applied, the same mechanism executes payload/appliquer.php. This script directly uses SVP’s Decideur and Actionneur classes to:

    • resolve dependencies;
    • verify that SVP does not perform actions that were absent from the announced plan;
    • download, install, update, enable, or disable the required plugins.

    This logic is in payload/appliquer.php:134.

  4. After updating the plugin files, spip-cli also runs:

spip plugins:maj:bdd
spip cache:vider

The first command applies any plugin database migrations. The second clears SPIP’s cache: src/Execution.php:337.

The src/SpipCli.php:14 class centralizes these calls. It:

  • uses the configured absolute binary path;
  • runs commands from the relevant site directory;
  • safely escapes command-line arguments;
  • captures standard output, errors, and the exit code;
  • stops commands that exceed their timeout.

To sum up, spip_auto_update plays a coordinator role with SVP that decides and perform plugin operations, and spip-cli that provides the execution environment inside each website.