diff --git a/core/aqua.js b/core/aqua.js index be5b803..cc5c264 100644 --- a/core/aqua.js +++ b/core/aqua.js @@ -1,29 +1,63 @@ #!/usr/bin/env node -const args = require('yargs').argv +const {Signale} = require('signale'); +const log = new Signale(); +const interactive = new Signale({interactive: true}); const path = require('path'); -const {compile} = require('./compiler.js'); -args.index = args.index || path.join(process.cwd(), 'index.js'); -args.cache = args.cache || path.join(process.cwd(), '.cache'); +require('yargs') + .scriptName("aqua") + .usage('$0 [args]') -console.log('a') -let index = platformPrecompile(); -console.log('a') -index = compileParameters(index); -console.log('a') -index = compileLinks(index); -console.log('a') + .command('compile [paramaters]', 'compiles a system into a cache', (yargs) => { + yargs.option('cache', { + type: 'string', + default: '.cache', + describe: 'path of the cache' + }) + yargs.option('index', { + type: 'string', + default: 'index.js', + describe: 'path to the system index' + }) + }, cliCompile) -compile({ - index: index, - cache: args.cache -}) -console.log('a') + .help() + .argv; + +return; + + + +/// this is the base compile function, that the CLI directly calls. +async function cliCompile(args) { + console.log('things') + const {compile} = require('./compiler.js'); + if(!path.isAbsolute(args.index)) args.index = path.join(process.cwd(), 'index.js'); + if(!path.isAbsolute(args.cache)) args.cache = path.join(process.cwd(), 'index.js'); + + + let index = platformPrecompile(args); + log.info('precompile completed'); + + + index = compileParameters(index); + log.info('parameters injected'); + + + index = compileLinks(index); + log.info('entity links created') + + + compile({ + index: index, + cache: args.cache + }) +} /// Do all platform related things to the index file, like substituting /// CLI arguments, and converting from a filepath to an actual index object. // TODO make this also do dependencies -function platformPrecompile() { +function platformPrecompile(args) { // if its a path, require the file and create the object. if(typeof args.index === 'string') { args.index = require(args.index); diff --git a/core/cache.js b/core/cache.js index e1e97cd..c09c5ea 100644 --- a/core/cache.js +++ b/core/cache.js @@ -25,12 +25,10 @@ module.exports.Cache = class Cache { } addEntity(name, code) { - console.log(`writing ${name}...`); fs.writeFileSync(path.join(this.paths.code, `${name}.js`), code); } addInstance(instance) { - console.log(`writing ${instance}...`); fs.writeFileSync(path.join(this.paths.instances, `${instance._id}.json`), JSON.stringify(instance, null, 2)); } } \ No newline at end of file diff --git a/core/compiler.js b/core/compiler.js index f2f24cd..aaf14ac 100644 --- a/core/compiler.js +++ b/core/compiler.js @@ -13,7 +13,6 @@ async function compile({cache: cachePath, index}) { // const modules = {}; for(const symbol in index.Entities) { - console.log(symbol) const module = index.Entities[symbol]; let code = await retrieveModule(module.From, module.Name); // modules[module.Name] = code; diff --git a/package.json b/package.json index 20fe466..73e9667 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ }, "homepage": "https://github.com/marcus13345/AquaTin#readme", "dependencies": { + "signale": "^1.4.0", "uuid": "^3.3.2", "yargs": "^13.2.4" }