Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
12,364 changes: 12,359 additions & 5 deletions package-lock.json

Large diffs are not rendered by default.

76 changes: 41 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
{
"name": "@elderjs/elderjs",
"version": "1.6.5",
"type": "commonjs",
"main": "./build/index.js",
"types": "./build/index.d.ts",
"exports": {
"require": "./build/index.js",
"import": "./build/esm/index.mjs"
},
"engineStrict": true,
"engines": {
"node": ">= 12.0.0"
},
"scripts": {
"build": "rimraf ./build && tsc",
"build": "rimraf ./build && tsc && mkdirp ./build/esm && cp ./src/esm/index.mjs ./build/esm && cp ./src/esm/package.json ./build/esm",
"dev": "tsc -w",
"prepare": "npm run build",
"test": "jest",
"test": "jest && node ./src/esm/__tests__/index.mjs",
"test:watch": "jest --watch",
"test:coverage": "jest --collect-coverage",
"eslint": "eslint --ext .ts .",
Expand All @@ -21,56 +26,57 @@
"build/**/*"
],
"dependencies": {
"@babel/core": "^7.13.10",
"@babel/core": "^7.16.0",
"@elderjs/shortcodes": "^2.0.2",
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-commonjs": "^21.0.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"@rollup/plugin-replace": "^2.4.2",
"@rollup/plugin-node-resolve": "^13.0.6",
"@rollup/plugin-replace": "^3.0.0",
"btoa": "^1.2.1",
"chokidar": "^3.5.1",
"clean-css": "^5.1.1",
"cli-progress": "^3.9.0",
"cosmiconfig": "^7.0.0",
"chokidar": "^3.5.2",
"clean-css": "^5.2.2",
"cli-progress": "^3.9.1",
"cosmiconfig": "^7.0.1",
"del": "^6.0.0",
"devalue": "^2.0.1",
"esbuild": "^0.12.4",
"fs-extra": "^9.1.0",
"glob": "^7.1.6",
"esbuild": "^0.14.2",
"fs-extra": "^10.0.0",
"glob": "^7.2.0",
"lodash.defaultsdeep": "^4.6.1",
"lodash.get": "^4.4.2",
"lodash.kebabcase": "^4.1.1",
"nanoid": "^3.1.20",
"nanoid": "^3.1.30",
"regexparam": "^2.0.0",
"rollup": "^2.51.2",
"rollup": "^2.61.0",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-multi-input": "^1.2.0",
"rollup-plugin-multi-input": "^1.3.1",
"rollup-plugin-terser": "^7.0.2",
"route-sort": "^1.0.0",
"spark-md5": "^3.0.1",
"svelte": "^3.38.3",
"yup": "^0.29.3"
"spark-md5": "^3.0.2",
"svelte": "^3.44.2",
"yup": "^0.32.11"
},
"devDependencies": {
"@types/fs-extra": "^9.0.8",
"@types/jest": "^26.0.20",
"@types/node": "^14.14.33",
"@typescript-eslint/eslint-plugin": "^4.28.1",
"@typescript-eslint/parser": "^4.28.1",
"@types/fs-extra": "^9.0.13",
"@types/jest": "^27.0.3",
"@types/node": "^16.11.12",
"@typescript-eslint/eslint-plugin": "^5.6.0",
"@typescript-eslint/parser": "^5.6.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^7.21.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.2.1",
"eslint-plugin-prettier": "^3.1.4",
"jest": "^26.6.3",
"eslint": "^8.4.1",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jest": "^25.3.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "^27.4.3",
"locate-character": "^2.0.5",
"prettier": "^2.3.2",
"mkdirp": "^1.0.4",
"prettier": "^2.5.1",
"rimraf": "^3.0.2",
"ts-jest": "^26.5.3",
"ts-node": "^9.1.1",
"typescript": "^4.3.5"
"ts-jest": "^27.1.1",
"ts-node": "^10.4.0",
"typescript": "^4.5.3"
},
"description": "Elder.js is an opinionated static site generator and web framework built with SEO in mind.",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/build/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ async function build(initializationOptions: InitializationOptions = {}): Promise
throw new Error(`Build did not complete successfully.`);
}
} else {
process.on('message', async (msg) => {
process.on('message', async (msg: any) => {
if (msg.cmd === 'start') {
const wElder = new Elder({ ...initializationOptions, context: 'build', worker: true });

Expand Down
6 changes: 6 additions & 0 deletions src/esm/__tests__/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { build } from '../../../build/esm/index.mjs';

if (typeof build !== 'function') {
throw 'build not exported to esm';
}
console.info('esm tests passed');
1 change: 1 addition & 0 deletions src/esm/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../index.js';
1 change: 1 addition & 0 deletions src/esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"type": "module"}
15 changes: 8 additions & 7 deletions src/utils/validations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { ShortcodeDef } from '../shortcodes/types';
import type { RouteOptions } from '../routes/types';
import type { HookOptions } from '../hooks/types';
import hookInterface from '../hooks/hookInterface';
import BaseSchema from 'yup/lib/schema'

/**
* Important note:
Expand All @@ -23,7 +24,7 @@ const shortcodeSchema = yup.object({
.label(`A sync/async function that returns the html, css, js, and head to be added to the html.`),
});

const configSchema = yup.object({
const configSchema:BaseSchema = yup.object({
origin: yup
.string()
.notRequired()
Expand Down Expand Up @@ -224,13 +225,13 @@ const pluginSchema = yup.object({
shortcodes: yup.array().notRequired().default([]).label('Array of shortcodes'),
});

const hookSchema = yup
const hookSchema:BaseSchema = yup
.object({
hook: yup
.string()
.required()
.test('valid-hook', 'This is not a supported hook.', (value) =>
hookInterface.find((supportedHook) => supportedHook.hook === value),
!!hookInterface.find((supportedHook) => supportedHook.hook === value),
)
.label('The hook the defined "run" function should be executed on.'),
name: yup.string().required().label('A user friendly name of the function to be run.'),
Expand Down Expand Up @@ -272,11 +273,11 @@ const rollupSchema = yup.object({
});

function getDefaultRollup(): RollupSettings {
return rollupSchema.cast();
return rollupSchema.cast({});
}

function getDefaultConfig(): SettingsOptions {
return configSchema.cast();
return configSchema.cast(undefined);
}

function validateRoute(route, routeName: string): RouteOptions | false {
Expand Down Expand Up @@ -315,7 +316,7 @@ function validateHook(hook): HookOptions | false {
try {
hookSchema.validateSync(hook);
const validated = hookSchema.cast(hook);
return validated;
return validated as HookOptions;
} catch (err) {
if (hook && hook.$$meta && hook.$$meta.type === 'plugin') {
console.error(
Expand All @@ -334,7 +335,7 @@ function validateShortcode(shortcode): ShortcodeDef | false {
try {
shortcodeSchema.validateSync(shortcode);
const validated = shortcodeSchema.cast(shortcode);
return validated;
return validated as ShortcodeDef;
} catch (err) {
if (shortcode && shortcode.$$meta && shortcode.$$meta.type === 'plugin') {
console.error(
Expand Down
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"target": "es2020",
"module": "commonjs",
"lib": ["es2020"],
"lib": ["es2020", "dom"],
"allowJs": true,

"outDir": "build",
Expand All @@ -12,7 +12,8 @@
// "noImplicitAny": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"declaration": true
"declaration": true,
"moduleResolution": "node"
},
"include": ["src"],
"exclude": ["node_modules", "**/__tests__/**", "dist"]
Expand Down