Skip to content

Commit b5f4194

Browse files
harrisiirakMichaelLeeHobbssheerlox
authored
Typescript rewrite (#360)
* WIP - Phase 1 of converting to TypeScript is mostly complete * WIP - Phase 1 of converting to TypeScript is mostly complete * WIP - refactored compactField into CronFields. Clean up on other files * WIP: cleanup types * WIP: cleanup types * WIP: refactored findSchedule in to multiple smaller functions * WIP: refactored findSchedule in to multiple smaller functions * WIP: refactored shiftTimezone on to CronDate * WIP: refactored file names. Testing install from github * added prepare script * updated library packaging * updated the default export to match the current library * updated exports for compatible with CommonJS-style require * attempt 2 at cjs combability * attempt 3 at cjs compatability * some clean up * wip - cleaner support for CJS and ESM * wip - looks like we still need the index.cjs.js to support cjs even with the separate builds * wip - added notes, and general cleanup * wip - added note * wip - init jest setup/work * WIP - testing precommit lint * WIP - testing precommit lint * wip - testing pre-commit hook * wip - formatted code * wip - refactoring test... * wip - refactoring test... * wip - refactored CronParser stringify test * wip - Test conversion complete. Overall coverage is at 91%. Lost lots of coverage on CronParser, not sure why yet. Added a lot of FIXME's for things that don't make sense or aren't needed. Phase 2 basically done. Phase 3 will be a code review. * wip - types cleanup * wip - cleanup * wip - simplified code * wip - simplified code * wip - fixes #153 and #299. Adds test for #156 * wip - Adds fix for #156 in the form of toString vs stringify as it'd be very difficult to make stringify work with these expressions * wip - Adds fix for #244 in the form of strict mode which defaults to false * wip - working on a fix for 284 * wip - working on a fix for 284 * wip - fixed 284, major cleanup * wip - 99.5% code coverage and mostly documented * wip - code analysis clean up * wip - add documentation * wip - updated notes * wip - basically done * Done for now * fixed typos * removed tsx * removed npx from scripts calling jest * removed old_typesVersions * update requires node version * Remove .run folder from repository * Remove GPT4 PROMPTS from repository * cleaned up .gitignore * cleaned up .npmignore * cleaned up .eslintrc.cjs * Update src/CronDate.ts Co-authored-by: Harri Siirak <[email protected]> * renamed applyDateOperation and made hoursLength optional * renamed handleMathOp to invokeDateOperation * cleaned up predefined expressions * cleaned up Predefined Expressions * removed pointless defensive code * added types RawCronFields and SerializedCronFields * cleaned up asserts on getRawFields * fixed test * cleaned up parse options * cleaned up handleSingleRange, handleMultipleRanges * commented compactField * changed output dir to dist * cleaned up PredefinedExpressionsEnum * cleaned up assert * removed collect coverage from .js * added prettier as a dev dependencies and added object-curly-spacing to the eslint rules * Renamed enums using PascalCase * removed prettier, having eslint and prettier at the same time was a bad experience. WebStorm won't pick up object-curly-spacing or ij_typescript_spaces_within_imports but running eslint --fix will handle it. Future dev's will just have to configure their IDE's run eslint --fix on save or by hotkey, or manually configure their IDE to insert the spaces * refactored out CronConstants.ts and refactored constraints into the fields classes * disabled failing test that are allowed by current behavior. It's upto @harrisiirak if he wants correct the behavior to be inline with cron specs and which spec or allow a more flexible standard. * fixed comment * Fixed bugs for dual builds which broke the tests. Fixed the tests * refactored casing on enums * removed debug * renamed interfaces and cleaned up some code * freeze instead of cloning to prevent mutation * optimized applyDateOperation * renamed CronFields to CronFieldCollection * removed archive * fixed github build based on suggestion from harrisiirak * this commit is to capture DaysInMonth changes before removing it so we can roll back if we want * refactored out DaysInMonth enum, we had to do silly things to make it work and it was only used in one place * cleaned up enum names * cleaned up unneeded mutation protection * cleaned up tests * cleaned up var naming * clean up old todos * cleaned up unneeded mutation protection * added documentation for strict mode * cleaned up the project, 100% coverage, fixed broken test, replaced spread anti-mutation with Object.freeze * clean up * remove unsupported Node.js versions from the build matrix. * removed notes * removed redundant utc option * cleaned up comments * renamed DayOfTheMonthRange to DayOfMonthRange * renamed DayOfTheWeekRange to DayOfWeekRange * renamed CronFieldTypes to CronFieldType * Update src/wrapper-index.cjs Co-authored-by: Harri Siirak <[email protected]> * removed ESM support and updated documentation * Update src/fields/CronMonth.ts Co-authored-by: Harri Siirak <[email protected]> * Update src/fields/CronMonth.ts Co-authored-by: Harri Siirak <[email protected]> * perf(npm): remove superfluous files from npm package (#328) * perf(npm): remove superfluous files from npm package * test: fix TS tests to point to the right file * Bump package version * Update package-lock.json * Add +x flag to .husky/pre-commit * Update files in package.json * Use CronUnit enum directly where possible * Add parseInt radix * Remove docs from repo * Array index access formatting * Rename CronDayOfTheWeek to CronDayOfWeek * Cleanup CronFields tests * Remove unnecessary assertion * Remove unused code path * Rename test cases * Change assertion * Remove Object.freeze usage * Remove assertions that can create possible performance issues * Upgrade luxon * Update dev deps * Update dev deps * Ingore duplicate enum values * Update import order * Import field classes directly and remove CronFieldCollection module re-exports * Remove duplicate options interface * Simplify CronFieldCollection usage * Remove package.cjs.json * Remove invalid target from ignorePatterns * Change allowJs to false * Update LICENSE * Include Node.js 20 in build workflow * Iterators cleanup. Implement E6 compatible iterator for CronExpression class * Cleanup CronExpression tests * Cleanup CronDate tests * Cleanup CronParser tests * Cleanup CronFields tests * Cleanup CronExpressionParser tests * More tests cleanup * Bump luxon to v3.5.0 * Apply minor performance improvements to findSchedule loop * Optimize unit add/subtract logic in CronDate * Refactor types and decouple CronExpression from CronExpressionParser to avoid any internal circular dependencies * Upgrade eslint deps and config format * Fix index exports and add missing CronExpressionParser export * Add CronFieldCollection.from method to simplify interval fields modifications * Update README.md with relevant changes * Refactor CronParser class and split file parsing related logic into CronFileParser class * Remove applyDateOperation check * Ignore loop guard in coverage report * Update husky usage * Remove unnecessary startOf calls for second add/subtract in CronDate * Add benchmarking tooling * Bump min Node.js version requirement * Add documentation generation and publishing GH Actions workflow * Remove component.json * Add .npmignore * Update tsconfig.json * Add prettier for code linting/formatting * Reformat files * Use test instead it * Update package.json --------- Co-authored-by: Michael Hobbs <[email protected]> Co-authored-by: Pierre Cavin <[email protected]>
1 parent fa94e7f commit b5f4194

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+11138
-13862
lines changed

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# .editorconfig
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
max_line_length = 120
8+
9+
[*.{js,ts}]
10+
ij_typescript_spaces_within_imports = true

.eslintrc.json

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/workflows/documentation.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
jobs:
14+
documentation:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: '>=22'
25+
cache: 'npm'
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Generate documentation
31+
run: npm run docs
32+
33+
- name: Setup Pages
34+
uses: actions/configure-pages@v4
35+
36+
- name: Upload artifact
37+
uses: actions/upload-pages-artifact@v3
38+
with:
39+
path: 'docs'
40+
41+
- name: Deploy to GitHub Pages
42+
id: deployment
43+
uses: actions/deploy-pages@v4

.github/workflows/push.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@ name: Build
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master]
88

99
jobs:
1010
build:
11-
1211
runs-on: ubuntu-latest
1312

1413
strategy:
1514
matrix:
16-
node-version: [12.x, 14.x, 15.x, 16.x, 17.x, 18.x, 19.x]
15+
node-version: [18.x, 19.x, 20.x, 21.x, 22.x, 23.x]
1716

1817
steps:
19-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
2019
- name: Use Node.js ${{ matrix.node-version }}
21-
uses: actions/setup-node@v3
20+
uses: actions/setup-node@v4
2221
with:
2322
node-version: ${{ matrix.node-version }}
2423
- run: npm ci
24+
- run: npm run build
2525
- run: npm test

.gitignore

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
node_modules/
1+
node_modules
22
lib-cov
33
coverage
44
*.seed
@@ -12,10 +12,18 @@ coverage
1212
pids
1313
logs
1414
results
15+
dist
16+
testing
17+
docs
1518

16-
npm-debug.log
17-
19+
.run
1820
.idea
1921
.history
2022
.vscode
2123
.nyc_output
24+
yarn.lock
25+
26+
benchmarks/versions/
27+
benchmarks/results/
28+
29+
!coverage/*.svg

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm run precommit

.npmignore

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Source
2+
src/
3+
*.ts
4+
!*.d.ts
5+
6+
# Tests
7+
tests/
8+
coverage/
9+
.nyc_output/
10+
11+
# Benchmarks
12+
benchmarks/
13+
14+
# Development configs
15+
.editorconfig
16+
.eslintrc*
17+
.prettierrc*
18+
.github/
19+
.vscode/
20+
.idea/
21+
.history/
22+
tsconfig.json
23+
jest.config.js
24+
eslint.config.js
25+
26+
# Documentation
27+
docs/
28+
29+
# Misc
30+
.DS_Store
31+
*.log
32+
33+
# Keep dist folder
34+
!dist/
35+
!dist/**/*.js
36+
!dist/**/*.d.ts

.prettierrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"singleQuote": true,
3+
"semi": true,
4+
"tabWidth": 2,
5+
"printWidth": 120,
6+
"trailingComma": "all",
7+
"bracketSpacing": true
8+
}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2014-2016 Harri Siirak
3+
Copyright (c) 2014-2023 Harri Siirak
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)