HEX
Server: Apache
System: Linux webd004.cluster130.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User: frenchy (106757)
PHP: 7.4.33
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/frenchy/www/french-american.org/current/node_modules/@frctl/fractal/bin/fractal
#!/usr/bin/env node

'use strict';

const Path           = require('path');
const semver         = require('semver');
const Liftoff        = require('liftoff');
const chalk          = require('chalk');
const updateNofifier = require('update-notifier');
const cliPackage     = require('../package.json');
const utils          = require('../src/core/utils');
const Fractal        = require('../.').Fractal;

const notifier = updateNofifier({
    pkg: cliPackage
});

const FractalCli = new Liftoff({
    processTitle: 'fractal',
    moduleName: '@frctl/fractal',
    configName: 'fractal',
    extensions: {
        '.js': null
    }
    // ,
    // v8flags: ['--harmony']
});

/*
 * Figure out what the Fractal CLI config file is called.
 *
 * - See if there is a package.json file present that contains a specific filename
 * - Otherwise look for the default fractal.js
 */

let config = {};
try {
    const projectPackage = require(Path.join(process.cwd(), 'package.json'));
    if (projectPackage.fractal && projectPackage.fractal.main) {
        config.configPath = Path.join(process.cwd(), projectPackage.fractal.main);
    }
} catch(e){}

FractalCli.launch(config, function(env){

    let app;
    let scope = 'global';
    let configPath = env.configPath;

    if (configPath) {
        // Config file found - it's running in project context.
        try {
            app = require(configPath);
            scope = 'project';
        } catch(e) {
            console.log(e.stack);
            return;
        }
    }

    /*
     * If it's a project context check compare the local Fractal version with the CLI version.
     * Also check that the config file is correctly exporting a configured fractal instance.
     *
     * If it's not a global context, then import the global Fractal module and create a fresh instance.
     */

    if (scope === 'project') {
        if (semver.lt(env.modulePackage.version, `1.0.0`)) {
            // Project is using a legacy version of Fractal, load it the old way...
            console.log(`Fractal version mismatch! Global: ${cliPackage.version} / Local: ${env.modulePackage.version}`);
            let frctl = require(env.modulePath);
            frctl.run();
            return;
        }

        if (! app || ! app.__fractal) {
            // looks like the configuration file is not correctly module.export'ing a fractal intance
            console.log(`${chalk.red('Configuration error')}: The CLI configuration file is not exporting an instance of Fractal.`);
            return;
        }

        // Alert to any version mismatches.
        if (semver.gt(cliPackage.version, env.modulePackage.version)) {
            app.cli.notify.versionMismatch({
                cli: cliPackage.version,
                local: env.modulePackage.version
            });
        }

    } else {
        // Global context
        app = require('../.').create();
    }

    /*
     * Notify of any available updates on exit
     */

    if (notifier.update) {
        process.on('exit', function () {
            app.cli.notify.updateAvailable(notifier.update);
    	});
    }

    /*
     * Kick things off...
     */

    app.cli.init(scope, configPath, env, cliPackage);
    app.cli.exec();
});