diff --git a/README.md b/README.md index 69c0a73e..5628b382 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ Alizer also offers a NPM package providing helpers for recognize languages/frame The syntax is the following: ``` -import * as recognizer from 'language-recognizer'; +import * as recognizer from '@redhat-developer/alizer'; ..... diff --git a/js/Jenkinsfile b/js/Jenkinsfile new file mode 100644 index 00000000..4ddef6f5 --- /dev/null +++ b/js/Jenkinsfile @@ -0,0 +1,56 @@ +#!/usr/bin/env groovy + +node('rhel8') { + stage('Checkout repo') { + deleteDir() + git url: "https://github.com/${params.FORK}/alizer.git", branch: params.BRANCH + } + + stage('Install requirements') { + def nodeHome = tool 'nodejs-12.13.1' + env.PATH = "${nodeHome}/bin:${env.PATH}" + } + + dir('js') { + stage('Build') { + sh "npm install" + sh "npm run compile" + } + + stage('Test') { + sh "npm run test" + } + + def packageJson = readJSON file: 'package.json' + + stage('Package') { + sh "npm pack" + def packs = findFiles(glob: '**.tgz') + def packName = "redhat-developer-alizer-${packageJson.version}-${env.BUILD_NUMBER}.tgz" + sh "mv ${packs[0].name} ${packName}" + sh "ln -s ${packName} redhat-developer-alizer-latest.tgz" + } + + if (params.UPLOAD_LOCATION) { + stage('Snapshot') { + def filesToPush = findFiles(glob: '**.tgz') + for (i = 0; i < filesToPush.length; i++) { + sh "rsync -Pzrlt --rsh=ssh --protocol=28 ${filesToPush[i].path} ${UPLOAD_LOCATION}/snapshots/alizer/" + } + } + } + + if (publish.equals('true')) { + stage('Publish to NPM') { + withCredentials([[$class: 'StringBinding', credentialsId: 'npm-token', variable: 'TOKEN']]) { + sh "echo registry=https://registry.npmjs.com > .npmrc" + sh "echo //registry.npmjs.com/:_authToken=${TOKEN} >> .npmrc" + sh "npm publish" + } + currentBuild.keepLog = true + currentBuild.description = "${packageJson.version}.${env.BUILD_NUMBER}" + } + } + } + +} \ No newline at end of file diff --git a/js/package-lock.json b/js/package-lock.json index f1dbbc3a..1baf5c10 100644 --- a/js/package-lock.json +++ b/js/package-lock.json @@ -1,5 +1,5 @@ { - "name": "language-recognizer", + "name": "@redhat-developer/alizer", "version": "0.0.1", "lockfileVersion": 2, "requires": true, diff --git a/js/package.json b/js/package.json index 2b048a5b..c2b62551 100644 --- a/js/package.json +++ b/js/package.json @@ -1,5 +1,5 @@ { - "name": "language-recognizer", + "name": "@redhat-developer/alizer", "version": "0.0.1", "description": "", "main": "lib/src/recognizer.js",