Skip to content

Commit

Permalink
feat: update dependencies (#228)
Browse files Browse the repository at this point in the history
Co-authored-by: Michaël De Boey <info@michaeldeboey.be>
Co-authored-by: Nick McCurdy <nick@nickmccurdy.com>
  • Loading branch information
MichaelDeBoey and nickmccurdy committed Aug 30, 2022
1 parent 01550fe commit ce96bf4
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 93 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node: [12, 14, 16]
node: [12.22.0, 12, 14.17.0, 14, 16.10.0, 16, 18]
runs-on: ${{ matrix.os }}
steps:
- name: 🛑 Cancel Previous Runs
Expand Down
150 changes: 75 additions & 75 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@
"name": "kcd-scripts",
"version": "0.0.0-semantically-released",
"description": "CLI for common scripts for my projects",
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0",
"npm": ">=6"
"keywords": [],
"homepage": "https://github.com/kentcdodds/kcd-scripts#readme",
"bugs": {
"url": "https://github.com/kentcdodds/kcd-scripts/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/kentcdodds/kcd-scripts"
},
"license": "MIT",
"author": "Kent C. Dodds <me@kentcdodds.com> (https://kentcdodds.com)",
"bin": {
"kcd-scripts": "dist/index.js"
},
"scripts": {
"test": "node src test",
"test:update": "node src test --updateSnapshot",
"build": "node src build",
"lint": "node src lint",
"format": "node src format",
"validate": "node src validate"
},
"files": [
"dist",
"babel.js",
Expand All @@ -27,98 +26,99 @@
"prettier.js",
"shared-tsconfig.json"
],
"keywords": [],
"author": "Kent C. Dodds <me@kentcdodds.com> (https://kentcdodds.com)",
"license": "MIT",
"scripts": {
"build": "node src build",
"format": "node src format",
"lint": "node src lint",
"test": "node src test",
"test:update": "node src test --updateSnapshot",
"validate": "node src validate"
},
"eslintConfig": {
"extends": [
"kentcdodds",
"kentcdodds/jest"
],
"rules": {
"no-console": "off",
"no-nested-ternary": "off",
"no-process-exit": "off",
"no-useless-catch": "off",
"import/extensions": "off",
"import/no-dynamic-require": "off",
"import/no-import-module-exports": "off",
"import/no-unassigned-import": "off"
}
},
"eslintIgnore": [
"node_modules",
"coverage",
"dist"
],
"dependencies": {
"@babel/cli": "^7.17.6",
"@babel/core": "^7.17.8",
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@babel/plugin-transform-modules-commonjs": "^7.17.7",
"@babel/plugin-transform-runtime": "^7.17.0",
"@babel/preset-env": "^7.16.11",
"@babel/preset-react": "^7.16.7",
"@babel/preset-typescript": "^7.16.7",
"@babel/runtime": "^7.17.8",
"@babel/cli": "^7.18.10",
"@babel/core": "^7.18.13",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-transform-modules-commonjs": "^7.18.6",
"@babel/plugin-transform-runtime": "^7.18.10",
"@babel/preset-env": "^7.18.10",
"@babel/preset-react": "^7.18.6",
"@babel/preset-typescript": "^7.18.6",
"@babel/runtime": "^7.18.9",
"@rollup/plugin-babel": "^5.3.1",
"@rollup/plugin-commonjs": "^21.0.3",
"@rollup/plugin-commonjs": "^22.0.2",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.1.3",
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-replace": "^4.0.0",
"@types/jest": "^27.4.1",
"@types/jest": "^27.5.2",
"arrify": "^2.0.1",
"babel-jest": "^27.5.1",
"babel-jest": "^28.1.3",
"babel-plugin-macros": "^3.1.0",
"babel-plugin-minify-dead-code-elimination": "^0.5.1",
"babel-plugin-minify-dead-code-elimination": "^0.5.2",
"babel-plugin-module-resolver": "^4.1.0",
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
"babel-plugin-transform-inline-environment-variables": "^0.4.4",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"browserslist": "^4.20.2",
"builtin-modules": "^3.2.0",
"browserslist": "^4.21.3",
"builtin-modules": "^3.3.0",
"chalk": "^4.1.2",
"concurrently": "^7.1.0",
"concurrently": "^7.3.0",
"cosmiconfig": "^7.0.1",
"cpy": "^8.1.2",
"cross-env": "^7.0.3",
"cross-spawn": "^7.0.3",
"doctoc": "^2.1.0",
"eslint": "^8.12.0",
"eslint-config-kentcdodds": "^20.2.0",
"glob": "^7.2.0",
"doctoc": "^2.2.0",
"eslint": "^8.23.0",
"eslint-config-kentcdodds": "^20.4.0",
"glob": "^8.0.3",
"husky": "^4.3.8",
"is-ci": "^3.0.1",
"jest": "^27.5.1",
"jest": "^28.1.3",
"jest-environment-jsdom": "^28.1.3",
"jest-serializer-path": "^0.1.15",
"jest-snapshot-serializer-raw": "^1.2.0",
"jest-watch-typeahead": "^1.0.0",
"lint-staged": "^12.3.7",
"jest-watch-typeahead": "^1.1.0",
"lint-staged": "^12.5.0",
"lodash.camelcase": "^4.3.0",
"lodash.has": "^4.5.2",
"lodash.omit": "^4.5.0",
"mkdirp": "^1.0.4",
"prettier": "2.6.2",
"prettier": "2.7.1",
"read-pkg-up": "^7.0.1",
"resolve": "^1.22.0",
"resolve": "^1.22.1",
"rimraf": "^3.0.2",
"rollup": "^2.70.1",
"rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-globals": "^1.4.0",
"rollup": "^2.78.1",
"rollup-plugin-polyfill-node": "^0.10.2",
"rollup-plugin-terser": "^7.0.2",
"semver": "^7.3.5",
"semver": "^7.3.7",
"which": "^2.0.2",
"yargs-parser": "^21.0.1"
"yargs-parser": "^21.1.1"
},
"devDependencies": {
"jest-in-case": "^1.0.2",
"slash": "^3.0.0"
},
"eslintConfig": {
"extends": [
"kentcdodds",
"kentcdodds/jest"
],
"rules": {
"no-process-exit": "off",
"import/no-dynamic-require": "off",
"import/no-import-module-exports": "off",
"import/no-unassigned-import": "off",
"import/extensions": "off",
"no-console": "off",
"no-nested-ternary": "off",
"no-useless-catch": "off"
}
},
"eslintIgnore": [
"node_modules",
"coverage",
"dist"
],
"repository": {
"type": "git",
"url": "https://github.com/kentcdodds/kcd-scripts"
},
"bugs": {
"url": "https://github.com/kentcdodds/kcd-scripts/issues"
},
"homepage": "https://github.com/kentcdodds/kcd-scripts#readme"
"engines": {
"node": "^12.22.0 || ^14.17.0 || ^16.10.0 || >=17.0.0",
"npm": ">=6"
}
}
4 changes: 3 additions & 1 deletion src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ cases(
expect(crossSpawnSyncMock).toHaveBeenCalledTimes(1)
const [firstCall] = crossSpawnSyncMock.mock.calls
const [script, calledArgs] = firstCall
expect([script, ...calledArgs].join(' ')).toMatchSnapshot('format script')
expect([script, ...calledArgs].join(' ')).toMatchSnapshot(
'format script',
)
}
} catch (error) {
if (throws) {
Expand Down
5 changes: 4 additions & 1 deletion src/config/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ const ignores = [
'__mocks__',
]

/** @type {import('@jest/types').Config.InitialOptions} */
const jestConfig = {
roots: ['<rootDir>/src'],
testEnvironment: ifAnyDep(
['webpack', 'rollup', 'react', 'preact'],
'jsdom',
'node',
),
testURL: 'http://localhost',
testEnvironmentOptions: {
url: 'http://localhost',
},
moduleFileExtensions: ['js', 'jsx', 'json', 'ts', 'tsx'],
modulePaths: ['<rootDir>/src', 'shared', '<rootDir>/tests'],
collectCoverageFrom: ['src/**/*.+(js|jsx|ts|tsx)'],
Expand Down
4 changes: 3 additions & 1 deletion src/config/prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
/** @type {import('prettier').Options} */
module.exports = {
arrowParens: 'avoid',
bracketSameLine: false,
bracketSpacing: false,
embeddedLanguageFormatting: 'auto',
endOfLine: 'lf',
htmlWhitespaceSensitivity: 'css',
insertPragma: false,
bracketSameLine: false,
jsxSingleQuote: false,
printWidth: 80,
proseWrap: 'always',
quoteProps: 'as-needed',
requirePragma: false,
semi: false,
singleAttributePerLine: false,
singleQuote: true,
tabWidth: 2,
trailingComma: 'all',
Expand Down
9 changes: 4 additions & 5 deletions src/config/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ const {
} = require('@rollup/plugin-node-resolve')
const replace = require('@rollup/plugin-replace')
const camelcase = require('lodash.camelcase')
const {terser} = require('rollup-plugin-terser')
const nodeBuiltIns = require('rollup-plugin-node-builtins')
const nodeGlobals = require('rollup-plugin-node-globals')
const omit = require('lodash.omit')
const nodePolyfills = require('rollup-plugin-polyfill-node')
const {terser} = require('rollup-plugin-terser')
const {
pkg,
hasFile,
Expand Down Expand Up @@ -133,13 +132,13 @@ const output = [
},
]

/** @returns {import('rollup').RollupOptions} */
module.exports = {
input: codeSplitting ? input : input[0],
output,
external: externalPredicate,
plugins: [
isNode ? nodeBuiltIns() : null,
isNode ? nodeGlobals() : null,
isNode ? nodePolyfills() : null,
nodeResolve({
preferBuiltins: isNode,
mainFields: ['module', 'main', 'jsnext', 'browser'],
Expand Down
5 changes: 4 additions & 1 deletion src/run-script.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
const path = require('path')
const spawn = require('cross-spawn')
const glob = require('glob')
const {toPOSIX} = require('./utils')

const [executor, ignoredBin, script] = process.argv

if (script && script !== '--help' && script !== 'help') {
spawnScript()
} else {
const scriptsPath = path.join(__dirname, 'scripts/')
const scriptsAvailable = glob.sync(path.join(__dirname, 'scripts', '*'))
const scriptsAvailable = glob.sync(
toPOSIX(path.join(__dirname, 'scripts', '*')),
)
// `glob.sync` returns paths with unix style path separators even on Windows.
// So we normalize it before attempting to strip out the scripts path.
const scriptsAvailableMessage = scriptsAvailable
Expand Down
8 changes: 6 additions & 2 deletions src/scripts/__tests__/precommit.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ cases(
expect(crossSpawnSyncMock).toHaveBeenCalledTimes(2)
const [firstCall, secondCall] = crossSpawnSyncMock.mock.calls
const [scriptOne, calledArgsOne] = firstCall
expect([scriptOne, ...calledArgsOne].join(' ')).toMatchSnapshot('pre-commit scriptOne')
expect([scriptOne, ...calledArgsOne].join(' ')).toMatchSnapshot(
'pre-commit scriptOne',
)
const [scriptTwo, calledArgsTwo] = secondCall
expect([scriptTwo, ...calledArgsTwo].join(' ')).toMatchSnapshot('pre-commit scriptTwo')
expect([scriptTwo, ...calledArgsTwo].join(' ')).toMatchSnapshot(
'pre-commit scriptTwo',
)
} catch (error) {
throw error
} finally {
Expand Down
11 changes: 6 additions & 5 deletions src/scripts/build/rollup.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const {
hasFile,
resolveBin,
fromRoot,
toPOSIX,
getConcurrentlyArgs,
writeExtraEntry,
hasTypescript,
Expand Down Expand Up @@ -76,8 +77,8 @@ function go() {
writeExtraEntry(
'preact',
{
cjs: glob.sync(fromRoot('preact/**/*.cjs.js'))[0],
esm: glob.sync(fromRoot('preact/**/*.esm.js'))[0],
cjs: glob.sync(toPOSIX(fromRoot('preact/**/*.cjs.js')))[0],
esm: glob.sync(toPOSIX(fromRoot('preact/**/*.esm.js')))[0],
},
false,
)
Expand All @@ -101,7 +102,7 @@ function go() {
const isCodesplitting = rollupInputs.length > 1

const outputs = isCodesplitting
? glob.sync(fromRoot(path.join(dirpath, format, '*.js')))
? glob.sync(toPOSIX(fromRoot(path.posix.join(dirpath, format, '*.js'))))
: [fromRoot(path.join(dirpath, filename))]

for (const output of outputs) {
Expand All @@ -123,8 +124,8 @@ function go() {
// because typescript generates type defs for ignored files, we need to
// remove the ignored files
const ignoredFiles = [
...glob.sync(fromRoot('dist', '**/__tests__/**')),
...glob.sync(fromRoot('dist', '**/__mocks__/**')),
...glob.sync(toPOSIX(fromRoot('dist', '**/__tests__/**'))),
...glob.sync(toPOSIX(fromRoot('dist', '**/__mocks__/**'))),
]
ignoredFiles.forEach(ignoredFile => {
rimraf.sync(ignoredFile)
Expand Down
4 changes: 3 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ function resolveBin(modName, {executable = modName, cwd = process.cwd()} = {}) {
}

const fromRoot = (...p) => path.join(appDirectory, ...p)
const toPOSIX = p => p.split(path.sep).join(path.posix.sep)
const hasFile = (...p) => fs.existsSync(fromRoot(...p))
const ifFile = (files, t, f) =>
arrify(files).some(file => hasFile(file)) ? t : f
Expand Down Expand Up @@ -192,7 +193,7 @@ function getRollupInputs() {
const buildInputGlob =
process.env.BUILD_INPUT ||
(hasTypescript ? 'src/index.{js,ts,tsx}' : 'src/index.js')
const input = glob.sync(fromRoot(buildInputGlob))
const input = glob.sync(toPOSIX(fromRoot(buildInputGlob)))
if (!input.length) {
throw new Error(`Unable to find files with this glob: ${buildInputGlob}`)
}
Expand Down Expand Up @@ -222,6 +223,7 @@ function getRollupOutput(format = process.env.BUILD_FORMAT) {
module.exports = {
appDirectory,
fromRoot,
toPOSIX,
getConcurrentlyArgs,
hasFile,
hasLocalConfig,
Expand Down

0 comments on commit ce96bf4

Please sign in to comment.