Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert wayback search to TS and updates deps #945

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
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
16 changes: 0 additions & 16 deletions packages/ia-wayback-search/.eslintrc

This file was deleted.

30 changes: 26 additions & 4 deletions packages/ia-wayback-search/.gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
/node_modules/
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

## testing
/coverage/
## npm
/node_modules/
/npm-debug.log

## temp folders
/.tmp/

# build
/_site/
/lib/
/dist/
/out-tsc/
/build/
ghpages
dist
dist-ssr
*.local

storybook-static

# Logs
logs
*.log
npm-debug.log*
npm-error.log*
3 changes: 3 additions & 0 deletions packages/ia-wayback-search/coverage/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
!.placeholder
!.gitignore
Empty file.
30 changes: 30 additions & 0 deletions packages/ia-wayback-search/demo/app-root.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { html, css, LitElement } from 'lit';
import { customElement } from 'lit/decorators.js';
import '../src/ia-wayback-search';

@customElement('app-root')
export class AppRoot extends LitElement {
render() {
return html`
<ia-wayback-search
.queryHandler=${{
performQuery: (query: string) =>
(window.location.href = `https://web.archive.org/web/*/${query}`),
}}
@waybackSearchSubmitted=${(e: CustomEvent) =>
console.log(`waybackSearchSubmitted: ${e.detail.query}`)}
@waybackMachineStatsLinkClicked=${() =>
console.log('waybackMachineStatsLinkClicked event')}
@waybackMachineLogoLink=${() =>
console.log('waybackMachineLogoLink event')}
>
</ia-wayback-search>
`;
}

static styles = css`
:host {
display: block;
}
`;
}
22 changes: 22 additions & 0 deletions packages/ia-wayback-search/demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!doctype html>
<html lang="en-GB">
<head>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta charset="utf-8">
<style>
html {
font-size: 10px; /* This is to match petabox's base font size */
}

body {
background: #fafafa;
}
</style>
</head>
<body>
<app-root></app-root>

<script type="module" src="../dist/demo/app-root.js">
</script>
</body>
</html>
53 changes: 53 additions & 0 deletions packages/ia-wayback-search/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import html from 'eslint-plugin-html';
import tsParser from '@typescript-eslint/parser';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});

export default [
...compat.extends('plugin:@typescript-eslint/recommended'),
{
plugins: {
'@typescript-eslint': typescriptEslint,
html,
},

languageOptions: {
parser: tsParser,
},

settings: {
'import/resolver': {
node: {
extensions: ['.ts', '.tsx'],
moduleDirectory: ['node_modules', 'src', 'demo'],
},
},
},

rules: {
'@typescript-eslint/no-unsafe-function-type': 'warn',
'@typescript-eslint/no-unused-vars': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
},
},
{
ignores: ['**/*.js', '**/*.mjs'],
},
{
files: ['**/*.test.ts'],
rules: {
'@typescript-eslint/no-unused-expressions': 'off',
},
},
];
58 changes: 0 additions & 58 deletions packages/ia-wayback-search/index.html

This file was deleted.

3 changes: 0 additions & 3 deletions packages/ia-wayback-search/index.js

This file was deleted.

4 changes: 4 additions & 0 deletions packages/ia-wayback-search/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { WaybackSearch } from './src/ia-wayback-search';

export { WaybackSearch };
export default WaybackSearch;
82 changes: 47 additions & 35 deletions packages/ia-wayback-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,57 @@
"version": "0.2.5",
"description": "Wayback search form component",
"license": "AGPL-3.0-only",
"main": "index.js",
"module": "index.js",
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"type": "module",
"publishConfig": {
"access": "public"
},
"scripts": {
"start": "cd ../../www/ && web-dev-server --app-index ./index.html --node-resolve --watch --open",
"lint:eslint": "eslint --ext .js . --ignore-path .gitignore",
"format:eslint": "eslint --ext .js . --fix --ignore-path .gitignore",
"lint:prettier": "prettier \"**/*.js\" --check --ignore-path .gitignore",
"format:prettier": "prettier \"**/*.js\" --write --ignore-path .gitignore",
"lint": "npm run lint:eslint",
"format": "npm run format:eslint && npm run format:prettier",
"test": "ulimit -v unlimited; web-test-runner 'test/**/*.test.js' --node-resolve --coverage --puppeteer",
"site:build": "npm run storybook:build",
"storybook": "start-storybook -p 9001",
"storybook:build": "build-storybook -o _site -s storybook-static"
"start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
"prepare": "rimraf dist && tsc && husky install",
"build": "tsc",
"lint": "eslint . && prettier \"**/*.ts\" --check",
"format": "eslint . --fix && prettier \"**/*.ts\" --write",
"circular": "madge --circular --extensions ts .",
"test": "tsc && npm run lint && npm run circular && wtr --coverage",
"test:watch": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wtr --watch\"",
"ghpages:build": "rimraf ghpages && npm run prepare && vite build",
"ghpages:publish": "npm run ghpages:prepare -e $(git branch --show-current)",
"ghpages:prepare": "npm run ghpages:build && touch ghpages/.nojekyll && npm run ghpages:generate",
"ghpages:generate": "gh-pages -t -d ghpages -m \"Build for $(git log --pretty=format:\"%h %an %ai %s\" -n1) [skip ci]\""
},
"devDependencies": {
"@open-wc/demoing-storybook": "^2.4.7",
"@open-wc/eslint-config": "^8.0.2",
"@open-wc/polyfills-loader": "^0.3.3",
"@open-wc/prettier-config": "^1.1.0",
"@open-wc/testing": "^3.1.6",
"@storybook/react": "^6.5.12",
"@web/test-runner": "^0.14.0",
"@web/test-runner-puppeteer": "^0.10.5",
"eslint": "^8.24.0",
"eslint-plugin-lit": "^1.6.1",
"gulp": "^4.0.2",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"sinon": "^14.0.1",
"web-dev-server": "^3.0.27"
"@open-wc/eslint-config": "^12.0.3",
"@open-wc/testing": "^4.0.0",
"@types/form-data": "^2.5.2",
"@types/mocha": "^10.0.10",
"@types/node": "^22.13.10",
"@types/sinon": "^17.0.4",
"@typescript-eslint/eslint-plugin": "^8.19.1",
"@typescript-eslint/parser": "^8.19.1",
"@web/dev-server": "^0.4.6",
"@web/test-runner": "^0.20.0",
"concurrently": "^9.1.2",
"eslint": "^9.17.0",
"eslint-config-prettier": "^10.1.1",
"eslint-plugin-html": "^8.1.2",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-lit": "^2.0.0",
"eslint-plugin-lit-a11y": "^4.1.4",
"eslint-plugin-no-only-tests": "^3.3.0",
"eslint-plugin-wc": "^3.0.0",
"gh-pages": "^6.3.0",
"husky": "^9.1.7",
"madge": "^8.0.0",
"prettier": "^3.4.2",
"rimraf": "^6.0.1",
"sinon": "^19.0.2",
"ts-lit-plugin": "^2.0.2",
"tslib": "^2.8.1",
"typescript": "^5.7.2",
"vite": "^6.0.7"
},
"husky": {
"hooks": {
Expand All @@ -50,11 +66,7 @@
"git add"
]
},
"eslintConfig": {
"extends": [
"@open-wc/eslint-config",
"eslint-config-prettier"
]
},
"prettier": "@open-wc/prettier-config"
"dependencies": {
"lit": "^2.8.0"
}
}
9 changes: 9 additions & 0 deletions packages/ia-wayback-search/prettier.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @see https://prettier.io/docs/configuration
* @type {import("prettier").Config}
*/
const config = {
singleQuote: true,
};

export default config;
Loading