mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 22:02:55 +01:00
Fixes to website scripts
This commit is contained in:
parent
5a7ba61be9
commit
e9074202ae
3 changed files with 22 additions and 8 deletions
24
gulpfile.js
24
gulpfile.js
|
|
@ -20,6 +20,7 @@ const File = require('vinyl');
|
||||||
const ts = require('typescript');
|
const ts = require('typescript');
|
||||||
|
|
||||||
const WEBSITE_GENERATED_PATH = path.join(__dirname, 'monaco-editor/website/playground/new-samples');
|
const WEBSITE_GENERATED_PATH = path.join(__dirname, 'monaco-editor/website/playground/new-samples');
|
||||||
|
/** @type {string} */
|
||||||
const MONACO_EDITOR_VERSION = (function () {
|
const MONACO_EDITOR_VERSION = (function () {
|
||||||
const packageJsonPath = path.join(__dirname, 'package.json');
|
const packageJsonPath = path.join(__dirname, 'package.json');
|
||||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString());
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath).toString());
|
||||||
|
|
@ -653,6 +654,13 @@ const cleanWebsiteTask = function (cb) {
|
||||||
rimraf('../monaco-editor-website', { maxBusyTries: 1 }, cb);
|
rimraf('../monaco-editor-website', { maxBusyTries: 1 }, cb);
|
||||||
};
|
};
|
||||||
const buildWebsiteTask = taskSeries(cleanWebsiteTask, function () {
|
const buildWebsiteTask = taskSeries(cleanWebsiteTask, function () {
|
||||||
|
/**
|
||||||
|
* @param {string} dataPath
|
||||||
|
* @param {string} contents
|
||||||
|
* @param {RegExp} regex
|
||||||
|
* @param {(match:string, fileContents:Buffer)=>string} callback
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
function replaceWithRelativeResource(dataPath, contents, regex, callback) {
|
function replaceWithRelativeResource(dataPath, contents, regex, callback) {
|
||||||
return contents.replace(regex, function (_, m0) {
|
return contents.replace(regex, function (_, m0) {
|
||||||
var filePath = path.join(path.dirname(dataPath), m0);
|
var filePath = path.join(path.dirname(dataPath), m0);
|
||||||
|
|
@ -666,15 +674,18 @@ const buildWebsiteTask = taskSeries(cleanWebsiteTask, function () {
|
||||||
return es
|
return es
|
||||||
.merge(
|
.merge(
|
||||||
gulp
|
gulp
|
||||||
.src(['website/**/*'], { dot: true })
|
.src(['monaco-editor/website/**/*'], { dot: true })
|
||||||
.pipe(
|
.pipe(
|
||||||
es.through(
|
es.through(
|
||||||
|
/**
|
||||||
|
* @param {File} data
|
||||||
|
*/
|
||||||
function (data) {
|
function (data) {
|
||||||
if (!data.contents || !/\.(html)$/.test(data.path) || /new-samples/.test(data.path)) {
|
if (!data.contents || !/\.(html)$/.test(data.path) || /new-samples/.test(data.path)) {
|
||||||
return this.emit('data', data);
|
return this.emit('data', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
var contents = data.contents.toString();
|
let contents = data.contents.toString();
|
||||||
contents = contents.replace(/\.\.\/release\/dev/g, 'node_modules/monaco-editor/min');
|
contents = contents.replace(/\.\.\/release\/dev/g, 'node_modules/monaco-editor/min');
|
||||||
contents = contents.replace(/{{version}}/g, MONACO_EDITOR_VERSION);
|
contents = contents.replace(/{{version}}/g, MONACO_EDITOR_VERSION);
|
||||||
contents = contents.replace(/{{year}}/g, new Date().getFullYear());
|
contents = contents.replace(/{{year}}/g, new Date().getFullYear());
|
||||||
|
|
@ -709,8 +720,8 @@ const buildWebsiteTask = taskSeries(cleanWebsiteTask, function () {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
var allCSS = '';
|
let allCSS = '';
|
||||||
var tmpcontents = replaceWithRelativeResource(
|
let tmpcontents = replaceWithRelativeResource(
|
||||||
data.path,
|
data.path,
|
||||||
contents,
|
contents,
|
||||||
/<link data-inline="yes-please" href="([^"]+)".*/g,
|
/<link data-inline="yes-please" href="([^"]+)".*/g,
|
||||||
|
|
@ -734,7 +745,7 @@ const buildWebsiteTask = taskSeries(cleanWebsiteTask, function () {
|
||||||
|
|
||||||
if (!err) {
|
if (!err) {
|
||||||
output = new CleanCSS().minify(output).styles;
|
output = new CleanCSS().minify(output).styles;
|
||||||
var isFirst = true;
|
let isFirst = true;
|
||||||
contents = contents.replace(
|
contents = contents.replace(
|
||||||
/<link data-inline="yes-please" href="([^"]+)".*/g,
|
/<link data-inline="yes-please" href="([^"]+)".*/g,
|
||||||
function (_, m0) {
|
function (_, m0) {
|
||||||
|
|
@ -779,6 +790,9 @@ const buildWebsiteTask = taskSeries(cleanWebsiteTask, function () {
|
||||||
|
|
||||||
.pipe(
|
.pipe(
|
||||||
es.through(
|
es.through(
|
||||||
|
/**
|
||||||
|
* @param {File} data
|
||||||
|
*/
|
||||||
function (data) {
|
function (data) {
|
||||||
this.emit('data', data);
|
this.emit('data', data);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"entryPoints": ["monaco.d.ts"],
|
"entryPoints": ["monaco.d.ts"],
|
||||||
"out": "../../monaco-editor-website/api",
|
"out": "../../../monaco-editor-website/api",
|
||||||
"theme": "./theme",
|
"theme": "default",
|
||||||
"name": "Monaco Editor API",
|
"name": "Monaco Editor API",
|
||||||
"readme": "none",
|
"readme": "none",
|
||||||
"hideGenerator": true
|
"hideGenerator": true
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
"release": "npm run release-css && npm run release-html && npm run release-json && npm run release-languages && npm run release-typescript && gulp release",
|
"release": "npm run release-css && npm run release-html && npm run release-json && npm run release-languages && npm run release-typescript && gulp release",
|
||||||
"website": "gulp build-website && npm run typedoc && gulp prepare-website-branch",
|
"website": "gulp build-website && npm run typedoc && gulp prepare-website-branch",
|
||||||
"build-website": "gulp build-website && npm run typedoc",
|
"build-website": "gulp build-website && npm run typedoc",
|
||||||
"typedoc": "cd typedoc && \"../node_modules/.bin/typedoc\" --options ./typedoc.json",
|
"typedoc": "cd monaco-editor/typedoc && \"../../node_modules/.bin/typedoc\" --options ./typedoc.json",
|
||||||
"prettier": "prettier --write ."
|
"prettier": "prettier --write ."
|
||||||
},
|
},
|
||||||
"typings": "./esm/vs/editor/editor.api.d.ts",
|
"typings": "./esm/vs/editor/editor.api.d.ts",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue