Upgrade to gulp 4

pull/1329/head
Alex Dima 6 years ago
parent 70e48eeb52
commit 440404716e

@ -26,8 +26,46 @@ const MONACO_EDITOR_VERSION = (function() {
return version;
})();
gulp.task('clean-release', function(cb) { rimraf('release', { maxBusyTries: 1 }, cb); });
gulp.task('release', ['clean-release'], function() {
async function _execute(task) {
// Always invoke as if it were a callback task
return new Promise((resolve, reject) => {
if (task.length === 1) {
// this is a calback task
task((err) => {
if (err) {
return reject(err);
}
resolve();
});
return;
}
const taskResult = task();
if (typeof taskResult === 'undefined') {
// this is a sync task
resolve();
return;
}
if (typeof taskResult.then === 'function') {
// this is a promise returning task
taskResult.then(resolve, reject);
return;
}
// this is a stream returning task
taskResult.on('end', _ => resolve());
taskResult.on('error', err => reject(err));
});
}
function taskSeries(...tasks) {
return async () => {
for (let i = 0; i < tasks.length; i++) {
await _execute(tasks[i]);
}
};
}
const cleanReleaseTask = function(cb) { rimraf('release', { maxBusyTries: 1 }, cb); };
gulp.task('release', taskSeries(cleanReleaseTask, function() {
return es.merge(
// dev folder
@ -44,7 +82,7 @@ gulp.task('release', ['clean-release'], function() {
.pipe(es.through(function(data) {
var json = JSON.parse(data.contents.toString());
json.private = false;
data.contents = new Buffer(JSON.stringify(json, null, ' '));
data.contents = Buffer.from(JSON.stringify(json, null, ' '));
this.emit('data', data);
}))
.pipe(gulp.dest('release')),
@ -53,7 +91,8 @@ gulp.task('release', ['clean-release'], function() {
.pipe(gulp.dest('release')),
// min-maps folder
gulp.src('node_modules/monaco-editor-core/min-maps/**/*').pipe(gulp.dest('release/min-maps')),
gulp.src('node_modules/monaco-editor-core/min-maps/**/*')
.pipe(gulp.dest('release/min-maps')),
// other files
gulp.src([
@ -66,7 +105,7 @@ gulp.task('release', ['clean-release'], function() {
.pipe(addPluginThirdPartyNotices())
.pipe(gulp.dest('release'))
)
});
}));
/**
* Release to `dev` or `min`.
@ -76,6 +115,7 @@ function releaseOne(type) {
gulp.src('node_modules/monaco-editor-core/' + type + '/**/*')
.pipe(addPluginContribs(type))
.pipe(gulp.dest('release/' + type)),
pluginStreams(type, 'release/' + type + '/')
)
}
@ -110,7 +150,7 @@ function pluginStream(plugin, type, destinationPath) {
let contents = data.contents.toString();
contents = contents.replace('define(["require", "exports"],', 'define(["require", "exports", "vs/editor/editor.api"],');
data.contents = new Buffer(contents);
data.contents = Buffer.from(contents);
this.emit('data', data);
}))
.pipe(gulp.dest(destinationPath + plugin.modulePrefix))
@ -197,7 +237,7 @@ function addPluginContribs(type) {
}
contents = contents.substring(0, insertIndex) + '\n' + extraContent.join('\n') + '\n' + contents.substring(insertIndex);
data.contents = new Buffer(contents);
data.contents = Buffer.from(contents);
this.emit('data', data);
});
}
@ -212,6 +252,7 @@ function ESM_release() {
.pipe(ESM_addImportSuffix())
.pipe(ESM_addPluginContribs('release/esm'))
.pipe(gulp.dest('release/esm')),
ESM_pluginStreams('release/esm/')
)
}
@ -275,7 +316,7 @@ function ESM_pluginStream(plugin, destinationPath) {
}
}
data.contents = new Buffer(contents);
data.contents = Buffer.from(contents);
this.emit('data', data);
}))
.pipe(es.through(function(data) {
@ -297,7 +338,7 @@ function ESM_pluginStream(plugin, destinationPath) {
contents
);
data.contents = new Buffer(contents);
data.contents = Buffer.from(contents);
this.emit('data', data);
}))
@ -332,7 +373,7 @@ function ESM_addImportSuffix() {
);
}
data.contents = new Buffer(contents);
data.contents = Buffer.from(contents);
this.emit('data', data);
});
}
@ -376,7 +417,7 @@ function ESM_addPluginContribs(dest) {
this.emit('data', new File({
path: data.path,
base: data.base,
contents: new Buffer(mainFileContents)
contents: Buffer.from(mainFileContents)
}));
});
}
@ -417,12 +458,12 @@ function addPluginDTS() {
// Ensure consistent indentation and line endings
contents = cleanFile(contents);
data.contents = new Buffer(contents);
data.contents = Buffer.from(contents);
this.emit('data', new File({
path: path.join(path.dirname(data.path), 'esm/vs/editor/editor.api.d.ts'),
base: data.base,
contents: new Buffer(toExternalDTS(contents))
contents: Buffer.from(toExternalDTS(contents))
}));
fs.writeFileSync('website/playground/monaco.d.ts.txt', contents);
@ -509,7 +550,7 @@ function addPluginThirdPartyNotices() {
});
contents += '\n' + extraContent.join('\n');
data.contents = new Buffer(contents);
data.contents = Buffer.from(contents);
this.emit('data', data);
});
@ -518,8 +559,8 @@ function addPluginThirdPartyNotices() {
// --- website
gulp.task('clean-website', function(cb) { rimraf('../monaco-editor-website', { maxBusyTries: 1 }, cb); });
gulp.task('build-website', ['clean-website'], function() {
const cleanWebsiteTask = function(cb) { rimraf('../monaco-editor-website', { maxBusyTries: 1 }, cb); };
const buildWebsiteTask = taskSeries(cleanWebsiteTask, function() {
const initialCWD = process.cwd();
@ -600,7 +641,7 @@ gulp.task('build-website', ['clean-website'], function() {
return '<script>' + fileContents.toString('utf8') + '</script>';
});
data.contents = new Buffer(contents.split(/\r\n|\r|\n/).join('\n'));
data.contents = Buffer.from(contents.split(/\r\n|\r|\n/).join('\n'));
this.emit('data', data);
if (done && waiting === 0) {
@ -651,7 +692,7 @@ gulp.task('build-website', ['clean-website'], function() {
cp.execSync('npm install monaco-editor', {
cwd: path.join(__dirname, '../monaco-editor-website')
});
fs.unlink('../monaco-editor-website/package.json');
fs.unlinkSync('../monaco-editor-website/package.json');
this.emit('end');
}))
@ -659,7 +700,7 @@ gulp.task('build-website', ['clean-website'], function() {
});
gulp.task('website', ['build-website'], function() {
gulp.task('website', taskSeries(buildWebsiteTask, function() {
cp.execSync('git init', {
cwd: path.join(__dirname, '../monaco-editor-website')
});
@ -687,10 +728,10 @@ gulp.task('website', ['build-website'], function() {
cp.execSync('git commit -m "Publish website"', {
cwd: path.join(__dirname, '../monaco-editor-website')
});
console.log('RUN monaco-editor-website>git push origin gh-pages --force')
});
console.log('RUN monaco-editor-website>git push origin gh-pages --force');
}));
gulp.task('generate-test-samples', function() {
const generateTestSamplesTask = function() {
var sampleNames = fs.readdirSync(path.join(__dirname, 'test/samples'));
var samples = sampleNames.map(function(sampleName) {
var samplePath = path.join(__dirname, 'test/samples', sampleName);
@ -787,10 +828,10 @@ gulp.task('generate-test-samples', function() {
'</html>',
]
fs.writeFileSync(path.join(__dirname, 'test/playground.generated/index.html'), index.join('\n'));
});
};
gulp.task('simpleserver', ['generate-test-samples'], function(cb) {
gulp.task('simpleserver', taskSeries(generateTestSamplesTask, function() {
httpServer.createServer({ root: '../', cache: 5 }).listen(8080);
httpServer.createServer({ root: '../', cache: 5 }).listen(8088);
console.log('LISTENING on 8080 and 8088');
});
}));

2539
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -19,9 +19,9 @@
},
"devDependencies": {
"clean-css": "^4.2.1",
"event-stream": "3.3.4",
"gulp": "^3.9.1",
"gulp-typedoc": "^2.2.0",
"event-stream": "4.0.1",
"gulp": "^4.0.0",
"gulp-typedoc": "^2.2.2",
"http-server": "^0.11.1",
"monaco-css": "2.3.0",
"monaco-editor-core": "0.15.5",
@ -29,10 +29,10 @@
"monaco-json": "2.3.0",
"monaco-languages": "1.6.0",
"monaco-typescript": "3.3.1",
"rimraf": "^2.6.2",
"rimraf": "^2.6.3",
"typedoc": "^0.11.1",
"typescript": "^3.0.1",
"uncss": "^0.16.2",
"vinyl": "^0.5.3"
"vinyl": "^2.2.0"
}
}

@ -40,8 +40,8 @@ loadEditor(function() {
monaco.languages.register({ id: 'mySpecialLanguage' });
monaco.languages.registerHoverProvider('mySpecialLanguage', {
provideHover: function(model, position) {
return xhr('../playground.html').then(function(res) {
provideHover: function (model, position) {
return xhr('../playground.html').then(function (res) {
return {
range: new monaco.Range(1, 1, model.getLineCount(), model.getLineMaxColumn(model.getLineCount())),
contents: [
@ -60,7 +60,7 @@ monaco.editor.create(document.getElementById("container"), {
function xhr(url) {
var req = null;
return new Promise(function(c,e) {
return new Promise(function (c, e) {
req = new XMLHttpRequest();
req.onreadystatechange = function () {
if (req._canceled) { return; }
@ -75,7 +75,7 @@ function xhr(url) {
}
};
req.open("GET", url, true );
req.open("GET", url, true);
req.responseType = "";
req.send(null);
@ -90,4 +90,4 @@ function xhr(url) {
});
</script>
</body>
</html>
</html>
Loading…
Cancel
Save