diff --git a/OAT.xml b/OAT.xml index 5ca9b26..e147fe5 100644 --- a/OAT.xml +++ b/OAT.xml @@ -65,6 +65,14 @@ desc="self developed image"/> + + + + + + + + ="a"&&u<="z"||u>="A"&&u<="Z"||"$"===u||"_"===u||y.Unicode.ID_START.test(u))}static isIdContinueChar(u){return"string"==typeof u&&(u>="a"&&u<="z"||u>="A"&&u<="Z"||u>="0"&&u<="9"||"$"===u||"_"===u||"‌"===u||"‍"===u||y.Unicode.ID_CONTINUE.test(u))}static isDigitWithoutZero(u){return/[1-9]/.test(u)}static isDigit(u){return"string"==typeof u&&/[0-9]/.test(u)}static isHexDigit(u){return"string"==typeof u&&/[0-9A-Fa-f]/.test(u)}};var I=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(v,"__esModule",{value:!0}),v.parseJsonText=v.parseJsonFile=void 0;const N=I(e),b=I(D),S=I(u),w=g;var H;!function(u){u[u.Char=0]="Char",u[u.EOF=1]="EOF",u[u.Identifier=2]="Identifier"}(H||(H={}));let x,M,T,V,G,j,J="start",U=[],W=0,L=1,$=0,k=!1,K="default",z="'",q=1;function Z(u,D=!1){M=String(u),J="start",U=[],W=0,L=1,$=0,V=void 0,k=D;do{x=X(),ru[J]()}while("eof"!==x.type);return V}function X(){for(K="default",G="",z="'",q=1;;){j=Q();const u=uu[K]();if(u)return u}}function Q(){if(M[W])return String.fromCodePoint(M.codePointAt(W))}function Y(){const u=Q();return"\n"===u?(L++,$=0):u?$+=u.length:$++,u&&(W+=u.length),u}v.parseJsonFile=function(u,D=!1,e="utf-8"){const t=N.default.readFileSync(S.default.resolve(u),{encoding:e});try{return Z(t,D)}catch(D){if(D instanceof SyntaxError){const e=D.message.split("at");if(2===e.length)throw new Error(`${e[0].trim()}${b.default.EOL}\t at ${u}:${e[1].trim()}`)}throw new Error(`${u} is not in valid JSON/JSON5 format.`)}},v.parseJsonText=Z;const uu={default(){switch(j){case"/":return Y(),void(K="comment");case void 0:return Y(),Du("eof")}if(!w.JudgeUtil.isIgnoreChar(j)&&!w.JudgeUtil.isSpaceSeparator(j))return uu[J]();Y()},start(){K="value"},beforePropertyName(){switch(j){case"$":case"_":return G=Y(),void(K="identifierName");case"\\":return Y(),void(K="identifierNameStartEscape");case"}":return Du("punctuator",Y());case'"':case"'":return z=j,Y(),void(K="string")}if(w.JudgeUtil.isIdStartChar(j))return G+=Y(),void(K="identifierName");throw Fu(H.Char,Y())},afterPropertyName(){if(":"===j)return Du("punctuator",Y());throw Fu(H.Char,Y())},beforePropertyValue(){K="value"},afterPropertyValue(){switch(j){case",":case"}":return Du("punctuator",Y())}throw Fu(H.Char,Y())},beforeArrayValue(){if("]"===j)return Du("punctuator",Y());K="value"},afterArrayValue(){switch(j){case",":case"]":return Du("punctuator",Y())}throw Fu(H.Char,Y())},end(){throw Fu(H.Char,Y())},comment(){switch(j){case"*":return Y(),void(K="multiLineComment");case"/":return Y(),void(K="singleLineComment")}throw Fu(H.Char,Y())},multiLineComment(){switch(j){case"*":return Y(),void(K="multiLineCommentAsterisk");case void 0:throw Fu(H.Char,Y())}Y()},multiLineCommentAsterisk(){switch(j){case"*":return void Y();case"/":return Y(),void(K="default");case void 0:throw Fu(H.Char,Y())}Y(),K="multiLineComment"},singleLineComment(){switch(j){case"\n":case"\r":case"\u2028":case"\u2029":return Y(),void(K="default");case void 0:return Y(),Du("eof")}Y()},value(){switch(j){case"{":case"[":return Du("punctuator",Y());case"n":return Y(),eu("ull"),Du("null",null);case"t":return Y(),eu("rue"),Du("boolean",!0);case"f":return Y(),eu("alse"),Du("boolean",!1);case"-":case"+":return"-"===Y()&&(q=-1),void(K="numerical");case".":case"0":case"I":case"N":return void(K="numerical");case'"':case"'":return z=j,Y(),G="",void(K="string")}if(void 0===j||!w.JudgeUtil.isDigitWithoutZero(j))throw Fu(H.Char,Y());K="numerical"},numerical(){switch(j){case".":return G=Y(),void(K="decimalPointLeading");case"0":return G=Y(),void(K="zero");case"I":return Y(),eu("nfinity"),Du("numeric",q*(1/0));case"N":return Y(),eu("aN"),Du("numeric",NaN)}if(void 0!==j&&w.JudgeUtil.isDigitWithoutZero(j))return G=Y(),void(K="decimalInteger");throw Fu(H.Char,Y())},zero(){switch(j){case".":case"e":case"E":return void(K="decimal");case"x":case"X":return G+=Y(),void(K="hexadecimal")}return Du("numeric",0)},decimalInteger(){switch(j){case".":case"e":case"E":return void(K="decimal")}if(!w.JudgeUtil.isDigit(j))return Du("numeric",q*Number(G));G+=Y()},decimal(){switch(j){case".":G+=Y(),K="decimalFraction";break;case"e":case"E":G+=Y(),K="decimalExponent"}},decimalPointLeading(){if(w.JudgeUtil.isDigit(j))return G+=Y(),void(K="decimalFraction");throw Fu(H.Char,Y())},decimalFraction(){switch(j){case"e":case"E":return G+=Y(),void(K="decimalExponent")}if(!w.JudgeUtil.isDigit(j))return Du("numeric",q*Number(G));G+=Y()},decimalExponent(){switch(j){case"+":case"-":return G+=Y(),void(K="decimalExponentSign")}if(w.JudgeUtil.isDigit(j))return G+=Y(),void(K="decimalExponentInteger");throw Fu(H.Char,Y())},decimalExponentSign(){if(w.JudgeUtil.isDigit(j))return G+=Y(),void(K="decimalExponentInteger");throw Fu(H.Char,Y())},decimalExponentInteger(){if(!w.JudgeUtil.isDigit(j))return Du("numeric",q*Number(G));G+=Y()},hexadecimal(){if(w.JudgeUtil.isHexDigit(j))return G+=Y(),void(K="hexadecimalInteger");throw Fu(H.Char,Y())},hexadecimalInteger(){if(!w.JudgeUtil.isHexDigit(j))return Du("numeric",q*Number(G));G+=Y()},identifierNameStartEscape(){if("u"!==j)throw Fu(H.Char,Y());Y();const u=tu();switch(u){case"$":case"_":break;default:if(!w.JudgeUtil.isIdStartChar(u))throw Fu(H.Identifier)}G+=u,K="identifierName"},identifierName(){switch(j){case"$":case"_":case"‌":case"‍":return void(G+=Y());case"\\":return Y(),void(K="identifierNameEscape")}if(!w.JudgeUtil.isIdContinueChar(j))return Du("identifier",G);G+=Y()},identifierNameEscape(){if("u"!==j)throw Fu(H.Char,Y());Y();const u=tu();switch(u){case"$":case"_":case"‌":case"‍":break;default:if(!w.JudgeUtil.isIdContinueChar(u))throw Fu(H.Identifier)}G+=u,K="identifierName"},string(){switch(j){case"\\":return Y(),void(G+=function(){const u=Q(),D=function(){switch(Q()){case"b":return Y(),"\b";case"f":return Y(),"\f";case"n":return Y(),"\n";case"r":return Y(),"\r";case"t":return Y(),"\t";case"v":return Y(),"\v"}return}();if(D)return D;switch(u){case"0":if(Y(),w.JudgeUtil.isDigit(Q()))throw Fu(H.Char,Y());return"\0";case"x":return Y(),function(){let u="",D=Q();if(!w.JudgeUtil.isHexDigit(D))throw Fu(H.Char,Y());if(u+=Y(),D=Q(),!w.JudgeUtil.isHexDigit(D))throw Fu(H.Char,Y());return u+=Y(),String.fromCodePoint(parseInt(u,16))}();case"u":return Y(),tu();case"\n":case"\u2028":case"\u2029":return Y(),"";case"\r":return Y(),"\n"===Q()&&Y(),""}if(void 0===u||w.JudgeUtil.isDigitWithoutZero(u))throw Fu(H.Char,Y());return Y()}());case'"':case"'":if(j===z){const u=Du("string",G);return Y(),u}return void(G+=Y());case"\n":case"\r":case void 0:throw Fu(H.Char,Y());case"\u2028":case"\u2029":!function(u){console.warn(`JSON5: '${Cu(u)}' in strings is not valid ECMAScript; consider escaping.`)}(j)}G+=Y()}};function Du(u,D){return{type:u,value:D,line:L,column:$}}function eu(u){for(const D of u){if(Q()!==D)throw Fu(H.Char,Y());Y()}}function tu(){let u="",D=4;for(;D-- >0;){const D=Q();if(!w.JudgeUtil.isHexDigit(D))throw Fu(H.Char,Y());u+=Y()}return String.fromCodePoint(parseInt(u,16))}const ru={start(){if("eof"===x.type)throw Fu(H.EOF);nu()},beforePropertyName(){switch(x.type){case"identifier":case"string":return T=x.value,void(J="afterPropertyName");case"punctuator":return void iu();case"eof":throw Fu(H.EOF)}},afterPropertyName(){if("eof"===x.type)throw Fu(H.EOF);J="beforePropertyValue"},beforePropertyValue(){if("eof"===x.type)throw Fu(H.EOF);nu()},afterPropertyValue(){if("eof"===x.type)throw Fu(H.EOF);switch(x.value){case",":return void(J="beforePropertyName");case"}":iu()}},beforeArrayValue(){if("eof"===x.type)throw Fu(H.EOF);"punctuator"!==x.type||"]"!==x.value?nu():iu()},afterArrayValue(){if("eof"===x.type)throw Fu(H.EOF);switch(x.value){case",":return void(J="beforeArrayValue");case"]":iu()}},end(){}};function nu(){const u=function(){let u;switch(x.type){case"punctuator":switch(x.value){case"{":u={};break;case"[":u=[]}break;case"null":case"boolean":case"numeric":case"string":u=x.value}return u}();if(k&&"object"==typeof u&&(u._line=L,u._column=$),void 0===V)V=u;else{const D=U[U.length-1];Array.isArray(D)?k&&"object"!=typeof u?D.push({value:u,_line:L,_column:$}):D.push(u):D[T]=k&&"object"!=typeof u?{value:u,_line:L,_column:$}:u}!function(u){if(u&&"object"==typeof u)U.push(u),J=Array.isArray(u)?"beforeArrayValue":"beforePropertyName";else{const u=U[U.length-1];J=u?Array.isArray(u)?"afterArrayValue":"afterPropertyValue":"end"}}(u)}function iu(){U.pop();const u=U[U.length-1];J=u?Array.isArray(u)?"afterArrayValue":"afterPropertyValue":"end"}function Cu(u){const D={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(D[u])return D[u];if(u<" "){const D=u.charCodeAt(0).toString(16);return`\\x${`00${D}`.substring(D.length)}`}return u}function Fu(u,D){let e="";switch(u){case H.Char:e=void 0===D?`JSON5: invalid end of input at ${L}:${$}`:`JSON5: invalid character '${Cu(D)}' at ${L}:${$}`;break;case H.EOF:e=`JSON5: invalid end of input at ${L}:${$}`;break;case H.Identifier:$-=5,e=`JSON5: invalid identifier character at ${L}:${$}`}const t=new Eu(e);return t.lineNumber=L,t.columnNumber=$,t}class Eu extends SyntaxError{}var Au={},ou=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),au=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),cu=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&ou(D,u,e);return au(D,u),D},su=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(Au,"__esModule",{value:!0}),Au.isFileExists=Au.offlinePluginConversion=Au.executeCommand=Au.getNpmPath=Au.hasNpmPackInPaths=void 0;const lu=t,Bu=su(e),du=cu(u),fu=i,_u=l;Au.hasNpmPackInPaths=function(u,D){try{return require.resolve(u,{paths:[...D]}),!0}catch(u){return!1}},Au.getNpmPath=function(){const u=process.execPath;return du.join(du.dirname(u),fu.NPM_TOOL)},Au.executeCommand=function(u,D,e){0!==(0,lu.spawnSync)(u,D,e).status&&(0,_u.logErrorAndExit)(`Error: ${u} ${D} execute failed.See above for details.`)},Au.offlinePluginConversion=function(u,D){return D.startsWith("file:")||D.endsWith(".tgz")?du.resolve(u,fu.HVIGOR,D.replace("file:","")):D},Au.isFileExists=function(u){return Bu.default.existsSync(u)&&Bu.default.statSync(u).isFile()};var pu={};!function(u){var D=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(u,"__esModule",{value:!0}),u.hashFile=u.hash=u.createHash=void 0;const t=D(r),i=D(e);u.createHash=(u="MD5")=>t.default.createHash(u);u.hash=(D,e)=>(0,u.createHash)(e).update(D).digest("hex");u.hashFile=(D,e)=>{if(i.default.existsSync(D))return(0,u.hash)(i.default.readFileSync(D,"utf-8"),e)}}(pu);var Ou=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),hu=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),Pu=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&Ou(D,u,e);return hu(D,u),D},vu=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(P,"__esModule",{value:!0});var gu=P.initProjectWorkSpace=void 0;const mu=Pu(e),Ru=Pu(u),yu=i,Iu=v,Nu=l,bu=Au,Su=vu(D),wu=pu;let Hu,xu,Mu;function Tu(u,D,e){return void 0!==e.dependencies&&(0,bu.offlinePluginConversion)(yu.HVIGOR_PROJECT_ROOT_DIR,D.dependencies[u])===Ru.normalize(e.dependencies[u])}function Vu(){const u=Ru.join(Mu,yu.WORK_SPACE);if((0,Nu.logInfoPrintConsole)("Hvigor cleaning..."),!mu.existsSync(u))return;const D=mu.readdirSync(u);if(!D||0===D.length)return;const e=Ru.resolve(Mu,"node_modules","@ohos","hvigor","bin","hvigor.js");mu.existsSync(e)&&(0,bu.executeCommand)(process.argv[0],[e,"--stop-daemon"],{});try{D.forEach((D=>{mu.rmSync(Ru.resolve(u,D),{recursive:!0})}))}catch(D){(0,Nu.logErrorAndExit)(`The hvigor build tool cannot be installed. Please manually clear the workspace directory and synchronize the project again.\n\n Workspace Path: ${u}.`)}}gu=P.initProjectWorkSpace=function(){if(Hu=function(){const u=Ru.resolve(yu.HVIGOR_PROJECT_WRAPPER_HOME,yu.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME);mu.existsSync(u)||(0,Nu.logErrorAndExit)(`Error: Hvigor config file ${u} does not exist.`);return(0,Iu.parseJsonFile)(u)}(),Mu=function(u){let D,e=u.hvigorVersion;e.endsWith(".tgz")&&(e=function(u){let D=Ru.normalize(u);const e=D.lastIndexOf(Ru.sep);-1!==e&&(D=D.substring(e+1));D=D.replace(".tgz","");let t=0;for(let u=0;u="0"&&D.charAt(u)<="9"){t=u;break}return D=D.substring(t),D}(e));D=e>"2.5.0"?function(u){let D=`${yu.HVIGOR_ENGINE_PACKAGE_NAME}@${u.hvigorVersion}`;const e=u.dependencies;if(e){Object.getOwnPropertyNames(e).sort().forEach((u=>{D+=`,${u}@${e[u]}`}))}return(0,wu.hash)(D)}(u):(0,wu.hash)(process.cwd());return Ru.resolve(Su.default.homedir(),".hvigor","project_caches",D)}(Hu),xu=function(){const u=Ru.resolve(Mu,yu.WORK_SPACE,yu.DEFAULT_PACKAGE_JSON);return mu.existsSync(u)?(0,Iu.parseJsonFile)(u):{dependencies:{}}}(),!(0,bu.hasNpmPackInPaths)(yu.HVIGOR_ENGINE_PACKAGE_NAME,[Ru.join(Mu,yu.WORK_SPACE)])||(0,bu.offlinePluginConversion)(yu.HVIGOR_PROJECT_ROOT_DIR,Hu.hvigorVersion)!==xu.dependencies[yu.HVIGOR_ENGINE_PACKAGE_NAME]||!function(){function u(u){const D=null==u?void 0:u.dependencies;return void 0===D?0:Object.getOwnPropertyNames(D).length}const D=u(Hu),e=u(xu);if(D+1!==e)return!1;for(const u in null==Hu?void 0:Hu.dependencies)if(!(0,bu.hasNpmPackInPaths)(u,[Ru.join(Mu,yu.WORK_SPACE)])||!Tu(u,Hu,xu))return!1;return!0}()){Vu();try{!function(){(0,Nu.logInfoPrintConsole)("Hvigor installing...");for(const u in Hu.dependencies)Hu.dependencies[u]&&(Hu.dependencies[u]=(0,bu.offlinePluginConversion)(yu.HVIGOR_PROJECT_ROOT_DIR,Hu.dependencies[u]));const u={dependencies:{...Hu.dependencies}};u.dependencies[yu.HVIGOR_ENGINE_PACKAGE_NAME]=(0,bu.offlinePluginConversion)(yu.HVIGOR_PROJECT_ROOT_DIR,Hu.hvigorVersion);const D=Ru.join(Mu,yu.WORK_SPACE);try{mu.mkdirSync(D,{recursive:!0});const e=Ru.resolve(D,yu.DEFAULT_PACKAGE_JSON);mu.writeFileSync(e,JSON.stringify(u))}catch(u){(0,Nu.logErrorAndExit)(u)}(function(){const u=["config","set","store-dir",yu.HVIGOR_PNPM_STORE_PATH],D={cwd:Ru.join(Mu,yu.WORK_SPACE),stdio:["inherit","inherit","inherit"]};(0,bu.executeCommand)(yu.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,u,D)})(),function(){const u=["install"],D={cwd:Ru.join(Mu,yu.WORK_SPACE),stdio:["inherit","inherit","inherit"]};(0,bu.executeCommand)(yu.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,u,D)}(),(0,Nu.logInfoPrintConsole)("Hvigor install success.")}()}catch(u){Vu()}}return Mu};var Gu={};!function(r){var C=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),F=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),E=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&C(D,u,e);return F(D,u),D},A=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(r,"__esModule",{value:!0}),r.executeInstallPnpm=r.isPnpmInstalled=r.environmentHandler=r.checkNpmConifg=r.PNPM_VERSION=void 0;const o=t,a=E(e),c=A(D),s=E(u),B=i,d=l,f=Au;r.PNPM_VERSION="7.30.0",r.checkNpmConifg=function(){const u=s.resolve(B.HVIGOR_PROJECT_ROOT_DIR,".npmrc"),D=s.resolve(c.default.homedir(),".npmrc");if((0,f.isFileExists)(u)||(0,f.isFileExists)(D))return;const e=(0,f.getNpmPath)(),t=(0,o.spawnSync)(e,["config","get","prefix"],{cwd:B.HVIGOR_PROJECT_ROOT_DIR});if(0!==t.status||!t.stdout)return void(0,d.logErrorAndExit)("Error: The hvigor depends on the npmrc file. Configure the npmrc file first.");const r=s.resolve(`${t.stdout}`.replace(/[\r\n]/gi,""),".npmrc");(0,f.isFileExists)(r)||(0,d.logErrorAndExit)("Error: The hvigor depends on the npmrc file. Configure the npmrc file first.")},r.environmentHandler=function(){process.env["npm_config_update-notifier"]="false"},r.isPnpmInstalled=function(){return!!a.existsSync(B.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH)&&(0,f.hasNpmPackInPaths)("pnpm",[B.HVIGOR_WRAPPER_TOOLS_HOME])},r.executeInstallPnpm=function(){(0,d.logInfoPrintConsole)(`Installing pnpm@${r.PNPM_VERSION}...`);const u=(0,f.getNpmPath)();!function(){const u=s.resolve(B.HVIGOR_WRAPPER_TOOLS_HOME,B.DEFAULT_PACKAGE_JSON);try{a.existsSync(B.HVIGOR_WRAPPER_TOOLS_HOME)||a.mkdirSync(B.HVIGOR_WRAPPER_TOOLS_HOME,{recursive:!0});const D={dependencies:{}};D.dependencies[B.PNPM]=r.PNPM_VERSION,a.writeFileSync(u,JSON.stringify(D))}catch(D){(0,d.logErrorAndExit)(`Error: EPERM: operation not permitted,create ${u} failed.`)}}(),(0,f.executeCommand)(u,["install","pnpm"],{cwd:B.HVIGOR_WRAPPER_TOOLS_HOME,stdio:["inherit","inherit","inherit"],env:process.env}),(0,d.logInfoPrintConsole)("Pnpm install success.")}}(Gu),function(){Gu.checkNpmConifg(),Gu.environmentHandler(),Gu.isPnpmInstalled()||Gu.executeInstallPnpm();const D=gu();_(u.join(D,i.WORK_SPACE))}(); \ No newline at end of file diff --git a/hvigorw b/hvigorw new file mode 100644 index 0000000..ff6a29a --- /dev/null +++ b/hvigorw @@ -0,0 +1,48 @@ +#!/bin/bash + +# ---------------------------------------------------------------------------- +# Hvigor startup script, version 1.0.0 +# +# Required ENV vars: +# ------------------ +# NODE_HOME - location of a Node home dir +# or +# Add /usr/local/nodejs/bin to the PATH environment variable +# ---------------------------------------------------------------------------- + +HVIGOR_APP_HOME="`pwd -P`" +HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js +warn() { + echo "" + echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" +} + +error() { + echo "" + echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" +} + +fail() { + error "$@" + exit 1 +} + +# Determine node to start hvigor wrapper script +if [ -n "${NODE_HOME}" ];then + EXECUTABLE_NODE="${NODE_HOME}/bin/node" + if [ ! -x "$EXECUTABLE_NODE" ];then + fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed" + fi +else + EXECUTABLE_NODE="node" + which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path" +fi + +# Check hvigor wrapper script +if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then + fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}" +fi + +# start hvigor-wrapper script +exec "${EXECUTABLE_NODE}" \ + "${HVIGOR_WRAPPER_SCRIPT}" "$@" diff --git a/hvigorw.bat b/hvigorw.bat new file mode 100644 index 0000000..d570007 --- /dev/null +++ b/hvigorw.bat @@ -0,0 +1,64 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Hvigor startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js +set NODE_EXE=node.exe + +goto start + +:start +@rem Find node.exe +if defined NODE_HOME goto findNodeFromNodeHome + +%NODE_EXE% --version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. +echo. +echo Please set the NODE_HOME variable in your environment to match the +echo location of your NodeJs installation. + +goto fail + +:findNodeFromNodeHome +set NODE_HOME=%NODE_HOME:"=% +set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE% + +if exist "%NODE_EXE_PATH%" goto execute +echo. +echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. +echo. +echo Please set the NODE_HOME variable in your environment to match the +echo location of your NodeJs installation. + +goto fail + +:execute +@rem Execute hvigor +"%NODE_EXE%" "%WRAPPER_MODULE_PATH%" %* + +if "%ERRORLEVEL%" == "0" goto hvigorwEnd + +:fail +exit /b 1 + +:hvigorwEnd +if "%OS%" == "Windows_NT" endlocal + +:end