diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml new file mode 100644 index 0000000..3776d7a --- /dev/null +++ b/.github/workflows/ci-build.yml @@ -0,0 +1,39 @@ +name: 'CI Build' + +on: + workflow_dispatch: + push: + branches: + - master + pull_request: + types: [ opened, reopened, edited, synchronize ] + branches: + - master + +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: false + +jobs: + compile-and-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up NodeJS + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'yarn' + cache-dependency-path: 'yarn.lock' + scope: '@dalet-oss' + + - name: Install dependencies + run: yarn install + + - name: Build + run: yarn build + + - name: Run tests + run: yarn test diff --git a/.github/workflows/ci-publish.yml b/.github/workflows/ci-publish.yml new file mode 100644 index 0000000..1c803c0 --- /dev/null +++ b/.github/workflows/ci-publish.yml @@ -0,0 +1,40 @@ +name: 'CI Publish to Maven Central' + +on: + workflow_dispatch: + push: + tags: + - 'release/*' + +concurrency: + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: false + +jobs: + compile-test-and-publish-to-npm: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up NodeJS + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'yarn' + cache-dependency-path: 'yarn.lock' + scope: '@dalet-oss' + + - name: Install dependencies + run: yarn install + + - name: Build + run: yarn build + + - name: Run tests + run: yarn test + + - name: Publish to public NPM registry + run: ./publish.sh + env: + NPM_REGISTRY_ACCESS_TOKEN: ${{ secrets.NPM_REGISTRY_ACCESS_TOKEN }} diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..38f11c6 --- /dev/null +++ b/.npmrc @@ -0,0 +1 @@ +registry=https://registry.npmjs.org diff --git a/README.md b/README.md index a6481a5..a0edf99 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,21 @@ # LexoRank on Typescript A reference implementation of a list ordering system like [JIRA's Lexorank algorithm](https://www.youtube.com/watch?v=OjQv9xMoFbg). -[![npm version](https://badge.fury.io/js/lexorank.svg)](https://badge.fury.io/js/lexorank) +[![npm version](https://badge.fury.io/js/@dalet-oss%2Flexorank.svg)](https://badge.fury.io/js/@dalet-oss%2Flexorank) + +This was forked from [https://github.com/kvandake/lexorank-ts](https://github.com/kvandake/lexorank-ts) in October 2024 +because, unfortunately, the maintainer appears to have abandoned their project. ## Getting Started Npm ```sh -npm install lexorank +npm install @dalet-oss/lexorank ``` Yarn ```sh -yarn add lexorank +yarn add @dalet-oss/lexorank ``` ## Storyboard @@ -24,7 +27,7 @@ yarn add lexorank ```typescript -import {LexoRank} from "lexorank"; +import { LexoRank } from '@dalet-oss/lexorank'; // min const minLexoRank = LexoRank.min(); @@ -39,7 +42,7 @@ const parsedLexoRank = LexoRank.parse('0|0i0000:'); ### Public methods ```typescript -import {LexoRank} from "lexorank"; +import { LexoRank } from '@dalet-oss/lexorank'; // any lexoRank const lexoRank = LexoRank.middle(); @@ -58,7 +61,7 @@ const lexoRankStr = lexoRank.toString(); LexRank calculation based on existing LexoRanks. ```typescript -import {LexoRank} from "lexorank"; +import { LexoRank } from '@dalet-oss/lexorank'; // any lexorank const any1LexoRank = LexoRank.min(); diff --git a/package.json b/package.json index 7c37d28..a8b6366 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,15 @@ { - "name": "lexorank", - "_id": "lexorank@1.0.5", - "version": "1.0.5", + "name": "@dalet-oss/lexorank", + "version": "1.0.0-DEV", "description": "A reference implementation of a list ordering system like JIRA's Lexorank algorithm", "author": { - "name": "kvandake" + "name": "Oliver Lockwood" }, + "contributors": [ + "Oliver Lockwood (@oliverlockwood)", + "Manan Shah (@mananrshah)", + "@kvandake" + ], "license": "MIT", "main": "lib/index.js", "types": "lib/index.d.ts", @@ -15,24 +19,17 @@ ], "repository": { "type": "git", - "url": "git+https://github.com/kvandake/lexorank-ts.git" + "url": "git+https://github.com/dalet-oss/lexorank-ts.git" }, "bugs": { - "url": "https://github.com/kvandake/lexorank-ts/issues" + "url": "https://github.com/dalet-oss/lexorank-ts/issues" }, - "homepage": "https://github.com/kvandake/lexorank-ts", + "homepage": "https://github.com/dalet-oss/lexorank-ts", "scripts": { "clean": "rimraf lib", "build": "yarn run clean && tsc", "test": "jest", - "lint": "eslint -c .eslintrc.js --ext .ts ./src", - "prepublishOnly": "yarn test && yarn run lint", - "preversion": "yarn run lint", - "version": "git add -A src", - "postversion": "git push && git push --tags", - "storybook": "start-storybook -p 6006", - "build-storybook": "build-storybook", - "chromatic": "npx chromatic --project-token=$CHROMATIC_PROJECT_TOKEN" + "lint": "eslint -c .eslintrc.js --ext .ts ./src" }, "devDependencies": { "@babel/core": "^7.18.13", diff --git a/publish.sh b/publish.sh new file mode 100755 index 0000000..92c0c4c --- /dev/null +++ b/publish.sh @@ -0,0 +1,36 @@ +echo 'Determining version number for publication' +echo 'Looking for an existing release tag against this commit' + +VERSION=$(git describe --tags --match release/* --exact-match 2>&1) +if [ $? -ne 0 ] +then + LAST=$(git describe --tags --match release/* 2>&1) + if [ $? -ne 0 ] + then + echo 'No release tags found at all; bail out' + exit 1 + fi + + echo "No matching tag found. Push a tag like release/1.0.1 against HEAD in order to release. Most recent tag is: ${LAST}" + exit 0 +fi + +VERSION=$(echo $VERSION | sed 's#release/##g') +echo "Publishing version: ${VERSION}" + +status=$(curl -s --head -w %{http_code} -o /dev/null https://www.npmjs.com/package/@dalet-oss/lexorank/v/${VERSION}/) +if [ $status -eq 200 ] +then + echo 'Version already available on the NPM Registry. This must be a rebuild; nothing to do here.' +else + echo 'Version not already available on the NPM Registry' + + echo 'Setting the version into package.json' + yarn version --no-git-tag-version --new-version ${VERSION} + + echo 'Adding NPM registry access token for https://registry.npmjs.org into local .npmrc' + echo "//registry.npmjs.org/:_authToken=${NPM_REGISTRY_ACCESS_TOKEN}" >> .npmrc + + echo 'Publishing to NPM Central' + npm publish --access public +fi