Skip to content

Commit

Permalink
Merge pull request #428 from xylabs/feature/esm-only
Browse files Browse the repository at this point in the history
ESM Only
  • Loading branch information
JoelBCarter authored Aug 27, 2024
2 parents 7ab04eb + a9903ba commit 1f9ae4b
Show file tree
Hide file tree
Showing 87 changed files with 2,229 additions and 1,062 deletions.
348 changes: 174 additions & 174 deletions .yarn/releases/yarn-4.4.0.cjs → .yarn/releases/yarn-4.4.1.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ plugins:
- path: .yarn/plugins/@yarnpkg/plugin-outdated.cjs
spec: "https://mskelton.dev/yarn-outdated/v3"

yarnPath: .yarn/releases/yarn-4.4.0.cjs
yarnPath: .yarn/releases/yarn-4.4.1.cjs
25 changes: 21 additions & 4 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
// eslint.config.mjs

import { config as xylabsConfig } from '@xylabs/eslint-config-flat'
import {
typescriptConfig,
unicornConfig,
workspacesConfig,
rulesConfig,
importConfig,
} from '@xylabs/eslint-config-flat'

export default [
{ ignores: ['.yarn/**', 'jest.config.cjs', '**/dist/**', 'dist', 'build/**', 'coverage', 'scripts', 'node_modules/**', 'puppeteer', '.*', 'eslint.config.mjs', 'load.mjs'] },
unicornConfig,
workspacesConfig,
rulesConfig,
{
ignores: ['.yarn/**', 'jest.config.cjs', '**/dist/**', 'dist', 'build/**', 'coverage', 'node_modules/**', 'puppeteer', '.*'],
...typescriptConfig,
rules: {
...typescriptConfig.rules,
'@typescript-eslint/consistent-type-imports': ['warn'],
},
},
...xylabsConfig,
{
rules: {},
...importConfig,
rules: {
...importConfig.rules,
'import-x/no-cycle': ['warn', { maxDepth: 5 }],
},
},
]
4 changes: 1 addition & 3 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ const generateJestConfig = ({ esModules }: { esModules: string[] }) => {
extensionsToTreatAsEsm: ['.ts'],
globalSetup: './jestSetup/globalSetup.ts',
globalTeardown: './jestSetup/globalTeardown.ts',
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
moduleNameMapper: { '^(\\.{1,2}/.*)\\.js$': '$1' },
preset: 'ts-jest',
setupFiles: ['dotenv/config'],
setupFilesAfterEnv: ['jest-sorted', 'jest-extended/all', './jestSetup/setupFiles.ts'],
Expand Down
4 changes: 2 additions & 2 deletions jestSetup/globalSetup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { config } from 'dotenv'
config()
import { Config } from 'jest'
import { SuperTest, Test } from 'supertest'
import type { Config } from 'jest'
import type { SuperTest, Test } from 'supertest'

// Augment global scope with shared variables (must be var)
declare global {
Expand Down
2 changes: 1 addition & 1 deletion jestSetup/globalTeardown.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { config } from 'dotenv'
config()
import { Config } from 'jest'
import type { Config } from 'jest'

/**
* Jest global teardown method runs after all tests are run
Expand Down
2 changes: 1 addition & 1 deletion load.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ async function fetchRandomUrls(concurrentRequests = 300) {
}

// Run the load test
fetchRandomUrls()
fetchRandomUrls().catch(console.error)
144 changes: 68 additions & 76 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,66 @@
{
"name": "@xylabs/meta-server",
"version": "4.0.14",
"description": "Meta Server - adjusts meta data on index.html for served static site",
"keywords": [
"xylabs",
"nodejs",
"static",
"utility",
"typescript",
"react"
],
"homepage": "https://xylabs.com",
"bugs": {
"url": "https://github.com/xylabs/sdk-meta-server-nodejs/issues",
"email": "[email protected]"
},
"repository": {
"type": "git",
"url": "git+https://github.com/xylabs/sdk-meta-server-nodejs.git"
},
"license": "LGPL-3.0-or-later",
"author": {
"email": "[email protected]",
"name": "XY Labs Development Team",
"email": "[email protected]",
"url": "https://xylabs.com"
},
"bugs": {
"email": "[email protected]",
"url": "https://github.com/xylabs/sdk-meta-server-nodejs/issues"
"sideEffects": false,
"type": "module",
"exports": {
".": {
"node": {
"import": {
"types": "./dist/node/index.d.ts",
"default": "./dist/node/index.mjs"
}
}
},
"./package.json": "./package.json"
},
"module": "dist/node/index.mjs",
"types": "dist/node/index.d.ts",
"bin": {
"docker-build": "dist/node/bin/docker-build.mjs",
"generate-dotenv": "dist/node/bin/generate-dotenv.mjs",
"start-meta": "dist/node/bin/start-meta.mjs"
},
"scripts": {
"coverage": "yarn jest --coverage",
"start": "nodemon",
"start-esm": "node ./dist/node/bin/start-meta.mjs",
"test": "vitest run"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.627.0",
"@xylabs/assert": "^3.6.12",
"@xylabs/delay": "^3.6.12",
"@xylabs/exists": "^3.6.12",
"@xylabs/forget": "^3.6.12",
"@xylabs/promise": "^3.6.12",
"@aws-sdk/client-s3": "^3.637.0",
"@xylabs/assert": "^4.0.5",
"@xylabs/delay": "^4.0.5",
"@xylabs/exists": "^4.0.5",
"@xylabs/forget": "^4.0.5",
"@xylabs/promise": "^4.0.5",
"@xylabs/sdk-api-express-ecs": "^2.0.4",
"@xyo-network/axios": "^2.91.3",
"@xyo-network/sdk-meta": "^2.11.5",
"@xyo-network/sdk-meta": "^3.0.1",
"async-mutex": "^0.5.0",
"date-fns": "^3.6.0",
"dotenv": "^16.4.5",
Expand All @@ -32,100 +70,54 @@
"lru-cache": "^11.0.0",
"mime": "^4.0.4",
"minimatch": "^10.0.1",
"puppeteer": "^23.0.2",
"puppeteer": "^23.2.0",
"serve-static": "^1.15.0",
"yargs": "^17.7.2"
},
"description": "Meta Server - adjusts meta data on index.html for served static site",
"devDependencies": {
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.3",
"@babel/preset-env": "^7.25.4",
"@types/express": "^4.17.21",
"@types/he": "^1.2.3",
"@types/jest": "^29.5.12",
"@types/jest-image-snapshot": "^6.4.0",
"@types/node": "^22.2.0",
"@types/node": "^22.5.0",
"@types/serve-static": "^1.15.7",
"@types/supertest": "^6.0.2",
"@xylabs/eslint-config": "^3.15.16",
"@xylabs/eslint-config-flat": "^3.15.16",
"@xylabs/eslint-config-flat": "^4.0.7",
"@xylabs/eslint-config-react": "^3.15.16",
"@xylabs/jest-helpers": "^3.6.12",
"@xylabs/ts-scripts-yarn3": "^3.15.16",
"@xylabs/tsconfig": "^3.15.16",
"@xylabs/tsconfig-dom": "^3.15.16",
"@xylabs/tsconfig-dom-jest": "^3.15.16",
"@xylabs/tsconfig-jest": "^3.15.16",
"axios": "^1.7.3",
"@xylabs/jest-helpers": "^4.0.5",
"@xylabs/ts-scripts-yarn3": "^4.0.7",
"@xylabs/tsconfig": "^4.0.7",
"@xylabs/tsconfig-dom": "^4.0.7",
"@xylabs/tsconfig-dom-jest": "^4.0.7",
"@xylabs/tsconfig-jest": "^4.0.7",
"axios": "^1.7.5",
"babel-jest": "^29.7.0",
"dotenv": "^16.4.5",
"eslint": "^9.9.0",
"jest": "^29.7.0",
"eslint": "^9.9.1",
"jest-extended": "^4.0.2",
"jest-image-snapshot": "^6.4.0",
"jest-serializer-html": "^7.1.0",
"nodemon": "^3.1.4",
"supertest": "^7.0.0",
"ts-jest": "^29.2.4",
"ts-node": "^10.9.2",
"typescript": "^5.5.4"
"typescript": "^5.5.4",
"vitest": "^2.0.5"
},
"docs": "dist/docs.json",
"exports": {
".": {
"node": {
"require": {
"types": "./dist/node/index.d.cts",
"default": "./dist/node/index.cjs"
},
"import": {
"types": "./dist/node/index.d.mts",
"default": "./dist/node/index.mjs"
}
}
},
"./package.json": "./package.json"
},
"main": "dist/node/index.cjs",
"module": "dist/node/index.mjs",
"types": "dist/node/index.d.ts",
"homepage": "https://xylabs.com",
"keywords": [
"xylabs",
"nodejs",
"static",
"utility",
"typescript",
"react"
],
"license": "LGPL-3.0-or-later",
"name": "@xylabs/meta-server",
"peerDependencies": {
"axios": "^1"
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/xylabs/sdk-meta-server-nodejs.git"
},
"scripts": {
"coverage": "yarn jest --coverage",
"start": "nodemon",
"start-cjs": "node ./dist/node/bin/start-meta.cjs",
"start-esm": "node ./dist/node/bin/start-meta.mjs",
"test": "yarn jest --forceExit"
},
"sideEffects": false,
"version": "4.0.14",
"packageManager": "[email protected]",
"engines": {
"node": ">=22"
},
"volta": {
"node": "22.5.1",
"yarn": "4.4.0"
},
"packageManager": "[email protected]",
"type": "module"
"publishConfig": {
"access": "public"
},
"docs": "dist/docs.json"
}
9 changes: 5 additions & 4 deletions src/bin/getFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import yargs from 'yargs'
*/
const getFlags = async () => {
const args = yargs(process.argv.slice(2))
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { _, $0, ...flags } = await args.parserConfiguration({
'camel-case-expansion': false,
}).argv

const {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
_, $0, ...flags
} = await args.parserConfiguration({ 'camel-case-expansion': false }).argv
return flags
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { delay } from '@xylabs/delay'
import { asyncHandler } from '@xylabs/sdk-api-express-ecs'
import { RequestHandler } from 'express'
import type { RequestHandler } from 'express'
import { StatusCodes } from 'http-status-codes'

import { MountPathAndMiddleware } from '../../types/index.ts'
import type { MountPathAndMiddleware } from '../../types/index.ts'

const handleStatusCode: RequestHandler = (req, res, _next) => {
const { code } = req.params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@ import { assertEx } from '@xylabs/assert'
import { exists } from '@xylabs/exists'
import { asyncHandler } from '@xylabs/sdk-api-express-ecs'
import { HttpStatusCode } from 'axios'
import { NextFunction, Request, RequestHandler, Response } from 'express'
import type {
NextFunction, Request, RequestHandler, Response,
} from 'express'

import type {
RepositoryFile,
RouteMatcher,
} from '../../lib/index.js'
import {
arrayBufferToString,
createGlobMatcher,
getAdjustedPath,
getUriBehindProxy,
MemoryFileRepository,
RepositoryFile,
RouteMatcher,
stringToArrayBuffer,
} from '../../lib/index.js'
import { ApplicationMiddlewareOptions, MountPathAndMiddleware } from '../../types/index.ts'
import type { ApplicationMiddlewareOptions, MountPathAndMiddleware } from '../../types/index.ts'
import { useIndexAndDynamicPreviewImage } from './lib/index.ts'

/**
Expand Down Expand Up @@ -57,7 +61,9 @@ const getPageHandler = (baseDir: string) => {
if (enableCaching) {
console.log(`[dynamicShare][pageHandler][${uri}]: caching`)
const data = stringToArrayBuffer(updatedHtml)
const file: RepositoryFile = { data, type: 'text/html', uri: adjustedPath }
const file: RepositoryFile = {
data, type: 'text/html', uri: adjustedPath,
}
await pageRepository.addFile(file)
}
console.log(`[dynamicShare][pageHandler][${uri}]: return html`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Meta, OpenGraphMeta, TwitterMeta } from '@xyo-network/sdk-meta'
import type {
Meta, OpenGraphMeta, TwitterMeta,
} from '@xyo-network/sdk-meta'

import { defaultViewportSize, getContentType } from '../../../../lib/index.ts'
import { getImageUrlFromPage } from './getImageUrlFromPage.ts'
Expand All @@ -14,7 +16,11 @@ export const getImageMeta = async (url: string, width = defaultViewportSize.widt
console.log(`[dynamicShare][getImageMeta][${url}]: generating`)
const imageUrl = await getImageUrlFromPage(url)
const type = getContentType(imageUrl) || 'image/png'
const og: OpenGraphMeta = { image: { '': imageUrl, height, 'secure_url': imageUrl, type, 'url': imageUrl, width } }
const og: OpenGraphMeta = {
image: {
'': imageUrl, height, 'secure_url': imageUrl, type, 'url': imageUrl, width,
},
}
const twitter: TwitterMeta = { card: 'summary_large_image', image: { '': imageUrl } }
const meta = { og, twitter }
console.log(`[dynamicShare][getImageMeta][${url}]: generated`)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`getImageMeta > generates page preview image Meta 1`] = `Promise {}`;

exports[`getImageMeta > generates page preview image Meta 2`] = `Promise {}`;

exports[`getImageMeta generates page preview image Meta 1`] = `Promise {}`;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @stylistic/max-len */
import { getImageMeta } from '../getImageMeta.ts'

describe('getImageMeta', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Server } from 'node:http'
import type { Server } from 'node:http'

import { StatusCodes } from 'http-status-codes'
import { SuperTest, Test } from 'supertest'
import type { SuperTest, Test } from 'supertest'

import { getServerOnPort } from '../../../spec/index.ts'

Expand Down Expand Up @@ -31,8 +31,8 @@ describe('dynamicShare', () => {
html = response.text
expect(html).toBeString()
})
afterAll((done) => {
server.close(() => done())
afterAll(() => {
server.close(() => null)
})
describe('page meta', () => {
const tests = [
Expand Down
Loading

0 comments on commit 1f9ae4b

Please sign in to comment.