Skip to content
This repository has been archived by the owner on May 9, 2020. It is now read-only.

Commit

Permalink
Release v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chenbin92 authored Apr 27, 2020
2 parents b62582c + 8812428 commit a577907
Show file tree
Hide file tree
Showing 79 changed files with 904 additions and 448 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ const commonRules = {
"no-underscore-dangle": 0,
"class-methods-use-this": 0,
"no-param-reassign": 0,
"comma-dangle": 0
"comma-dangle": 0,
"prefer-object-spread": 0,
// TODO: open rule indent, consider of MemberExpression
"indent": 0,
};

const jsRules = deepmerge(eslint, {
Expand Down
4 changes: 2 additions & 2 deletions examples/basic-mpa/src/pages/Dashboard/app.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createApp, IAppConfig } from 'ice';
import Dashboard from './index';
import routes from './routes';

const appConfig: IAppConfig = {
router: {
routes: [{ path: '/', component: Dashboard }],
routes
},
};

Expand Down
3 changes: 3 additions & 0 deletions examples/basic-mpa/src/pages/Dashboard/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Index from './index';

export default [{ path: '/', component: Index }];
5 changes: 5 additions & 0 deletions examples/basic-request/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ const appConfig: IAppConfig = {
baseURL: '/api',
interceptors: {
response: {
// 可选的
onConfig: (config) => {
console.log({history});
return config;
},
// 可选的
onError: (error) => {
return Promise.reject(error);
}
},
}
}
Expand Down
52 changes: 26 additions & 26 deletions examples/basic-service/mock/index.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
module.exports = {
'GET /todo_getAll': {
"errorCode": "0",
"errorMsg": "",
"data": [
'errorCode': '0',
'errorMsg': '',
'data': [
{
"id": "1",
"title": "安卓",
"dnoe": true
'id': '1',
'title': '安卓',
'dnoe': true
},
{
"id": "2",
"title": "iOS",
"dnoe": true
'id': '2',
'title': 'iOS',
'dnoe': true
}
],
"success": true
'success': true
},
'GET /todo_getOne': {
"errorCode": "0",
"errorMsg": "",
"data": {
"id": "2222222",
"title": "安卓",
"dnoe": true
'errorCode': '0',
'errorMsg': '',
'data': {
'id': '2222222',
'title': '安卓',
'dnoe': true
},
"requestId": "@guid",
"success": true
'requestId': '@guid',
'success': true
},
'POST /todo_add': {
"errorCode": "0",
"errorMsg": "",
"data": {
"id": "2222222",
"title": "安卓",
"dnoe": true
'errorCode': '0',
'errorMsg': '',
'data': {
'id': '2222222',
'title': '安卓',
'dnoe': true
},
"requestId": "@guid",
"success": true
'requestId': '@guid',
'success': true
},
};
4 changes: 4 additions & 0 deletions examples/basic-spa/build.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@
"prod": {
"ignoreHtmlTemplate": false
}
},
"eslint": {
"disable": false,
"quiet": true
}
}
3 changes: 2 additions & 1 deletion examples/basic-spa/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { createApp, APP_MODE, IAppConfig } from 'ice';
const appConfig: IAppConfig = {
app: {
rootId: 'ice-container',
errorBoundary: true
errorBoundary: true,
parseSearchParams: true
},
logger: {
level: APP_MODE === 'build' ? 'error' : 'debug',
Expand Down
25 changes: 23 additions & 2 deletions examples/basic-spa/src/pages/Dashboard/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
import React from 'react';
import { Link } from 'ice';
import { Link, useSearchParams, withSearchParams } from 'ice';

const Dashboard = () => {
@withSearchParams
class Foo extends React.PureComponent {
public render() {
console.log('Foo:', this.props.searchParams);
return (
<>Foo</>
);
}
}

const Bar = () => {
const searchParams = useSearchParams();
console.log('Bar:', searchParams);
return (
<>Bar</>
);
};

const Dashboard = (props) => {
console.log('props:', props);
return (
<>
<h2>Dashboard Page...</h2>
<Foo />
<Bar />
<Link to="/about">About</Link>
</>
);
Expand Down
4 changes: 2 additions & 2 deletions examples/basic-store/src/pages/NotFound/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Link } from 'ice';

const Home = () => {
const NotFound = () => {
return (
<>
<h2>404 Page...</h2>
Expand All @@ -11,4 +11,4 @@ const Home = () => {
);
};

export default Home;
export { NotFound };
14 changes: 7 additions & 7 deletions examples/basic-store/src/routes.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { lazy } from 'ice';
// import { lazy } from 'ice';

import Layout from '@/layouts/index';
// import Home from '@/pages/Home';
// import About from '@/pages/About';
// import NotFound from '@/pages/NotFound';
import Home from '@/pages/Home';
import About from '@/pages/About';
import { NotFound } from '@/pages/NotFound';

const Home = lazy(() => import('@/pages/Home'));
const About =lazy(() => import('@/pages/About'));
const NotFound = lazy(() => import('@/pages/NotFound'));
// const Home = lazy(() => import('@/pages/Home'));
// const About =lazy(() => import('@/pages/About'));
// const NotFound = lazy(() => import('@/pages/NotFound'));

export default [
{
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.1.9",
"version": "1.2.0",
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ice.js",
"private": true,
"version": "1.1.8",
"version": "1.2.0",
"workspaces": [
"packages/*"
],
Expand Down Expand Up @@ -30,7 +30,7 @@
},
"devDependencies": {
"@commitlint/cli": "^8.2.0",
"@ice/spec": "^0.1.9",
"@ice/spec": "^1.0.0",
"eslint": "^6.8.0",
"esm": "^3.2.25",
"execa": "^4.0.0",
Expand All @@ -50,4 +50,4 @@
"dependencies": {
"core-js": "^3.6.4"
}
}
}
2 changes: 1 addition & 1 deletion packages/create-ice/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-ice",
"version": "1.1.9",
"version": "1.2.0",
"description": "npm init ice",
"author": "[email protected]",
"homepage": "",
Expand Down
22 changes: 11 additions & 11 deletions packages/icejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ice.js",
"version": "1.1.9",
"version": "1.2.0",
"description": "command line interface and builtin plugin for icejs",
"author": "[email protected]",
"homepage": "",
Expand All @@ -21,16 +21,16 @@
},
"dependencies": {
"@alib/build-scripts": "^0.1.13",
"build-plugin-ice-config": "1.1.9",
"build-plugin-ice-core": "1.1.9",
"build-plugin-ice-helpers": "1.1.9",
"build-plugin-ice-logger": "1.1.9",
"build-plugin-ice-mpa": "1.1.9",
"build-plugin-ice-request": "1.1.9",
"build-plugin-ice-router": "1.1.9",
"build-plugin-ice-ssr": "1.1.9",
"build-plugin-ice-store": "1.1.9",
"build-plugin-react-app": "1.1.9",
"build-plugin-ice-config": "1.2.0",
"build-plugin-ice-core": "1.2.0",
"build-plugin-ice-helpers": "1.2.0",
"build-plugin-ice-logger": "1.2.0",
"build-plugin-ice-mpa": "1.2.0",
"build-plugin-ice-request": "1.2.0",
"build-plugin-ice-router": "1.2.0",
"build-plugin-ice-ssr": "1.2.0",
"build-plugin-ice-store": "1.2.0",
"build-plugin-react-app": "1.2.0",
"chokidar": "^3.3.1",
"commander": "^5.0.0",
"detect-port": "^1.3.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-config",
"version": "1.1.9",
"version": "1.2.0",
"description": "Define application config in icejs",
"author": "[email protected]",
"homepage": "",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const plugin: IPlugin = async (api): Promise<void> => {

await fse.copy(srcPath, distPath);
// add to ice exports
applyMethod('addIceExport', { source: `./config`, exportName });
applyMethod('addIceExport', { source: './config', exportName });
} else {
// remove config file
applyMethod('removeIceExport', exportName);
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-core",
"version": "1.1.9",
"version": "1.2.0",
"description": "the core plugin for icejs.",
"author": "[email protected]",
"homepage": "",
Expand Down
20 changes: 11 additions & 9 deletions packages/plugin-core/src/generator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as prettier from 'prettier';
import generateExports from '../utils/generateExports';
import checkExportData from '../utils/checkExportData';
import removeExportData from '../utils/removeExportData';
import { IExportData } from '../types';
import { IExportData } from '../types/base';

interface IRenderData {
[key: string]: any;
Expand All @@ -20,7 +20,7 @@ interface IRenderFile {
(templatePath: string, targetDir: string, extraData?: IRenderData): void;
}

const API_MAP = ['addEntryImports', 'addEntryCode', 'addIceExport', 'addIceTypesExport'];
const API_MAP = ['addEntryImports', 'addEntryCode', 'addIceExport', 'addIceTypesExport', 'addIceAppConfigTypes'];

export default class Generator {
public templateDir: string;
Expand Down Expand Up @@ -50,7 +50,7 @@ export default class Generator {
this.showPrettierError = true;
}

public addExport = (registerKey ,exportData: IExportData|IExportData[]) => {
public addExport = (registerKey, exportData: IExportData | IExportData[]) => {
const exportList = this.contentRegistration[registerKey] || [];
checkExportData(exportList, exportData, registerKey);
this.addContent(registerKey, exportData);
Expand All @@ -59,7 +59,7 @@ export default class Generator {
}
}

public removeExport = (registerKey: string, removeExportName: string|string[]) => {
public removeExport = (registerKey: string, removeExportName: string | string[]) => {
const exportList = this.contentRegistration[registerKey] || [];
this.contentRegistration[registerKey] = removeExportData(exportList, removeExportName);
if (this.rerender) {
Expand All @@ -86,20 +86,22 @@ export default class Generator {

private getExportStr(registerKey, dataKeys) {
const exportList = this.contentRegistration[registerKey] || [];
const { importStr, exportStr } = generateExports(exportList);
const [importStrKey, exportStrKey] = dataKeys;
const { importStr, exportStr, extraStr } = generateExports(exportList);
const [importStrKey, exportStrKey, extraStrKey] = dataKeys;
return {
[importStrKey]: importStr,
[exportStrKey]: exportStr,
[extraStrKey]: extraStr,
};
}

public parseRenderData() {
const globalStyles = globby.sync(['src/global.@(scss|less|css)'], { cwd: this.projectRoot});
const globalStyles = globby.sync(['src/global.@(scss|less|css)'], { cwd: this.projectRoot });
this.renderData = {
...this.renderData,
...this.getExportStr('addIceExport', ['iceImports', 'iceExports']),
...this.getExportStr('addIceTypesExport', ['iceTypesImports', 'iceTypesExports']),
...this.getExportStr('addIceAppConfigTypes', ['iceIAppConfigTypesImports', 'iceIAppConfigTypesExports', 'iceIAppTypes']), // add types to the AppConfig & IApp
globalStyle: globalStyles.length && globalStyles[0],
entryImportsBefore: this.generateImportStr('addEntryImports_before'),
entryImportsAfter: this.generateImportStr('addEntryImports_after'),
Expand All @@ -118,7 +120,7 @@ export default class Generator {

public async render() {
this.rerender = true;
const ejsTemplates = await globby(['**/*'], { cwd: this.templateDir});
const ejsTemplates = await globby(['**/*'], { cwd: this.templateDir });
this.parseRenderData();
ejsTemplates.forEach((template) => {
const templatePath = path.join(this.templateDir, template);
Expand All @@ -135,7 +137,7 @@ export default class Generator {

public renderFile: IRenderFile = (templatePath, targetPath, extraData = {}) => {
const templateContent = fse.readFileSync(templatePath, 'utf-8');
let content = ejs.render(templateContent, {...this.renderData, ...extraData});
let content = ejs.render(templateContent, { ...this.renderData, ...extraData });
try {
content = prettier.format(content, {
parser: 'typescript',
Expand Down
Loading

0 comments on commit a577907

Please sign in to comment.