Convert build scripts to JavaScript.

hediet/typify-build
Henning Dieterichs 3 years ago
parent 84665761ff
commit 4bf3b49c41
No known key found for this signature in database
GPG Key ID: 771381EFFDB9EC06

@ -3,11 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
//@ts-check import glob from 'glob';
import { tsc, dts, buildESM, buildAMD } from './utils';
const glob = require('glob'); import { copyFile, removeDir } from './fs';
const { tsc, dts, buildESM, buildAMD } = require('../build/utils');
const { copyFile, removeDir } = require('../build/fs');
removeDir(`out`); removeDir(`out`);

@ -3,18 +3,14 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * 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';
const fs = require('fs');
const path = require('path');
const REPO_ROOT = path.join(__dirname, '../'); const REPO_ROOT = path.join(__dirname, '../');
const existingDirCache = new Set(); const existingDirCache = new Set();
/**
* @param {string} dirname export function ensureDir(dirname: string) {
*/
function ensureDir(dirname) {
/** @type {string[]} */ /** @type {string[]} */
const dirs = []; const dirs = [];
@ -32,15 +28,11 @@ function ensureDir(dirname) {
} }
}); });
} }
exports.ensureDir = ensureDir;
/** /**
* Copy a file. * 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 source = path.join(REPO_ROOT, _source);
const destination = path.join(REPO_ROOT, _destination); const destination = path.join(REPO_ROOT, _destination);
@ -49,15 +41,11 @@ function copyFile(_source, _destination) {
console.log(`Copied ${_source} to ${_destination}`); console.log(`Copied ${_source} to ${_destination}`);
} }
exports.copyFile = copyFile;
/** /**
* Remove a directory and all its contents. * 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') { if (typeof keep === 'undefined') {
keep = () => false; keep = () => false;
} }
@ -95,4 +83,3 @@ function removeDir(_dirPath, keep) {
return keepsFiles; return keepsFiles;
} }
} }
exports.removeDir = removeDir;

@ -3,12 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
//@ts-check import path = require('path');
import fs = require('fs');
const path = require('path'); import child_process = require('child_process');
const fs = require('fs'); import { REPO_ROOT } from './utils';
const child_process = require('child_process');
const { REPO_ROOT } = require('./utils');
const generatedNote = `// const generatedNote = `//
// **NOTE**: Do not edit directly! This file is generated using \`npm run import-typescript\` // **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. * 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');
const glob = require('glob'); import fs = require('fs');
const path = require('path'); import cp = require('child_process');
const fs = require('fs');
const cp = require('child_process');
const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm'; const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
const { REPO_ROOT } = require('../utils'); import { REPO_ROOT } from '../utils';
const files = glob.sync('**/package.json', { const files = glob.sync('**/package.json', {
cwd: REPO_ROOT, cwd: REPO_ROOT,
@ -29,18 +27,16 @@ for (const file of files) {
} }
function npmInstall(location) { function npmInstall(location) {
/** @type {'inherit'} */
const stdio = 'inherit'; const stdio = 'inherit';
const opts = {
env: process.env,
cwd: location,
stdio
};
const args = ['install']; const args = ['install'];
console.log(`Installing dependencies in ${location}...`); console.log(`Installing dependencies in ${location}...`);
console.log(`$ npm ${args.join(' ')}`); 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) { if (result.error || result.status !== 0) {
process.exit(1); process.exit(1);

@ -3,12 +3,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
//@ts-check import glob from 'glob';
import path from 'path';
const glob = require('glob'); import fs from 'fs';
const path = require('path'); import { REPO_ROOT } from '../utils';
const fs = require('fs');
const { REPO_ROOT } = require('../utils');
const files = glob.sync('**/package-lock.json', { const files = glob.sync('**/package-lock.json', {
cwd: REPO_ROOT, cwd: REPO_ROOT,

@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
const cp = require('child_process'); import cp = require('child_process');
const path = require('path'); import path = require('path');
function huskyInstall() { function huskyInstall() {
console.log(`Installing husky hooks...`); console.log(`Installing husky hooks...`);

@ -3,16 +3,12 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
//@ts-check import path = require('path');
import fs = require('fs');
/** @typedef {import('../build/utils').IFile} IFile */ import { REPO_ROOT, readFiles, writeFiles, IFile } from '../build/utils';
import { removeDir } from '../build/fs';
const path = require('path'); import ts = require('typescript');
const fs = require('fs'); import { generateMetadata } from './releaseMetadata';
const { REPO_ROOT, readFiles, writeFiles } = require('../build/utils');
const { removeDir } = require('../build/fs');
const ts = require('typescript');
const { generateMetadata } = require('./releaseMetadata');
removeDir(`release`); removeDir(`release`);
@ -89,11 +85,8 @@ function AMD_releaseOne(type) {
* - rename the AMD module 'vs/editor/editor.main' to 'vs/editor/edcore.main' * - rename the AMD module 'vs/editor/editor.main' to 'vs/editor/edcore.main'
* - append monaco.contribution modules from plugins * - append monaco.contribution modules from plugins
* - append new AMD module 'vs/editor/editor.main' that stiches things together * - 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) { for (const file of files) {
if (!/editor\.main\.js$/.test(file.path)) { if (!/editor\.main\.js$/.test(file.path)) {
continue; continue;
@ -223,9 +216,8 @@ function ESM_releasePlugins() {
/** /**
* Adds `.js` to all import statements. * Adds `.js` to all import statements.
* @param {IFile[]} files
*/ */
function ESM_addImportSuffix(files) { function ESM_addImportSuffix(files: IFile[]) {
for (const file of files) { for (const file of files) {
if (!/\.js$/.test(file.path)) { if (!/\.js$/.test(file.path)) {
continue; continue;
@ -254,9 +246,8 @@ function ESM_addImportSuffix(files) {
/** /**
* - Rename esm/vs/editor/editor.main.js to esm/vs/editor/edcore.main.js * - 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 * - 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) { for (const file of files) {
if (!/editor\.main\.js$/.test(file.path)) { if (!/editor\.main\.js$/.test(file.path)) {
continue; continue;
@ -340,10 +331,8 @@ function releaseDTS() {
/** /**
* Transforms a .d.ts which uses internal modules (namespaces) to one which is usable with external modules * 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. * 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 lines = contents.split(/\r\n|\r|\n/);
let killNextCloseCurlyBrace = false; let killNextCloseCurlyBrace = false;
for (let i = 0; i < lines.length; i++) { for (let i = 0; i < lines.length; i++) {
@ -387,10 +376,8 @@ function toExternalDTS(contents) {
/** /**
* Normalize line endings and ensure consistent 4 spaces indentation * Normalize line endings and ensure consistent 4 spaces indentation
* @param {string} contents
* @returns {string}
*/ */
function cleanFile(contents) { function cleanFile(contents: string): string {
return contents return contents
.split(/\r\n|\r|\n/) .split(/\r\n|\r|\n/)
.map(function (line) { .map(function (line) {

@ -3,13 +3,11 @@
* Licensed under the MIT License. See LICENSE in the project root for license information. * Licensed under the MIT License. See LICENSE in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
//@ts-check import glob = require('glob');
import path = require('path');
const glob = require('glob'); import fs = require('fs');
const path = require('path'); import { REPO_ROOT } from './utils';
const fs = require('fs'); import { ensureDir } from './fs';
const { REPO_ROOT } = require('./utils');
const { ensureDir } = require('./fs');
const customFeatureLabels = { const customFeatureLabels = {
'vs/editor/browser/controller/coreCommands': 'coreCommands', 'vs/editor/browser/controller/coreCommands': 'coreCommands',
@ -25,10 +23,7 @@ const customFeatureLabels = {
'vs/editor/standalone/browser/quickAccess/standaloneHelpQuickAccess': 'quickHelp' 'vs/editor/standalone/browser/quickAccess/standaloneHelpQuickAccess': 'quickHelp'
}; };
/** function getBasicLanguages(): Promise<{ label: string; entry: string }[]> {
* @returns { Promise<{ label: string; entry: string; }[]> }
*/
function getBasicLanguages() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
glob( glob(
'./release/esm/vs/basic-languages/*/*.contribution.js', './release/esm/vs/basic-languages/*/*.contribution.js',
@ -54,10 +49,7 @@ function getBasicLanguages() {
}); });
} }
/** function readAdvancedLanguages(): Promise<string[]> {
* @returns { Promise<string[]> }
*/
function readAdvancedLanguages() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
glob( glob(
'./release/esm/vs/language/*/monaco.contribution.js', './release/esm/vs/language/*/monaco.contribution.js',
@ -78,10 +70,9 @@ function readAdvancedLanguages() {
}); });
} }
/** function getAdvancedLanguages(): Promise<
* @returns { Promise<{ label: string; entry: string; worker: { id: string; entry: string; }; }[]> } { label: string; entry: string; worker: { id: string; entry: string } }[]
*/ > {
function getAdvancedLanguages() {
return readAdvancedLanguages().then((languages) => { return readAdvancedLanguages().then((languages) => {
let result = []; let result = [];
for (const lang of languages) { for (const lang of languages) {
@ -112,11 +103,11 @@ function getAdvancedLanguages() {
} }
} }
function generateMetadata() { export function generateMetadata() {
return Promise.all([getBasicLanguages(), getAdvancedLanguages()]).then( return Promise.all([getBasicLanguages(), getAdvancedLanguages()]).then(
([basicLanguages, advancedLanguages]) => { ([basicLanguages, advancedLanguages]) => {
basicLanguages.sort(strcmp); basicLanguages.sort((a, b) => strcmp(a.entry, b.entry));
advancedLanguages.sort(strcmp); advancedLanguages.sort((a, b) => strcmp(a.entry, b.entry));
let i = 0, let i = 0,
len = basicLanguages.length; len = basicLanguages.length;
@ -197,13 +188,8 @@ exports.languages = ${JSON.stringify(languages, null, ' ')};
} }
); );
} }
exports.generateMetadata = generateMetadata;
/** function strcmp(a: string, b: string) {
* @tyoe {string} a
* @tyoe {string} b
*/
function strcmp(a, b) {
if (a < b) { if (a < b) {
return -1; return -1;
} }
@ -213,10 +199,7 @@ function strcmp(a, b) {
return 0; return 0;
} }
/** function getFeatures(): { label: string; entry: string | string[] }[] {
* @returns {{label:string;entry:string|string[];}[]}
*/
function getFeatures() {
const skipImports = [ const skipImports = [
'vs/editor/browser/widget/codeEditorWidget', 'vs/editor/browser/widget/codeEditorWidget',
'vs/editor/browser/widget/diffEditorWidget', 'vs/editor/browser/widget/diffEditorWidget',
@ -228,8 +211,7 @@ function getFeatures() {
'vs/editor/contrib/gotoSymbol/documentSymbols' 'vs/editor/contrib/gotoSymbol/documentSymbols'
]; ];
/** @type {string[]} */ let features: string[] = [];
let features = [];
const files = 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/edcore.main.js')).toString() +
fs.readFileSync(path.join(REPO_ROOT, 'release/esm/vs/editor/editor.all.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: { label: string; entry: any }[] = features.map((feature) => {
let result = features.map((feature) => {
/** @type {string} */ let label; /** @type {string} */ let label;
if (customFeatureLabels[feature]) { if (customFeatureLabels[feature]) {
label = customFeatureLabels[feature]; label = customFeatureLabels[feature];

@ -3,14 +3,12 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
//@ts-check import fs = require('fs');
import path = require('path');
const fs = require('fs'); import http = require('http');
const path = require('path'); import yaserver = require('yaserver');
const http = require('http'); import { REPO_ROOT } from './utils';
const yaserver = require('yaserver'); import { ensureDir } from './fs';
const { REPO_ROOT } = require('./utils');
const { ensureDir } = require('./fs');
const WEBSITE_GENERATED_PATH = path.join(REPO_ROOT, 'website/playground/new-samples'); const WEBSITE_GENERATED_PATH = path.join(REPO_ROOT, 'website/playground/new-samples');
@ -157,11 +155,7 @@ function generateTestSamplesTask() {
); );
} }
/** function createSimpleServer(rootDir: string, port: number) {
* @param {string} rootDir
* @param {number} port
*/
function createSimpleServer(rootDir, port) {
yaserver yaserver
.createServer({ .createServer({
rootDir: rootDir rootDir: rootDir

@ -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. * 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'); export const REPO_ROOT = path.join(__dirname, '../');
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;
/** /**
* Launch the typescript compiler synchronously over a project. * 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); const projectPath = path.join(REPO_ROOT, _projectPath);
console.log(`Launching compiler at ${_projectPath}...`); console.log(`Launching compiler at ${_projectPath}...`);
const res = cp.spawnSync( const res = cp.spawnSync(
@ -35,14 +29,11 @@ function tsc(_projectPath) {
process.exit(res.status); process.exit(res.status);
} }
} }
exports.tsc = tsc;
/** /**
* Launch prettier on a specific file. * Launch prettier on a specific file.
*
* @param {string} _filePath
*/ */
function prettier(_filePath) { export function prettier(_filePath: string) {
const filePath = path.join(REPO_ROOT, _filePath); const filePath = path.join(REPO_ROOT, _filePath);
cp.spawnSync( cp.spawnSync(
process.execPath, process.execPath,
@ -52,16 +43,11 @@ function prettier(_filePath) {
console.log(`Ran prettier over ${_filePath}`); console.log(`Ran prettier over ${_filePath}`);
} }
exports.prettier = prettier;
/** /**
* Transform an external .d.ts file to an internal .d.ts file * 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 source = path.join(REPO_ROOT, _source);
const destination = path.join(REPO_ROOT, _destination); const destination = path.join(REPO_ROOT, _destination);
@ -100,12 +86,8 @@ function dts(_source, _destination, namespace) {
prettier(_destination); prettier(_destination);
} }
exports.dts = dts;
/** export function build(options: import('esbuild').BuildOptions) {
* @param {import('esbuild').BuildOptions} options
*/
function build(options) {
esbuild.build(options).then((result) => { esbuild.build(options).then((result) => {
if (result.errors.length > 0) { if (result.errors.length > 0) {
console.error(result.errors); console.error(result.errors);
@ -115,16 +97,8 @@ function build(options) {
} }
}); });
} }
exports.build = build;
/** export function buildESM(options: { base: string; entryPoints: string[]; external: string[] }) {
* @param {{
* base: string;
* entryPoints: string[];
* external: string[];
* }} options
*/
function buildESM(options) {
build({ build({
entryPoints: options.entryPoints, entryPoints: options.entryPoints,
bundle: true, bundle: true,
@ -146,26 +120,23 @@ function buildESM(options) {
] ]
}); });
} }
exports.buildESM = buildESM;
/** function buildOneAMD(
* @param {'dev'|'min'} type type: 'dev' | 'min',
* @param {{ options: {
* base: string; base: string;
* entryPoint: string; entryPoint: string;
* amdModuleId: string; amdModuleId: string;
* amdDependencies?: string[]; amdDependencies?: string[];
* external?: string[]; external?: string[];
* }} options }
*/ ) {
function buildOneAMD(type, options) {
if (!options.amdDependencies) { if (!options.amdDependencies) {
options.amdDependencies = []; options.amdDependencies = [];
} }
options.amdDependencies.unshift('require'); options.amdDependencies.unshift('require');
/** @type {import('esbuild').BuildOptions} */ const opts: esbuild.BuildOptions = {
const opts = {
entryPoints: [options.entryPoint], entryPoints: [options.entryPoint],
bundle: true, bundle: true,
target: 'esnext', target: 'esnext',
@ -198,20 +169,16 @@ function buildOneAMD(type, options) {
build(opts); build(opts);
} }
/** export function buildAMD(options: {
* @param {{ base: string;
* base: string; entryPoint: string;
* entryPoint: string; amdModuleId: string;
* amdModuleId: string; amdDependencies?: string[];
* amdDependencies?: string[]; external?: string[];
* external?: string[]; }) {
* }} options
*/
function buildAMD(options) {
buildOneAMD('dev', options); buildOneAMD('dev', options);
buildOneAMD('min', options); buildOneAMD('min', options);
} }
exports.buildAMD = buildAMD;
function getGitVersion() { function getGitVersion() {
const git = path.join(REPO_ROOT, '.git'); const git = path.join(REPO_ROOT, '.git');
@ -263,7 +230,7 @@ function getGitVersion() {
return refs[ref]; return refs[ref];
} }
const bundledFileHeader = (() => { export const bundledFileHeader = (() => {
const sha1 = getGitVersion(); const sha1 = getGitVersion();
const semver = require('../package.json').version; const semver = require('../package.json').version;
const headerVersion = semver + '(' + sha1 + ')'; const headerVersion = semver + '(' + sha1 + ')';
@ -280,16 +247,16 @@ const bundledFileHeader = (() => {
return BUNDLED_FILE_HEADER; return BUNDLED_FILE_HEADER;
})(); })();
exports.bundledFileHeader = bundledFileHeader;
/** @typedef {{ path:string; contents:Buffer;}} IFile */ export interface IFile {
path: string;
contents: Buffer;
}
/** export function readFiles(
* @param {string} pattern pattern: string,
* @param {{ base:string; ignore?:string[]; dot?:boolean; }} options options: { base: string; ignore?: string[]; dot?: boolean }
* @returns {IFile[]} ): IFile[] {
*/
function readFiles(pattern, options) {
let files = glob.sync(pattern, { cwd: REPO_ROOT, ignore: options.ignore, dot: options.dot }); let files = glob.sync(pattern, { cwd: REPO_ROOT, ignore: options.ignore, dot: options.dot });
// remove dirs // remove dirs
files = files.filter((file) => { files = files.filter((file) => {
@ -310,17 +277,11 @@ function readFiles(pattern, options) {
}; };
}); });
} }
exports.readFiles = readFiles;
/** export function writeFiles(files: IFile[], dest: string) {
* @param {IFile[]} files
* @param {string} dest
*/
function writeFiles(files, dest) {
for (const file of files) { for (const file of files) {
const fullPath = path.join(REPO_ROOT, dest, file.path); const fullPath = path.join(REPO_ROOT, dest, file.path);
ensureDir(path.dirname(fullPath)); ensureDir(path.dirname(fullPath));
fs.writeFileSync(fullPath, file.contents); 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. * 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');
/** @typedef {import('../build/utils').IFile} IFile */ import fs = require('fs');
import cp = require('child_process');
const glob = require('glob'); import CleanCSS from 'clean-css';
const path = require('path'); import { REPO_ROOT, readFiles, writeFiles } from './utils';
const fs = require('fs'); import { removeDir } from './fs';
const cp = require('child_process');
const CleanCSS = require('clean-css'); const MONACO_EDITOR_VERSION: string = (() => {
const { REPO_ROOT, readFiles, writeFiles } = require('./utils');
const { removeDir } = require('./fs');
/** @type {string} */
const MONACO_EDITOR_VERSION = (() => {
const output = cp.execSync(`npm show monaco-editor version`).toString(); const output = cp.execSync(`npm show monaco-editor version`).toString();
const version = output.split(/\r\n|\r|\n/g)[0]; const version = output.split(/\r\n|\r|\n/g)[0];
if (!/\d+\.\d+\.\d+/.test(version)) { if (!/\d+\.\d+\.\d+/.test(version)) {
@ -72,14 +67,12 @@ function checkSamples() {
} }
} }
/** function replaceWithRelativeResource(
* @param {string} dataPath dataPath: string,
* @param {string} contents contents: string,
* @param {RegExp} regex regex: RegExp,
* @param {(match:string, fileContents:Buffer)=>string} callback callback: (match: string, fileContents: Buffer) => string
* @returns {string} ): string {
*/
function replaceWithRelativeResource(dataPath, contents, regex, callback) {
return contents.replace(regex, function (_, m0) { return contents.replace(regex, function (_, m0) {
const filePath = path.join(REPO_ROOT, 'website', path.dirname(dataPath), m0); const filePath = path.join(REPO_ROOT, 'website', path.dirname(dataPath), m0);
return callback(m0, fs.readFileSync(filePath)); return callback(m0, fs.readFileSync(filePath));
@ -140,7 +133,7 @@ function generateWebsite() {
contents, contents,
/<link data-inline="yes-please" href="([^"]+)".*/g, /<link data-inline="yes-please" href="([^"]+)".*/g,
function (m0, fileContents) { 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>`; return `<style>${minifiedCSS}</style>`;
} }
); );

97
package-lock.json generated

@ -4,12 +4,51 @@
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "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": { "@tootallnate/once": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz",
"integrity": "sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==", "integrity": "sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==",
"dev": true "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": { "@types/minimatch": {
"version": "3.0.5", "version": "3.0.5",
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz",
@ -130,6 +169,12 @@
"picomatch": "^2.0.4" "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": { "argparse": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
@ -340,6 +385,12 @@
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true "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": { "cross-spawn": {
"version": "7.0.3", "version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
@ -1056,6 +1107,12 @@
"integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==",
"dev": true "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": { "marked": {
"version": "3.0.8", "version": "3.0.8",
"resolved": "https://registry.npmjs.org/marked/-/marked-3.0.8.tgz", "resolved": "https://registry.npmjs.org/marked/-/marked-3.0.8.tgz",
@ -1767,6 +1824,40 @@
"punycode": "^2.1.1" "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": { "type-check": {
"version": "0.3.2", "version": "0.3.2",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",
@ -2049,6 +2140,12 @@
"buffer-crc32": "~0.2.3" "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": { "yocto-queue": {
"version": "0.1.0", "version": "0.1.0",
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",

@ -7,16 +7,16 @@
"author": "Microsoft Corporation", "author": "Microsoft Corporation",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"build-website": "node ./build/website.js && npm run typedoc", "build-website": "ts-node ./build/website && npm run typedoc",
"import-typescript": "node ./build/importTypescript.js", "import-typescript": "ts-node ./build/importTypescript",
"playwright-install": "node ./node_modules/playwright/install.js", "playwright-install": "node ./node_modules/playwright/install.js",
"playwright-install-deps": "playwright install-deps", "playwright-install-deps": "playwright install-deps",
"postinstall": "node ./build/postinstall.js", "postinstall": "ts-node ./build/postinstall",
"prettier-check": "prettier --check .", "prettier-check": "prettier --check .",
"prettier": "prettier --write .", "prettier": "prettier --write .",
"pretty-quick": "pretty-quick --staged", "pretty-quick": "pretty-quick --staged",
"release": "node ./build/build.js && node ./build/release.js", "release": "ts-node ./build/build && ts-node ./build/release",
"simpleserver": "node ./build/simpleserver", "simpleserver": "ts-node ./build/simpleserver",
"smoketest-debug": "node ./test/smoke/runner.js --debug-tests", "smoketest-debug": "node ./test/smoke/runner.js --debug-tests",
"smoketest": "node ./test/smoke/runner.js", "smoketest": "node ./test/smoke/runner.js",
"test": "mocha test/unit/all.js", "test": "mocha test/unit/all.js",
@ -55,6 +55,7 @@
"vscode-languageserver-textdocument": "^1.0.2", "vscode-languageserver-textdocument": "^1.0.2",
"vscode-languageserver-types": "3.16.0", "vscode-languageserver-types": "3.16.0",
"vscode-uri": "3.0.2", "vscode-uri": "3.0.2",
"yaserver": "^0.4.0" "yaserver": "^0.4.0",
"ts-node": "^10.4.0"
} }
} }

Loading…
Cancel
Save