@@ -14,6 +14,10 @@ const originalTestFolder = path.join(__dirname, 'test', 'resources', 'projects',
1414const tempTestFolder = path . join ( __dirname , 'test-temp' ) ;
1515const testSettings = path . join ( tempTestFolder , '.vscode' , 'settings.json' ) ;
1616const JDT_LS_SNAPSHOT_URL = "http://download.eclipse.org/jdtls/snapshots/jdt-language-server-latest.tar.gz"
17+ const NON_NPM_REPOSITORY_RE = new RegExp (
18+ String . raw `"resolved":\s*"https://.+/registry.npmjs.org/` ,
19+ "g"
20+ ) ;
1721//...
1822
1923gulp . task ( 'clean_jre' , function ( done ) {
@@ -216,6 +220,32 @@ gulp.task('prepare_pre_release', function (done) {
216220 done ( ) ;
217221} ) ;
218222
223+ gulp . task ( 'repo_check' , function ( done ) {
224+ const data = fse . readFileSync ( "./package-lock.json" , { encoding : "utf-8" } ) ;
225+
226+ if ( NON_NPM_REPOSITORY_RE . test ( data ) ) {
227+ done ( new Error ( "Found references to the internal registry in the file package-lock.json. Please fix it with 'npm run repo:fix'" ) ) ;
228+ } else {
229+ done ( ) ;
230+ }
231+ } ) ;
232+
233+ gulp . task ( 'repo_fix' , function ( done ) {
234+ const data = fse . readFileSync ( "./package-lock.json" , { encoding : "utf-8" } ) ;
235+ const newData = data . replace ( NON_NPM_REPOSITORY_RE , `"resolved": "https://registry.npmjs.org/` ) ;
236+
237+ if ( data !== newData ) {
238+ fse . writeFileSync ( "./package-lock.json" , newData , {
239+ encoding : "utf-8" ,
240+ } ) ;
241+ console . log ( `successfully fixed package-lock.json` ) ;
242+ } else {
243+ console . log ( "nothing to fix" ) ;
244+ }
245+
246+ done ( ) ;
247+ } ) ;
248+
219249function isWin ( ) {
220250 return / ^ w i n / . test ( process . platform ) ;
221251}
@@ -252,4 +282,4 @@ function build_server_fn(){
252282 gulp . src ( server_dir + '/org.eclipse.jdt.ls.product/distro/*.tar.gz' )
253283 . pipe ( decompress ( ) )
254284 . pipe ( gulp . dest ( './server' ) ) ;
255- }
285+ }
0 commit comments