From: SUBHANSHU Date: Mon, 18 Jul 2022 19:13:10 +0530 Subject: add functionalities with details --- add functionalities with details --- --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +/lib \ No newline at end of file --- 'a/README.md' +++ b/README.md @@ -1 +1,35 @@ -# Publishing node module in openForge \ No newline at end of file +# Publishing node module in openForge + +## commands to push +1. init git +2. set origin +### Npm command +1. npm init/ npm init -y (to init the npm and set package.json file) +2. code the index or the main file of the project (index or the main file) +3. run npm run build +4. npm login +5. npm whoami **check the id is correct or not* +6. npm publish + + + + +**Note** +### I had used typescript hence: +1. run npm i -D typescript in terminal after npm init +2. add tsconfig.json file with configurations and :- + - add "include": ["folder-name"] *used to give the folde name to be compiled* + - add "exclude": ["not-required-folder-names"] *like node_modules, test files name* + +3. in package.json +- change \*scripts\* :- + - add "build":"tsc" *for typescript* + - add "prepare": "npm run build" *to prepare the package file for publishing* +- add at the end "files" : ["/lib/**/*"] *for pushing only the lib file that was build after npm build on the npm registery + - or can create a new file .npmignore +- add "types" : " .d.ts", *it tells where the decleration file is* +- **_Note_** Don't forget to check the index,js file path + + + + --- /dev/null +++ b/package-lock.json @@ -0,0 +1,37 @@ +{ + "name": "digilocker-npm-module", + "version": "1.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "digilocker-npm-module", + "version": "1.0.0", + "license": "ISC", + "devDependencies": { + "typescript": "^4.7.4" + } + }, + "node_modules/typescript": { + "version": "4.7.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz", + "integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + } + }, + "dependencies": { + "typescript": { + "version": "4.7.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz", + "integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==", + "dev": true + } + } +} --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "name": "digilocker-npm-module", + "version": "1.0.0", + "description": "Node npm module for Digilocker", + "main": "lib/index.js", + "types": "lib/index.d.ts", + "scripts": { + "build":"tsc", + "prepare": "npm run build" + }, + "repository": { + "type": "git", + "url": "https://openforge.gov.in/plugins/git/internship/ashish_ranjan_satyam_srivastava.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "typescript": "^4.7.4" + }, + "files": ["/lib/**/*"] +} --- /dev/null +++ b/src/index.ts @@ -0,0 +1,11 @@ +export class App{ + static success(msg:string){ + console.log(`%c${msg}`, 'color: green'); + } + static danger(msg:string){ + console.log(`%c${msg}`, 'color: red'); + } + static info(msg:string){ + console.log(`%c${msg}`, 'color: blue','background:yellow'); + } +} \ No newline at end of file --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "moduleResolution": "node", + "sourceMap": true, + "declaration": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "removeComments": false, + "outDir": "./lib", + "strict": true, + }, + "include": ["src"], //src is the folder where all the files are located that are to be compiled + "exclude": ["node_modules","**/__test__/**"] , //exclude all the files in the node_modules folder and all the files in the __test__ folder +} \ No newline at end of file