fix: remove path fro dev, use progress.resolve() replace
This commit is contained in:
		@@ -6,10 +6,11 @@
 | 
			
		||||
    "type": {
 | 
			
		||||
      "type": "string",
 | 
			
		||||
      "enum": [
 | 
			
		||||
        "inline-app",
 | 
			
		||||
        "micro-app"
 | 
			
		||||
        "system-app",
 | 
			
		||||
        "micro-app",
 | 
			
		||||
        "gateway-app"
 | 
			
		||||
      ],
 | 
			
		||||
      "$comment": "Type must be either 'inline-app' or 'micro-app'"
 | 
			
		||||
      "$comment": "Type must be either 'system-app' or 'micro-app' or 'gateway-app'."
 | 
			
		||||
    },
 | 
			
		||||
    "single": {
 | 
			
		||||
      "type": "boolean",
 | 
			
		||||
@@ -36,7 +37,8 @@
 | 
			
		||||
      "required": [
 | 
			
		||||
        "host",
 | 
			
		||||
        "path"
 | 
			
		||||
      ]
 | 
			
		||||
      ],
 | 
			
		||||
      "$comment": "远程服务的地址和路径"
 | 
			
		||||
    },
 | 
			
		||||
    "micro": {
 | 
			
		||||
      "type": "object",
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,16 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "@kevisual/user-config",
 | 
			
		||||
  "version": "1.0.1",
 | 
			
		||||
  "name": "@kevisual/use-config",
 | 
			
		||||
  "version": "1.0.2",
 | 
			
		||||
  "types": "dist/config.d.ts",
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "build": "npm run clean && rollup -c",
 | 
			
		||||
    "watch": " rollup -c -w",
 | 
			
		||||
    "clean": "rimraf dist"
 | 
			
		||||
  },
 | 
			
		||||
  
 | 
			
		||||
  "publishConfig": {
 | 
			
		||||
    "access": "public"
 | 
			
		||||
  },
 | 
			
		||||
  "files": [
 | 
			
		||||
    "dist",
 | 
			
		||||
    "src",
 | 
			
		||||
 
 | 
			
		||||
@@ -1,10 +1,6 @@
 | 
			
		||||
import JSON5 from 'json5';
 | 
			
		||||
import fs from 'fs';
 | 
			
		||||
import path from 'path';
 | 
			
		||||
import { fileURLToPath } from 'url';
 | 
			
		||||
 | 
			
		||||
const __filename = fileURLToPath(import.meta.url); // 当前模块的文件路径
 | 
			
		||||
const __dirname = path.dirname(__filename); // 当前模块的目录路径
 | 
			
		||||
 | 
			
		||||
// 配置类型
 | 
			
		||||
export type Config = {
 | 
			
		||||
@@ -51,11 +47,7 @@ export const fileIsExist = (path: string) => {
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
export const getDirname = () => {
 | 
			
		||||
  const isDev = getNODE_ENV() === 'development';
 | 
			
		||||
  if (isDev) {
 | 
			
		||||
    return path.resolve();
 | 
			
		||||
  }
 | 
			
		||||
  return __dirname;
 | 
			
		||||
  return path.resolve();
 | 
			
		||||
};
 | 
			
		||||
export const getConfigFile = (fileName = 'app.config.json5') => {
 | 
			
		||||
  const dirname = getDirname();
 | 
			
		||||
@@ -133,7 +125,3 @@ export const deleteContext = (key: string): any => {
 | 
			
		||||
  }
 | 
			
		||||
  return _context;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getNODE_ENV = (): string => {
 | 
			
		||||
  return process?.env?.NODE_ENV || 'production';
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -1,12 +1,7 @@
 | 
			
		||||
import path from 'path';
 | 
			
		||||
import fs from 'fs';
 | 
			
		||||
import type { App } from './read-app-schema.ts';
 | 
			
		||||
import { fileURLToPath } from 'url';
 | 
			
		||||
import { getConfigFile } from './config.ts';
 | 
			
		||||
 | 
			
		||||
const __filename = fileURLToPath(import.meta.url); // 当前模块的文件路径
 | 
			
		||||
const __dirname = path.dirname(__filename); // 当前模块的目录路径
 | 
			
		||||
 | 
			
		||||
export const getPkgs = () => {
 | 
			
		||||
  const configFile = getConfigFile();
 | 
			
		||||
  if (!configFile) {
 | 
			
		||||
@@ -17,7 +12,7 @@ export const getPkgs = () => {
 | 
			
		||||
  return config;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getApps = (): App => {
 | 
			
		||||
export const getApp = (): App => {
 | 
			
		||||
  const config = getPkgs();
 | 
			
		||||
  return config.apps || {};
 | 
			
		||||
  return config.app || {};
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user