From 81628794edd8f3117ba8f1ba016aad76f593f509 Mon Sep 17 00:00:00 2001 From: Marco Roth Date: Fri, 30 Sep 2022 05:38:38 +0200 Subject: [PATCH] Migrate codebase to modern JavaScript --- .blade.yml | 40 - .github/workflows/tests.yml | 31 + .travis.yml | 8 - CHANGELOG.md | 4 + MIT-LICENSE | 6 +- README.md | 28 +- app/assets/javascripts/local-time.js | 616 ++- app/assets/javascripts/local-time.umd.js | 623 +++ bin/blade | 17 - .../src/local-time/calendar_date.coffee | 37 - .../src/local-time/config/i18n.coffee | 74 - .../src/local-time/config/locale.coffee | 2 - .../src/local-time/config/timer.coffee | 1 - .../src/local-time/controller.coffee | 63 - .../src/local-time/helpers/date_parse.coffee | 15 - .../src/local-time/helpers/dom.coffee | 11 - .../src/local-time/helpers/i18n.coffee | 24 - .../src/local-time/helpers/strftime.coffee | 57 - .../javascripts/src/local-time/index.coffee | 20 - .../src/local-time/page_observer.coffee | 43 - .../src/local-time/relative_time.coffee | 72 - .../javascripts/src/local-time/start.coffee | 25 - package.json | 43 +- playground/index.html | 36 + playground/index.js | 5 + playground/package.json | 20 + playground/vite.config.js | 9 + playground/yarn.lock | 219 + rollup.config.js | 43 + src/calendar_date.js | 51 + src/config/i18n.js | 84 + src/config/index.js | 33 + src/controller.js | 90 + src/helpers/date_parse.js | 28 + src/helpers/dom.js | 13 + src/helpers/i18n.js | 48 + src/helpers/index.js | 4 + src/helpers/strftime.js | 77 + src/index.js | 33 + src/page_observer.js | 66 + src/relative_time.js | 86 + src/start.js | 38 + test/javascripts/fixtures/body.html | 8 - test/javascripts/src/i18n.test.js | 62 + test/javascripts/src/i18n_test.coffee | 47 - test/javascripts/src/local_time.test.js | 70 + test/javascripts/src/local_time_test.coffee | 37 - test/javascripts/src/relative_date.test.js | 126 + .../javascripts/src/relative_date_test.coffee | 89 - test/javascripts/src/strftime.test.js | 84 + test/javascripts/src/strftime_test.coffee | 54 - test/javascripts/src/test.coffee | 43 - test/javascripts/src/test_helpers.js | 30 + test/javascripts/src/time_ago.test.js | 87 + test/javascripts/src/time_ago_test.coffee | 56 - test/javascripts/vendor/moment.js | 6 - test/javascripts/vendor/sinon-timers.js | 385 -- web-test-runner.config.mjs | 5 + yarn.lock | 3596 +++++++++++++++++ 59 files changed, 6368 insertions(+), 1260 deletions(-) delete mode 100644 .blade.yml create mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml create mode 100644 app/assets/javascripts/local-time.umd.js delete mode 100755 bin/blade delete mode 100644 lib/assets/javascripts/src/local-time/calendar_date.coffee delete mode 100644 lib/assets/javascripts/src/local-time/config/i18n.coffee delete mode 100644 lib/assets/javascripts/src/local-time/config/locale.coffee delete mode 100644 lib/assets/javascripts/src/local-time/config/timer.coffee delete mode 100644 lib/assets/javascripts/src/local-time/controller.coffee delete mode 100644 lib/assets/javascripts/src/local-time/helpers/date_parse.coffee delete mode 100644 lib/assets/javascripts/src/local-time/helpers/dom.coffee delete mode 100644 lib/assets/javascripts/src/local-time/helpers/i18n.coffee delete mode 100644 lib/assets/javascripts/src/local-time/helpers/strftime.coffee delete mode 100644 lib/assets/javascripts/src/local-time/index.coffee delete mode 100644 lib/assets/javascripts/src/local-time/page_observer.coffee delete mode 100644 lib/assets/javascripts/src/local-time/relative_time.coffee delete mode 100644 lib/assets/javascripts/src/local-time/start.coffee create mode 100644 playground/index.html create mode 100644 playground/index.js create mode 100644 playground/package.json create mode 100644 playground/vite.config.js create mode 100644 playground/yarn.lock create mode 100644 rollup.config.js create mode 100644 src/calendar_date.js create mode 100644 src/config/i18n.js create mode 100644 src/config/index.js create mode 100644 src/controller.js create mode 100644 src/helpers/date_parse.js create mode 100644 src/helpers/dom.js create mode 100644 src/helpers/i18n.js create mode 100644 src/helpers/index.js create mode 100644 src/helpers/strftime.js create mode 100644 src/index.js create mode 100644 src/page_observer.js create mode 100644 src/relative_time.js create mode 100644 src/start.js delete mode 100644 test/javascripts/fixtures/body.html create mode 100644 test/javascripts/src/i18n.test.js delete mode 100644 test/javascripts/src/i18n_test.coffee create mode 100644 test/javascripts/src/local_time.test.js delete mode 100644 test/javascripts/src/local_time_test.coffee create mode 100644 test/javascripts/src/relative_date.test.js delete mode 100644 test/javascripts/src/relative_date_test.coffee create mode 100644 test/javascripts/src/strftime.test.js delete mode 100644 test/javascripts/src/strftime_test.coffee delete mode 100644 test/javascripts/src/test.coffee create mode 100644 test/javascripts/src/test_helpers.js create mode 100644 test/javascripts/src/time_ago.test.js delete mode 100644 test/javascripts/src/time_ago_test.coffee delete mode 100644 test/javascripts/vendor/moment.js delete mode 100644 test/javascripts/vendor/sinon-timers.js create mode 100644 web-test-runner.config.mjs create mode 100644 yarn.lock diff --git a/.blade.yml b/.blade.yml deleted file mode 100644 index c819fcd..0000000 --- a/.blade.yml +++ /dev/null @@ -1,40 +0,0 @@ -load_paths: - - lib/assets/javascripts/src - - test/javascripts/src - - test/javascripts/vendor - - test/javascripts/fixtures - -logical_paths: - - local-time.js - - test.js - -build: - logical_paths: - - local-time.js - path: app/assets/javascripts - js_compressor: uglifier - -require: - - sprockets/export - -plugins: - sauce_labs: - test_config: - time_zone: Central - browsers: - Google Chrome: - version: -2 - os: Mac, Windows, Linux - Firefox: - version: -2 - os: Mac, Windows, Linux - Safari: - version: -2 - Microsoft Edge: - version: -2 - Internet Explorer: - version: -3 - iPhone: - version: -1 - Android: - version: -1 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..ed97dec --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,31 @@ +name: Tests + +on: + pull_request: + push: + +jobs: + test: + name: JavaScript Test Action + runs-on: ubuntu-latest + strategy: + matrix: + node: [14, 16, 18] + + steps: + - uses: actions/checkout@master + + - name: Setup Node v${{ matrix.node }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node }} + cache: 'yarn' + + - name: Yarn install + run: yarn install + + - name: Run JavaScript Tests + run: yarn build + + - name: Run JavaScript Tests + run: yarn test diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index f935609..0000000 --- a/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: ruby -cache: bundler -branches: - only: - - master -before_install: - - true && `base64 --decode <<< ZXhwb3J0IFNBVUNFX1VTRVJOQU1FPWJhc2VjYW1wX2xvY2FsX3RpbWUK` - - true && `base64 --decode <<< ZXhwb3J0IFNBVUNFX0FDQ0VTU19LRVk9ZWM5Y2QyMjMtOTFjNS00NmRkLWJmNDktZWIyYmZiY2NjYzMzCg==` diff --git a/CHANGELOG.md b/CHANGELOG.md index 260f71a..e86a381 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +**3.0.0-beta.1** (September 30, 2022) + +* Migrate Codebase to modern JavaScript [Marco Roth] + **2.1.0** (September 4, 2018) * Add support for non-padded numerical strftime values (`%-d`, `%-m`, etc.) [Paco Benavent] diff --git a/MIT-LICENSE b/MIT-LICENSE index 140a332..0c72788 100644 --- a/MIT-LICENSE +++ b/MIT-LICENSE @@ -1,4 +1,4 @@ -Copyright 2018 Javan Makhmali, Basecamp +Copyright 2022 Marco Roth Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -18,3 +18,7 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Copyright for portions of project local-time are held by Javan Makhmali, +Basecamp 2018 as part of project local-time. All other copyright for +project @marcoroth/local-time are held by Marco Roth, 2022 diff --git a/README.md b/README.md index 64d6531..e2642f1 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,19 @@ -# Local Time +# Modern Local Time + +> This is a modern fork of Basecamp's `local-time` npm package and gem. The original repo can be found here: https://github.com/basecamp/local_time Local Time makes it easy to display times and dates to users in their local time. Its Rails helpers render `