Skip to content

Commit

Permalink
Switch to @pika/pack for building
Browse files Browse the repository at this point in the history
  • Loading branch information
jaclarke committed Jun 23, 2019
1 parent 3b3f818 commit fb51aa3
Show file tree
Hide file tree
Showing 12 changed files with 3,466 additions and 572 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node_modules
lib
pkg
coverage
.vscode
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ node_js:
env:
- TZ=Europe/London
script:
- tsc
- npm run build
- jest --coverage
- cat ./coverage/lcov.info | coveralls
3,963 changes: 3,431 additions & 532 deletions package-lock.json

Large diffs are not rendered by default.

27 changes: 17 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
{
"name": "cronosjs",
"version": "1.0.0",
"version": "1.1.0",
"description": "A cron based task scheduler for node and the browser, with extended syntax and timezone support.",
"keywords": [
"cron",
"schedule",
"scheduler",
"timezone support"
],
"main": "lib/index.js",
"types": "lib/index.d.ts",
"files": [
"/lib",
"!*.js.map"
],
"scripts": {
"build": "rimraf ./lib && tsc",
"build": "pack build",
"test": "jest"
},
"author": "James Clarke <jaclarke77@gmail.com>",
"license": "ISC",
"repository": "github:jaclarke/cronosjs",
"bugs": "https://github.com/jaclarke/cronosjs/issues",
"devDependencies": {
"@pika/pack": "^0.4.0",
"@pika/plugin-build-node": "^0.4.0",
"@pika/plugin-build-web": "^0.4.0",
"@pika/plugin-ts-standard-pkg": "^0.4.0",
"coveralls": "^3.0.3",
"jest": "^24.7.1",
"rimraf": "^2.6.3",
"typescript": "^3.4.3"
},
"dependencies": {}
"dependencies": {},
"engines" : {
"node" : ">=8.0.0"
},
"@pika/pack": {
"pipeline": [
["@pika/plugin-ts-standard-pkg"],
["@pika/plugin-build-node"],
["@pika/plugin-build-web"]
]
}
}
8 changes: 4 additions & 4 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function expandFieldItem(item: string, first: number, last: number): number[] {
}

function secondsOrMinutesParser(field: string): number[] {
const allowed = new Set()
const allowed: Set<number> = new Set()

for (const item of field.split(',')) {
for (const n of expandFieldItem(item, 0, 59)) {
Expand All @@ -92,7 +92,7 @@ function secondsOrMinutesParser(field: string): number[] {
}

function hoursParser(field: string): number[] {
const allowed = new Set()
const allowed: Set<number> = new Set()

for (const item of field.split(',')) {
for (const n of expandFieldItem(item, 0, 23)) {
Expand Down Expand Up @@ -214,7 +214,7 @@ function daysParser(daysOfMonthField: string, daysOfWeekField: string): CronosDa
}

function monthsParser(field: string): number[] {
const allowed = new Set()
const allowed: Set<number> = new Set()

const normalisedField = field.replace(monthReplacementRegex, match => {
return monthReplacements.indexOf(match) + 1 + ''
Expand All @@ -230,7 +230,7 @@ function monthsParser(field: string): number[] {
}

function yearsParser(field: string): number[] {
const allowed = new Set()
const allowed: Set<number> = new Set()

for (const item of field.split(',')) {
for (const n of expandFieldItem(item, 1970, 2099)) {
Expand Down
15 changes: 1 addition & 14 deletions tests/api.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { scheduleTask, CronosExpression, CronosTask, validate } = require('../lib')
const { CronosDate } = require('../lib/date')
const { scheduleTask, CronosExpression, CronosTask, validate } = require('../pkg/dist-node')

const RealDate = Date

Expand Down Expand Up @@ -58,18 +57,6 @@ describe('Validate cron string', () => {
})
})

test('CronosDate.copyWith()', () => {
const date = new CronosDate(2019, 4, 21, 11, 23, 45)

expect(date.copyWith()).toEqual(date)

expect(
date.copyWith({
year: 2020, month: 5, day: 22, hour: 12, minute: 24, second: 46
})
).toEqual(new CronosDate(2020, 5, 22, 12, 24, 46))
})

describe('Scheduling tests', () => {
beforeEach(() => {
jest.useFakeTimers()
Expand Down
2 changes: 1 addition & 1 deletion tests/extended.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { CronosExpression } = require('../lib/expression')
const { CronosExpression } = require('../pkg/dist-node')

test('6 stars (* * * * * *)', () => {
expect(
Expand Down
2 changes: 1 addition & 1 deletion tests/invalid.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { CronosExpression } = require('../lib/expression')
const { CronosExpression } = require('../pkg/dist-node')

test('Too few fields', () => {
expect(
Expand Down
2 changes: 1 addition & 1 deletion tests/predefined.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { CronosExpression } = require('../lib/expression')
const { CronosExpression } = require('../pkg/dist-node')

test('@hourly', () => {
expect(
Expand Down
2 changes: 1 addition & 1 deletion tests/simple.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { CronosExpression } = require('../lib/expression')
const { CronosExpression } = require('../pkg/dist-node')

test('Every minute (* * * * *)', () => {
expect(
Expand Down
2 changes: 1 addition & 1 deletion tests/timezone.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { CronosExpression, CronosTimezone } = require('../lib')
const { CronosExpression, CronosTimezone } = require('../pkg/dist-node')

test('5:17 every Tue (EST/EDT)', () => {
expect(
Expand Down
11 changes: 6 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"compilerOptions": {
/* Basic Options */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"target": "esnext", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "esnext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": ["dom", "es6", "esnext"], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
Expand All @@ -11,7 +11,7 @@
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "lib", /* Redirect output structure to the directory. */
// "outDir": "lib", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "incremental": true, /* Enable incremental compilation */
Expand Down Expand Up @@ -44,7 +44,7 @@
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
"types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
Expand All @@ -61,6 +61,7 @@
},
"exclude": [
"node_modules",
"lib"
"pkg",
"docs",
]
}

0 comments on commit fb51aa3

Please sign in to comment.