update
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
declare const x: typeof Reflect.getPrototypeOf | null;
|
||||
|
||||
export = x;
|
||||
@@ -0,0 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
/** @type {import('.')} */
|
||||
module.exports = Error;
|
||||
@@ -0,0 +1,40 @@
|
||||
import semver from 'semver';
|
||||
import { createConfigDir, getLastUpdate, saveLastUpdate } from './cache';
|
||||
import getDistVersion from './getDistVersion';
|
||||
import { IUpdate } from './types';
|
||||
|
||||
const hasNewVersion = async ({
|
||||
pkg,
|
||||
updateCheckInterval = 1000 * 60 * 60 * 24,
|
||||
distTag = 'latest',
|
||||
alwaysRun,
|
||||
debug,
|
||||
}: IUpdate) => {
|
||||
createConfigDir();
|
||||
const lastUpdateCheck = getLastUpdate(pkg.name);
|
||||
if (
|
||||
alwaysRun ||
|
||||
!lastUpdateCheck ||
|
||||
lastUpdateCheck < new Date().getTime() - updateCheckInterval
|
||||
) {
|
||||
const latestVersion = await getDistVersion(pkg.name, distTag);
|
||||
saveLastUpdate(pkg.name);
|
||||
if (semver.gt(latestVersion, pkg.version)) {
|
||||
return latestVersion;
|
||||
} else if (debug) {
|
||||
console.error(
|
||||
`Latest version (${latestVersion}) not newer than current version (${pkg.version})`
|
||||
);
|
||||
}
|
||||
} else if (debug) {
|
||||
console.error(
|
||||
`Too recent to check for a new update. simpleUpdateNotifier() interval set to ${updateCheckInterval}ms but only ${
|
||||
new Date().getTime() - lastUpdateCheck
|
||||
}ms since last check.`
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
export default hasNewVersion;
|
||||
@@ -0,0 +1,28 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [v1.0.2](https://github.com/ljharb/side-channel-weakmap/compare/v1.0.1...v1.0.2) - 2024-12-10
|
||||
|
||||
### Commits
|
||||
|
||||
- [types] fix generics ordering [`1b62e94`](https://github.com/ljharb/side-channel-weakmap/commit/1b62e94a2ad6ed30b640ba73c4a2535836c67289)
|
||||
|
||||
## [v1.0.1](https://github.com/ljharb/side-channel-weakmap/compare/v1.0.0...v1.0.1) - 2024-12-10
|
||||
|
||||
### Commits
|
||||
|
||||
- [types] fix generics ordering [`08a4a5d`](https://github.com/ljharb/side-channel-weakmap/commit/08a4a5dbffedc3ebc79f1aaaf5a3dd6d2196dc1b)
|
||||
- [Deps] update `side-channel-map` [`b53fe44`](https://github.com/ljharb/side-channel-weakmap/commit/b53fe447dfdd3a9aebedfd015b384eac17fce916)
|
||||
|
||||
## v1.0.0 - 2024-12-10
|
||||
|
||||
### Commits
|
||||
|
||||
- Initial implementation, tests, readme, types [`53c0fa4`](https://github.com/ljharb/side-channel-weakmap/commit/53c0fa4788435a006f58b9d7b43cb65989ecee49)
|
||||
- Initial commit [`a157947`](https://github.com/ljharb/side-channel-weakmap/commit/a157947f26fcaf2c4a941d3a044e76bf67343532)
|
||||
- npm init [`54dfc55`](https://github.com/ljharb/side-channel-weakmap/commit/54dfc55bafb16265910d5aad4e743c43aee5bbbb)
|
||||
- Only apps should have lockfiles [`0ddd6c7`](https://github.com/ljharb/side-channel-weakmap/commit/0ddd6c7b07fe8ee04d67b2e9f7255af7ce62c07d)
|
||||
Reference in New Issue
Block a user