forked from jfrog/ide-plugins-common
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ transitive dependencies test added (direct and indirect)
- Loading branch information
1 parent
9d3788e
commit 9c331c5
Showing
8 changed files
with
1,902 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
BSD License | ||
|
||
For Yarn software | ||
|
||
Copyright (c) 2016-present, Yarn Contributors. All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
This is an example package that can be used to test Yarn. | ||
|
||
It has the common default fields in its `package.json`, along with production and development dependencies as well that | ||
are specific to the package we have created. | ||
|
||
## The `package.json` | ||
|
||
### Default Package Fields | ||
|
||
`yarn init` produces a default `package.json` similar to: | ||
|
||
``` | ||
{ | ||
"name": "example-yarn-package", | ||
"version": "1.0.0", | ||
"description": "An example package to demonstrate Yarn", | ||
"main": "index.js", | ||
"repository": { | ||
"url": "github.com/yarnpkg/example-yarn-package", | ||
"type": "git" | ||
}, | ||
"author": "Yarn Contributors", | ||
"license": "BSD-2-Clause", | ||
} | ||
``` | ||
|
||
### Custom Package Fields | ||
|
||
You can add custom fields to your `package.json` as well. In our case, we have added 4 custom fields. | ||
|
||
The `scripts` field are for any special scripts that you want to use when running `yarn`. For example, here we add a | ||
script called `test` that calls the Jest test runner because we added Jest tests to our Yarn package. | ||
|
||
``` | ||
"scripts": { | ||
"test": "jest" | ||
}, | ||
``` | ||
|
||
The `dependencies` field lists the other packages that this package is dependent upon. Our example package is dependent | ||
on [Lodash](https://lodash.com/) since we use its `multiply` function. | ||
|
||
``` | ||
"dependencies": { | ||
"lodash": "^4.16.2" | ||
}, | ||
``` | ||
|
||
The `devDependencies` field lists the other packages that this package is dependent upon *during development*. Our | ||
example package is dependent on [Jest](https://facebook.github.io/jest/) since we created some Jest-enabled tests for | ||
our package. | ||
|
||
``` | ||
"devDependencies": { | ||
"jest-cli": "15.1.1" | ||
}, | ||
``` | ||
|
||
The `jest` field is a custom field specific to the Jest package we included as a dev dependency. In this case, we are | ||
testing | ||
in a node environment at the command-line. | ||
|
||
``` | ||
"jest": { | ||
"testEnvironment": "node" | ||
} | ||
``` | ||
|
||
> It is important to note that Lodash and Jest are not required for Yarn. They are just examples of what can be used | ||
> when you are creating the code for your Yarn package. | ||
## Development | ||
|
||
``` | ||
$ yarn install | ||
$ yarn run test | ||
``` | ||
|
||
## Production | ||
|
||
``` | ||
$ yarn install --production | ||
``` |
6 changes: 6 additions & 0 deletions
6
src/test/resources/yarn/exampleYarnPackage/__tests__/area-rectangle-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
'use strict'; | ||
|
||
test('area of rectangle with width 3 and height 4 to equal 12', () => { | ||
const ShapeMath = require('../index.js'); | ||
expect(ShapeMath.area_rectangle(3, 4)).toBe(12); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Math functions on shapes | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// For package depenency demonstration purposes only | ||
var multiply = require('lodash/multiply'); | ||
|
||
module.exports = { | ||
area_rectangle: function (width, height) { | ||
return multiply(height, width); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "example-yarn-package", | ||
"version": "1.0.0", | ||
"description": "An example package to demonstrate Yarn", | ||
"main": "index.js", | ||
"repository": { | ||
"url": "github.com/yarnpkg/example-yarn-package", | ||
"type": "git" | ||
}, | ||
"scripts": { | ||
"test": "jest" | ||
}, | ||
"author": "Yarn Contributors", | ||
"license": "BSD-2-Clause", | ||
"dependencies": { | ||
"lodash": "4.16.2" | ||
}, | ||
"devDependencies": { | ||
"jest-cli": "15.1.1" | ||
}, | ||
"jest": { | ||
"testEnvironment": "node" | ||
} | ||
} |
Oops, something went wrong.