@moneko/core 3.39.5 → 3.40.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.
@@ -1,11 +1,17 @@
1
- import { exec, type ExecException } from 'node:child_process';
1
+ import { exec, type ExecException, type PromiseWithChild } from 'node:child_process';
2
2
  import { join } from 'node:path';
3
3
  import { platform } from 'node:process';
4
+ import { promisify } from 'node:util';
5
+ type ExecPromise = (command: string) => PromiseWithChild<{
6
+ stdout: string;
7
+ stderr: string;
8
+ }>;
9
+ declare const execPromise: ExecPromise;
4
10
  import { fileExists, loadFile, println, saveFile } from '@moneko/utils';
5
11
  import { createCA, createCert } from 'mkcert';
6
12
  import log from './log.mjs';
7
- import { getIPv4 } from './net.mjs';
8
13
  import paths from './paths.mjs';
14
+ declare async function isCertificateInstalled(organization: string): Promise<boolean>;
9
15
  declare function installCallback(error: ExecException | null, _stdout: string, stderr: string);
10
16
  export declare function installCA(certPath: string);
11
17
  export declare async function setupCert(domain?: string, install?: boolean);
package/lib/commom/ca.mjs CHANGED
@@ -1 +1 @@
1
- import{exec as t}from"node:child_process";import{join as o}from"node:path";import{platform as r}from"node:process";import{fileExists as e,loadFile as i,println as a,saveFile as n}from"@moneko/utils";import{createCA as s,createCert as l}from"mkcert";import m from"./log.mjs";import{getIPv4 as c}from"./net.mjs";import d from"./paths.mjs";function p(t,o,r){if(t&&!r.includes("already exists")){m(t);return}}export function installCA(o){return"darwin"===r?t(`security add-trusted-cert -d -r trustRoot -k "$HOME/Library/Keychains/login.keychain-db" "${o}"`,p):"win32"===r?t(`certutil -addstore -user "Root" "${o}"`,p):void a(`⚠️ 暂不支持自动安装 CA 的平台: ${r}`)}export async function setupCert(t="localhost",r=!0){let a=o(d.CA_DIR,`${t}_cert.pem`),m=o(d.CA_DIR,`${t}_key.pem`),p="Moneko Dev CA";if(!e(a)||!e(m)){let t=await s({organization:p,validity:365,countryCode:"CN",state:"Hunan",locality:"Changsha"});await Promise.all([n(a,t.cert),n(m,t.key)])}r&&installCA(a);let u=await Promise.all([i(m),i(a)]);return l({ca:{key:u[0],cert:u[1]},domains:[...new Set([t,"localhost","127.0.0.1",c()].filter(Boolean))],organization:p,validity:365})}
1
+ import{exec as t}from"node:child_process";import{join as e}from"node:path";import{platform as r}from"node:process";import{promisify as i}from"node:util";let o=i(t);import{fileExists as a,loadFile as n,println as l,saveFile as c}from"@moneko/utils";import{createCA as s,createCert as m}from"mkcert";import u from"./log.mjs";import d from"./paths.mjs";async function f(t){try{if("darwin"===r){let{stdout:e}=await o(`security find-certificate -c "${t}" -a`);return e.length>0}if("win32"===r){let{stdout:e}=await o(`certutil -store -user Root | findstr /C:"${t}"`);return e.length>0}}catch(t){u(t)}return!1}function p(t,e,r){if(t&&!r.includes("already exists")){u(t);return}}export function installCA(e){return"darwin"===r?t(`security add-trusted-cert -d -r trustRoot -k "$HOME/Library/Keychains/login.keychain-db" "${e}"`,p):"win32"===r?t(`certutil -addstore -user "Root" "${e}"`,p):void l(`⚠️ 暂不支持自动安装 CA 的平台: ${r}`)}export async function setupCert(t="localhost",r=!0){let i=e(d.CA_DIR,"root_cert.pem"),o=e(d.CA_DIR,"root_key.pem"),l="Local Development CA - DO NOT TRUST";if(!a(i)||!a(o)){let t=await s({organization:l,validity:365,countryCode:"CN",state:"Hunan",locality:"Changsha"});await Promise.all([c(i,t.cert),c(o,t.key)])}r&&!await f(l)&&installCA(i);let u=e(d.CA_DIR,`${t}_cert.pem`),p=e(d.CA_DIR,`${t}_key.pem`);if(!a(u)||!a(p)){let e=await Promise.all([n(i),n(o)]),r=await m({ca:{cert:e[0],key:e[1]},domains:[...new Set([t,"localhost","127.0.0.1"].filter(Boolean))],organization:l,validity:365});await Promise.all([c(u,r.cert),c(p,r.key)])}let y=await Promise.all([n(u),n(p)]);return{cert:y[0],key:y[1]}}
@@ -1 +1 @@
1
- import{resolve as e}from"node:path";import s from"./paths.mjs";export default function(n,t=1){let a=n.replace(/^\/|\/$/g,"").replace(/\\/g,"/"),i=a,o="index.ts",d=a.match(/(.+)\/index\.([^/]+)$/),m=a.match(/(.+)\.([^/]+)$/);d?(i=d[1],o=`index.${d[2]}`):m&&(i=m[1],o=`index.${m[2]}`);let p=!!i.endsWith("@app/rem")||["*.css","*.less","*.scss","*.sass"];return{name:i,main:o,pkg:e(s.nodeModules,i,"package.json"),file:e(s.nodeModules,i,o),meta:`{"name":"${i}","main":"${o}","version":"0.0.${t}","description": "","sideEffects": ${p}}`}}
1
+ import{resolve as e}from"node:path";import s from"./paths.mjs";export default function(n,t=1){let i=n.replace(/^\/|\/$/g,"").replace(/\\/g,"/"),a=i,o="index.ts",d=i.match(/(.+)\/index\.([^/]+)$/),m=i.match(/(.+)\.([^/]+)$/);d?(a=d[1],o=`index.${d[2]}`):m&&(a=m[1],o=`index.${m[2]}`);let r=!!a.endsWith("@app/rem")||JSON.stringify(["*.css","*.less","*.scss","*.sass"]);return{name:a,main:o,pkg:e(s.nodeModules,a,"package.json"),file:e(s.nodeModules,a,o),meta:`{"name":"${a}","main":"${o}","version":"0.0.${t}","description": "","sideEffects": ${r}}`}}
@@ -1,3 +1,4 @@
1
+ import { tmpdir } from 'node:os';
1
2
  import { resolve } from 'node:path';
2
3
  import url from 'node:url';
3
4
  import { fileExists } from '@moneko/utils';
@@ -1 +1 @@
1
- import{resolve as o}from"node:path";import e from"node:url";import{fileExists as t}from"@moneko/utils";let c=JSON.parse(process.env.npm_config_argv||'{"original":[]}').original;export const __dirname=e.fileURLToPath(new URL("..",import.meta.url));export const yarnArgv={};for(let o=0,e=c.length;o<e;o++){let e=c[o].split("=");Object.assign(yarnArgv,{[e[0]]:e[1]||!0})}export const CUSTOMCONFIG=process.env.npm_config_config||yarnArgv.config||process.env.__args__config__;let n=process.cwd(),a=o(n,"./node_modules"),r={nodeModules:a,pnpmNodeModules:o(a,"./.pnpm/node_modules"),denoNodeModules:o(a,"./.deno"),corePath:__dirname,programPath:n,CA_DIR:o(a,"./.cache/.ca"),webpackCachePath:o(a,"./.cache"),lintCachePath:o(a,"./.cache"),httpCachePath:o(a,"./.cache/http"),swcCachePath:o(a,"./.cache/.swc"),configPath:o(n,"./config/index.ts"),customConfigPath:o(n,`./config/${CUSTOMCONFIG}.ts`),coveragePath:o(n,"./coverage/clover.xml"),pagesPath:o(n,"./src/pages"),componentsPath:o(n,"./components"),mockPath:o(n,"./mock")};export const config_files=[t(r.configPath)&&r.configPath,t(r.customConfigPath)&&r.customConfigPath].filter(Boolean);export const routeDir="library"===process.env.APPTYPE?r.componentsPath:r.pagesPath;export default r;
1
+ import{tmpdir as o}from"node:os";import{resolve as e}from"node:path";import t from"node:url";import{fileExists as n}from"@moneko/utils";let c=JSON.parse(process.env.npm_config_argv||'{"original":[]}').original;export const __dirname=t.fileURLToPath(new URL("..",import.meta.url));export const yarnArgv={};for(let o=0,e=c.length;o<e;o++){let e=c[o].split("=");Object.assign(yarnArgv,{[e[0]]:e[1]||!0})}export const CUSTOMCONFIG=process.env.npm_config_config||yarnArgv.config||process.env.__args__config__;let a=process.cwd(),r=e(a,"./node_modules"),s={nodeModules:r,pnpmNodeModules:e(r,"./.pnpm/node_modules"),denoNodeModules:e(r,"./.deno"),corePath:__dirname,programPath:a,CA_DIR:e(o(),"@moneko/.ca"),webpackCachePath:e(r,"./.cache"),lintCachePath:e(r,"./.cache"),httpCachePath:e(r,"./.cache/http"),swcCachePath:e(r,"./.cache/.swc"),configPath:e(a,"./config/index.ts"),customConfigPath:e(a,`./config/${CUSTOMCONFIG}.ts`),coveragePath:e(a,"./coverage/clover.xml"),pagesPath:e(a,"./src/pages"),componentsPath:e(a,"./components"),mockPath:e(a,"./mock")};export const config_files=[n(s.configPath)&&s.configPath,n(s.customConfigPath)&&s.customConfigPath].filter(Boolean);export const routeDir="library"===process.env.APPTYPE?s.componentsPath:s.pagesPath;export default s;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.39.5",
3
+ "version": "3.40.0",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",