Skip to content

Commit

Permalink
chore: minor cleanup (#208)
Browse files Browse the repository at this point in the history
* chore: minor cleanup
* chore: update browserslist in lockfile
* build: disabling running headless Chrome locally in CI
* docs: add deprecation notice

Signed-off-by: Rong Sen Ng (motss) <wes.ngrongsen@gmail.com>
  • Loading branch information
motss authored Mar 27, 2022
1 parent 122925a commit b8bc0b7
Show file tree
Hide file tree
Showing 8 changed files with 294 additions and 197 deletions.
4 changes: 4 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# User config
foreground-scripts=true
message="chore(release): %s :tada:"
package-lock=true
preid=rc
progress=true
quiet=true
sign-git-tag=true
update-binary=true
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
**NOTE: Deprecated as of March 28, 2022 and 5.x will be in a complete feature freeze. Please migrate to [6.x](https://github.com/motss/app-datepicker/tree/main). Thanks for using this `app-datepicker`.**

<div align="center" style="text-align: center;">
<h1 style="border-bottom: none;">app-datepicker</h1>
<h1 style="border-bottom: none;">[DEPRECATED] app-datepicker</h1>

<p>Datepicker element built with lit-element and Material Design 2</p>
</div>
Expand Down
376 changes: 203 additions & 173 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 6 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@
"build:config": "tsc -p tsconfig.wdio.json",
"build:prod": "tsc -p tsconfig.prod.json",
"build:test": "tsc -p tsconfig.test.json",
"check": "package-check",
"clean": "shx rm -rf dist/ src/tests/snapshots/*.png logs/ .*cache *.log",
"postinstall": "sh postinstall.sh",
"lint": "tslint --project tsconfig.json --config tslint.prod.json --format stylish",
"lint:dev": "tslint --config tslint.json --project tsconfig.json --format stylish",
"pre-commit": "package-check && npm run lint && tsc --noEmit",
"prepublishOnly": "npm run lint && npm run build:prod",
"serve": "es-dev-server --watch --port 3000 --node-resolve --dedupe",
"test": "npm run build:config && npm run test:dev",
Expand All @@ -65,19 +66,16 @@
"test:sl": "npm run build:config && env-cmd -f ./.env npm run test:sl:dev",
"test:sl:clean": "npm run build:clean && npm run test:sl",
"test:sl:dev": "node ./run-tests.js --config-file ./dist/tests/wdio.sl.config.js",
"ts": "tsc",
"watch": "tsc --watch"
},
"husky": {
"hooks": {
"pre-commit": "npm run check && npm run lint && tsc --noEmit"
}
"simple-git-hooks": {
"pre-commit": "npm run pre-commit"
},
"dependencies": {
"@material/mwc-button": "^0.25.3",
"lit": "^2.0.2",
"lit": "^2.2.1",
"nodemod": "2.8.4",
"tslib": "^2.3.0"
"tslib": "^2.3.1"
},
"devDependencies": {
"@reallyland/tsconfig": "^3.1.0",
Expand Down
32 changes: 32 additions & 0 deletions postinstall.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env zx

const {
CI = 'false',
INIT_CWD = '',
} = process.env;

if (CI !== 'true') {
const {
name: fullModuleName,
} = JSON.parse(await fs.readFile('./package.json', { encoding: 'utf-8' }));
const [, moduleName = fullModuleName] = fullModuleName.split('/', 2);

if (
![
fullModuleName,
moduleName,
].some(n => INIT_CWD.endsWith(`node_modules/${n}`)) &&
INIT_CWD.endsWith(moduleName)
) {
/**
* NOTE: To skip running `simple-git-hooks` in CI environment.
* But `npm x -y -- simple-git-hooks@latest` does not work as expected so splitting it into
* a 2-step process: install without saving as dependency then execute it.
*/
await $`npm i --no-save simple-git-hooks`
await $`rm -rf .git/hooks`
await $`sh ${__dirname}/simple-git-hooks.sh`;

await $`npm dedupe`;
}
}
13 changes: 13 additions & 0 deletions postinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

DIRNAME="$(dirname "$0")"
POSTINSTALL_SCRIPT="$DIRNAME/postinstall.mjs"

# NPM_MAJOR_VERSION=$(npm -v | cut -d '.' -f 1)
NPM_MAJOR_VERSION=$(npm -v | awk -F . '{print $1}')

if [ "$NPM_MAJOR_VERSION" -gt 6 ]; then
npm x -y -- zx@latest "$POSTINSTALL_SCRIPT"
else
npx -y -- zx@latest "$POSTINSTALL_SCRIPT"
fi
17 changes: 17 additions & 0 deletions simple-git-hooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

DIRNAME=$(dirname "$0")
CONFIG="$DIRNAME/.base.simple-git-hooks.json"
NPM_BIN=$(npm bin)

# NOTE(motss): This is a workaround for the fact that the `simple-git-hooks` does not support
# custom configuration file.
#
# 1. To temporarily copy the configuration file to `pwd`
cp "$CONFIG" ./.simple-git-hooks.json

# 2. Run the `simple-git-hooks`
"$NPM_BIN"/simple-git-hooks

# 3. Remove the configuration file from `pwd`
rm -rf ./.simple-git-hooks.json
31 changes: 16 additions & 15 deletions src/tests/wdio.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@ export const config: WdioConfig = {
exclude: [],
maxInstances: 36,
capabilities: [
{
browserName: 'chrome',
'goog:chromeOptions': {
args: [
'disable-background-timer-throttling',
'disable-gpu',
'disable-renderer-backgrounding',
'headless',
'no-sandbox',
'window-size=800,600',
],
w3c: true,
},
maxInstances: 10,
},
// NOTE(motss): Disabling running headless Chrome in CI
// {
// browserName: 'chrome',
// 'goog:chromeOptions': {
// args: [
// 'disable-background-timer-throttling',
// 'disable-gpu',
// 'disable-renderer-backgrounding',
// 'headless',
// 'no-sandbox',
// 'window-size=800,600',
// ],
// w3c: true,
// },
// maxInstances: 10,
// },
{
browserName: 'firefox',
'moz:firefoxOptions': {
Expand Down

0 comments on commit b8bc0b7

Please sign in to comment.