-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #141 from xx45/feature/iamkun Locale && Plugin update
- Loading branch information
Showing
22 changed files
with
211 additions
and
54 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,10 @@ package-lock.json | |
# jest | ||
coverage | ||
|
||
# dist | ||
dist | ||
# build | ||
locale | ||
plugin | ||
dayjs.min.js | ||
|
||
#dev | ||
demo.js |
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 |
---|---|---|
|
@@ -10,4 +10,9 @@ yarn.lock | |
package-lock.json | ||
|
||
# jest | ||
coverage | ||
coverage | ||
|
||
# dev | ||
src | ||
test | ||
build |
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 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,45 @@ | ||
const rollup = require('rollup') | ||
const configFactory = require('./rollup.config') | ||
const fs = require('fs') | ||
const util = require('util') | ||
const path = require('path') | ||
|
||
const { promisify } = util | ||
|
||
const promisifyReadDir = promisify(fs.readdir) | ||
|
||
const formatName = n => n.replace(/\.js/, '').replace('-', '_') | ||
|
||
async function build(option) { | ||
const bundle = await rollup.rollup(option.input) | ||
await bundle.write(option.output) | ||
} | ||
|
||
(async () => { | ||
try { | ||
const locales = await promisifyReadDir(path.join(__dirname, '../src/locale')) | ||
locales.forEach((l) => { | ||
build(configFactory({ | ||
input: `./src/locale/${l}`, | ||
fileName: `./locale/${l}`, | ||
name: `dayjs_locale_${formatName(l)}` | ||
})) | ||
}) | ||
|
||
const plugins = await promisifyReadDir(path.join(__dirname, '../src/plugin')) | ||
plugins.forEach((l) => { | ||
build(configFactory({ | ||
input: `./src/plugin/${l}`, | ||
fileName: `./plugin/${l}`, | ||
name: `dayjs_plugin_${formatName(l)}` | ||
})) | ||
}) | ||
|
||
build(configFactory({ | ||
input: './src/index.js', | ||
fileName: './dayjs.min.js' | ||
})) | ||
} catch (e) { | ||
console.error(e) // eslint-disable-line no-console | ||
} | ||
})() |
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,28 @@ | ||
const babel = require('rollup-plugin-babel') | ||
const uglify = require('rollup-plugin-uglify') | ||
|
||
module.exports = (config) => { | ||
const { input, fileName, name } = config | ||
return { | ||
input: { | ||
input, | ||
external: [ | ||
'dayjs' | ||
], | ||
plugins: [ | ||
babel({ | ||
exclude: 'node_modules/**' | ||
}), | ||
uglify() | ||
] | ||
}, | ||
output: { | ||
file: fileName, | ||
format: 'umd', | ||
name: name || 'dayjs', | ||
globals: { | ||
dayjs: 'dayjs' | ||
} | ||
} | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,5 +1,12 @@ | ||
export default { | ||
import dayjs from 'dayjs' | ||
|
||
const locale = { | ||
name: 'es', | ||
weekdays: ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'], | ||
months: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'] | ||
weekdays: 'Domingo_Lunes_Martes_Miércoles_Jueves_Viernes_Sábado'.split('_'), | ||
months: 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'), | ||
ordinal: n => `${n}º` | ||
} | ||
|
||
dayjs.locale(locale, null, true) | ||
|
||
export default locale |
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,12 @@ | ||
import dayjs from 'dayjs' | ||
|
||
const locale = { | ||
name: 'zh-cn', | ||
weekdays: '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'), | ||
months: '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'), | ||
ordinal: n => n | ||
} | ||
|
||
dayjs.locale(locale, null, true) | ||
|
||
export default locale |
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 |
---|---|---|
|
@@ -29,3 +29,4 @@ export default (o, c, d) => { // locale needed later | |
return oldFormat.bind(this)(result, locale) | ||
} | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const dayjs = require('../../src') | ||
|
||
module.exports = dayjs |
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
Oops, something went wrong.