Skip to content

Commit

Permalink
😁 add emoji
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Sep 29, 2019
1 parent 3b7c216 commit 29f14d6
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 24 deletions.
6 changes: 4 additions & 2 deletions packages/umi-build-dev/src/plugins/commands/block/addBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export interface AddBlockOption {
// 在 ci 与 function 中执行可以设置为 auto
execution?: 'shell' | 'auto';

index?: number;

// 传输 log 用
remoteLog?: (log: string) => void;
}
Expand Down Expand Up @@ -363,12 +365,12 @@ async function add(
try {
clipboardy.writeSync(viewUrl);
log.success(
`probable url ${chalk.cyan(viewUrl)} ${chalk.dim(
`✨ Probable url ${chalk.cyan(viewUrl)} ${chalk.dim(
'(copied to clipboard)',
)} for view the block.`,
);
} catch (e) {
log.success(`probable url ${chalk.cyan(viewUrl)} for view the block.`);
log.success(`✨ Probable url ${chalk.cyan(viewUrl)} for view the block.`);
log.error('copy to clipboard failed');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ const clone = async (ctx: IFlowContext) => {
return;
}

logger.appendLog(`Start git clone from ${repo}`);
logger.appendLog(`🚚 Start git clone from ${repo}`);
await execa('git', ['clone', repo, id, '--single-branch', '--recurse-submodules', '-b', branch], {
cwd: blocksTempPath,
env: process.env,
});
logger.appendLog('Success git clone\n');
logger.appendLog('🎉 Success git clone\n');
};

export default clone;
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const clone = async (ctx: IFlowContext, args: IAddBlockOption) => {
const { logger, execa } = ctx;
const { branch, templateTmpDirPath, sourcePath, routePath } = ctx.stages.blockCtx as ICtxTypes;

logger.appendLog('Start git fetch');
logger.appendLog('Start git fetch');
try {
await execa('git', ['fetch'], {
cwd: templateTmpDirPath,
Expand All @@ -27,9 +27,9 @@ const clone = async (ctx: IFlowContext, args: IAddBlockOption) => {
logger.appendLog(`Faild git fetch: ${e.message}`);
throw new Error(e);
}
logger.appendLog('Success git fetch\n');
logger.appendLog('🎉 Success git fetch\n');

logger.appendLog(`Start git checkout ${branch}`);
logger.appendLog(`Start git checkout ${branch}`);
try {
await execa('git', ['checkout', branch], {
cwd: templateTmpDirPath,
Expand All @@ -39,9 +39,9 @@ const clone = async (ctx: IFlowContext, args: IAddBlockOption) => {
throw new Error(e);
}

logger.appendLog(`Success git checkout ${branch}\n`);
logger.appendLog(`🎉 Success git checkout ${branch}\n`);

logger.appendLog('Start git pull');
logger.appendLog('Start git pull');

try {
await execa('git', ['pull'], {
Expand Down Expand Up @@ -73,7 +73,7 @@ const clone = async (ctx: IFlowContext, args: IAddBlockOption) => {
throw e;
}

logger.appendLog('Success git pull\n');
logger.appendLog('🎉 Success git pull\n');

assert(existsSync(sourcePath), `${sourcePath} don't exists`);
let pkg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const generatorFunc = async (ctx: IFlowContext, args: IAddBlockOption) => {
const { dryRun, page: isPage, js, execution = 'shell', uni18n } = args;

logger.appendLog();
logger.appendLog('Start generate files');
logger.appendLog('📦 Start generate files');

const getBlockGenerator = require('../../../../getBlockGenerator');
const BlockGenerator = getBlockGenerator.default(ctx.api);
Expand Down Expand Up @@ -76,20 +76,20 @@ const generatorFunc = async (ctx: IFlowContext, args: IAddBlockOption) => {
}
}

logger.appendLog('Success generate files\n');
logger.appendLog('🎉 Success generate files\n');

// 调用 sylvanas 转化 ts
if (js) {
// opts.remoteLog('TypeScript to JavaScript'); // TODO: add log
logger.appendLog('Start TypeScript to JavaScript');
logger.appendLog('🎭 Start TypeScript to JavaScript');
require('../../../../tsTojs').default(generator.blockFolderPath);
logger.appendLog('Success TypeScript to JavaScript\n');
logger.appendLog('🎉 Success TypeScript to JavaScript\n');
}

if (uni18n) {
logger.appendLog('Start remove i18n code');
logger.appendLog('🌏 Start remove i18n code');
require('../../../../remove-locale').default(generator.blockFolderPath, uni18n);
logger.appendLog('Success remove i18n code\n');
logger.appendLog('🎉 Success remove i18n code\n');
}

ctx.stages.generator = generator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const writeRoutes = async (ctx: IFlowContext, args: IAddBlockOption) => {

if (generator.needCreateNewRoute && api.config.routes && !skipModifyRoutes) {
logger.appendLog(
`Start write route from ${generator.routePath} to ${api.service.userConfig.file}`,
`🛠 Start write route from ${generator.routePath} to ${api.service.userConfig.file}`,
);
// 当前 _modifyBlockNewRouteConfig 只支持配置式路由
// 未来可以做下自动写入注释配置,支持约定式路由
Expand All @@ -29,12 +29,14 @@ const writeRoutes = async (ctx: IFlowContext, args: IAddBlockOption) => {
logger.appendLog(`Faild to write route: ${e.message}\n`);
throw new Error(e);
}
logger.appendLog('Success write route\n');
logger.appendLog('🎉 Success write route\n');
}

if (!generator.isPageBlock) {
logger.appendLog(
`Start write block component ${generator.blockFolderName} import to ${generator.entryPath}`,
`🍽 Start write block component ${generator.blockFolderName} import to ${
generator.entryPath
}`,
);
try {
appendBlockToContainer({
Expand All @@ -47,12 +49,12 @@ const writeRoutes = async (ctx: IFlowContext, args: IAddBlockOption) => {
logger.appendLog(`Faild write block component: ${e.message}\n`);
throw new Error(e);
}
logger.appendLog('Success write block component \n');
logger.appendLog('🎉 Success write block component \n');
}

// Final: show success message
const viewUrl = `http://localhost:${process.env.PORT || '8000'}${generator.path.toLowerCase()}`;
logger.appendLog(`Probable url ${chalk.cyan(viewUrl)} for view the block.`);
logger.appendLog(`Probable url ${chalk.cyan(viewUrl)} for view the block.`);
};

export default writeRoutes;
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export interface IAddBlockOption {
// 在 ci 与 function 中执行可以设置为 auto
execution?: 'shell' | 'auto';

// 区块的位置
index?: number;

// 传输 log 用
remoteLog?: (log: string) => void;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default (api: IApi) => {
case 'org.umi.block.list':
(async () => {
try {
const resourceId = (payload as { resourceId: string }).resourceId;
const { resourceId } = payload as { resourceId: string };
let data = blockListCache[resourceId];
if (!data || (payload as { force: boolean }).force) {
data = await blockService.getBlockList(resourceId, resources);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,14 @@ export const getFilesTreeData = (
!isDirectory &&
!fileName.includes('.tsx') &&
!fileName.includes('.jsx') &&
!fileName.includes('.js')
!fileName.includes('.js') &&
!fileName.includes('.ts')
) {
return undefined;
}
const absPath = winPath(join(path, fileName));
const absPagePath = winPath(join(parentPath, fileName));
const children = isDirectory ? getFolderTreeData(absPath, absPagePath, depth + 1) : [];
const children = isDirectory ? getFilesTreeData(absPath, absPagePath, depth + 1) : [];
if (children && children.length > 0) {
return {
key: absPagePath,
Expand Down

0 comments on commit 29f14d6

Please sign in to comment.