1+ /* eslint-disable @typescript-eslint/no-var-requires */
12// Copyright (c) Microsoft Corporation. All rights reserved.
23// Licensed under the MIT license.
34
@@ -10,124 +11,148 @@ const filter = require('gulp-filter');
1011const gRegexRename = require ( 'gulp-regex-rename' ) ;
1112const fs = require ( 'node:fs' ) ;
1213const BAZEL_ECLIPSE_DIR = '../bazel-eclipse' ;
13- const BAZEL_ECLIPSE_LATEST_URL = "https://opensource.salesforce.com/bazel-eclipse/latest/p2-repository.zip" ;
14+ const BAZEL_ECLIPSE_LATEST_URL =
15+ 'https://opensource.salesforce.com/bazel-eclipse/latest/p2-repository.zip' ;
1416const NON_NPM_REPOSITORY_RE = new RegExp (
15- String . raw `"resolved":\s*"https://(?!(registry\.npmjs\.org\/?))` ,
16- "g"
17+ String . raw `"resolved":\s*"https://(?!(registry\.npmjs\.org\/?))` ,
18+ 'g'
1719) ;
1820
1921// a little helper to drop OSGi versions from bundle jar file name
2022const DROP_JAR_VERSION = gRegexRename ( / _ \d + \. \d + \. \d + ( \. [ ^ \. ] + ) ? \. j a r / , '.jar' ) ;
2123
2224// read the package.json once so we can use it in the gulp script
23- const packageJson = JSON . parse ( fs . readFileSync ( " ./package.json" ) . toString ( ) ) ;
25+ const packageJson = JSON . parse ( fs . readFileSync ( ' ./package.json' ) . toString ( ) ) ;
2426
2527// we only need the headless jars of the Bazel JDT Language Server extension
26- const declaredServerJars = new Set ( packageJson . contributes . javaExtensions . map ( path => path . split ( '/' ) . reverse ( ) [ 0 ] ) ) ;
27- const jarIsIncludedInPackageJson = filter ( file => {
28- return declaredServerJars . has ( file . basename ) ;
28+ const declaredServerJars = new Set (
29+ packageJson . contributes . javaExtensions . map (
30+ ( path ) => path . split ( '/' ) . reverse ( ) [ 0 ]
31+ )
32+ ) ;
33+ const jarIsIncludedInPackageJson = filter ( ( file ) => {
34+ return declaredServerJars . has ( file . basename ) ;
2935} ) ;
3036
3137gulp . task ( 'download_server' , function ( done ) {
32- downloadServerImpl ( ) ;
33- done ( ) ;
38+ downloadServerImpl ( ) ;
39+ done ( ) ;
3440} ) ;
3541
3642gulp . task ( 'build_server' , function ( done ) {
37- buildServerImpl ( ) ;
38- done ( ) ;
43+ buildServerImpl ( ) ;
44+ done ( ) ;
3945} ) ;
4046
4147gulp . task ( 'build_or_download' , function ( done ) {
42- if ( ! fs . existsSync ( BAZEL_ECLIPSE_DIR ) ) {
43- console . log ( 'NOTE: bazel-eclipse is not found as a sibling directory, downloading the latest snapshot of the Bazel JDT Language Server extension...' ) ;
44- downloadServerImpl ( ) ;
45- }
46- else {
47- buildServerImpl ( ) ;
48- }
49- done ( ) ;
48+ if ( ! fs . existsSync ( BAZEL_ECLIPSE_DIR ) ) {
49+ console . log (
50+ 'NOTE: bazel-eclipse is not found as a sibling directory, downloading the latest snapshot of the Bazel JDT Language Server extension...'
51+ ) ;
52+ downloadServerImpl ( ) ;
53+ } else {
54+ buildServerImpl ( ) ;
55+ }
56+ done ( ) ;
5057} ) ;
5158
5259gulp . task ( 'prepare_pre_release' , function ( done ) {
5360 // parse existing version (using ECMA script regex from https://semver.org/)
54- const stableVersion = packageJson . version . match ( / ^ ( 0 | [ 1 - 9 ] \d * ) \. ( 0 | [ 1 - 9 ] \d * ) \. ( 0 | [ 1 - 9 ] \d * ) (?: - ( (?: 0 | [ 1 - 9 ] \d * | \d * [ a - z A - Z - ] [ 0 - 9 a - z A - Z - ] * ) (?: \. (?: 0 | [ 1 - 9 ] \d * | \d * [ a - z A - Z - ] [ 0 - 9 a - z A - Z - ] * ) ) * ) ) ? (?: \+ ( [ 0 - 9 a - z A - Z - ] + (?: \. [ 0 - 9 a - z A - Z - ] + ) * ) ) ? $ / ) ;
61+ const stableVersion = packageJson . version . match (
62+ / ^ ( 0 | [ 1 - 9 ] \d * ) \. ( 0 | [ 1 - 9 ] \d * ) \. ( 0 | [ 1 - 9 ] \d * ) (?: - ( (?: 0 | [ 1 - 9 ] \d * | \d * [ a - z A - Z - ] [ 0 - 9 a - z A - Z - ] * ) (?: \. (?: 0 | [ 1 - 9 ] \d * | \d * [ a - z A - Z - ] [ 0 - 9 a - z A - Z - ] * ) ) * ) ) ? (?: \+ ( [ 0 - 9 a - z A - Z - ] + (?: \. [ 0 - 9 a - z A - Z - ] + ) * ) ) ? $ /
63+ ) ;
5564 const major = stableVersion [ 1 ] ;
5665 // unfortunately, VS Code Marketplace does not support full semver
5766 // also, the limit is < 2147483647 on VS Code Marketplace
5867 // thus, we use year (just the last two digits) as minor
5968 // and patch that is based starting with the month up to the minute (for granularity)
6069 const date = new Date ( ) ;
61- const year = date . getUTCFullYear ( ) - 2000 ;
70+ const year = date . getUTCFullYear ( ) - 2000 ;
6271 const month = date . getUTCMonth ( ) + 1 ;
6372 const day = date . getUTCDate ( ) ;
6473 const hours = date . getUTCHours ( ) ;
6574 const minutes = date . getUTCMinutes ( ) ;
66- const patch = `1${ prependZero ( month ) } ${ prependZero ( day ) } ${ prependZero ( hours ) } ${ prependZero ( minutes ) } ` ;
75+ const patch = `1${ prependZero ( month ) } ${ prependZero ( day ) } ${ prependZero (
76+ hours
77+ ) } ${ prependZero ( minutes ) } `;
6778 const insiderPackageJson = Object . assign ( packageJson , {
6879 version : `${ major } .${ year } .${ patch } ` ,
6980 } ) ;
7081 console . log ( `Applying pre-release version '${ major } .${ year } .${ patch } '...` ) ;
71- fs . writeFileSync ( "./package.json" , JSON . stringify ( insiderPackageJson , null , "\t" ) ) ;
82+ fs . writeFileSync (
83+ './package.json' ,
84+ JSON . stringify ( insiderPackageJson , null , '\t' )
85+ ) ;
7286 done ( ) ;
7387} ) ;
7488
7589gulp . task ( 'repo_check' , function ( done ) {
76- const data = fs . readFileSync ( " ./package-lock.json" , { encoding : " utf-8" } ) ;
90+ const data = fs . readFileSync ( ' ./package-lock.json' , { encoding : ' utf-8' } ) ;
7791
7892 if ( NON_NPM_REPOSITORY_RE . test ( data ) ) {
79- done ( new Error ( "Found references to the internal registry in the file package-lock.json. Please fix it with replacing all URLs using 'https://registry.npmjs.org'!" ) ) ;
93+ done (
94+ new Error (
95+ "Found references to the internal registry in the file package-lock.json. Please fix it with replacing all URLs using 'https://registry.npmjs.org'!"
96+ )
97+ ) ;
8098 } else {
8199 done ( ) ;
82100 }
83101} ) ;
84102
85103function isWin ( ) {
86- return / ^ w i n / . test ( process . platform ) ;
104+ return / ^ w i n / . test ( process . platform ) ;
87105}
88106
89107function isMac ( ) {
90- return / ^ d a r w i n / . test ( process . platform ) ;
108+ return / ^ d a r w i n / . test ( process . platform ) ;
91109}
92110
93111function isLinux ( ) {
94- return / ^ l i n u x / . test ( process . platform ) ;
112+ return / ^ l i n u x / . test ( process . platform ) ;
95113}
96114
97115function mvnw ( ) {
98- return isWin ( ) ? " mvnw.cmd" : " ./mvnw" ;
116+ return isWin ( ) ? ' mvnw.cmd' : ' ./mvnw' ;
99117}
100118
101119function prependZero ( num ) {
102120 if ( num > 99 ) {
103- throw new Error ( " Unexpected value to prepend with zero" ) ;
121+ throw new Error ( ' Unexpected value to prepend with zero' ) ;
104122 }
105- return `${ num < 10 ? "0" : "" } ${ num } ` ;
123+ return `${ num < 10 ? '0' : '' } ${ num } ` ;
106124}
107125
108126function downloadServerImpl ( ) {
109- fs . rmSync ( './server' , { recursive : true , force : true } ) ;
110- download ( BAZEL_ECLIPSE_LATEST_URL )
111- . pipe ( decompress ( ) )
112- . pipe ( filter ( [ 'plugins/*.jar' ] ) )
113- . pipe ( rename ( function ( path ) {
114- return {
115- dirname : "" , // flatten
116- basename : path . basename ,
117- extname : path . extname
118- } ;
119- } ) )
120- . pipe ( DROP_JAR_VERSION )
121- . pipe ( jarIsIncludedInPackageJson )
122- . pipe ( gulp . dest ( './server' ) ) ;
127+ fs . rmSync ( './server' , { recursive : true , force : true } ) ;
128+ download ( BAZEL_ECLIPSE_LATEST_URL )
129+ . pipe ( decompress ( ) )
130+ . pipe ( filter ( [ 'plugins/*.jar' ] ) )
131+ . pipe (
132+ rename ( function ( path ) {
133+ return {
134+ dirname : '' , // flatten
135+ basename : path . basename ,
136+ extname : path . extname ,
137+ } ;
138+ } )
139+ )
140+ . pipe ( DROP_JAR_VERSION )
141+ . pipe ( jarIsIncludedInPackageJson )
142+ . pipe ( gulp . dest ( './server' ) ) ;
123143}
124144
125145function buildServerImpl ( ) {
126- fs . rmSync ( './server' , { recursive : true , force : true } ) ;
127- cp . execSync ( mvnw ( ) + ' clean package -DskipTests=true' , { cwd : BAZEL_ECLIPSE_DIR , stdio : [ 0 , 1 , 2 ] } ) ;
128- gulp . src ( BAZEL_ECLIPSE_DIR + '/releng/p2repository/target/repository/plugins/*.jar' )
129- . pipe ( DROP_JAR_VERSION )
130- . pipe ( jarIsIncludedInPackageJson )
131- . pipe ( gulp . dest ( './server' ) ) ;
146+ fs . rmSync ( './server' , { recursive : true , force : true } ) ;
147+ cp . execSync ( mvnw ( ) + ' clean package -DskipTests=true' , {
148+ cwd : BAZEL_ECLIPSE_DIR ,
149+ stdio : [ 0 , 1 , 2 ] ,
150+ } ) ;
151+ gulp
152+ . src (
153+ BAZEL_ECLIPSE_DIR + '/releng/p2repository/target/repository/plugins/*.jar'
154+ )
155+ . pipe ( DROP_JAR_VERSION )
156+ . pipe ( jarIsIncludedInPackageJson )
157+ . pipe ( gulp . dest ( './server' ) ) ;
132158}
133-
0 commit comments