From 6ad3ba58d855875130272e5cb79334243cfcd31c Mon Sep 17 00:00:00 2001 From: xiaohuoni Date: Wed, 8 Jan 2025 15:31:27 +0800 Subject: [PATCH 1/2] feat: auto open url --- packages/alita/package.json | 9 +++++---- packages/alita/src/features/config/alitaconfig.ts | 13 +++++++++++++ pnpm-lock.yaml | 15 +++++++++++---- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/packages/alita/package.json b/packages/alita/package.json index a3a955415..9ad8c6fd3 100644 --- a/packages/alita/package.json +++ b/packages/alita/package.json @@ -43,15 +43,16 @@ "alita": "bin/alita.js" }, "dependencies": { - "@alita/types": "3.1.2", "@alita/native": "3.4.3", - "@alita/plugins": "3.5.5", "@alita/plugin-azure": "3.2.3", - "@umijs/core": "4.3.30", - "@umijs/bundler-webpack": "4.3.30", + "@alita/plugins": "3.5.5", + "@alita/types": "3.1.2", "@umijs/babel-preset-umi": "4.3.30", + "@umijs/bundler-webpack": "4.3.30", + "@umijs/core": "4.3.30", "@umijs/preset-umi": "4.3.30", "@umijs/utils": "4.3.30", + "open": "8.4.0", "umi": "4.3.30" } } diff --git a/packages/alita/src/features/config/alitaconfig.ts b/packages/alita/src/features/config/alitaconfig.ts index c9375d23c..1413dfd02 100644 --- a/packages/alita/src/features/config/alitaconfig.ts +++ b/packages/alita/src/features/config/alitaconfig.ts @@ -102,4 +102,17 @@ export default (api: IApi) => { }, ]); } + + // auto open url + api.onDevCompileDone(async ({ isFirstCompile, ws }) => { + const timer = setTimeout(async () => { + if (isFirstCompile) { + const open = require('open'); + await open(`http://localhost:${process.env.PORT}`); + } + }, 2000); + ws?.wss.on('connection', async () => { + clearTimeout(timer); + }); + }); }; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 55cbf7a04..7dbd445c1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -218,6 +218,9 @@ importers: antd-mobile: specifier: ^5.10.0 version: 5.31.1(react-dom@17.0.2)(react@17.0.2) + open: + specifier: 8.4.0 + version: 8.4.0 examples/extends-app: dependencies: @@ -544,6 +547,9 @@ importers: '@umijs/utils': specifier: 4.3.30 version: 4.3.30 + open: + specifier: 8.4.0 + version: 8.4.0 umi: specifier: 4.3.30 version: 4.3.30(@babel/core@7.23.6)(@types/node@17.0.45)(@types/react@18.2.14)(eslint@8.35.0)(jest@27.5.1)(prettier@2.8.8)(react-dom@17.0.2)(react@17.0.2)(stylelint@14.8.2)(typescript@4.9.5)(webpack@5.90.3) @@ -8732,6 +8738,7 @@ packages: /acorn-import-assertions@1.9.0(acorn@8.9.0): resolution: {integrity: sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==} + deprecated: package has been renamed to acorn-import-attributes peerDependencies: acorn: ^8 dependencies: @@ -10748,7 +10755,7 @@ packages: npm: 9.7.2 npm-request: 1.0.0 npminstall: 7.9.0 - open: 8.4.2 + open: 8.4.0 urllib: 3.17.1 transitivePeerDependencies: - bluebird @@ -17418,8 +17425,8 @@ packages: is-wsl: 2.2.0 dev: true - /open@8.4.2: - resolution: {integrity: sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==} + /open@8.4.0: + resolution: {integrity: sha512-XgFPPM+B28FtCCgSb9I+s9szOC1vZRSwgWsRUA5ylIxRTgKozqjOCrVOqGsYABPYK5qnfqClxZTFBa8PKt2v6Q==} engines: {node: '>=12'} dependencies: define-lazy-prop: 2.0.0 @@ -21265,7 +21272,7 @@ packages: rollup: optional: true dependencies: - open: 8.4.2 + open: 8.4.0 picomatch: 2.3.1 source-map: 0.7.4 yargs: 17.7.2 From 55bef5f61c44ce725a0849a4927474ba8775a92c Mon Sep 17 00:00:00 2001 From: xiaohuoni Date: Wed, 8 Jan 2025 15:32:42 +0800 Subject: [PATCH 2/2] chore: changeset --- .changeset/plenty-spies-dream.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/plenty-spies-dream.md diff --git a/.changeset/plenty-spies-dream.md b/.changeset/plenty-spies-dream.md new file mode 100644 index 000000000..ce4cb19a5 --- /dev/null +++ b/.changeset/plenty-spies-dream.md @@ -0,0 +1,5 @@ +--- +'alita': patch +--- + +feat: auto open url