Skip to content
Snippets Groups Projects
osuny.js 2.61 KiB
Newer Older
Arnaud Levy's avatar
Arnaud Levy committed
#! /usr/bin/env node

Arnaud Levy's avatar
Arnaud Levy committed
const shell = require("shelljs");
shell.set('-e'); // exit upon first error
Arnaud Levy's avatar
Arnaud Levy committed

Olivia Simonet's avatar
Olivia Simonet committed
console.log(`
  .=*#%%#*=        -*#%%#*=.      =+-      ++.     .+ .+#%%#+.     :++      -+-
 :@@=:..:+@@.     #@#:..:+@@.     *@*      @@:     -@#@+:..-@@-    -@@      *@*
 +@*      %@=    .@@.     %@=     *@*      @@:     -@@.     *@*    -@@      *@*
 +@*      %@=     %@*     *%=     *@*      @@:     -@@      *@*    -@@      *@*
 +@*      %@=      +@@=           *@*      @@:     -@@      *@*    -@@      *@*
 +@*      %@=       .+@@+.        *@*      @@:     -@@      *@*    -@@      *@*
 +@*      %@=         .+@@+.      *@*      @@:     -@@      *@*    .@@=.   :@@=
 +@*      %@=     ==     +@@:     *@*      @@:     -@@      *@*     .+%@@@@%*-
 +@*      %@=    .@@.     +@#     *@*     .@@:     -@@      *@*         @@-
 =@%     .@@-     @@-     #@#     +@#    :#@@:     -@@      *@*         @@-
  =%@%##%@%=      :#@%##%@@*       *@@##@%=:@:     :@@      *@+         %@-
     .:..            ..:.            ...
Arnaud Levy's avatar
Arnaud Levy committed
 `);
Arnaud Levy's avatar
Arnaud Levy committed

const command = process.argv[2];

alexisben's avatar
alexisben committed
let pagefindExclude = `
Arnaud Levy's avatar
Arnaud Levy committed
    .authors__term,
    .categories__term,
    .diplomas__taxonomy, .block-diplomas,
alexisben's avatar
alexisben committed
    .events__section, .block-agenda,
Arnaud Levy's avatar
Arnaud Levy committed
    .organizations__section, .block-organizations,
    .pages__section, .block-pages,
    .persons__section, .block-persons, 
    .posts__section, .block-posts, .post-sidebar, 
    .programs__section, .block-programs
    `;

function execute(string) {
    console.log("OSUNY runs " + string);
    shell.exec(string);
Arnaud Levy's avatar
Arnaud Levy committed
if (command === "watch") {
    execute("hugo server");
Arnaud Levy's avatar
Arnaud Levy committed
}

if (command === "dev") {
    execute("hugo");
    execute("npx pagefind --site 'public' --output-subdir '../static/pagefind' --exclude-selectors '" + pagefindExclude + "'");
    execute("hugo server");
Arnaud Levy's avatar
Arnaud Levy committed
}

if (command === "build") {
alexisben's avatar
alexisben committed
    execute("yarn upgrade");
    execute("hugo");
    execute("npm_config_yes=true npx pagefind --site 'public' --exclude-selectors '" + pagefindExclude + "'");
Arnaud Levy's avatar
Arnaud Levy committed
}

if (command === "update") {
    execute("git pull --recurse-submodules --depth 1");
    execute("git submodule update --remote");
Arnaud Levy's avatar
Arnaud Levy committed
}

if (command === "setup-example") {
    execute("git submodule add https://github.com/noesya/osuny-example");
Arnaud Levy's avatar
Arnaud Levy committed
}

if (command === "server-example") {
    execute("hugo server --config osuny-example/config/example/config.yaml");
Arnaud Levy's avatar
Arnaud Levy committed
}

if (command === "example") {
Arnaud Levy's avatar
Arnaud Levy committed
    execute("yarn setup-example > /dev/null || yarn upgrade");
    execute("yarn osuny server-example");
Arnaud Levy's avatar
Arnaud Levy committed
}

if (command === "update-theme") {
    execute("cd themes/osuny-hugo-theme-aaa");
    execute("git checkout main");
    execute("git pull");
    execute("cd ../..");
    execute("yarn upgrade");
Arnaud Levy's avatar
Arnaud Levy committed
}