hackmud-script-manager 0.14.0-496fb0f → 0.14.0-66846c3
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/hsm.js +1 -1
- package/package.json +2 -2
package/bin/hsm.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
import o from"chalk";import e from"fs";import{homedir as s}from"os";import{resolve as t,basename as i,extname as n,dirname as r,relative as a}from"path";import{s as l,processScript as c}from"../processScript/index.js";import{D as p,w as g,push as m}from"../push.js";import{c as u}from"../processScript/minify.js";import{generateTypings as f}from"../generateTypings.js";import{syncMacros as b}from"../syncMacros.js";import{pull as h}from"../pull.js";import{watch as d}from"../watch.js";import"@babel/generator";import"@babel/parser";import"@babel/plugin-proposal-class-properties";import"@babel/plugin-proposal-class-static-block";import"@babel/plugin-proposal-decorators";import"@babel/plugin-proposal-do-expressions";import"@babel/plugin-proposal-function-bind";import"@babel/plugin-proposal-function-sent";import"@babel/plugin-proposal-json-strings";import"@babel/plugin-proposal-logical-assignment-operators";import"@babel/plugin-proposal-nullish-coalescing-operator";import"@babel/plugin-proposal-numeric-separator";import"@babel/plugin-proposal-object-rest-spread";import"@babel/plugin-proposal-optional-catch-binding";import"@babel/plugin-proposal-optional-chaining";import"@babel/plugin-proposal-partial-application";import"@babel/plugin-proposal-pipeline-operator";import"@babel/plugin-proposal-private-property-in-object";import"@babel/plugin-proposal-record-and-tuple";import"@babel/plugin-proposal-throw-expressions";import"@babel/plugin-transform-exponentiation-operator";import"@babel/plugin-transform-typescript";import"@babel/traverse";import"@babel/types";import"@rollup/plugin-babel";import"@rollup/plugin-commonjs";import"@rollup/plugin-json";import"@rollup/plugin-node-resolve";import"perf_hooks";import"prettier";import"rollup";import"../processScript/postprocess.js";import"../assert-1556d989.js";import"../spliceString-2c6f214f.js";import"../processScript/preprocess.js";import"../processScript/transform.js";import"../processScript/shared.js";import"acorn";import"terser";import"chokidar";const{readFile:k,rmdir:w,writeFile:y,mkdir:j}=e.promises,v=t(s(),".config"),$=t(v,"hsm.json"),S=new Map,P=[];let C;const x=o.rgb(255,244,4),N=o.rgb(243,249,152),O=o.rgb(179,255,155),L=o.rgb(255,150,224),U=o.rgb(30,255,0),T=o.rgb(202,202,202),E=new p((o=>{let e=0;for(const s of o)e+=(e>>1)+e+"xi1_8ratvsw9hlbgm02y5zpdcn7uekof463qj".indexOf(s)+1;return[x,N,O,L,U,T][e%6](o)}));for(const o of process.argv.slice(2))if("-"==o[0]){const[e,s]=o.split("=");let t=s;if(t)if("true"==t)t=!0;else if("false"==t)t=!1;else{const o=Number(t);isFinite(o)&&(t=o)}else t=!0;if("-"==o[1])S.set(e.slice(2),t);else for(const o of e.slice(1))S.set(o,t)}else P.push(o);function help(){switch(P[0]){case"config":switch(P[1]){case"get":console.log("hsm config get <key>");break;case"set":console.log("hsm config set <key> <value>");break;case"delete":console.log("hsm config delete <key>");break;default:console.log("hsm config <get, delete, set>")}break;case"push":console.log('hsm push [<dir> [..."<script user>.<script name>"]]');break;case"watch":console.log("hsm watch [dir]");break;case"pull":console.log("hsm pull <script user>.<script name>");break;case"minify":case"golf":console.log(`${i(process.argv[1])} ${P[0]} <target> [output]`);break;default:console.log("hsm <push, watch, pull, config, golf>")}}function version(){console.log("0.14.0-
|
2
|
+
import o from"chalk";import e from"fs";import{homedir as s}from"os";import{resolve as t,basename as i,extname as n,dirname as r,relative as a}from"path";import{s as l,processScript as c}from"../processScript/index.js";import{D as p,w as g,push as m}from"../push.js";import{c as u}from"../processScript/minify.js";import{generateTypings as f}from"../generateTypings.js";import{syncMacros as b}from"../syncMacros.js";import{pull as h}from"../pull.js";import{watch as d}from"../watch.js";import"@babel/generator";import"@babel/parser";import"@babel/plugin-proposal-class-properties";import"@babel/plugin-proposal-class-static-block";import"@babel/plugin-proposal-decorators";import"@babel/plugin-proposal-do-expressions";import"@babel/plugin-proposal-function-bind";import"@babel/plugin-proposal-function-sent";import"@babel/plugin-proposal-json-strings";import"@babel/plugin-proposal-logical-assignment-operators";import"@babel/plugin-proposal-nullish-coalescing-operator";import"@babel/plugin-proposal-numeric-separator";import"@babel/plugin-proposal-object-rest-spread";import"@babel/plugin-proposal-optional-catch-binding";import"@babel/plugin-proposal-optional-chaining";import"@babel/plugin-proposal-partial-application";import"@babel/plugin-proposal-pipeline-operator";import"@babel/plugin-proposal-private-property-in-object";import"@babel/plugin-proposal-record-and-tuple";import"@babel/plugin-proposal-throw-expressions";import"@babel/plugin-transform-exponentiation-operator";import"@babel/plugin-transform-typescript";import"@babel/traverse";import"@babel/types";import"@rollup/plugin-babel";import"@rollup/plugin-commonjs";import"@rollup/plugin-json";import"@rollup/plugin-node-resolve";import"perf_hooks";import"prettier";import"rollup";import"../processScript/postprocess.js";import"../assert-1556d989.js";import"../spliceString-2c6f214f.js";import"../processScript/preprocess.js";import"../processScript/transform.js";import"../processScript/shared.js";import"acorn";import"terser";import"chokidar";const{readFile:k,rmdir:w,writeFile:y,mkdir:j}=e.promises,v=t(s(),".config"),$=t(v,"hsm.json"),S=new Map,P=[];let C;const x=o.rgb(255,244,4),N=o.rgb(243,249,152),O=o.rgb(179,255,155),L=o.rgb(255,150,224),U=o.rgb(30,255,0),T=o.rgb(202,202,202),E=new p((o=>{let e=0;for(const s of o)e+=(e>>1)+e+"xi1_8ratvsw9hlbgm02y5zpdcn7uekof463qj".indexOf(s)+1;return[x,N,O,L,U,T][e%6](o)}));for(const o of process.argv.slice(2))if("-"==o[0]){const[e,s]=o.split("=");let t=s;if(t)if("true"==t)t=!0;else if("false"==t)t=!1;else{const o=Number(t);isFinite(o)&&(t=o)}else t=!0;if("-"==o[1])S.set(e.slice(2),t);else for(const o of e.slice(1))S.set(o,t)}else P.push(o);function help(){switch(P[0]){case"config":switch(P[1]){case"get":console.log("hsm config get <key>");break;case"set":console.log("hsm config set <key> <value>");break;case"delete":console.log("hsm config delete <key>");break;default:console.log("hsm config <get, delete, set>")}break;case"push":console.log('hsm push [<dir> [..."<script user>.<script name>"]]');break;case"watch":console.log("hsm watch [dir]");break;case"pull":console.log("hsm pull <script user>.<script name>");break;case"minify":case"golf":console.log(`${i(process.argv[1])} ${P[0]} <target> [output]`);break;default:console.log("hsm <push, watch, pull, config, golf>")}}function version(){console.log("0.14.0-66846c3")}async function getConfig(){return C||(C=await k($,{encoding:"utf-8"}).then((o=>{let e;try{e=JSON.parse(o)}catch{return console.log("config file was corrupted, resetting"),{}}return e&&"object"==typeof e?e:(console.log("config file was corrupted, resetting"),{})}),(()=>(console.log(`creating config file at ${$}`),{}))))}function exploreObject(o,e,s=!1){for(const i of e){var t;o=s?"object"==typeof o[i]?o[i]:o[i]={}:null===(t=o)||void 0===t?void 0:t[i]}return o}function updateConfig(){if(C){const o=JSON.stringify(C,void 0,"\t");y($,o).catch((async e=>{switch(e.code){case"EISDIR":await w($);break;case"ENOENT":await j(v);break;default:throw e}y($,o)}))}}function onPushLogger({file:e,users:s,srcLength:r,minLength:a,error:l}){s.length&&(l?console.log(`error "${o.bold(l.message)}" in ${o.bold(e)}`):console.log(`pushed ${o.bold(e)} to ${s.map((e=>o.bold(E.get(e)))).join(", ")} | ${o.bold(String(a))} chars from ${o.bold(String(r))} | saved ${o.bold(String(r-a))} (${o.bold(`${Math.round(100*(1-a/r))}%`)}) | ${o.bold(`${t(C.hackmudPath,s[0],"scripts",i(e,n(e)))}.js`)}`))}(async()=>{if(S.get("version")||S.get("v"))version();else if(S.get("help")||S.get("h"))help();else{switch(P[0]){case"push":{const o=await getConfig();if(!o.hackmudPath){console.log("you need to set hackmudPath in config before you can use this command");break}const e=P[1]||".",s=o.hackmudPath,t=P.slice(2);t.length||t.push("*.*");(await m(e,s,{scripts:t,onPush:onPushLogger,minify:!S.get("skip-minify")})).length||console.warn("couldn't find any scripts to push"),updateConfig()}break;case"dev":case"watch":{var e,s,p;const o=await getConfig();if(!o.hackmudPath){console.log("you need to set hackmudPath in config before you can use this command");break}const t=P[1]||".",i=o.hackmudPath,n=(null===(e=S.get("users"))||void 0===e?void 0:e.toString().split(","))||[],r=(null===(s=S.get("scripts"))||void 0===s?void 0:s.toString().split(","))||[],a=null===(p=S.get("gen-types"))||void 0===p?void 0:p.toString();d(t,i,n,r,onPushLogger,{genTypes:a})}break;case"pull":{const o=await getConfig();if(!o.hackmudPath){console.log("you need to set hackmudPath in config before you can use this command");break}const e=P[1];if(!e){help();break}const s=P[2]||".",t=o.hackmudPath;try{await h(s,t,e)}catch{console.log("something went wrong, did you forget to #down the script?")}}break;case"sync-macros":{const{hackmudPath:o}=await getConfig();if(!o){console.log("you need to set hackmudPath in config before you can use this command");break}const{macrosSynced:e,usersSynced:s}=await b(o);console.log(`synced ${e} macros to ${s} users`)}break;case"gen-types":{const o=t(P[1]||".");f(o,P[2]?t(P[2]):t(o,"../player.d.ts"),(await getConfig()).hackmudPath)}break;case"config":switch(P[1]){case"get":P[2]?console.log(exploreObject(await getConfig(),P[2].split("."))):console.log(await getConfig());break;case"delete":if(P[2]){var w;const o=P[2].split("."),e=o.pop();if(!o.length){help();break}const s=await getConfig();null===(w=exploreObject(s,o))||void 0===w||delete w[e],console.log(s)}else console.log("Usage:\nhsm config delete <key>");break;case"set":if(P[2]&&P[3]){const o=P[2].split(".");if(!o.length){help();break}const e=o.pop(),s=await getConfig();if(o.length||"hackmudPath"!=e){let t=s;for(const e of o)"object"==typeof t[e]||(t[e]={}),t=t[e];t[e]=P[3]}else s.hackmudPath=t(P[3]);console.log(s)}else console.log("Usage:\nhsm config set <key> <value>");break;default:P[1]&&console.log("unknown command"),help()}break;case"help":case"h":help();break;case"version":case"v":version();break;case"golf":case"minify":{const e=P[1];if(!e){console.log(`Target required\nUsage: ${i(process.argv[1])} ${P[0]} <target> [output]`);break}const s=n(e);if(!l.includes(s)){console.log(`Unsupported file extension "${o.bold(s)}"\nSupported extensions are "${l.map((e=>o.bold(e))).join('", "')}"`);break}await k(e,{encoding:"utf-8"}).then((async n=>{const l=i(e,s),p=l.endsWith(".src"),m=p?l.slice(0,-4):l;let f="UNKNOWN";"scripts"==i(t(e,".."))&&"hackmud"==i(t(e,"../../.."))&&(f=i(t(e,"../..")));const b=!S.get("skip-minify"),h=Boolean(S.get("mangle-names"));!b&&h&&console.warn("warning: `--mangle-names` has no effect while `--skip-minify` is active");const{script:d,srcLength:k,warnings:w,timeTook:y}=await c(n,{minify:b,scriptUser:f,scriptName:m,filePath:e,mangleNames:h});for(const{message:e,line:s}of w)console.log(`warning "${o.bold(e)}" on line ${o.bold(String(s))}`);let j;j=P[2]?P[2]:t(r(e),p?`${m}.js`:".js"==s?`${l}.min.js`:`${l}.js`);const v=u(d);await g(j,d).catch((async o=>{if(!P[2]||"EISDIR"!=o.code)throw o;j=t(j,`${i(e,s)}.js`),await g(j,d)})).then((()=>console.log(`wrote ${o.bold(v)} chars to ${o.bold(a(".",j))} | saved ${o.bold(k-v)} chars | took ${Math.round(100*y)/100}ms`)),(o=>console.log(o.message)))}),(o=>console.log(o.message)))}break;default:P[0]&&console.log("unknown command"),help()}updateConfig()}})();
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hackmud-script-manager",
|
3
|
-
"version": "0.14.0-
|
3
|
+
"version": "0.14.0-66846c3",
|
4
4
|
"description": "Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.",
|
5
5
|
"keywords": [
|
6
6
|
"api",
|
@@ -68,7 +68,7 @@
|
|
68
68
|
"devDependencies": {
|
69
69
|
"@babel/preset-env": "^7.16.4",
|
70
70
|
"@babel/preset-typescript": "^7.16.0",
|
71
|
-
"@samual/lib": "^0.
|
71
|
+
"@samual/lib": "^0.2.2",
|
72
72
|
"@types/babel__core": "^7.1.16",
|
73
73
|
"@types/node": "^12.20.37",
|
74
74
|
"@types/prettier": "^2.4.2",
|