Coder Social home page Coder Social logo

kcd-scripts's Introduction

kcd-scripts πŸ› πŸ“¦

CLI toolbox for common scripts for my projects


Build Status Code Coverage version downloads MIT License All Contributors PRs Welcome Code of Conduct

The problem

I do a bunch of open source and want to make it easier to maintain so many projects.

This solution

This is a CLI that abstracts away all configuration for my open source projects for linting, testing, building, and more.

Table of Contents

Installation

This module is distributed via npm which is bundled with node and should be installed as one of your project's devDependencies:

npm install --save-dev kcd-scripts

Usage

This is a CLI and exposes a bin called kcd-scripts. I don't really plan on documenting or testing it super duper well because it's really specific to my needs. You'll find all available scripts in src/scripts.

This project actually dogfoods itself. If you look in the package.json, you'll find scripts with node src {scriptName}. This serves as an example of some of the things you can do with kcd-scripts.

Overriding Config

Unlike react-scripts, kcd-scripts allows you to specify your own configuration for things and have that plug directly into the way things work with kcd-scripts. There are various ways that it works, but basically if you want to have your own config for something, just add the configuration and kcd-scripts will use that instead of it's own internal config. In addition, kcd-scripts exposes its configuration so you can use it and override only the parts of the config you need to.

This can be a very helpful way to make editor integration work for tools like ESLint which require project-based ESLint configuration to be present to work.

So, if we were to do this for ESLint, you could create an .eslintrc with the contents of:

{"extends": "./node_modules/kcd-scripts/eslint.js"}

Note: for now, you'll have to include an .eslintignore in your project until this eslint issue is resolved.

Or, for babel, a .babelrc with:

{"presets": ["kcd-scripts/babel"]}

Or, for jest:

const {jest: jestConfig} = require('kcd-scripts/config')
module.exports = Object.assign(jestConfig, {
  // your overrides here

  // for test written in Typescript, add:
  transform: {
    '\\.(ts|tsx)$': '<rootDir>/node_modules/ts-jest/preprocessor.js',
  },
})

Note: kcd-scripts intentionally does not merge things for you when you start configuring things to make it less magical and more straightforward. Extending can take place on your terms. I think this is actually a great way to do this.

TypeScript Support

If the tsconfig.json-file is present in the project root directory and typescript is a dependency the @babel/preset-typescript will automatically get loaded when you use the default babel config that comes with kcd-scripts. If you customized your .babelrc-file you might need to manually add @babel/preset-typescript to the presets-section.

kcd-scripts will automatically load any .ts and .tsx files, including the default entry point, so you don't have to worry about any rollup configuration.

If you have a typecheck script (normally set to kcd-scripts typecheck) that will be run as part of the validate script (which is run as part of the pre-commit script as well).

TypeScript definition files will also automatically be generated during the build script.

Inspiration

This is inspired by react-scripts.

Other Solutions

If you are aware of any please make a pull request and add it here! Again, this is a very specific-to-me solution.

  • Rollpkg - convention over config build tool to create packages with TypeScript and Rollup.
  • bebbi-scripts - like kcd-scripts but βœ… tsc, βœ… esm/cjs/types, βœ… in TS, βœ… yarn 3, βœ… init package.json, βœ… yarn workspace, βœ… extensible (babel, storybook, ..), 🚫 yarn pnp, 🚫 npm

Issues

Looking to contribute? Look for the Good First Issue label.

πŸ› Bugs

Please file an issue for bugs, missing documentation, or unexpected behavior.

See Bugs

πŸ’‘ Feature Requests

Please file an issue to suggest new features. Vote on feature requests by adding a πŸ‘. This helps maintainers prioritize what to work on.

See Feature Requests

Contributors ✨

Thanks goes to these people (emoji key):

Kent C. Dodds
Kent C. Dodds

πŸ’» πŸ“– πŸš‡ ⚠️
Suhas Karanth
Suhas Karanth

πŸ’» πŸ› ⚠️
Matt Parrish
Matt Parrish

πŸ’» ⚠️
Mateus
Mateus

πŸ’» ⚠️
Macklin Underdown
Macklin Underdown

πŸ’» ⚠️
stereobooster
stereobooster

πŸ’» ⚠️
Dony Sukardi
Dony Sukardi

πŸ› πŸ’»
Alexander Nanberg
Alexander Nanberg

πŸ’»
Alex Liang
Alex Liang

πŸ’»
Jeff Detmer
Jeff Detmer

πŸ’»
Alex Zherdev
Alex Zherdev

πŸ’»
Adam Harrington
Adam Harrington

πŸ’» ⚠️
AdriΓ  Fontcuberta
AdriΓ  Fontcuberta

πŸ’»
Eric Berry
Eric Berry

πŸ”
Jared Schaab
Jared Schaab

πŸ’» ⚠️
Bitcollage
Bitcollage

πŸ’»
MichaΓ«l De Boey
MichaΓ«l De Boey

πŸ’» πŸ‘€
Weyert de Boer
Weyert de Boer

πŸ’»
Jakub JastrzΔ™bski
Jakub JastrzΔ™bski

πŸ’»
Lukas
Lukas

πŸ’» πŸ“–
Rahim Alwer
Rahim Alwer

πŸ’»
Vincent Ricard
Vincent Ricard

πŸ’»
Tim Deschryver
Tim Deschryver

πŸ’»
Eddy Wilson
Eddy Wilson

πŸ‘€
Ricardo Busquet
Ricardo Busquet

πŸ‘€
Peter HozΓ‘k
Peter HozΓ‘k

πŸ‘€
Marco Moretti
Marco Moretti

πŸ’»
Rafael Pedicini
Rafael Pedicini

πŸ“–
Michael Peyper
Michael Peyper

πŸ’»
HOU Ce
HOU Ce

πŸ’»
Ari PerkkiΓΆ
Ari PerkkiΓΆ

πŸ’» ⚠️
Sebastian Silbermann
Sebastian Silbermann

πŸ’»
Nicolas Stepien
Nicolas Stepien

πŸ’»
Varun
Varun

πŸ“–
Nick McCurdy
Nick McCurdy

πŸ’»
Sai Maheshwar
Sai Maheshwar

πŸ’»

This project follows the all-contributors specification. Contributions of any kind welcome!

LICENSE

MIT

kcd-scripts's People

Contributors

adamdharrington avatar afontcu avatar alexandernanberg avatar allcontributors[bot] avatar andarist avatar andrewcsontos avatar andrewmcodes avatar ariperkkio avatar ashiknesin avatar benmonro avatar donysukardi avatar eliperkins avatar eps1lon avatar fobbyal avatar houce avatar j-u-p-iter avatar jeffdetmer avatar jrolfs avatar kentcdodds avatar kubajastrz avatar macklinu avatar marcosvega91 avatar michaeldeboey avatar mihar-22 avatar nickmccurdy avatar pbomb avatar schaab avatar serkansipahi avatar sudo-suhas avatar weyert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kcd-scripts's Issues

TypeScript support

Hi, I wanted to start working on testing-library/dom-testing-library#494 but it seems like kcd-scripts doesn't support transpilation of TypeScript files.

  • kcd-scripts version: 5.6.1
  • node version: 12.11.0
  • npm (or yarn) version: N/A

What you did:

I cloned https://github.com/testing-library/dom-testing-library, renamed src/index.js to src/index.ts and started working on enabling TS support.

Changing input file was easy:

cross-env BUILD_INPUT=src/index.ts kcd-scripts build

I've added typescript and @babel/preset-typescript dependencies and babel config:

// babel.config.js
module.exports = {
  presets: ['kcd-scripts/babel', '@babel/preset-typescript'],
}

This is where the issue comes. Because kcd-scripts doesn't support overriding rollup plugins, I can't add extensions: ['.js, '.ts'] to rollupBabel and nodeResolve plugins. Also, I need to use runtimeHelpers: true for some reason, but I use custom babel config so this line is stopping me as well:

runtimeHelpers: useBuiltinConfig,

Problem description:

I need to customize some plugins in rollup configuration.

Suggested solutions (pick one):

  1. Support TypeScript extensions and change runtimeHelpers: true under some condition. A flag maybe? Or automatic detection based on input file extension?
  2. Same as above but without any condition, I don't think it will add that much build overhead but this is something to check.
  3. Allow overriding certain rollup plugins.

This is how I visualize 3rd option:

// kcd-scripts' rollup.config.js
const builtinPlugins = {babel: rollupBabel(...), resolve: nodeResolve(...), ...};
module.exports = { 
  input, 
  output,
  ..., 
  plugins: Object.values(builtinPlugins),
  builtinPlugins,
}
// custom usage rollup.config.js
const rollupConfig = require('kcd-scripts/dist/config/rollup.config')
const rollupBabel = require('rollup-plugin-babel')

rollupConfig.builtinPlugins.babel = rollupBabel({
  extensions: ['.js', '.ts'],
  runtimeHelpers: true,
}),

rollupConfig.plugins = Object.values(builtinPlugins)
module.exports = rollupConfig

Add A Helpful Error for Node Versions less than 8.x

  • kcd-scripts version: v0.25.1
  • node version: v7.4
  • npm (or yarn) version: v5.4.2

Relevant code or config

npm run build

What you did:
Ran this command on Node v7

What happened:
Got an output that did not indicate Node v8 was required.

> [email protected] build /Users/ianjones/Desktop/egghead-dev/kcd-scripts
> node src build

/Users/ianjones/Desktop/egghead-dev/kcd-scripts/src/index.js:18
    )
    ^
SyntaxError: Unexpected token )
    at Object.exports.runInThisContext (vm.js:78:16)
    at Module._compile (module.js:543:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:420:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:535:3

Problem description:
This seems to cause issues with projects that depend on kcd-scripts. Here is a reference:
kentcdodds/generator-kcd-oss#6

It is a more straight-forward error when you experience it in the context of this project. It is likely confusing for someone who would run into this using generator-kdc-oss.

Suggested solution:
Print an error telling the user that Node v8 is required.

High-level visibility of configurations

  • kcd-scripts version: 6.2.3
  • node version: 12.16.1
  • npm (or yarn) version: 6.13.4

Relevant code or config

all the config produced by kcd-scripts

What you did:

i introduced kcd-scripts to our team in order to set up a clear repeateable process

What happened:

we now have a consistent means of deploying configuration to our projects, but our team has a weak understanding of what rules we have subjected ourselves to.

Problem description:

trying to understand what eslint and what babel configuration we have is a bit complicated, as there are numerous different configurations that are combined (in eslints case) and a variety of conditionals in the babelrc config generator. eslint in particular has been hard to understand.

Suggested solution:

it would be lovely to have a way to preview the aggregated eslint rules, for example. i'm less sure what could be done about, for example, babel, but that's less difficult to understand.

kcd-scripts build --no-clean fails

  • kcd-scripts version: 1.11.0
  • node version: 10
  • npm (or yarn) version: yarn 1.19.2

Relevant code or config

What you did:

$ kcd-scripts build --no-clean

What happened:

yarn build:main
yarn run v1.19.2
$ kcd-scripts build --no-clean
error: unknown option '--no-clean'
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Reproduction repository:

https://github.com/testing-library/react-testing-library

Problem description:

@babel/[email protected] no longer silently ignores excess args (babel/babel#10698)

Suggested solution:

Pin @babel/cli to 7.7.0 in short term and use proper arg parsing and forwarding in the long term

Pragma for Preact build is incorrect

  • kcd-scripts version: 0.39.1
  • node version: 10.4.1
  • npm (or yarn) version: [email protected]

Relevant code or config

{
  plugins: [
   ... 
   isPreact
      ? [require.resolve('babel-plugin-transform-react-jsx'), {pragma: 'h'}]
      : null,
}

What you did: Build a preact bundle that includes JSX

What happened: JSX gets transformed to just h instead of React.h where React is Preact and h is undefined when trying to run the code with the built bundle.

Reproduction repository: https://github.com/donysukardi/kcd-scripts-preact-issue

Problem description: Pragma for Preact build is incorrect

Suggested solution: Update pragma to 'React.h' instead of just 'h'

Allow users to override the configuration of `browserslist`

  • kcd-scripts version: 0.36.1
  • node version: 8.10.0
  • npm (or yarn) version: 5.8.0

Relevant code or config

const symbol = Symbol();

What you did:

I use the Symbol in my code, and I expect that it would be transformed into the higher compatibility version in ES5.

What happened:

I can't do this due to the default browsers need to be supported the repo specified can't meet my needs.

Reproduction repository:

Problem description:

I read the source codes of babel-preset-env and browserslist and this repo. I make sure that this is because of that browserslist take the passed query higher priority than the config (package.json or config file). So once you specified the query like the following:

https://github.com/kentcdodds/kcd-scripts/blob/master/src/config/babelrc.js#L13

Suggested solution:

The users like me could not override this in any way. Standing in the perspective of babel-preset-env or browserslist, it takes the query in the plugin options higher priority than the config file is reasonable. The kcd-scripts encapsulate these configurations. So it should treat the browsers list like .babelrc, if the configuration file exists, use that instead of the built-in.

https://github.com/browserslist/browserslist/blob/master/index.js#L186-L193

Doesn't work with Windows, partially becasue of lint-staged

  • kcd-scripts version: 0.14.2
  • node version: 8.2.1
  • npm (or yarn) version: 4.0.5

Relevant code or config

https://github.com/okonet/lint-staged/blob/58ea81805272acd89bf23c98b8c1a88ad343456d/src/findBin.js#L35

What you did:

git commit

What happened:

[22:16:18] Running tasks for **/*.+(js|json|less|css|ts) [started]
[22:16:18] Running tasks for .all-contributorsrc [started]
[22:16:18] Running tasks for .all-contributorsrc [skipped]
[22:16:18] β†’ No staged files match .all-contributorsrc
[22:16:18] C:\Program Files (x86)\Nodist\v-x64\8.2.1\node.exe C:\Users\junyoung\Documents\WebProject\TypeScript\glamorous\node_modules\kcd-scripts\dist\index.js format [started]
[22:16:18] C:\Program Files (x86)\Nodist\v-x64\8.2.1\node.exe C:\Users\junyoung\Documents\WebProject\TypeScript\glamorous\node_modules\kcd-scripts\dist\index.js format [failed]
[22:16:18] β†’ C:\Program could not be found. Try `npm install C:\Program`.
[22:16:18] Running tasks for **/*.+(js|json|less|css|ts) [failed]
[22:16:18] β†’ C:\Program could not be found. Try `npm install C:\Program`.
C:\Program could not be found. Try `npm install C:\Program`.

Suggested solution:

Well, let's wait the response in lint-staged/lint-staged#292
or fix https://github.com/kentcdodds/kcd-scripts/blob/master/src/config/lintstagedrc.js

babel-plugin-minify-dead-code-elimination removes function names

  • kcd-scripts version: 7.5.3
  • node version: 12.20.0
  • npm (or yarn) version: 6.14.8

Relevant code or config

export function createFunc1() {
  function func() {
  }
  return func
}

export function createFunc2() {
  function func() {
  }
  const name = func.name // not returned, just used
  return func
}

What you did:

Run kcd-scripts build

What happened:

The output is

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.createFunc1 = createFunc1;
exports.createFunc2 = createFunc2;

function createFunc1() {
  return function () {};
}

function createFunc2() {
  function func() {}

  func.name; // not returned, just used

  return func;
}

Reproduction repository:

Babel REPL

Problem description:

The name of the function returned in createFunc1 gets removed thanks to babel-plugin-minify-dead-code-elimination. This is causing me problems in a node package (specifically a testing library) where the name gets removed and consequently does not appear in stack traces which hurts debugability when things go wrong.

I can understand the desire to remove this when building for browsers (reduced bundle size), but I don't personally see many advantages to this for a node/test package.

Suggested solution:

There is an option to keep function names in the plugin, so we could set that the be true and keep the rest of the functionality. We could use the isTest flag to conditionally set the option for tests only.

Similarly, we could use the isTest flag to remove the plugin all together for tests.

Either solution would suffice for my issue. I'm also happy to submit the PR for this change if you agree with it and can advise me which approach is your preference.

Environment key "jest/globals" is unknown

  • kcd-scripts version: 1.5.2
  • node version: 12.6.0
  • npm (or yarn) version: Yarn 1.12.1

Relevant code or config

I fave the following script in my package.json "lint": "kcd-scripts lint --config .eslintrc.js --ignore-path .eslintignore"

My eslintrc.js file contains:

module.exports = {
	extends: './node_modules/kcd-scripts/eslint.js',
	rules: {
		'import/extensions': [
			'error',
			{
				json: 'always',
				js: 'never',
				css: 'off',
				jpg: 'always',
				png: 'always',
				JPG: 'always',
			},
		],
		'react/prop-types': 'warn',
	},
}

What you did:
Ran script yarn run lint

What happened:
The result is in a eslint config validator error Environment key "jest/globals" is unknown

Jeffs-Air:SpacePoints jeffbaumgardt$ yarn run lint
yarn run v1.12.1
$ kcd-scripts lint --config .eslintrc.js --ignore-path .eslintignore
Error: .eslintrc.js Β» ./node_modules/kcd-scripts/eslint.js Β» /Users/jeffbaumgardt/Node/SpacePoints/node_modules/kcd-scripts/node_modules/eslint-config-kentcdodds/jest.js:
        Environment key "jest/globals" is unknown

    at /Users/jeffbaumgardt/Node/SpacePoints/node_modules/kcd-scripts/node_modules/eslint/lib/shared/config-validator.js:169:19
    at Array.forEach (<anonymous>)
    at validateEnvironment (/Users/jeffbaumgardt/Node/SpacePoints/node_modules/kcd-scripts/node_modules/eslint/lib/shared/config-validator.js:163:30)
    at validateConfigArray (/Users/jeffbaumgardt/Node/SpacePoints/node_modules/kcd-scripts/node_modules/eslint/lib/shared/config-validator.js:334:9)
    at CascadingConfigArrayFactory._finalizeConfigArray (/Users/jeffbaumgardt/Node/SpacePoints/node_modules/kcd-scripts/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:392:13)
    at CascadingConfigArrayFactory.getConfigArrayForFile (/Users/jeffbaumgardt/Node/SpacePoints/node_modules/kcd-scripts/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:248:21)
    at FileEnumerator._iterateFilesRecursive (/Users/jeffbaumgardt/Node/SpacePoints/node_modules/kcd-scripts/node_modules/eslint/lib/cli-engine/file-enumerator.js:400:49)
    at _iterateFilesRecursive.next (<anonymous>)
    at FileEnumerator.iterateFiles (/Users/jeffbaumgardt/Node/SpacePoints/node_modules/kcd-scripts/node_modules/eslint/lib/cli-engine/file-enumerator.js:254:49)
    at iterateFiles.next (<anonymous>)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Reproduction repository:
https://github.com/JeffBaumgardt/testingCRA-KCDScripts
This is a fresh install of CRA and kcd-scripts only files added are the .eslintignore and .eslintrc.js files. Added lint script to package.json

Problem description:
The config validator for eslint is complaining about the env flag for jest/globals. I'm not sure why as this is a valid flag per the eslint-plugin-jest plugin. I've looked around and have not been able to find any information pertaining to this issue. On eslint-plugin-jest, eslint, or eslint-config-kentcdodds.

If this issue is better placed in the eslint-config-kentcdodds repo I will be happy to add it there.

Suggested solution:
I don't have any good ideas at the moment.

Endless chain of unfound plugins for ESLint

  • kcd-scripts version: 0.25.1
  • node version: 8.6.0
  • npm (or yarn) version: yarn 1.1.0
  • OS: Mac OS Sierra (10.12.6)

What you did:
yarn add -D kcd-scripts
yarn lint:js -> kcd-scripts lint

What happened:

Basically a series of errors saying that some plugin or config is not found, after I run the lint command.

screen shot 2017-10-13 at 7 41 01 pm

Problem description:
I'm trying to move my existing project to use CRA for production build (codesplitting, etc.) and kcd-scripts for dev (linting, prettier, precommit) to avoid config bloat and hide all of the webpack + babel mess. CRA was no problem, but as I moved to dev workflow, trying to run kcd-scripts lint resulted in missing some sort of plugin or config. After doing yarn add -D the_missing_thing and repeating the lint command it spat out anther missing dep and so on. I've continued installing more and more of these and each time kcd-scripts lint took more and more time to run.
I'm currently on my 10th missing module and I don't think it should be this way :)
The whole point of the toolkits is to encapsulate dependencies and I get this:

screen shot 2017-10-13 at 7 42 30 pm

Suggested solution:
I think that eslint's module-resolver is scanning all modules in node_modules and pulling their eslint-configs and then it throws when it doesn't find something. But I'm not sure, it's a wild guess based from the error and I'm pretty sure kcd-scripts does not need stuff like cssnano to run.
TBH I don't know why I even have that in my dependencies, but it's node - not surprising:)

Thank you for your work @kentcdodds, I really enjoy all of the OSS things you do.

pre-commit script: doctoc.js could not be found

  • kcd-scripts version: 0.37.0
    because of the potential breaking change in 0.38, I decided not to upgrade
  • node version: 0.8.4
  • npm version: 0.5.3
  • windows version: 10

What you did:

While working on the PR for cypress-testing-library, I thought I'd enable the pre-commit hook. So I added the .opt-in file and added the pre-commit text to it. Then I did the git commit (both SourceTree and command line)

What happened:

Running tasks for README.md [started]
Running tasks for README.md [failed]
β†’ .\node_modules\doctoc\doctoc.js could not be found. Try `npm install .\node_modules\doctoc\doctoc.js`.

doctoc.js does exist in the node_modules folder.

External packages not working

  • kcd-scripts version: 0.48.0
  • node version: v11.3.0
  • npm (or yarn) version:
import DatePicker from 'react-datepicker'

(see index.js)

What you did:
I am trying to make my own component library for frequently used components, and reducers etc. As long I am doing npm run build it's all working fine but when I am trying to run npm run build --bundle it's failing for theumd-build with the following error:

[umd] [!] (babel plugin) TypeError: @babel/template placeholder "NODE": Property expression of ExpressionStatement expected node to be of a type ["Expression"] but instead got "VariableDeclarator"
[umd] node_modules/react-datepicker/es/index.js
[umd] TypeError: @babel/template placeholder "NODE": Property expression of ExpressionStatement expected node to be of a type ["Expression"] but instead got "VariableDeclarator"

What happened:

After executing the command ./node_modules/.bin/kcd-scripts build --bundle --no-clean --size-snapshot as found in the paypal/downshift-repo. I am getting the above mentioned error. I am not sure how I could resolve this.

Reproduction repository:
I have made a small reproducible case of my issue:
https://github.com/weyert/kcd-scripts-issue

Problem description:
I am doing something wrong when using third-party packages but not sure what. I think the problem that this package react-datepicker is already precompiled.

Suggested solution:

The automated release is failing 🚨

🚨 The automated release from the next branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the next branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


The release 6.1.0 on branch next cannot be published as it is out of range.

Based on the releases published on other branches, only versions within the range >=6.3.0 can be published from branch next.

The following commit is responsible for the invalid release:

This commit should be moved to a valid branch with git merge or git cherry-pick and removed from branch next with git revert or git reset.

A valid branch could be master or next.

See the workflow configuration documentation for more details.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

pre-commit hook fails for no reason

  • kcd-scripts version: 0.0.0-semantically-released πŸ˜‰
  • node version: 8.5.0
  • npm version: 5.3.0
  • yarnversion: 1.0.2

What you did:
git commit

What happened:

husky > npm run -s precommit (node v8.5.0)

25l[09:24:02] Running tasks for **/*.+(js|json|less|css|ts) [started]
[09:24:02] Running tasks for .all-contributorsrc [started]
[09:24:02] Running tasks for .all-contributorsrc [skipped]
[09:24:02] β†’ No staged files match .all-contributorsrc
[09:24:02] kcd-scripts format [started]
[09:24:03] kcd-scripts format [completed]
[09:24:03] kcd-scripts lint [started]
[09:24:05] kcd-scripts lint [completed]
[09:24:05] kcd-scripts test --findRelatedTests [started]
[09:24:07] kcd-scripts test --findRelatedTests [completed]
[09:24:07] git add [started]
[09:24:07] git add [completed]
[09:24:07] Running tasks for **/*.+(js|json|less|css|ts) [completed]
25h25h
husky > pre-commit hook failed (add --no-verify to bypass)
verbose npm output
husky > npm run -s precommit (node v8.5.0)


> [email protected] precommit E:\Projects\repos\kcd-scripts
> node src precommit

25l[09:25:15] Running tasks for **/*.+(js|json|less|css|ts) [started]
[09:25:15] Running tasks for .all-contributorsrc [started]
[09:25:15] Running tasks for .all-contributorsrc [skipped]
[09:25:15] β†’ No staged files match .all-contributorsrc
[09:25:15] kcd-scripts format [started]
[09:25:16] kcd-scripts format [completed]
[09:25:16] kcd-scripts lint [started]
[09:25:18] kcd-scripts lint [completed]
[09:25:18] kcd-scripts test --findRelatedTests [started]
[09:25:20] kcd-scripts test --findRelatedTests [completed]
[09:25:20] git add [started]
[09:25:20] git add [completed]
[09:25:20] Running tasks for **/*.+(js|json|less|css|ts) [completed]
25h25hnpm WARN invalid config access=undefined
npm WARN invalid config also=undefined
npm WARN invalid config https-proxy=undefined
npm WARN invalid config Must be a full url with 'http://'
npm WARN invalid config init-author-url=undefined
npm WARN invalid config Must be a full url with 'http://'
npm WARN invalid config only=undefined
npm WARN invalid config proxy=undefined
npm WARN invalid config Must be a full url with 'http://'
npm WARN onload-script failed to require onload script undefined
npm WARN onload-script Error: Cannot find module 'undefined'
npm WARN onload-script     at Function.Module._resolveFilename (module.js:527:15)
npm WARN onload-script     at Function.Module._load (module.js:476:23)
npm WARN onload-script     at Module.require (module.js:568:17)
npm WARN onload-script     at require (internal/module.js:11:18)
npm WARN onload-script     at cb (C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:225:11)
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:356:16
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:81:7
npm WARN onload-script     at Array.forEach (<anonymous>)
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:80:13
npm WARN onload-script     at f (C:\nvm\v8.5.0\node_modules\npm\node_modules\once\once.js:25:25)
npm WARN onload-script  { Error: Cannot find module 'undefined'
npm WARN onload-script     at Function.Module._resolveFilename (module.js:527:15)
npm WARN onload-script     at Function.Module._load (module.js:476:23)
npm WARN onload-script     at Module.require (module.js:568:17)
npm WARN onload-script     at require (internal/module.js:11:18)
npm WARN onload-script     at cb (C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:225:11)
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:356:16
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:81:7
npm WARN onload-script     at Array.forEach (<anonymous>)
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:80:13
npm WARN onload-script     at f (C:\nvm\v8.5.0\node_modules\npm\node_modules\once\once.js:25:25)
npm WARN onload-script   stack: 'Error: Cannot find module \'undefined\'\n    at Function.Module._resolveFilename (module.js:527:15)\n    at Function.Module._load (module.js:476:23)\n    at Module.require (module.js:568:17)\n    at require (internal/module.js:11:18)\n    at cb (C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\npm.js:225:11)\n
    at C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\npm.js:356:16\n    at C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\config\\core.js:81:7\n    at Array.forEach (<anonymous>)\n    at C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\config\\core.js:80:13\n    at f (C:\\nvm\\v8.5.0\\node_modules\\npm\\node_modules\\once\\once.js:25:25)',
npm WARN onload-script   code: 'MODULE_NOT_FOUND' }
npm WARN invalid config access=undefined
npm WARN invalid config also=undefined
npm WARN invalid config https-proxy=undefined
npm WARN invalid config Must be a full url with 'http://'
npm WARN invalid config init-author-url=undefined
npm WARN invalid config Must be a full url with 'http://'
npm WARN invalid config only=undefined
npm WARN invalid config proxy=undefined
npm WARN invalid config Must be a full url with 'http://'
npm WARN onload-script failed to require onload script undefined
npm WARN onload-script Error: Cannot find module 'undefined'
npm WARN onload-script     at Function.Module._resolveFilename (module.js:527:15)
npm WARN onload-script     at Function.Module._load (module.js:476:23)
npm WARN onload-script     at Module.require (module.js:568:17)
npm WARN onload-script     at require (internal/module.js:11:18)
npm WARN onload-script     at cb (C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:225:11)
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:356:16
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:81:7
npm WARN onload-script     at Array.forEach (<anonymous>)
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:80:13
npm WARN onload-script     at f (C:\nvm\v8.5.0\node_modules\npm\node_modules\once\once.js:25:25)
npm WARN onload-script  { Error: Cannot find module 'undefined'
npm WARN onload-script     at Function.Module._resolveFilename (module.js:527:15)
npm WARN onload-script     at Function.Module._load (module.js:476:23)
npm WARN onload-script     at Module.require (module.js:568:17)
npm WARN onload-script     at require (internal/module.js:11:18)
npm WARN onload-script     at cb (C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:225:11)
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\npm.js:356:16
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:81:7
npm WARN onload-script     at Array.forEach (<anonymous>)
npm WARN onload-script     at C:\nvm\v8.5.0\node_modules\npm\lib\config\core.js:80:13
npm WARN onload-script     at f (C:\nvm\v8.5.0\node_modules\npm\node_modules\once\once.js:25:25)
npm WARN onload-script   stack: 'Error: Cannot find module \'undefined\'\n    at Function.Module._resolveFilename (module.js:527:15)\n    at Function.Module._load (module.js:476:23)\n    at Module.require (module.js:568:17)\n    at require (internal/module.js:11:18)\n    at cb (C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\npm.js:225:11)\n
    at C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\npm.js:356:16\n    at C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\config\\core.js:81:7\n    at Array.forEach (<anonymous>)\n    at C:\\nvm\\v8.5.0\\node_modules\\npm\\lib\\config\\core.js:80:13\n    at f (C:\\nvm\\v8.5.0\\node_modules\\npm\\node_modules\\once\\once.js:25:25)',
npm WARN onload-script   code: 'MODULE_NOT_FOUND' }

> [email protected] validate E:\Projects\repos\kcd-scripts
> node src validate

npm ERR! file undefined
npm ERR! path undefined
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn undefined
npm ERR! [email protected] validate: `node src validate`
npm ERR! spawn undefined ENOENT
npm ERR!
npm ERR! Failed at the [email protected] validate script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! code ELIFECYCLE
npm ERR! errno -4058
npm ERR! [email protected] validate: `node src validate`
npm ERR! Exit status -4058
npm ERR!
npm ERR! Failed at the [email protected] validate script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\suhas.karanth\AppData\Roaming\npm-cache\_logs\2017-09-19T03_55_21_615Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] precommit: `node src precommit`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] precommit script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\suhas.karanth\AppData\Roaming\npm-cache\_logs\2017-09-19T03_55_21_791Z-debug.log

husky > pre-commit hook failed (add --no-verify to bypass)

Problem description:

This is related to the issue I had faced with opt-cli - ta2edchimp/opt-cli#213.
Invoking spawn with env having undefined values breaks npm.

Suggested solution:

While I know how to fix the issue, in kcd-scripts, I am wondering if the fix should be in cross-spawn or even npm.

Getting babelHelpers is not defined

Changes in rollup/rollup-plugin-babel@f8182c6 (v3.0.6) seem to be breaking the rollup build which was previously working fine.

Since this library is not committing lock file, rollup-plugin-babel@^3.0.3 gets resolved to 3.0.6.

I am getting babelHelpers is not defined error when trying to run the build artefact.

image

It seems to be working fine after I remove "babel-plugin-external-helpers" plugin from .babelrc though.

Reference: rollup/rollup-plugin-babel#228

Environment key "jest/globals" is unknown

  • kcd-scripts version: 7.5.3
  • node version: 10.22.0
  • npm (or yarn) version: yarn 1.22.5

Relevant code or config

  "eslintConfig": {
    "extends": "./node_modules/kcd-scripts/eslint.js",
     ...
  },
  "husky": {
    "hooks": {
      "pre-commit": "kcd-scripts pre-commit"
    }
  },

What you did:
Trying to make a commit on the Downshift library I get an error when kcd-scripts lint is running.

What happened:

❯ git commit -m "fix: test"
husky > pre-commit (node v10.22.0)
βœ” Preparing...
⚠ Running tasks...
  ↓ No staged files match README.md [SKIPPED]
  ❯ kcd-scripts lint [FAILED]
    βœ” kcd-scripts format
    βœ– kcd-scripts lint [FAILED]
    β—Ό kcd-scripts test --findRelatedTests
↓ Skipped because of errors from tasks. [SKIPPED]
βœ” Reverting to original state because of errors...
βœ” Cleaning up...

βœ– kcd-scripts lint:

Oops! Something went wrong! :(

ESLint: 7.15.0

Error: package.json Β» ./node_modules/kcd-scripts/eslint.js Β» /Users/jorge.moya/dev/downshift/node_modules/kcd-scripts/node_modules/eslint-config-kentcdodds/jest.js:
        Environment key "jest/globals" is unknown

    at Object.keys.forEach.id (/Users/jorge.moya/dev/downshift/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:173:23)
    at Array.forEach (<anonymous>)
    at ConfigValidator.validateEnvironment (/Users/jorge.moya/dev/downshift/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:167:34)
    at ConfigValidator.validateConfigArray (/Users/jorge.moya/dev/downshift/node_modules/@eslint/eslintrc/lib/shared/config-validator.js:317:18)
    at CascadingConfigArrayFactory._finalizeConfigArray (/Users/jorge.moya/dev/downshift/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js:493:23)
    at CascadingConfigArrayFactory.getConfigArrayForFile (/Users/jorge.moya/dev/downshift/node_modules/@eslint/eslintrc/lib/cascading-config-array-factory.js:299:21)
    at FileEnumerator._iterateFilesWithFile (/Users/jorge.moya/dev/downshift/node_modules/kcd-scripts/node_modules/eslint/lib/cli-engine/file-enumerator.js:365:43)
    at FileEnumerator._iterateFiles (/Users/jorge.moya/dev/downshift/node_modules/kcd-scripts/node_modules/eslint/lib/cli-engine/file-enumerator.js:346:25)
    at FileEnumerator.iterateFiles (/Users/jorge.moya/dev/downshift/node_modules/kcd-scripts/node_modules/eslint/lib/cli-engine/file-enumerator.js:296:59)
    at iterateFiles.next (<anonymous>)
husky > pre-commit hook failed (add --no-verify to bypass)

Reproduction repository: https://github.com/downshift-js/downshift/

I wasn't sure if it was best to report this issue here on in eslint-config-kentcdodds. Let me know if I should move the issue somewhere else, thank you.

lintstagedrc.js failes on Windows

  • node version: 10.10.0
  • npm (or yarn) version: 6.0.0

Relevant code or config

npm run precommit

Problem description:

I'm working on a fork of kcd-scripts for my own company's purposes and while testing the lintstagedrc.js file failes on Windows. Probably has to do with #8 or is very similar. I also noticed this when working on React-Testing-Library when I went to commit, again lintstagedrc.js fails.

Unfortunately I'm not versed enough in the fs and path operators to figure out how to change \ for /. Unless we write a dirty method to check for win32 and do a global replace on the path string, tranding slashes. But I don't know what other problems might arise from that.

Some Ideas

Hi,

This is a not bug report. I want to thank you for the toolkit. Previously I used a toolkit similar to this idea from Walmart Labs (don't remember name), but kcd-scripts is more feature rich.

I implemented a derived version of kcd-scripts and would like to share a few ideas back here, hoping they are useful for others and hear what they think about them. My derivation is for typescript, but ideas are general.

  • init script: Since there are tons of config files, this script generates necessary files in project directory, and creates script entries in package.json. For example:
    • Files such as .gitattributes, .gitignore, .prettierrc.js are generated.
    • build, test, validate etc. scripts entries are created.
    • Files which cannot inherit from another file, such as .gitattributes, is created as symlink to some base file in kcd-scripts. So whenever original file is updated, this files acts as updated as well.
    • Also typescript configuration must be in root folder of project, so it is also generated as symlink.
    • Some files are not needed to be in project folder to kcd-scripts work. However, IDEs are expecting them in project folder to be functional. For example WebStorm looks for .eslintrc, tsconfig.json etc. Those files are generated as inheriting from originals, so IDEs can find them, and they are up to date when kcd-scripts are updated.
    • Other related files mentioned below ideas are also generated.
    • init script is automatically executed via scripts.install entry in package.json, when the module is installed.
  • Added TypeScript related scripts.
  • Added TSLint scripts.
  • Moved scripts.precommit entry to .huskyrc.js file, because it will be deprecated in next version of `husky``
  • Added jsdoc2md script and readme.hbs template with doctoc support, which generates API docs both for JavaScript and TypeScript.

I didn't publish it yet, because it is still rough.

@kentcdodds, as the creator of original toolkit and experienced user of it, I would like to hear what do you think about those. Are there any caveats/pitfalls or any suggestions?

Kind Regards,

Scoped package name is resulting into weird path in dist/

Hi @kentcdodds!

Thanks for the scripts, very cool project. I've been looking for something like this for a few months and how happy I was to find this. πŸ™‚

I have stumbled upon a little issue. The scoped packages are getting unconventional build artifacts.

@namespace/package-name is getting a file structure that reflects the name /dist/@namespace/package-name.umd.js

What do you think about converting @namespace/package-name -> namespace-package-name or maybe even dropping the namespace if it is present?

Please feel free to close this if you don't find it relevant or necessary. I'm willing to send a quick PR if this makes sense.

[Build Fails]: Cannot find module 'kcd-scripts/babel'

I'm trying to use this module to replace babel in the below project but getting errors. Any help is appreciated.

Git repo : https://github.com/chandanrjit/react-webpack-boilerplate

usage:

{"presets": ["kcd-scripts/babel"]}

ERROR in ./src/index.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module 'kcd-scripts/babel' from 'C:\workspace\code\research\react-webpack-boilerplate'
    at Function.resolveSync [as sync] (C:\workspace\code\research\react-webpack-boilerplate\node_modules\resolve\lib\sync.js:81:15)    at resolveStandardizedName (C:\workspace\code\research\react-webpack-boilerplate\node_modules\@babel\core\lib\config\files\plugins.js:101:31)

check prettier formatting in validate script

Without this, formatting is not checked in CI and only applied if the precommit hooks are installed, which is optional

Options:

  • Add prettier --list-different to validate command
  • Integrate prettier rules into ESLint (probably preferred for JS)

tsconfig conflicts with build

shared-tsconfig allow importing modules from src per module name.

"baseUrl": "../../src",

The IDE picks this up and suggests using non-relative imports.

kcd-scripts build does not support the import from baseUrl and resulting build is corrupt.

Suggested solution:

Remove the baseURL.

eslint error - Cannot find module '@ljharb/eslint-config'

  • kcd-scripts version: 0.37.0
  • node version: 9.11.1
  • npm version: 5.3.0

What you did:
Create fresh copy of create-react-app
install kcd-scripts as dev dependency
Add lint script to package.json

  • "lint": "kcd-scripts lint"

What happened:

Cannot find module '@ljharb/eslint-config'
Referenced from: C:\Node\test-project\node_modules\array-includes\.eslintrc
Error: Cannot find module '@ljharb/eslint-config'
Referenced from: C:\Node\test-project\node_modules\array-includes\.eslintrc
    at ModuleResolver.resolve (C:\Node\test-project\node_modules\kcd-scripts\node_modules\eslint\lib\util\module-resolve
r.js:74:19)

Reproduction repository:

I created a fresh copy of react-react-app
npx create-react-app test-project
No need for a production repo

Problem description:
I don't see @ljharb/eslint-config referenced in the internal eslint config for kcd-scripts so I don't know where this error is coming from. I can only assume it has something to do with array-includes package but I'm not 100%

Suggested solution:
I do not have a suggested solution at this time.

ReactDOM is misspelled as ReactDom in UMD files

I first issued this to the @testing-library/react but after debugging I found out this issue belongs to this project.

Looks like it's caused by https://github.com/kentcdodds/kcd-scripts/blob/master/src/config/rollup.config.js#L44. I don't know the reasoning behind this.


testing-library/react-testing-library#797

I noticed that the generated UMD files has incorrect spelling of ReactDOM. The "DOM" part is misspelled as "Dom".

Steps:

  • npm i @testing-library/react -SED
  • Search for ReactDom in ./node_modules/@testing-library

Screenshot 2020-10-12 at 17 39 49

How did I find this? Our company are using a legacy build system and we rely on globals everywhere and we are on way to migrate from Enzyme to this lib.

ESLint fails on Node 15

As can be seen in https://github.com/MichaelDeBoey/gatsby-plugin-instagram-embed/runs/2317212678#step:6:17 & https://github.com/robinmetral/gatsby-plugin-pinterest/pull/34/checks?check_run_id=2312829302#step:6:33, ESLint errors out on Node 15 with the following error:

Environment key "jest/globals" is unknown

Both packages only use the default ESLint config, without any changes.

I tried to figure out what could be wrong, but I can't find the problem tbh as jest/globals is set in kentcdodds/jest ESLint config: https://github.com/kentcdodds/eslint-config-kentcdodds/blob/6f2fc42262e63d3288f409e3e62317456d2aa328/jest.js#L29

Working fine on Node 14 and below though πŸ€”

Loose mode by default

I suggest using babel's loose mode by default, it allows you to ship quite less bytes of code to the end users and truth to be told, you shouldn't really miss most of default fully spec-compliant behaviours.

Babel removes test files from src directory after building

  • kcd-scripts version: 6.6.0
  • node version: 14.14.0
  • npm version: 6.14.8

Relevant code or config

$ kcd-scripts build --out-dir .

What you did:
Run npm run build in the root of the project

What happened:
src/__tests__/gatsby-node.js was deleted

Reproduction repository:
https://github.com/MichaelDeBoey/gatsby-plugin-pinterest/tree/support-pluginOptionsSchema

Problem description:
When implementing gatsby-uc/gatsby-plugin-pinterest#15 and running npm run build or npm run validate in the root of the project, src/__tests__/gatsby-node.js was deleted.

Suggested solution:
Investigation needed πŸ€”

@babel/runtime error

  • kcd-scripts version: 1.2.1
  • node version: 10.11.0
  • npm (or yarn) version: npm 6.9.0

Relevant code or config

  "scripts": {
    "test": "kcd-scripts test --config=jest.config.js"
  },

What you did:
npm run test
What happened:

Error: You should add @babel/runtime as dependency to your package. It will allow reusing "babel helpers" from node_modules rather than bundling their copies into your files.
    at Object.<anonymous> (/Users/bmonro001/Code/react-svelte/node_modules/kcd-scripts/dist/config/babelrc.js:33:9)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/bmonro001/Code/react-svelte/node_modules/kcd-scripts/dist/config/index.js:4:10)
    at Module._compile (internal/modules/cjs/loader.js:689:30)

Reproduction repository:
https://github.com/benmonro/react-svelte/tree/bug/kcd-script-error

Problem description:
why do i need to install @babel/runtime as a (non dev) dependency just to run tests?
Suggested solution:
have kcd-scripts not require that dep.

Incorrect `latest` version tag in NPM

  • kcd-scripts version 10.1.1/11.0.0:
  • node version: N/A
  • npm (or yarn) version: N/A

Relevant code or config

npm i kcd-scripts@latest

What you did:

Tried installing the latest version after the release notes for 10.1.0 told me about the accidental breaking changes and the reversion.

What happened:

Version 10.1.1. is installed instead of version 11.0.0.

Reproduction repository:

N/A

Problem description:

I assume it's a mistake that kcd-scripts@latest is pointing to 10.1.1 in NPM, right? https://www.npmjs.com/package/kcd-scripts?activeTab=versions

Suggested solution:

Push the latest tag to 11.0.0.

Could not parse lint-staged config.

  • kcd-scripts version: "0.38.1"
  • node version: v8.6.0
  • npm (or yarn) version: 5.5.1

Relevant code or config

What you did:

git commit -m "..."

What happened:

husky > npm run -s precommit (node v8.6.0)

Could not parse lint-staged config.

Error: Cannot find module './node_modules/kcd-scripts/dist/config/lintstagedrc.js'

Please make sure you have created it correctly.
See https://github.com/okonet/lint-staged#configuration.

husky > pre-commit hook failed (add --no-verify to bypass)

...
ls -la ./node_modules/kcd-scripts/dist/config/lintstaged.config.js
-rw-r--r--  1 xxx  zzz  707 May 21 12:05 ./node_modules/kcd-scripts/dist/config/lintstaged.config.js

Reproduction repository:

https://github.com/stereobooster/react-precious-image

Problem description:

lint-staged can not resolve path to the config properly

Suggested solution:

provide full path to the config (starting from the root)

Is it worth adding *.ts and *tsx to jest.config.js

  • kcd-scripts version: 0.27.2
  • node version: 9.3.0
  • yarn version: 1.3.2

Relevant code or config

  collectCoverageFrom: ['src/**/*.js'],
  testMatch: ['**/__tests__/**/*.js'],
  testPathIgnorePatterns: [...ignores],
  coveragePathIgnorePatterns: [...ignores, 'src/(umd|cjs|esm)-entry.js$'],
  transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'],

Problem description: This isn't a huge problem since the benefit of kcd-scripts is the ability to overwrite options. But, given the high number of typescript, it would be nice to not have to overwrite the same options every time.

Suggested solution: Before creating a PR, I wanted to pose the question to see what others thought. Is addin *.ts and *.jsx to jest.config.js a worthy thought?

Project starter based on kcd-scripts?

  • kcd-scripts version: N/A
  • node version: N/A
  • npm (or yarn) version: N/A

Relevant code or config N/A

What you did: N/A

What happened: N/A

Reproduction repository: N/A

Problem description:

How to bootstrap fresh project with kcd-scripts? For create-react-app I do

create-react-app project-name

Suggested solution:

Provide command to bootstrap fresh project or empty github repo which can be used as reference.

Fix resolveBin for windows

resolveBin:

kcd-scripts/src/utils.js

Lines 21 to 44 in bd3d642

function resolveBin(modName, {executable = modName, cwd = process.cwd()} = {}) {
let pathFromWhich
try {
pathFromWhich = fs.realpathSync(which.sync(executable))
} catch (_error) {
// ignore _error
}
try {
const modPkgPath = require.resolve(`${modName}/package.json`)
const modPkgDir = path.dirname(modPkgPath)
const {bin} = require(modPkgPath)
const binPath = typeof bin === 'string' ? bin : bin[executable]
const fullPathToBin = path.join(modPkgDir, binPath)
if (fullPathToBin === pathFromWhich) {
return executable
}
return fullPathToBin.replace(cwd, '.')
} catch (error) {
if (pathFromWhich) {
return executable
}
throw error
}
}

It's responsible for taking a module name (like eslint) and getting a path to the executable binary. If the path to the executable is the same as the one that's in the $PATH environment variable (using which), then we can return the raw binary name itself and execute a script with that, otherwise we'll return the full path so it's executed with the full path (because it's not available in $PATH presumably.

This is useful because if the user sees the script we run (which they do in some situations) then the script will be shorter.

It works on linux systems right now, but apparently the result of which.sync is to a file ending in .CMD and isn't a symlink (so the realpathSync doesn't resolve it to the binary path).

So we need to find a package that will do this for us (I already tried resolve-bin and it didn't work the way I want it to) or fix this function up to make it work for windows as well as linux.

Anyone wanna help out?

Warnings when installing with yarn

  • kcd-scripts version: 0.32.1
  • node version: 8.9.0
  • npm (or yarn) version: yarn 1.3.2

What you did:

yarn

What happened:

screen shot 2018-01-19 at 10 20 54 am

Problem description:

Just having a bunch of warnings, does not seem to affect how a module works.

Suggested solution:

Not sure the solution is needed, but Kent said that he's not using yarn, but npm instead, so I figured it wouldn't hurt to make you're aware of this.

`format` does not recognize all `prettier` config formats.

  • kcd-scripts version: 1.8.0
  • node version: 10.16.3
  • npm (or yarn) version: 6.11.3

Relevant code or config

# .prettierrc.toml
semi = true
singleQuote = false

What you did:

Added a local .prettierrc.toml and ran format.

What happened:

The local configuration was not respected.

Reproduction repository

Problem description: I have a local .prettierrc.toml and it is not being respected.

Suggested solution: Prettier uses cosmiconfig for configuration file support. Leverage cosmiconfig when looking for local configuration. It also handles inspecting package.json as well. I suspect you could leverage this with all the different commands eliminating the need to do the search yourself.

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


The release 6.4.0 on branch master cannot be published as it is out of range.

Based on the releases published on other branches, only versions within the range >=6.3.0 <6.4.0 can be published from branch master.

The following commit is responsible for the invalid release:

This commit should be moved to a valid branch with git merge or git cherry-pick and removed from branch master with git revert or git reset.

A valid branch could be next.

See the workflow configuration documentation for more details.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

Jest environment.teardown error with CRA (conflicting versions)

Note:

This is not an issue per se, but more of a heads-up/unofficial docs for people who encounter the same problem. However this can spark some discussions on how to manage versions of the external (app) and internal (toolbox) dependencies.

Env:

  • kcd-scripts ^0.42.1:
  • node: 8.11.3
  • yarn 1.9.4

What you did:

Use default pre-commit on CRA based repo.

What happened:

TypeError: environment.teardown is not a function

screen shot 2018-08-17 at 12 15 00 am

Problem description:

The issue is realated to the fact that CRA does not allow conflicting Jest versions.

Related issues for some background: jest#6393, jest#5119

Suggested solution:

Add lint-staged entry in your package.json, ultimately overwriting actions on pre-commit hook, something along these lines

  "lint-staged": {
    "*.js": [
      "yarn format",
      "yarn lint",
      "git add"
    ]
  },

Allow to debug unit tests, e.g. Visual Studio Code

  • kcd-scripts version: 0.48.0
  • node version: v11.3.0
  • npm (or yarn) version: 6.4.1

I would like to be able to debug unit tests and indirectly my library code from Visual Studio Code only currently I am not able to get it working easily. I think it might be related to the use of cross-spawn. The main problem is that Visual Studio passed --inspect-brk=33548 argument to the node while run-script expects the script name. E.g. kcd-scripts --inspect-brk=33548 test

How are you currently debugging the code base? E.g. downshift?

[pre-commit]: test step hangs due to --watch

  • kcd-scripts version: "kcd-scripts": "^7.5.3"
  • node version: v14.16.0
  • npm (or yarn) version: [email protected]
  • OS: Debian 10 running in crostini container in Chromeos

What you did:

Make change to code and create commit.

What happened:

kcd-scripts test --findRelatedTests hangs. Jest is passed --watch option due to SCRIPTS_PRE-COMMIT dropping somewhere in execution.

Reproduction repository:

  • @testing-library/dom-testing-library
  • @testing-library/react-testing-library
  • @testing-library/eslint-plugin-jest-dom

Problem description:

Some debug logs tracing SCRIPTS_PRE-COMMIT environment variable.

// Attempt to strt the script with the passed node arguments
const result = spawn.sync(
executor,
nodeArgs.concat(scriptPath).concat(args.slice(scriptIndex + 1)),
{
stdio: 'inherit',
env: getEnv(),
},
)

83 |  console.log(`SCRIPTS_PRE-COMMIT ${getEnv()['SCRIPTS_PRE-COMMIT']}`);
   |  ^^^ logs "SCRIPTS_PRE-COMMIT true" βœ…

result = spawn.sync(resolveBin('lint-staged'), [...config, ...args], {
stdio: 'inherit',
})

22 |  console.log('SCRIPTS_PRE-COMMIT', process.env['SCRIPTS_PRE-COMMIT']);
   |  ^^^ logs "SCRIPTS_PRE-COMMIT true" βœ…

kcd-scripts test run by lint-staged does not have same environment variables as processes spawned before.

// eslint-disable-next-line jest/no-jest-import
require('jest').run([...config, ...watch, ...args])

24 | console.log('SCRIPTS_PRE-COMMIT', process.env['SCRIPTS_PRE-COMMIT']);
   | ^^^ logs "SCRIPTS_PRE-COMMIT undefined" ❌
25 | console.log('watch', watch);
   | ^^^ logs "watch [ '--watch' ]" ❌

Suggested solution:

There's work-around to commit with CI=true.

My guess is that lint-staged or husky is not handling environment variables correctly. But I wonder why no one else is running into this.

Question: working with various eslint config wrinkles

Hi @kentcdodds, I apologize if this isn't the best place to ask this question, but I'm working on a custom scripts toolkit of my own, borrowing heavily from kcd-scripts, so I thought this might help others who were similarly inspired by this project.

I've started off by re-implementing your linting approach almost directly, and I'm harvesting eslint config from the existing projects I'm supporting, but I'd like to pick your brain about handling a couple various eslintrc wrinkles in my toolkit's config/eslintrc.js.

First, how would you deal with exporting things like "recommended" configs from plugins? I see you use require.resolve in your implementation (which, I assume is done to ensure you're exporting config from the toolkit's node_modules instead of the consuming project's node_modules), but I'm not quite sure how that might map to usages like this:

extends: [
  "eslint:recommended",
  "plugin:flowtype/recommended",
  "plugin:react/recommended",
  "plugin:import/errors"
],

Also, how would you recommend sharing config that's scattered across several .eslintrc files? For example, In a react web app with an express backend, I've got config files with different plugins/rules/etc. for my server folder (settings for pure non-transpiled node stuff), and my client folder (react, flow, babel transpiled stuff), and also test folders (things like jest or cypress settings, also inheriting/extending the settings for the source code they target).

Thanks in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.