update dependencies, cleanup, refine (#642)

* update dependencies, cleanup, refine

fixes #637

* update CI command to verify
pull/644/head
Jason O'Neill 2022-01-06 05:44:13 -08:00 zatwierdzone przez GitHub
rodzic 46f05224ab
commit ca346ccbb2
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
18 zmienionych plików z 5108 dodań i 6710 usunięć

Wyświetl plik

@ -5,13 +5,12 @@ name: Node.js CI
on:
push:
branches: [ next ]
branches: [next]
pull_request:
branches: [ next ]
branches: [next]
jobs:
build:
runs-on: ubuntu-latest
strategy:
@ -20,13 +19,12 @@ jobs:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npx playwright install-deps
- run: npm ci
- run: npm run build --if-present
- run: npm test
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npx playwright install-deps
- run: npm ci
- run: npm run verify

Wyświetl plik

@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx --no-install lint-staged

Wyświetl plik

@ -4,7 +4,9 @@
.github
dist
docs/*.md
docs/search.json
src/components/icon/icons
src/react/index.ts
node_modules
package-lock.json
tsconfig.json

Wyświetl plik

@ -1,6 +1,6 @@
import fs from 'fs';
import { parse } from 'comment-parser';
import pascalCase from 'pascal-case';
import { pascalCase } from 'pascal-case';
const packageData = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
const { name, description, version, author, homepage, license } = packageData;

Wyświetl plik

@ -22,6 +22,7 @@ _During the beta period, these restrictions may be relaxed in the event of a mis
- Refactored `<sl-breadcrumb-item>`, `<sl-button>`, `<sl-card>`, `<sl-dialog>`, `<sl-drawer>`, `<sl-input>`, `<sl-range>`, `<sl-select>`, and `<sl-textarea>` to use a Reactive Controller for slot detection
- Refactored internal id usage in `<sl-details>`, `<sl-dialog>`, `<sl-drawer>`, and `<sl-dropdown>`
- Removed `position: relative` from the common component stylesheet
- Updated all dependencies to latest versions
## 2.0.0-beta.63

Wyświetl plik

@ -0,0 +1,4 @@
export default {
'*.{js,ts,jsx,tsx,json,html,xml,css,scss,sass,md}': 'cspell --no-must-find-files',
'*': 'prettier --write --ignore-unknown'
};

11456
package-lock.json wygenerowano

Plik diff jest za duży Load Diff

Wyświetl plik

@ -32,16 +32,21 @@
"scripts": {
"start": "node scripts/build.js --bundle --serve",
"build": "node scripts/build.js --bundle --types --copydir \"docs/dist\"",
"prepublishOnly": "npm run build && npm run test",
"verify": "npm run spellcheck && npm run prettier:check && npm run ts-check && npm run build && npm run test",
"prepublishOnly": "npm run verify",
"prettier": "prettier --write --loglevel warn .",
"create": "plop --plopfile scripts/plop/plopfile.cjs",
"prettier:check": "prettier --check --loglevel warn .",
"ts-check": "tsc --noEmit",
"create": "plop --plopfile scripts/plop/plopfile.js",
"test": "web-test-runner \"src/**/*.test.ts\" --node-resolve --playwright --browsers chromium firefox webkit",
"test:watch": "web-test-runner \"src/**/*.test.ts\" --node-resolve --playwright --browsers chromium firefox webkit --watch",
"spellcheck": "cspell \"**/*.{js,ts,jsx,tsx,json,html,xml,css,scss,sass,md}\""
"spellcheck": "cspell \"**/*.{js,ts,jsx,tsx,json,html,xml,css,scss,sass,md}\" --no-progress",
"list-outdated-dependencies": "npm-check-updates --format repo --peer",
"update-dependencies": "npm-check-updates --peer -u && npm install && npm run prettier && npm run verify"
},
"dependencies": {
"@lit-labs/react": "^1.0.1",
"@popperjs/core": "^2.7.0",
"@popperjs/core": "^2.11.2",
"@shoelace-style/animations": "^1.1.0",
"@shoelace-style/localize": "^2.1.3",
"color": "4.1",
@ -49,48 +54,37 @@
"qr-creator": "^1.0.0"
},
"devDependencies": {
"@custom-elements-manifest/analyzer": "^0.4.12",
"@open-wc/testing": "^2.5.33",
"@types/color": "^3.0.1",
"@types/react": "^17.0.33",
"@web/dev-server-esbuild": "^0.2.12",
"@web/test-runner": "^0.13.5",
"@custom-elements-manifest/analyzer": "^0.5.7",
"@open-wc/testing": "^3.0.3",
"@types/color": "^3.0.2",
"@types/react": "^17.0.38",
"@web/dev-server-esbuild": "^0.2.16",
"@web/test-runner": "^0.13.23",
"@web/test-runner-playwright": "^0.8.8",
"bluebird": "^3.7.2",
"bootstrap-icons": "^1.7.2",
"browser-sync": "^2.26.14",
"chalk": "^4.1.0",
"browser-sync": "^2.27.7",
"chalk": "^5.0.0",
"command-line-args": "^5.2.0",
"comment-parser": "^1.1.5",
"concurrently": "^5.3.0",
"comment-parser": "^1.3.0",
"cspell": "^5.14.0",
"del": "^6.0.0",
"download": "^8.0.0",
"esbuild": "^0.12.4",
"esbuild": "^0.14.10",
"front-matter": "^4.0.2",
"get-port": "^5.1.1",
"globby": "^11.0.4",
"husky": "^4.3.8",
"lint-staged": "^12.1.4",
"get-port": "^6.0.0",
"globby": "^12.0.2",
"husky": "^7.0.4",
"lint-staged": "^12.1.5",
"lunr": "^2.3.9",
"mkdirp": "^0.5.5",
"plop": "^2.7.4",
"npm-check-updates": "^12.1.0",
"pascal-case": "^3.1.2",
"plop": "^3.0.5",
"prettier": "^2.5.1",
"react": "^17.0.2",
"recursive-copy": "^2.0.11",
"sinon": "^11.1.1",
"strip-css-comments": "^4.1.0",
"tslib": "^2.2.0",
"typescript": "^4.2.4",
"wait-on": "^5.2.1"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,ts,jsx,tsx,json,html,xml,css,scss,sass,md}": "cspell --no-must-find-files",
"*": "prettier --write --ignore-unknown"
"recursive-copy": "^2.0.13",
"sinon": "^12.0.1",
"strip-css-comments": "^5.0.0",
"tslib": "^2.3.1",
"typescript": "^4.5.4"
}
}

Wyświetl plik

@ -1,12 +1,12 @@
import fs from 'fs';
import browserSync from 'browser-sync';
import chalk from 'chalk';
import commandLineArgs from 'command-line-args';
import copy from 'recursive-copy';
import del from 'del';
import esbuild from 'esbuild';
import getPort from 'get-port';
import glob from 'globby';
import mkdirp from 'mkdirp';
import getPort, { portNumbers } from 'get-port';
import { globby } from 'globby';
import { execSync } from 'child_process';
const bs = browserSync.create();
@ -22,7 +22,7 @@ const { bundle, copydir, dir, serve, types } = commandLineArgs([
const outdir = dir;
del.sync(outdir);
mkdirp.sync(outdir);
fs.mkdirSync(outdir, { recursive: true });
(async () => {
try {
@ -47,15 +47,15 @@ mkdirp.sync(outdir);
// The whole shebang
'./src/shoelace.ts',
// Components
...(await glob('./src/components/**/!(*.(style|test)).ts')),
...(await globby('./src/components/**/!(*.(style|test)).ts')),
// Translations
...(await glob('./src/translations/**/*.ts')),
...(await globby('./src/translations/**/*.ts')),
// Public utilities
...(await glob('./src/utilities/**/!(*.(style|test)).ts')),
...(await globby('./src/utilities/**/!(*.(style|test)).ts')),
// Theme stylesheets
...(await glob('./src/themes/**/!(*.test).ts')),
...(await globby('./src/themes/**/!(*.test).ts')),
// React wrappers
...(await glob('./src/react/**/*.ts'))
...(await globby('./src/react/**/*.ts'))
],
outdir,
chunkNames: 'chunks/[name].[hash]',
@ -93,7 +93,7 @@ mkdirp.sync(outdir);
// Dev server
if (serve) {
const port = await getPort({
port: getPort.makeRange(4000, 4999)
port: portNumbers(4000, 4999)
});
// Make sure docs/dist is empty since we're serving it virtually

Wyświetl plik

@ -4,19 +4,19 @@
import chalk from 'chalk';
import commandLineArgs from 'command-line-args';
import fs from 'fs/promises';
import glob from 'globby';
import mkdirp from 'mkdirp';
import { mkdirSync } from 'fs';
import { globbySync } from 'globby';
import path from 'path';
import prettier from 'prettier';
import stripComments from 'strip-css-comments';
const { outdir } = commandLineArgs({ name: 'outdir', type: String });
const files = glob.sync('./src/themes/**/*.styles.ts');
const files = globbySync('./src/themes/**/*.styles.ts');
const themesDir = path.join(outdir, 'themes');
console.log('Generating stylesheets');
mkdirp.sync(themesDir);
mkdirSync(themesDir, { recursive: true });
try {
files.map(async file => {

Wyświetl plik

@ -1,17 +1,15 @@
//
// This script downloads and generates icons and icon metadata.
//
import Promise from 'bluebird';
import chalk from 'chalk';
import commandLineArgs from 'command-line-args';
import copy from 'recursive-copy';
import del from 'del';
import download from 'download';
import mkdirp from 'mkdirp';
import fm from 'front-matter';
import { readFileSync } from 'fs';
import { readFileSync, mkdirSync } from 'fs';
import { stat, readFile, writeFile } from 'fs/promises';
import glob from 'globby';
import { globby } from 'globby';
import path from 'path';
const { outdir } = commandLineArgs({ name: 'outdir', type: String });
@ -38,7 +36,7 @@ let numIcons = 0;
// Copy icons
console.log(`Copying icons and license`);
await del([iconDir]);
await mkdirp(iconDir);
mkdirSync(iconDir, { recursive: true });
await Promise.all([
copy(`${srcPath}/icons`, iconDir),
copy(`${srcPath}/LICENSE.md`, path.join(iconDir, 'LICENSE.md')),
@ -47,20 +45,22 @@ let numIcons = 0;
// Generate metadata
console.log(`Generating icon metadata`);
const files = await glob(`${srcPath}/docs/content/icons/**/*.md`);
const files = await globby(`${srcPath}/docs/content/icons/**/*.md`);
const metadata = await Promise.map(files, async file => {
const name = path.basename(file, path.extname(file));
const data = fm(await readFile(file, 'utf8')).attributes;
numIcons++;
const metadata = await Promise.all(
files.map(async file => {
const name = path.basename(file, path.extname(file));
const data = fm(await readFile(file, 'utf8')).attributes;
numIcons++;
return {
name,
title: data.title,
categories: data.categories,
tags: data.tags
};
});
return {
name,
title: data.title,
categories: data.categories,
tags: data.tags
};
})
);
await writeFile(path.join(iconDir, 'icons.json'), JSON.stringify(metadata, null, 2), 'utf8');

Wyświetl plik

@ -1,9 +1,8 @@
import chalk from 'chalk';
import fs from 'fs';
import del from 'del';
import mkdirp from 'mkdirp';
import path from 'path';
import pascalCase from 'pascal-case';
import { pascalCase } from 'pascal-case';
import prettier from 'prettier';
import prettierConfig from '../prettier.config.cjs';
import { getAllComponents } from './shared.js';
@ -12,7 +11,7 @@ const outdir = path.join('./src/react');
// Clear build directory
del.sync(outdir);
mkdirp.sync(outdir);
fs.mkdirSync(outdir, { recursive: true });
// Fetch component metadata
const metadata = JSON.parse(fs.readFileSync('./dist/custom-elements.json', 'utf8'));
@ -29,7 +28,7 @@ components.map(component => {
const componentFile = path.join(componentDir, 'index.ts');
const importPath = component.modulePath.replace(/^src\//, '').replace(/\.ts$/, '');
mkdirp.sync(componentDir);
fs.mkdirSync(componentDir, { recursive: true });
const events = (component.events || []).map(event => `${`on${pascalCase(event.name)}`}: '${event.name}'`).join(',\n');

Wyświetl plik

@ -1,7 +1,7 @@
import commandLineArgs from 'command-line-args';
import fs from 'fs';
import path from 'path';
import glob from 'globby';
import { globby } from 'globby';
import lunr from 'lunr';
import { getAllComponents } from './shared.js';
@ -59,7 +59,7 @@ console.log('Generating search index for documentation');
return members.join(' ');
}
const files = await glob('./docs/**/*.md');
const files = await globby('./docs/**/*.md');
const map = {};
const searchIndex = lunr(function () {
// The search index uses these field names extensively, so shortening them can save some serious bytes. The initial

Wyświetl plik

@ -1,4 +1,4 @@
module.exports = function (plop) {
export default function (plop) {
plop.setHelper('tagWithoutPrefix', tag => tag.replace(/^sl-/, ''));
plop.setHelper('tagToTitle', tag => {
@ -64,4 +64,4 @@ module.exports = function (plop) {
}
]
});
};
}

Wyświetl plik

@ -1,5 +1,4 @@
import { expect, fixture, html } from '@open-wc/testing';
import { aTimeout } from '@open-wc/testing-helpers';
import '../../../dist/shoelace.js';
import type SlAvatar from './avatar';
@ -24,9 +23,8 @@ describe('<sl-avatar>', () => {
});
describe('when provided an image and label parameter', async () => {
const image =
'https://images.unsplash.com/photo-1529778873920-4da4926a72c2?ixlib=rb-1.2.1&auto=format&fit=crop&w=300&q=80';
const label = 'Gray tabby kitten looking down';
const image = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
const label = 'Small transparent square';
before(async () => {
el = await fixture<SlAvatar>(html`<sl-avatar image="${image}" label="${label}"></sl-avatar>`);
});

Wyświetl plik

@ -4,11 +4,37 @@ import sinon from 'sinon';
import '../../../dist/shoelace.js';
import type SlInclude from './include';
const stubbedFetchResponse: Response = {
headers: new Headers(),
ok: true,
redirected: false,
status: 200,
statusText: 'OK',
type: 'default',
url: '',
json: () => Promise.resolve({}),
text: () => Promise.resolve(''),
blob: sinon.fake(),
arrayBuffer: sinon.fake(),
formData: sinon.fake(),
bodyUsed: false,
body: null,
clone: sinon.fake()
};
describe('<sl-include>', () => {
afterEach(() => {
sinon.verifyAndRestore();
});
it('should load content and emit sl-load', async () => {
const el = await fixture<SlInclude>(
html` <sl-include src="https://jsonplaceholder.typicode.com/posts/1"></sl-include> `
);
sinon.stub(window, 'fetch').resolves({
...stubbedFetchResponse,
ok: true,
status: 200,
text: () => Promise.resolve('"id": 1')
});
const el = await fixture<SlInclude>(html` <sl-include src="/found"></sl-include> `);
const loadHandler = sinon.spy();
el.addEventListener('sl-load', loadHandler);
@ -19,9 +45,13 @@ describe('<sl-include>', () => {
});
it('should emit sl-error when content cannot be loaded', async () => {
const el = await fixture<SlInclude>(
html` <sl-include src="https://jsonplaceholder.typicode.com/not-found"></sl-include> `
);
sinon.stub(window, 'fetch').resolves({
...stubbedFetchResponse,
ok: false,
status: 404,
text: () => Promise.resolve('{}')
});
const el = await fixture<SlInclude>(html` <sl-include src="/not-found"></sl-include> `);
const loadHandler = sinon.spy();
el.addEventListener('sl-error', loadHandler);

Wyświetl plik

@ -1,45 +0,0 @@
//
// A lightweight debounce implementation
//
export function debounce(callback: (...args: [any]) => void, delay: number) {
let timer: any;
return function () {
if (timer) {
return;
}
callback.apply(this, arguments);
timer = setTimeout(() => (timer = null), delay);
};
}
//
// A lightweight throttle implementation
//
export function throttle(callback: (...args: [any]) => void, delay: number) {
let isThrottled = false;
let args: any;
let context: any;
function wrapper() {
if (isThrottled) {
args = arguments;
context = this;
return;
}
isThrottled = true;
callback.apply(this, arguments);
setTimeout(() => {
isThrottled = false;
if (args) {
wrapper.apply(context, args);
args = context = null;
}
}, delay);
}
return wrapper;
}

Wyświetl plik

@ -1,80 +1,35 @@
{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true /* Enable incremental compilation */,
"target": "es2017" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
"module": "es2015" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
"lib": [ /* Specify library files to be included in the compilation. */
"target": "es2017",
"module": "es2015",
"lib": [
"dom",
"dom.Iterable",
"es2020"
],
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
"declaration": true /* Generates corresponding '.d.ts' file. */,
// "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": "./dist" /* Redirect output structure to the directory. */,
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
// "strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
"strictNullChecks": true /* Enable strict null checks. */,
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
"noUnusedLocals": true /* Report errors on unused locals. */,
"noUnusedParameters": true /* Report errors on unused parameters. */,
"noImplicitReturns": true /* Report error when not all code paths in function return a value. */,
"noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */,
// "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
/* Module Resolution Options */
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "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. */
// "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. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
"experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"declaration": true,
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"strictPropertyInitialization": false,
"strictFunctionTypes": false,
"noImplicitThis": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"esModuleInterop": true,
"experimentalDecorators": true,
"removeComments": true,
"skipLibCheck": true /* Skip type checking of declaration files. */,
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"useUnknownInCatchVariables": true
},
"exclude": [
"docs",
"dist",
"src/**/*.test.ts"
]
}
}