Skip to content

Commit

Permalink
feat: monorepo采用pnpm方案 (#109)
Browse files Browse the repository at this point in the history
* chore: 修改打包脚本

* fix: puppeteer test in windows (#108)

* chore: 修改脚本

close #10 

Co-authored-by: lyonbot <lyonbot@outlook.com>
  • Loading branch information
yiludege and lyonbot authored Aug 30, 2022
1 parent d7fdbfb commit 34d460d
Show file tree
Hide file tree
Showing 16 changed files with 28,966 additions and 36 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ jobs:

- name: install
run: |
npm install lerna -g
lerna bootstrap --ignore main-react --ignore main-vue --ignore react16 --ignore react17 --ignore vite --ignore vue2 --ignore vue3 --ignore angular12 --ignore wujie-doc --no-ci
npm install -g pnpm
pnpm i --filter "wujie-project" --filter "./packages/**"
- name: publish to npm
run: |
lerna run prepack
lerna publish from-package --no-verify-access --ignore-scripts -y
../node_modules/.bin/lerna run prepack
../node_modules/.bin/lerna publish from-package --no-verify-access --ignore-scripts -y
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lerna run --scope wujie lint
./node_modules/.bin/lerna run --scope wujie lint
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,6 @@ import WujieReact from "wujie-react";
运行以下脚本,可以本地开发无界微前端框架,支持实时编译调试开发。

```bash
npm i // 安装包依赖
pnpm i // 安装包依赖,务必使用pnpm
npm run start // 启动所有应用
```
1 change: 1 addition & 0 deletions examples/main-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0-rc.12",
"private": true,
"dependencies": {
"@ant-design/icons": "^4.7.0",
"@babel/core": "^7.16.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.3",
"@svgr/webpack": "^5.5.0",
Expand Down
4 changes: 0 additions & 4 deletions examples/main-react/src/pages/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ import Switch from "antd/es/switch";
import Tooltip from "antd/es/tooltip";
import Button from "antd/es/button";
import { UnorderedListOutlined } from "@ant-design/icons";
import PropTypes from "prop-types";

export default class Home extends React.Component {
static propTypes = {
changeActive: PropTypes.func,
};
state = {
checkState: window.localStorage.getItem("preload") !== "false",
disable: !window.Proxy || !window.CustomElementRegistry,
Expand Down
2 changes: 1 addition & 1 deletion examples/react16/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"babel-jest": "^27.4.2",
"babel-loader": "^8.2.3",
"babel-plugin-named-asset-import": "^0.3.8",
"babel-preset-react-app": "^10.0.1",
"babel-preset-react-app": "^7.0.2",
"bfj": "^7.0.2",
"browserslist": "^4.18.1",
"camelcase": "^6.2.1",
Expand Down
11 changes: 5 additions & 6 deletions examples/react17/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"@babel/core": "7.12.3",
"@pmmmwh/react-refresh-webpack-plugin": "0.4.3",
"@svgr/webpack": "5.5.0",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@typescript-eslint/eslint-plugin": "^4.5.0",
"@typescript-eslint/parser": "^4.5.0",
"antd": "^4.18.3",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.0",
"babel-jest": "^27.4.2",
"babel-loader": "8.1.0",
"babel-plugin-named-asset-import": "^0.3.7",
"babel-preset-react-app": "^10.0.0",
Expand All @@ -37,10 +37,9 @@
"fs-extra": "^9.0.1",
"html-webpack-plugin": "4.5.0",
"identity-obj-proxy": "3.0.0",
"jest": "26.6.0",
"jest-circus": "26.6.0",
"jest-resolve": "26.6.0",
"jest-watch-typeahead": "0.6.1",
"jest": "^27.4.3",
"jest-resolve": "^27.4.2",
"jest-watch-typeahead": "^1.0.0",
"mini-css-extract-plugin": "0.11.3",
"optimize-css-assets-webpack-plugin": "5.0.4",
"pnp-webpack-plugin": "1.6.4",
Expand Down
1 change: 1 addition & 0 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"examples/*",
"docs"
],
"npmClient": "pnpm",
"command": {
"version": {
"allowBranch": "master"
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"scripts": {
"start": "lerna run start --parallel",
"doc": "lerna run docs:dev",
"postinstall": "lerna bootstrap",
"clean": "rimraf node_modules **/*/node_modules",
"test": "lerna run test --scope wujie",
"commitlint": "commitlint -E COMMIT_EDITMSG_PATH",
Expand All @@ -22,8 +21,9 @@
"devDependencies": {
"@commitlint/cli": "^16.2.3",
"@commitlint/config-conventional": "^16.2.1",
"@lerna-lite/cli": "^1.11.1",
"@lerna-lite/run": "^1.11.1",
"husky": "^7.0.4",
"lerna": "^5.4.3",
"lint-staged": "^12.4.1",
"rimraf": "^3.0.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/wujie-core/__test__/integration/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ module.exports = {
// setupFiles: [],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
setupFilesAfterEnv: ['expect-puppeteer'],
setupFilesAfterEnv: [],

// The number of seconds after which a test is considered as slow and reported as such in the results.
// slowTestThreshold: 5,
Expand Down
2 changes: 1 addition & 1 deletion packages/wujie-core/__test__/integration/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"downlevelIteration": true,
"experimentalDecorators": true,
"declaration": true,
"types": ["puppeteer", "jest-environment-puppeteer", "expect-puppeteer"]
"types": ["puppeteer", "jest-environment-puppeteer", "jest"]
}
}
5 changes: 2 additions & 3 deletions packages/wujie-core/__test__/integration/utils.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Page } from "puppeteer";

const fs = require("fs");
const path = require("path");
const http = require("http");

let server = null;
type Page = typeof page;

export function initEnv() {
server = http.createServer((_req, res) => {
res.writeHead(200, { "Content-Type": "text/html" });
Expand Down
19 changes: 11 additions & 8 deletions packages/wujie-core/jest-puppeteer.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
const { resolve } = require("path");
const LERNA_EXEC = resolve(__dirname, "../../node_modules/.bin/lerna");

module.exports = {
launch: {
headless: true,
Expand All @@ -6,56 +9,56 @@ module.exports = {
},
server: [
{
command: "lerna run start --scope react16",
command: LERNA_EXEC + " run start --scope react16",
usedPortAction: "kill",
launchTimeout: 60000,
host: "0.0.0.0",
port: 7600,
},
{
command: "lerna run start --scope react17",
command: LERNA_EXEC + " run start --scope react17",
usedPortAction: "kill",
launchTimeout: 60000,
host: "0.0.0.0",
port: 7100,
},
{
command: "lerna run start --scope vue2",
command: LERNA_EXEC + " run start --scope vue2",
usedPortAction: "kill",
launchTimeout: 60000,
host: "0.0.0.0",
port: 7200,
},
{
command: "lerna run start --scope vue3",
command: LERNA_EXEC + " run start --scope vue3",
usedPortAction: "kill",
launchTimeout: 60000,
host: "0.0.0.0",
port: 7300,
},
{
command: "lerna run start --scope vite",
command: LERNA_EXEC + " run start --scope vite",
usedPortAction: "kill",
launchTimeout: 60000,
host: "0.0.0.0",
port: 7500,
},
{
command: "lerna run start --scope angular12",
command: LERNA_EXEC + " run start --scope angular12",
usedPortAction: "kill",
launchTimeout: 60000,
host: "0.0.0.0",
port: 7400,
},
{
command: "lerna run integration --scope main-react",
command: LERNA_EXEC + " run integration --scope main-react",
usedPortAction: "kill",
launchTimeout: 60000,
host: "0.0.0.0",
port: 7700,
},
{
command: "lerna run start --scope main-vue",
command: LERNA_EXEC + " run start --scope main-vue",
usedPortAction: "kill",
launchTimeout: 60000,
host: "0.0.0.0",
Expand Down
5 changes: 1 addition & 4 deletions packages/wujie-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"@babel/plugin-transform-runtime": "^7.18.6",
"@babel/preset-env": "^7.14.7",
"@babel/preset-typescript": "^7.18.6",
"@types/expect-puppeteer": "^4.4.7",
"@types/jest": "^27.0.3",
"@types/jest-environment-puppeteer": "^5.0.2",
"@types/puppeteer": "^5.4.6",
Expand All @@ -52,12 +51,10 @@
"eslint-plugin-promise": "^5.1.0",
"jest": "^27.3.1",
"jest-puppeteer": "^6.1.0",
"lerna": "^4.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.6.2",
"puppeteer": "^14.2.1",
"sass-loader": "^12.1.0",
"ts-jest": "^27.0.7",
"ts-jest": "^27.1.4",
"typescript": "^4.4.2",
"webpack": "^5.42.0",
"webpack-cli": "^4.8.0"
Expand Down
Loading

0 comments on commit 34d460d

Please sign in to comment.