-
Notifications
You must be signed in to change notification settings - Fork 9
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
Trying to support non cli #22
Closed
Closed
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
a211d30
trying to test non cli
9d892b5
lets try this
2f81d1a
addeding a log to test
52cf554
Trying-To-Support-non-cli: Merge branch 'Trying-To-Support-non-cli' o…
94adce3
lets just try using lib
4a75de5
* added the ability to simply call run
8113b0c
added readme change
ccf627a
one more readme modifcaiton
522d8d3
revert removal of new line
169bf72
added constants to support the specification of target from nodejs side
8bcf0cd
readme update
c8636cd
fix to how i defined constants
d077c7f
* added editorconfig
2e95ed8
* added a change to attempt to see if we can use require now
eb051d0
and the file change itself
5330db5
so it turns out a - breaks npm install haha
aac19ec
missed line opps
a20a4c4
alright?.. lets try a roll back
2af5ad1
hmm
cf6b811
ah.. opps my cheery pick of line borked package json
a1fcc18
adding inital tests
ea876d7
added linting changes
22a6c23
* npm ignore updates
9545544
* committing initial tests before testing the removal incase i lose s…
c49936e
*tear down fixed
b6eeeb6
final iteration of the index.js top level test
2193b08
* added another refactor to make tests look cleaner
84944cc
added cli mocking inital files
2d4de75
moved around tests for cleaner postioning
0aa9192
disable failing trest
c88c5fd
Files tests
dc4d700
added another return to avoid the race conditions occurring during te…
37a6ece
small change to add commit message for draft pr
556305f
npmignore rejig
af8a420
readme fix
4a1e282
simplification of random filename as its not needed to be so complex
74d32fc
unneeded anon func?
f7fd558
* removal of argv mock
aa83793
* slight refactors to utils
3f17809
Trying-To-Support-non-cli: adding linting fixes
phyzical a986cc7
Trying-To-Support-non-cli: more liniting
phyzical ac8ea00
Trying-To-Support-non-cli: changed to es6 exports, more linting
phyzical 8093f27
Update README.md
phyzical cdeb6a4
Trying-To-Support-non-cli: rollback the export change
phyzical 4d5fe7e
Trying-To-Support-non-cli: Merge branch 'Trying-To-Support-non-cli' o…
phyzical 9071cd4
Trying-To-Support-non-cli: add readme fix
phyzical 6b45606
Trying-To-Support-non-cli: adding inital typescript funtionailty
phyzical 5964cd9
Trying-To-Support-non-cli: updated the typescripting to support index
phyzical 829032c
Trying-To-Support-non-cli: added logic to mimic a cli usage added log…
phyzical 064b7a7
Trying-To-Support-non-cli: fixed a bug in the regex tester not workin…
phyzical 379dfd6
Trying-To-Support-non-cli: finished cli context tests
phyzical File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[*] | ||
indent_size = 2 | ||
indent_style = space | ||
tab_width = 2 | ||
insert_final_newline = true |
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 @@ | ||
module.exports = { | ||
extends: ['eslint:recommended', 'prettier'], // extending recommended config and config derived from eslint-config-prettier | ||
plugins: ['prettier'], // extending recommended config and config derived from eslint-config-prettier | ||
env: { | ||
browser: true, | ||
node: true, | ||
amd: true, | ||
es6: true, | ||
commonjs: true, | ||
jest: true, | ||
}, | ||
parser: 'babel-eslint', | ||
rules: { | ||
'prettier/prettier': [ | ||
// customizing prettier rules (unfortunately not many of them are customizable) | ||
'error', | ||
{ | ||
singleQuote: true, | ||
tabWidth: 2, | ||
}, | ||
], | ||
eqeqeq: ['error', 'always'], // adding some custom ESLint rules | ||
}, | ||
}; |
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 |
---|---|---|
|
@@ -3,3 +3,6 @@ ISSUE_TEMPLATE.md | |
PULL_REQUEST_TEMPLATE.md | ||
yarn.lock | ||
package-lock.json | ||
.editorconfig | ||
.eslintrc.js | ||
tests |
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 |
---|---|---|
|
@@ -12,7 +12,7 @@ $ npm install add-dependencies [-g] | |
|
||
### Usage | ||
|
||
Run: | ||
Run (for `nodejs` see Example): | ||
|
||
```sh | ||
$ add-dependencies [package_file] <dependencies> [target] [--no-overwrite] | ||
|
@@ -35,7 +35,7 @@ If no `package_file` argument passed, the script searches for a `package.json` f | |
|
||
Use `--no-overwrite` flag to prevent already existing packages in `package.json` from being overwritten. | ||
|
||
Example: | ||
Example: | ||
|
||
```sh | ||
$ add-dependencies /home/user/project/package.json [email protected] [email protected] redux eslint --dev | ||
|
@@ -46,3 +46,24 @@ or with `npx`: | |
```sh | ||
$ npx add-dependencies /home/user/project/package.json [email protected] [email protected] redux eslint --dev | ||
``` | ||
|
||
or via nodejs | ||
|
||
```js | ||
const npmAdd = require('add-dependencies'); | ||
//OR | ||
// Note: to use import you must have `"type": "module"` in your projects package.json | ||
import npmAdd from 'add-dependencies'; | ||
|
||
const dependencies = [ | ||
'package1', | ||
'package2', | ||
'package3', | ||
]; | ||
const target = npmAdd.CONSTANTS.DEPENDENCIES; | ||
const overwrite = false; | ||
const packageFilePath = 'package.json'; | ||
new npmAdd(dependencies, target, overwrite, packageFilePath) | ||
.run() | ||
.then(() => console.log('completed')); | ||
``` |
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,15 @@ | ||
#!/usr/bin/env node | ||
|
||
const AddDependencies = require('./lib/AddDependencies'); | ||
|
||
console.log( | ||
'\x1b[33m%s\x1b[0m', | ||
'This script adds dependencies (latest or specified versions) to the package.json file skipping the installation process.' | ||
); | ||
|
||
const app = new AddDependencies(); | ||
|
||
app.run().catch((error) => { | ||
console.error('\x1b[31m%s\x1b[0m', error); | ||
process.exit(1); | ||
}); |
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 |
---|---|---|
@@ -1,11 +1,3 @@ | ||
#!/usr/bin/env node | ||
const AddDependencies = require('./lib/AddDependencies'); | ||
|
||
console.log('\x1b[33m%s\x1b[0m', 'This script adds dependencies (latest or specified versions) to the package.json file skipping the installation process.'); | ||
|
||
const app = new AddDependencies(); | ||
|
||
app.addDependencies().then(app.saveToPackage.bind(app)).catch((error) => { | ||
console.error('\x1b[31m%s\x1b[0m', error); | ||
process.exit(1); | ||
}); | ||
module.exports = require('./lib/AddDependencies'); |
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,5 @@ | ||
#!/usr/bin/env node | ||
|
||
import AddDependencies from './lib/AddDependencies.js'; | ||
|
||
export default AddDependencies; |
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was one change i was unsure of, as to why
app.saveToPackage.bind(app)
was being done?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obviously, because
saveToPackage
method is supposed to use the class context.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but why does it not have the class context from within itself already? or was this something todo with the asyncy nature of the package