From 7d62a43ea63f3a264cd8fa8820e1e53753e93d5a Mon Sep 17 00:00:00 2001 From: Yusef Almamari Date: Wed, 27 Nov 2024 17:17:29 +0400 Subject: [PATCH] First commit --- .eslintignore | 7 + .eslintrc | 26 ++ .github/workflows/publish.yml | 54 ++++ .gitignore | 10 + .prettierignore | 4 + .prettierrc | 7 + LICENSE | 7 + README.md | 149 ++++++++++ package.json | 73 +++++ src/CSLJsonParser.ts | 493 ++++++++++++++++++++++++++++++++++ src/citeease-cli.ts | 5 + src/common.ts | 87 ++++++ src/index.ts | 349 ++++++++++++++++++++++++ src/types.ts | 35 +++ tsconfig.json | 18 ++ 15 files changed, 1324 insertions(+) create mode 100644 .eslintignore create mode 100644 .eslintrc create mode 100644 .github/workflows/publish.yml create mode 100644 .gitignore create mode 100644 .prettierignore create mode 100644 .prettierrc create mode 100644 LICENSE create mode 100644 README.md create mode 100644 package.json create mode 100644 src/CSLJsonParser.ts create mode 100644 src/citeease-cli.ts create mode 100644 src/common.ts create mode 100644 src/index.ts create mode 100644 src/types.ts create mode 100644 tsconfig.json diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..cc302ac --- /dev/null +++ b/.eslintignore @@ -0,0 +1,7 @@ +# See https://eslint.org/docs/latest/use/configure/ignore for more about ignoring files. + +# dependencies +node_modules/ + +# prodiction +dist/ \ No newline at end of file diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..1175cd1 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,26 @@ +{ + "root": true, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": "latest", + }, + "env": { + "browser": true, + "commonjs": true, + "es6": true, + "node": true, + }, + "plugins": ["@typescript-eslint", "import", "prettier"], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/recommended", + "plugin:import/errors", + "plugin:prettier/recommended", + ], + "rules": { + "indent": ["warn", 4], + "quotes": ["warn", "double"], + "no-unused-vars": "warn", + "@typescript-eslint/no-var-requires": "off", + }, +} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..244f26f --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,54 @@ +name: Publish NPM package + +on: + push: + branches: + - main + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: "20" + registry-url: "https://registry.npmjs.org" + + - name: Install dependencies + run: npm install + + # - name: Test + # run: npm run test + + - name: Check the version + id: check + run: | + CURRENT_VERSION=$(jq -r .version package.json) + echo "Current version: $CURRENT_VERSION" + LATEST_VERSION=$(npm show version || echo "0.0.0") + echo "Latest version: $LATEST_VERSION" + + if [ "$LATEST_VERSION" != "$CURRENT_VERSION" ]; + then + echo "Version changed" + echo "version_changed=true" >> $GITHUB_OUTPUT + echo "new_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT + else + echo "Version not changed" + echo "version_changed=false" >> $GITHUB_OUTPUT + fi + + - name: Build + run: npm run build + if: steps.check.outputs.version_changed == 'true' + + - name: Publish + if: steps.check.outputs.version_changed == 'true' + run: npm publish --access public --no-git-checks + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9502a68 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules + +# production +/dist + +# misc +package-lock.json \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..d4fd620 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,4 @@ +# See https://prettier.io/docs/en/ignore.html for more about ignoring files. + +# dependencies +node_modules/ diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..106964a --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "trailingComma": "es5", + "printWidth": 120, + "tabWidth": 4, + "semi": true, + "singleQuote": false +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7311083 --- /dev/null +++ b/LICENSE @@ -0,0 +1,7 @@ +Copyright © 2024 Ganemede Labs + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..1085d59 --- /dev/null +++ b/README.md @@ -0,0 +1,149 @@ +# CiteEase CLI + +![npm](https://img.shields.io/npm/v/citeease-cli) +![npm](https://img.shields.io/npm/dw/citeease-cli) +![License](https://img.shields.io/npm/l/citeease-cli) + +`citeease-cli` is a CLI tool that generates formatted citations (references) based on various unique identifiers, including URL, DOI, ISBN, PMID, and PMCID. Just pass in your identifiers, and `citeease-cli` will handle the rest! + +## 📋 Table of Contents + +- [Installation](#-installation) +- [Usage](#-usage) +- [Configuration](#-configuration) +- [Supported Identifiers](#-supported-identifiers) +- [Data Sources](#-data-sources) +- [Output](#-output) +- [License](#-license) +- [Contact](#-contact) + +## ⚙️ Installation + +Install `citeease-cli` globally via npm: + +```bash +npm install -g citeease-cli +``` + +Or use it directly with `npx` without global installation: + +```bash +npx citeease-cli cite +``` + +## 🚀 Usage + +To generate citations, provide a list of unique identifiers as arguments. `citeease-cli` will attempt to identify the type of each identifier automatically. + +### Options + +- `--style`, `-s