<commit_before>#!/usr/bin/env node
'use strict';

/**
 * Bundle singpath-core demo.
 */

// dependencies
const tools = require('@singpath/tools');
const path = require('path');
const sh = require('shelljs');

// exit on error
sh.set('-e');

// paths
const dist = process.env.npm_package_config_build_dir || 'dist';
const assets = process.env.npm_package_config_build_assets_dir || path.join('tools', 'assets');
const distAssests = path.join(assets, 'dist', '*');
const output = path.join(dist, 'singpath-core.js');
const outputMin = path.join(dist, 'singpath-core.min.js');
const outputTree = path.join(dist, 'singpath-core.tree.html');
const demo = path.join(dist, 'demo.js');

const externals = [{
  name: 'angular',
  entry: 'angular-animate/angular-animate.js',
  globalName: 'angular'
}, {
  name: 'angular',
  entry: 'angular-aria/angular-aria.js',
  globalName: 'angular'
}, {
  name: 'angular',
  entry: 'angular-messages/angular-messages.js',
  globalName: 'angular'
}, {
  name: 'angular',
  entry: 'angular-route/angular-route.js',
  globalName: 'angular'
}, {
  name: 'angular',
  entry: 'angular/angular.js',
  globalName: 'angular'
}, {
  name: 'angular-material',
  entry: 'angular-material/angular-material.js',
  globalName: 'angular'
}, {
  name: 'angular-loading-bar',
  entry: 'angular-loading-bar/build/loading-bar.js',
  globalName: 'angular'
}, {
  name: 'firebase',
  entry: 'firebase/firebase.js',
  globalName: 'Firebase'
}, {
  name: 'angularfire',
  entry: 'angularfire',
  globalName: 'angular'
}];

// jspm options
const deps = externals.map(e => e.name);
const globalDeps = externals.reduce(
  (gd, e) => Object.assign(gd, {[e.entry]: e.globalName}),
  {}
);
const src = ['singpath-core'].concat(deps).join(' - ');
const depsOpts = `--global-name spfShared --global-deps '${JSON.stringify(globalDeps)}'`;


// Setup
tools.clean(dist);
sh.echo(`Setting up "${dist}/"...`);
sh.mkdir('-p', dist);
sh.cp('LICENSE', distAssests, dist);


// Bundles
sh.echo(`Buidling ${output}...`);
tools.exec(`jspm build ${src} "${output}" ${depsOpts} --format umd --skip-source-maps`);

sh.echo(`Buidling ${outputMin}...`);
tools.exec(`jspm build ${src} "${outputMin}" ${depsOpts} --format umd --minify`);

sh.echo(`Buidling ${demo}...`);
tools.exec(`jspm build singpath-core/demo.js "${demo}" --global-name spfSharedDemo --format umd`);


// Dependency tree
//
// You don't want the browser to load the source map file
// (the source map is often as big as the bundle).
// So we are stripping the source map directive in the bundle
// by stripping the last line.
sh.echo(`Removing source map directive from ${outputMin}...`);
sh.sed('-i', /^\/\/# sourceMappingURL=.*$/, '', outputMin);

sh.echo('Analysing source map...');
tools.execPipe(`source-map-explorer --html "${outputMin}" "${outputMin}.map"`, {stdout: outputTree});

sh.echo(`open "'${outputTree}'" to find weight of each modules.`);
<commit_msg>Attempt to fix gh-pages auto-update<commit_after>#!/usr/bin/env node
'use strict';

/**
 * Bundle singpath-core demo.
 */

// dependencies
const tools = require('@singpath/tools');
const path = require('path');
const sh = require('shelljs');

// exit on error
sh.set('-e');

// paths
const dist = process.env.npm_package_config_build_dir || 'dist';
const assets = process.env.npm_package_config_build_assets_dir || 'tools/assets';
const distAssests = `${assets}/*`;
const output = path.join(dist, 'singpath-core.js');
const outputMin = path.join(dist, 'singpath-core.min.js');
const outputTree = path.join(dist, 'singpath-core.tree.html');
const demo = path.join(dist, 'demo.js');

const externals = [{
  name: 'angular',
  entry: 'angular-animate/angular-animate.js',
  globalName: 'angular'
}, {
  name: 'angular',
  entry: 'angular-aria/angular-aria.js',
  globalName: 'angular'
}, {
  name: 'angular',
  entry: 'angular-messages/angular-messages.js',
  globalName: 'angular'
}, {
  name: 'angular',
  entry: 'angular-route/angular-route.js',
  globalName: 'angular'
}, {
  name: 'angular',
  entry: 'angular/angular.js',
  globalName: 'angular'
}, {
  name: 'angular-material',
  entry: 'angular-material/angular-material.js',
  globalName: 'angular'
}, {
  name: 'angular-loading-bar',
  entry: 'angular-loading-bar/build/loading-bar.js',
  globalName: 'angular'
}, {
  name: 'firebase',
  entry: 'firebase/firebase.js',
  globalName: 'Firebase'
}, {
  name: 'angularfire',
  entry: 'angularfire',
  globalName: 'angular'
}];

// jspm options
const deps = externals.map(e => e.name);
const globalDeps = externals.reduce(
  (gd, e) => Object.assign(gd, {[e.entry]: e.globalName}),
  {}
);
const src = ['singpath-core'].concat(deps).join(' - ');
const depsOpts = `--global-name spfShared --global-deps '${JSON.stringify(globalDeps)}'`;


// Setup
sh.echo(`CWD: ${process.cwd()}`);
tools.clean(dist);
sh.echo(`Setting up "${dist}/"...`);
sh.mkdir('-p', dist);
sh.cp('-r', 'LICENSE', distAssests, dist);


// Bundles
sh.echo(`Buidling ${output}...`);
tools.exec(`jspm build ${src} "${output}" ${depsOpts} --format umd --skip-source-maps`);

sh.echo(`Buidling ${outputMin}...`);
tools.exec(`jspm build ${src} "${outputMin}" ${depsOpts} --format umd --minify`);

sh.echo(`Buidling ${demo}...`);
tools.exec(`jspm build singpath-core/demo.js "${demo}" --global-name spfSharedDemo --format umd`);


// Dependency tree
//
// You don't want the browser to load the source map file
// (the source map is often as big as the bundle).
// So we are stripping the source map directive in the bundle
// by stripping the last line.
sh.echo(`Removing source map directive from ${outputMin}...`);
sh.sed('-i', /^\/\/# sourceMappingURL=.*$/, '', outputMin);

sh.echo('Analysing source map...');
tools.execPipe(`source-map-explorer --html "${outputMin}" "${outputMin}.map"`, {stdout: outputTree});

sh.echo(`open "'${outputTree}'" to find weight of each modules.`);

{'fraction_non_alphanumeric': 0.20504516788818816, 'fraction_numerical': 0.0, 'mean_word_length': 4.354014598540146, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '2881376', 'n_tokens_mistral': 2049, 'n_tokens_neox': 2035, 'n_words': 477}