mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
Merge branch 'master' of https://github.com/WeBankFinTech/fes.js
This commit is contained in:
commit
66b3e43b77
@ -10,17 +10,17 @@ Object.keys(_ENUMS).forEach(key => {
|
|||||||
/**
|
/**
|
||||||
* 获取枚举键值,如不传key,则返回name的枚举数组
|
* 获取枚举键值,如不传key,则返回name的枚举数组
|
||||||
* @param {string} name 枚举名称
|
* @param {string} name 枚举名称
|
||||||
* @param {string} key 枚举键名称
|
* @param {string} [key] 枚举键名称
|
||||||
* @param {{
|
* @param {{
|
||||||
* dir: string
|
* dir: string
|
||||||
* extend: Array<{
|
* extend: Array<{
|
||||||
* key:string
|
* key:string
|
||||||
* dir:string
|
* dir:string
|
||||||
* transfer: Function
|
* transfer: Function
|
||||||
* }>}} opt 配置项
|
* }>}} [opt] 配置项
|
||||||
*/
|
*/
|
||||||
function get(name, key, opt = { dir: 'value', extend: []}) {
|
function get(name, key, opt = { dir: 'value', extend: []}) {
|
||||||
if (Object.prototype.toString.call(key) === '[object Object]') {
|
if (Object.prototype.toString.call(key) === '[object Object]') {
|
||||||
opt = key
|
opt = key
|
||||||
key = null
|
key = null
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ function get(name, key, opt = { dir: 'value', extend: []}) {
|
|||||||
} else {
|
} else {
|
||||||
value = format(list, opt.extend)
|
value = format(list, opt.extend)
|
||||||
}
|
}
|
||||||
return typeof value === 'object' ? readonly(value) : value
|
return typeof value === 'object' ? readonly(value) : value
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,7 +86,7 @@ function concat(name, _enum, opt = { keyName: '', valueName: '', before: false,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 格式化枚举
|
* 格式化枚举
|
||||||
* @param {Array} _enum 枚举数组
|
* @param {Array} _enum 枚举数组
|
||||||
* @param {Array<{key:string, dir:string, transfer: Function}>} extend 格式化规则
|
* @param {Array<{key:string, dir:string, transfer: Function}>} extend 格式化规则
|
||||||
*/
|
*/
|
||||||
function format(_enum = [], extend = []) {
|
function format(_enum = [], extend = []) {
|
||||||
@ -108,7 +108,7 @@ function format(_enum = [], extend = []) {
|
|||||||
/**
|
/**
|
||||||
* 根据dir解析value的属性值
|
* 根据dir解析value的属性值
|
||||||
* @param value
|
* @param value
|
||||||
* @param dir
|
* @param dir
|
||||||
*/
|
*/
|
||||||
function parseValueDir(value, dir='value') {
|
function parseValueDir(value, dir='value') {
|
||||||
if (!['object', 'function'].includes(typeof value) || !value || !dir || dir === 'value') return value
|
if (!['object', 'function'].includes(typeof value) || !value || !dir || dir === 'value') return value
|
||||||
|
@ -1,17 +1,9 @@
|
|||||||
import { readFileSync, existsSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { winPath } from '@fesjs/utils';
|
import { winPath } from '@fesjs/utils';
|
||||||
import { runtimePath } from '../../../../utils/constants';
|
import { runtimePath } from '../../../../utils/constants';
|
||||||
|
import { getAppPath } from '../../../../utils/getAppEntryPath';
|
||||||
|
|
||||||
function getAppPath(absSrcPath) {
|
|
||||||
for (const suffix of ['.js', '.ts', '.jsm']) {
|
|
||||||
const p = winPath(join(absSrcPath, `app${suffix}`));
|
|
||||||
if (existsSync(p)) {
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function (api) {
|
export default function (api) {
|
||||||
const {
|
const {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { chokidar, lodash, winPath } from '@fesjs/utils';
|
import { chokidar, lodash, winPath } from '@fesjs/utils';
|
||||||
import { join } from 'path';
|
import { getAppPath } from './getAppEntryPath';
|
||||||
|
|
||||||
export default async ({ api, watch }) => {
|
export default async ({ api, watch }) => {
|
||||||
const { paths } = api;
|
const { paths } = api;
|
||||||
@ -44,8 +44,7 @@ export default async ({ api, watch }) => {
|
|||||||
type: api.ApplyPluginsType.add,
|
type: api.ApplyPluginsType.add,
|
||||||
initialValue: [
|
initialValue: [
|
||||||
paths.absPagesPath,
|
paths.absPagesPath,
|
||||||
join(paths.absSrcPath, 'app.js'),
|
getAppPath(paths.absSrcPath)
|
||||||
join(paths.absSrcPath, 'app.ts')
|
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
lodash
|
lodash
|
||||||
|
13
packages/fes-preset-built-in/src/utils/getAppEntryPath.js
Normal file
13
packages/fes-preset-built-in/src/utils/getAppEntryPath.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { join } from 'path';
|
||||||
|
import { existsSync } from 'fs';
|
||||||
|
import { winPath } from '@fesjs/utils';
|
||||||
|
|
||||||
|
export function getAppPath(absSrcPath) {
|
||||||
|
for (const suffix of ['.js', '.ts', '.jsm', '.jsx', '.tsx']) {
|
||||||
|
const p = winPath(join(absSrcPath, `app${suffix}`));
|
||||||
|
if (existsSync(p)) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user