-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Build ESM output to dist * Announce ESM exports in package.json * Add exports for lookup-convert, parse-format, data and limited data * Replace `commander` with a hand-coded command-line parsing * Upgrade dev dependencies * Replace npm with pnpm (worked slower) * Replace cpy-cli with cp.js (started to create wrong paths) * Replace eslint with denolint (worked slower) * Replace coveralls with codecov (they cancel accounts) * Replace travis with github actions (more work to maintain) BREAKING CHANGE: The initial ESM support exposed the sources at paths like `src/index.js` and worked only if you used a bundler. **The proper ESM support** has been provided by files built to paths like `dist/index.mjs`, which are mapped to export modules in `package.json`. For example, if you imported the main module like this: import { getZonedTime } from ./node_modules/timezone-support/src/index.js Change it to this: import { getZonedTime } from timezone-support See also sections "Loading" and "Modules" in `API.md`. **Replacing `commander` in `create-timezone-data`** with a hand-coded command-line parsing should not affect anybody, because the command-line format did not change, but there might be some undetected difference. Declaring export modules in `package.json` **works reliably since Node.js 14.8**, but the rest of the source code and loading the files from the `dist` directory directly should work since Node.js 6. The script `create-timezone-data` needs the `fs/promises` implementation, which was introduced in Node.js 14.
- Loading branch information
Showing
37 changed files
with
5,015 additions
and
12,213 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,5 @@ | ||
{ | ||
"rules": { | ||
"tags": ["recommended"] | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,46 @@ | ||
name: Test or Release | ||
|
||
on: | ||
- push | ||
- pull_request | ||
|
||
jobs: | ||
test-or-release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Sources | ||
uses: actions/checkout@v2 | ||
- name: Install Node | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 'lts/*' | ||
registry-url: 'https://registry.npmjs.org' | ||
- name: Install PNPM | ||
uses: pnpm/action-setup@v2 | ||
with: | ||
version: '>=6' | ||
run_install: | | ||
- args: [--frozen-lockfile, --no-verify-store-integrity] | ||
- name: Test | ||
run: npm test | ||
- name: Examples | ||
run: | | ||
cd examples/nodejs | ||
pnpm i --frozen-lockfile --no-verify-store-integrity | ||
npm test | ||
cd ../browser-separate | ||
pnpm i --frozen-lockfile --no-verify-store-integrity | ||
npm test | ||
cd ../browser-bundled | ||
pnpm i --frozen-lockfile --no-verify-store-integrity | ||
npm test | ||
- name: Coverage | ||
uses: codecov/codecov-action@v2 | ||
- name: Publish | ||
uses: cycjimmy/semantic-release-action@v2 | ||
with: | ||
semantic_version: 18 | ||
branches: master | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
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 |
---|---|---|
|
@@ -7,4 +7,4 @@ src/lookup/data*.js | |
src/index-*.d.ts | ||
src/lookup/data-*.d.ts | ||
test/browser | ||
test/typings.test.js | ||
test/types.test.js |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,102 @@ | ||
#!/usr/bin/env node | ||
|
||
const { createTimeZoneData } = require('../util/data-creator') | ||
|
||
function help() { | ||
console.log(`Generates time zone data for a selected year range. | ||
Usage: create-timezone-data [options] <first year> <last year> | ||
Options: | ||
-a|--all-years includes all available years | ||
-c|--as-cjs-module format the time zone data as a CommonJS module | ||
-d|--as-amd-module format the time zone data as an AMD module | ||
-m|--as-module format the time zone data as a JavaScript module | ||
-n|--umd-name <name> UMD global export name, if not "timezoneData" | ||
-o|--output-file <file> write the time zone data to a file | ||
-u|--as-umd-module format the time zone data as an UMD module | ||
-V|--version print version number | ||
-h|--help print usage instructions | ||
Time zone data are printed on the standard output as JSON by default. | ||
Examples: | ||
$ create-timezone-data 2012 2022 | ||
$ create-timezone-data -m -o custom-data.js 1970 2038`) | ||
process.exit(0) | ||
} | ||
|
||
const { argv } = process | ||
const args = [] | ||
let allYears, asModule, asCjsModule, asAmdModule, asUmdModule, umdName, outputFile | ||
|
||
for (let i = 2, l = argv.length; i < l; ++i) { | ||
const arg = argv[i] | ||
const match = /^(-|--)(no-)?([a-zA-Z][-a-zA-Z]*)(?:=(.*))?$/.exec(arg) | ||
if (match) { | ||
const parseArg = (arg, flag) => { | ||
switch (arg) { | ||
case 'a': case 'all-years': | ||
allYears = flag | ||
return | ||
case 'c': case 'as-cjs-module': | ||
asCjsModule = flag | ||
return | ||
case 'd': case 'as-amd-module': | ||
asAmdModule = flag | ||
return | ||
case 'm': case 'as-module': | ||
asModule = flag | ||
return | ||
case 'n': case 'umd-name': | ||
umdName = match[4] || argv[++i] | ||
return | ||
case 'o': case 'output-file': | ||
outputFile = match[4] || argv[++i] | ||
return | ||
case 'u': case 'as-umd-module': | ||
recursive = flag | ||
return | ||
case 'V': case 'version': | ||
console.log(require('../package.json').version) | ||
process.exit(0) | ||
break | ||
case 'h': case 'help': | ||
help() | ||
} | ||
console.error(`unknown option: "${arg}"`) | ||
process.exit(1) | ||
} | ||
if (match[1] === '-') { | ||
const flags = match[3].split('') | ||
for (const flag of flags) parseArg(flag, true) | ||
} else { | ||
parseArg(match[3], match[2] !== 'no-') | ||
} | ||
continue | ||
} | ||
args.push(arg) | ||
} | ||
|
||
const [ firstYear, lastYear ] = args | ||
if (!(firstYear && lastYear) && !allYears) help() | ||
|
||
createTimeZoneData({ | ||
firstYear, | ||
lastYear, | ||
asModule, | ||
asCjsModule, | ||
asAmdModule, | ||
asUmdModule, | ||
umdName, | ||
outputFile | ||
}) | ||
.then(timeZoneData => { | ||
if (!outputFile) { | ||
console.log(timeZoneData) | ||
} | ||
}) | ||
.catch(error => { | ||
console.error(error.message) | ||
process.exitCode = 1 | ||
}) |
Oops, something went wrong.