jsmp-infra-andrii-yaremenko
v1.0.0
Published
task jsmp-infra-andrii-yaremenko
Downloads
1
Readme
Task's requirement
- Create new package ()
- Name it as jsmp-infra-{package name}
- Write source code following next requirements o Code must be written with use of ES2015 import/export syntax and may use other ES2015 features (e.g. default parameters, destructuring etc.) o Code must use at least one external dependency (e.g. lodash) o Create file that export function which accepts array, other parameter(s) and returns updated array o Create file that export function which accepts string, other parameter(s) and returns updated string o Create file that will be entry point for your package and will export functions from files created in previous steps.
- Write simplest tests for your functions: o Code must be written with use of ES2015 import/export syntax and may use other ES2015 features (e.g. default parameters, destructuring etc.) o Use standard assert Node.js package Example: assert(myFunction('ABc', 'upper') === 'ABC', 'should convert string to uppercase') o Create 3 tests for each of two functions (better to have 1 simple and 2 edge cases)
- Write next npm scripts: a. compile - script(s) that transpiles original source and tests files to ES5. You have to use babel-cli package and create simple .babelrc file for this purpose b. clean - script(s) removes all files and folders that are created during by compile scripts c. test - script(s) that runs transpiled test files. d. Create tasks that will perform cleanup, transpilation and run tests before package will be published. (check official docs and presentation)
- Add readme file that contains short description and examples how to use your package. (check readme files for other packages)
- Create proper .gitignore file to exclude generated files from repository
- Create proper .npmignore file to publish only files that are required for consumers of your package (npm will bundle meta files and readme by itself)
- Register on npmjs.com
- Publish your package
- Made some updates and publish updated version
- Provide mentor with link(+ access) to package repository and link to package on npmjs.com
- (Optional) Create separate file and use your package. a. Try to install it from registry b. Try to install it from your filesystem (relative or absolute path) c. Try to consume it via npm link d. Notice differences in ways of how you can receive updates made to jsmp-infra-{package name} package
What will be checked
- Package installs and works without errors and warnings. – 2 points
- NPM scripts contains all required commands. – max 2 points (0.5 point per item)
- Package has full meta information. Link to docs: https://docs.npmjs.com/files/package.json. – 1 point
- Package has correctly configured dependencies (proper dependency types). – 0.5 point
- Package has lock file. – 0.5 point
- Package doesn't contain files that are not required for consumers. – 1 point
- Package can be used as on examples in readme. For example, https://github.com/MikeMcl/decimal.js/. – 1 point
- Package is cross platform. (there is no native commands in NPM scripts) – 1 point
- Package works on specified engines (Node, NPM versions). – 1point
How to use
package.json contains 4 scripts which you can use
1. npm run compile (compile - script(s) that transpiles original source and tests files to ES5, and put compiled
files in dist/js directory);
2. npm run clean (emoves all files and folders that are created during by compile scripts);
3. npm run test (runs transpiled test files);
4. npm run build (runs all scripts which were describe above).
Package provide 2 methods:
1. `modifyString()` method which modify recieve string transform option for it.
For example modifyString('my string', 'upper') will return 'MY STRING';
The second should to be equal 'upper' or 'lower' if this parameter doesn't transfered the string will be
capitalize;
2. `sortArray()` method which accept two arguments array and value, and return new sorted array. This method
works only with numbers. Example invoke sortArray([10, 1, 3, 1020], 18) return [1, 3, 10, 18, 1020];
How to run
1. Сhoose the root directory
open terminal and run corresponding script