
Research
/Security News
npm Author Qix Compromised via Phishing Email in Major Supply Chain Attack
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
@date-fns/upgrade-codemod
Advanced tools
npx @date-fns/upgrade-codemod <path> [...options]
path
files or directory to transform--dry
option for a dry-run--print
option to print the output for comparisonnpx @date-fns/upgrade-codemod src/
N.B. At the moment this codemod applies fixes ONLY for first 3 points of
2.0 date-fns CHANGELOG
You'll have to take care of all the other breaking changes.
Codemod imports required tools from @date-fns/upgrade
(you will have to add it as dependency in your project if required) and wraps
date-fns
function call arguments accordingly.
+import { legacyParse, legacyParseMap, convertTokens } from '@date-fns/upgrade/v2'
const dateIs = '2019-07-01'
const someToken = 'MM-DD';
-const format = importedFormat('2019-07-01', someToken)
-const closestIndex = closestToIndex(new Date(2015, 8, 6), [
- new Date(2015, 0, 1),
- new Date(2016, 0, 1),
- new Date(2017, 0, 1)
-])
-const addSecondsPlease = addSeconds(dateIs, 999)
-const isoDay = getThatDay(new Date())
+const format = importedFormat(
+ legacyParse('2019-07-01'),
+ convertTokens(someToken)
+)
+const closestIndex = closestToIndex(
+ legacyParse(new Date(2015, 8, 6)),
+ legacyParseMap([
+ new Date(2015, 0, 1),
+ new Date(2016, 0, 1),
+ new Date(2017, 0, 1)
+ ])
+)
+const addSecondsPlease = addSeconds(legacyParse(dateIs), 999)
+const isoDay = getThatDay(legacyParse(new Date()))
Codemod also changes import locations
import * as importedFormat from 'date-fns/format'
-import closestToIndex from 'date-fns/closest_to_index'
-import addSeconds from 'date-fns/add_seconds'
-import getThatDay from 'date-fns/get_iso_day'
+import closestToIndex from 'date-fns/closestToIndex'
+import addSeconds from 'date-fns/addSeconds'
+import getThatDay from 'date-fns/getISODay'
FAQs
date-fns codemod 1.x -> 2.0
The npm package @date-fns/upgrade-codemod receives a total of 0 weekly downloads. As such, @date-fns/upgrade-codemod popularity was classified as not popular.
We found that @date-fns/upgrade-codemod demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.