@moneko/core 3.39.6 → 3.40.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.
@@ -1,11 +1,17 @@
1
- import { exec, type ExecException } from 'node:child_process';
2
- import { join } from 'node:path';
1
+ import { exec, type ExecException, type PromiseWithChild } from 'node:child_process';
2
+ import { join, relative } 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,relative as r}from"node:path";import{platform as o}from"node:process";import{promisify as i}from"node:util";let a=i(t);import{fileExists as n,loadFile as l,println as c,saveFile as s}from"@moneko/utils";import{createCA as m,createCert as p}from"mkcert";import u from"./log.mjs";import d from"./paths.mjs";async function f(t){try{if("darwin"===o){let{stdout:e}=await a(`security find-certificate -c "${t}" -a`);return e.length>0}if("win32"===o){let{stdout:e}=await a(`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(`security add-trusted-cert -d -r trustRoot -k "$HOME/Library/Keychains/login.keychain-db" "${e}"`,y):"win32"===o?t(`certutil -addstore -user "Root" "${e}"`,y):void c(`⚠️ 暂不支持自动安装 CA 的平台: ${o}`)}export async function setupCert(t="localhost",o=!0){let i=r(d.programPath,`${d.corePath}/pem/root-cert.pem`),a=r(d.programPath,`${d.corePath}/pem/root-key.pem`),c="Local Development CA - DO NOT TRUST";if(!n(i)||!n(a)){let t=await m({organization:c,validity:365,countryCode:"CN",state:"Hunan",locality:"Changsha"});await Promise.all([s(i,t.cert),s(a,t.key)])}o&&!await f(c)&&installCA(i);let u=e(d.CA_DIR,`${t}_cert.pem`),y=e(d.CA_DIR,`${t}_key.pem`);if(!n(u)||!n(y)){let e=await Promise.all([l(i),l(a)]),r=await p({ca:{cert:e[0],key:e[1]},domains:[...new Set([t,"localhost","127.0.0.1"].filter(Boolean))],organization:c,validity:365});await Promise.all([s(u,r.cert),s(y,r.key)])}let h=await Promise.all([l(u),l(y)]);return{cert:h[0],key:h[1]}}
@@ -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;
@@ -0,0 +1,22 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDvDCCAqSgAwIBAgIFNTA1NTcwDQYJKoZIhvcNAQELBQAwgYwxLDAqBgNVBAMT
3
+ I0xvY2FsIERldmVsb3BtZW50IENBIC0gRE8gTk9UIFRSVVNUMQswCQYDVQQGEwJD
4
+ TjEOMAwGA1UECBMFSHVuYW4xETAPBgNVBAcTCENoYW5nc2hhMSwwKgYDVQQKEyNM
5
+ b2NhbCBEZXZlbG9wbWVudCBDQSAtIERPIE5PVCBUUlVTVDAeFw0yNTA0MTAwNzQ5
6
+ MzdaFw0yNjA0MTAwNzQ5MzdaMIGMMSwwKgYDVQQDEyNMb2NhbCBEZXZlbG9wbWVu
7
+ dCBDQSAtIERPIE5PVCBUUlVTVDELMAkGA1UEBhMCQ04xDjAMBgNVBAgTBUh1bmFu
8
+ MREwDwYDVQQHEwhDaGFuZ3NoYTEsMCoGA1UEChMjTG9jYWwgRGV2ZWxvcG1lbnQg
9
+ Q0EgLSBETyBOT1QgVFJVU1QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
10
+ AQC8JyVLUKEaZ4Hcm0xXAFLMqLZxq78Kl/B0YlI11HfPWo8afatul+x+jrQRhTwX
11
+ gX2m/aubVKV/G86YYniGdVivcfGgIGHEZurvE1iQmvSD8LZ0s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BmJDD3v
22
+ tw5HYKjAMZeU6o1nGa99wrSApBuVY7C8TyGSBc72W+VswCe6BYjXiOiVNCtH8IPk
23
+ 1NiBSVEi37F3B9+snG0C9t+IBR4RBnuNucznJhxqVH6D6YGbUgoNFo/02CTekxdg
24
+ VfIxAoGBAOUxvprqF3YBl1k3Zz6VV8kXapx3t1YCTup9Ef9ahClSE0sqjyqq7lM7
25
+ ZkmCVJIfVgZaLvVT7tlOsLeima2VNC7xfxdRB4i/qQfNILhr9F/s/epQQvJkZ0CS
26
+ ryB7kc0RBMJZ2bD8ozcihstdxglpd4eTt+0DQzWfTGGWhmq4LNuq
27
+ -----END RSA PRIVATE KEY-----
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "3.39.6",
3
+ "version": "3.40.1",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",