-
Notifications
You must be signed in to change notification settings - Fork 16
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: check update with first lc run #41
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
235ad61
docs: add contributors markdown
wh131462 c0f7c6f
ci(release): modify ci to release when tag add and change the release…
wh131462 18fb00d
Merge branch 'master' into dev
wh131462 a58833e
feat(update): check update when first run lc and will be not allow un…
wh131462 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// 以毫秒计算的时间单位 | ||
export const Second = 1000 | ||
export const Minute = 60 * Second | ||
export const Hour = 60 * Minute | ||
export const Day = 24 * Hour | ||
export const Week = 7 * Day | ||
export const Year = 365 * Day |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* npm 的安装指令 | ||
* @param packageName | ||
* @param isUpdate | ||
* @param isGlobal | ||
* @returns {`npm ${string} ${string} ${string}`} | ||
* @constructor | ||
*/ | ||
export function NpmInstall(packageName, isUpdate, isGlobal) { | ||
return `npm ${isUpdate ? 'update' : 'install'} ${isGlobal ? '-g' : ''} ${packageName}` | ||
} | ||
|
||
/** | ||
* yarn 的安装指令 | ||
* @param packageName | ||
* @param isUpdate | ||
* @param isGlobal | ||
* @returns {`yarn ${string} ${string} ${string}`} | ||
* @constructor | ||
*/ | ||
export function YarnInstall(packageName, isUpdate, isGlobal) { | ||
return `yarn ${isGlobal ? 'global' : ''} ${isUpdate ? 'upgrade' : 'add'} ${packageName}` | ||
} | ||
|
||
/** | ||
* pnpm 的安装指令 | ||
* @param packageName | ||
* @param isUpdate | ||
* @param isGlobal | ||
* @returns {`pnpm ${string} ${string} ${string}`} | ||
* @constructor | ||
*/ | ||
export function PnpmInstall(packageName, isUpdate, isGlobal) { | ||
return `pnpm ${isGlobal ? 'global' : ''} ${isUpdate ? 'update' : 'install'} ${packageName}` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { logger } from '#common/utils/logger/logger.js' | ||
import { checkUpdate } from '#common/utils/update/update.js' | ||
import { getStore, setStore } from '#common/utils/store/controller/store.js' | ||
import { Day } from '#common/constants/date.const.js' | ||
import { | ||
NpmInstall, | ||
PnpmInstall, | ||
YarnInstall | ||
} from '#common/constants/manager.const.js' | ||
import { PackageName } from '#common/constants/question.const.js' | ||
|
||
const { timestamp, hasShow } = (await getStore('checkResult')) ?? {} | ||
if (Date.now() - timestamp <= Day || hasShow) process.exit(0) | ||
|
||
const { localVersion, remoteVersion, isCliUpdate } = await checkUpdate() | ||
const needShow = false | ||
if (isCliUpdate) { | ||
const installInfo = [NpmInstall, YarnInstall, PnpmInstall] | ||
.map((fun) => fun(PackageName, true, true)) // 暂时先默认为全局 | ||
.join('\n') | ||
logger.warn( | ||
`[leetcode-practice] 检测到新版本[ ${remoteVersion} ]已经发布! 您当前的版本为[ ${localVersion} ]! 您可以执行对应的指令进行手动更新~` | ||
) | ||
logger.info(`${installInfo}`) | ||
} | ||
await setStore('checkResult', { timestamp: Date.now(), hasShow: needShow }) | ||
process.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这不是永远都是true