Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
[
require.resolve('babel-plugin-module-resolver'),
{
alias: {
// Projects don't need to install react, react-dom and enzyme
react: compatDirname(
'react/package',
cwd,
dirname(require.resolve('react/package.json')),
),
'react-dom': compatDirname(
'react-dom/package',
cwd,
dirname(require.resolve('react-dom/package.json')),
),
enzyme: compatDirname(
'enzyme/package.json',
cwd,
dirname(require.resolve('enzyme/package.json')),
),
'enzyme-adapter-react-16': compatDirname(
'enzyme-adapter-react-16/package.json',
cwd,
dirname(require.resolve('enzyme-adapter-react-16/package.json')),
),
},
},
'umi-test',
],
],
});
require.resolve('@babel/preset-typescript'),
[
require.resolve('babel-preset-umi'),
{
transformRuntime: false,
// ...(process.env.TARGETS === 'node' ? { targets: { node: 8 } } : {}),
},
],
],
plugins: [
[
require.resolve('babel-plugin-module-resolver'),
{
alias: {
// Projects don't need to install react, react-dom and enzyme
react: compatDirname(
'react/package',
cwd,
dirname(require.resolve('react/package.json')),
),
'react-dom': compatDirname(
'react-dom/package',
cwd,
dirname(require.resolve('react-dom/package.json')),
),
enzyme: compatDirname(
'enzyme/package.json',
cwd,
dirname(require.resolve('enzyme/package.json')),
),
'enzyme-adapter-react-16': compatDirname(
'enzyme-adapter-react-16/package.json',
// ...(process.env.TARGETS === 'node' ? { targets: { node: 8 } } : {}),
},
],
],
plugins: [
[
require.resolve('babel-plugin-module-resolver'),
{
alias: {
// Projects don't need to install react, react-dom and enzyme
react: compatDirname(
'react/package',
cwd,
dirname(require.resolve('react/package.json')),
),
'react-dom': compatDirname(
'react-dom/package',
cwd,
dirname(require.resolve('react-dom/package.json')),
),
enzyme: compatDirname(
'enzyme/package.json',
cwd,
dirname(require.resolve('enzyme/package.json')),
),
'enzyme-adapter-react-16': compatDirname(
'enzyme-adapter-react-16/package.json',
cwd,
dirname(require.resolve('enzyme-adapter-react-16/package.json')),
),
},
},
// ...(process.env.TARGETS === 'node' ? { targets: { node: 8 } } : {}),
},
],
],
plugins: [
[
require.resolve('babel-plugin-module-resolver'),
{
alias: {
// Projects don't need to install react, react-dom and enzyme
react: compatDirname(
'react/package',
cwd,
dirname(require.resolve('react/package.json')),
),
'react-dom': compatDirname(
'react-dom/package',
cwd,
dirname(require.resolve('react-dom/package.json')),
),
enzyme: compatDirname(
'enzyme/package.json',
cwd,
dirname(require.resolve('enzyme/package.json')),
),
'enzyme-adapter-react-16': compatDirname(
'enzyme-adapter-react-16/package.json',
cwd,
dirname(require.resolve('enzyme-adapter-react-16/package.json')),
),
},
},
[
require.resolve('babel-plugin-module-resolver'),
{
alias: {
// Projects don't need to install react, react-dom and enzyme
react: compatDirname(
'react/package',
cwd,
dirname(require.resolve('react/package.json')),
),
'react-dom': compatDirname(
'react-dom/package',
cwd,
dirname(require.resolve('react-dom/package.json')),
),
enzyme: compatDirname(
'enzyme/package.json',
cwd,
dirname(require.resolve('enzyme/package.json')),
),
'enzyme-adapter-react-16': compatDirname(
'enzyme-adapter-react-16/package.json',
cwd,
dirname(require.resolve('enzyme-adapter-react-16/package.json')),
),
},
},
'ddn-test',
],
],
});
require.resolve('@babel/preset-typescript'),
[
require.resolve('babel-preset-umi'),
{
transformRuntime: false,
// ...(process.env.TARGETS === 'node' ? { targets: { node: 8 } } : {}),
},
],
],
plugins: [
[
require.resolve('babel-plugin-module-resolver'),
{
alias: {
// Projects don't need to install react, react-dom and enzyme
react: compatDirname(
'react/package',
cwd,
dirname(require.resolve('react/package.json')),
),
'react-dom': compatDirname(
'react-dom/package',
cwd,
dirname(require.resolve('react-dom/package.json')),
),
enzyme: compatDirname(
'enzyme/package.json',
cwd,
dirname(require.resolve('enzyme/package.json')),
),
'enzyme-adapter-react-16': compatDirname(
'enzyme-adapter-react-16/package.json',
init() {
// load env
this.loadEnv();
// init plugins
this.initPlugins();
// reload user config
const userConfig = new UserConfig(this);
const config = userConfig.getConfig({ force: true });
mergeConfig(this.config, config);
this.userConfig = userConfig;
if (config.browserslist) {
deprecate('config.browserslist', 'use config.targets instead');
}
debug('got user config');
debug(this.config);
// assign user's outputPath config to paths object
if (config.outputPath) {
const { paths } = this;
paths.outputPath = config.outputPath;
paths.absOutputPath = join(paths.cwd, config.outputPath);
}
debug('got paths');
debug(this.paths);
}
export async function parseGitUrl(url, closeFastGithub) {
const args = GitUrlParse(url);
const { ref, filepath, resource, full_name: fullName } = args;
const fastGithub = await getFastGithub();
// 如果是 github 并且 autoFastGithub =true 使用
// 因为自动转化只支持 github 也可以需要关掉
const repo =
resource === 'github.com' && !closeFastGithub
? args.toString().replace(`${resource}`, fastGithub)
: args.toString();
return {
repo: urlAddGit(repo),
branch: ref || 'master',
path: `/${filepath}`,
id: `${resource}/${fullName}`, // 唯一标识一个 git 仓库
};
}
subBlocks.map((block: string) => {
const subBlockPath = join(ctx.templateTmpDirPath, block);
debug(`subBlockPath: ${subBlockPath}`);
return new BlockGenerator(args._.slice(2), {
sourcePath: subBlockPath,
path: isPageBlock ? generator.path : join(generator.path, generator.blockFolderName),
// eslint-disable-next-line
blockName: getNameFromPkg(require(join(subBlockPath, 'package.json'))),
isPageBlock: false,
dryRun,
env: {
cwd: api.cwd,
},
routes: api.config.routes,
resolved: winPath(__dirname),
}).run();
}),
);
.map((fileName: string) => {
const status = fs.statSync(join(path, fileName));
// 是文件夹 并且不已 . 开头, 且最深三层
if (status.isDirectory() && fileName.indexOf('.') !== 0 && depth < 3) {
const absPath = winPath(join(path, fileName));
const absPagePath = winPath(join(parentPath, fileName));
const children = getFolderTreeData(absPath, absPagePath, depth + 1);
if (children && children.length > 0) {
return {
key: absPagePath,
title: fileName,
value: absPagePath,
children,
};
}
return { title: fileName, value: absPagePath, key: absPagePath };
}
return undefined;
})
.filter(obj => obj);