mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 15:05:39 +01:00
Merge pull request #2937 from microsoft/hediet/typify-build
Convert build scripts to JavaScript.
This commit is contained in:
commit
c9be1b35fb
14 changed files with 231 additions and 233 deletions
|
|
@ -3,11 +3,9 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
//@ts-check
|
||||
|
||||
const glob = require('glob');
|
||||
const { tsc, dts, buildESM, buildAMD } = require('../build/utils');
|
||||
const { copyFile, removeDir } = require('../build/fs');
|
||||
import glob from 'glob';
|
||||
import { tsc, dts, buildESM, buildAMD } from './utils';
|
||||
import { copyFile, removeDir } from './fs';
|
||||
|
||||
removeDir(`out`);
|
||||
|
||||
|
|
@ -3,18 +3,14 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
//@ts-check
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
const REPO_ROOT = path.join(__dirname, '../');
|
||||
|
||||
const existingDirCache = new Set();
|
||||
/**
|
||||
* @param {string} dirname
|
||||
*/
|
||||
function ensureDir(dirname) {
|
||||
|
||||
export function ensureDir(dirname: string) {
|
||||
/** @type {string[]} */
|
||||
const dirs = [];
|
||||
|
||||
|
|
@ -32,15 +28,11 @@ function ensureDir(dirname) {
|
|||
}
|
||||
});
|
||||
}
|
||||
exports.ensureDir = ensureDir;
|
||||
|
||||
/**
|
||||
* Copy a file.
|
||||
*
|
||||
* @param {string} _source
|
||||
* @param {string} _destination
|
||||
*/
|
||||
function copyFile(_source, _destination) {
|
||||
export function copyFile(_source: string, _destination: string) {
|
||||
const source = path.join(REPO_ROOT, _source);
|
||||
const destination = path.join(REPO_ROOT, _destination);
|
||||
|
||||
|
|
@ -49,15 +41,11 @@ function copyFile(_source, _destination) {
|
|||
|
||||
console.log(`Copied ${_source} to ${_destination}`);
|
||||
}
|
||||
exports.copyFile = copyFile;
|
||||
|
||||
/**
|
||||
* Remove a directory and all its contents.
|
||||
*
|
||||
* @param {string} _dirPath
|
||||
* @param {((filename:string)=>boolean)} [keep]
|
||||
*/
|
||||
function removeDir(_dirPath, keep) {
|
||||
export function removeDir(_dirPath: string, keep?: (filename: string) => boolean) {
|
||||
if (typeof keep === 'undefined') {
|
||||
keep = () => false;
|
||||
}
|
||||
|
|
@ -95,4 +83,3 @@ function removeDir(_dirPath, keep) {
|
|||
return keepsFiles;
|
||||
}
|
||||
}
|
||||
exports.removeDir = removeDir;
|
||||
|
|
@ -3,12 +3,10 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
//@ts-check
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const child_process = require('child_process');
|
||||
const { REPO_ROOT } = require('./utils');
|
||||
import path = require('path');
|
||||
import fs = require('fs');
|
||||
import child_process = require('child_process');
|
||||
import { REPO_ROOT } from './utils';
|
||||
|
||||
const generatedNote = `//
|
||||
// **NOTE**: Do not edit directly! This file is generated using \`npm run import-typescript\`
|
||||
|
|
@ -3,14 +3,12 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
//@ts-check
|
||||
|
||||
const glob = require('glob');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const cp = require('child_process');
|
||||
import glob = require('glob');
|
||||
import path = require('path');
|
||||
import fs = require('fs');
|
||||
import cp = require('child_process');
|
||||
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
||||
const { REPO_ROOT } = require('../utils');
|
||||
import { REPO_ROOT } from '../utils';
|
||||
|
||||
const files = glob.sync('**/package.json', {
|
||||
cwd: REPO_ROOT,
|
||||
|
|
@ -29,18 +27,16 @@ for (const file of files) {
|
|||
}
|
||||
|
||||
function npmInstall(location) {
|
||||
/** @type {'inherit'} */
|
||||
const stdio = 'inherit';
|
||||
const opts = {
|
||||
env: process.env,
|
||||
cwd: location,
|
||||
stdio
|
||||
};
|
||||
const args = ['install'];
|
||||
|
||||
console.log(`Installing dependencies in ${location}...`);
|
||||
console.log(`$ npm ${args.join(' ')}`);
|
||||
const result = cp.spawnSync(npm, args, opts);
|
||||
const result = cp.spawnSync(npm, args, {
|
||||
env: process.env,
|
||||
cwd: location,
|
||||
stdio
|
||||
});
|
||||
|
||||
if (result.error || result.status !== 0) {
|
||||
process.exit(1);
|
||||
|
|
@ -3,12 +3,10 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
//@ts-check
|
||||
|
||||
const glob = require('glob');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { REPO_ROOT } = require('../utils');
|
||||
import glob from 'glob';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { REPO_ROOT } from '../utils';
|
||||
|
||||
const files = glob.sync('**/package-lock.json', {
|
||||
cwd: REPO_ROOT,
|
||||
|
|
@ -3,8 +3,8 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
const cp = require('child_process');
|
||||
const path = require('path');
|
||||
import cp = require('child_process');
|
||||
import path = require('path');
|
||||
|
||||
function huskyInstall() {
|
||||
console.log(`Installing husky hooks...`);
|
||||
|
|
@ -3,16 +3,12 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
//@ts-check
|
||||
|
||||
/** @typedef {import('../build/utils').IFile} IFile */
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { REPO_ROOT, readFiles, writeFiles } = require('../build/utils');
|
||||
const { removeDir } = require('../build/fs');
|
||||
const ts = require('typescript');
|
||||
const { generateMetadata } = require('./releaseMetadata');
|
||||
import path = require('path');
|
||||
import fs = require('fs');
|
||||
import { REPO_ROOT, readFiles, writeFiles, IFile } from '../build/utils';
|
||||
import { removeDir } from '../build/fs';
|
||||
import ts = require('typescript');
|
||||
import { generateMetadata } from './releaseMetadata';
|
||||
|
||||
removeDir(`release`);
|
||||
|
||||
|
|
@ -89,11 +85,8 @@ function AMD_releaseOne(type) {
|
|||
* - rename the AMD module 'vs/editor/editor.main' to 'vs/editor/edcore.main'
|
||||
* - append monaco.contribution modules from plugins
|
||||
* - append new AMD module 'vs/editor/editor.main' that stiches things together
|
||||
*
|
||||
* @param {'dev'|'min'} type
|
||||
* @param {IFile[]} files
|
||||
*/
|
||||
function AMD_addPluginContribs(type, files) {
|
||||
function AMD_addPluginContribs(type: 'dev' | 'min', files: IFile[]) {
|
||||
for (const file of files) {
|
||||
if (!/editor\.main\.js$/.test(file.path)) {
|
||||
continue;
|
||||
|
|
@ -223,9 +216,8 @@ function ESM_releasePlugins() {
|
|||
|
||||
/**
|
||||
* Adds `.js` to all import statements.
|
||||
* @param {IFile[]} files
|
||||
*/
|
||||
function ESM_addImportSuffix(files) {
|
||||
function ESM_addImportSuffix(files: IFile[]) {
|
||||
for (const file of files) {
|
||||
if (!/\.js$/.test(file.path)) {
|
||||
continue;
|
||||
|
|
@ -254,9 +246,8 @@ function ESM_addImportSuffix(files) {
|
|||
/**
|
||||
* - Rename esm/vs/editor/editor.main.js to esm/vs/editor/edcore.main.js
|
||||
* - Create esm/vs/editor/editor.main.js that that stiches things together
|
||||
* @param {IFile[]} files
|
||||
*/
|
||||
function ESM_addPluginContribs(files) {
|
||||
function ESM_addPluginContribs(files: IFile[]) {
|
||||
for (const file of files) {
|
||||
if (!/editor\.main\.js$/.test(file.path)) {
|
||||
continue;
|
||||
|
|
@ -340,10 +331,8 @@ function releaseDTS() {
|
|||
/**
|
||||
* Transforms a .d.ts which uses internal modules (namespaces) to one which is usable with external modules
|
||||
* This function is duplicated in the `vscode` repo.
|
||||
* @param {string} contents
|
||||
* @returns string
|
||||
*/
|
||||
function toExternalDTS(contents) {
|
||||
function toExternalDTS(contents: string): string {
|
||||
let lines = contents.split(/\r\n|\r|\n/);
|
||||
let killNextCloseCurlyBrace = false;
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
|
|
@ -387,10 +376,8 @@ function toExternalDTS(contents) {
|
|||
|
||||
/**
|
||||
* Normalize line endings and ensure consistent 4 spaces indentation
|
||||
* @param {string} contents
|
||||
* @returns {string}
|
||||
*/
|
||||
function cleanFile(contents) {
|
||||
function cleanFile(contents: string): string {
|
||||
return contents
|
||||
.split(/\r\n|\r|\n/)
|
||||
.map(function (line) {
|
||||
|
|
@ -3,13 +3,11 @@
|
|||
* Licensed under the MIT License. See LICENSE in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
//@ts-check
|
||||
|
||||
const glob = require('glob');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const { REPO_ROOT } = require('./utils');
|
||||
const { ensureDir } = require('./fs');
|
||||
import glob = require('glob');
|
||||
import path = require('path');
|
||||
import fs = require('fs');
|
||||
import { REPO_ROOT } from './utils';
|
||||
import { ensureDir } from './fs';
|
||||
|
||||
const customFeatureLabels = {
|
||||
'vs/editor/browser/controller/coreCommands': 'coreCommands',
|
||||
|
|
@ -25,10 +23,7 @@ const customFeatureLabels = {
|
|||
'vs/editor/standalone/browser/quickAccess/standaloneHelpQuickAccess': 'quickHelp'
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns { Promise<{ label: string; entry: string; }[]> }
|
||||
*/
|
||||
function getBasicLanguages() {
|
||||
function getBasicLanguages(): Promise<{ label: string; entry: string }[]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
glob(
|
||||
'./release/esm/vs/basic-languages/*/*.contribution.js',
|
||||
|
|
@ -54,10 +49,7 @@ function getBasicLanguages() {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns { Promise<string[]> }
|
||||
*/
|
||||
function readAdvancedLanguages() {
|
||||
function readAdvancedLanguages(): Promise<string[]> {
|
||||
return new Promise((resolve, reject) => {
|
||||
glob(
|
||||
'./release/esm/vs/language/*/monaco.contribution.js',
|
||||
|
|
@ -78,10 +70,9 @@ function readAdvancedLanguages() {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns { Promise<{ label: string; entry: string; worker: { id: string; entry: string; }; }[]> }
|
||||
*/
|
||||
function getAdvancedLanguages() {
|
||||
function getAdvancedLanguages(): Promise<
|
||||
{ label: string; entry: string; worker: { id: string; entry: string } }[]
|
||||
> {
|
||||
return readAdvancedLanguages().then((languages) => {
|
||||
let result = [];
|
||||
for (const lang of languages) {
|
||||
|
|
@ -112,11 +103,11 @@ function getAdvancedLanguages() {
|
|||
}
|
||||
}
|
||||
|
||||
function generateMetadata() {
|
||||
export function generateMetadata() {
|
||||
return Promise.all([getBasicLanguages(), getAdvancedLanguages()]).then(
|
||||
([basicLanguages, advancedLanguages]) => {
|
||||
basicLanguages.sort(strcmp);
|
||||
advancedLanguages.sort(strcmp);
|
||||
basicLanguages.sort((a, b) => strcmp(a.entry, b.entry));
|
||||
advancedLanguages.sort((a, b) => strcmp(a.entry, b.entry));
|
||||
|
||||
let i = 0,
|
||||
len = basicLanguages.length;
|
||||
|
|
@ -197,13 +188,8 @@ exports.languages = ${JSON.stringify(languages, null, ' ')};
|
|||
}
|
||||
);
|
||||
}
|
||||
exports.generateMetadata = generateMetadata;
|
||||
|
||||
/**
|
||||
* @tyoe {string} a
|
||||
* @tyoe {string} b
|
||||
*/
|
||||
function strcmp(a, b) {
|
||||
function strcmp(a: string, b: string) {
|
||||
if (a < b) {
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -213,10 +199,7 @@ function strcmp(a, b) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {{label:string;entry:string|string[];}[]}
|
||||
*/
|
||||
function getFeatures() {
|
||||
function getFeatures(): { label: string; entry: string | string[] }[] {
|
||||
const skipImports = [
|
||||
'vs/editor/browser/widget/codeEditorWidget',
|
||||
'vs/editor/browser/widget/diffEditorWidget',
|
||||
|
|
@ -228,8 +211,7 @@ function getFeatures() {
|
|||
'vs/editor/contrib/gotoSymbol/documentSymbols'
|
||||
];
|
||||
|
||||
/** @type {string[]} */
|
||||
let features = [];
|
||||
let features: string[] = [];
|
||||
const files =
|
||||
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();
|
||||
|
|
@ -243,8 +225,7 @@ function getFeatures() {
|
|||
}
|
||||
});
|
||||
|
||||
/** @type {{label:string;entry:any;}[]} */
|
||||
let result = features.map((feature) => {
|
||||
let result: { label: string; entry: any }[] = features.map((feature) => {
|
||||
/** @type {string} */ let label;
|
||||
if (customFeatureLabels[feature]) {
|
||||
label = customFeatureLabels[feature];
|
||||
|
|
@ -3,14 +3,12 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
//@ts-check
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const http = require('http');
|
||||
const yaserver = require('yaserver');
|
||||
const { REPO_ROOT } = require('./utils');
|
||||
const { ensureDir } = require('./fs');
|
||||
import fs = require('fs');
|
||||
import path = require('path');
|
||||
import http = require('http');
|
||||
import yaserver = require('yaserver');
|
||||
import { REPO_ROOT } from './utils';
|
||||
import { ensureDir } from './fs';
|
||||
|
||||
const WEBSITE_GENERATED_PATH = path.join(REPO_ROOT, 'website/playground/new-samples');
|
||||
|
||||
|
|
@ -157,11 +155,7 @@ function generateTestSamplesTask() {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} rootDir
|
||||
* @param {number} port
|
||||
*/
|
||||
function createSimpleServer(rootDir, port) {
|
||||
function createSimpleServer(rootDir: string, port: number) {
|
||||
yaserver
|
||||
.createServer({
|
||||
rootDir: rootDir
|
||||
7
build/tsconfig.json
Normal file
7
build/tsconfig.json
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"files": ["./**/*"]
|
||||
}
|
||||
|
|
@ -3,26 +3,20 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
//@ts-check
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as cp from 'child_process';
|
||||
import * as esbuild from 'esbuild';
|
||||
import alias from 'esbuild-plugin-alias';
|
||||
import * as glob from 'glob';
|
||||
import { ensureDir } from './fs';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const cp = require('child_process');
|
||||
const esbuild = require('esbuild');
|
||||
/** @type {any} */
|
||||
const alias = require('esbuild-plugin-alias');
|
||||
const glob = require('glob');
|
||||
const { ensureDir } = require('./fs');
|
||||
|
||||
const REPO_ROOT = path.join(__dirname, '../');
|
||||
exports.REPO_ROOT = REPO_ROOT;
|
||||
export const REPO_ROOT = path.join(__dirname, '../');
|
||||
|
||||
/**
|
||||
* Launch the typescript compiler synchronously over a project.
|
||||
*
|
||||
* @param {string} _projectPath
|
||||
*/
|
||||
function tsc(_projectPath) {
|
||||
export function tsc(_projectPath: string) {
|
||||
const projectPath = path.join(REPO_ROOT, _projectPath);
|
||||
console.log(`Launching compiler at ${_projectPath}...`);
|
||||
const res = cp.spawnSync(
|
||||
|
|
@ -35,14 +29,11 @@ function tsc(_projectPath) {
|
|||
process.exit(res.status);
|
||||
}
|
||||
}
|
||||
exports.tsc = tsc;
|
||||
|
||||
/**
|
||||
* Launch prettier on a specific file.
|
||||
*
|
||||
* @param {string} _filePath
|
||||
*/
|
||||
function prettier(_filePath) {
|
||||
export function prettier(_filePath: string) {
|
||||
const filePath = path.join(REPO_ROOT, _filePath);
|
||||
cp.spawnSync(
|
||||
process.execPath,
|
||||
|
|
@ -52,16 +43,11 @@ function prettier(_filePath) {
|
|||
|
||||
console.log(`Ran prettier over ${_filePath}`);
|
||||
}
|
||||
exports.prettier = prettier;
|
||||
|
||||
/**
|
||||
* Transform an external .d.ts file to an internal .d.ts file
|
||||
*
|
||||
* @param {string} _source
|
||||
* @param {string} _destination
|
||||
* @param {string} namespace
|
||||
*/
|
||||
function dts(_source, _destination, namespace) {
|
||||
export function dts(_source: string, _destination: string, namespace: string) {
|
||||
const source = path.join(REPO_ROOT, _source);
|
||||
const destination = path.join(REPO_ROOT, _destination);
|
||||
|
||||
|
|
@ -100,12 +86,8 @@ function dts(_source, _destination, namespace) {
|
|||
|
||||
prettier(_destination);
|
||||
}
|
||||
exports.dts = dts;
|
||||
|
||||
/**
|
||||
* @param {import('esbuild').BuildOptions} options
|
||||
*/
|
||||
function build(options) {
|
||||
export function build(options: import('esbuild').BuildOptions) {
|
||||
esbuild.build(options).then((result) => {
|
||||
if (result.errors.length > 0) {
|
||||
console.error(result.errors);
|
||||
|
|
@ -115,16 +97,8 @@ function build(options) {
|
|||
}
|
||||
});
|
||||
}
|
||||
exports.build = build;
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* base: string;
|
||||
* entryPoints: string[];
|
||||
* external: string[];
|
||||
* }} options
|
||||
*/
|
||||
function buildESM(options) {
|
||||
export function buildESM(options: { base: string; entryPoints: string[]; external: string[] }) {
|
||||
build({
|
||||
entryPoints: options.entryPoints,
|
||||
bundle: true,
|
||||
|
|
@ -146,26 +120,23 @@ function buildESM(options) {
|
|||
]
|
||||
});
|
||||
}
|
||||
exports.buildESM = buildESM;
|
||||
|
||||
/**
|
||||
* @param {'dev'|'min'} type
|
||||
* @param {{
|
||||
* base: string;
|
||||
* entryPoint: string;
|
||||
* amdModuleId: string;
|
||||
* amdDependencies?: string[];
|
||||
* external?: string[];
|
||||
* }} options
|
||||
*/
|
||||
function buildOneAMD(type, options) {
|
||||
function buildOneAMD(
|
||||
type: 'dev' | 'min',
|
||||
options: {
|
||||
base: string;
|
||||
entryPoint: string;
|
||||
amdModuleId: string;
|
||||
amdDependencies?: string[];
|
||||
external?: string[];
|
||||
}
|
||||
) {
|
||||
if (!options.amdDependencies) {
|
||||
options.amdDependencies = [];
|
||||
}
|
||||
options.amdDependencies.unshift('require');
|
||||
|
||||
/** @type {import('esbuild').BuildOptions} */
|
||||
const opts = {
|
||||
const opts: esbuild.BuildOptions = {
|
||||
entryPoints: [options.entryPoint],
|
||||
bundle: true,
|
||||
target: 'esnext',
|
||||
|
|
@ -198,20 +169,16 @@ function buildOneAMD(type, options) {
|
|||
build(opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* base: string;
|
||||
* entryPoint: string;
|
||||
* amdModuleId: string;
|
||||
* amdDependencies?: string[];
|
||||
* external?: string[];
|
||||
* }} options
|
||||
*/
|
||||
function buildAMD(options) {
|
||||
export function buildAMD(options: {
|
||||
base: string;
|
||||
entryPoint: string;
|
||||
amdModuleId: string;
|
||||
amdDependencies?: string[];
|
||||
external?: string[];
|
||||
}) {
|
||||
buildOneAMD('dev', options);
|
||||
buildOneAMD('min', options);
|
||||
}
|
||||
exports.buildAMD = buildAMD;
|
||||
|
||||
function getGitVersion() {
|
||||
const git = path.join(REPO_ROOT, '.git');
|
||||
|
|
@ -263,7 +230,7 @@ function getGitVersion() {
|
|||
return refs[ref];
|
||||
}
|
||||
|
||||
const bundledFileHeader = (() => {
|
||||
export const bundledFileHeader = (() => {
|
||||
const sha1 = getGitVersion();
|
||||
const semver = require('../package.json').version;
|
||||
const headerVersion = semver + '(' + sha1 + ')';
|
||||
|
|
@ -280,16 +247,16 @@ const bundledFileHeader = (() => {
|
|||
|
||||
return BUNDLED_FILE_HEADER;
|
||||
})();
|
||||
exports.bundledFileHeader = bundledFileHeader;
|
||||
|
||||
/** @typedef {{ path:string; contents:Buffer;}} IFile */
|
||||
export interface IFile {
|
||||
path: string;
|
||||
contents: Buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} pattern
|
||||
* @param {{ base:string; ignore?:string[]; dot?:boolean; }} options
|
||||
* @returns {IFile[]}
|
||||
*/
|
||||
function readFiles(pattern, options) {
|
||||
export function readFiles(
|
||||
pattern: string,
|
||||
options: { base: string; ignore?: string[]; dot?: boolean }
|
||||
): IFile[] {
|
||||
let files = glob.sync(pattern, { cwd: REPO_ROOT, ignore: options.ignore, dot: options.dot });
|
||||
// remove dirs
|
||||
files = files.filter((file) => {
|
||||
|
|
@ -310,17 +277,11 @@ function readFiles(pattern, options) {
|
|||
};
|
||||
});
|
||||
}
|
||||
exports.readFiles = readFiles;
|
||||
|
||||
/**
|
||||
* @param {IFile[]} files
|
||||
* @param {string} dest
|
||||
*/
|
||||
function writeFiles(files, dest) {
|
||||
export function writeFiles(files: IFile[], dest: string) {
|
||||
for (const file of files) {
|
||||
const fullPath = path.join(REPO_ROOT, dest, file.path);
|
||||
ensureDir(path.dirname(fullPath));
|
||||
fs.writeFileSync(fullPath, file.contents);
|
||||
}
|
||||
}
|
||||
exports.writeFiles = writeFiles;
|
||||
|
|
@ -3,20 +3,15 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
//@ts-check
|
||||
import glob = require('glob');
|
||||
import path = require('path');
|
||||
import fs = require('fs');
|
||||
import cp = require('child_process');
|
||||
import CleanCSS from 'clean-css';
|
||||
import { REPO_ROOT, readFiles, writeFiles } from './utils';
|
||||
import { removeDir } from './fs';
|
||||
|
||||
/** @typedef {import('../build/utils').IFile} IFile */
|
||||
|
||||
const glob = require('glob');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const cp = require('child_process');
|
||||
const CleanCSS = require('clean-css');
|
||||
const { REPO_ROOT, readFiles, writeFiles } = require('./utils');
|
||||
const { removeDir } = require('./fs');
|
||||
|
||||
/** @type {string} */
|
||||
const MONACO_EDITOR_VERSION = (() => {
|
||||
const MONACO_EDITOR_VERSION: string = (() => {
|
||||
const output = cp.execSync(`npm show monaco-editor version`).toString();
|
||||
const version = output.split(/\r\n|\r|\n/g)[0];
|
||||
if (!/\d+\.\d+\.\d+/.test(version)) {
|
||||
|
|
@ -72,14 +67,12 @@ function checkSamples() {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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: string,
|
||||
contents: string,
|
||||
regex: RegExp,
|
||||
callback: (match: string, fileContents: Buffer) => string
|
||||
): string {
|
||||
return contents.replace(regex, function (_, m0) {
|
||||
const filePath = path.join(REPO_ROOT, 'website', path.dirname(dataPath), m0);
|
||||
return callback(m0, fs.readFileSync(filePath));
|
||||
|
|
@ -140,7 +133,7 @@ function generateWebsite() {
|
|||
contents,
|
||||
/<link data-inline="yes-please" href="([^"]+)".*/g,
|
||||
function (m0, fileContents) {
|
||||
const minifiedCSS = new CleanCSS().minify(fileContents.toString('utf8')).styles;
|
||||
const minifiedCSS = (new CleanCSS() as any).minify(fileContents.toString('utf8')).styles;
|
||||
return `<style>${minifiedCSS}</style>`;
|
||||
}
|
||||
);
|
||||
97
package-lock.json
generated
97
package-lock.json
generated
|
|
@ -4,12 +4,51 @@
|
|||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@cspotcode/source-map-consumer": {
|
||||
"version": "0.8.0",
|
||||
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz",
|
||||
"integrity": "sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==",
|
||||
"dev": true
|
||||
},
|
||||
"@cspotcode/source-map-support": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz",
|
||||
"integrity": "sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@cspotcode/source-map-consumer": "0.8.0"
|
||||
}
|
||||
},
|
||||
"@tootallnate/once": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz",
|
||||
"integrity": "sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==",
|
||||
"dev": true
|
||||
},
|
||||
"@tsconfig/node10": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.8.tgz",
|
||||
"integrity": "sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg==",
|
||||
"dev": true
|
||||
},
|
||||
"@tsconfig/node12": {
|
||||
"version": "1.0.9",
|
||||
"resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.9.tgz",
|
||||
"integrity": "sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw==",
|
||||
"dev": true
|
||||
},
|
||||
"@tsconfig/node14": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.1.tgz",
|
||||
"integrity": "sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg==",
|
||||
"dev": true
|
||||
},
|
||||
"@tsconfig/node16": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.2.tgz",
|
||||
"integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/minimatch": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz",
|
||||
|
|
@ -130,6 +169,12 @@
|
|||
"picomatch": "^2.0.4"
|
||||
}
|
||||
},
|
||||
"arg": {
|
||||
"version": "4.1.3",
|
||||
"resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz",
|
||||
"integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==",
|
||||
"dev": true
|
||||
},
|
||||
"argparse": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
|
||||
|
|
@ -340,6 +385,12 @@
|
|||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
|
||||
"dev": true
|
||||
},
|
||||
"create-require": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz",
|
||||
"integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==",
|
||||
"dev": true
|
||||
},
|
||||
"cross-spawn": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||
|
|
@ -1056,6 +1107,12 @@
|
|||
"integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==",
|
||||
"dev": true
|
||||
},
|
||||
"make-error": {
|
||||
"version": "1.3.6",
|
||||
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
|
||||
"integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==",
|
||||
"dev": true
|
||||
},
|
||||
"marked": {
|
||||
"version": "3.0.8",
|
||||
"resolved": "https://registry.npmjs.org/marked/-/marked-3.0.8.tgz",
|
||||
|
|
@ -1767,6 +1824,40 @@
|
|||
"punycode": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"ts-node": {
|
||||
"version": "10.4.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.4.0.tgz",
|
||||
"integrity": "sha512-g0FlPvvCXSIO1JDF6S232P5jPYqBkRL9qly81ZgAOSU7rwI0stphCgd2kLiCrU9DjQCrJMWEqcNSjQL02s6d8A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@cspotcode/source-map-support": "0.7.0",
|
||||
"@tsconfig/node10": "^1.0.7",
|
||||
"@tsconfig/node12": "^1.0.7",
|
||||
"@tsconfig/node14": "^1.0.0",
|
||||
"@tsconfig/node16": "^1.0.2",
|
||||
"acorn": "^8.4.1",
|
||||
"acorn-walk": "^8.1.1",
|
||||
"arg": "^4.1.0",
|
||||
"create-require": "^1.1.0",
|
||||
"diff": "^4.0.1",
|
||||
"make-error": "^1.1.1",
|
||||
"yn": "3.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"acorn-walk": {
|
||||
"version": "8.2.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz",
|
||||
"integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==",
|
||||
"dev": true
|
||||
},
|
||||
"diff": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz",
|
||||
"integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"type-check": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",
|
||||
|
|
@ -2049,6 +2140,12 @@
|
|||
"buffer-crc32": "~0.2.3"
|
||||
}
|
||||
},
|
||||
"yn": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz",
|
||||
"integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==",
|
||||
"dev": true
|
||||
},
|
||||
"yocto-queue": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
|
||||
|
|
|
|||
13
package.json
13
package.json
|
|
@ -7,16 +7,16 @@
|
|||
"author": "Microsoft Corporation",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build-website": "node ./build/website.js && npm run typedoc",
|
||||
"import-typescript": "node ./build/importTypescript.js",
|
||||
"build-website": "ts-node ./build/website && npm run typedoc",
|
||||
"import-typescript": "ts-node ./build/importTypescript",
|
||||
"playwright-install": "node ./node_modules/playwright/install.js",
|
||||
"playwright-install-deps": "playwright install-deps",
|
||||
"postinstall": "node ./build/postinstall.js",
|
||||
"postinstall": "ts-node ./build/postinstall",
|
||||
"prettier-check": "prettier --check .",
|
||||
"prettier": "prettier --write .",
|
||||
"pretty-quick": "pretty-quick --staged",
|
||||
"release": "node ./build/build.js && node ./build/release.js",
|
||||
"simpleserver": "node ./build/simpleserver",
|
||||
"release": "ts-node ./build/build && ts-node ./build/release",
|
||||
"simpleserver": "ts-node ./build/simpleserver",
|
||||
"smoketest-debug": "node ./test/smoke/runner.js --debug-tests",
|
||||
"smoketest": "node ./test/smoke/runner.js",
|
||||
"test": "mocha test/unit/all.js",
|
||||
|
|
@ -55,6 +55,7 @@
|
|||
"vscode-languageserver-textdocument": "^1.0.2",
|
||||
"vscode-languageserver-types": "3.16.0",
|
||||
"vscode-uri": "3.0.2",
|
||||
"yaserver": "^0.4.0"
|
||||
"yaserver": "^0.4.0",
|
||||
"ts-node": "^10.4.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue