From 2a07b101a4427e157234258518685ea70301372a Mon Sep 17 00:00:00 2001 From: Donald Pakkies Date: Mon, 14 Mar 2022 21:03:28 +0000 Subject: [PATCH 1/4] chore(deps): update imba --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e776813..f3bdd39 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "ir": "./bin/runtime" }, "dependencies": { - "imba": "^2.0.0-alpha.201" + "imba": "^2.0.0-alpha.204" }, "devDependencies": { "@types/jest": "^27.4.1", From f0cdecd4ed491ef6de121195070ffdb7660f549b Mon Sep 17 00:00:00 2001 From: Donald Pakkies Date: Mon, 14 Mar 2022 21:05:01 +0000 Subject: [PATCH 2/4] fix: improve windows support --- src/Command.imba | 5 ++++- src/ImbaCompiler.imba | 2 +- src/ImbaRunner.imba | 19 ++++++++++++------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/Command.imba b/src/Command.imba index 71831c6..bed2038 100644 --- a/src/Command.imba +++ b/src/Command.imba @@ -69,13 +69,16 @@ export default class Command def exec const fallbackScript = self.createFallbackScript! + if process.platform === 'win32' + self.args[0] = fallbackScript || join(process.cwd!, self.args[0]) + self.args.splice 1, 0, '--' const watcher = [] if self.watch then watcher.push '-w' - spawnSync("{ImbaRunner.instance!.slice(0, -1)}", [...watcher, ...self.args], { + spawnSync("{ImbaRunner.instance!}", [...watcher, ...self.args], { stdio: 'inherit', cwd: process.cwd! }) diff --git a/src/ImbaCompiler.imba b/src/ImbaCompiler.imba index cc08970..2d5623c 100644 --- a/src/ImbaCompiler.imba +++ b/src/ImbaCompiler.imba @@ -31,7 +31,7 @@ export default class ImbaCompiler fs.writeFileSync(path.join(directory, self.sessionId), self.code.trim!) - const results\Buffer = execSync("{ImbaRunner.instance!} {path.join(directory, self.sessionId)} --platform=node --format=cjs --print") + const results\Buffer = execSync("{ImbaRunner.instance(true)} {path.join(directory, self.sessionId)} --platform=node --format=cjs --print") fs.rmSync(path.join(directory, self.sessionId)) diff --git a/src/ImbaRunner.imba b/src/ImbaRunner.imba index b2f14b1..06f61ba 100644 --- a/src/ImbaRunner.imba +++ b/src/ImbaRunner.imba @@ -5,17 +5,22 @@ import path from 'path' export default class ImbaRunner + static get ext + process.platform === 'win32' ? '.cmd' : '' + static get imba - const local\String = path.join(process.cwd!, 'node_modules', '.bin', 'imbac') - const onboard\String = path.join(__dirname, '..', 'node_modules', '.bin', 'imbac') + const local\String = path.join(process.cwd!, 'node_modules', '.bin', 'imba') + const onboard\String = path.join(__dirname, '..', 'node_modules', '.bin', 'imba') fs.existsSync(local) ? local : onboard - static def instance - if !fs.existsSync(self.imba) - throw new ImbaMissingException `Imba not found at ${self.imba}` + static def instance compiler\Boolean = false + const file = self.imba + (compiler ? 'c' : '') + self.ext + + if !fs.existsSync(file) + throw new ImbaMissingException `Imba not found at ${file}` - self.imba + file static get version - execSync("{self.instance!} -v").toString!.trim! \ No newline at end of file + execSync("{self.instance(true)} -v").toString!.trim! From 2703b6590862ac31232a48b8cf698be67d5d2e7e Mon Sep 17 00:00:00 2001 From: Donald Pakkies Date: Mon, 14 Mar 2022 21:05:25 +0000 Subject: [PATCH 3/4] chore: build imba and regenerate types --- lib/Command.js | 53 +++++++++++---------- lib/ImbaCompiler.js | 30 ++++++------ lib/ImbaRepl.js | 58 +++++++++++------------ lib/ImbaRunner.js | 34 ++++++++----- lib/UpdateNotifier.js | 54 ++++++++++----------- lib/index.js | 24 +++++----- types/Command.d.ts | 4 +- types/ImbaCompiler.d.ts | 4 +- types/ImbaRepl.d.ts | 4 +- types/ImbaRunner.d.ts | 6 ++- types/UpdateNotifier.d.ts | 4 +- types/Version.ts | 6 --- types/lib/Command.d.ts | 11 ----- types/lib/ContextHelpers.d.ts | 3 -- types/lib/Error/ImbaMissingException.d.ts | 4 -- types/lib/ImbaCompiler.d.ts | 19 -------- types/lib/ImbaRepl.d.ts | 28 ----------- types/lib/ImbaRunner.d.ts | 7 --- types/lib/UpdateNotifier.d.ts | 21 -------- types/lib/index.d.ts | 3 -- types/types/Version.d.ts | 5 -- 21 files changed, 147 insertions(+), 235 deletions(-) delete mode 100644 types/Version.ts delete mode 100644 types/lib/Command.d.ts delete mode 100644 types/lib/ContextHelpers.d.ts delete mode 100644 types/lib/Error/ImbaMissingException.d.ts delete mode 100644 types/lib/ImbaCompiler.d.ts delete mode 100644 types/lib/ImbaRepl.d.ts delete mode 100644 types/lib/ImbaRunner.d.ts delete mode 100644 types/lib/UpdateNotifier.d.ts delete mode 100644 types/lib/index.d.ts delete mode 100644 types/types/Version.d.ts diff --git a/lib/Command.js b/lib/Command.js index 91fbd84..757bc9c 100644 --- a/lib/Command.js +++ b/lib/Command.js @@ -1,25 +1,25 @@ function requireDefault$__(obj){ return obj && obj.__esModule ? obj : { default: obj }; }; -const Ψ__init__ = Symbol.for('#__init__'), Ψ__initor__ = Symbol.for('#__initor__'), Ψ__inited__ = Symbol.for('#__inited__'); +const $10 = Symbol.for('#__init__'), $13 = Symbol.for('#__initor__'), $14 = Symbol.for('#__inited__'), $11 = Symbol.for('#__hooks__'); Object.defineProperty(exports, "__esModule", {value: true}); /*body*/ -var _$fsφ = require('fs'/*$path$*/); -var _$fsφ2 = require('fs'/*$path$*/); -var _$fsφ3 = require('fs'/*$path$*/); -var _$pathφ = require('path'/*$path$*/); -var _$pathφ2 = require('path'/*$path$*/); -var _$pathφ3 = require('path'/*$path$*/); -var _$child_processφ = require('child_process'/*$path$*/); -var _$jsonφ = require('../package.json'/*$path$*/); -var _$ImbaRunnerφ = requireDefault$__(require('./ImbaRunner'/*$path$*/)); +var $1 = require('fs'/*$path$*/); +var $2 = require('fs'/*$path$*/); +var $3 = require('fs'/*$path$*/); +var $4 = require('path'/*$path$*/); +var $5 = require('path'/*$path$*/); +var $6 = require('path'/*$path$*/); +var $7 = require('child_process'/*$path$*/); +var $8 = require('../package.json'/*$path$*/); +var $9 = requireDefault$__(require('./ImbaRunner'/*$path$*/)); class Command { - [Ψ__init__]($$ = null){ - var vφ; - this.args = ($$ && (vφ = $$.args) !== undefined) ? (vφ) : []; - this.watch = ($$ && (vφ = $$.watch) !== undefined) ? (vφ) : false; + [$10]($$ = null){ + var $12; + this.args = ($$ && ($12 = $$.args) !== undefined) ? ($12) : []; + this.watch = ($$ && ($12 = $$.watch) !== undefined) ? ($12) : false; } get isRuntime(){ @@ -28,7 +28,7 @@ class Command { } constructor(){ - this[Ψ__init__](); + this[$10](); this.args = process.argv.slice(2); } @@ -41,7 +41,7 @@ class Command { printVersion(){ - return console.log(("Imba Shell v" + _$jsonφ.version + " (imba " + (_$ImbaRunnerφ.default.version) + ")")); + return console.log(("Imba Shell v" + $8.version + " (imba " + ($9.default.version) + ")")); } displayHelp(){ @@ -72,7 +72,7 @@ class Command { if (this.watch == false && !(this.args[0])) { return this.displayHelp() }; - if ((this.args[0] == undefined && this.watch) || (!(_$fsφ.existsSync(_$pathφ.join(process.cwd(),this.args[0]))) && !(this.args[0].trim().startsWith('-')))) { + if ((this.args[0] == undefined && this.watch) || (!($1.existsSync($4.join(process.cwd(),this.args[0]))) && !(this.args[0].trim().startsWith('-')))) { console.log('Error: Script missing.'); @@ -92,7 +92,7 @@ class Command { return this.displayHelp(); }; - if (_$fsφ.existsSync(_$pathφ.join(process.cwd(),this.args[0]))) { + if ($1.existsSync($4.join(process.cwd(),this.args[0]))) { return this.exec(); }; @@ -104,18 +104,23 @@ class Command { const fallbackScript = this.createFallbackScript(); + if (process.platform === 'win32') { + + this.args[0] = fallbackScript || $4.join(process.cwd(),this.args[0]); + }; + this.args.splice(1,0,'--'); const watcher = []; if (this.watch) { watcher.push('-w') }; - _$child_processφ.spawnSync(("" + _$ImbaRunnerφ.default.instance().slice(0,-1)),[...watcher,...this.args],{ + $7.spawnSync(("" + $9.default.instance()),[...watcher,...this.args],{ stdio: 'inherit', cwd: process.cwd() }); - if (fallbackScript !== null) { return _$fsφ3.unlinkSync(fallbackScript) }; + if (fallbackScript !== null) { return $3.unlinkSync(fallbackScript) }; } createFallbackScript(){ @@ -125,13 +130,13 @@ class Command { if (!(this.args[0].endsWith('.imba'))) { - sourceScript = _$pathφ.join(process.cwd(),this.args[0]); - fallbackScript = _$pathφ.join(process.cwd(),_$pathφ2.dirname(this.args[0]),("." + _$pathφ3.basename(this.args[0]) + ".imba")); + sourceScript = $4.join(process.cwd(),this.args[0]); + fallbackScript = $4.join(process.cwd(),$5.dirname(this.args[0]),("." + $6.basename(this.args[0]) + ".imba")); try { - _$fsφ2.copyFileSync(sourceScript,fallbackScript); - this.args[0] = _$pathφ.join(_$pathφ2.dirname(this.args[0]),("." + _$pathφ3.basename(this.args[0]) + ".imba")); + $2.copyFileSync(sourceScript,fallbackScript); + this.args[0] = $4.join($5.dirname(this.args[0]),("." + $6.basename(this.args[0]) + ".imba")); } catch (e) { fallbackScript = null; diff --git a/lib/ImbaCompiler.js b/lib/ImbaCompiler.js index d975a50..8313276 100644 --- a/lib/ImbaCompiler.js +++ b/lib/ImbaCompiler.js @@ -1,19 +1,19 @@ function requireDefault$__(obj){ return obj && obj.__esModule ? obj : { default: obj }; }; -const Ψ__init__ = Symbol.for('#__init__'), Ψ__initor__ = Symbol.for('#__initor__'), Ψ__inited__ = Symbol.for('#__inited__'); +const $7 = Symbol.for('#__init__'), $9 = Symbol.for('#__initor__'), $10 = Symbol.for('#__inited__'), $8 = Symbol.for('#__hooks__'); Object.defineProperty(exports, "__esModule", {value: true}); /*body*/ -var _$child_processφ = require('child_process'/*$path$*/); -var _$jsonφ = require('../package.json'/*$path$*/); -var _$fsφ = requireDefault$__(require('fs'/*$path$*/)); -var _$ImbaRunnerφ = requireDefault$__(require('./ImbaRunner'/*$path$*/)); -var _$osφ = requireDefault$__(require('os'/*$path$*/)); -var _$pathφ = requireDefault$__(require('path'/*$path$*/)); +var $1 = require('child_process'/*$path$*/); +var $2 = require('../package.json'/*$path$*/); +var $3 = requireDefault$__(require('fs'/*$path$*/)); +var $4 = requireDefault$__(require('./ImbaRunner'/*$path$*/)); +var $5 = requireDefault$__(require('os'/*$path$*/)); +var $6 = requireDefault$__(require('path'/*$path$*/)); class ImbaCompiler { - [Ψ__init__]($$ = null){ + [$7]($$ = null){ this.code = $$ ? $$.code : undefined; this.sessionId = $$ ? $$.sessionId : undefined; @@ -23,7 +23,7 @@ class ImbaCompiler { @param {String} sessionId */ constructor(code,sessionId){ - this[Ψ__init__](); + this[$7](); if (typeof code !== 'string') { throw new TypeError('Expected code to be a String.'); @@ -49,18 +49,18 @@ class ImbaCompiler { get(){ - const directory = _$pathφ.default.join(_$osφ.default.homedir(),("." + _$jsonφ.name)); + const directory = $6.default.join($5.default.homedir(),("." + $2.name)); - if (!(_$fsφ.default.existsSync(directory))) { + if (!($3.default.existsSync(directory))) { - _$fsφ.default.mkdirSync(directory,{recursive: true}); + $3.default.mkdirSync(directory,{recursive: true}); }; - _$fsφ.default.writeFileSync(_$pathφ.default.join(directory,this.sessionId),this.code.trim()); + $3.default.writeFileSync($6.default.join(directory,this.sessionId),this.code.trim()); - const results = _$child_processφ.execSync(("" + _$ImbaRunnerφ.default.instance() + " " + _$pathφ.default.join(directory,this.sessionId) + " --platform=node --format=cjs --print")); + const results = $1.execSync(("" + $4.default.instance(true) + " " + $6.default.join(directory,this.sessionId) + " --platform=node --format=cjs --print")); - _$fsφ.default.rmSync(_$pathφ.default.join(directory,this.sessionId)); + $3.default.rmSync($6.default.join(directory,this.sessionId)); return results.toString(); } diff --git a/lib/ImbaRepl.js b/lib/ImbaRepl.js index cb15d0b..9ac6ee3 100644 --- a/lib/ImbaRepl.js +++ b/lib/ImbaRepl.js @@ -2,27 +2,27 @@ function requireDefault$__(obj){ return obj && obj.__esModule ? obj : { default: obj }; };; function iter$__(a){ let v; return a ? ((v=a.toIterable) ? v.call(a) : a) : []; }; -const Ψ__init__ = Symbol.for('#__init__'), Ψ__initor__ = Symbol.for('#__initor__'), Ψ__inited__ = Symbol.for('#__inited__'); +const $9 = Symbol.for('#__init__'), $21 = Symbol.for('#__initor__'), $22 = Symbol.for('#__inited__'), $10 = Symbol.for('#__hooks__'); Object.defineProperty(exports, "__esModule", {value: true}); /*body*/ -var _$jsonφ = require('../package.json'/*$path$*/); -var _$ContextHelpersφ = require('./ContextHelpers'/*$path$*/); -var _$ImbaCompilerφ = requireDefault$__(require('./ImbaCompiler'/*$path$*/)); -var _$ImbaRunnerφ = requireDefault$__(require('./ImbaRunner'/*$path$*/)); -var _$osφ = requireDefault$__(require('os'/*$path$*/)); -var _$pathφ = requireDefault$__(require('path'/*$path$*/)); -var _$replφ = requireDefault$__(require('repl'/*$path$*/)); -var _$UpdateNotifierφ = requireDefault$__(require('./UpdateNotifier'/*$path$*/)); +var $1 = require('../package.json'/*$path$*/); +var $2 = require('./ContextHelpers'/*$path$*/); +var $3 = requireDefault$__(require('./ImbaCompiler'/*$path$*/)); +var $4 = requireDefault$__(require('./ImbaRunner'/*$path$*/)); +var $5 = requireDefault$__(require('os'/*$path$*/)); +var $6 = requireDefault$__(require('path'/*$path$*/)); +var $7 = requireDefault$__(require('repl'/*$path$*/)); +var $8 = requireDefault$__(require('./UpdateNotifier'/*$path$*/)); class ImbaRepl { - [Ψ__init__]($$ = null){ - var vφ; - this.ctxCallbacks = ($$ && (vφ = $$.ctxCallbacks) !== undefined) ? (vφ) : []; - this.cmdCallbacks = ($$ && (vφ = $$.cmdCallbacks) !== undefined) ? (vφ) : []; - this.update = ($$ && (vφ = $$.update) !== undefined) ? (vφ) : null; - this.prompt = ($$ && (vφ = $$.prompt) !== undefined) ? (vφ) : '>>> '; - this.historyPath = ($$ && (vφ = $$.historyPath) !== undefined) ? (vφ) : null; + [$9]($$ = null){ + var $11; + this.ctxCallbacks = ($$ && ($11 = $$.ctxCallbacks) !== undefined) ? ($11) : []; + this.cmdCallbacks = ($$ && ($11 = $$.cmdCallbacks) !== undefined) ? ($11) : []; + this.update = ($$ && ($11 = $$.update) !== undefined) ? ($11) : null; + this.prompt = ($$ && ($11 = $$.prompt) !== undefined) ? ($11) : '>>> '; + this.historyPath = ($$ && ($11 = $$.historyPath) !== undefined) ? ($11) : null; } /** @@ -30,7 +30,7 @@ class ImbaRepl { @param {String|null} historyPath */ constructor(prompt = '>>> ',historyPath = null){ - this[Ψ__init__](); + this[$9](); if (typeof prompt !== 'string') { throw new TypeError('Expected prompt to be a String.'); @@ -102,11 +102,11 @@ class ImbaRepl { throw new TypeError('Expected repl options to be an Object.'); }; - console.log(("Imba Shell v" + _$jsonφ.version + " (imba " + (_$ImbaRunnerφ.default.version) + ") by Donald Pakkies")); + console.log(("Imba Shell v" + $1.version + " (imba " + ($4.default.version) + ") by Donald Pakkies")); - if (this.update) { (new _$UpdateNotifierφ.default).check(this.update) }; + if (this.update) { (new $8.default).check(this.update) }; - const server = await _$replφ.default.start({...{prompt: this.prompt},...options}); + const server = await $7.default.start({...{prompt: this.prompt},...options}); if (this.historyPath) { @@ -118,27 +118,27 @@ class ImbaRepl { self.registerCommand('clear',function() { - _$ContextHelpersφ.clear(); + $2.clear(); return process.stdout.write(self.prompt); }); self.registerCommand('exit',function() { - return _$ContextHelpersφ.exit(); + return $2.exit(); }); - for (let iφ = 0, itemsφ = iter$__(self.ctxCallbacks), lenφ = itemsφ.length; iφ < lenφ; iφ++) { - let handler = itemsφ[iφ]; + for (let $12 = 0, $13 = iter$__(self.ctxCallbacks), $14 = $13.length; $12 < $14; $12++) { + let handler = $13[$12]; handler(server.context); }; - for (let iφ2 = 0, itemsφ2 = iter$__(self.cmdCallbacks), lenφ2 = itemsφ2.length; iφ2 < lenφ2; iφ2++) { - let handler = itemsφ2[iφ2]; + for (let $15 = 0, $16 = iter$__(self.cmdCallbacks), $17 = $16.length; $15 < $17; $15++) { + let handler = $16[$15]; server.defineCommand(handler.name,handler.callback); }; - for (let iφ3 = 0, keysφ = Object.keys(_$ContextHelpersφ), lφ = keysφ.length, key, handler; iφ3 < lφ; iφ3++){ - key = keysφ[iφ3];handler = _$ContextHelpersφ[key]; + for (let $18 = 0, $19 = Object.keys($2), $20 = $19.length, key, handler; $18 < $20; $18++){ + key = $19[$18];handler = $2[key]; server.context[key] = handler; }; @@ -148,7 +148,7 @@ class ImbaRepl { server.eval = function(cmd,context,file,cb) { - const compiledCode = _$ImbaCompilerφ.default.code(cmd,sessionId).get(); + const compiledCode = $3.default.code(cmd,sessionId).get(); return cmdEval(compiledCode,context,file,async function(error,results) { diff --git a/lib/ImbaRunner.js b/lib/ImbaRunner.js index bc21320..2752a36 100644 --- a/lib/ImbaRunner.js +++ b/lib/ImbaRunner.js @@ -4,35 +4,45 @@ function requireDefault$__(obj){ Object.defineProperty(exports, "__esModule", {value: true}); /*body*/ -var _$child_processφ = require('child_process'/*$path$*/); -var _$fsφ = requireDefault$__(require('fs'/*$path$*/)); -var _$ImbaMissingExceptionφ = requireDefault$__(require('./Error/ImbaMissingException'/*$path$*/)); -var _$pathφ = requireDefault$__(require('path'/*$path$*/)); +var $1 = require('child_process'/*$path$*/); +var $2 = requireDefault$__(require('fs'/*$path$*/)); +var $3 = requireDefault$__(require('./Error/ImbaMissingException'/*$path$*/)); +var $4 = requireDefault$__(require('path'/*$path$*/)); class ImbaRunner { + static get ext(){ + + return (process.platform === 'win32') ? '.cmd' : ''; + } + static get imba(){ - const local = _$pathφ.default.join(process.cwd(),'node_modules','.bin','imbac'); - const onboard = _$pathφ.default.join(__dirname,'..','node_modules','.bin','imbac'); + const local = $4.default.join(process.cwd(),'node_modules','.bin','imba'); + const onboard = $4.default.join(__dirname,'..','node_modules','.bin','imba'); - return _$fsφ.default.existsSync(local) ? local : onboard; + return $2.default.existsSync(local) ? local : onboard; } - static instance(){ + /** + @param {Boolean} compiler + */ + static instance(compiler = false){ + + const file = this.imba + (compiler ? 'c' : '') + this.ext; - if (!(_$fsφ.default.existsSync(this.imba))) { + if (!($2.default.existsSync(file))) { - throw new _$ImbaMissingExceptionφ.default((`Imba not found at $` + (this.imba))); + throw new $3.default((`Imba not found at $` + file)); }; - return this.imba; + return file; } static get version(){ - return _$child_processφ.execSync(("" + this.instance() + " -v")).toString().trim(); + return $1.execSync(("" + this.instance(true) + " -v")).toString().trim(); } }; exports.default = ImbaRunner; diff --git a/lib/UpdateNotifier.js b/lib/UpdateNotifier.js index 20f94b3..048d06f 100644 --- a/lib/UpdateNotifier.js +++ b/lib/UpdateNotifier.js @@ -1,25 +1,25 @@ function requireDefault$__(obj){ return obj && obj.__esModule ? obj : { default: obj }; }; -const Ψ__init__ = Symbol.for('#__init__'), Ψ__initor__ = Symbol.for('#__initor__'), Ψ__inited__ = Symbol.for('#__inited__'); +const $6 = Symbol.for('#__init__'), $9 = Symbol.for('#__initor__'), $10 = Symbol.for('#__inited__'), $7 = Symbol.for('#__hooks__'); Object.defineProperty(exports, "__esModule", {value: true}); /*body*/ -var _$jsonφ = require('../package.json'/*$path$*/); -var _$fsφ = requireDefault$__(require('fs'/*$path$*/)); -var _$httpsφ = requireDefault$__(require('https'/*$path$*/)); -var _$osφ = requireDefault$__(require('os'/*$path$*/)); -var _$pathφ = requireDefault$__(require('path'/*$path$*/)); +var $1 = require('../package.json'/*$path$*/); +var $2 = requireDefault$__(require('fs'/*$path$*/)); +var $3 = requireDefault$__(require('https'/*$path$*/)); +var $4 = requireDefault$__(require('os'/*$path$*/)); +var $5 = requireDefault$__(require('path'/*$path$*/)); class UpdateNotifier { - [Ψ__init__]($$ = null){ - var vφ; - this.package = ($$ && (vφ = $$.package) !== undefined) ? (vφ) : (("https://registry.npmjs.org/-/package/" + _$jsonφ.name + "/dist-tags")); - this.directory = ($$ && (vφ = $$.directory) !== undefined) ? (vφ) : _$pathφ.default.join(_$osφ.default.homedir(),("." + _$jsonφ.name)); + [$6]($$ = null){ + var $8; + this.package = ($$ && ($8 = $$.package) !== undefined) ? ($8) : (("https://registry.npmjs.org/-/package/" + $1.name + "/dist-tags")); + this.directory = ($$ && ($8 = $$.directory) !== undefined) ? ($8) : $5.default.join($4.default.homedir(),("." + $1.name)); } constructor(){ - this[Ψ__init__](); - if (!(_$fsφ.default.existsSync(this.directory))) { _$fsφ.default.mkdirSync(this.directory) }; + this[$6](); + if (!($2.default.existsSync(this.directory))) { $2.default.mkdirSync(this.directory) }; if (this.shouldFetchLatestVersion()) { @@ -29,11 +29,11 @@ class UpdateNotifier { shouldFetchLatestVersion(){ - const file = _$pathφ.default.join(this.directory,'latest.json'); + const file = $5.default.join(this.directory,'latest.json'); - if (!(_$fsφ.default.existsSync(file))) { return true }; + if (!($2.default.existsSync(file))) { return true }; - const fileDate = _$fsφ.default.statSync(file).mtime; + const fileDate = $2.default.statSync(file).mtime; const currentDate = new Date; const _FILE_DATE = Date.UTC(fileDate.getFullYear(),fileDate.getMonth(),fileDate.getDate()); @@ -42,7 +42,7 @@ class UpdateNotifier { const shouldRefresh = Math.floor((_CURRENT_DATE - _FILE_DATE) / _MS_PER_DAY > 0); - if (shouldRefresh) { _$fsφ.default.unlinkSync(file) }; + if (shouldRefresh) { $2.default.unlinkSync(file) }; return shouldRefresh; } @@ -52,15 +52,15 @@ class UpdateNotifier { */ compareVersion(latestVersion){ - if (_$jsonφ.version.trim() == latestVersion.trim()) { return 0 }; + if ($1.version.trim() == latestVersion.trim()) { return 0 }; - return latestVersion.localeCompare(_$jsonφ.version) == 1; + return latestVersion.localeCompare($1.version) == 1; } fetchLatestVersion(){ var self = this; - const request = _$httpsφ.default.get(this.package); + const request = $3.default.get(this.package); request.on('response',function(response) { @@ -83,9 +83,9 @@ class UpdateNotifier { */ storeVersion(data){ - const latestPath = _$pathφ.default.join(this.directory,'latest.json'); + const latestPath = $5.default.join(this.directory,'latest.json'); - return _$fsφ.default.writeFileSync(latestPath,data); + return $2.default.writeFileSync(latestPath,data); } /** @@ -93,25 +93,25 @@ class UpdateNotifier { */ check(callback = null){ - if (!(_$fsφ.default.existsSync(_$pathφ.default.join(this.directory,'latest.json')))) { return }; + if (!($2.default.existsSync($5.default.join(this.directory,'latest.json')))) { return }; - const response = JSON.parse(_$fsφ.default.readFileSync(_$pathφ.default.join(this.directory,'latest.json')).toString()); + const response = JSON.parse($2.default.readFileSync($5.default.join(this.directory,'latest.json')).toString()); if (!(this.compareVersion(response.latest))) { return }; if (callback && typeof callback == 'function') { - response.current = _$jsonφ.version; + response.current = $1.version; return callback(response); }; - const repeat = function(/**@type {String}*/char$) { return char$.repeat(_$jsonφ.name.length * 2); }; + const repeat = function(/**@type {String}*/char$) { return char$.repeat($1.name.length * 2); }; console.log('┌─────────────────────────────────────────────────────' + repeat('─') + '─┐'); console.log('│ ' + repeat(' ') + '│'); - console.log(("│ New version available: v" + (response.latest) + " (current: v" + _$jsonφ.version + ") ") + repeat(' ') + '│'); - console.log(("│ Run \u001B[32mnpm install -g " + _$jsonφ.name + "\u001B[0m or \u001B[32myarn global add " + _$jsonφ.name + "\u001B[0m to update! │")); + console.log(("│ New version available: v" + (response.latest) + " (current: v" + $1.version + ") ") + repeat(' ') + '│'); + console.log(("│ Run \u001B[32mnpm install -g " + $1.name + "\u001B[0m or \u001B[32myarn global add " + $1.name + "\u001B[0m to update! │")); console.log('│ ' + repeat(' ') + '│'); return console.log('└──────────────────────────────────────────────────────' + repeat('─') + '┘'); } diff --git a/lib/index.js b/lib/index.js index c3e84cc..770b44a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -4,16 +4,16 @@ function requireDefault$__(obj){ Object.defineProperty(exports, "__esModule", {value: true}); /*body*/ -var _$ContextHelpersφ = require('./ContextHelpers'/*$path$*/); -var _$Commandφ = requireDefault$__(require('./Command'/*$path$*/)); -var _$ImbaCompilerφ = requireDefault$__(require('./ImbaCompiler'/*$path$*/)); -var _$ImbaReplφ = requireDefault$__(require('./ImbaRepl'/*$path$*/)); -var _$ImbaRunnerφ = requireDefault$__(require('./ImbaRunner'/*$path$*/)); -var _$UpdateNotifierφ = requireDefault$__(require('./UpdateNotifier'/*$path$*/)); +var $1 = require('./ContextHelpers'/*$path$*/); +var $2 = requireDefault$__(require('./Command'/*$path$*/)); +var $3 = requireDefault$__(require('./ImbaCompiler'/*$path$*/)); +var $4 = requireDefault$__(require('./ImbaRepl'/*$path$*/)); +var $5 = requireDefault$__(require('./ImbaRunner'/*$path$*/)); +var $6 = requireDefault$__(require('./UpdateNotifier'/*$path$*/)); -exports.Command = _$Commandφ.default; -exports.ContextHelpers = _$ContextHelpersφ; -exports.ImbaCompiler = _$ImbaCompilerφ.default; -exports.ImbaRepl = _$ImbaReplφ.default; -exports.ImbaRunner = _$ImbaRunnerφ.default; -exports.UpdateNotifier = _$UpdateNotifierφ.default; +exports.Command = $2.default; +exports.ContextHelpers = $1; +exports.ImbaCompiler = $3.default; +exports.ImbaRepl = $4.default; +exports.ImbaRunner = $5.default; +exports.UpdateNotifier = $6.default; diff --git a/types/Command.d.ts b/types/Command.d.ts index 16f3428..1f8ce15 100644 --- a/types/Command.d.ts +++ b/types/Command.d.ts @@ -12,6 +12,6 @@ declare class Command { exec(): void; createFallbackScript(): string; handle(): any; - [Ψ__init__]($$?: any): void; + [$10]($$?: any): void; } -declare const Ψ__init__: unique symbol; +declare const $10: unique symbol; diff --git a/types/ImbaCompiler.d.ts b/types/ImbaCompiler.d.ts index 17256bf..c1a2148 100644 --- a/types/ImbaCompiler.d.ts +++ b/types/ImbaCompiler.d.ts @@ -14,6 +14,6 @@ declare class ImbaCompiler { code: string; sessionId: string; get(): string; - [Ψ__init__]($$?: any): void; + [$7]($$?: any): void; } -declare const Ψ__init__: unique symbol; +declare const $7: unique symbol; diff --git a/types/ImbaRepl.d.ts b/types/ImbaRepl.d.ts index d157a7f..23cbfb4 100644 --- a/types/ImbaRepl.d.ts +++ b/types/ImbaRepl.d.ts @@ -28,6 +28,6 @@ declare class ImbaRepl { @param {Object} options */ run(options?: any): Promise; - [Ψ__init__]($$?: any): void; + [$9]($$?: any): void; } -declare const Ψ__init__: unique symbol; +declare const $9: unique symbol; diff --git a/types/ImbaRunner.d.ts b/types/ImbaRunner.d.ts index c01bed7..3aa5c67 100644 --- a/types/ImbaRunner.d.ts +++ b/types/ImbaRunner.d.ts @@ -1,7 +1,11 @@ export var __esModule: boolean; export default ImbaRunner; declare class ImbaRunner { + static get ext(): "" | ".cmd"; static get imba(): any; - static instance(): any; + /** + @param {Boolean} compiler + */ + static instance(compiler?: boolean): string; static get version(): string; } diff --git a/types/UpdateNotifier.d.ts b/types/UpdateNotifier.d.ts index 0e3c323..8243205 100644 --- a/types/UpdateNotifier.d.ts +++ b/types/UpdateNotifier.d.ts @@ -17,6 +17,6 @@ declare class UpdateNotifier { @param {Function|Boolean} callback */ check(callback?: Function | boolean): any; - [Ψ__init__]($$?: any): void; + [$6]($$?: any): void; } -declare const Ψ__init__: unique symbol; +declare const $6: unique symbol; diff --git a/types/Version.ts b/types/Version.ts deleted file mode 100644 index 1f608bc..0000000 --- a/types/Version.ts +++ /dev/null @@ -1,6 +0,0 @@ -type Version = { - latest: string; - current: string; -}; - -export default Version; diff --git a/types/lib/Command.d.ts b/types/lib/Command.d.ts deleted file mode 100644 index c139894..0000000 --- a/types/lib/Command.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -export var __esModule: boolean; -export default Command; -declare class Command { - args: string[]; - printVersion(): void; - invalidCommand(): void; - run(): any; - handle(): any; - [Ψ__init__]($$?: any): void; -} -declare const Ψ__init__: unique symbol; diff --git a/types/lib/ContextHelpers.d.ts b/types/lib/ContextHelpers.d.ts deleted file mode 100644 index a200cc1..0000000 --- a/types/lib/ContextHelpers.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export var __esModule: boolean; -export function exit(): never; -export function clear(): void; diff --git a/types/lib/Error/ImbaMissingException.d.ts b/types/lib/Error/ImbaMissingException.d.ts deleted file mode 100644 index 047ec7c..0000000 --- a/types/lib/Error/ImbaMissingException.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export var __esModule: boolean; -export default ImbaMissingException; -declare class ImbaMissingException extends Error { -} diff --git a/types/lib/ImbaCompiler.d.ts b/types/lib/ImbaCompiler.d.ts deleted file mode 100644 index 17256bf..0000000 --- a/types/lib/ImbaCompiler.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -export var __esModule: boolean; -export default ImbaCompiler; -declare class ImbaCompiler { - /** - @param {String} code - @param {String} sessionId - */ - static code(code: string, sessionId: string): ImbaCompiler; - /** - @param {String} code - @param {String} sessionId - */ - constructor(code: string, sessionId: string); - code: string; - sessionId: string; - get(): string; - [Ψ__init__]($$?: any): void; -} -declare const Ψ__init__: unique symbol; diff --git a/types/lib/ImbaRepl.d.ts b/types/lib/ImbaRepl.d.ts deleted file mode 100644 index db1de9f..0000000 --- a/types/lib/ImbaRepl.d.ts +++ /dev/null @@ -1,28 +0,0 @@ -export var __esModule: boolean; -export default ImbaRepl; -declare class ImbaRepl { - /** - @param {String} prompt - @param {String|null} historyPath - */ - constructor(prompt?: string, historyPath?: string | null); - ctxCallbacks: any; - cmdCallbacks: any; - prompt: string; - historyPath: string; - /** - @param {Function} callback - */ - registerCallback(callback: Function): ImbaRepl; - /** - @param {String} name - @param {Function} callback - */ - registerCommand(name: string, callback: Function): ImbaRepl; - /** - @param {Object} options - */ - run(options?: any): Promise; - [Ψ__init__]($$?: any): void; -} -declare const Ψ__init__: unique symbol; diff --git a/types/lib/ImbaRunner.d.ts b/types/lib/ImbaRunner.d.ts deleted file mode 100644 index c01bed7..0000000 --- a/types/lib/ImbaRunner.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export var __esModule: boolean; -export default ImbaRunner; -declare class ImbaRunner { - static get imba(): any; - static instance(): any; - static get version(): string; -} diff --git a/types/lib/UpdateNotifier.d.ts b/types/lib/UpdateNotifier.d.ts deleted file mode 100644 index c2c7197..0000000 --- a/types/lib/UpdateNotifier.d.ts +++ /dev/null @@ -1,21 +0,0 @@ -export var __esModule: boolean; -export default UpdateNotifier; -declare class UpdateNotifier { - package: string; - directory: any; - /** - @param {String} latestVersion - */ - compareVersion(latestVersion: string): any; - fetchLatestVersion(): any; - /** - @param {String} data - */ - schedule(data: string): any; - /** - @param {Function} callback - */ - check(callback?: Function): any; - [Ψ__init__]($$?: any): void; -} -declare const Ψ__init__: unique symbol; diff --git a/types/lib/index.d.ts b/types/lib/index.d.ts deleted file mode 100644 index 6cfcb39..0000000 --- a/types/lib/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export var __esModule: boolean; -export { _$ContextHelpersφ as ContextHelpers }; -import _$ContextHelpersφ = require("./ContextHelpers"); diff --git a/types/types/Version.d.ts b/types/types/Version.d.ts deleted file mode 100644 index 3725879..0000000 --- a/types/types/Version.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -declare type Version = { - latest: string; - current: string; -}; -export default Version; From ec591bf2d31deebd873571e53bf3fe06de3507e5 Mon Sep 17 00:00:00 2001 From: Donald Pakkies Date: Mon, 14 Mar 2022 21:05:55 +0000 Subject: [PATCH 4/4] chore: bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f3bdd39..50f4c3d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "imba-shell", - "version": "0.3.1", + "version": "0.4.0", "description": "Interactive debugger and REPL for Imba.", "keywords": [ "imba",