@deveco-test/deveco-cli-openharmony-arm64 0.1.7 → 0.4.0-TD.3.6

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.
Files changed (42) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +837 -837
  3. package/SKILL.md +187 -186
  4. package/THIRD-PARTY-LICENSES +4 -4
  5. package/dist/cli.js +135 -126
  6. package/dist/internal/telemetry-upload-background.js +9 -0
  7. package/docs.zip +2 -2
  8. package/index.zip +0 -0
  9. package/package.json +108 -108
  10. package/scripts/install-better-sqlite3.mjs +51 -51
  11. package/scripts/install-jieba-wasm.mjs +47 -47
  12. package/scripts/lib/better-sqlite3-vendor.mjs +128 -128
  13. package/scripts/lib/cli-data-dir.mjs +44 -44
  14. package/scripts/lib/doc-init-log-path.mjs +15 -15
  15. package/scripts/lib/jieba-wasm-vendor.mjs +102 -102
  16. package/scripts/postinstall.mjs +64 -64
  17. package/src/resources/aclPermission/aclPermissionsInfo.json +310 -310
  18. package/templates/application/AppScope/app.json5 +10 -10
  19. package/templates/application/AppScope/resources/base/element/string.json +8 -8
  20. package/templates/application/AppScope/resources/base/media/layered_image.json +6 -6
  21. package/templates/application/build-profile.json5 +41 -41
  22. package/templates/application/code-linter.json5 +31 -31
  23. package/templates/application/entry/build-profile.json5 +32 -32
  24. package/templates/application/entry/gitignore.txt +5 -5
  25. package/templates/application/entry/hvigorfile.ts +7 -7
  26. package/templates/application/entry/obfuscation-rules.txt +19 -19
  27. package/templates/application/entry/oh-package.json5 +10 -10
  28. package/templates/application/entry/src/main/ets/entryability/EntryAbility.ets +62 -62
  29. package/templates/application/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +30 -30
  30. package/templates/application/entry/src/main/ets/pages/Index.ets +37 -37
  31. package/templates/application/entry/src/main/module.json5 +49 -49
  32. package/templates/application/entry/src/main/resources/base/element/color.json +7 -7
  33. package/templates/application/entry/src/main/resources/base/element/float.json +8 -8
  34. package/templates/application/entry/src/main/resources/base/element/string.json +15 -15
  35. package/templates/application/entry/src/main/resources/base/media/layered_image.json +6 -6
  36. package/templates/application/entry/src/main/resources/base/profile/backup_config.json +2 -2
  37. package/templates/application/entry/src/main/resources/base/profile/main_pages.json +5 -5
  38. package/templates/application/entry/src/main/resources/dark/element/color.json +7 -7
  39. package/templates/application/gitignore.txt +11 -11
  40. package/templates/application/hvigor/hvigor-config.json5 +23 -23
  41. package/templates/application/hvigorfile.ts +7 -7
  42. package/templates/application/oh-package.json5 +10 -10
@@ -0,0 +1,9 @@
1
+ import Wt from"path";import*as S from"fs";import*as Y from"path";import{homedir as xt}from"os";import*as W from"fs";import*as g from"path";function J(n){let t=g.resolve(n),e=[],r=t;for(;;)try{let i=W.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 N(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=N(n);if(!t)throw new Error("Path must not be empty.");return J(t)}var Et="deveco-cli",X,$=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===""?"":N(n))||Y.join(xt(),".local","share",Et);try{return K(e)}catch(r){throw new $(r instanceof Error?r.message:String(r))}}function G(){if(X!==void 0)return X;let n=wt();try{if(S.existsSync(n))return S.realpathSync(n)}catch{}return n}import bt from"crypto";import c from"fs";import P from"os";import m from"path";import Ct from"https";var q={devecoApiTraceUpload:"https://cn.devecostudio.huawei.com/codeGenie/cli/trace/upload"};var D=class n{static ENDPOINT=q.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=Ct.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 w=[];h.on("data",Tt=>w.push(Tt)),h.on("end",()=>{s({code:h.statusCode??0,body:Buffer.concat(w).toString("utf8")})})});p.on("timeout",()=>{p.destroy(new Error("request timeout"))}),p.on("error",l),p.write(r),p.end()})}};var Z={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()},M=class{constructor(t={}){this.config=t}config;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??Z.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}},Q=new M({namingStrategy:Z.snakeCase,fieldNames:{}});import b from"crypto";import C from"fs";import Lt from"path";var L="aes-256-gcm",_t=12,Ft="deveco-cli-trace-file",At="trace-file-secret",et=32;function tt(n){try{let t=C.readFileSync(n,"utf8").trim();return t&&Buffer.from(t,"base64").length===et?t:null}catch{return null}}function rt(n){let t=Lt.join(n,At),e=tt(t);if(e)return j(e);let r=b.randomBytes(et).toString("base64");try{C.mkdirSync(n,{recursive:!0});try{C.writeFileSync(t,r,{flag:"wx"})}catch{let i=tt(t);if(i)return j(i);C.writeFileSync(t,r)}}catch{}return j(r)}function j(n){return b.createHash("sha256").update(Ft).update(n).digest()}function nt(n,t){let e=b.randomBytes(_t),r=b.createCipheriv(L,t,e),i=Buffer.concat([r.update(n,"utf8"),r.final()]),o={version:1,algorithm:L,ciphertext:i.toString("base64"),iv:e.toString("base64"),authTag:r.getAuthTag().toString("base64")};return JSON.stringify(o)}function it(n,t){let e;try{e=JSON.parse(n)}catch{return null}if(!kt(e))return n;try{let r=b.createDecipheriv(L,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 kt(n){if(!n||typeof n!="object")return!1;let t=n;return t.version===1&&t.algorithm===L&&typeof t.ciphertext=="string"&&typeof t.iv=="string"&&typeof t.authTag=="string"}import*as a from"fs";import*as A from"path";import*as _ from"os";import*as y from"path";import ye from"json5";import*as ot from"os";function B(){return Ot().toLowerCase().includes("openharmony")}function Ot(){return ot.platform()}var Se=[B()?".bitfun":".idea",".deveco",B()?".cxx":"cxx","compile_commands.json"];function st(){if(process.platform==="win32"){let n=process.env.LOCALAPPDATA??y.join(_.homedir(),"AppData","Local");return y.join(n,"devecocli-mcp-server","logs")}return process.platform==="darwin"?y.join(_.homedir(),"Library","Logs","devecocli-mcp-server"):y.join(_.homedir(),".local","share","devecocli-mcp-server","logs")}var at="mcp-server.log",It="mcp-server",Rt={maxSize:10*1024*1024,maxFiles:4},U=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={...Rt,...e},this.minLevel=t?"debug":"info",t?(this.mode="console",this.logDir=null,this.currentLogFile=null):(this.mode="file",this.logDir=st(),this.currentLogFile=A.join(this.logDir,at),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,`${It}-${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===at||/^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()}] ${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}},T=null;function Pt(n=!1){T&&T.dispose(),T=new U(n)}function F(){return T||Pt(!1),T}var u={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 ct from"fs";import Nt from"path";var k=300*1e3,O=3600*1e3,ut=10080*60*1e3,v=8*1024*1024,pt=3600*1e3,lt=".pending",$t=/\.reclaim-\d+-\d+$/;function I(){let n=process.env.DEVECO_CLI_DISABLE_TELEMETRY;return n==="1"||n==="true"}var Mt="upload-state.json";function ft(n){return Nt.join(n,Mt)}function jt(){return{firstEventAt:null,lastUploadAt:null,lastRetryAt:null}}function V(n){try{let t=ct.readFileSync(ft(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 jt()}}function z(n,t){try{ct.writeFileSync(ft(n),JSON.stringify(t),"utf8")}catch{}}function dt(n){let t=V(n);t.firstEventAt===null&&(t.firstEventAt=Date.now(),z(n,t))}function mt(n){let t=V(n);t.lastUploadAt=Date.now(),t.firstEventAt=null,z(n,t)}function gt(n){let t=V(n);t.lastRetryAt=Date.now(),z(n,t)}function ht(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 H(n){if(!n.startsWith("telemetry-"))return null;let t=$t.exec(n),e=t?n.slice(0,t.index):n;if(!e.endsWith(lt))return null;let r=e.slice(0,-lt.length);return r.endsWith(".txt")?r:null}function yt(n){return H(n)!==null}import Bt from"crypto";import R from"fs";import Ut from"path";var Vt="install-id";function zt(n){return Ut.join(n,Vt)}function vt(n){try{let t=R.readFileSync(n,"utf8").trim();return Ht(t)?t:null}catch{return null}}function Ht(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 St(n){let t=zt(n),e=vt(t);if(e)return e;let r=Bt.randomUUID();try{R.mkdirSync(n,{recursive:!0});try{R.writeFileSync(t,r,{flag:"wx"})}catch{let i=vt(t);if(i)return i;R.writeFileSync(t,r)}}catch{}return r}var x=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=I();traceFileKey=Buffer.alloc(0);sessionId=bt.randomUUID();cliVersion="";devecoStudioVersion=null;sourceType="";cltVersion=null;nodeVersion="";initialTimer=null;intervalTimer=null;retryInitialTimer=null;retryTimer=null;flushChain=Promise.resolve();constructor(){u.debug(`[telemetry] instance created, sessionId=${this.sessionId}`)}init(t){this.storageDir=t,this.failedDir=m.join(t,"failed"),this.cliVersion="0.4.0-TD.3.6",this.nodeVersion=process.version,this.installId=St(t).replace(/-/g,""),this.traceFileKey=rt(t),c.mkdirSync(t,{recursive:!0}),c.mkdirSync(this.failedDir,{recursive:!0}),u.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,u.debug(`[telemetry] studio version set: ${t}`)}setSourceType(t){this.sourceType=t,u.debug(`[telemetry] sourceType set: ${t}`)}setCltVersion(t){this.cltVersion=t,u.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=nt(JSON.stringify(o),this.traceFileKey);await c.promises.appendFile(this.currentFile(),s+`
3
+ `,"utf8"),dt(this.storageDir)}catch{}}buildTraceEvent(t,e,r,i){let o=`${n.EVENT_PREFIX}${t.event}`,s=Q.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:bt.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,ram:this.resolveTotalRam(),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=P.arch();return t==="x64"?"amd64":t}resolveOsName(){switch(process.platform){case"win32":{let t=P.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 P.arch()==="arm64"?"mac_arm":"mac";default:return"linux"}}resolveTotalRam(){return`${Math.round(P.totalmem()/1024)}KB`}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){u.debug("[telemetry] scheduler not started (telemetry disabled)");return}u.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),u.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 mt(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 c.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=ht(s);if(l!==null){if(t-l>ut){try{await c.promises.unlink(o)}catch{}continue}await this.flushFile(o)||(i=!1)}}return i||u.warn("[telemetry] retry failed"),gt(this.storageDir),i}async reclaimStalePending(){let t=Date.now();for(let e of[this.storageDir,this.failedDir]){let r;try{r=await c.promises.readdir(e)}catch{continue}for(let i of r)yt(i)&&await this.reclaimOrphan(m.join(e,i),t)}}async reclaimOrphan(t,e){let r;try{let h=await c.promises.stat(t);if(e-h.mtimeMs<pt)return;r=h.size}catch{return}let i=m.dirname(t),o=H(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 c.promises.unlink(s)}catch{}u.warn(`[telemetry] dropped stale orphan pending: ${s} (${r} bytes > budget ${p})`);return}if(await this.mergeOrphanInto(s,l)){u.warn(`[telemetry] reclaimed orphan pending: ${s} (${r} bytes)`);return}u.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 c.promises.rename(t,i)}catch{return null}return await this.touch(i),i}async mergeOrphanInto(t,e){try{await c.promises.appendFile(e,await c.promises.readFile(t))}catch(r){return u.warn(`[telemetry] merge orphan pending failed: ${t} -> ${e}: ${r instanceof Error?r.message:String(r)}`),!1}try{await c.promises.unlink(t)}catch(r){u.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 c.promises.stat(t)).size}catch{return 0}}async touch(t){let e=new Date;try{await c.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 c.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){u.warn(`[telemetry] ${m.basename(t)} is ${e} bytes (> ${v}), dropped without uploading`);try{await c.promises.unlink(t)}catch{}return!0}let r=t+".pending";try{await c.promises.rename(t,r)}catch{return!1}await this.touch(r);let i;try{i=await c.promises.readFile(r,"utf8")}catch{return!1}let o=i.split(`
4
+ `).map(s=>s.trim()).filter(Boolean);if(o.length===0){try{await c.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=it(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){u.warn("[telemetry] upload failed");let w=e.slice(i).join(`
5
+ `)+`
6
+ `;return await this.moveToFailed(t,w),!1}}try{await c.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&&u.warn(`[telemetry] failed file capped at ${v} bytes, dropped ${o.length-l.length} older events`);try{l.length>0&&await c.promises.appendFile(i,l.join(`
8
+ `)+`
9
+ `,"utf8")}catch{return}try{await c.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 E=new x;import{spawn as qe}from"child_process";import{existsSync as Qe}from"fs";import{dirname as er,join as rr}from"path";import{fileURLToPath as ir}from"url";var Jt=Wt.join(G(),"TraceLogData");E.init(Jt);(async()=>{try{await E.flush(),await E.retryFailed()}catch(n){u.warn("[telemetry] background upload error:",n),process.exit(1)}})();
package/docs.zip CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/docs.zip
3
- size: 40550917 bytes
4
- sha256: 7f4183fb41f8c2224ec9941d666ee0a6e178741c4cc511d4bba53d535273b463
3
+ size: 40538363 bytes
4
+ sha256: 69cea82c1729991ed37837dc115cb43463b45b6381de6005f9d0c153399f6d1f
package/index.zip CHANGED
Binary file
package/package.json CHANGED
@@ -1,108 +1,108 @@
1
- {
2
- "name": "@deveco-test/deveco-cli-openharmony-arm64",
3
- "version": "0.1.7",
4
- "description": "HarmonyOS application development command line tool",
5
- "license": "MIT",
6
- "type": "module",
7
- "bin": {
8
- "devecocli": "dist/cli.js"
9
- },
10
- "files": [
11
- "dist",
12
- "scripts/postinstall.mjs",
13
- "scripts/install-better-sqlite3.mjs",
14
- "scripts/install-jieba-wasm.mjs",
15
- "scripts/lib/better-sqlite3-vendor.mjs",
16
- "scripts/lib/jieba-wasm-vendor.mjs",
17
- "scripts/lib/cli-data-dir.mjs",
18
- "scripts/lib/doc-init-log-path.mjs",
19
- "templates",
20
- "src/resources",
21
- "THIRD-PARTY-LICENSES",
22
- "SKILL.md",
23
- "docs.zip",
24
- "index.zip"
25
- ],
26
- "scripts": {
27
- "prepare": "husky",
28
- "postinstall": "node scripts/postinstall.mjs",
29
- "build": "tsup",
30
- "build:index": "tsx index/build-index-bundle.ts",
31
- "dev": "tsx watch src/cli.ts",
32
- "start": "tsx src/cli.ts",
33
- "lint": "eslint src",
34
- "lint:fix": "eslint src --fix",
35
- "format": "prettier --write src",
36
- "license": "generate-license-file --input package.json --output THIRD-PARTY-LICENSES --overwrite --ci",
37
- "prepublishOnly": "npm run lint && npm run license && npm run build"
38
- },
39
- "engines": {
40
- "node": ">=18"
41
- },
42
- "os": [
43
- "openharmony"
44
- ],
45
- "cpu": [
46
- "arm64"
47
- ],
48
- "keywords": [
49
- "harmonyos",
50
- "deveco",
51
- "cli"
52
- ],
53
- "devDependencies": {
54
- "@eslint/js": "^10.0.1",
55
- "@types/adm-zip": "^0.5.8",
56
- "@types/better-sqlite3": "^7.6.13",
57
- "@types/fs-extra": "^11.0.4",
58
- "@types/global-agent": "^3.0.0",
59
- "@types/node": "^25.6.0",
60
- "@types/turndown": "^5.0.5",
61
- "@types/yauzl": "^2.10.3",
62
- "eslint": "^10.2.1",
63
- "generate-license-file": "^4.2.1",
64
- "husky": "^9.1.7",
65
- "prettier": "^3.8.3",
66
- "tsup": "^8.5.1",
67
- "tsx": "^4.21.0",
68
- "turndown": "^7.2.4",
69
- "typescript": "^6.0.3",
70
- "typescript-eslint": "^8.59.1"
71
- },
72
- "dependencies": {
73
- "@modelcontextprotocol/sdk": "^1.29.0",
74
- "@sqlite.org/sqlite-wasm": "3.53.4-build1",
75
- "adm-zip": "^0.6.1",
76
- "axios": "1.19.0",
77
- "colorette": "^2.0.20",
78
- "commander": "^13.1.0",
79
- "execa": "^9.6.1",
80
- "fs-extra": "^11.3.4",
81
- "global-agent": "^4.1.3",
82
- "jieba-wasm": "^2.4.0",
83
- "json5": "^2.2.3",
84
- "mdast-util-to-string": "^4.0.0",
85
- "ora": "^8.2.0",
86
- "pkijs": "^3.4.0",
87
- "p-limit": "^5.0.0",
88
- "proper-lockfile": "^4.1.2",
89
- "proxy-from-env": "^2.1.0",
90
- "regedit": "^5.1.4",
91
- "remark-gfm": "^4.0.1",
92
- "remark-parse": "^11.0.0",
93
- "smol-toml": "^1.6.1",
94
- "socket.io-client": "^4.7.5",
95
- "unified": "^11.0.5",
96
- "xdg-basedir": "^5.1.0",
97
- "yauzl": "^3.2.0",
98
- "zod": "^4.4.3"
99
- },
100
- "optionalDependencies": {
101
- "@node-rs/jieba": "^2.0.1",
102
- "@node-rs/jieba-wasm32-wasi": "2.0.1",
103
- "better-sqlite3": "^12.11.1"
104
- },
105
- "overrides": {
106
- "dotenv": "16.4.7"
107
- }
108
- }
1
+ {
2
+ "name": "@deveco-test/deveco-cli-openharmony-arm64",
3
+ "version": "0.4.0-TD.3.6",
4
+ "description": "HarmonyOS application development command line tool",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": {
8
+ "devecocli": "dist/cli.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "scripts/postinstall.mjs",
13
+ "scripts/install-better-sqlite3.mjs",
14
+ "scripts/install-jieba-wasm.mjs",
15
+ "scripts/lib/better-sqlite3-vendor.mjs",
16
+ "scripts/lib/jieba-wasm-vendor.mjs",
17
+ "scripts/lib/cli-data-dir.mjs",
18
+ "scripts/lib/doc-init-log-path.mjs",
19
+ "templates",
20
+ "src/resources",
21
+ "THIRD-PARTY-LICENSES",
22
+ "SKILL.md",
23
+ "docs.zip",
24
+ "index.zip"
25
+ ],
26
+ "scripts": {
27
+ "prepare": "husky",
28
+ "postinstall": "node scripts/postinstall.mjs",
29
+ "build": "tsup",
30
+ "build:index": "tsx index/build-index-bundle.ts",
31
+ "dev": "tsx watch src/cli.ts",
32
+ "start": "tsx src/cli.ts",
33
+ "lint": "eslint src",
34
+ "lint:fix": "eslint src --fix",
35
+ "format": "prettier --write src",
36
+ "license": "generate-license-file --input package.json --output THIRD-PARTY-LICENSES --overwrite --ci",
37
+ "prepublishOnly": "npm run lint && npm run license && npm run build"
38
+ },
39
+ "engines": {
40
+ "node": ">=18"
41
+ },
42
+ "os": [
43
+ "openharmony"
44
+ ],
45
+ "cpu": [
46
+ "arm64"
47
+ ],
48
+ "keywords": [
49
+ "harmonyos",
50
+ "deveco",
51
+ "cli"
52
+ ],
53
+ "devDependencies": {
54
+ "@eslint/js": "^10.0.1",
55
+ "@types/adm-zip": "^0.5.8",
56
+ "@types/better-sqlite3": "^7.6.13",
57
+ "@types/fs-extra": "^11.0.4",
58
+ "@types/global-agent": "^3.0.0",
59
+ "@types/node": "^25.6.0",
60
+ "@types/turndown": "^5.0.5",
61
+ "@types/yauzl": "^2.10.3",
62
+ "eslint": "^10.2.1",
63
+ "generate-license-file": "^4.2.1",
64
+ "husky": "^9.1.7",
65
+ "prettier": "^3.8.3",
66
+ "tsup": "^8.5.1",
67
+ "tsx": "^4.21.0",
68
+ "turndown": "^7.2.4",
69
+ "typescript": "^6.0.3",
70
+ "typescript-eslint": "^8.59.1"
71
+ },
72
+ "dependencies": {
73
+ "@modelcontextprotocol/sdk": "^1.29.0",
74
+ "@sqlite.org/sqlite-wasm": "3.53.4-build1",
75
+ "adm-zip": "^0.6.1",
76
+ "axios": "1.19.0",
77
+ "colorette": "^2.0.20",
78
+ "commander": "^13.1.0",
79
+ "execa": "^9.6.1",
80
+ "fs-extra": "^11.3.4",
81
+ "global-agent": "^4.1.3",
82
+ "jieba-wasm": "^2.4.0",
83
+ "json5": "^2.2.3",
84
+ "mdast-util-to-string": "^4.0.0",
85
+ "ora": "^8.2.0",
86
+ "pkijs": "^3.4.0",
87
+ "p-limit": "^5.0.0",
88
+ "proper-lockfile": "^4.1.2",
89
+ "proxy-from-env": "^2.1.0",
90
+ "regedit": "^5.1.4",
91
+ "remark-gfm": "^4.0.1",
92
+ "remark-parse": "^11.0.0",
93
+ "smol-toml": "^1.6.1",
94
+ "socket.io-client": "^4.7.5",
95
+ "unified": "^11.0.5",
96
+ "xdg-basedir": "^5.1.0",
97
+ "yauzl": "^3.2.0",
98
+ "zod": "^4.4.3"
99
+ },
100
+ "optionalDependencies": {
101
+ "@node-rs/jieba": "^2.0.1",
102
+ "@node-rs/jieba-wasm32-wasi": "2.0.1",
103
+ "better-sqlite3": "^12.11.1"
104
+ },
105
+ "overrides": {
106
+ "dotenv": "16.4.7"
107
+ }
108
+ }
@@ -1,51 +1,51 @@
1
- /*
2
- * Copyright (c) 2026 Huawei Device Co., Ltd.
3
- * SPDX-License-Identifier: MIT
4
- */
5
-
6
- import { appendFile, mkdir } from 'fs/promises';
7
- import { dirname } from 'path';
8
- import { getDocInitLogPath } from './lib/doc-init-log-path.mjs';
9
- import {
10
- installBetterSqlite3ViaNpm,
11
- isBetterSqlite3Loadable,
12
- resolveTargetVersion,
13
- } from './lib/better-sqlite3-vendor.mjs';
14
-
15
- async function appendInstallLog(message) {
16
- try {
17
- const logPath = getDocInitLogPath();
18
- await mkdir(dirname(logPath), { recursive: true });
19
- await appendFile(
20
- logPath,
21
- `${new Date().toISOString()} [better-sqlite3] ${message}\n`
22
- );
23
- } catch {
24
- // ignore logging failures
25
- }
26
- }
27
-
28
- /** @deprecated Use installBetterSqlite3ViaNpm */
29
- export const ensureBetterSqlite3NativeBinary = installBetterSqlite3ViaNpm;
30
-
31
- export async function ensureBetterSqlite3ForDocs() {
32
- const targetVersion = resolveTargetVersion();
33
- await appendInstallLog(
34
- `ensure better-sqlite3@${targetVersion} for Node ${process.version} via npm install`
35
- );
36
-
37
- if (await isBetterSqlite3Loadable()) {
38
- await appendInstallLog('skip: better-sqlite3 already loadable');
39
- return { ok: true, skipped: true, reason: 'already-installed' };
40
- }
41
-
42
- const result = await installBetterSqlite3ViaNpm();
43
- if (result.ok) {
44
- await appendInstallLog(`installed better-sqlite3@${targetVersion} via npm`);
45
- } else {
46
- await appendInstallLog(
47
- `npm install failed (${result.reason}): ${result.error ?? 'unknown error'}`
48
- );
49
- }
50
- return result;
51
- }
1
+ /*
2
+ * Copyright (c) 2026 Huawei Device Co., Ltd.
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { appendFile, mkdir } from 'fs/promises';
7
+ import { dirname } from 'path';
8
+ import { getDocInitLogPath } from './lib/doc-init-log-path.mjs';
9
+ import {
10
+ installBetterSqlite3ViaNpm,
11
+ isBetterSqlite3Loadable,
12
+ resolveTargetVersion,
13
+ } from './lib/better-sqlite3-vendor.mjs';
14
+
15
+ async function appendInstallLog(message) {
16
+ try {
17
+ const logPath = getDocInitLogPath();
18
+ await mkdir(dirname(logPath), { recursive: true });
19
+ await appendFile(
20
+ logPath,
21
+ `${new Date().toISOString()} [better-sqlite3] ${message}\n`
22
+ );
23
+ } catch {
24
+ // ignore logging failures
25
+ }
26
+ }
27
+
28
+ /** @deprecated Use installBetterSqlite3ViaNpm */
29
+ export const ensureBetterSqlite3NativeBinary = installBetterSqlite3ViaNpm;
30
+
31
+ export async function ensureBetterSqlite3ForDocs() {
32
+ const targetVersion = resolveTargetVersion();
33
+ await appendInstallLog(
34
+ `ensure better-sqlite3@${targetVersion} for Node ${process.version} via npm install`
35
+ );
36
+
37
+ if (await isBetterSqlite3Loadable()) {
38
+ await appendInstallLog('skip: better-sqlite3 already loadable');
39
+ return { ok: true, skipped: true, reason: 'already-installed' };
40
+ }
41
+
42
+ const result = await installBetterSqlite3ViaNpm();
43
+ if (result.ok) {
44
+ await appendInstallLog(`installed better-sqlite3@${targetVersion} via npm`);
45
+ } else {
46
+ await appendInstallLog(
47
+ `npm install failed (${result.reason}): ${result.error ?? 'unknown error'}`
48
+ );
49
+ }
50
+ return result;
51
+ }
@@ -1,47 +1,47 @@
1
- /*
2
- * Copyright (c) 2026 Huawei Device Co., Ltd.
3
- * SPDX-License-Identifier: MIT
4
- */
5
-
6
- import { appendFile, mkdir } from 'fs/promises';
7
- import { dirname } from 'path';
8
- import { getDocInitLogPath } from './lib/doc-init-log-path.mjs';
9
- import { installJiebaWasmViaNpm } from './lib/jieba-wasm-vendor.mjs';
10
-
11
- async function appendInstallLog(message) {
12
- try {
13
- const logPath = getDocInitLogPath();
14
- await mkdir(dirname(logPath), { recursive: true });
15
- await appendFile(
16
- logPath,
17
- `${new Date().toISOString()} [jieba-wasm] ${message}\n`
18
- );
19
- } catch {
20
- // ignore logging failures
21
- }
22
- }
23
-
24
- export async function ensureJiebaWasmForDocs() {
25
- await appendInstallLog(
26
- `ensure @node-rs/jieba-wasm32-wasi@2.0.1 for Node ${process.version}`
27
- );
28
- const result = await installJiebaWasmViaNpm();
29
- if (result.skipped) {
30
- if (result.reason === 'already-installed') {
31
- await appendInstallLog('skip: jieba wasm32-wasi already loadable');
32
- } else if (result.reason === 'native-available') {
33
- await appendInstallLog('skip: jieba native already loadable');
34
- } else {
35
- await appendInstallLog(`skip: ${result.reason}`);
36
- }
37
- } else if (result.ok) {
38
- await appendInstallLog(
39
- 'installed @node-rs/jieba-wasm32-wasi@2.0.1 via npm'
40
- );
41
- } else {
42
- await appendInstallLog(
43
- `npm install failed (${result.reason}): ${result.error ?? 'unknown error'}`
44
- );
45
- }
46
- return result;
47
- }
1
+ /*
2
+ * Copyright (c) 2026 Huawei Device Co., Ltd.
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { appendFile, mkdir } from 'fs/promises';
7
+ import { dirname } from 'path';
8
+ import { getDocInitLogPath } from './lib/doc-init-log-path.mjs';
9
+ import { installJiebaWasmViaNpm } from './lib/jieba-wasm-vendor.mjs';
10
+
11
+ async function appendInstallLog(message) {
12
+ try {
13
+ const logPath = getDocInitLogPath();
14
+ await mkdir(dirname(logPath), { recursive: true });
15
+ await appendFile(
16
+ logPath,
17
+ `${new Date().toISOString()} [jieba-wasm] ${message}\n`
18
+ );
19
+ } catch {
20
+ // ignore logging failures
21
+ }
22
+ }
23
+
24
+ export async function ensureJiebaWasmForDocs() {
25
+ await appendInstallLog(
26
+ `ensure @node-rs/jieba-wasm32-wasi@2.0.1 for Node ${process.version}`
27
+ );
28
+ const result = await installJiebaWasmViaNpm();
29
+ if (result.skipped) {
30
+ if (result.reason === 'already-installed') {
31
+ await appendInstallLog('skip: jieba wasm32-wasi already loadable');
32
+ } else if (result.reason === 'native-available') {
33
+ await appendInstallLog('skip: jieba native already loadable');
34
+ } else {
35
+ await appendInstallLog(`skip: ${result.reason}`);
36
+ }
37
+ } else if (result.ok) {
38
+ await appendInstallLog(
39
+ 'installed @node-rs/jieba-wasm32-wasi@2.0.1 via npm'
40
+ );
41
+ } else {
42
+ await appendInstallLog(
43
+ `npm install failed (${result.reason}): ${result.error ?? 'unknown error'}`
44
+ );
45
+ }
46
+ return result;
47
+ }