mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 15:05:39 +01:00
Minor improvements
This commit is contained in:
parent
c419101f73
commit
94ca41beeb
3 changed files with 80 additions and 30 deletions
|
|
@ -145,3 +145,72 @@ function dts(_source, _destination, namespace) {
|
||||||
prettier(_destination);
|
prettier(_destination);
|
||||||
}
|
}
|
||||||
exports.dts = dts;
|
exports.dts = dts;
|
||||||
|
|
||||||
|
function getGitVersion() {
|
||||||
|
const git = path.join(REPO_ROOT, '.git');
|
||||||
|
const headPath = path.join(git, 'HEAD');
|
||||||
|
let head;
|
||||||
|
|
||||||
|
try {
|
||||||
|
head = fs.readFileSync(headPath, 'utf8').trim();
|
||||||
|
} catch (e) {
|
||||||
|
return void 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^[0-9a-f]{40}$/i.test(head)) {
|
||||||
|
return head;
|
||||||
|
}
|
||||||
|
|
||||||
|
const refMatch = /^ref: (.*)$/.exec(head);
|
||||||
|
|
||||||
|
if (!refMatch) {
|
||||||
|
return void 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ref = refMatch[1];
|
||||||
|
const refPath = path.join(git, ref);
|
||||||
|
|
||||||
|
try {
|
||||||
|
return fs.readFileSync(refPath, 'utf8').trim();
|
||||||
|
} catch (e) {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
|
|
||||||
|
const packedRefsPath = path.join(git, 'packed-refs');
|
||||||
|
let refsRaw;
|
||||||
|
|
||||||
|
try {
|
||||||
|
refsRaw = fs.readFileSync(packedRefsPath, 'utf8').trim();
|
||||||
|
} catch (e) {
|
||||||
|
return void 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const refsRegex = /^([0-9a-f]{40})\s+(.+)$/gm;
|
||||||
|
let refsMatch;
|
||||||
|
const refs = {};
|
||||||
|
|
||||||
|
while (refsMatch = refsRegex.exec(refsRaw)) {
|
||||||
|
refs[refsMatch[2]] = refsMatch[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
return refs[ref];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getBundledFileHeader() {
|
||||||
|
const sha1 = getGitVersion();
|
||||||
|
const semver = require('../package.json').version;
|
||||||
|
const headerVersion = semver + '(' + sha1 + ')';
|
||||||
|
|
||||||
|
const BUNDLED_FILE_HEADER = [
|
||||||
|
'/*!-----------------------------------------------------------------------------',
|
||||||
|
' * Copyright (c) Microsoft Corporation. All rights reserved.',
|
||||||
|
' * Version: ' + headerVersion,
|
||||||
|
' * Released under the MIT license',
|
||||||
|
' * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt',
|
||||||
|
' *-----------------------------------------------------------------------------*/',
|
||||||
|
''
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
|
return BUNDLED_FILE_HEADER;
|
||||||
|
}
|
||||||
|
exports.getBundledFileHeader = getBundledFileHeader;
|
||||||
|
|
|
||||||
|
|
@ -6,24 +6,12 @@
|
||||||
const requirejs = require('requirejs');
|
const requirejs = require('requirejs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const Terser = require('terser');
|
const terser = require('terser');
|
||||||
const helpers = require('monaco-plugin-helpers');
|
const { getBundledFileHeader } = require('../../build/utils');
|
||||||
|
|
||||||
const REPO_ROOT = path.resolve(__dirname, '..', '..');
|
const REPO_ROOT = path.resolve(__dirname, '..', '..');
|
||||||
|
|
||||||
const sha1 = helpers.getGitVersion(REPO_ROOT);
|
const BUNDLED_FILE_HEADER = getBundledFileHeader();
|
||||||
const semver = require('../../package.json').version;
|
|
||||||
const headerVersion = semver + '(' + sha1 + ')';
|
|
||||||
|
|
||||||
const BUNDLED_FILE_HEADER = [
|
|
||||||
'/*!-----------------------------------------------------------------------------',
|
|
||||||
' * Copyright (c) Microsoft Corporation. All rights reserved.',
|
|
||||||
' * Version: ' + headerVersion,
|
|
||||||
' * Released under the MIT license',
|
|
||||||
' * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt',
|
|
||||||
' *-----------------------------------------------------------------------------*/',
|
|
||||||
''
|
|
||||||
].join('\n');
|
|
||||||
|
|
||||||
bundleOne('monaco.contribution');
|
bundleOne('monaco.contribution');
|
||||||
bundleOne('cssMode', ['vs/language/css/monaco.contribution']);
|
bundleOne('cssMode', ['vs/language/css/monaco.contribution']);
|
||||||
|
|
@ -76,7 +64,7 @@ function bundleOne(moduleId, exclude) {
|
||||||
const fileContents = fs.readFileSync(devFilePath).toString();
|
const fileContents = fs.readFileSync(devFilePath).toString();
|
||||||
console.log();
|
console.log();
|
||||||
console.log(`Minifying ${devFilePath}...`);
|
console.log(`Minifying ${devFilePath}...`);
|
||||||
const result = await Terser.minify(fileContents, {
|
const result = await terser.minify(fileContents, {
|
||||||
output: {
|
output: {
|
||||||
comments: 'some'
|
comments: 'some'
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,17 @@
|
||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
const requirejs = require('requirejs');
|
const requirejs = require('requirejs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const terser = require('terser');
|
const terser = require('terser');
|
||||||
const helpers = require('monaco-plugin-helpers');
|
const { getBundledFileHeader } = require('../../build/utils');
|
||||||
|
|
||||||
const REPO_ROOT = path.resolve(__dirname, '..', '..');
|
const REPO_ROOT = path.resolve(__dirname, '..', '..');
|
||||||
|
|
||||||
const sha1 = helpers.getGitVersion(REPO_ROOT);
|
const BUNDLED_FILE_HEADER = getBundledFileHeader();
|
||||||
const semver = require('../../package.json').version;
|
|
||||||
const headerVersion = semver + '(' + sha1 + ')';
|
|
||||||
|
|
||||||
const BUNDLED_FILE_HEADER = [
|
|
||||||
'/*!-----------------------------------------------------------------------------',
|
|
||||||
' * Copyright (c) Microsoft Corporation. All rights reserved.',
|
|
||||||
' * Version: ' + headerVersion,
|
|
||||||
' * Released under the MIT license',
|
|
||||||
' * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt',
|
|
||||||
' *-----------------------------------------------------------------------------*/',
|
|
||||||
''
|
|
||||||
].join('\n');
|
|
||||||
|
|
||||||
bundleOne('monaco.contribution');
|
bundleOne('monaco.contribution');
|
||||||
bundleOne('htmlMode', ['vs/language/html/monaco.contribution']);
|
bundleOne('htmlMode', ['vs/language/html/monaco.contribution']);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue