@oracle/oraclejet-audit 19.0.4 → 20.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corePackMigrator/resource/htmlUtils.js +1 -1
- package/jaf-amd.js +1 -1
- package/lib/AST_Ts.js +1 -1
- package/lib/checkage.js +1 -1
- package/lib/defaults.js +1 -1
- package/lib/ns.js +1 -1
- package/lib/scaffold.js +1 -1
- package/meta/19.0.0/jetauditmeta.js +1 -1
- package/meta/20.0.0/jetauditmeta.js +9 -0
- package/meta/metaverlist.json +1 -1
- package/package.json +2 -2
- package/rulepacks/jetwc/jetwc-css-scoping.js +1 -1
- package/rulepacks/jetwc/rules.json +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-componentFinder.js +1 -1
- package/rulepacks/jetwc-lib/jetwcutils-tsxUtils.js +1 -1
- package/rules/jet/msgid.json +1 -1
- package/rules/jet/oj-html-ojoption-text.js +1 -1
- package/rules/jet/rules.json +1 -1
package/lib/AST_Ts.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const NT=require("./AstNodeTypes");const Scope=require("./Scope");const COMMON_DOC_METHODS={"getElementsByClassName":true,"getElementsByTagName":true,"getElementsByTagNameNS":true,"getElementById":true,"getElementsByName":true,"querySelector":true,"querySelectorAll":true,"createElement":true,"createElementNS":true};const LOC="loc";const RANGE="range";const PARENT="parent";const TSXFUNCTION="TsxFunction";var AST=function(data,file,fileType,nd,ecmaVer,comments,msgCtx,config){var opts={ecmaVersion:ecmaVer,comment:comments};if(fileType==="tsx"){opts.jsx=true;opts.comment=true}opts.loc=true;opts.range=true;opts.errorOnUnknownASTType=true;opts.project="D:/vsprojects/JetAuditDev/tsconfig/tsconfig.json";this._ast=nd.tsparse.parse(data,opts);this._data=data;this._file=file;this._fileType=fileType;this._tlib=null;this._scope=null;this._utils=null;this._program=null;this._isComments=comments;this._msgCtx=msgCtx;this._config=config;this._nd=nd};AST.prototype.walk=function(callback){try{this._walkAddParent(callback)}catch(e){console.log(`JAF internal TS/TSX WALK ERROR: ${e}`)}};AST.prototype.getAst=function(){return this._ast};AST.prototype.getFilePath=function(){return this._file};AST.prototype.getFileType=function(){return this._fileTpe};AST.prototype.getRawComments=function(){return this._ast.comments};AST.prototype.getNodeFromIndex=function(index){return _getNodeFromIndex2(this._ast,index)};function _getNodeFromIndex2(node,index){var body,n,i,ret=null;if(!node){return null}if(index===node.range[0]){return node}if(index<node.range[0]||index>node.range[1]){return null}if(node.body){body=node.body;if(Array.isArray(body)){for(i=0;i<body.length;i++){n=body[i];if(index<n.range[0]){ret=n}else{ret=_getNodeFromIndex2(n,index)}if(ret){if(ret===-1){ret=null}break}}}else{ret=_getNodeFromIndex2(body,index);if(ret){if(ret===-1){ret=null}}}}else{if(node.type===NT.IF_STMT){ret=_getNodeFromIndex2(node.consequent,index)}else{ret=node}}return ret};AST.prototype.extractNamedFuncs=function(){let body,node,decls,fname,func;if(!(body=this._ast.body)){return}body.forEach((node,b)=>{if(node.type===NT.VAR_DECLARATION&&(decls=node.declarations)){decls.forEach(decl=>{if(fname=decl.id?.name){if(decl.init?.type===NT.ARROW_FUNC_EXPR){if(!this._namedFuncs){this._namedFuncs=[]}let func={type:TSXFUNCTION,name:fname,node:decl.init,body:decl.init.body,range:decl.init.range};this._namedFuncs.push(func);if(func.body?.type===NT.BLOCK_STMT&&func.body.body){func.returns=[];func.body.body.forEach(stmt=>{if(stmt.type===NT.RETURN_STMT){func.returns.push({node:stmt})}})}};}})}else if(node.type===NT.FUNC_DECLARATION&&(body=node.body)){if(node?.id.type===NT.IDENTIFIER&&node.body.body){if(!this._namedFuncs){this._namedFuncs=[]}func={type:TSXFUNCTION,name:node.id.name,node:node,body:node.body,range:node.range};this._namedFuncs.push(func);node.body.body.forEach(stmt=>{if(stmt.type===NT.RETURN_STMT){if(!func.returns){func.returns=[]}func.returns.push({node:stmt})}})}}});return this._namedFuncs};AST.prototype.getUtils=function(){if(!this._utils){this._utils={getBlock:this.getBlock.bind(this),getBody:this.getBody.bind(this),getProgram:this.getProgram.bind(this),getContainingFunctionName:this.getContainingFunctionName.bind(this),isFuncArg:this.isFuncArg.bind(this),getScopes:this._createVarScopes.bind(this),getNodeTypes:_getNodeTypes,isCommonDocApi:this.isCommonDocApi,parseDefine:this.parseDefine.bind(this),parseImport:this.parseImport.bind(this)}}return this._utils};function _getNodeTypes(){return NT};AST.prototype.getBlock=function(node){var block;if(!node){if(!this._program){node=this._ast;if(node.type!==NT.PROGRAM){node=null}this._program=node}else{node=this._program}block=node}else{while(node){if(node.type){if(node.type===NT.BLOCK_STMT||node.type===NT.PROGRAM){block=node;break}}node=node.parent}}return block};AST.prototype.getBody=function(node){var block=this.getBlock(node);return block?block.body:block};AST.prototype.getFunctionBody=function(node){var block;if(!node){if(!this._program){node=this._ast;if(node.type!==NT.PROGRAM){node=null}this._program=node}else{node=this._program}block=node}else{while(node){if(node.type){if(node.type===NT.FUNC_DECLARATION||node.type===NT.PROGRAM){block=node;break}}node=node.parent}}return block};AST.prototype.getProgram=function(){return this._ast.type===NT.PROGRAM?this._ast:null};AST.prototype.getContainingFunctionName=function(node){var body=this.getFunctionBody(node);return body&&body.id?body.id.name:undefined};AST.prototype._createVarScopes=function(){if(!this._scope){this._scope=new Scope(this._msgCtx,this._config,this._file,this._nd);this._scopeStacks=this._scope.build(this._ast);this._accessor=this._scope.getAccessor()}return this._accessor};AST.prototype.getData=function(){return this._data};AST.prototype.isFuncArg=function(node,varName){var args,arg,n,j,ret=false;var n=node;while(n.type&&n.type!==NT.FUNC_DECLARATION){n=n.parent;if(!n||!n.type){n=null;break}}if(n){args=n.params;for(j=0;j<args.length;j++){arg=args[j];if(arg.type===NT.IDENTIFIER){if(arg.name===varName){ret=true;break}}}}return ret};AST.prototype.isCommonDocApi=function(method){return COMMON_DOC_METHODS[method]};AST.prototype.parseDefine=function(node,obj){var modules,names,len,i;if(!node.arguments||node.arguments.length<2){return null}modules=node.arguments[0].elements;names=node.arguments[1].params;obj=obj||null;if(modules&&names&&modules.length){len=Math.min(modules.length,names.length);obj=obj?obj:{};for(i=0;i<len;i++){obj[names[i].name]=modules[i].value}}return obj};AST.prototype.parseImport=function(node,obj){var source,specifiers,spec,name,i;obj=obj||{};source=node.source&&node.source.value;if(node.specifiers){specifiers=node.specifiers;for(var i=0;i<specifiers.length;i++){spec=specifiers[i];if((spec.type===NT.IMPORT_DEF_SPECIFIER||spec.type===NT.IMPORT_SPECIFIER)&&spec.local){name=spec.local.name;obj[name]=source}}}return obj};AST.prototype._walkAddParent=function(fn){var stack=[this._ast],i,j,key,len,node,child,subchild;for(i=0;i<stack.length;i+=1){node=stack[i];if(node.type==="Line"||node.type===NT.EMPTY_STMT){continue}fn(node);for(key in node){if(key!==PARENT){if(key===RANGE||key===LOC){continue}child=node[key];if(child instanceof Array){for(j=0,len=child.length;j<len;j+=1){subchild=child[j];if(subchild){subchild.parent=node;stack.push(subchild)}}}else if(child!=void 0&&typeof child.type==="string"){child.parent=node;stack.push(child)}}}}};module.exports=AST;
|
|
6
|
+
const NT=require("./AstNodeTypes");const Scope=require("./Scope");const COMMON_DOC_METHODS={"getElementsByClassName":true,"getElementsByTagName":true,"getElementsByTagNameNS":true,"getElementById":true,"getElementsByName":true,"querySelector":true,"querySelectorAll":true,"createElement":true,"createElementNS":true};const LOC="loc";const RANGE="range";const PARENT="parent";const TSXFUNCTION="TsxFunction";var AST=function(data,file,fileType,nd,ecmaVer,comments,msgCtx,config){var opts={ecmaVersion:ecmaVer,comment:comments};if(fileType==="tsx"){opts.jsx=true;opts.comment=true}opts.loc=true;opts.range=true;opts.errorOnUnknownASTType=true;opts.project="D:/vsprojects/JetAuditDev/tsconfig/tsconfig.json";this._ast=nd.tsparse.parse(data,opts);this._data=data;this._file=file;this._fileType=fileType;this._tlib=null;this._scope=null;this._utils=null;this._program=null;this._isComments=comments;this._msgCtx=msgCtx;this._config=config;this._nd=nd};AST.prototype.walk=function(callback){try{this._walkAddParent(callback)}catch(e){console.log(`JAF internal TS/TSX WALK ERROR: ${e}`)}};AST.prototype.getAst=function(){return this._ast};AST.prototype.getFilePath=function(){return this._file};AST.prototype.getFileType=function(){return this._fileTpe};AST.prototype.getRawComments=function(){return this._ast.comments};AST.prototype.getNodeFromIndex=function(index){return _getNodeFromIndex2(this._ast,index)};function _getNodeFromIndex2(node,index){var body,n,i,ret=null;if(!node){return null}if(index===node.range[0]){return node}if(index<node.range[0]||index>node.range[1]){return null}if(node.body){body=node.body;if(Array.isArray(body)){for(i=0;i<body.length;i++){n=body[i];if(index<n.range[0]){ret=n}else{ret=_getNodeFromIndex2(n,index)}if(ret){if(ret===-1){ret=null}break}}}else{ret=_getNodeFromIndex2(body,index);if(ret){if(ret===-1){ret=null}}}}else{if(node.type===NT.IF_STMT){ret=_getNodeFromIndex2(node.consequent,index)}else{ret=node}}return ret};AST.prototype.extractNamedFuncs=function(){let body,node,decls,fname,func;if(!(body=this._ast.body)){return}body.forEach((node,b)=>{if(node.type===NT.VAR_DECLARATION&&(decls=node.declarations)||node.type===NT.EXPORT_NAMED_DECL&&(decls=node.declaration.declarations)){decls.forEach(decl=>{if(fname=decl.id?.name){if(decl.init?.type===NT.ARROW_FUNC_EXPR){if(!this._namedFuncs){this._namedFuncs=[]}let func={type:TSXFUNCTION,name:fname,node:decl.init,body:decl.init.body,range:decl.init.range};this._namedFuncs.push(func);if(func.body?.type===NT.BLOCK_STMT&&func.body.body){func.returns=[];func.body.body.forEach(stmt=>{if(stmt.type===NT.RETURN_STMT){func.returns.push({node:stmt})}})}};}})}else if(node.type===NT.FUNC_DECLARATION&&(body=node.body)){if(node?.id.type===NT.IDENTIFIER&&node.body.body){if(!this._namedFuncs){this._namedFuncs=[]}func={type:TSXFUNCTION,name:node.id.name,node:node,body:node.body,range:node.range};this._namedFuncs.push(func);node.body.body.forEach(stmt=>{if(stmt.type===NT.RETURN_STMT){if(!func.returns){func.returns=[]}func.returns.push({node:stmt})}})}}});return this._namedFuncs};AST.prototype.getUtils=function(){if(!this._utils){this._utils={getBlock:this.getBlock.bind(this),getBody:this.getBody.bind(this),getProgram:this.getProgram.bind(this),getContainingFunctionName:this.getContainingFunctionName.bind(this),isFuncArg:this.isFuncArg.bind(this),getScopes:this._createVarScopes.bind(this),getNodeTypes:_getNodeTypes,isCommonDocApi:this.isCommonDocApi,parseDefine:this.parseDefine.bind(this),parseImport:this.parseImport.bind(this)}}return this._utils};function _getNodeTypes(){return NT};AST.prototype.getBlock=function(node){var block;if(!node){if(!this._program){node=this._ast;if(node.type!==NT.PROGRAM){node=null}this._program=node}else{node=this._program}block=node}else{while(node){if(node.type){if(node.type===NT.BLOCK_STMT||node.type===NT.PROGRAM){block=node;break}}node=node.parent}}return block};AST.prototype.getBody=function(node){var block=this.getBlock(node);return block?block.body:block};AST.prototype.getFunctionBody=function(node){var block;if(!node){if(!this._program){node=this._ast;if(node.type!==NT.PROGRAM){node=null}this._program=node}else{node=this._program}block=node}else{while(node){if(node.type){if(node.type===NT.FUNC_DECLARATION||node.type===NT.PROGRAM){block=node;break}}node=node.parent}}return block};AST.prototype.getProgram=function(){return this._ast.type===NT.PROGRAM?this._ast:null};AST.prototype.getContainingFunctionName=function(node){var body=this.getFunctionBody(node);return body&&body.id?body.id.name:undefined};AST.prototype._createVarScopes=function(){if(!this._scope){this._scope=new Scope(this._msgCtx,this._config,this._file,this._nd);this._scopeStacks=this._scope.build(this._ast);this._accessor=this._scope.getAccessor()}return this._accessor};AST.prototype.getData=function(){return this._data};AST.prototype.isFuncArg=function(node,varName){var args,arg,n,j,ret=false;var n=node;while(n.type&&n.type!==NT.FUNC_DECLARATION){n=n.parent;if(!n||!n.type){n=null;break}}if(n){args=n.params;for(j=0;j<args.length;j++){arg=args[j];if(arg.type===NT.IDENTIFIER){if(arg.name===varName){ret=true;break}}}}return ret};AST.prototype.isCommonDocApi=function(method){return COMMON_DOC_METHODS[method]};AST.prototype.parseDefine=function(node,obj){var modules,names,len,i;if(!node.arguments||node.arguments.length<2){return null}modules=node.arguments[0].elements;names=node.arguments[1].params;obj=obj||null;if(modules&&names&&modules.length){len=Math.min(modules.length,names.length);obj=obj?obj:{};for(i=0;i<len;i++){obj[names[i].name]=modules[i].value}}return obj};AST.prototype.parseImport=function(node,obj){var source,specifiers,spec,name,i;obj=obj||{};source=node.source&&node.source.value;if(node.specifiers){specifiers=node.specifiers;for(var i=0;i<specifiers.length;i++){spec=specifiers[i];if((spec.type===NT.IMPORT_DEF_SPECIFIER||spec.type===NT.IMPORT_SPECIFIER)&&spec.local){name=spec.local.name;obj[name]=source}}}return obj};AST.prototype._walkAddParent=function(fn){var stack=[this._ast],i,j,key,len,node,child,subchild;for(i=0;i<stack.length;i+=1){node=stack[i];if(node.type==="Line"||node.type===NT.EMPTY_STMT){continue}fn(node);for(key in node){if(key!==PARENT){if(key===RANGE||key===LOC){continue}child=node[key];if(child instanceof Array){for(j=0,len=child.length;j<len;j+=1){subchild=child[j];if(subchild){subchild.parent=node;stack.push(subchild)}}}else if(child!=void 0&&typeof child.type==="string"){child.parent=node;stack.push(child)}}}}};module.exports=AST;
|
package/lib/checkage.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const BUILT="2026-03-17T02:
|
|
6
|
+
const BUILT="2026-03-17T02:53:38.735Z";const MAJOR_RELS=2;function CheckAge(burnedInJetVer,msgCtx){this._jetRels=-1;this._msgCtx=msgCtx;this._burnedInMajor=parseInt(burnedInJetVer.split(".")[0])};CheckAge.prototype.checkAge=function(){var curDate;var buildDate;var buildMonth;var monthsToNow;curDate=new Date;buildDate=BUILT==="@BUILT@"?curDate:new Date(BUILT);buildMonth=buildDate.getMonth()+1;monthsToNow=_getElapsedMonths(buildDate,curDate);if(!monthsToNow){this._jetRels=0}else{this._jetRels=_getReleases(buildMonth,monthsToNow);if(this._jetRels>MAJOR_RELS){this._emitMsg(monthsToNow)}}return this._jetRels};CheckAge.prototype.getJafReleaseCount=function(){return this._jetRels};CheckAge.prototype.getMajorReleaseCount=function(major){if(typeof major==="string"){let a=major.split(".");major=parseInt(a[0])}if(isNaN(major)){return this._jetRels}let estimatedMajor=this._burnedInMajor+this._jetRels;return estimatedMajor-major};CheckAge.prototype._emitMsg=function(old){var INDENT=" ".repeat(12);var s,h,p;if(this._jetRels){s=""+this._jetRels;if(this._jetRels===1){h="has";p=""}else{h="have";p="s"}}else{s="at least one";h="has";p=""}var s=`\nThis version of JAF is ${old} month${old===1?"":"s"} old, and there ${h} been ${s} scheduled public\n`+`${INDENT}major JET release${p}, together with JAF updates and fixes. It is strongly\n`+INDENT+"recommended that you install the latest version of JAF. [JAF-9100]\n";this._msgCtx.warn(s,"JAF-9100",true)};function _getElapsedMonths(start,end){return end.getMonth()-start.getMonth()+12*(end.getFullYear()-start.getFullYear())};function _getReleases(buildMonth,months){var toNextRel,releases=0;if(buildMonth===1){toNextRel=0}else if(buildMonth>1&&buildMonth<7){toNextRel=7-buildMonth}else if(buildMonth===7){toNextRel=0}else{toNextRel=13-buildMonth}if((releases=months-toNextRel)>=0){releases=1+Math.floor(releases/6)}else{releases=0}return releases};module.exports=CheckAge;
|
package/lib/defaults.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const defaults={JETVER:"
|
|
6
|
+
const defaults={JETVER:"20.0.1".replace(/(\d*\.\d*)(\.\d*)+$/g,"$1")+".0",THEME:"Alta",ECMAVER:14};module.exports=defaults;
|
package/lib/ns.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const _ns=["oj-acx","oj-acx-assets","oj-adp","oj-approvals","oj-av","oj-bangylon","oj-bi","oj-bi-sac","oj-cagbu","oj-cda","oj-cegbu","oj-cegbu-scp","oj-cgbu","oj-cgm","oj-cic","oj-clm","oj-communities","oj-core","oj-cp","oj-cso","oj-csp","oj-cx","oj-cx-aiapps","oj-cx-ap","oj-cx-cg","oj-cx-dcs","oj-cx-fsvc","oj-cx-hd","oj-cx-interviews","oj-cx-iss","oj-cx-km","oj-cx-km-agent","oj-cx-marketing","oj-cx-ma","oj-cx-mc","oj-cx-ol","oj-cx-saleshub","oj-cx-svc","oj-cxi","oj-cxm","oj-dbt","oj-dcs","oj-doceng","oj-dyn","oj-ee","oj-ehrc","oj-em","oj-epm","oj-fa","oj-faw","oj-fa-fin","oj-fnd","oj-fom","oj-fsgbu","oj-fsgbu-demo","oj-fwk","oj-gbu","oj-gbu-comp","oj-gcs","oj-gtm","oj-hcm","oj-hed","oj-hsgbu","oj-hsp","oj-hsp-common","oj-hsp-cruise","oj-hsp-hdp","oj-hsp-ohip","oj-hsp-opera","oj-ia","oj-i18n","oj-idaas","oj-ips","oj-ircs","oj-j4s","oj-jv","oj-lux","oj-lx","oj-mca","oj-mcps","oj-nav","oj-oa","oj-oac","oj-oal","oj-oal-ni","oj-oal-ux","oj-oax","oj-ob","oj-oc","oj-oce","oj-ocm","oj-oda","oj-oda-chat","oj-odcs","oj-odcs-oit","oj-odps","oj-ofs","oj-ofsc","oj-ogg","oj-ohai","oj-ohi","oj-ohiui","oj-oic","oj-oit","oj-ol","oj-omc","oj-omnichannel","oj-opa","oj-opaas","oj-opac","oj-pa","oj-psc","oj-prmt","oj-psm","oj-ref","oj-rgbu","oj-rgbu-jraf","oj-rw","oj-scs","oj-sp","oj-spatial","oj-spectra","oj-svc","oj-taui","oj-ugbu","oj-uw","oj-ux","oj-vb","oj-vb-sample","oj-vbdt","oj-wc","oj-wcc","oj","oj-c","oj-cc","oj-dynamic","oj-ext","oj-sample","oj-sample-internal","ns","ns-ui","demo","my","app"];const _setNS=new Set(_ns);module.exports={has:function(k){return _setNS.has(k)},getKeys:function(){return[..._setNS]}};
|
|
6
|
+
const _ns=["oj-acx","oj-acx-assets","oj-adp","oj-approvals","oj-av","oj-bangylon","oj-bi","oj-bi-sac","oj-cagbu","oj-cda","oj-cegbu","oj-cegbu-scp","oj-cgbu","oj-cgm","oj-cic","oj-clm","oj-communities","oj-core","oj-cp","oj-cso","oj-csp","oj-cx","oj-cx-aiapps","oj-cx-ap","oj-cx-cg","oj-cx-dcs","oj-cx-fsvc","oj-cx-hd","oj-cx-interviews","oj-cx-iss","oj-cx-km","oj-cx-km-agent","oj-cx-marketing","oj-cx-ma","oj-cx-mc","oj-cx-ol","oj-cx-saleshub","oj-cx-svc","oj-cxi","oj-cxm","oj-dbt","oj-dcs","oj-doceng","oj-dyn","oj-ee","oj-ehrc","oj-em","oj-epm","oj-fa","oj-faw","oj-fa-fin","oj-fnd","oj-fom","oj-fsgbu","oj-fsgbu-demo","oj-fwk","oj-gbu","oj-gbu-comp","oj-gcs","oj-gtm","oj-hcm","oj-hed","oj-hsgbu","oj-hsp","oj-hsp-common","oj-hsp-cruise","oj-hsp-hdp","oj-hsp-ohip","oj-hsp-opera","oj-ia","oj-i18n","oj-idaas","oj-ips","oj-ircs","oj-j4s","oj-jv","oj-lux","oj-lx","oj-mca","oj-mcps","oj-nav","oj-oa","oj-oac","oj-oal","oj-oal-ni","oj-oal-ux","oj-oax","oj-ob","oj-oc","oj-oce","oj-ocm","oj-oda","oj-oda-chat","oj-odcs","oj-odcs-oit","oj-odps","oj-ofs","oj-ofsc","oj-ogg","oj-ohai","oj-ohi","oj-ohiui","oj-oic","oj-oit","oj-ol","oj-omc","oj-omnichannel","oj-opa","oj-opaas","oj-opac","oj-pa","oj-psc","oj-portalai","oj-portalconversation","oj-prmt","oj-psm","oj-ref","oj-rgbu","oj-rgbu-jraf","oj-rgiu","oj-rw","oj-scs","oj-sp","oj-spatial","oj-spectra","oj-svc","oj-taui","oj-ugbu","oj-uw","oj-ux","oj-vb","oj-vb-sample","oj-vbdt","oj-wc","oj-wcc","oj","oj-c","oj-cc","oj-dynamic","oj-ext","oj-sample","oj-sample-internal","ns","ns-ui","demo","my","app"];const _setNS=new Set(_ns);module.exports={has:function(k){return _setNS.has(k)},getKeys:function(){return[..._setNS]}};
|
package/lib/scaffold.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Licensed under The Universal Permissive License (UPL), Version 1.0
|
|
4
4
|
* as shown at https://oss.oracle.com/licenses/upl/
|
|
5
5
|
*/
|
|
6
|
-
const DEFAULTS=require("./defaults");const OJET_CONFIG="oraclejetconfig.json";const OJAF_CONFIG="oraclejafconfig.json";const OJAF_DEFAULT_CONFIG="jafconfig.json";const DEPENDENCIES_VER_PROP="@oracle/oraclejet";const PACKAGE_JSON="package.json";const TSCONFIG="tsconfig.json";const SUFFIX_HTML="/**/*.html";const SUFFIX_JS="/**/*.js";const SUFFIX_TS="/**/*.ts";const SUFFIX_CSS="/**/*.css";const SUFFIX_COMPJSON="/**/component.json";const OJET_COMMENT="OJET Based Configuration";const NON_OJET_COMMENT="Default Configuration";const SLASHIFY=/\\\\|\\/g;const STABLE="Stable";var Scaffold=function(cwd,nd,appCtx){this._cwd=_fwdSlashify(cwd);this._nd=nd;this._appCtx=appCtx;this._fsUtils=appCtx.fsUtils;this._ojet=null;this._jetConfig=null;this._jafConfig=null;this._ojetLib=null;this._md5=null};Scaffold.prototype.init=function(){if(!this._initDone){this._ojet=this.isOJET();if(!this._ojet&&this._ojetJafConfigExists()){this._appCtx.warn(`JAF Configuration '${OJAF_CONFIG}' found, but OJET configuration '${OJET_CONFIG}' no longer exists.\n`)}this._initDone=true}return this._ojet};Scaffold.prototype.isOJET=function(){return this._initDone?!!this._jetConfig:this._fsUtils.fileExists(this._nd.path.join(this._cwd,OJET_CONFIG))};Scaffold.prototype.handleOjetConfig=function(isScaffold){var ojetPath,ojafPath,doUpdate=false,temp,hash,tsHash,tsc,tsConfig,jafConfig,defaultExists,error=false;ojetPath=this._nd.path.join(this._cwd,OJET_CONFIG);this._jetConfig=this._nd.jsonLoader.load(ojetPath,this._nd,errMsg=>{this._appCtx.error(errMsg);error=true},false,this._appCtx.utils);if(isScaffold){if(error){this._appCtx.error("Cannot continue with --init");return"error"}else if(this._jetConfig){this._appCtx.msg(`Scaffolding JAF configuration in ${this._getFolderName()} ...`)}else{this._appCtx.error("OJET CLI config not found - cannot continue with --init");return"error"}}if(tsConfig=this._readTsConfig(ojetPath)){try{tsConfig=JSON.stringify(tsConfig)}catch(e){tsConfig=null}}this._ojetLib=this._appCtx.ojetLib=new this._nd.ojetUtils(this._jetConfig,tsConfig,this._cwd);ojafPath=this._nd.path.join(this._cwd,OJAF_CONFIG);if(this._fsUtils.fileExists(ojafPath)){this._jafConfig=this._readJAFConfig(ojafPath);if(this._jafConfig==="error"){return"error"}}if(isScaffold){defaultExists=this._defaultConfigExists();if(this._jafConfig||defaultExists){this._appCtx.warn(`Pre-existing configuration found '${defaultExists?OJAF_DEFAULT_CONFIG:OJAF_CONFIG}' : ojaf will not delete it.`);return"error"}}hash=this._isOjetFileChange(ojetPath);if(this._jafConfig){jafConfig=this._jafConfig;if(hash){if(jafConfig.ojet&&jafConfig.ojet.update){if(this._appCtx.verboseMode||this._appCtx.debugMode){if(hash){this._appCtx.info(`${OJET_CONFIG} change detected - updating ${OJAF_CONFIG}`)}if(tsHash){if(typeof tsHash==="string"){this._appCtx.info(`${TSCONFIG} change detected - updating ${OJAF_CONFIG}`)}else{this._appCtx.info(`${TSCONFIG} no longer found - updating ${OJAF_CONFIG}`)}}}jafConfig.files=this._getFileSet();jafConfig.exclude=this._getExcludes();jafConfig.components=this._getComposites();if(tsc=this._getTsConfigPath()){if(jafConfig.typescript){jafConfig.typescript.tsconfig=tsc}else{jafConfig.typescript={tsconfig:tsc}}}else if(jafConfig.typescript&&jafConfig.typescript.tsconfig){delete jafConfig.typescript}if(jafConfig.tsconfig){delete jafConfig.tsconfig}temp=this._getJetVer();if(jafConfig.jetVer!==temp){jafConfig.jetVer=temp}if(temp=this._getTheme()){if(jafConfig.theme!==temp){jafConfig.theme=temp}}else if(jafConfig.theme){delete jafConfig.theme}if(!jafConfig.ojet){jafConfig.ojet={}}if(hash){jafConfig.ojet.md5=hash}if(typeof jafConfig.ojet.update!=="boolean"){jafConfig.ojet.update=true}if(typeof tsHash==="string"){jafConfig.ojet.tsmd5=tsHash}else if(tsHash&&jafConfig.ojet.tsmd5){delete jafConfig.ojet.tsmd5}doUpdate=true;this._backupJAFConfig(ojafPath)}else{const changeMsg=" changes detected, but oraclejafconfig updates are disabled";if(hash){this._appCtx.warn(OJET_CONFIG+changeMsg)}if(tsHash){this._appCtx.warn(TSCONFIG+changeMsg)}}}}else if(isScaffold){jafConfig={};jafConfig.title=["+---------------------------------------------------------------------+","| OJET Application Audit |","+---------------------------------------------------------------------+","JAF $jafver - Jet $jetver : ($jafdate, $jaftime)\n"];jafConfig.base="$jafcwd";jafConfig.files=this._getFileSet(),jafConfig.exclude=this._getExcludes(),jafConfig.components=this._getComposites(),jafConfig.builtinJetRules=true,jafConfig.jetVer=this._getJetVer(),jafConfig.ecmaVer=DEFAULTS.ECMAVER,jafConfig.format="prose",jafConfig.severity="all",jafConfig.groups=["all"];if(temp=this._getTheme()){jafConfig.theme=temp}if(tsc=this._getTsConfigPath()){jafConfig.typescript={compile:true}}if(tsHash){jafConfig.ojet.tsmd5=tsHash}jafConfig.options={verbose:false,color:true};jafConfig.ojet={update:true,md5:hash};this._jafConfig=jafConfig;doUpdate=true}if(doUpdate&&!this._writeJAFConfig(OJAF_CONFIG,true)){this.appCtx.error("Failed to "+(isScaffold?"scaffold":"update")+" OJAF config '"+this._nd.path.join(this._cwd,OJAF_CONFIG)+"'");return"error"}if(isScaffold){this._scaffoldSuccessful(OJAF_CONFIG)}if(this._appCtx.debugMode){this._appCtx.debug("JAFConfig :\n"+JSON.stringify(jafConfig,null,3))}return jafConfig};Scaffold.prototype.getOjetConfig=function(){return this._jetConfig};Scaffold.prototype.getOjetLib=function(){return this._ojetLib?this._ojetLib:new this._nd.ojetUtils(null,null,null)};Scaffold.prototype._getFileSet=function(){var source,src,files=[];if(this._jetConfig&&this._jetConfig.paths){if(source=this._jetConfig.paths.source){if(src=source.common){files.push("./"+src+SUFFIX_HTML);if(source.javascript){files.push("./"+src+SUFFIX_JS)}if(source.typescript){files.push("./"+src+SUFFIX_TS)}files.push("./"+src+SUFFIX_COMPJSON)}if(source.styles){files.push("./"+src+"/"+source.styles+SUFFIX_CSS)}}}return _fwdSlashify(files)};Scaffold.prototype.createNonOjetConfig=function(){var oj;oj=this._ojetJafConfigExists();if(oj||this._defaultConfigExists()){this._appCtx.error("Default configuration '"+(oj?OJAF_CONFIG:OJAF_DEFAULT_CONFIG)+"' exists - terminating --init");return"'error"}this._jafConfig=this._createDefaultNonOjetConfig();this._setFileProps(this._jafConfig);if(!this._writeJAFConfig(OJAF_DEFAULT_CONFIG,false)){this._appCtx.error("Failed to scaffold OJAF config '"+OJAF_DEFAULT_CONFIG+"'");return"error"}this._scaffoldSuccessful(OJAF_DEFAULT_CONFIG)};Scaffold.prototype._getExcludes=function(){var files=[],source;if(this._jetConfig.paths&&this._jetConfig.paths.source){source=this._jetConfig.paths.source.common;files.push("./"+this._nd.path.join(source,"**"+"/"+"*-min.js"));files.push("./"+this._nd.path.join(source,"**"+"/"+"*-min.css"));files.push("./**/node_modules/**/*.*")}return _fwdSlashify(files)};Scaffold.prototype._getComposites=function(){var a=[],dir;if(this._jetConfig.paths&&this._jetConfig.paths.exchangeComponents){dir="./exchange_components/**/component.json"}else{dir="./jet_components/**/component.json"}a.push(dir);if(dir=_getOjCPackComponentJson()){a.push(dir)}return _fwdSlashify(a)};function _getOjCPackComponentJson(){};Scaffold.prototype._getTsConfigPath=function(){return this._tsConfigExists()?".":null};Scaffold.prototype._getJetVer=function(){var i,ojetPackage,ver,error;var _self=this;ojetPackage=this._nd.jsonLoader.load(this._nd.path.join(this._cwd,PACKAGE_JSON),this._nd,function(errMsg){_self._appCtx.error(errMsg);_self._appCtx.warn("Defaulting to "+_self._appCtx.defaultJetVer);error=true});if(!error&&ojetPackage&&ojetPackage.dependencies){ver=ojetPackage.dependencies[DEPENDENCIES_VER_PROP];if(ver){for(i=0;i<ver.length;i++){if(!isNaN(ver.charAt(i))){ver=ver.substring(i);break}}ver=ver.replace(".tgz","");i=ver.lastIndexOf(".");ver=ver.substring(0,i)}}return ver?ver:this._appCtx.defaultJetVer};Scaffold.prototype._getTheme=function(){var dt=this._jetConfig.defaultTheme;if(dt){dt=dt.charAt(0).toUpperCase()+dt.substring(1).toLowerCase();if(dt===STABLE){dt="Redwood"}}return dt};Scaffold.prototype._getFolderName=function(){return this._nd.path.basename(this._cwd)};Scaffold.prototype._readJAFConfig=function(path){var error;var _self=this;var json=this._nd.jsonLoader.load(path,this._nd,function(errMsg){_self._appCtx.error(errMsg);error=true},true,this._appCtx.utils);if(error){this._appCtx.error(`JSON syntax error -> '${path}`)}return error?"error":json};Scaffold.prototype._writeJAFConfig=function(name,isOjet){var data,ret=false;try{data=`// JAF Generated ${isOjet?OJET_COMMENT:NON_OJET_COMMENT}\n// Updated: ${new Date().toString()}\n\n${JSON.stringify(this._jafConfig,null,3)}`;this._nd.fs.writeFileSync(this._nd.path.join(this._cwd,name),data);ret=true}catch(e){this._appCtx.error(e.message)}return ret};Scaffold.prototype._backupJAFConfig=function(fp){var data,ret=false;try{data=this._readFile(fp);if(data){this._nd.fs.writeFileSync(fp+".bak",data);ret=true}}catch(e){this._appCtx.error(e.message)}return ret};Scaffold.prototype._isOjetFileChange=function(ojPath){if(!this._md5){this._md5=require("md5")}var ojetMd5,ojafMd5;var jafConfig=this._jafConfig;ojetMd5=this._md5(this._readFile(ojPath));ojafMd5=jafConfig&&jafConfig.ojet&&jafConfig.ojet.md5;return ojetMd5!==ojafMd5?ojetMd5:false};Scaffold.prototype._readTsConfig=function(ojPath){var p,ret=false;p=this._nd.path.join(ojPath,TSCONFIG);if(this._fsUtils.fileExists(p)){ret=this._readFile(p)}return ret};Scaffold.prototype._readFile=function(fp){var data;try{data=this._nd.fs.readFileSync(fp,"utf8")}catch(e){}return typeof data==="string"?data:null};function _fwdSlashify(path){if(Array.isArray(path)){for(var i=0;i<path.length;i++){path[i]=path[i].replace(SLASHIFY,"/")}return path}else if(path){return path.replace(SLASHIFY,"/")}};Scaffold.prototype._createDefaultNonOjetConfig=function(){var o={"base":"$jafcwd","files":[],"exclude":[],"components":["./jet_components/**/component.json"],"builtinJetRules":true,"jetVer":this._appCtx.defaultJetVer,"ecmaVer":DEFAULTS.ECMAVER,"groups":["all"],"format":"prose","severity":"all","options":{verbose:false,color:true},"title":["+---------------------------------------------------------------------+","| Application Audit |","+---------------------------------------------------------------------+","JAF $jafver - Jet $jetver : ($jafdate, $jaftime)\n"]};if(this._tsConfigExists()){o.typescript={compile:true}}return o};Scaffold.prototype._setFileProps=function(obj){var path,folder;folder="src";if(path=this._getPathTo(folder)){obj.files.push(path+"/**/*.html");obj.files.push(path+"/**/*.js");obj.files.push(path+"/**/*.ts");obj.files.push(path+"/**/*.css");obj.exclude.push(path+"/**/*-min.js");obj.exclude.push(path+"/**/*-min.css")}folder="jet-composites";path=this._getPathTo(folder);if(path){obj.components=[path];obj.exclude.push(path+"/**/extension/**/*.*");obj.exclude.push(path+"/**/resources/**/*.*")}obj.exclude.push("./**/node_modules/**/*.*")};Scaffold.prototype._getPathTo=function(folder){var path=this._fsUtils.findFile(this._cwd,folder,function(dir,file){return file!=="node_modules"&&!dir.includes("node_modules")});if(path){path=this._nd.path.join(path,folder);path=_fwdSlashify(path);path="."+path.replace(this._cwd,"")}else{path=null}return path};Scaffold.prototype._defaultConfigExists=function(){var file=this._nd.path.join(this._cwd,OJAF_DEFAULT_CONFIG);return this._fsUtils.fileExists(file)};Scaffold.prototype._ojetJafConfigExists=function(){var file=this._nd.path.join(this._cwd,OJAF_CONFIG);return this._fsUtils.fileExists(file)};Scaffold.prototype._tsConfigExists=function(){var file=this._nd.path.join(this._cwd,TSCONFIG);return this._fsUtils.fileExists(file)};Scaffold.prototype._scaffoldSuccessful=function(configName){var msg=this._appCtx.msg;msg(" __ ___");msg(" __ / /___ _/ _/ Configuration generation successful");msg(" / // // _ `/ _/ created: '@@'".replace("@@",configName));msg(" \\___/ \\_,_/_/\n")};module.exports=Scaffold;
|
|
6
|
+
const DEFAULTS=require("./defaults");const OJET_CONFIG="oraclejetconfig.json";const OJAF_CONFIG="oraclejafconfig.json";const OJAF_DEFAULT_CONFIG="jafconfig.json";const DEPENDENCIES_VER_PROP="@oracle/oraclejet";const PACKAGE_JSON="package.json";const TSCONFIG="tsconfig.json";const SUFFIX_HTML="/**/*.html";const SUFFIX_JS="/**/*.js";const SUFFIX_TS="/**/*.ts";const SUFFIX_TSX="/**/*.tsx";const SUFFIX_CSS="/**/*.css";const SUFFIX_COMPJSON="/**/component.json";const OJET_COMMENT="OJET Based Configuration";const NON_OJET_COMMENT="Default Configuration";const SLASHIFY=/\\\\|\\/g;const STABLE="Stable";const VDOM_ARCHITECTURE="vdom";var Scaffold=function(cwd,nd,appCtx){this._cwd=_fwdSlashify(cwd);this._nd=nd;this._appCtx=appCtx;this._fsUtils=appCtx.fsUtils;this._ojet=null;this._jetConfig=null;this._jafConfig=null;this._ojetLib=null;this._md5=null};Scaffold.prototype.init=function(){if(!this._initDone){this._ojet=this.isOJET();if(!this._ojet&&this._ojetJafConfigExists()){this._appCtx.warn(`JAF Configuration '${OJAF_CONFIG}' found, but OJET configuration '${OJET_CONFIG}' no longer exists.\n`)}this._initDone=true}return this._ojet};Scaffold.prototype.isOJET=function(){return this._initDone?!!this._jetConfig:this._fsUtils.fileExists(this._nd.path.join(this._cwd,OJET_CONFIG))};Scaffold.prototype.handleOjetConfig=function(isScaffold){var ojetPath,ojafPath,doUpdate=false,temp,hash,tsHash,tsc,tsConfig,jafConfig,defaultExists,error=false;ojetPath=this._nd.path.join(this._cwd,OJET_CONFIG);this._jetConfig=this._nd.jsonLoader.load(ojetPath,this._nd,errMsg=>{this._appCtx.error(errMsg);error=true},false,this._appCtx.utils);if(isScaffold){if(error){this._appCtx.error("Cannot continue with --init");return"error"}else if(this._jetConfig){this._appCtx.msg(`Scaffolding JAF configuration in ${this._getFolderName()} ...`)}else{this._appCtx.error("OJET CLI config not found - cannot continue with --init");return"error"}}if(tsConfig=this._readTsConfig(ojetPath)){try{tsConfig=JSON.stringify(tsConfig)}catch(e){tsConfig=null}}this._ojetLib=this._appCtx.ojetLib=new this._nd.ojetUtils(this._jetConfig,tsConfig,this._cwd);ojafPath=this._nd.path.join(this._cwd,OJAF_CONFIG);if(this._fsUtils.fileExists(ojafPath)){this._jafConfig=this._readJAFConfig(ojafPath);if(this._jafConfig==="error"){return"error"}}if(isScaffold){defaultExists=this._defaultConfigExists();if(this._jafConfig||defaultExists){this._appCtx.warn(`Pre-existing configuration found '${defaultExists?OJAF_DEFAULT_CONFIG:OJAF_CONFIG}' : ojaf will not delete it.`);return"error"}}hash=this._isOjetFileChange(ojetPath);if(this._jafConfig){jafConfig=this._jafConfig;if(hash){if(jafConfig.ojet&&jafConfig.ojet.update){if(this._appCtx.verboseMode||this._appCtx.debugMode){if(hash){this._appCtx.info(`${OJET_CONFIG} change detected - updating ${OJAF_CONFIG}`)}if(tsHash){if(typeof tsHash==="string"){this._appCtx.info(`${TSCONFIG} change detected - updating ${OJAF_CONFIG}`)}else{this._appCtx.info(`${TSCONFIG} no longer found - updating ${OJAF_CONFIG}`)}}}jafConfig.files=this._getFileSet();jafConfig.exclude=this._getExcludes();jafConfig.components=this._getComposites();if(tsc=this._getTsConfigPath()){if(jafConfig.typescript){jafConfig.typescript.tsconfig=tsc}else{jafConfig.typescript={tsconfig:tsc}}}else if(jafConfig.typescript&&jafConfig.typescript.tsconfig){delete jafConfig.typescript}if(jafConfig.tsconfig){delete jafConfig.tsconfig}temp=this._getJetVer();if(jafConfig.jetVer!==temp){jafConfig.jetVer=temp}if(temp=this._getTheme()){if(jafConfig.theme!==temp){jafConfig.theme=temp}}else if(jafConfig.theme){delete jafConfig.theme}if(!jafConfig.ojet){jafConfig.ojet={}}if(hash){jafConfig.ojet.md5=hash}if(typeof jafConfig.ojet.update!=="boolean"){jafConfig.ojet.update=true}if(typeof tsHash==="string"){jafConfig.ojet.tsmd5=tsHash}else if(tsHash&&jafConfig.ojet.tsmd5){delete jafConfig.ojet.tsmd5}doUpdate=true;this._backupJAFConfig(ojafPath)}else{const changeMsg=" changes detected, but oraclejafconfig updates are disabled";if(hash){this._appCtx.warn(OJET_CONFIG+changeMsg)}if(tsHash){this._appCtx.warn(TSCONFIG+changeMsg)}}}}else if(isScaffold){jafConfig={};jafConfig.title=["+---------------------------------------------------------------------+","| OJET Application Audit |","+---------------------------------------------------------------------+","JAF $jafver - Jet $jetver : ($jafdate, $jaftime)\n"];jafConfig.base="$jafcwd";jafConfig.files=this._getFileSet(),jafConfig.exclude=this._getExcludes(),jafConfig.components=this._getComposites(),jafConfig.builtinJetRules=true,jafConfig.jetVer=this._getJetVer(),jafConfig.ecmaVer=DEFAULTS.ECMAVER,jafConfig.format="prose",jafConfig.severity="all",jafConfig.groups=["all"];if(temp=this._getTheme()){jafConfig.theme=temp}if(tsc=this._getTsConfigPath()){jafConfig.typescript={compile:true}}if(tsHash){jafConfig.ojet.tsmd5=tsHash}jafConfig.options={verbose:false,color:true};jafConfig.ojet={update:true,md5:hash};this._jafConfig=jafConfig;doUpdate=true}if(doUpdate&&!this._writeJAFConfig(OJAF_CONFIG,true)){this.appCtx.error("Failed to "+(isScaffold?"scaffold":"update")+" OJAF config '"+this._nd.path.join(this._cwd,OJAF_CONFIG)+"'");return"error"}if(isScaffold){this._scaffoldSuccessful(OJAF_CONFIG)}if(this._appCtx.debugMode){this._appCtx.debug("JAFConfig :\n"+JSON.stringify(jafConfig,null,3))}return jafConfig};Scaffold.prototype.getOjetConfig=function(){return this._jetConfig};Scaffold.prototype.getOjetLib=function(){return this._ojetLib?this._ojetLib:new this._nd.ojetUtils(null,null,null)};Scaffold.prototype._getFileSet=function(){var source,src,files=[];if(this._jetConfig&&this._jetConfig.paths){if(source=this._jetConfig.paths.source){if(src=source.common){files.push("./"+src+SUFFIX_HTML);if(source.javascript){files.push("./"+src+SUFFIX_JS)}if(source.typescript){files.push("./"+src+SUFFIX_TS)}files.push("./"+src+SUFFIX_COMPJSON)}if(source.styles){files.push("./"+src+"/"+source.styles+SUFFIX_CSS)}if(this._jetConfig.architecture===VDOM_ARCHITECTURE){files.push("./"+src+SUFFIX_TSX)}}}return _fwdSlashify(files)};Scaffold.prototype.createNonOjetConfig=function(){var oj;oj=this._ojetJafConfigExists();if(oj||this._defaultConfigExists()){this._appCtx.error("Default configuration '"+(oj?OJAF_CONFIG:OJAF_DEFAULT_CONFIG)+"' exists - terminating --init");return"'error"}this._jafConfig=this._createDefaultNonOjetConfig();this._setFileProps(this._jafConfig);if(!this._writeJAFConfig(OJAF_DEFAULT_CONFIG,false)){this._appCtx.error("Failed to scaffold OJAF config '"+OJAF_DEFAULT_CONFIG+"'");return"error"}this._scaffoldSuccessful(OJAF_DEFAULT_CONFIG)};Scaffold.prototype._getExcludes=function(){var files=[],source;if(this._jetConfig.paths&&this._jetConfig.paths.source){source=this._jetConfig.paths.source.common;files.push("./"+this._nd.path.join(source,"**"+"/"+"*-min.js"));files.push("./"+this._nd.path.join(source,"**"+"/"+"*-min.css"));files.push("./**/node_modules/**/*.*")}return _fwdSlashify(files)};Scaffold.prototype._getComposites=function(){var a=[],dir;if(this._jetConfig.paths&&this._jetConfig.paths.exchangeComponents){dir="./exchange_components/**/component.json"}else{dir="./jet_components/**/component.json"}a.push(dir);if(dir=_getOjCPackComponentJson()){a.push(dir)}return _fwdSlashify(a)};function _getOjCPackComponentJson(){};Scaffold.prototype._getTsConfigPath=function(){return this._tsConfigExists()?".":null};Scaffold.prototype._getJetVer=function(){var i,ojetPackage,ver,error;var _self=this;ojetPackage=this._nd.jsonLoader.load(this._nd.path.join(this._cwd,PACKAGE_JSON),this._nd,function(errMsg){_self._appCtx.error(errMsg);_self._appCtx.warn("Defaulting to "+_self._appCtx.defaultJetVer);error=true});if(!error&&ojetPackage&&ojetPackage.dependencies){ver=ojetPackage.dependencies[DEPENDENCIES_VER_PROP];if(ver){for(i=0;i<ver.length;i++){if(!isNaN(ver.charAt(i))){ver=ver.substring(i);break}}ver=ver.replace(".tgz","");i=ver.lastIndexOf(".");ver=ver.substring(0,i)}}return ver?ver:this._appCtx.defaultJetVer};Scaffold.prototype._getTheme=function(){var dt=this._jetConfig.defaultTheme;if(dt){dt=dt.charAt(0).toUpperCase()+dt.substring(1).toLowerCase();if(dt===STABLE){dt="Redwood"}}return dt};Scaffold.prototype._getFolderName=function(){return this._nd.path.basename(this._cwd)};Scaffold.prototype._readJAFConfig=function(path){var error;var _self=this;var json=this._nd.jsonLoader.load(path,this._nd,function(errMsg){_self._appCtx.error(errMsg);error=true},true,this._appCtx.utils);if(error){this._appCtx.error(`JSON syntax error -> '${path}`)}return error?"error":json};Scaffold.prototype._writeJAFConfig=function(name,isOjet){var data,ret=false;try{data=`// JAF Generated ${isOjet?OJET_COMMENT:NON_OJET_COMMENT}\n// Updated: ${new Date().toString()}\n\n${JSON.stringify(this._jafConfig,null,3)}`;this._nd.fs.writeFileSync(this._nd.path.join(this._cwd,name),data);ret=true}catch(e){this._appCtx.error(e.message)}return ret};Scaffold.prototype._backupJAFConfig=function(fp){var data,ret=false;try{data=this._readFile(fp);if(data){this._nd.fs.writeFileSync(fp+".bak",data);ret=true}}catch(e){this._appCtx.error(e.message)}return ret};Scaffold.prototype._isOjetFileChange=function(ojPath){if(!this._md5){this._md5=require("md5")}var ojetMd5,ojafMd5;var jafConfig=this._jafConfig;ojetMd5=this._md5(this._readFile(ojPath));ojafMd5=jafConfig&&jafConfig.ojet&&jafConfig.ojet.md5;return ojetMd5!==ojafMd5?ojetMd5:false};Scaffold.prototype._readTsConfig=function(ojPath){var p,ret=false;p=this._nd.path.join(ojPath,TSCONFIG);if(this._fsUtils.fileExists(p)){ret=this._readFile(p)}return ret};Scaffold.prototype._readFile=function(fp){var data;try{data=this._nd.fs.readFileSync(fp,"utf8")}catch(e){}return typeof data==="string"?data:null};function _fwdSlashify(path){if(Array.isArray(path)){for(var i=0;i<path.length;i++){path[i]=path[i].replace(SLASHIFY,"/")}return path}else if(path){return path.replace(SLASHIFY,"/")}};Scaffold.prototype._createDefaultNonOjetConfig=function(){var o={"base":"$jafcwd","files":[],"exclude":[],"components":["./jet_components/**/component.json"],"builtinJetRules":true,"jetVer":this._appCtx.defaultJetVer,"ecmaVer":DEFAULTS.ECMAVER,"groups":["all"],"format":"prose","severity":"all","options":{verbose:false,color:true},"title":["+---------------------------------------------------------------------+","| Application Audit |","+---------------------------------------------------------------------+","JAF $jafver - Jet $jetver : ($jafdate, $jaftime)\n"]};if(this._tsConfigExists()){o.typescript={compile:true}}return o};Scaffold.prototype._setFileProps=function(obj){var path,folder;folder="src";if(path=this._getPathTo(folder)){obj.files.push(path+"/**/*.html");obj.files.push(path+"/**/*.js");obj.files.push(path+"/**/*.ts");obj.files.push(path+"/**/*.css");obj.exclude.push(path+"/**/*-min.js");obj.exclude.push(path+"/**/*-min.css")}folder="jet-composites";path=this._getPathTo(folder);if(path){obj.components=[path];obj.exclude.push(path+"/**/extension/**/*.*");obj.exclude.push(path+"/**/resources/**/*.*")}obj.exclude.push("./**/node_modules/**/*.*")};Scaffold.prototype._getPathTo=function(folder){var path=this._fsUtils.findFile(this._cwd,folder,function(dir,file){return file!=="node_modules"&&!dir.includes("node_modules")});if(path){path=this._nd.path.join(path,folder);path=_fwdSlashify(path);path="."+path.replace(this._cwd,"")}else{path=null}return path};Scaffold.prototype._defaultConfigExists=function(){var file=this._nd.path.join(this._cwd,OJAF_DEFAULT_CONFIG);return this._fsUtils.fileExists(file)};Scaffold.prototype._ojetJafConfigExists=function(){var file=this._nd.path.join(this._cwd,OJAF_CONFIG);return this._fsUtils.fileExists(file)};Scaffold.prototype._tsConfigExists=function(){var file=this._nd.path.join(this._cwd,TSCONFIG);return this._fsUtils.fileExists(file)};Scaffold.prototype._scaffoldSuccessful=function(configName){var msg=this._appCtx.msg;msg(" __ ___");msg(" __ / /___ _/ _/ Configuration generation successful");msg(" / // // _ `/ _/ created: '@@'".replace("@@",configName));msg(" \\___/ \\_,_/_/\n")};module.exports=Scaffold;
|