<commit_before>#!/usr/bin/env node

'use strict';

var Browserify = require('browserify');
var Child_Process = require('child_process');
var Envify = require('envify/custom');
var exec = Child_Process.exec;
var Express = require('express');
var Fs = require('fs');
var Livereload = require('livereload');
var Ncp = require('ncp').ncp
var Path = require('path');
var Program = require('commander');
var Watchify = require('watchify');

var Assistant = require('./../dev/assistant/assistant');
var Config = require('./../dev/config');

var livereloadOptions = {
    port: 35729,
    exts: ['html','css','js','png','gif','jpg','coffee','less','json'],
    applyJSLive: false,
    applyCSSLive: false,
    exclusions: [/\\node_modules\//,/\\.git\//,/\\.svn\//,/\\.hg\//],
    interval: 1000
};

Program.command('copy-core-components')
    .option('-d, --destinationFolder [destinationFolder]')
    .action(function(info) {
        var coreComponentsFolder = Path.join(__dirname, '..', 'lib', 'core-components', 'famous');
        Ncp(coreComponentsFolder, info.destinationFolder, function(copyErr) {
            if (copyErr) {
                return console.error('Couldn\'t copy core components!');
            }
        });
    });

Program.command('watch-runtime')
    .option('-i, --inputFile [inputFile]')
    .option('-s, --serverHost [serverHost]')
    .option('-o, --outputFile [outputFile]')
    .action(function(info) {
        var b = Browserify(info.inputFile, { cache: {}, packageCache: {} });
        var w = Watchify(b);
        w.transform(Envify({ FF_ASSET_READ_HOST: info.serverHost }));
        function bundle() { w.bundle().pipe(Fs.createWriteStream(info.outputFile)); }
        w.on('update', function() { bundle(); });
        w.on('bytes', function(bytes) { console.log('Wrote ' + bytes + ' bytes to ' + info.outputFile); });
        bundle();
    });

Program.command('local-only-bootstrap')
    .description('Bootstrap local development, recursively building _only local_ components')
    .option('-s, --sourceDirectory [sourceDirectory]')
    .option('-b, --blocksDirectory [blocksDirectory]')
    .option('-r, --rebuildEverythingOnChange [rebuildEverythingOnChange]')
    .option('-p, --port [port]')
    .action(function(info) {
        var assistant = new Assistant({
            builderOptions: {
                localRawSourceFolder: info.sourceDirectory,
                localBlocksFolder: info.blocksDirectory,
                codeManagerAssetReadHost: 'http://localhost:' + info.port,
                doSkipDependencyDereferencing: true,
                doAttemptToBuildDependenciesLocally: true
            }
        });

        var doRebuildEverythingOnChange = info.rebuildEverythingOnChange === 'yes';

        assistant.buildAll(info.sourceDirectory, '', function(buildAllErr) {
            if (!buildAllErr) {
                assistant.watchDirectoryRecursive(info.sourceDirectory, '', doRebuildEverythingOnChange);

                var livereloadServer = Livereload.createServer(livereloadOptions);
                livereloadServer.watch([info.blocksDirectory]);

                var server = Express();
                server.use(Express.static(info.blocksDirectory));
                server.listen(info.port);
            }
            else {
                console.log(buildAllErr);
            }
        });
    });

Program.command('snapshot-component')
    .option('-n, --componentName [componentName]')
    .option('-s, --sourceDirectory [sourceDirectory]')
    .option('-b, --blocksDirectory [blocksDirectory]')
    .option('-d, --destinationDirectory [destinationDirectory]')
    .action(function(info) {
        var assistant = new Assistant({
            builderOptions: {
                localRawSourceFolder: info.sourceDirectory,
                localBlocksFolder: info.blocksDirectory,
                codeManagerAssetReadHost: 'https://api-te.famo.us/codemanager',
                codeManagerAssetWriteHost: 'https://api-te.famo.us/codemanager',
                codeManagerVersionInfoHost: null,
                authHost: 'https://api-te.famo.us/auth',
                doWriteToCodeManager: true,
                doSkipDependencyDereferencing: false,
                doAttemptToBuildDependenciesLocally: true,
                doSkipExecutableBuild: false
            }
        });

        var baseDir = info.sourceDirectory;
        var subDir = info.componentName.split(Config.get('componentDelimiter')).join(Path.sep);

        assistant.buildSingle(baseDir, subDir, function(buildErr, buildInfo) {
            var destPath = Path.join(info.destinationDirectory, buildInfo.name);
<commit_msg>fix: Use api-beta instead of api-te<commit_after>#!/usr/bin/env node

'use strict';

var Browserify = require('browserify');
var Child_Process = require('child_process');
var Envify = require('envify/custom');
var exec = Child_Process.exec;
var Express = require('express');
var Fs = require('fs');
var Livereload = require('livereload');
var Ncp = require('ncp').ncp
var Path = require('path');
var Program = require('commander');
var Watchify = require('watchify');

var Assistant = require('./../dev/assistant/assistant');
var Config = require('./../dev/config');

var livereloadOptions = {
    port: 35729,
    exts: ['html','css','js','png','gif','jpg','coffee','less','json'],
    applyJSLive: false,
    applyCSSLive: false,
    exclusions: [/\\node_modules\//,/\\.git\//,/\\.svn\//,/\\.hg\//],
    interval: 1000
};

Program.command('copy-core-components')
    .option('-d, --destinationFolder [destinationFolder]')
    .action(function(info) {
        var coreComponentsFolder = Path.join(__dirname, '..', 'lib', 'core-components', 'famous');
        Ncp(coreComponentsFolder, info.destinationFolder, function(copyErr) {
            if (copyErr) {
                return console.error('Couldn\'t copy core components!');
            }
        });
    });

Program.command('watch-runtime')
    .option('-i, --inputFile [inputFile]')
    .option('-s, --serverHost [serverHost]')
    .option('-o, --outputFile [outputFile]')
    .action(function(info) {
        var b = Browserify(info.inputFile, { cache: {}, packageCache: {} });
        var w = Watchify(b);
        w.transform(Envify({ FF_ASSET_READ_HOST: info.serverHost }));
        function bundle() { w.bundle().pipe(Fs.createWriteStream(info.outputFile)); }
        w.on('update', function() { bundle(); });
        w.on('bytes', function(bytes) { console.log('Wrote ' + bytes + ' bytes to ' + info.outputFile); });
        bundle();
    });

Program.command('local-only-bootstrap')
    .description('Bootstrap local development, recursively building _only local_ components')
    .option('-s, --sourceDirectory [sourceDirectory]')
    .option('-b, --blocksDirectory [blocksDirectory]')
    .option('-r, --rebuildEverythingOnChange [rebuildEverythingOnChange]')
    .option('-p, --port [port]')
    .action(function(info) {
        var assistant = new Assistant({
            builderOptions: {
                localRawSourceFolder: info.sourceDirectory,
                localBlocksFolder: info.blocksDirectory,
                codeManagerAssetReadHost: 'http://localhost:' + info.port,
                doSkipDependencyDereferencing: true,
                doAttemptToBuildDependenciesLocally: true
            }
        });

        var doRebuildEverythingOnChange = info.rebuildEverythingOnChange === 'yes';

        assistant.buildAll(info.sourceDirectory, '', function(buildAllErr) {
            if (!buildAllErr) {
                assistant.watchDirectoryRecursive(info.sourceDirectory, '', doRebuildEverythingOnChange);

                var livereloadServer = Livereload.createServer(livereloadOptions);
                livereloadServer.watch([info.blocksDirectory]);

                var server = Express();
                server.use(Express.static(info.blocksDirectory));
                server.listen(info.port);
            }
            else {
                console.log(buildAllErr);
            }
        });
    });

Program.command('snapshot-component')
    .option('-n, --componentName [componentName]')
    .option('-s, --sourceDirectory [sourceDirectory]')
    .option('-b, --blocksDirectory [blocksDirectory]')
    .option('-d, --destinationDirectory [destinationDirectory]')
    .action(function(info) {
        var assistant = new Assistant({
            builderOptions: {
                localRawSourceFolder: info.sourceDirectory,
                localBlocksFolder: info.blocksDirectory,
                codeManagerAssetReadHost: 'https://api-beta.famo.us/codemanager',
                codeManagerAssetWriteHost: 'https://api-beta.famo.us/codemanager',
                codeManagerVersionInfoHost: null,
                authHost: 'https://api-beta.famo.us/auth',
                doWriteToCodeManager: true,
                doSkipDependencyDereferencing: false,
                doAttemptToBuildDependenciesLocally: true,
                doSkipExecutableBuild: false
            }
        });

        var baseDir = info.sourceDirectory;
        var subDir = info.componentName.split(Config.get('componentDelimiter')).join(Path.sep);

        assistant.buildSingle(baseDir, subDir, function(buildErr, buildInfo) {
            var destPath = Path.join(info.destinationDirectory, buildInfo.name);

{'fraction_non_alphanumeric': 0.1469453376205788, 'fraction_numerical': 0.0019292604501607716, 'mean_word_length': 2.711614956245028, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2190325', 'n_tokens_mistral': 2659, 'n_tokens_neox': 2548, 'n_words': 457}