Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Feat/depend #659

Merged
merged 44 commits into from
Feb 27, 2018
Merged

Feat/depend #659

merged 44 commits into from
Feb 27, 2018

Conversation

nikhedonia
Copy link
Contributor

@nikhedonia nikhedonia commented Feb 16, 2018

this package is a cli tool for dependency analysis for packages.
It implements linting and automatic fixing of version numbers.
Furthermore it can print graphviz compatible description to console.

Once merged we can add a linting and fix commands to our package.json files.
eg.:
depend -e "packages/*/package.json" -s conservative --bail which would result in an exit code of one if we have divergent package versions or a outdated times-component-package in use.

for quick fixing I'd suggest to use:
depend -e "packages/*/package.json" -s majorityProgressive --fix
which would automatically resolve all version number issues by the following rules:

if a dependency is a times-component package, take the latest version

  • if there are multiple versions used in the codebase use what the majority uses.
  • if it's a tie: use the latest version (progressive)

More Examples

depend -g "@times-components/*=>dextrose@" | fdp -Tsvg -o dextrose.svg

dextrose

depend -g "*/ad@ => *" | circo -Tgif -o ad.gif

ad

depend --hint --strategy majority

packages/gestures/package.json
     dextrose: 1.3.2 -> 1.4.5
packages/slice/package.json
     @times-components/article: 0.32.7 -> 0.37.0
     dextrose: 1.4.0 -> 1.4.5
packages/tealium/package.json
     react-native-web: 0.1.14 -> 0.3.2
packages/utils/package.json
     @times-components/jest-configurator: 0.0.23 -> 0.2.0

depend --list -e "packages/*/package.json"

@times-components/watermark 0.3.4
2 prop-types 15.6.0
3 react-broadcast 0.5.2
4 @storybook/addon-actions 3.3.11
5 @storybook/react-native 3.3.11
6 @times-components/eslint-config-thetimes 0.1.3
7 dextrose 1.4.5 1.4.0 1.3.2
[...]

QuickInstall

git ch feat/checkdep
npm pack packages/depend/
npm i -g times-components-depend-0.0.1.tgz
git ch - # back to work
depend -e "packages/*/package.json"--hint -s majorityProgressive # show all packages that need fixing
depend -e "packages/*/package.json" --fix -s majorityProgressive # fix what needs fixing  

Limitations

currently ambitious version ranges are not supported.

@times-tools
Copy link
Collaborator

@times-tools
Copy link
Collaborator

@times-tools
Copy link
Collaborator

@times-tools
Copy link
Collaborator

@nikhedonia nikhedonia force-pushed the feat/checkdep branch 2 times, most recently from 266cac4 to 8a64ff9 Compare February 16, 2018 09:29
@times-tools
Copy link
Collaborator

@times-tools
Copy link
Collaborator

@nikhedonia nikhedonia force-pushed the feat/checkdep branch 2 times, most recently from 7ff3952 to 0e75714 Compare February 16, 2018 19:35
@times-tools
Copy link
Collaborator

@times-tools
Copy link
Collaborator

@times-tools
Copy link
Collaborator

@nikhedonia nikhedonia force-pushed the feat/checkdep branch 2 times, most recently from 4ffccab to 93dd2d6 Compare February 17, 2018 15:18
@times-tools
Copy link
Collaborator

@times-tools
Copy link
Collaborator

@times-tools
Copy link
Collaborator

@times-tools
Copy link
Collaborator

# Usage

```
depend -e "packages/*/package.json" [...options]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it intends to always be a package dependency tool, cant we remove the need for packages/*/package.json ? Just seems like extra typing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually defaults to packages/*/package.json; maybe it would be better to read this from the lerna.json file?.

However if you run it within packages/ad the expression will change.

I've also been using it a lot to analyse the node_modules folder to find out which dependency installs what.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for using the lerna.json

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lerna support added


fixes the packages that are not in-sync

## --graph, -g ["{filter}"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth actually deploying these images somewhere and linking them into the PRs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It actually only creates a graphviz compatible output that can then be rendered to an image (see PR). Where would you guys suggest to upload those files ?

return (a, b) => s1(a, b) || s2(a, b);
}

// TODO: support semver ranges
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth adding as an issue or a Jira ticket

@@ -0,0 +1,40 @@
import optimist from "optimist";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This packages is deprecated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, couldn't get it working with yargs though...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we try?

@nikhedonia nikhedonia force-pushed the feat/checkdep branch 11 times, most recently from fdf122d to c71cd57 Compare February 27, 2018 20:15
Copy link
Contributor

@craigbilner craigbilner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will merge as now mature and useful but if you could pick up on the comments you can

would be good to fill the test coverage holes too which don't seem too problematic

biggest issue atm is the requirement to provide -l . for every call which isn't obvious from the README


Based on the parsed packages, linting rules are computed. Based on those rules,
hints are computed and can be displayed using `--hint` and applied with `--fix`.
Strategies add additional rules for ensuring packages install the same external
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can provide your own strategy and additional rules...?

# Linting

Based on the parsed packages, linting rules are computed. Based on those rules,
hints are computed and can be displayed using `--hint` and applied with `--fix`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we have a message if you pass no flags to advise and a message if there's nothing to change?

# Usage

```
depend --lerna "{path/to/lerna/project}" [...options]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you run at root guess you don't need to do this? Looks like it needs some error handling too

}
```

`depend -g` outputs all dependencies in `.dot` format:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

graph has to take a pattern?

Depend itself does not have any rendering capabilities but `--graph` output can
be directly piped into a [graphviz](https://www.graphviz.org/) renderer.

`depend -g "@times-components/*=>dextrose@" | fdp -Tsvg -o dextrose.svg`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might want to mention you need to have graphviz installed at this point?


`=>jest`

everything that installs jest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to output any package that contains jest in it?

@@ -0,0 +1,54 @@
import { applyPatch } from "../depend";

describe("depend apply-patch tests", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally these should read as sentences

"fmt": "prettier --write '**/*.*'",
"prettier:diff": "prettier --list-different '**/*.*'",
"lint": "eslint . && npm run prettier:diff",
"test": "jest --bail --ci --coverage"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't use these flags at the package level anymore

packageJson.dependencies[name],
version
])
.filter(x => x[1]),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still some cryptic refs like this that should be refactored

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants