Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: rax component docs not display #887

Merged
merged 2 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions extensions/material-helper/src/utils/getComponentSource.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as parser from '@babel/parser';
import traverse from '@babel/traverse';
import { isImportDefaultSpecifier } from '@babel/types';
import getBabelParserPlugins from './getBabelParserPlugins';

function getComponentSource(
Expand All @@ -16,15 +17,16 @@ function getComponentSource(
traverse(ast, {
ImportDeclaration(path) {
const specifiers = path.get('specifiers');
const targetSpecifier = specifiers.find(specifier => specifier.node.local.name === tagName);
const targetSpecifier = specifiers.find((specifier) => specifier.node.local.name === tagName);
if (targetSpecifier) {
result.source = path.node.source.value;
// @ts-ignore
result.importedComponent = targetSpecifier.node.imported.name;
const { node: { local, imported } } = targetSpecifier;
result.importedComponent = isImportDefaultSpecifier(targetSpecifier) ? local.name : imported.name;
path.stop();
}
}
})
},
});

return result;
}
Expand Down
4 changes: 4 additions & 0 deletions packages/constant/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 0.1.2

- Feat: add fusion mobile docs link

## 0.1.1

- Chore: update appworks icon
2 changes: 1 addition & 1 deletion packages/constant/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@appworks/constant",
"version": "0.1.1",
"version": "0.1.2",
"main": "lib/index.js",
"scripts": {
"compile": "rm -rf lib && tsc -p ./tsconfig.json",
Expand Down
2 changes: 2 additions & 0 deletions packages/constant/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ export const ALI_DIP_PRO = Base64.decode('aHR0cHM6Ly9hZHAuZmMuYWxpYmFiYS1pbmMuY2
export const ALI_EXTENSION_UPLOAD_URL = Base64.decode('aHR0cHM6Ly9tYXJrZXRwbGFjZS5hbnRmaW4taW5jLmNvbS9vcGVuYXBpL2V4dGVuc2lvbi91cGxvYWQ=');
export const ALI_EXTENSION_STATUS_UPDATE_URL = Base64.decode('aHR0cHM6Ly9tYXJrZXRwbGFjZS5hbnRmaW4taW5jLmNvbS9vcGVuYXBpL2V4dGVuc2lvbi9zdGF0dXM=');
export const ICEWORKS_ICON_PATH = 'https://img.alicdn.com/imgextra/i4/O1CN01AvqMOu1sYpY1j8xaI_!!6000000005779-2-tps-574-204.png';

export const FUSION_MOBILE_MATERIAL_BASE_HOME_URL = Base64.decode('aHR0cHM6Ly9mdXNpb24uYWxpYmFiYS1pbmMuY29tL21vYmlsZQ==');
1 change: 1 addition & 0 deletions packages/material-engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"typings": "lib/index.d.ts",
"dependencies": {
"@appworks/common-service": "^0.1.0",
"@appworks/constant": "^0.1.1",
"@appworks/i18n": "^0.1.0",
"@appworks/material-utils": "^0.1.0",
"@appworks/project-service": "^0.1.0",
Expand Down
22 changes: 11 additions & 11 deletions packages/material-engine/src/material/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
getDataFromSettingJson,
CONFIGURATION_KEY_MATERIAL_SOURCES,
} from '@appworks/common-service';
import { FUSION_MOBILE_MATERIAL_BASE_HOME_URL } from '@appworks/constant';
import { IMaterialSource, IMaterialData, IMaterialBase } from '@appworks/material-utils';
import { getProjectType } from '@appworks/project-service';
import i18n from './i18n';
Expand All @@ -23,11 +24,10 @@ const VUE_MATERIAL_SOURCE = 'https://ice.alicdn.com/assets/materials/vue-materia
const RAX_MATERIAL_SOURCE = 'https://ice.alicdn.com/assets/materials/rax-materials.json';
// base component source
const FUSION_PC_COMPONENTS_SOURCE = 'https://ice.alicdn.com/assets/base-components-1.x.json';
const RAX_BASE_COMPONENTS_SOURCE = 'http://ice.alicdn.com/assets/rax-base-components.json';
const RAX_BASE_COMPONENTS_SOURCE = 'https://ice.alicdn.com/assets/rax-base-components.json';
const ANTD_PC_COMPONENTS_SOURCE = 'https://iceworks.oss-cn-hangzhou.aliyuncs.com/assets/antd-components.json';
// base home url
const FUSION_PC_MATERIAL_BASE_HOME_URL = 'https://fusion.design/pc/component';
const FUSION_MOBILE_MATERIAL_BASE_HOME_URL = 'https://fusion.alibaba-inc.com/mobile';
const ANTD_PC_MATERIAL_BASE_HOME_URL = 'https://ant.design/components';
// base repository url
const FUSION_PC_MATERIAL_BASE_REPOSITORY_URL = 'https://github.com/alibaba-fusion/next/tree/master/src';
Expand All @@ -38,20 +38,20 @@ const componentSourceDetails = [
npm: '@alifd/next',
homeUrl: FUSION_PC_MATERIAL_BASE_HOME_URL,
componentNameFormatFunc: kebabCase,
repositoryUrl: FUSION_PC_MATERIAL_BASE_REPOSITORY_URL
repositoryUrl: FUSION_PC_MATERIAL_BASE_REPOSITORY_URL,
},
{
npm: '@alifd/meet',
homeUrl: FUSION_MOBILE_MATERIAL_BASE_HOME_URL,
componentNameFormatFunc: kebabCase
componentNameFormatFunc: kebabCase,
},
{
npm: 'antd',
homeUrl: ANTD_PC_MATERIAL_BASE_HOME_URL,
componentNameFormatFunc: lowerCase,
repositoryUrl: ANTD_PC_MATERIAL_BASE_REPOSITORY_URL
}
]
repositoryUrl: ANTD_PC_MATERIAL_BASE_REPOSITORY_URL,
},
];

const OFFICAL_MATERIAL_SOURCES = [
{
Expand Down Expand Up @@ -100,7 +100,7 @@ const isIceMaterial = (source: string) => {

const isAntdMaterial = (source: string) => {
return source === ANTD_MATERIAL_SOURCE;
}
};

const isRaxMaterial = (source: string) => {
return source === RAX_MATERIAL_SOURCE;
Expand Down Expand Up @@ -197,7 +197,7 @@ export const getData = async function (source: string): Promise<IMaterialData> {
};

function getBaseMaterials(data, npm?, version?) {
const componentSourceDetail = componentSourceDetails.find(item => item.npm === npm) || {} as any;
const componentSourceDetail = componentSourceDetails.find((item) => item.npm === npm) || {} as any;
const { homeUrl, repositoryUrl, componentNameFormatFunc } = componentSourceDetail;

return data.map((base: any) => {
Expand All @@ -207,13 +207,13 @@ function getBaseMaterials(data, npm?, version?) {
title,
categories: [type],
importStatement,
homepage: homeUrl ? `${homeUrl}/${componentNameFormatFunc(name)}`: '',
homepage: homeUrl ? `${homeUrl}/${componentNameFormatFunc(name)}` : '',
repository: repositoryUrl ? `${repositoryUrl}/${componentNameFormatFunc(name)}` : '',
source: source || {
type: 'npm',
npm,
version,
registry: 'http://registry.npmjs.com',
registry: 'https://registry.npmjs.com',
},
};
});
Expand Down
Loading