@@ -14,6 +14,10 @@ const originalTestFolder = path.join(__dirname, 'test', 'resources', 'projects',
14
14
const tempTestFolder = path . join ( __dirname , 'test-temp' ) ;
15
15
const testSettings = path . join ( tempTestFolder , '.vscode' , 'settings.json' ) ;
16
16
const 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
+ ) ;
17
21
//...
18
22
19
23
gulp . task ( 'clean_jre' , function ( done ) {
@@ -216,6 +220,32 @@ gulp.task('prepare_pre_release', function (done) {
216
220
done ( ) ;
217
221
} ) ;
218
222
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
+
219
249
function isWin ( ) {
220
250
return / ^ w i n / . test ( process . platform ) ;
221
251
}
@@ -252,4 +282,4 @@ function build_server_fn(){
252
282
gulp . src ( server_dir + '/org.eclipse.jdt.ls.product/distro/*.tar.gz' )
253
283
. pipe ( decompress ( ) )
254
284
. pipe ( gulp . dest ( './server' ) ) ;
255
- }
285
+ }
0 commit comments