@moneko/core 3.44.11-beta.1 → 3.45.0

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.
@@ -3,7 +3,6 @@ import { join, relative } from 'node:path';
3
3
  import { platform } from 'node:process';
4
4
  import { promisify } from 'node:util';
5
5
  import { type CertificateResult, fileExists, generateCert, loadFile, normalCertificateAuthority, println, saveFile } from '@moneko/utils';
6
- import { hostHelp } from './host.mjs';
7
6
  import log from './log.mjs';
8
7
  import paths from './paths.mjs';
9
8
  type ExecPromise = (command: string) => PromiseWithChild<{
package/lib/commom/ca.mjs CHANGED
@@ -1 +1 @@
1
- import{exec as t}from"node:child_process";import{join as r,relative as e}from"node:path";import{platform as o}from"node:process";import{promisify as i}from"node:util";import{fileExists as a,generateCert as n,loadFile as s,normalCertificateAuthority as c,println as l,saveFile as m}from"@moneko/utils";import{hostHelp as u}from"./host.mjs";import f from"./log.mjs";import p from"./paths.mjs";let d=i(t);async function y(t){try{if("darwin"===o){let{stdout:r}=await d(`security find-certificate -c "${t}" -a`);return r.length>0}if("win32"===o){let{stdout:r}=await d(`certutil -store -user Root | findstr /C:"${t}"`);return r.length>0}}catch(t){f(t)}return!1}function h(t,r,e){if(t&&!e.includes("already exists")){f(t);return}}export function installCA(r){return"darwin"===o?t(`sudo security add-trusted-cert -d -r trustRoot -k "/Library/Keychains/System.keychain" "${r}"`,h):"win32"===o?t(`certutil -addstore -user "Root" "${r}"`,h):void l(`⚠️ 暂不支持自动安装 CA 的平台: ${o}`)}export async function setupCert(t="localhost",o=!0){let i=e(p.programPath,`${p.corePath}/cert/cert.pem`),l=e(p.programPath,`${p.corePath}/cert/key.pem`),f=!a(i)||!a(l);if(f){let t=c();await Promise.all([m(i,t.cert),m(l,t.key)])}o&&(!await y("Local Root Certificate Authority - Moneko")||f)&&installCA(i);let d=r(p.CA_DIR,`${t}_cert.pem`),h=r(p.CA_DIR,`${t}_key.pem`);if(f||!a(d)||!a(h)){let r=await Promise.all([s(i),s(l)]),e=n(r[0],r[1],t);await Promise.all([m(d,e.cert),m(h,e.key)])}let w=await Promise.all([s(d),s(h)]);return u(t),{cert:w[0],key:w[1]}}
1
+ import{exec as t}from"node:child_process";import{join as e,relative as r}from"node:path";import{platform as o}from"node:process";import{promisify as i}from"node:util";import{fileExists as a,generateCert as n,loadFile as c,normalCertificateAuthority as l,println as s,saveFile as m}from"@moneko/utils";import u from"./log.mjs";import f from"./paths.mjs";let p=i(t);async function d(t){try{if("darwin"===o){let{stdout:e}=await p(`security find-certificate -c "${t}" -a`);return e.length>0}if("win32"===o){let{stdout:e}=await p(`certutil -store -user Root | findstr /C:"${t}"`);return e.length>0}}catch(t){u(t)}return!1}function y(t,e,r){if(t&&!r.includes("already exists")){u(t);return}}export function installCA(e){return"darwin"===o?t(`sudo security add-trusted-cert -d -r trustRoot -k "/Library/Keychains/System.keychain" "${e}"`,y):"win32"===o?t(`certutil -addstore -user "Root" "${e}"`,y):void s(`⚠️ 暂不支持自动安装 CA 的平台: ${o}`)}export async function setupCert(t="localhost",o=!0){let i=r(f.programPath,`${f.corePath}/cert/cert.pem`),s=r(f.programPath,`${f.corePath}/cert/key.pem`),u=!a(i)||!a(s);if(u){let t=l();await Promise.all([m(i,t.cert),m(s,t.key)])}o&&(!await d("Local Root Certificate Authority - Moneko")||u)&&installCA(i);let p=e(f.CA_DIR,`${t}_cert.pem`),y=e(f.CA_DIR,`${t}_key.pem`);if(u||!a(p)||!a(y)){let e=await Promise.all([c(i),c(s)]),r=n(e[0],e[1],t);await Promise.all([m(p,r.cert),m(y,r.key)])}let h=await Promise.all([c(p),c(y)]);return{cert:h[0],key:h[1]}}
@@ -1,4 +1,3 @@
1
1
  import { addHost, checkHost, getHostsPath, ink, println } from '@moneko/utils';
2
- import log from './log.mjs';
3
2
  declare function flashDNS();
4
3
  export declare function hostHelp(domain: string);
@@ -1,19 +1,19 @@
1
- import{addHost as s,checkHost as t,getHostsPath as o,ink as e,println as l}from"@moneko/utils";import r from"./log.mjs";export function hostHelp(c){let i="127.0.0.1";if(t(i,c)||s(i,c),!t(i,c)){let s=`
2
- ${e("🚦 域名解析配置提醒","yellow",{bold:!0})}
1
+ import{addHost as s,checkHost as t,getHostsPath as e,ink as o,println as l}from"@moneko/utils";export function hostHelp(r){let c="127.0.0.1";t(c,r)||s(c,r),t(c,r)||l(`
2
+ ${o("🚦 域名解析配置提醒","yellow",{bold:!0})}
3
3
 
4
- 检测到您正在使用本地域名:${e(c,"yellow")},但系统未找到对应的本地解析记录
4
+ 检测到您正在使用本地域名:${o(r,"yellow")},但系统未找到对应的本地解析记录
5
5
 
6
6
  📝 请按以下步骤操作:
7
7
 
8
8
  1. 使用文本编辑器【以管理员身份】打开 hosts 文件:
9
9
 
10
- ${e("hosts 文件地址:","242")} ${e(o(),"208")}
10
+ ${o("hosts 文件地址:","242")} ${o(e(),"208")}
11
11
 
12
12
  2. 在文件末尾添加解析规则:
13
13
 
14
- ${e(i,"39")} ${e(c,"39")}
14
+ ${o(c,"39")} ${o(r,"39")}
15
15
 
16
16
  3. 保存文件后,建议刷新DNS缓存:
17
17
 
18
- ${e(function(){switch(process.platform){case"darwin":return"sudo dscacheutil -flushcache";case"win32":return"ipconfig /flushdns";default:return"sudo systemctl restart systemd-resolved"}}(),"208")}
19
- `;l(s),r(s)}}
18
+ ${o(function(){switch(process.platform){case"darwin":return"sudo dscacheutil -flushcache";case"win32":return"ipconfig /flushdns";default:return"sudo systemctl restart systemd-resolved"}}(),"208")}
19
+ `)}
@@ -1,5 +1,6 @@
1
1
  import { ink, println, termClear } from '@moneko/utils';
2
2
  import webpack from 'webpack';
3
+ import { hostHelp } from '../commom/host.mjs';
3
4
  import { getIPv4, getPort } from '../commom/net.mjs';
4
5
  import { CONFIG } from '../config.mjs';
5
6
  declare const oldPord: number;
@@ -1,3 +1,3 @@
1
- import{ink as e,println as r,termClear as t}from"@moneko/utils";import{getIPv4 as o,getPort as s}from"../commom/net.mjs";import{CONFIG as n}from"../config.mjs";let i=n.devServer.port||3e3;export const PORT=await s(i);n.devServer.port=PORT;let m="/"===n.basename?"":n.basename,a=i!==PORT&&e(`Port ${e(`${i}`,"yellow")} is in use, trying ${e(`${PORT}`,"green")} instead.
2
- `,"245");export function getServerAddress(e){return`${n.devServer.https?"https":"http"}://${"local"===e?n.devServer.host:o()}:${PORT}${m}`}let l=e("You application is running here:","245"),g=`${e(" Local ","231",{bg:"blue"})} ${e(getServerAddress("local"),"75")}
3
- ${e(" Network ","231",{bg:"29"})} ${e(getServerAddress("net"),"green")}`;export function devLog(o,s){t(3);let n=(s?.endTime??0)-(s?.startTime??0);r([l,"",g,"",e(`Compiled successfully in ${e(`${n}ms`,"green")}`,"245"),""].join("\n"),!0),a&&r(a),s&&(s.compilation.warnings.forEach(e=>{r(e.message)}),s.compilation.errors.forEach(e=>{r(e.message)})),o&&r(o.message)}
1
+ import{ink as e,println as r,termClear as o}from"@moneko/utils";import{hostHelp as t}from"../commom/host.mjs";import{getIPv4 as s,getPort as n}from"../commom/net.mjs";import{CONFIG as m}from"../config.mjs";let i=m.devServer.port||3e3;export const PORT=await n(i);m.devServer.port=PORT;let a="/"===m.basename?"":m.basename,l=i!==PORT&&e(`Port ${e(`${i}`,"yellow")} is in use, trying ${e(`${PORT}`,"green")} instead.
2
+ `,"245");export function getServerAddress(e){return`${m.devServer.https?"https":"http"}://${"local"===e?m.devServer.host:s()}:${PORT}${a}`}let p=e("You application is running here:","245"),c=`${e(" Local ","231",{bg:"blue"})} ${e(getServerAddress("local"),"75")}
3
+ ${e(" Network ","231",{bg:"29"})} ${e(getServerAddress("net"),"green")}`;export function devLog(s,n){o(3);let i=(n?.endTime??0)-(n?.startTime??0);r([p,"",c,"",e(`Compiled successfully in ${e(`${i}ms`,"green")}`,"245"),""].join("\n"),!0),l&&r(l),t(m.devServer.host),n&&(n.compilation.warnings.forEach(e=>{r(e.message)}),n.compilation.errors.forEach(e=>{r(e.message)})),s&&r(s.message)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.44.11-beta.1",
3
+ "version": "3.45.0",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",