index.js
function update(args, done) {
    app = this.fractal;

    let typo3cli = path.join(typo3path, '../vendor/bin/typo3');
    let typo3args = ['extbase', 'component:discover'];
    try {
        if (fs.statSync(typo3cli).isFile()) {
            typo3args.shift();
        }
    } catch (e) {
        typo3cli = path.join(typo3path, 'typo3/cli_dispatch.phpsh');
    }

    try {
        if (fs.statSync(typo3cli).isFile()) {
            typo3args.unshift(typo3cli);
            const componentsJSON = execFileSync('php', typo3args).toString();
            const components = JSON.parse(componentsJSON);
            for (const component of components) {
                processComponent(component);
            }

            // Write the general shared context
            const context = { context: { typo3: typo3url } };
            writeFile(path.resolve(app.components.get('path'), 'components.config.json'), JSON.stringify(context, null, 4));

            // See if there's a component file manifest
            const manifest = path.resolve(app.components.get('path'), 'components.files.json');
            try {
                if (fs.statSync(manifest).isFile()) {
                    const currentFiles = new Set(files);
                    const prevFiles = new Set(JSON.parse(fs.readFileSync(manifest)));

                    // Delete all redundant files
                    [...prevFiles].filter(f => !currentFiles.has(f)).forEach(f => fs.unlinkSync(path.resolve(app.components.get('path'), f)));
                }
            } catch (e) {
                // Ignore errors
            } finally {
                writeFile(manifest, JSON.stringify(files));
                deleteEmpty.sync(app.components.get('path'));
            }
        }
        done();
    } catch (e) {
        console.log(e);
        process.exit(1);
    }
}
function update(args, done) {
    app = this.fractal;

    let typo3cli = path.join(typo3path, '../vendor/bin/typo3');
    let typo3args = ['extbase', 'component:discover'];
    try {
        if (fs.statSync(typo3cli).isFile()) {
            typo3args.shift();
        }
    } catch (e) {
        typo3cli = path.join(typo3path, 'typo3/cli_dispatch.phpsh');
    }

    try {
        if (fs.statSync(typo3cli).isFile()) {
            typo3args.unshift(typo3cli);
            const componentsJSON = execFileSync('php', typo3args).toString();
            const components = JSON.parse(componentsJSON);
            for (const component of components) {
                processComponent(component);
            }

            // Write the general shared context
            const context = { context: { typo3: typo3url } };
            writeFile(path.resolve(app.components.get('path'), 'components.config.json'), JSON.stringify(context, null, 4));

            // See if there's a component file manifest
            const manifest = path.resolve(app.components.get('path'), 'components.files.json');
            try {
                if (fs.statSync(manifest).isFile()) {
                    const currentFiles = new Set(files);
                    const prevFiles = new Set(JSON.parse(fs.readFileSync(manifest)));

                    // Delete all redundant files
                    [...prevFiles].filter(f => !currentFiles.has(f)).forEach(f => fs.unlinkSync(path.resolve(app.components.get('path'), f)));
                }
            } catch (e) {
                // Ignore errors
            } finally {
                writeFile(manifest, JSON.stringify(files));
                deleteEmpty.sync(app.components.get('path'));
            }
        }
        done();
    } catch (e) {
        console.log(e);
        process.exit(1);
    }
}
function update ( args , done ) { app = this . fractal ; let typo3cli = path . join ( typo3path , '../vendor/bin/typo3' ) ; let typo3args = [ 'extbase' , 'component:discover' ] ; try { if ( fs . statSync ( typo3cli ) . isFile ( ) ) { typo3args . shift ( ) ; } } catch ( e ) { typo3cli = path . join ( typo3path , 'typo3/cli_dispatch.phpsh' ) ; } try { if ( fs . statSync ( typo3cli ) . isFile ( ) ) { typo3args . unshift ( typo3cli ) ; const componentsJSON = execFileSync ( 'php' , typo3args ) . toString ( ) ; const components = JSON . parse ( componentsJSON ) ; for ( const component of components ) { processComponent ( component ) ; } // Write the general shared context const context = { context : { typo3 : typo3url } } ; writeFile ( path . resolve ( app . components . get ( 'path' ) , 'components.config.json' ) , JSON . stringify ( context , null , 4 ) ) ; // See if there's a component file manifest const manifest = path . resolve ( app . components . get ( 'path' ) , 'components.files.json' ) ; try { if ( fs . statSync ( manifest ) . isFile ( ) ) { const currentFiles = new Set ( files ) ; const prevFiles = new Set ( JSON . parse ( fs . readFileSync ( manifest ) ) ) ; // Delete all redundant files [ ... prevFiles ] . filter ( f => ! currentFiles . has ( f ) ) . forEach ( f => fs . unlinkSync ( path . resolve ( app . components . get ( 'path' ) , f ) ) ) ; } } catch ( e ) { // Ignore errors } finally { writeFile ( manifest , JSON . stringify ( files ) ) ; deleteEmpty . sync ( app . components . get ( 'path' ) ) ; } } done ( ) ; } catch ( e ) { console . log ( e ) ; process . exit ( 1 ) ; } }
Update the components by extracting them from a TYPO3 instance

@param {Array} args Arguments
@param {Function} done Callback
Update the components by extracting them from a TYPO3 instance