|
|
|
@ -7,6 +7,8 @@ const glob = require('glob');
|
|
|
|
|
const path = require('path');
|
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
|
|
const REPO_ROOT = path.join(__dirname, '..');
|
|
|
|
|
|
|
|
|
|
const customFeatureLabels = {
|
|
|
|
|
'vs/editor/browser/controller/coreCommands': 'coreCommands',
|
|
|
|
|
'vs/editor/contrib/caretOperations/caretOperations': 'caretOperations',
|
|
|
|
@ -30,7 +32,7 @@ generateFeatures();
|
|
|
|
|
function getBasicLanguages() {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
glob(
|
|
|
|
|
'./node_modules/monaco-editor/esm/vs/basic-languages/*/*.contribution.js',
|
|
|
|
|
'./release/esm/vs/basic-languages/*/*.contribution.js',
|
|
|
|
|
{ cwd: path.dirname(__dirname) },
|
|
|
|
|
(err, files) => {
|
|
|
|
|
if (err) {
|
|
|
|
@ -40,9 +42,7 @@ function getBasicLanguages() {
|
|
|
|
|
|
|
|
|
|
resolve(
|
|
|
|
|
files.map((file) => {
|
|
|
|
|
const entry = file
|
|
|
|
|
.substring('./node_modules/monaco-editor/esm/'.length)
|
|
|
|
|
.replace(/\.js$/, '');
|
|
|
|
|
const entry = file.substring('./release/esm/'.length).replace(/\.js$/, '');
|
|
|
|
|
const label = path.basename(file).replace(/\.contribution\.js$/, '');
|
|
|
|
|
return {
|
|
|
|
|
label: label,
|
|
|
|
@ -61,7 +61,7 @@ function getBasicLanguages() {
|
|
|
|
|
function readAdvancedLanguages() {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
glob(
|
|
|
|
|
'./node_modules/monaco-editor/esm/vs/language/*/monaco.contribution.js',
|
|
|
|
|
'./release/esm/vs/language/*/monaco.contribution.js',
|
|
|
|
|
{ cwd: path.dirname(__dirname) },
|
|
|
|
|
(err, files) => {
|
|
|
|
|
if (err) {
|
|
|
|
@ -71,7 +71,7 @@ function readAdvancedLanguages() {
|
|
|
|
|
|
|
|
|
|
resolve(
|
|
|
|
|
files
|
|
|
|
|
.map((file) => file.substring('./node_modules/monaco-editor/esm/vs/language/'.length))
|
|
|
|
|
.map((file) => file.substring('./release/esm/vs/language/'.length))
|
|
|
|
|
.map((file) => file.substring(0, file.length - '/monaco.contribution.js'.length))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
@ -90,7 +90,6 @@ function getAdvancedLanguages() {
|
|
|
|
|
const entry = `vs/language/${lang}/monaco.contribution`;
|
|
|
|
|
checkFileExists(entry);
|
|
|
|
|
const workerId = `vs/language/${lang}/${shortLang}Worker`;
|
|
|
|
|
checkFileExists(workerId);
|
|
|
|
|
const workerEntry = `vs/language/${lang}/${shortLang}.worker`;
|
|
|
|
|
checkFileExists(workerEntry);
|
|
|
|
|
result.push({
|
|
|
|
@ -106,12 +105,7 @@ function getAdvancedLanguages() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function checkFileExists(moduleName) {
|
|
|
|
|
const filePath = path.join(
|
|
|
|
|
__dirname,
|
|
|
|
|
'..',
|
|
|
|
|
'node_modules/monaco-editor/esm',
|
|
|
|
|
`${moduleName}.js`
|
|
|
|
|
);
|
|
|
|
|
const filePath = path.join(REPO_ROOT, 'release/esm', `${moduleName}.js`);
|
|
|
|
|
if (!fs.existsSync(filePath)) {
|
|
|
|
|
console.error(`Could not find ${filePath}.`);
|
|
|
|
|
process.exit(1);
|
|
|
|
@ -175,17 +169,20 @@ export const languagesArr: IFeatureDefinition[] = ${JSON.stringify(result, null,
|
|
|
|
|
export type EditorLanguage = ${result.map((el) => `'${el.label}'`).join(' | ')};
|
|
|
|
|
|
|
|
|
|
`;
|
|
|
|
|
fs.writeFileSync(path.join(__dirname, '../src/languages.ts'), code.replace(/\r\n/g, '\n'));
|
|
|
|
|
fs.writeFileSync(
|
|
|
|
|
path.join(REPO_ROOT, 'webpack-plugin/src/languages.ts'),
|
|
|
|
|
code.replace(/\r\n/g, '\n')
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const readmeLanguages = JSON.stringify(result.map((r) => r.label))
|
|
|
|
|
.replace(/"/g, "'")
|
|
|
|
|
.replace(/','/g, "', '");
|
|
|
|
|
let readme = fs.readFileSync(path.join(__dirname, '../README.md')).toString();
|
|
|
|
|
let readme = fs.readFileSync(path.join(REPO_ROOT, 'webpack-plugin/README.md')).toString();
|
|
|
|
|
readme = readme.replace(
|
|
|
|
|
/<!-- LANGUAGES_BEGIN -->([^<]+)<!-- LANGUAGES_END -->/,
|
|
|
|
|
`<!-- LANGUAGES_BEGIN -->\`${readmeLanguages}\`<!-- LANGUAGES_END -->`
|
|
|
|
|
);
|
|
|
|
|
fs.writeFileSync(path.join(__dirname, '../README.md'), readme);
|
|
|
|
|
fs.writeFileSync(path.join(REPO_ROOT, 'webpack-plugin/README.md'), readme);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
@ -217,16 +214,8 @@ function generateFeatures() {
|
|
|
|
|
|
|
|
|
|
let features = [];
|
|
|
|
|
const files =
|
|
|
|
|
fs
|
|
|
|
|
.readFileSync(
|
|
|
|
|
path.join(__dirname, '../node_modules/monaco-editor/esm/vs/editor/edcore.main.js')
|
|
|
|
|
)
|
|
|
|
|
.toString() +
|
|
|
|
|
fs
|
|
|
|
|
.readFileSync(
|
|
|
|
|
path.join(__dirname, '../node_modules/monaco-editor/esm/vs/editor/editor.all.js')
|
|
|
|
|
)
|
|
|
|
|
.toString();
|
|
|
|
|
fs.readFileSync(path.join(REPO_ROOT, 'release/esm/vs/editor/edcore.main.js')).toString() +
|
|
|
|
|
fs.readFileSync(path.join(REPO_ROOT, 'release/esm/vs/editor/editor.all.js')).toString();
|
|
|
|
|
files.split(/\r\n|\n/).forEach((line) => {
|
|
|
|
|
const m = line.match(/import '([^']+)'/);
|
|
|
|
|
if (m) {
|
|
|
|
@ -277,15 +266,18 @@ export type EditorFeature = ${result.map((el) => `'${el.label}'`).join(' | ')};
|
|
|
|
|
|
|
|
|
|
export type NegatedEditorFeature = ${result.map((el) => `'!${el.label}'`).join(' | ')};
|
|
|
|
|
`;
|
|
|
|
|
fs.writeFileSync(path.join(__dirname, '../src/features.ts'), code.replace(/\r\n/g, '\n'));
|
|
|
|
|
fs.writeFileSync(
|
|
|
|
|
path.join(REPO_ROOT, 'webpack-plugin/src/features.ts'),
|
|
|
|
|
code.replace(/\r\n/g, '\n')
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const readmeFeatures = JSON.stringify(result.map((r) => r.label))
|
|
|
|
|
.replace(/"/g, "'")
|
|
|
|
|
.replace(/','/g, "', '");
|
|
|
|
|
let readme = fs.readFileSync(path.join(__dirname, '../README.md')).toString();
|
|
|
|
|
let readme = fs.readFileSync(path.join(REPO_ROOT, 'webpack-plugin/README.md')).toString();
|
|
|
|
|
readme = readme.replace(
|
|
|
|
|
/<!-- FEATURES_BEGIN -->([^<]+)<!-- FEATURES_END -->/,
|
|
|
|
|
`<!-- FEATURES_BEGIN -->\`${readmeFeatures}\`<!-- FEATURES_END -->`
|
|
|
|
|
);
|
|
|
|
|
fs.writeFileSync(path.join(__dirname, '../README.md'), readme);
|
|
|
|
|
fs.writeFileSync(path.join(REPO_ROOT, 'webpack-plugin/README.md'), readme);
|
|
|
|
|
}
|