Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Notify Umi3 update to Umi4 #8434

Merged
merged 1 commit into from Jul 11, 2022
Merged

feat: Notify Umi3 update to Umi4 #8434

merged 1 commit into from Jul 11, 2022

Conversation

zzcan
Copy link
Contributor

@zzcan zzcan commented Jul 6, 2022

resolve #8400

@fz6m
Copy link
Member

fz6m commented Jul 6, 2022

你可以在描述内容里加入 resolve #8400 ,在 PR 合入时同步关闭 issue

@sorrycc
Copy link
Member

sorrycc commented Jul 7, 2022

运行效果截个图看下。

@zzcan
Copy link
Contributor Author

zzcan commented Jul 8, 2022

运行效果截个图看下。
build

image

@sorrycc sorrycc merged commit 43a7f3c into umijs:3.x Jul 11, 2022
@@ -0,0 +1 @@
(()=>{"use strict";var e={733:e=>{const lazy=(e,t,s)=>e===undefined?t(s):e;e.exports=e=>t=>{let s;return function(){if(arguments.length===0){s=lazy(s,e,t);return s}const r={};[].forEach.call(arguments,(n=>{Object.defineProperty(r,n,{get:()=>{s=lazy(s,e,t);if(typeof s[n]==="function"){return function(){return s[n].apply(s,arguments)}}return s[n]}})}));return r}};e.exports.proxy=e=>t=>{let s;const r={get:(r,n)=>{s=lazy(s,e,t);return Reflect.get(s,n)},apply:(r,n,a)=>{s=lazy(s,e,t);return Reflect.apply(s,n,a)}};return new Proxy((()=>{}),r)}},811:(e,t,s)=>{const{spawn:r}=s(129);const n=s(622);const{format:a}=s(669);const i=s(733)(require);const o=i("configstore");const c=i("chalk");const p=i("semver");const u=i("semver-diff");const l=i("latest-version");const d=i("is-npm");const h=i("is-installed-globally");const g=i("is-yarn-global");const f=i("has-yarn");const k=i("boxen");const m=i("xdg-basedir");const y=i("is-ci");const _=i("pupa");const N=1e3*60*60*24;class UpdateNotifier{constructor(e={}){this.options=e;e.pkg=e.pkg||{};e.distTag=e.distTag||"latest";e.pkg={name:e.pkg.name||e.packageName,version:e.pkg.version||e.packageVersion};if(!e.pkg.name||!e.pkg.version){throw new Error("pkg.name and pkg.version required")}this.packageName=e.pkg.name;this.packageVersion=e.pkg.version;this.updateCheckInterval=typeof e.updateCheckInterval==="number"?e.updateCheckInterval:N;this.disabled="NO_UPDATE_NOTIFIER"in process.env||process.env.NODE_ENV==="test"||process.argv.includes("--no-update-notifier")||y();this.shouldNotifyInNpmScript=e.shouldNotifyInNpmScript;if(!this.disabled){try{const e=o();this.config=new e(`update-notifier-${this.packageName}`,{optOut:false,lastUpdateCheck:Date.now()})}catch{const t=c().yellow(a(" %s update check failed ",e.pkg.name))+a("\n Try running with %s or get access ",c().cyan("sudo"))+"\n to the local update config store via \n"+c().cyan(a(" sudo chown -R $USER:$(id -gn $USER) %s ",m().config));process.on("exit",(()=>{console.error(k()(t,{align:"center"}))}))}}}check(){if(!this.config||this.config.get("optOut")||this.disabled){return}this.update=this.config.get("update");if(this.update){this.update.current=this.packageVersion;this.config.delete("update")}if(Date.now()-this.config.get("lastUpdateCheck")<this.updateCheckInterval){return}r(process.execPath,[s.ab+"check.js",JSON.stringify(this.options)],{detached:true,stdio:"ignore"}).unref()}async fetchInfo(){const{distTag:e}=this.options;const t=await l()(this.packageName,{version:e});return{latest:t,current:this.packageVersion,type:u()(this.packageVersion,t)||e,name:this.packageName}}notify(e){const t=!this.shouldNotifyInNpmScript&&d().isNpmOrYarn;if(!process.stdout.isTTY||t||!this.update||!p().gt(this.update.latest,this.update.current)){return this}e={isGlobal:h(),isYarnGlobal:g()(),...e};let s;if(e.isYarnGlobal){s=`yarn global add ${this.packageName}`}else if(e.isGlobal){s=`npm i -g ${this.packageName}`}else if(f()()){s=`yarn add ${this.packageName}`}else{s=`npm i ${this.packageName}`}const r="Update available "+c().dim("{currentVersion}")+c().reset(" → ")+c().green("{latestVersion}")+" \nRun "+c().cyan("{updateCommand}")+" to update";const n=e.message||r;e.boxenOptions=e.boxenOptions||{padding:1,margin:1,align:"center",borderColor:"yellow",borderStyle:"round"};const a=k()(_()(n,{packageName:this.packageName,currentVersion:this.update.current,latestVersion:this.update.latest,updateCommand:s}),e.boxenOptions);if(e.defer===false){console.error(a)}else{process.on("exit",(()=>{console.error(a)}));process.on("SIGINT",(()=>{console.error("");process.exit()}))}return this}}e.exports=e=>{const t=new UpdateNotifier(e);t.check();return t};e.exports.UpdateNotifier=UpdateNotifier},129:e=>{e.exports=require("child_process")},622:e=>{e.exports=require("path")},669:e=>{e.exports=require("util")}};var t={};function __nccwpck_require__(s){var r=t[s];if(r!==undefined){return r.exports}var n=t[s]={exports:{}};var a=true;try{e[s](n,n.exports,__nccwpck_require__);a=false}finally{if(a)delete t[s]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var s=__nccwpck_require__(811);module.exports=s})();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const o=i("configstore");const c=i("chalk");const p=i("semver");const u=i("semver-diff");const l=i("latest-version");const d=i("is-npm");const h=i("is-installed-globally");const g=i("is-yarn-global");const f=i("has-yarn");const k=i("boxen");const m=i("xdg-basedir");const y=i("is-ci");const _=i("pupa");

@zzcan 这个预打包产物有问题,依赖没打进去,Umi 项目 CI 能过是因为幽灵依赖,刚发了个测试版可以验一下:3.5.29-alpha.0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const o=i("configstore");const c=i("chalk");const p=i("semver");const u=i("semver-diff");const l=i("latest-version");const d=i("is-npm");const h=i("is-installed-globally");const g=i("is-yarn-global");const f=i("has-yarn");const k=i("boxen");const m=i("xdg-basedir");const y=i("is-ci");const _=i("pupa");

@zzcan 这个预打包产物有问题,依赖没打进去,Umi 项目 CI 能过是因为幽灵依赖,刚发了个测试版可以验一下:3.5.29-alpha.0

去掉了update-notifier预打包 #8527

sorrycc added a commit that referenced this pull request Jul 14, 2022
sorrycc added a commit that referenced this pull request Jul 14, 2022
@zzcan zzcan deleted the 3.x branch July 14, 2022 06:17
@zzcan zzcan restored the 3.x branch July 14, 2022 06:20
@zzcan zzcan deleted the 3.x branch July 14, 2022 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants