@deveco-test/deveco-cli 1.3.5-Test.1 → 1.3.5-Test.4
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/cli.js +57 -0
- package/package.json +16 -47
- package/LICENSE +0 -21
- package/README.md +0 -1684
- package/SKILL.md +0 -236
- package/dist/cli.js +0 -1372
- package/dist/internal/telemetry-upload-background.js +0 -9
- package/src/resources/aclPermission/aclPermissionsInfo.json +0 -311
- package/src/resources/arkts-check.cjs +0 -3642
- package/templates/application/AppScope/app.json5 +0 -10
- package/templates/application/AppScope/resources/base/element/string.json +0 -8
- package/templates/application/AppScope/resources/base/media/layered_image.json +0 -7
- package/templates/application/build-profile.json5 +0 -42
- package/templates/application/code-linter.json5 +0 -32
- package/templates/application/entry/build-profile.json5 +0 -33
- package/templates/application/entry/gitignore.txt +0 -6
- package/templates/application/entry/hvigorfile.ts +0 -7
- package/templates/application/entry/obfuscation-rules.txt +0 -20
- package/templates/application/entry/oh-package.json5 +0 -10
- package/templates/application/entry/src/main/ets/entryability/EntryAbility.ets +0 -63
- package/templates/application/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +0 -31
- package/templates/application/entry/src/main/ets/pages/Index.ets +0 -38
- package/templates/application/entry/src/main/module.json5 +0 -50
- package/templates/application/entry/src/main/resources/base/element/color.json +0 -8
- package/templates/application/entry/src/main/resources/base/element/float.json +0 -8
- package/templates/application/entry/src/main/resources/base/element/string.json +0 -16
- package/templates/application/entry/src/main/resources/base/media/layered_image.json +0 -7
- package/templates/application/entry/src/main/resources/base/profile/backup_config.json +0 -3
- package/templates/application/entry/src/main/resources/base/profile/main_pages.json +0 -5
- package/templates/application/entry/src/main/resources/dark/element/color.json +0 -8
- package/templates/application/gitignore.txt +0 -13
- package/templates/application/hvigor/hvigor-config.json5 +0 -23
- package/templates/application/hvigorfile.ts +0 -7
- package/templates/application/oh-package.json5 +0 -10
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import Vt from"path";import*as S from"fs";import*as Y from"path";import{homedir as bt}from"os";import*as H from"fs";import*as g from"path";function W(n){let t=g.resolve(n),e=[],r=t;for(;;)try{let i=H.realpathSync(r);return e.length===0?i:g.join(i,...e.reverse())}catch(i){if(i.code!=="ENOENT")throw i;let o=g.dirname(r);if(o===r)return t;e.push(g.basename(r)),r=o}}function R(n){let t=n.trim();return(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1,-1).trim()),t}function K(n){let t=R(n);if(!t)throw new Error("Path must not be empty.");return W(t)}var Et="deveco-cli",J,N=class extends Error{constructor(t){super(t),this.name="CliDataDirError"}};function wt(){let n=process.env.DEVECO_CLI_DATA_DIR,e=(n===void 0||n===""?"":R(n))||Y.join(bt(),".local","share",Et);try{return K(e)}catch(r){throw new N(r instanceof Error?r.message:String(r))}}function X(){if(J!==void 0)return J;let n=wt();try{if(S.existsSync(n))return S.realpathSync(n)}catch{}return n}import vt from"crypto";import u from"fs";import z from"os";import m from"path";import Tt from"https";var G={devecoApiTraceUpload:"https://cn.devecostudio.huawei.com/codeGenie/cli/trace/upload"};var D=class n{static ENDPOINT=G.devecoApiTraceUpload;static SENDER="deveco-cli";async upload(t,e){let r={"Content-Type":"application/json",sender:n.SENDER,deviceid:e.replace(/-/g,""),"Content-Length":String(Buffer.byteLength(t,"utf8"))};try{let{body:i}=await this.httpPost(n.ENDPOINT,r,Buffer.from(t,"utf8"),6e4);return n.isSuccess(i)}catch{return!1}}static isSuccess(t){try{let e=JSON.parse(t),r=e?.code??e?.errorCode;return String(r)==="200"}catch{return!1}}async httpPost(t,e,r,i){let o=new URL(t);return new Promise((s,l)=>{let p=Tt.request({protocol:o.protocol,hostname:o.hostname,port:o.port||(o.protocol==="https:"?443:80),path:o.pathname+o.search,method:"POST",headers:e,timeout:i},h=>{let T=[];h.on("data",St=>T.push(St)),h.on("end",()=>{s({code:h.statusCode??0,body:Buffer.concat(T).toString("utf8")})})});p.on("timeout",()=>{p.destroy(new Error("request timeout"))}),p.on("error",l),p.write(r),p.end()})}};var q={identity:n=>n,camelCase:n=>n,snakeCase:n=>n.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").toLowerCase()},$=class{constructor(t={}){this.config=t}serialize(t){let e=this.transform(t);return this.config.pretty?JSON.stringify(e,null,2):JSON.stringify(e)}toObject(t){return this.transform(t)}transform(t){if(t==null)return t;if(Array.isArray(t))return t.map(o=>this.transform(o));if(typeof t!="object")return t;let e=this.config.namingStrategy??q.identity,r=this.config.fieldNames??{},i={};for(let[o,s]of Object.entries(t)){let l=r[o]??e(o);i[l]=this.transform(s)}return i}},Z=new $({namingStrategy:q.snakeCase,fieldNames:{}});import b from"crypto";import C from"fs";import Dt from"path";var _="aes-256-gcm",Ct=12,_t="deveco-cli-trace-file",Lt="trace-file-secret",tt=32;function Q(n){try{let t=C.readFileSync(n,"utf8").trim();return t&&Buffer.from(t,"base64").length===tt?t:null}catch{return null}}function et(n){let t=Dt.join(n,Lt),e=Q(t);if(e)return M(e);let r=b.randomBytes(tt).toString("base64");try{C.mkdirSync(n,{recursive:!0});try{C.writeFileSync(t,r,{flag:"wx"})}catch{let i=Q(t);if(i)return M(i);C.writeFileSync(t,r)}}catch{}return M(r)}function M(n){return b.createHash("sha256").update(_t).update(n).digest()}function rt(n,t){let e=b.randomBytes(Ct),r=b.createCipheriv(_,t,e),i=Buffer.concat([r.update(n,"utf8"),r.final()]),o={version:1,algorithm:_,ciphertext:i.toString("base64"),iv:e.toString("base64"),authTag:r.getAuthTag().toString("base64")};return JSON.stringify(o)}function nt(n,t){let e;try{e=JSON.parse(n)}catch{return null}if(!Ft(e))return n;try{let r=b.createDecipheriv(_,t,Buffer.from(e.iv,"base64"));return r.setAuthTag(Buffer.from(e.authTag,"base64")),Buffer.concat([r.update(Buffer.from(e.ciphertext,"base64")),r.final()]).toString("utf8")}catch{return null}}function Ft(n){if(!n||typeof n!="object")return!1;let t=n;return t.version===1&&t.algorithm===_&&typeof t.ciphertext=="string"&&typeof t.iv=="string"&&typeof t.authTag=="string"}import*as a from"fs";import*as A from"path";import*as L from"os";import*as y from"path";import ge from"json5";var ve=64*1024;function it(){if(process.platform==="win32"){let n=process.env.LOCALAPPDATA??y.join(L.homedir(),"AppData","Local");return y.join(n,"devecocli-mcp-server","logs")}return process.platform==="darwin"?y.join(L.homedir(),"Library","Logs","devecocli-mcp-server"):y.join(L.homedir(),".local","share","devecocli-mcp-server","logs")}var ot="mcp-server.log",At="mcp-server",kt={maxSize:10*1024*1024,maxFiles:4},B=class n{fd=null;logDir=null;currentLogFile=null;mode;rotationOptions;currentFileSize=0;currentDate="";isRotating=!1;minLevel;static LEVEL_ORDER={debug:0,info:1,warn:2,error:3};constructor(t,e){this.rotationOptions={...kt,...e},this.minLevel=t?"debug":"info",t?(this.mode="console",this.logDir=null,this.currentLogFile=null):(this.mode="file",this.logDir=it(),this.currentLogFile=A.join(this.logDir,ot),a.existsSync(this.logDir)||a.mkdirSync(this.logDir,{recursive:!0}),this.cleanupOrphanLogFiles(),this.openLogFile())}getCurrentDateString(){let t=new Date,e=t.getFullYear(),r=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");return`${e}-${r}-${i}`}getRotatedFileName(t,e){return A.join(this.logDir,`${At}-${t}.log.${e}`)}fileExists(t){try{return a.accessSync(t,a.constants.F_OK),!0}catch{return!1}}cleanupOrphanLogFiles(){if(this.logDir)try{let t=a.readdirSync(this.logDir),e=[];for(let i of t)if(i===ot||/^mcp-server-\d{4}-\d{2}-\d{2}\.log\.\d+$/.test(i)){let o=A.join(this.logDir,i),s=a.statSync(o);e.push({name:i,mtime:s.mtime,path:o})}e.sort((i,o)=>o.mtime.getTime()-i.mtime.getTime());let r=1+this.rotationOptions.maxFiles;for(let i=r;i<e.length;i++)try{a.unlinkSync(e[i].path)}catch{}}catch{}}rotateLog(){if(!(this.isRotating||!this.logDir||!this.currentLogFile)){this.isRotating=!0;try{if(this.closeLogFile(),!this.fileExists(this.currentLogFile)){this.isRotating=!1,this.openLogFile();return}let t=this.getCurrentDateString(),e=this.getRotatedFileName(t,this.rotationOptions.maxFiles);this.fileExists(e)&&a.unlinkSync(e);for(let i=this.rotationOptions.maxFiles-1;i>=1;i--){let o=this.getRotatedFileName(t,i),s=this.getRotatedFileName(t,i+1);this.fileExists(o)&&a.renameSync(o,s)}let r=this.getRotatedFileName(t,1);a.renameSync(this.currentLogFile,r),this.cleanupOrphanLogFiles(),this.openLogFile()}catch{this.openLogFile()}finally{this.isRotating=!1}}}openLogFile(){if(this.currentLogFile){this.currentDate=this.getCurrentDateString();try{if(this.fileExists(this.currentLogFile)){let t=a.statSync(this.currentLogFile);this.currentFileSize=t.size}else this.currentFileSize=0}catch{this.currentFileSize=0}try{this.fd=a.openSync(this.currentLogFile,"a")}catch{this.fd=null}}}closeLogFile(){if(this.fd!==null){try{a.closeSync(this.fd)}catch{}this.fd=null}}checkRotation(t){let e=this.getCurrentDateString();this.currentDate&&this.currentDate!==e&&(this.rotateLog(),this.currentDate=e),this.currentFileSize+=t,this.currentFileSize>=this.rotationOptions.maxSize&&this.rotateLog()}write(t,e,...r){if(this.mode==="silent"||n.LEVEL_ORDER[t]<n.LEVEL_ORDER[this.minLevel])return;let i=r.map(p=>p instanceof Error?`${p.name}: ${p.message}`:typeof p=="object"?JSON.stringify(p,null,2):String(p)).join(" "),o=i?`${e} ${i}`:e,l=`[${new Date().toLocaleString("sv-SE",{timeZone:"Asia/Shanghai",hour12:!1})+"."+String(new Date().getMilliseconds()).padStart(3,"0")}] [MCP/${t.toUpperCase()}] [pid=${process.pid}] ${o}
|
|
2
|
-
`;if(this.mode==="file"&&this.currentLogFile){if(this.fd===null&&this.openLogFile(),this.fd!==null)try{let p=Buffer.from(l);a.writeSync(this.fd,p),this.checkRotation(p.byteLength)}catch{this.closeLogFile(),this.openLogFile()}}else this.mode==="console"&&process.stderr.write(l)}debug(t,...e){this.write("debug",t,...e)}info(t,...e){this.write("info",t,...e)}warn(t,...e){this.write("warn",t,...e)}error(t,...e){this.write("error",t,...e)}dispose(){this.closeLogFile()}flush(){if(!(this.mode!=="file"||this.fd===null))try{a.fsyncSync(this.fd)}catch{}}getLogFilePath(){return this.currentLogFile}getLogDirectory(){return this.logDir}},E=null;function Ot(n=!1){E&&E.dispose(),E=new B(n)}function F(){return E||Ot(!1),E}var c={debug:(n,...t)=>F().debug(n,...t),info:(n,...t)=>F().info(n,...t),warn:(n,...t)=>F().warn(n,...t),error:(n,...t)=>F().error(n,...t)};import at from"fs";import Pt from"path";var k=300*1e3,O=3600*1e3,lt=10080*60*1e3,v=8*1024*1024,ct=3600*1e3,st=".pending",It=/\.reclaim-\d+-\d+$/;function P(){let n=process.env.DEVECO_CLI_DISABLE_TELEMETRY;return n==="1"||n==="true"}var Rt="upload-state.json";function ut(n){return Pt.join(n,Rt)}function Nt(){return{firstEventAt:null,lastUploadAt:null,lastRetryAt:null}}function j(n){try{let t=at.readFileSync(ut(n),"utf8"),e=JSON.parse(t);return{firstEventAt:typeof e.firstEventAt=="number"?e.firstEventAt:null,lastUploadAt:typeof e.lastUploadAt=="number"?e.lastUploadAt:null,lastRetryAt:typeof e.lastRetryAt=="number"?e.lastRetryAt:null}}catch{return Nt()}}function U(n,t){try{at.writeFileSync(ut(n),JSON.stringify(t),"utf8")}catch{}}function pt(n){let t=j(n);t.firstEventAt===null&&(t.firstEventAt=Date.now(),U(n,t))}function ft(n){let t=j(n);t.lastUploadAt=Date.now(),t.firstEventAt=null,U(n,t)}function dt(n){let t=j(n);t.lastRetryAt=Date.now(),U(n,t)}function mt(n){let t=n.match(/^telemetry-(\d{4})-(\d{2})-(\d{2})\.txt$/);if(!t)return null;let e=Date.parse(`${t[1]}-${t[2]}-${t[3]}T00:00:00`);return Number.isFinite(e)?e:null}function V(n){if(!n.startsWith("telemetry-"))return null;let t=It.exec(n),e=t?n.slice(0,t.index):n;if(!e.endsWith(st))return null;let r=e.slice(0,-st.length);return r.endsWith(".txt")?r:null}function gt(n){return V(n)!==null}import $t from"crypto";import I from"fs";import Mt from"path";var Bt="install-id";function jt(n){return Mt.join(n,Bt)}function ht(n){try{let t=I.readFileSync(n,"utf8").trim();return Ut(t)?t:null}catch{return null}}function Ut(n){return/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(n)}function yt(n){let t=jt(n),e=ht(t);if(e)return e;let r=$t.randomUUID();try{I.mkdirSync(n,{recursive:!0});try{I.writeFileSync(t,r,{flag:"wx"})}catch{let i=ht(t);if(i)return i;I.writeFileSync(t,r)}}catch{}return r}var w=class n{static MAX_BATCH=200;static MAX_PAYLOAD_BYTES=Math.floor(1.7*1024*1024);static TRACE_OS_VERSION="1.0";static COUNTRY_CODE="CN";static EVENT_PREFIX="devecocli_";uploader=new D;storageDir="";failedDir="";installId="";disabled=P();traceFileKey=Buffer.alloc(0);sessionId=vt.randomUUID();cliVersion="";devecoStudioVersion=null;sourceType="";cltVersion=null;nodeVersion="";initialTimer=null;intervalTimer=null;retryInitialTimer=null;retryTimer=null;flushChain=Promise.resolve();constructor(){c.debug(`[telemetry] instance created, sessionId=${this.sessionId}`)}init(t){this.storageDir=t,this.failedDir=m.join(t,"failed"),this.cliVersion="1.3.5-Test.1",this.nodeVersion=process.version,this.installId=yt(t).replace(/-/g,""),this.traceFileKey=et(t),u.mkdirSync(t,{recursive:!0}),u.mkdirSync(this.failedDir,{recursive:!0}),c.debug(`[telemetry] init: dir=${t}, failedDir=${this.failedDir}, cliVersion=${this.cliVersion}, os=${this.resolveOsName()}, arch=${this.resolveOsArch()}, node=${this.nodeVersion}`)}setStudioVersion(t){this.devecoStudioVersion=t,c.debug(`[telemetry] studio version set: ${t}`)}setSourceType(t){this.sourceType=t,c.debug(`[telemetry] sourceType set: ${t}`)}setCltVersion(t){this.cltVersion=t,c.debug(`[telemetry] CLT version set: ${t}`)}async track(t,e){if(this.disabled)return typeof e=="function"?e():void 0;if(!this.storageDir)throw new Error("Telemetry not initialized. Call init() first.");if(!e){await this.record(t,0,!0,null);return}if(typeof e!="function"){let o=e;await this.record(t,o.duration_ms,o.success,o.error_code);return}let r=e,i=Date.now();try{let o=await r(),s=Date.now()-i;return await this.record(t,s,!0,null),o}catch(o){let s=Date.now()-i,l=this.toErrorCode(o);throw await this.record(t,s,!1,l),o}}async record(t,e,r,i){let o=this.buildTraceEvent(t,e,r,i);try{let s=rt(JSON.stringify(o),this.traceFileKey);await u.promises.appendFile(this.currentFile(),s+`
|
|
3
|
-
`,"utf8"),pt(this.storageDir)}catch{}}buildTraceEvent(t,e,r,i){let o=`${n.EVENT_PREFIX}${t.event}`,s=Z.toObject(t);return s&&typeof s=="object"&&delete s.event,{countryCode:n.COUNTRY_CODE,event:o,eventtime:String(Date.now()),properties:{uid:this.installId,trace_uuid:vt.randomUUID(),trace_os_version:n.TRACE_OS_VERSION,os_arch:this.resolveOsArch(),action:o,trace_os_name:this.resolveOsName(),version:`${this.cliVersion}_${this.resolveOsSuffix()}`,deveco_studio_version:this.formatVersion(this.devecoStudioVersion),command_line_version:this.formatVersion(this.cltVersion),source_type:this.sourceType,session_id:this.sessionId,node_version:this.nodeVersion,duration_ms:e,success:r,error_code:i,event_detail:s}}}toErrorCode(t){return t instanceof Error?t.code??t.name:"UnknownError"}resolveOsArch(){let t=z.arch();return t==="x64"?"amd64":t}resolveOsName(){switch(process.platform){case"win32":{let t=z.release().split(".");return(parseInt(t[t.length-1],10)||0)>=22e3?"Windows 11":"Windows 10"}case"darwin":return"macOS";case"linux":return"Linux";default:return process.platform}}resolveOsSuffix(){switch(process.platform){case"win32":return"windows";case"darwin":return z.arch()==="arm64"?"mac_arm":"mac";default:return"linux"}}formatVersion(t){return t?`${t}_${this.resolveOsSuffix()}`:""}dateString(){let t=new Date,e=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0");return`${t.getFullYear()}-${e}-${r}`}currentFile(){return m.join(this.storageDir,`telemetry-${this.dateString()}.txt`)}startScheduler(){if(this.stopScheduler(),this.disabled){c.debug("[telemetry] scheduler not started (telemetry disabled)");return}c.debug(`[telemetry] scheduler started (flush every ${k/1e3}s, retry failed every ${O/1e3}s)`),this.initialTimer=setTimeout(()=>{this.flush().catch(()=>{}),this.intervalTimer=setInterval(()=>{this.flush().catch(()=>{})},k)},k),this.retryInitialTimer=setTimeout(()=>{this.retryFailed().catch(()=>{}),this.retryTimer=setInterval(()=>{this.retryFailed().catch(()=>{})},O)},O)}stopScheduler(){this.initialTimer&&(clearTimeout(this.initialTimer),this.initialTimer=null),this.intervalTimer&&(clearInterval(this.intervalTimer),this.intervalTimer=null),this.retryInitialTimer&&(clearTimeout(this.retryInitialTimer),this.retryInitialTimer=null),this.retryTimer&&(clearInterval(this.retryTimer),this.retryTimer=null),c.debug("[telemetry] scheduler stopped")}async flush(){return this.disabled?!0:this.runExclusive(()=>this.performFlush())}async performFlush(){if(!this.storageDir)throw new Error("Telemetry not initialized. Call init() first.");let t=await this.listPendingFiles(),e=!0;for(let r of t)await this.flushFile(r)||(e=!1);return ft(this.storageDir),e}async retryFailed(){return this.disabled?!0:this.runExclusive(()=>this.performRetryFailed())}async performRetryFailed(){if(!this.storageDir)throw new Error("Telemetry not initialized. Call init() first.");await this.reclaimStalePending();let t=Date.now(),e;try{e=await u.promises.readdir(this.failedDir)}catch{return!0}let r=e.filter(o=>o.startsWith("telemetry-")&&o.endsWith(".txt")).map(o=>m.join(this.failedDir,o)),i=!0;for(let o of r){let s=m.basename(o),l=mt(s);if(l!==null){if(t-l>lt){try{await u.promises.unlink(o)}catch{}continue}await this.flushFile(o)||(i=!1)}}return i||c.warn("[telemetry] retry failed"),dt(this.storageDir),i}async reclaimStalePending(){let t=Date.now();for(let e of[this.storageDir,this.failedDir]){let r;try{r=await u.promises.readdir(e)}catch{continue}for(let i of r)gt(i)&&await this.reclaimOrphan(m.join(e,i),t)}}async reclaimOrphan(t,e){let r;try{let h=await u.promises.stat(t);if(e-h.mtimeMs<ct)return;r=h.size}catch{return}let i=m.dirname(t),o=V(m.basename(t));if(o===null)return;let s=await this.claimOrphan(t,i,o);if(s===null)return;let l=m.join(i,o),p=v-await this.fileSize(l);if(r>p){try{await u.promises.unlink(s)}catch{}c.warn(`[telemetry] dropped stale orphan pending: ${s} (${r} bytes > budget ${p})`);return}if(await this.mergeOrphanInto(s,l)){c.warn(`[telemetry] reclaimed orphan pending: ${s} (${r} bytes)`);return}c.warn(`[telemetry] merge failed, kept orphan pending for retry: ${s} (${r} bytes)`)}async claimOrphan(t,e,r){let i=m.join(e,`${r}.pending.reclaim-${process.pid}-${Date.now()}`);try{await u.promises.rename(t,i)}catch{return null}return await this.touch(i),i}async mergeOrphanInto(t,e){try{await u.promises.appendFile(e,await u.promises.readFile(t))}catch(r){return c.warn(`[telemetry] merge orphan pending failed: ${t} -> ${e}: ${r instanceof Error?r.message:String(r)}`),!1}try{await u.promises.unlink(t)}catch(r){c.warn(`[telemetry] merged but failed to remove orphan pending: ${t}: ${r instanceof Error?r.message:String(r)}`)}return!0}async fileSize(t){try{return(await u.promises.stat(t)).size}catch{return 0}}async touch(t){let e=new Date;try{await u.promises.utimes(t,e,e)}catch{}}runExclusive(t){let e=()=>t(),r=this.flushChain.then(e,e);return this.flushChain=r.then(()=>{},()=>{}),r}async listPendingFiles(){let t;try{t=await u.promises.readdir(this.storageDir)}catch{return[]}return t.filter(e=>e.startsWith("telemetry-")&&e.endsWith(".txt")).map(e=>m.join(this.storageDir,e)).sort()}async flushFile(t){let e=await this.fileSize(t);if(e>v){c.warn(`[telemetry] ${m.basename(t)} is ${e} bytes (> ${v}), dropped without uploading`);try{await u.promises.unlink(t)}catch{}return!0}let r=t+".pending";try{await u.promises.rename(t,r)}catch{return!1}await this.touch(r);let i;try{i=await u.promises.readFile(r,"utf8")}catch{return!1}let o=i.split(`
|
|
4
|
-
`).map(s=>s.trim()).filter(Boolean);if(o.length===0){try{await u.promises.unlink(r)}catch{}return!0}return this.uploadInBatches(r,o)}collectDecryptBatch(t,e){let r=[],i=16,o=e;for(;o<t.length&&r.length<n.MAX_BATCH;){let s=nt(t[o],this.traceFileKey);if(s===null){o++;continue}let l=Buffer.byteLength(s,"utf8")+1;if(r.length>0&&i+l>n.MAX_PAYLOAD_BYTES)break;r.push(s),i+=l,o++}return{batch:r,next:o}}async uploadInBatches(t,e){let r=0;for(;r<e.length;){let i=r,{batch:o,next:s}=this.collectDecryptBatch(e,r);r=s;let l=this.buildPayloadItems(o);if(l.length===0)continue;let p=JSON.stringify(l),h=!1;try{h=await this.uploader.upload(p,this.installId)}catch{}if(!h){c.warn("[telemetry] upload failed");let T=e.slice(i).join(`
|
|
5
|
-
`)+`
|
|
6
|
-
`;return await this.moveToFailed(t,T),!1}}try{await u.promises.unlink(t)}catch{}return!0}buildPayloadItems(t){let e=[];for(let r of t)try{let i=JSON.parse(r);e.push({action:i.event,detail:JSON.stringify(i.properties),timestamp:Number(i.eventtime)||Date.now()})}catch{}return e}async moveToFailed(t,e){let r=m.basename(t,".pending"),i=m.join(this.failedDir,r),o=e.split(`
|
|
7
|
-
`).filter(Boolean),s=v-await this.fileSize(i),l=this.takeNewestWithinBudget(o,s);l.length<o.length&&c.warn(`[telemetry] failed file capped at ${v} bytes, dropped ${o.length-l.length} older events`);try{l.length>0&&await u.promises.appendFile(i,l.join(`
|
|
8
|
-
`)+`
|
|
9
|
-
`,"utf8")}catch{return}try{await u.promises.unlink(t)}catch{}}takeNewestWithinBudget(t,e){if(e<=0)return[];let r=[],i=0;for(let o=t.length-1;o>=0;o--){let s=Buffer.byteLength(t[o],"utf8")+1;if(i+s>e)break;i+=s,r.push(t[o])}return r.reverse(),r}};var x=new w;import{spawn as Ge}from"child_process";import{existsSync as Ze}from"fs";import{dirname as tr,join as er}from"path";import{fileURLToPath as nr}from"url";var zt=Vt.join(X(),"TraceLogData");x.init(zt);(async()=>{try{await x.flush(),await x.retryFailed()}catch(n){c.warn("[telemetry] background upload error:",n),process.exit(1)}})();
|
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"permissionName": "ohos.permission.SYSTEM_FLOAT_WINDOW",
|
|
4
|
-
"permissionDisplayName": "SYSTEM_FLOAT_WINDOW",
|
|
5
|
-
"permissionHelpUrlKey": "acl.system.float.window.instead.url",
|
|
6
|
-
"permissionInsteadName": "acl.SYSTEM_FLOAT_WINDOW.instead.name",
|
|
7
|
-
"minSupportApiLevel": "9"
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
"permissionName": "ohos.permission.READ_CONTACTS",
|
|
11
|
-
"permissionDisplayName": "READ_CONTACTS",
|
|
12
|
-
"permissionHelpUrlKey": "acl.read.contacts.instead.url",
|
|
13
|
-
"permissionInsteadName": "acl.READ_CONTACTS.instead.name",
|
|
14
|
-
"minSupportApiLevel": "8"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"permissionName": "ohos.permission.WRITE_CONTACTS",
|
|
18
|
-
"permissionDisplayName": "WRITE_CONTACTS",
|
|
19
|
-
"minSupportApiLevel": "8"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"permissionName": "ohos.permission.READ_IMAGEVIDEO",
|
|
23
|
-
"permissionDisplayName": "READ_IMAGEVIDEO",
|
|
24
|
-
"permissionHelpUrlKey": "acl.read.image.video.instead.url",
|
|
25
|
-
"permissionInsteadName": "acl.READ_IMAGEVIDEO.instead.name",
|
|
26
|
-
"minSupportApiLevel": "9"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"permissionName": "ohos.permission.WRITE_IMAGEVIDEO",
|
|
30
|
-
"permissionDisplayName": "WRITE_IMAGEVIDEO",
|
|
31
|
-
"permissionHelpUrlKey": "acl.write.image.video.instead.url",
|
|
32
|
-
"permissionInsteadName": "acl.WRITE_IMAGEVIDEO.instead.name",
|
|
33
|
-
"minSupportApiLevel": "9"
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"permissionName": "ohos.permission.READ_AUDIO",
|
|
37
|
-
"permissionDisplayName": "READ_AUDIO",
|
|
38
|
-
"permissionHelpUrlKey": "acl.read.audio.instead.url",
|
|
39
|
-
"permissionInsteadName": "acl.READ_AUDIO.instead.name",
|
|
40
|
-
"minSupportApiLevel": "9"
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
"permissionName": "ohos.permission.WRITE_AUDIO",
|
|
44
|
-
"permissionDisplayName": "WRITE_AUDIO",
|
|
45
|
-
"permissionHelpUrlKey": "acl.write.audio.instead.url",
|
|
46
|
-
"permissionInsteadName": "acl.WRITE_AUDIO.instead.name",
|
|
47
|
-
"minSupportApiLevel": "9"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"permissionName": "ohos.permission.READ_PASTEBOARD",
|
|
51
|
-
"permissionDisplayName": "READ_PASTEBOARD",
|
|
52
|
-
"permissionHelpUrlKey": "acl.read.pasteboard.instead.url",
|
|
53
|
-
"permissionInsteadName": "acl.READ_PASTEBOARD.instead.name",
|
|
54
|
-
"minSupportApiLevel": "11"
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
"permissionName": "ohos.permission.ACCESS_DDK_USB",
|
|
58
|
-
"permissionDisplayName": "ACCESS_DDK_USB",
|
|
59
|
-
"minSupportApiLevel": "11"
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"permissionName": "ohos.permission.ACCESS_DDK_HID",
|
|
63
|
-
"permissionDisplayName": "ACCESS_DDK_HID",
|
|
64
|
-
"minSupportApiLevel": "11"
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
"permissionName": "ohos.permission.FILE_ACCESS_PERSIST",
|
|
68
|
-
"permissionDisplayName": "FILE_ACCESS_PERSIST",
|
|
69
|
-
"minSupportApiLevel": "11"
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
"permissionName": "ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY",
|
|
73
|
-
"permissionDisplayName": "READ_WRITE_DOWNLOAD_DIRECTORY",
|
|
74
|
-
"minSupportApiLevel": "11"
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
"permissionName": "ohos.permission.READ_WRITE_DESKTOP_DIRECTORY",
|
|
78
|
-
"permissionDisplayName": "READ_WRITE_DESKTOP_DIRECTORY",
|
|
79
|
-
"minSupportApiLevel": "11"
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
"permissionName": "ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY",
|
|
83
|
-
"permissionDisplayName": "READ_WRITE_DOCUMENTS_DIRECTORY",
|
|
84
|
-
"minSupportApiLevel": "11"
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"permissionName": "ohos.permission.INPUT_MONITORING",
|
|
88
|
-
"permissionDisplayName": "INPUT_MONITORING",
|
|
89
|
-
"minSupportApiLevel": "12"
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
"permissionName": "ohos.permission.INTERCEPT_INPUT_EVENT",
|
|
93
|
-
"permissionDisplayName": "INTERCEPT_INPUT_EVENT",
|
|
94
|
-
"minSupportApiLevel": "12"
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
"permissionName": "ohos.permission.SHORT_TERM_WRITE_IMAGEVIDEO",
|
|
98
|
-
"permissionDisplayName": "SHORT_TERM_WRITE_IMAGEVIDEO",
|
|
99
|
-
"minSupportApiLevel": "12"
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
"permissionName": "ohos.permission.kernel.ALLOW_WRITABLE_CODE_MEMORY",
|
|
103
|
-
"permissionDisplayName": "ALLOW_WRITABLE_CODE_MEMORY",
|
|
104
|
-
"minSupportApiLevel": "14"
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
"permissionName": "ohos.permission.kernel.DISABLE_CODE_MEMORY_PROTECTION",
|
|
108
|
-
"permissionDisplayName": "DISABLE_CODE_MEMORY_PROTECTION",
|
|
109
|
-
"minSupportApiLevel": "14"
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
"permissionName": "ohos.permission.kernel.ALLOW_EXECUTABLE_FORT_MEMORY",
|
|
113
|
-
"permissionDisplayName": "ALLOW_EXECUTABLE_FORT_MEMORY",
|
|
114
|
-
"minSupportApiLevel": "14"
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
"permissionName": "ohos.permission.GET_WIFI_PEERS_MAC",
|
|
118
|
-
"permissionDisplayName": "GET_WIFI_PEERS_MAC",
|
|
119
|
-
"minSupportApiLevel": "8"
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
"permissionName": "ohos.permission.MANAGE_PASTEBOARD_APP_SHARE_OPTION",
|
|
123
|
-
"permissionDisplayName": "MANAGE_PASTEBOARD_APP_SHARE_OPTION",
|
|
124
|
-
"minSupportApiLevel": "14"
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
"permissionName": "ohos.permission.MANAGE_UDMF_APP_SHARE_OPTION",
|
|
128
|
-
"permissionDisplayName": "MANAGE_UDMF_APP_SHARE_OPTION",
|
|
129
|
-
"minSupportApiLevel": "14"
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
"permissionName": "ohos.permission.READ_WRITE_USER_FILE",
|
|
133
|
-
"permissionDisplayName": "READ_WRITE_USER_FILE",
|
|
134
|
-
"minSupportApiLevel": "13"
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
"permissionName": "ohos.permission.READ_WRITE_USB_DEV",
|
|
138
|
-
"permissionDisplayName": "READ_WRITE_USB_DEV",
|
|
139
|
-
"minSupportApiLevel": "13"
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
"permissionName": "ohos.permission.USE_FRAUD_CALL_LOG_PICKER",
|
|
143
|
-
"permissionDisplayName": "USE_FRAUD_CALL_LOG_PICKER",
|
|
144
|
-
"minSupportApiLevel": "15"
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
"permissionName": "ohos.permission.USE_FRAUD_MESSAGES_PICKER",
|
|
148
|
-
"permissionDisplayName": "USE_FRAUD_MESSAGES_PICKER",
|
|
149
|
-
"minSupportApiLevel": "15"
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
"permissionName": "ohos.permission.ACCESS_DISK_PHY_INFO",
|
|
153
|
-
"permissionDisplayName": "ACCESS_DISK_PHY_INFO",
|
|
154
|
-
"minSupportApiLevel": "15"
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
"permissionName": "ohos.permission.SET_PAC_URL",
|
|
158
|
-
"permissionDisplayName": "SET_PAC_URL",
|
|
159
|
-
"minSupportApiLevel": "15"
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
"permissionName": "ohos.permission.PERSONAL_MANAGE_RESTRICTIONS",
|
|
163
|
-
"permissionDisplayName": "PERSONAL_MANAGE_RESTRICTIONS",
|
|
164
|
-
"minSupportApiLevel": "15"
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
"permissionName": "ohos.permission.START_PROVISIONING_MESSAGE",
|
|
168
|
-
"permissionDisplayName": "START_PROVISIONING_MESSAGE",
|
|
169
|
-
"minSupportApiLevel": "15"
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
"permissionName": "ohos.permission.PRELOAD_FILE",
|
|
173
|
-
"permissionDisplayName": "PRELOAD_FILE",
|
|
174
|
-
"minSupportApiLevel": "15"
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
"permissionName": "ohos.permission.ACCESS_VIRTUAL_SCREEN",
|
|
178
|
-
"permissionDisplayName": "ACCESS_VIRTUAL_SCREEN",
|
|
179
|
-
"minSupportApiLevel": "16"
|
|
180
|
-
},
|
|
181
|
-
{
|
|
182
|
-
"permissionName": "ohos.permission.PERSISTENT_BLUETOOTH_PEERS_MAC",
|
|
183
|
-
"permissionDisplayName": "PERSISTENT_BLUETOOTH_PEERS_MAC",
|
|
184
|
-
"minSupportApiLevel": "16"
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
"permissionName": "ohos.permission.ACCESS_DDK_USB_SERIAL",
|
|
188
|
-
"permissionDisplayName": "ACCESS_DDK_USB_SERIAL",
|
|
189
|
-
"minSupportApiLevel": "18"
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
"permissionName": "ohos.permission.ACCESS_DDK_SCSI_PERIPHERAL",
|
|
193
|
-
"permissionDisplayName": "ACCESS_DDK_SCSI_PERIPHERAL",
|
|
194
|
-
"minSupportApiLevel": "18"
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
"permissionName": "ohos.permission.USE_FRAUD_APP_PICKER",
|
|
198
|
-
"permissionDisplayName": "USE_FRAUD_APP_PICKER",
|
|
199
|
-
"minSupportApiLevel": "18"
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
"permissionName": "ohos.permission.kernel.DISABLE_GOTPLT_RO_PROTECTION",
|
|
203
|
-
"permissionDisplayName": "DISABLE_GOTPLT_RO_PROTECTION",
|
|
204
|
-
"minSupportApiLevel": "17"
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
"permissionName": "ohos.permission.MANAGE_APN_SETTING",
|
|
208
|
-
"permissionDisplayName": "MANAGE_APN_SETTING",
|
|
209
|
-
"minSupportApiLevel": "16"
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
"permissionName": "ohos.permission.MANAGE_SCREEN_TIME_GUARD",
|
|
213
|
-
"permissionDisplayName": "MANAGE_SCREEN_TIME_GUARD",
|
|
214
|
-
"minSupportApiLevel": "20"
|
|
215
|
-
},
|
|
216
|
-
{
|
|
217
|
-
"permissionName": "ohos.permission.CUSTOMIZE_SAVE_BUTTON",
|
|
218
|
-
"permissionDisplayName": "CUSTOMIZE_SAVE_BUTTON",
|
|
219
|
-
"minSupportApiLevel": "20"
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
"permissionName": "ohos.permission.GET_ABILITY_INFO",
|
|
223
|
-
"permissionDisplayName": "GET_ABILITY_INFO",
|
|
224
|
-
"minSupportApiLevel": "20"
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
"permissionName": "ohos.permission.DLP_GET_HIDE_STATUS",
|
|
228
|
-
"permissionDisplayName": "DLP_GET_HIDE_STATUS",
|
|
229
|
-
"minSupportApiLevel": "20"
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
"permissionName": "ohos.permission.ACCESS_FIDO2_ONLINEAUTH",
|
|
233
|
-
"permissionDisplayName": "ACCESS_FIDO2_ONLINEAUTH",
|
|
234
|
-
"minSupportApiLevel": "20"
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
"permissionName": "ohos.permission.LINKTURBO",
|
|
238
|
-
"permissionDisplayName": "LINKTURBO",
|
|
239
|
-
"minSupportApiLevel": "20"
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
"permissionName": "ohos.permission.USE_FLOAT_BALL",
|
|
243
|
-
"permissionDisplayName": "USE_FLOAT_BALL",
|
|
244
|
-
"minSupportApiLevel": "20"
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
"permissionName": "ohos.permission.GET_ETHERNET_LOCAL_MAC",
|
|
248
|
-
"permissionDisplayName": "GET_ETHERNET_LOCAL_MAC",
|
|
249
|
-
"minSupportApiLevel": "20"
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
"permissionName": "ohos.permission.GET_WIFI_LOCAL_MAC",
|
|
253
|
-
"permissionDisplayName": "GET_WIFI_LOCAL_MAC",
|
|
254
|
-
"minSupportApiLevel": "20"
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
"permissionName": "ohos.permission.READ_LOCAL_DEVICE_NAME",
|
|
258
|
-
"permissionDisplayName": "READ_LOCAL_DEVICE_NAME",
|
|
259
|
-
"minSupportApiLevel": "20"
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
"permissionName": "ohos.permission.ACCESS_NET_TRACE_INFO",
|
|
263
|
-
"permissionDisplayName": "ACCESS_NET_TRACE_INFO",
|
|
264
|
-
"minSupportApiLevel": "20"
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
"permissionName": "ohos.permission.KEEP_BACKGROUND_RUNNING_SYSTEM",
|
|
268
|
-
"permissionDisplayName": "KEEP_BACKGROUND_RUNNING_SYSTEM",
|
|
269
|
-
"minSupportApiLevel": "20"
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
"permissionName": "ohos.permission.atomicService.MANAGE_STORAGE",
|
|
273
|
-
"permissionDisplayName": "MANAGE_STORAGE",
|
|
274
|
-
"minSupportApiLevel": "20"
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
"permissionName": "ohos.permission.WEB_NATIVE_MESSAGING",
|
|
278
|
-
"permissionDisplayName": "WEB_NATIVE_MESSAGING",
|
|
279
|
-
"minSupportApiLevel": "21"
|
|
280
|
-
},
|
|
281
|
-
{
|
|
282
|
-
"permissionName": "ohos.permission.HOOK_KEY_EVENT",
|
|
283
|
-
"permissionDisplayName": "HOOK_KEY_EVENT",
|
|
284
|
-
"minSupportApiLevel": "21"
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
"permissionName": "ohos.permission.SET_SYSTEMSHARE_APPLAUNCHTRUSTLIST",
|
|
288
|
-
"permissionDisplayName": "SET_SYSTEMSHARE_APPLAUNCHTRUSTLIST",
|
|
289
|
-
"minSupportApiLevel": "21"
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
"permissionName": "ohos.permission.SUBSCRIBE_NOTIFICATION",
|
|
293
|
-
"permissionDisplayName": "SUBSCRIBE_NOTIFICATION",
|
|
294
|
-
"minSupportApiLevel": "22"
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
"permissionName": "ohos.permission.ACCESS_USER_FULL_DISK",
|
|
298
|
-
"permissionDisplayName": "ACCESS_USER_FULL_DISK",
|
|
299
|
-
"minSupportApiLevel": "22"
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
"permissionName": "ohos.permission.CUSTOM_SCREEN_RECORDING",
|
|
303
|
-
"permissionDisplayName": "CUSTOM_SCREEN_RECORDING",
|
|
304
|
-
"minSupportApiLevel": "22"
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
"permissionName": "ohos.permission.GET_IP_MAC_INFO",
|
|
308
|
-
"permissionDisplayName": "GET_IP_MAC_INFO",
|
|
309
|
-
"minSupportApiLevel": "22"
|
|
310
|
-
}
|
|
311
|
-
]
|