Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
generator-ts-np
Advanced tools
Yeoman Generator For Building Node Packages :package: With Typescript.
This package helps you to scaffold a directory skeleton required to start writing an npm package in Typescript, which is fully configured and ready to contain your module logic. And finally, ready to publish.
Here you write your logic in Typescript and publish the compiled version of it - easily.
es6
. (You can change this)You don't have to write any type definitions here. It will be packaged within your package automatically.
npm install -g generator-ts-np
yo ts-np
To know really what happens under the hood, refer scripts
section in package.json
at your package root.
Script | What is it |
---|---|
npm test or npm run test | Featured Command :star:. This is a right combination of all other commands. (build s and runs your tests in tests/ directory) |
npm run build | compiles content of src/ into dist/ folder with some additional tasks like copying non-ts files cleaning dir, linting, prettifying etc. |
npm run lint | lints and styles your code with prettier and tslint and fixes fixable issues. |
npm run lint-noFix | invokes npm lint without fix option => means if any issues found, it just notifies with out fixing it. |
CI/CD (Continuous Integration/ Continuous Deployment) helps you to automate the npm publish
task.
This is disabled by default. Following are the things you would normally do while publishing your module(with out CI/CD).
package.json
With CI/CD enabled, all you have to do is:
package.json
git tag v<version>
)git push --tags
):warning: However, for the first time you have to manually publish it using
npm publish
. Rest of the updates can be handled via travis.
Travis will do all other things for you, including publishing your package to npm.
Open .travis.ym
file in your scaffolded directory structure and follow instructions over there.
After hand checking everything is correct,
package.json
$ git tag vX.X.X
(example: git tag v1.5.3
)$ git push --tags
Here is what you get:
.
| .editorconfig
| .gitignore
| .prettierignore
| .prettierrc
| .travis.yml
| .yo-rc.json
| ci-jest.config.json
| gulpfile.js
| package.json
| README.md
| tree.txt
| tsconfig.json
| tslint.json
|
+---.roughs
| README.md
|
+---.vscode
| launch.json
|
+---media
| .gitkeep
|
+---src
| index.ts
|
+---tests
| add.spec.ts
|
\---typings
typings.d.ts
npm run build
or npm test
, a dist
folder will also be created with all your compiled code. dist/src
is the directory which is going to be published to Npm.media/
: All your gallery.src/
: All your source code.typings/
: All your custom type definitionstests/
: All your tests. Jest Test Runner looks at this directory.credentials/
or private/
at the root of your package, which will be ignored by both git and npm.npm publish
, mainly the content of dist/src/
will be published. To know what folders/files will be ignored, take a look at files
section in package.json.media/
folder is .npmignored
by default. So if you need to use some images inside your package, handle files
section in package.json file accordingly. The idea here is that you should not publish any unnecessary stuffs to npm registry.:warning: Important: Before publishing your package, hand check each file and verify everything is perfect.
ts-np
only helps you to get started quickly and step back it self leaving the rest to you.
If you found any issues, kindly report at github issues.
MIT © Vajahath Ahmed
FAQs
Yeoman Generator For Building Node Packages With Typescript
The npm package generator-ts-np receives a total of 3 weekly downloads. As such, generator-ts-np popularity was classified as not popular.
We found that generator-ts-np demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.