Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proof of concept: use upng-js to generate animated PNGs instead of GIFs #143

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Rendering data
render/frames/*
render/data.json

# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Dependency directories
node_modules

# Optional npm cache directory
.npm

# Build
render/dist
131 changes: 64 additions & 67 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/**
* Terminalizer
*
*
* @author Mohammad Fares <[email protected]>
*/

var yargs = require('yargs'),
requireDir = require('require-dir');
var package = require('./package.json'),
commands = requireDir('./commands'),
DI = require('./di.js');
var yargs = require("yargs"),
requireDir = require("require-dir");
var package = require("./package.json"),
commands = requireDir("./commands"),
DI = require("./di.js");

// Define the DI as a global object
global.di = new DI();
Expand All @@ -17,88 +17,85 @@ global.di = new DI();
global.ROOT_PATH = __dirname;

// The base url of the Terminalizer website
global.BASEURL = 'https://terminalizer.com';
global.BASEURL = "https://terminalizer.com";

// Dependency Injection
di.require('chalk');
di.require('async');
di.require('request');
di.require('death');
di.require('path');
di.require('os');
di.require('electron');
di.require('deepmerge');
di.require('uuid');
di.require('is_js', 'is');
di.require('lodash', '_');
di.require('fs-extra', 'fs');
di.require('flowa', 'Flowa');
di.require('js-yaml', 'yaml');
di.require('performance-now', 'now');
di.require('async-promises', 'asyncPromises');
di.require('string-argv', 'stringArgv');
di.require('progress', 'ProgressBar');
di.require('gif-encoder', 'GIFEncoder');
di.require('inquirer');

di.set('pty', require('@faressoft/node-pty-prebuilt'));
di.set('PNG', require('pngjs').PNG);
di.set('spawn', require('child_process').spawn);
di.set('utility', require('./utility.js'));
di.set('commands', commands);
di.set('errorHandler', errorHandler);
di.require("chalk");
di.require("async");
di.require("request");
di.require("death");
di.require("path");
di.require("os");
di.require("electron");
di.require("deepmerge");
di.require("uuid");
di.require("is_js", "is");
di.require("lodash", "_");
di.require("fs-extra", "fs");
di.require("flowa", "Flowa");
di.require("js-yaml", "yaml");
di.require("performance-now", "now");
di.require("async-promises", "asyncPromises");
di.require("string-argv", "stringArgv");
di.require("progress", "ProgressBar");
di.require("gif-encoder", "GIFEncoder");
di.require("inquirer");

di.set("pty", require("@faressoft/node-pty-prebuilt"));
di.set("spawn", require("child_process").spawn);
di.set("utility", require("./utility.js"));
di.set("commands", commands);
di.set("errorHandler", errorHandler);

// Initialize yargs
yargs.usage('Usage: $0 <command> [options]')
// Add link
.epilogue('For more information, check https://terminalizer.com')
// Set the version number
.version(package.version)
// Add aliases for version and help options
.alias({v: 'version', h: 'help'})
// Require to pass a command
.demandCommand(1, 'The command is missing')
// Strict mode
.strict()
// Set width to 90 cols
.wrap(100)
// Handle failures
.fail(errorHandler);
yargs
.usage("Usage: $0 <command> [options]")
// Add link
.epilogue("For more information, check https://terminalizer.com")
// Set the version number
.version(package.version)
// Add aliases for version and help options
.alias({ v: "version", h: "help" })
// Require to pass a command
.demandCommand(1, "The command is missing")
// Strict mode
.strict()
// Set width to 90 cols
.wrap(100)
// Handle failures
.fail(errorHandler);

// Load commands
yargs.command(commands.init)
.command(commands.config)
.command(commands.record)
.command(commands.play)
.command(commands.render)
.command(commands.share)
.command(commands.generate)
yargs
.command(commands.init)
.command(commands.config)
.command(commands.record)
.command(commands.play)
.command(commands.render)
.command(commands.share)
.command(commands.generate);

debugger;

try {

// Parse the command line arguments
yargs.parse();

} catch (error) {

// Print the error
errorHandler(error);

}

/**
* Print an error
*
*
* @param {String|Error} error
*/
function errorHandler(error) {

error = error.toString();

console.error('Error: \n ' + error + '\n');
console.error('Hint:\n Use the ' + di.chalk.green('--help') + ' option to get help about the usage');
console.error("Error: " + (error.stack || error.toString()));
console.error(
"Hint:\n Use the " +
di.chalk.green("--help") +
" option to get help about the usage"
);
process.exit(1);

}
4 changes: 2 additions & 2 deletions bin/app.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

/**
* Terminalizer
*
*
* @author Mohammad Fares <[email protected]>
*/

require('../app.js');
require("../app.js");
20 changes: 8 additions & 12 deletions commands/config.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
/**
* Config
* Generate a config file in the current directory
*
*
* @author Mohammad Fares <[email protected]>
*/

/**
* Executed after the command completes its task
*/
function done() {

console.log(di.chalk.green('Successfully Saved'));
console.log('The config file is saved into the file:');
console.log(di.chalk.magenta('config.yml'));

console.log(di.chalk.green("Successfully Saved"));
console.log("The config file is saved into the file:");
console.log(di.chalk.magenta("config.yml"));
}

/**
* The command's main function
*
*
* @param {Object} argv
*/
function command(argv) {

// Copy the default config file
di.fs.copySync(di.path.join(ROOT_PATH, 'config.yml'), 'config.yml');
di.fs.copySync(di.path.join(ROOT_PATH, "config.yml"), "config.yml");

done();

}

////////////////////////////////////////////////////
Expand All @@ -38,13 +34,13 @@ function command(argv) {
* Command's usage
* @type {String}
*/
module.exports.command = 'config';
module.exports.command = "config";

/**
* Command's description
* @type {String}
*/
module.exports.describe = 'Generate a config file in the current directory';
module.exports.describe = "Generate a config file in the current directory";

/**
* Command's handler function
Expand Down
30 changes: 13 additions & 17 deletions commands/generate.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
/**
* Generate
* Generate a web player for a recording file
*
*
* @author Mohammad Fares <[email protected]>
*/

/**
* Executed after the command completes its task
*/
function done() {

// Terminate the app
process.exit();

}

/**
* The command's main function
*
*
* @param {Object} argv
*/
function command(argv) {

console.log('This command is not implemented yet. It will be available in the next versions');

console.log(
"This command is not implemented yet. It will be available in the next versions"
);
}

////////////////////////////////////////////////////
Expand All @@ -34,13 +32,13 @@ function command(argv) {
* Command's usage
* @type {String}
*/
module.exports.command = 'generate <recordingFile>';
module.exports.command = "generate <recordingFile>";

/**
* Command's description
* @type {String}
*/
module.exports.describe = 'Generate a web player for a recording file';
module.exports.describe = "Generate a web player for a recording file";

/**
* Command's handler function
Expand All @@ -50,16 +48,14 @@ module.exports.handler = command;

/**
* Builder
*
*
* @param {Object} yargs
*/
module.exports.builder = function(yargs) {

module.exports.builder = function (yargs) {
// Define the recordingFile argument
yargs.positional('recordingFile', {
describe: 'the recording file',
type: 'string',
coerce: di.utility.loadYAML
yargs.positional("recordingFile", {
describe: "the recording file",
type: "string",
coerce: di.utility.loadYAML,
});

};
Loading