From f581a5a3a40263df1adf2af8d23e70a832493353 Mon Sep 17 00:00:00 2001 From: Jeff MAURY Date: Fri, 2 Jul 2021 16:51:38 +0200 Subject: [PATCH 1/2] chore: add Jenkinsfile for Javascript implementation Fixes #28 Signed-off-by: Jeff MAURY --- js/Jenkinsfile | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 js/Jenkinsfile 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 From da746ff6eb02222efcef93253d4000b5f2e0924f Mon Sep 17 00:00:00 2001 From: Jeff MAURY Date: Fri, 2 Jul 2021 18:04:33 +0200 Subject: [PATCH 2/2] Change NPM package name Signed-off-by: Jeff MAURY --- README.md | 2 +- js/package-lock.json | 2 +- js/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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/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",