Skip to content

Commit

Permalink
fix: fixing file structure and names and example
Browse files Browse the repository at this point in the history
  • Loading branch information
amirhmoradi committed May 20, 2023
1 parent c937aaa commit 35d2ecb
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 29 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ tsconfig.tsbuildinfo
.turbo

# Builds
dist
/dist
/calendarSystems
/calendarUtils
/index.d.ts

# Linting
lint-results
Expand Down
20 changes: 10 additions & 10 deletions builder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ async function build(option) {
for (const tool of tools) {
// run builds sequentially to limit RAM usage
await build(configFactory({
input: `./src/utils/${tool}`,
fileName: `./dist/utils/${tool}.js`,
name: `dayjs_calendarSystems_utils_${formatName(tool)}`
input: `./src/calendarUtils/${tool}`,
fileName: `./calendarUtils/${tool}.js`,
name: `dayjs_calendarsystems_calendarutils_${formatName(tool)}`
}))
}

Expand All @@ -36,36 +36,36 @@ async function build(option) {
// run builds sequentially to limit RAM usage
await build(configFactory({
input: `./src/calendarSystems/${plugin}`,
fileName: `./dist/calendarSystems/${plugin}.js`,
name: `dayjs_calendarSystems_${formatName(plugin)}`
fileName: `./calendarSystems/${plugin}.js`,
name: `dayjs_calendarsystems_${formatName(plugin)}`
}))
}

build(configFactory({
input: './src/index.js',
fileName: './dist/dayjs-calendarsystems.min.js',
fileName: './dayjs-calendarsystems.min.js',
format: 'umd',
name: 'dayjs_calendarsystems'
}))

build(configFactory({
input: './src/index.js',
fileName: './dist/dayjs-calendarsystems.esm.js',
fileName: './dayjs-calendarsystems.esm.min.js',
format: 'esm'
}))
build(configFactory({
input: './src/index.js',
fileName: './dist/dayjs-calendarsystems.cjs.js',
fileName: './dayjs-calendarsystems.cjs.min.js',
format: 'cjs'
}))
build(configFactory({
input: './src/index.js',
fileName: './dist/dayjs-calendarsystems.umd.js',
fileName: './dayjs-calendarsystems.umd.min.js',
format: 'umd',
name: 'dayjs_calendarsystems'
}))

await promisify(ncp)('./types/', './dist')
await promisify(ncp)('./types/', './')

} catch (e) {
console.error(e) // eslint-disable-line no-console
Expand Down
2 changes: 1 addition & 1 deletion builder/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = (config) => {
output: {
file: fileName,
format: format,
name: name || 'dayjs',
name: name || 'dayjs_calendarsystems',
globals: {
dayjs: 'dayjs'
},
Expand Down
6 changes: 3 additions & 3 deletions examples/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import Dayjs from 'dayjs';
import calendarSystems from '../src/index.js';
import PersianCalendar from '../src/calendarSystems/persian.js'
import calendarSystems from "@calidy/dayjs-calendarsystems";
import PersianCalendarSystem from "@calidy/dayjs-calendarsystems/calendarSystems/PersianCalendarSystem";

Dayjs.extend(calendarSystems);

// Register the calendar system
Dayjs.registerCalendarSystem('persian', new PersianCalendar());
Dayjs.registerCalendarSystem('persian', new PersianCalendarSystem());

// Now you can use the calendar system
const date = Dayjs().toCalendarSystem('persian');
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
"name": "@calidy/dayjs-calendarsystems",
"version": "1.0.7",
"description": "Calendar Systems Management for Day.js",
"main": "dist/dayjs-calendarsystems.cjs.js",
"umd:main": "dist/dayjs-calendarsystems.umd.js",
"web": "dist/dayjs-calendarsystems.umd.js",
"module": "dist/dayjs-calendarsystems.esm.js",
"jsnext:main": "dist/dayjs-calendarsystems.esm.js",
"main": "dayjs-calendarsystems.cjs.min.js",
"umd:main": "dayjs-calendarsystems.umd.min.js",
"web": "dayjs-calendarsystems.umd.min.js",
"module": "dayjs-calendarsystems.esm.min.js",
"jsnext:main": "dayjs-calendarsystems.esm.min.js",
"types": "index.d.ts",
"scripts": {
"test": "jest",
"lint": "./node_modules/.bin/eslint src/* test/* dist/*",
"lint": "./node_modules/.bin/eslint src/* test/*",
"prettier": "prettier --write \"docs/**/*.md\"",
"babel": "cross-env BABEL_ENV=build babel src --out-dir esm --copy-files && node dist/esm",
"babel": "cross-env BABEL_ENV=build babel src --out-dir esm --copy-files && node esm",
"build": "node builder && yarn size",
"sauce": "npx karma start karma.sauce.conf.js",
"test:sauce": "npm run sauce -- 0 && npm run sauce -- 1 && npm run sauce -- 2 && npm run sauce -- 3",
Expand All @@ -27,21 +27,21 @@
"size-limit": [
{
"limit": "2.99 KB",
"path": "dist/dayjs-calendarsystems.umd.js",
"path": "dayjs-calendarsystems.umd.min.js",
"ignore": [
"dayjs"
]
},
{
"limit": "2.99 KB",
"path": "dist/dayjs-calendarsystems.cjs.js",
"path": "dayjs-calendarsystems.cjs.min.js",
"ignore": [
"dayjs"
]
},
{
"limit": "2.99 KB",
"path": "dist/dayjs-calendarsystems.esm.js",
"path": "dayjs-calendarsystems.esm.min.js",
"ignore": [
"dayjs"
]
Expand Down Expand Up @@ -100,7 +100,8 @@
"url": "https://github.com/calidy-com/dayjs-calendarsystems.git"
},
"files": [
"dist",
"calendarsystems",
"calendarUtils",
"*.md"
],
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/calendarSystems/PersianCalendarSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
*/

import CalendarSystemBase from './CalendarSystemBase';
import * as CalendarUtils from "../utils/fourmilabCalendar";
import {generatePersianMonthNames} from '../utils/IntlUtils';
import * as CalendarUtils from "../calendarUtils/fourmilabCalendar";
import {generatePersianMonthNames} from '../calendarUtils/IntlUtils';

export default class PersianCalendarSystem extends CalendarSystemBase {
constructor(locale = 'en') {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/PersianCalendarSystem.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PersianCalendarSystem from "../src/calendarSystems/PersianCalendarSystem";
import * as CalendarUtils from "../src/utils/fourmilabCalendar";
import * as CalendarUtils from "../src/calendarUtils/fourmilabCalendar";

describe("PersianCalendarSystem", () => {
let persianCalendar;
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 35d2ecb

Please sign in to comment.