diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index 3844c94..d905a07 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -2,10 +2,53 @@
Hi! I’m really excited that you are interested in contributing to ICE. Before submitting your contribution though, please make sure to take a moment and read through the following guidelines.
+- [Setup Environment](#setup-environment)
+- [Run Examples](#run-examples)
+- [Publish Packages](publish-packages)
- [Pull Request Guidelines](#pull-request-guidelines)
- [Issue Reporting Guidelines](#issue-reporting-guidelines)
- [Git Commit Specific](#git-commit-specific)
+## Setup Environment
+
+clone repo and initialize the setup environment:
+
+```bash
+# 1. clone and setup
+$ git clone git@github.com:ice-lab/icejs.git
+$ cd icejs && npm run setup
+
+# 2. watch packages
+$ npm run watch
+```
+
+## Run Examples
+
+We provide a lot of examples, you can run the examples:
+
+```bash
+$ cd examples/basic-spa
+$ npm link ../../packages/icejs
+$ npm start
+```
+
+## Publish Packages
+
+When you need to release, you can execute the command:
+
+```bash
+$ npm run publish
+# 1. ✔️ ✔️ ✔️ Checking the working tree status...
+# 2. 📦 📦 📦 Building packages...
+# 3. ⚡ ⚡ ⚡ Update package version automatically...
+# 4. 🚀 🚀 🚀 Start publishing...
+# 5. 🔖 🔖 🔖 Commit & Create tag'...
+# 6. 💡 💡 💡 Start syncing...
+```
+
+* When you need to release a latest version, the tag will be created automatically, running `npm publish` will tag your package with the `latest` dist-tag.
+* To publish a package with the `beta` dist-tag, you can choose to release rc、beta、alpha versions, the tag will not be created.
+
## Pull Request Guidelines
- Only code that's ready for release should be committed to the master branch. All development should be done in dedicated branches.
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..d85872e
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,23 @@
+name: CI
+
+on: [push]
+
+jobs:
+ lint:
+
+ runs-on: ubuntu-latest
+
+ strategy:
+ matrix:
+ node-version: [10.x]
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Use Node.js ${{ matrix.node-version }}
+ uses: actions/setup-node@v1
+ with:
+ node-version: ${{ matrix.node-version }}
+ - run: npm install
+ - run: npm run lint
+ env:
+ CI: true
diff --git a/README.md b/README.md
index 1432657..f23d225 100644
--- a/README.md
+++ b/README.md
@@ -115,20 +115,6 @@ Finally, To start developing your application run `npm run start`. The applicati
## Contributing
-```bash
-# 1. clone and setup
-$ git clone git@github.com:ice-lab/icejs.git
-$ cd icejs && npm run setup
-
-# 2. watch packages
-$ npm run watch
-
-# 3. run example
-$ cd examples/spa-basic
-$ npm link ../../packages/icejs
-$ npm start
-```
-
Please see our [CONTRIBUTING.md](/.github/CONTRIBUTING.md)
## Ecosystem
diff --git a/README_zh-CN.md b/README_zh-CN.md
index a272172..831cd42 100644
--- a/README_zh-CN.md
+++ b/README_zh-CN.md
@@ -115,20 +115,6 @@ createApp(appConfig)
## 贡献代码
-```bash
-# 1. clone and setup
-$ git clone git@github.com:ice-lab/icejs.git
-$ cd icejs && npm run setup
-
-# 2. watch packages
-$ npm run watch
-
-# 3. run example
-$ cd examples/spa-basic
-$ npm link ../../packages/icejs
-$ npm start
-```
-
贡献代码请参考 [CONTRIBUTING.md](/.github/CONTRIBUTING.md)
## 生态
diff --git a/examples/basic-mpa/src/pages/Dashboard/app.ts b/examples/basic-mpa/src/pages/Dashboard/app.ts
index b647eee..c0fea3e 100644
--- a/examples/basic-mpa/src/pages/Dashboard/app.ts
+++ b/examples/basic-mpa/src/pages/Dashboard/app.ts
@@ -1,7 +1,7 @@
-import { createApp } from 'ice'
+import { createApp, IAppConfig } from 'ice'
import Dashboard from './index'
-const appConfig = {
+const appConfig: IAppConfig = {
router: {
routes: [{ path: '/', component: Dashboard }],
},
diff --git a/examples/basic-mpa/src/pages/Dashboard/models/counter.ts b/examples/basic-mpa/src/pages/Dashboard/models/counter.ts
index bd24bcc..8c45dfa 100644
--- a/examples/basic-mpa/src/pages/Dashboard/models/counter.ts
+++ b/examples/basic-mpa/src/pages/Dashboard/models/counter.ts
@@ -1,18 +1,23 @@
-const delay = (time) => new Promise((resolve) => setTimeout(() => resolve(), time));
+export const delay = (time) => new Promise((resolve) => setTimeout(() => resolve(), time));
export default {
state: {
count: 0
},
- actions: {
- increment(prevState) {
+ reducers: {
+ increment (prevState) {
return { count: prevState.count + 1 }
},
+ decrement (prevState) {
+ return { count: prevState.count - 1 }
+ }
+ },
- async decrement(prevState) {
+ effects: {
+ async decrementAsync (state, payload, actions) {
await delay(10);
- return { count: prevState.count - 1 }
+ actions.decrement();
},
- },
+ }
};
diff --git a/examples/basic-mpa/src/pages/Home/app.ts b/examples/basic-mpa/src/pages/Home/app.ts
index ad841d7..fe34387 100644
--- a/examples/basic-mpa/src/pages/Home/app.ts
+++ b/examples/basic-mpa/src/pages/Home/app.ts
@@ -1,7 +1,7 @@
-import { createApp } from 'ice'
+import { createApp, IAppConfig } from 'ice'
import Home from './index'
-const appConfig = {
+const appConfig: IAppConfig = {
router: {
routes: [{ path: '/', component: Home }],
},
diff --git a/examples/basic-request/src/app.ts b/examples/basic-request/src/app.ts
index d364761..68cc317 100644
--- a/examples/basic-request/src/app.ts
+++ b/examples/basic-request/src/app.ts
@@ -1,6 +1,6 @@
-import { createApp } from 'ice';
+import { createApp, IAppConfig } from 'ice';
-const appConfig = {
+const appConfig: IAppConfig = {
app: {
rootId: 'ice-container',
},
diff --git a/examples/basic-spa/build.json b/examples/basic-spa/build.json
index 8f8f2d4..71487ed 100644
--- a/examples/basic-spa/build.json
+++ b/examples/basic-spa/build.json
@@ -1,7 +1,4 @@
{
- "router": {
- "ignorePaths": ["stores", "components"]
- },
"ignoreHtmlTemplate": true,
"plugins": [],
"modeConfig": {
diff --git a/examples/basic-spa/src/app.ts b/examples/basic-spa/src/app.ts
index c0a56eb..a1e0765 100644
--- a/examples/basic-spa/src/app.ts
+++ b/examples/basic-spa/src/app.ts
@@ -1,20 +1,22 @@
-import { createApp, APP_MODE } from 'ice'
+import { createApp, APP_MODE, IAppConfig } from 'ice'
-const appConfig = {
+const appConfig: IAppConfig = {
app: {
rootId: 'ice-container'
},
logger: {
level: APP_MODE === 'build' ? 'error' : 'debug',
},
+ router: {
+ type: 'hash'
+ },
request: {
timeout: 5000,
- // baseURL: '/abc',
+ baseURL: '/',
interceptors: {
- response: {
- onConfig: (conf) => {
- console.log('interceptors response:', conf)
- return conf
+ request: {
+ onConfig: (config) => {
+ return config
}
}
}
diff --git a/examples/basic-spa/src/routes.ts b/examples/basic-spa/src/routes.ts
index 4cf7169..cfd373a 100644
--- a/examples/basic-spa/src/routes.ts
+++ b/examples/basic-spa/src/routes.ts
@@ -6,11 +6,6 @@ const About = lazy(() => import('@/pages/About'));
const Notfound = lazy(() => import('@/pages/NotFound'));
export default [
- {
- path: '/',
- exact: true,
- component: Home
- },
{
path: '/dashboard',
exact: true,
@@ -22,8 +17,12 @@ export default [
component: About
},
{
- path: '*',
+ path: '/',
exact: true,
+ component: Home
+ },
+ {
+ path: '*',
component: Notfound
},
];
diff --git a/examples/basic-store/src/app.ts b/examples/basic-store/src/app.ts
index d364761..68cc317 100644
--- a/examples/basic-store/src/app.ts
+++ b/examples/basic-store/src/app.ts
@@ -1,6 +1,6 @@
-import { createApp } from 'ice';
+import { createApp, IAppConfig } from 'ice';
-const appConfig = {
+const appConfig: IAppConfig = {
app: {
rootId: 'ice-container',
},
diff --git a/examples/basic-store/src/models/counter.ts b/examples/basic-store/src/models/counter.ts
index 98c9f74..8c45dfa 100644
--- a/examples/basic-store/src/models/counter.ts
+++ b/examples/basic-store/src/models/counter.ts
@@ -6,16 +6,16 @@ export default {
},
reducers: {
- increment: (prevState) => {
+ increment (prevState) {
return { count: prevState.count + 1 }
},
- decrement: (prevState) => {
+ decrement (prevState) {
return { count: prevState.count - 1 }
}
},
effects: {
- decrementAsync: async (state, payload, actions) => {
+ async decrementAsync (state, payload, actions) {
await delay(10);
actions.decrement();
},
diff --git a/examples/basic-store/src/models/user.ts b/examples/basic-store/src/models/user.ts
index e50c9df..e9ce8d5 100644
--- a/examples/basic-store/src/models/user.ts
+++ b/examples/basic-store/src/models/user.ts
@@ -7,7 +7,7 @@ export default {
},
reducers: {
- update: (prevState, payload) => {
+ update (prevState, payload) {
return {
...prevState,
...payload,
@@ -16,7 +16,7 @@ export default {
},
effects: {
- getUserInfo: async (prevState, payload, actions, globalActions) => {
+ async getUserInfo (prevState, payload, actions, globalActions) {
globalActions.counter.decrement();
await delay(1000);
actions.update({
diff --git a/examples/basic-store/src/pages/About/model.ts b/examples/basic-store/src/pages/About/model.ts
index a68570a..5407119 100644
--- a/examples/basic-store/src/pages/About/model.ts
+++ b/examples/basic-store/src/pages/About/model.ts
@@ -4,7 +4,7 @@ export default {
},
reducers: {
- update: (prevState, payload) => {
+ update (prevState, payload) {
return {
...prevState,
...payload,
@@ -13,7 +13,7 @@ export default {
},
effects: {
- getPageTitle: async (prevState, payload, actions) => {
+ async getPageTitle (prevState, payload, actions) {
actions.update({
title: 'About Page'
});
diff --git a/examples/hello-world/src/app.ts b/examples/hello-world/src/app.ts
index d364761..68cc317 100644
--- a/examples/hello-world/src/app.ts
+++ b/examples/hello-world/src/app.ts
@@ -1,6 +1,6 @@
-import { createApp } from 'ice';
+import { createApp, IAppConfig } from 'ice';
-const appConfig = {
+const appConfig: IAppConfig = {
app: {
rootId: 'ice-container',
},
diff --git a/examples/icestark-child/src/app.ts b/examples/icestark-child/src/app.ts
index 0c91be5..d5192a2 100644
--- a/examples/icestark-child/src/app.ts
+++ b/examples/icestark-child/src/app.ts
@@ -1,6 +1,6 @@
-import { createApp } from 'ice'
+import { createApp, IAppConfig } from 'ice'
-const appConfig = {
+const appConfig: IAppConfig = {
app: {
rootId: 'ice-container'
},
@@ -8,7 +8,7 @@ const appConfig = {
level: 'warn'
},
icestark: {
- type: 'child',
+ type: 'child'
},
};
diff --git a/examples/icestark-child/src/pages/404.tsx b/examples/icestark-child/src/pages/404.tsx
deleted file mode 100644
index 21da91c..0000000
--- a/examples/icestark-child/src/pages/404.tsx
+++ /dev/null
@@ -1,17 +0,0 @@
-import React from 'react'
-import { Link } from 'ice'
-
-const Home = (props) => {
- console.log('render home', props);
-
- return (
- <>
-
404040404 Page...
- home
- About
- Dashboard
- >
- );
-}
-
-export default Home
diff --git a/examples/icestark-child/src/pages/About/_layout.tsx b/examples/icestark-child/src/pages/About/_layout.tsx
index 4658172..94234d1 100644
--- a/examples/icestark-child/src/pages/About/_layout.tsx
+++ b/examples/icestark-child/src/pages/About/_layout.tsx
@@ -8,7 +8,7 @@ export default function BasicLayout({
return (
- Headerxxx
+ Header
{children}
diff --git a/examples/icestark-child/src/pages/index.tsx b/examples/icestark-child/src/pages/index.tsx
index a97f711..4f05890 100644
--- a/examples/icestark-child/src/pages/index.tsx
+++ b/examples/icestark-child/src/pages/index.tsx
@@ -1,17 +1,7 @@
import React from 'react'
-import { Link, useIndexPage, helpers, logger } from 'ice'
-
-console.log('helpers from ice', helpers);
-console.log('logger from ice', logger);
-
-logger.info('=== info ===');
-logger.warn('=== warn ===');
+import { Link } from 'ice'
const Home = (props) => {
- const page = useIndexPage()
-
- console.log('Home props', props);
- console.log('render home', { page });
return (
<>
Home Page...{props.a}
@@ -22,11 +12,11 @@ const Home = (props) => {
}
Home.getInitialProps = async () => {
- return {a: 1}
+ return { a: 1 }
};
Home.pageConfig = {
- title: 'hahah'
+ title: 'Home Page'
};
export default Home
diff --git a/examples/icestark-layout/src/app.tsx b/examples/icestark-layout/src/app.tsx
index 24dd056..c262eb4 100644
--- a/examples/icestark-layout/src/app.tsx
+++ b/examples/icestark-layout/src/app.tsx
@@ -1,8 +1,8 @@
-import { createApp } from 'ice'
+import { createApp, IAppConfig } from 'ice'
import * as React from 'react';
import { ConfigProvider } from '@alifd/next';
-const appConfig = {
+const appConfig: IAppConfig = {
app: {
rootId: 'ice-container',
addProvider: ({ children }) => (
@@ -16,7 +16,7 @@ const appConfig = {
type: 'browser',
},
icestark: {
- type: 'framework',
+ type: 'framework11',
getApps: async () => {
const apps = await new Promise((resolve) => {
setTimeout(() => {
diff --git a/examples/with-fusion-design/src/app.ts b/examples/with-fusion-design/src/app.ts
index 025a6db..d8bef5f 100644
--- a/examples/with-fusion-design/src/app.ts
+++ b/examples/with-fusion-design/src/app.ts
@@ -1,6 +1,6 @@
-import { createApp } from 'ice'
+import { createApp, IAppConfig } from 'ice'
-const appConfig = {
+const appConfig: IAppConfig = {
app: {
rootId: 'ice-container'
}
diff --git a/lerna.json b/lerna.json
index 7fc3e85..fea60bc 100644
--- a/lerna.json
+++ b/lerna.json
@@ -1,5 +1,5 @@
{
- "version": "1.0.14",
+ "version": "1.0.15",
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [
diff --git a/package.json b/package.json
index 670423f..45cd0a5 100644
--- a/package.json
+++ b/package.json
@@ -11,8 +11,7 @@
"bootstrap": "SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/ npm run clean && lerna bootstrap --registry=https://registry.npm.taobao.org/ && npm run build",
"watch": "ts-node ./scripts/watch.ts",
"build": "ts-node ./scripts/build.ts",
- "publish": "npm run build && lerna publish",
- "publish-beta": "npm run build && lerna publish --dist-tag beta",
+ "publish": "ts-node ./scripts/publish.ts",
"sync": "ts-node ./scripts/sync.ts",
"owner": "ts-node ./scripts/owner.ts",
"clean": "lerna clean --yes && rimraf packages/*/lib",
@@ -39,6 +38,7 @@
"nsfw": "1.2.6",
"pify": "^4.0.1",
"rimraf": "^3.0.0",
+ "simple-git": "^1.132.0",
"ts-node": "^8.6.1",
"typescript": "^3.7.4"
},
diff --git a/packages/create-ice/package.json b/packages/create-ice/package.json
index afd24d6..f8d6cf5 100644
--- a/packages/create-ice/package.json
+++ b/packages/create-ice/package.json
@@ -1,6 +1,6 @@
{
"name": "create-ice",
- "version": "1.0.14",
+ "version": "1.0.15",
"description": "npm init ice",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
diff --git a/packages/icejs/package.json b/packages/icejs/package.json
index 58fe2ce..87d5716 100644
--- a/packages/icejs/package.json
+++ b/packages/icejs/package.json
@@ -1,6 +1,6 @@
{
"name": "ice.js",
- "version": "1.0.14",
+ "version": "1.0.15",
"description": "command line interface and builtin plugin for icejs",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
@@ -21,15 +21,15 @@
},
"dependencies": {
"@alib/build-scripts": "^0.1.13",
- "build-plugin-ice-config": "^1.0.14",
- "build-plugin-ice-core": "^1.0.14",
- "build-plugin-ice-helpers": "^1.0.14",
- "build-plugin-ice-logger": "^1.0.14",
- "build-plugin-ice-mpa": "^1.0.14",
- "build-plugin-ice-request": "^1.0.14",
- "build-plugin-ice-router": "^1.0.14",
- "build-plugin-ice-store": "^1.0.14",
- "build-plugin-react-app": "^1.0.14"
+ "build-plugin-ice-config": "1.0.15",
+ "build-plugin-ice-core": "1.0.15",
+ "build-plugin-ice-helpers": "1.0.15",
+ "build-plugin-ice-logger": "1.0.15",
+ "build-plugin-ice-mpa": "1.0.15",
+ "build-plugin-ice-request": "1.0.15",
+ "build-plugin-ice-router": "1.0.15",
+ "build-plugin-ice-store": "1.0.15",
+ "build-plugin-react-app": "1.0.15"
},
"engines": {
"node": ">=8.6.0",
diff --git a/packages/plugin-config/package.json b/packages/plugin-config/package.json
index d1a3901..f80c31b 100644
--- a/packages/plugin-config/package.json
+++ b/packages/plugin-config/package.json
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-config",
- "version": "1.0.14",
+ "version": "1.0.15",
"description": "Define application config in icejs",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
diff --git a/packages/plugin-core/package.json b/packages/plugin-core/package.json
index 8612b0a..246cfa8 100644
--- a/packages/plugin-core/package.json
+++ b/packages/plugin-core/package.json
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-core",
- "version": "1.0.14",
+ "version": "1.0.15",
"description": "the core plugin for icejs.",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
diff --git a/packages/plugin-core/src/index.ts b/packages/plugin-core/src/index.ts
index 73ae12b..4388142 100644
--- a/packages/plugin-core/src/index.ts
+++ b/packages/plugin-core/src/index.ts
@@ -49,7 +49,7 @@ export default (api) => {
const aliasPath = searchFolder
? require.resolve(depName, { paths: [searchFolder]})
: require.resolve(depName);
- config.resolve.alias.set(depName, aliasPath);
+ config.resolve.alias.set(depName, path.dirname(aliasPath));
});
// add babel exclude for node_modules module file
diff --git a/packages/plugin-helpers/package.json b/packages/plugin-helpers/package.json
index 193ee68..7577f65 100644
--- a/packages/plugin-helpers/package.json
+++ b/packages/plugin-helpers/package.json
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-helpers",
- "version": "1.0.14",
+ "version": "1.0.15",
"description": "builtin helpers in icejs",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
diff --git a/packages/plugin-icestark/package.json b/packages/plugin-icestark/package.json
index 83804ae..dd1fc82 100644
--- a/packages/plugin-icestark/package.json
+++ b/packages/plugin-icestark/package.json
@@ -1,6 +1,6 @@
{
"name": "build-plugin-icestark",
- "version": "1.0.14",
+ "version": "1.0.15",
"description": "Easy use `icestark` in icejs.",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
@@ -11,7 +11,8 @@
"test": "__tests__"
},
"files": [
- "lib"
+ "lib",
+ "src/types"
],
"dependencies": {
"@ice/stark": "^1.3.1",
diff --git a/packages/plugin-icestark/src/index.ts b/packages/plugin-icestark/src/index.ts
index b713485..0a81647 100644
--- a/packages/plugin-icestark/src/index.ts
+++ b/packages/plugin-icestark/src/index.ts
@@ -1,10 +1,12 @@
import * as path from 'path';
import * as glob from 'glob';
+import * as fse from 'fs-extra';
import { IPlugin } from '@alib/build-scripts';
-const plugin: IPlugin = ({ onGetWebpackConfig, context }) => {
+const plugin: IPlugin = async ({ onGetWebpackConfig, getValue, applyMethod, context }) => {
const { rootDir } = context;
-
+ const iceTempPath = getValue('ICE_TEMP');
+
const hasDefaultLayout = glob.sync(`${path.join(rootDir, 'src/layouts/index')}.@(ts?(x)|js?(x))`).length;
onGetWebpackConfig((config) => {
// set alias for default layout
@@ -14,6 +16,9 @@ const plugin: IPlugin = ({ onGetWebpackConfig, context }) => {
config.resolve.alias.set(pkgName, require.resolve(pkgName));
});
});
+
+ await fse.copy(path.join(__dirname, '..', 'src/types/index.ts'), path.join(iceTempPath, 'types/icestark.ts'));
+ applyMethod('addIceTypesExport', { source: './types/icestark', specifier: '{ IIceStark }', exportName: 'icestark?: IIceStark' });
};
-export default plugin;
\ No newline at end of file
+export default plugin;
diff --git a/packages/plugin-icestark/src/module.tsx b/packages/plugin-icestark/src/module.tsx
index 84db3ef..752ae44 100644
--- a/packages/plugin-icestark/src/module.tsx
+++ b/packages/plugin-icestark/src/module.tsx
@@ -11,35 +11,13 @@ import {
import { Router } from '$ice/Router';
import DefaultLayout from '$ice/Layout';
import removeRootLayout from './runtime/removeLayout';
-
-interface IAppRouter {
- ErrorComponent?: React.ComponentType;
- LoadingComponent?: React.ComponentType;
- NotFoundComponent?: React.ComponentType;
- shouldAssetsRemove?: (
- assetUrl?: string,
- element?: HTMLElement | HTMLLinkElement | HTMLStyleElement | HTMLScriptElement,
- ) => boolean;
-}
-
-interface IGetApps {
- (): AppConfig[]|Promise;
-}
-
-interface IConfig {
- type: 'framework' | 'child';
- getApps?: IGetApps;
- appRouter?: IAppRouter;
- removeRoutesLayout: boolean;
- AppRoute?: React.ComponentType;
- Layout?: React.ComponentType;
-}
+import { IIceStark } from './types'
const { useEffect, useState } = React;
const module = ({ appConfig, addDOMRender, setRenderRouter, modifyRoutes }) => {
const { icestark, router } = appConfig;
- const { type: appType } = (icestark || {}) as IConfig;
+ const { type: appType } = (icestark || {}) as IIceStark;
const { type, basename, modifyRoutes: runtimeModifyRoutes } = router;
if (runtimeModifyRoutes) {
modifyRoutes(runtimeModifyRoutes);
@@ -70,7 +48,7 @@ const module = ({ appConfig, addDOMRender, setRenderRouter, modifyRoutes }) => {
return ;
});
} else if (appType === 'framework') {
- const { getApps, appRouter, Layout, AppRoute: CustomAppRoute, removeRoutesLayout } = (icestark || {}) as IConfig;
+ const { getApps, appRouter, Layout, AppRoute: CustomAppRoute, removeRoutesLayout } = (icestark || {}) as IIceStark;
if (removeRoutesLayout) {
modifyRoutes(removeRootLayout);
}
@@ -99,11 +77,11 @@ const module = ({ appConfig, addDOMRender, setRenderRouter, modifyRoutes }) => {
function handleRouteChange(pathname) {
setAppPathname(pathname);
}
-
+
function handleAppLeave(config) {
setAppLeave(config);
}
-
+
function handleAppEnter(config) {
setAppEnter(config);
}
@@ -113,7 +91,7 @@ const module = ({ appConfig, addDOMRender, setRenderRouter, modifyRoutes }) => {
appEnter,
appLeave,
};
-
+
return (
{apps && (
diff --git a/packages/plugin-icestark/src/types.ts b/packages/plugin-icestark/src/types.ts
deleted file mode 100644
index e69de29..0000000
diff --git a/packages/plugin-icestark/src/types/index.ts b/packages/plugin-icestark/src/types/index.ts
new file mode 100644
index 0000000..1e28009
--- /dev/null
+++ b/packages/plugin-icestark/src/types/index.ts
@@ -0,0 +1,24 @@
+import { AppConfig } from '@ice/stark';
+
+export interface IAppRouter {
+ ErrorComponent?: React.ComponentType;
+ LoadingComponent?: React.ComponentType;
+ NotFoundComponent?: React.ComponentType;
+ shouldAssetsRemove?: (
+ assetUrl?: string,
+ element?: HTMLElement | HTMLLinkElement | HTMLStyleElement | HTMLScriptElement,
+ ) => boolean;
+}
+
+export interface IGetApps {
+ (): AppConfig[]|Promise;
+}
+
+export interface IIceStark {
+ type: 'framework' | 'child';
+ getApps?: IGetApps;
+ appRouter?: IAppRouter;
+ removeRoutesLayout?: boolean;
+ AppRoute?: React.ComponentType;
+ Layout?: React.ComponentType;
+}
diff --git a/packages/plugin-logger/package.json b/packages/plugin-logger/package.json
index 4a6a74d..bf60b00 100644
--- a/packages/plugin-logger/package.json
+++ b/packages/plugin-logger/package.json
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-logger",
- "version": "1.0.14",
+ "version": "1.0.15",
"description": "builtin logger in icejs",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
diff --git a/packages/plugin-mpa/package.json b/packages/plugin-mpa/package.json
index 449d059..67ee25b 100644
--- a/packages/plugin-mpa/package.json
+++ b/packages/plugin-mpa/package.json
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-mpa",
- "version": "1.0.14",
+ "version": "1.0.15",
"description": "enable mpa project for icejs framework",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
diff --git a/packages/plugin-react-app/package.json b/packages/plugin-react-app/package.json
index bc880d2..e007857 100644
--- a/packages/plugin-react-app/package.json
+++ b/packages/plugin-react-app/package.json
@@ -1,6 +1,6 @@
{
"name": "build-plugin-react-app",
- "version": "1.0.14",
+ "version": "1.0.15",
"description": "The basic webpack configuration for ice project",
"author": "ice-admin@alibaba-inc.com",
"main": "src/index.js",
diff --git a/packages/plugin-rematch/package.json b/packages/plugin-rematch/package.json
index b341ef8..297bc80 100644
--- a/packages/plugin-rematch/package.json
+++ b/packages/plugin-rematch/package.json
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-rematch",
- "version": "1.0.14",
+ "version": "1.0.15",
"description": "Easy use `rematch` in icejs",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
diff --git a/packages/plugin-request/package.json b/packages/plugin-request/package.json
index a6b6e37..095c4fc 100644
--- a/packages/plugin-request/package.json
+++ b/packages/plugin-request/package.json
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-request",
- "version": "1.0.14",
+ "version": "1.0.15",
"description": "request for build-plugin-ice-request",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
diff --git a/packages/plugin-request/request/types.ts b/packages/plugin-request/request/types.ts
index 30a23a9..4bafd48 100644
--- a/packages/plugin-request/request/types.ts
+++ b/packages/plugin-request/request/types.ts
@@ -1,14 +1,20 @@
-import { AxiosRequestConfig } from 'axios'
+import { AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios'
+
+export interface IInterceptorRequest {
+ onConfig?: (config: AxiosRequestConfig) => AxiosRequestConfig;
+ onError?: (error: AxiosError) => {};
+}
+
+export interface IInterceptorResponse {
+ onConfig?: (response: AxiosResponse) => AxiosResponse;
+ onError?: (error: AxiosError) => Promise;
+}
+
+export interface IInterceptors {
+ request?: IInterceptorRequest;
+ response?: IInterceptorResponse;
+}
export interface IRequest extends AxiosRequestConfig {
- interceptors: {
- request: {
- onConfig: (config) => {};
- onError: (error) => {};
- };
- response: {
- onConfig: (response) => {};
- onError: (error) => {};
- };
- };
+ interceptors: IInterceptors;
}
diff --git a/packages/plugin-router/package.json b/packages/plugin-router/package.json
index 7f4e5b5..f70ed0b 100644
--- a/packages/plugin-router/package.json
+++ b/packages/plugin-router/package.json
@@ -1,6 +1,6 @@
{
"name": "build-plugin-ice-router",
- "version": "1.0.14",
+ "version": "1.0.15",
"description": "build-plugin-ice-router",
"author": "ice-admin@alibaba-inc.com",
"homepage": "",
diff --git a/packages/plugin-router/src/index.ts b/packages/plugin-router/src/index.ts
index 9d9bb89..ff47f79 100644
--- a/packages/plugin-router/src/index.ts
+++ b/packages/plugin-router/src/index.ts
@@ -29,8 +29,8 @@ const plugin: IPlugin = ({ context, onGetWebpackConfig, getValue, applyMethod, r
const hasRouteFile = fse.existsSync(routeConfigPath);
// copy types
- fse.copySync(path.join(__dirname, '../src/types/index.ts'), path.join(iceTempPath, 'router/types.ts'));
- applyMethod('addIceTypesExport', { source: './router/types', specifier: '{ IAppRouterProps }', exportName: 'router?: IAppRouterProps' });
+ fse.copySync(path.join(__dirname, '../src/types/index.ts'), path.join(iceTempPath, 'types/router.ts'));
+ applyMethod('addIceTypesExport', { source: './types/router', specifier: '{ IAppRouterProps }', exportName: 'router?: IAppRouterProps' });
// modify webpack config
onGetWebpackConfig((config) => {
diff --git a/packages/plugin-router/src/runtime/Router.tsx b/packages/plugin-router/src/runtime/Router.tsx
index e519ab4..8543b18 100644
--- a/packages/plugin-router/src/runtime/Router.tsx
+++ b/packages/plugin-router/src/runtime/Router.tsx
@@ -26,7 +26,7 @@ function wrapperRoute(component, routerWrappers) {
}
function getRouteComponent(component, routerWrappers?: IRouteWrapper[]) {
- const { __LAZY__, dynamicImport }: IDynamicImportComponent = component;
+ const { __LAZY__, dynamicImport }: IDynamicImportComponent = component || {};
return __LAZY__ ? React.lazy(() => dynamicImport().then((m) => {
if (routerWrappers && routerWrappers.length) {
return { ...m, default: wrapperRoute(m.default, routerWrappers) }
@@ -81,8 +81,8 @@ function Routes({ routes }: RoutesProps) {
/>
);
} else {
- const routeComponent = getRouteComponent(component);
- return ;
+ const RouteComponent = getRouteComponent(component);
+ return ;
}
}
} else {
diff --git a/packages/plugin-router/src/types/index.ts b/packages/plugin-router/src/types/index.ts
index 4b90da7..779db97 100644
--- a/packages/plugin-router/src/types/index.ts
+++ b/packages/plugin-router/src/types/index.ts
@@ -52,6 +52,7 @@ export interface IModifyRoutes {
export interface IAppRouterProps {
type?: 'hash' | 'browser' | 'memory';
+ routes?: RouteItemProps[];
basename?: string;
modifyRoutes?: IModifyRoutes;
fallback?: React.ReactNode;
diff --git a/packages/plugin-store/src/index.ts b/packages/plugin-store/src/index.ts
index a6ee376..ba77015 100644
--- a/packages/plugin-store/src/index.ts
+++ b/packages/plugin-store/src/index.ts
@@ -12,8 +12,8 @@ export default async (api) => {
const pageModelsTemplatePath = path.join(templatePath, 'pageModels.ts.ejs')
const projectType = getValue('PROJECT_TYPE')
- await fse.copy(path.join(__dirname, '..', 'src/types/index.ts'), path.join(targetPath, 'store/types.ts'))
- applyMethod('addIceTypesExport', { source: './store/types', specifier: '{ IStore }', exportName: 'store?: IStore' })
+ await fse.copy(path.join(__dirname, '..', 'src/types/index.ts'), path.join(targetPath, './types/store.ts'))
+ applyMethod('addIceTypesExport', { source: './types/store', specifier: '{ IStore }', exportName: 'store?: IStore' })
onGetWebpackConfig(config => {
config.resolve.alias.set('$ice/appModels', path.join(targetPath, 'appModels.ts'))
diff --git a/scripts/fn/getPackages.ts b/scripts/fn/getPackages.ts
index cc05c26..c026785 100644
--- a/scripts/fn/getPackages.ts
+++ b/scripts/fn/getPackages.ts
@@ -6,8 +6,9 @@ import * as pify from 'pify'
const glob = pify(_glob)
-export default async function getWorkspacePackages() {
- const packages = []
+export default async function getPackages() {
+ const packageNames = []
+ const packageDirs = []
const rootPkgPath = path.join(__dirname, '../../package.json');
const rootPkgContent = fse.readJSONSync(rootPkgPath);
@@ -16,12 +17,13 @@ export default async function getWorkspacePackages() {
for (const dir of dirs) {
if (fse.existsSync(path.resolve(dir, 'package.json'))) {
const pkgContent = fse.readJSONSync(path.resolve(dir, 'package.json'))
- packages.push(pkgContent.name)
+ packageNames.push(pkgContent.name)
+ packageDirs.push(path.resolve(dir))
} else {
console.warn('Invalid workspace package:', dir)
}
}
}
- return packages
+ return { packageNames, packageDirs }
}
diff --git a/scripts/owner.ts b/scripts/owner.ts
index 9cd1f03..08f0ce8 100644
--- a/scripts/owner.ts
+++ b/scripts/owner.ts
@@ -12,11 +12,11 @@ import getPackages from './fn/getPackages';
const args = process.argv;
const action = args[2];
const name = args[3];
- const workspacePackages = await getPackages();
+ const { packageNames } = await getPackages();
- // console.log(`npm owner ${action} ${name} to ${workspacePackages.join(',')}...`);
+ // console.log(`npm owner ${action} ${name} to ${packageNames.join(',')}...`);
- workspacePackages.forEach((npmName) => {
+ packageNames.forEach((npmName) => {
console.log(`\nnpm owner ${action} ${name || ''} ${npmName}: `);
// https://www.npmjs.cn/cli/owner/
const params = action === 'ls' ? ['owner', action, npmName] : ['owner', action, name, npmName];
diff --git a/scripts/publish.ts b/scripts/publish.ts
new file mode 100644
index 0000000..13854ce
--- /dev/null
+++ b/scripts/publish.ts
@@ -0,0 +1,79 @@
+import { join } from 'path'
+import * as execa from 'execa'
+import * as fse from 'fs-extra'
+import { run } from './fn/shell'
+import getPackages from './fn/getPackages'
+
+const chalk = require('chalk')
+const gitP = require('simple-git/promise')
+const lerna = require.resolve('lerna/cli')
+
+async function publish() {
+ log('1. ✔️ ✔️ ✔️ Checking the working tree status...')
+ // const gitStatus = await run('git status --porcelain');
+ const status = await gitP().status()
+ if (status.modified.length) {
+ console.log(chalk.red(' ⚠️ ⚠️ ⚠️ Local file changes are not allowed to publish...\n'))
+ process.exit(0)
+ }
+
+ const { stdout } = execa.commandSync('lerna changed');
+ const needsPublishPackages = stdout.split('\n') || [];
+ if (!needsPublishPackages.length) {
+ console.log(chalk.red(' ⚠️ ⚠️ ⚠️ No packages to publish...\n'))
+ process.exit(0)
+ }
+
+ log('2. 📦 📦 📦 building packages...')
+ await run('npm run build')
+
+ log('3. ⚡ ⚡ ⚡ Update package version automatically...')
+ await run('lerna version --force-publish --exact --no-commit-hooks --no-git-tag-version')
+
+ // Note:
+ // cannot use lerna publish
+ // because lerna publish will not update version
+ log('4. 🚀 🚀 🚀 Start publishing...')
+ const { version: newVersion } = fse.readJsonSync(join(__dirname, '../lerna.json'))
+ const isLatestVersion = (newVersion.includes('rc') || newVersion.includes('alpha') || newVersion.includes('beta')) ? false : true
+ const { packageDirs } = await getPackages()
+ packageDirs.forEach((pkgDir) => {
+ const pkgContent = require(join(pkgDir, 'package.json'))
+ const { name, version } = pkgContent;
+ if (needsPublishPackages.includes(name)) {
+ console.log(`📦 📦 📦 开始发布 ${name}@${version}`)
+ const publishArgs = isLatestVersion ? 'publish' : 'publish --tag=beta'
+ execa.commandSync(`npm ${publishArgs}`, {
+ cwd: pkgDir,
+ stdio: 'inherit'
+ });
+ }
+ });
+
+ log(`5. 🔖 🔖 🔖 Commit${isLatestVersion ? ' & Create tag' : ''}...`)
+ await run(`git commit --all -m v${newVersion}`)
+
+ if (isLatestVersion) {
+ await run(`git tag v${newVersion}`)
+ await run('git push origin master --tags')
+ } else {
+ await run('git push')
+ }
+ log(`\n\n 🎉 🎉 🎉 Published successfully...`)
+
+ log('6. 💡 💡 💡 Start syncing...')
+ await run('npm run sync')
+}
+
+function log(msg) {
+ console.log(chalk.yellow(`\n ${msg} \n`))
+}
+
+(async() => {
+ try {
+ await publish()
+ } catch (error) {
+ console.error(error)
+ process.exit(1)
+ }
+})()
diff --git a/yarn.lock b/yarn.lock
index 9a16b6b..404e531 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -22,6 +22,26 @@
webpack-dev-server "^3.7.2"
yargs-parser "^14.0.0"
+"@alib/build-scripts@^0.1.16":
+ version "0.1.17"
+ resolved "https://registry.npm.taobao.org/@alib/build-scripts/download/@alib/build-scripts-0.1.17.tgz#d38b3abcd10db44e823132447b99c715c6acf22f"
+ integrity sha1-04s6vNENtE6CMTJEe5nHFcas8i8=
+ dependencies:
+ address "^1.1.0"
+ camelcase "^5.3.1"
+ chalk "^2.4.1"
+ commander "^2.19.0"
+ deepmerge "^4.0.0"
+ detect-port "^1.3.0"
+ fs-extra "^8.1.0"
+ jest "^24.9.0"
+ lodash "^4.17.15"
+ npmlog "^4.1.2"
+ react-dev-utils "^9.0.4"
+ webpack "^4.27.1"
+ webpack-dev-server "^3.7.2"
+ yargs-parser "^14.0.0"
+
"@alifd/fusion-collector@^1.2.5":
version "1.2.5"
resolved "https://registry.yarnpkg.com/@alifd/fusion-collector/-/fusion-collector-1.2.5.tgz#7684dde8e7193b0df313671e285f33f26e0eae67"
@@ -1406,10 +1426,10 @@
path-to-regexp "^1.7.0"
url-parse "^1.1.9"
-"@ice/store@^1.0.0":
- version "1.0.0"
- resolved "https://registry.npm.taobao.org/@ice/store/download/@ice/store-1.0.0.tgz#25a7a413efd7b48a2a22c0d723e2e160c527d9a2"
- integrity sha1-JaekE+/XtIoqIsDXI+LhYMUn2aI=
+"@ice/store@^1.1.0":
+ version "1.1.0"
+ resolved "https://registry.npm.taobao.org/@ice/store/download/@ice/store-1.1.0.tgz#23e58ae75cf6d4a164fedddec75f87bb54ecbafc"
+ integrity sha1-I+WK51z21KFk/t3ex1+Hu1Tsuvw=
dependencies:
is-promise "^2.1.0"
lodash.transform "^4.6.0"
@@ -8717,11 +8737,6 @@ markdown-escapes@^1.0.0:
resolved "https://registry.npmjs.org/markdown-escapes/-/markdown-escapes-1.0.3.tgz#6155e10416efaafab665d466ce598216375195f5"
integrity sha512-XUi5HJhhV5R74k8/0H2oCbCiYf/u4cO/rX8tnGkRvrqhsr5BRNU6Mg0yt/8UIx1iIS8220BNJsDb7XnILhLepw==
-markdown-it-task-lists@^2.1.1:
- version "2.1.1"
- resolved "https://registry.npmjs.org/markdown-it-task-lists/-/markdown-it-task-lists-2.1.1.tgz#f68f4d2ac2bad5a2c373ba93081a1a6848417088"
- integrity sha512-TxFAc76Jnhb2OUu+n3yz9RMu4CwGfaT788br6HhEDlvWfdeJcLUsxk1Hgw2yJio0OXsxv7pyIPmvECY7bMbluA==
-
markdown-table@^1.1.0:
version "1.1.3"
resolved "https://registry.npmjs.org/markdown-table/-/markdown-table-1.1.3.tgz#9fcb69bcfdb8717bfd0398c6ec2d93036ef8de60"
@@ -11977,6 +11992,13 @@ signal-exit@^3.0.0, signal-exit@^3.0.2:
resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=
+simple-git@^1.132.0:
+ version "1.132.0"
+ resolved "https://registry.npmjs.org/simple-git/-/simple-git-1.132.0.tgz#53ac4c5ec9e74e37c2fd461e23309f22fcdf09b1"
+ integrity sha512-xauHm1YqCTom1sC9eOjfq3/9RKiUA9iPnxBbrY2DdL8l4ADMu0jjM5l5lphQP5YWNqAL2aXC/OeuQ76vHtW5fg==
+ dependencies:
+ debug "^4.0.1"
+
simple-swizzle@^0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/simple-swizzle/-/simple-swizzle-0.2.2.tgz#a4da6b635ffcccca33f70d17cb92592de95e557a"