[MIRROR] Fix a number of build issues (#3716)

* Fix a number of build issues

* Update babel.config.js

* Update package.json

* Update package.json

* Update dreamseeker.js

* Update package.json

* Update webpack.config.js

* Update yarn.lock

* a

* a

Co-authored-by: Aleksej Komarov <stylemistake@gmail.com>
Co-authored-by: Gandalf <jzo123@hotmail.com>
This commit is contained in:
SkyratBot
2021-02-28 16:28:03 +01:00
committed by GitHub
parent 4bad355c11
commit 5ea469fcf0
17 changed files with 4135 additions and 1626 deletions

7
.vscode/tasks.json vendored
View File

@@ -7,8 +7,14 @@
"windows": {
"command": ".\\tools\\build\\build.bat"
},
"options": {
"env": {
"DM_EXE": "${config:dreammaker.byondPath}"
}
},
"problemMatcher": [
"$dreammaker",
"$tsc",
"$eslint-stylish"
],
"group": {
@@ -33,6 +39,7 @@
"command": ".\\tgui\\bin\\tgui.bat"
},
"problemMatcher": [
"$tsc",
"$eslint-stylish"
],
"group": "build",

View File

@@ -48,6 +48,10 @@
))
window.send_asset(get_asset_datum(/datum/asset/simple/namespaced/fontawesome))
window.send_asset(get_asset_datum(/datum/asset/spritesheet/chat))
// Preload assets for /datum/tgui_window
var/datum/asset/asset_tgui = get_asset_datum(/datum/asset/simple/tgui)
asset_tgui.send(src.client)
// Other setup
request_telemetry()
addtimer(CALLBACK(src, .proc/on_initialize_timed_out), 5 SECONDS)

View File

@@ -8,7 +8,10 @@ const createBabelConfig = options => {
const { mode, presets = [], plugins = [] } = options;
return {
presets: [
['@babel/preset-env', {
[require.resolve('@babel/preset-typescript'), {
allowDeclareFields: true,
}],
[require.resolve('@babel/preset-env'), {
modules: 'commonjs',
useBuiltIns: 'entry',
corejs: '3.8',
@@ -19,16 +22,19 @@ const createBabelConfig = options => {
...presets,
],
plugins: [
'@babel/plugin-transform-jscript',
'babel-plugin-inferno',
'babel-plugin-transform-remove-console',
'common/string.babel-plugin.cjs',
[require.resolve('@babel/plugin-proposal-class-properties'), {
loose: true,
}],
require.resolve('@babel/plugin-transform-jscript'),
require.resolve('babel-plugin-inferno'),
require.resolve('babel-plugin-transform-remove-console'),
require.resolve('common/string.babel-plugin.cjs'),
...plugins,
],
};
};
module.exports = (api) => {
module.exports = api => {
api.cache(true);
const mode = process.env.NODE_ENV;
return createBabelConfig({ mode });

View File

@@ -6,27 +6,37 @@
"packages/*"
],
"dependencies": {
"@babel/core": "^7.12.13",
"@babel/eslint-parser": "^7.12.13",
"@babel/core": "^7.13.8",
"@babel/eslint-parser": "^7.13.8",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/plugin-transform-jscript": "^7.12.13",
"@babel/preset-env": "^7.12.13",
"@babel/preset-env": "^7.13.8",
"@babel/preset-typescript": "^7.13.0",
"@types/jest": "^26.0.20",
"@types/jsdom": "^16.2.6",
"@types/node": "^14.14.31",
"@typescript-eslint/parser": "^4.15.2",
"babel-jest": "^26.6.3",
"babel-loader": "^8.2.2",
"babel-plugin-inferno": "^6.1.1",
"babel-plugin-transform-remove-console": "^6.9.4",
"common": "workspace:*",
"css-loader": "^5.0.2",
"cssnano": "^4.1.10",
"eslint": "^7.19.0",
"css-loader": "^5.1.0",
"eslint": "^7.20.0",
"eslint-plugin-react": "^7.22.0",
"file-loader": "^6.2.0",
"inferno": "^7.4.7",
"mini-css-extract-plugin": "^1.3.6",
"sass": "^1.32.6",
"inferno": "^7.4.8",
"jest": "^26.6.3",
"jest-circus": "^26.6.3",
"jsdom": "^16.4.0",
"mini-css-extract-plugin": "^1.3.9",
"sass": "^1.32.8",
"sass-loader": "^11.0.1",
"style-loader": "^2.0.0",
"terser-webpack-plugin": "^5.1.1",
"typescript": "^4.1.5",
"url-loader": "^4.1.1",
"webpack": "^5.21.2",
"webpack": "^5.24.2",
"webpack-bundle-analyzer": "^4.4.0",
"webpack-cli": "^4.5.0"
}

View File

@@ -52,7 +52,7 @@ DreamSeeker.getInstancesByPids = async pids => {
}
if (pidsToResolve.length > 0) {
try {
const command = 'netstat -ano | findstr LISTENING';
const command = 'netstat -ano | findstr TCP | findstr 0.0.0.0:0';
const { stdout } = await promisify(exec)(command, {
// Max buffer of 1MB (default is 200KB)
maxBuffer: 1024 * 1024,

View File

@@ -8,7 +8,6 @@ import { createLogger } from 'common/logging.js';
import fs from 'fs';
import os from 'os';
import { basename } from 'path';
import { promisify } from 'util';
import { resolveGlob, resolvePath } from './util.js';
import { regQuery } from './winreg.js';
import { DreamSeeker } from './dreamseeker.js';
@@ -93,15 +92,21 @@ export const reloadByondCache = async bundleDir => {
for (let cacheDir of cacheDirs) {
// Clear garbage
const garbage = await resolveGlob(cacheDir, './*.+(bundle|chunk|hot-update).*');
for (let file of garbage) {
await promisify(fs.unlink)(file);
try {
for (let file of garbage) {
fs.unlink(file);
}
// Copy assets
for (let asset of assets) {
const destination = resolvePath(cacheDir, basename(asset));
fs.copyFile(asset, destination);
}
logger.log(`copied ${assets.length} files to '${cacheDir}'`);
}
// Copy assets
for (let asset of assets) {
const destination = resolvePath(cacheDir, basename(asset));
await promisify(fs.copyFile)(asset, destination);
catch (err) {
logger.error(`failed copying to '${cacheDir}'`);
logger.error(err);
}
logger.log(`copied ${assets.length} files to '${cacheDir}'`);
}
// Notify dreamseeker
const dss = await dssPromise;

View File

@@ -5,9 +5,9 @@
"dependencies": {
"common": "workspace:*",
"dompurify": "^2.2.6",
"inferno": "^7.4.7",
"inferno-vnode-flags": "^7.4.7",
"marked": "^2.0.0",
"inferno": "^7.4.8",
"inferno-vnode-flags": "^7.4.8",
"marked": "^2.0.1",
"tgui-dev-server": "workspace:*",
"tgui-polyfill": "workspace:*"
}

View File

@@ -49,16 +49,16 @@ module.exports = (env = {}, argv) => {
chunkLoadTimeout: 15000,
},
resolve: {
extensions: ['.js', '.jsx'],
extensions: ['.tsx', '.ts', '.jsx', '.js'],
alias: {},
},
module: {
rules: [
{
test: /\.m?jsx?$/,
test: /\.(js|jsx|cjs|mjs|ts|tsx)$/,
use: [
{
loader: 'babel-loader',
loader: require.resolve('babel-loader'),
options: createBabelConfig({ mode }),
},
],
@@ -73,20 +73,20 @@ module.exports = (env = {}, argv) => {
},
},
{
loader: 'css-loader',
loader: require.resolve('css-loader'),
options: {
esModule: false,
},
},
{
loader: 'sass-loader',
loader: require.resolve('sass-loader'),
},
],
},
{
test: /\.(png|jpg|svg)$/,
use: [
'url-loader',
require.resolve('url-loader'),
],
},
],
@@ -105,6 +105,9 @@ module.exports = (env = {}, argv) => {
cache: {
type: 'filesystem',
cacheLocation: path.resolve(__dirname, `.yarn/webpack/${mode}`),
buildDependencies: {
config: [__filename],
},
},
stats: createStats(true),
plugins: [

File diff suppressed because it is too large Load Diff

View File

@@ -81,4 +81,4 @@ exec 4>&1
PATH="$(readlink -f "$NodeDir"):$PATH" # Set PATH so that recursive calls find it
exitstatus=$({ { set +e; "$NodeExe" "$@" 2>&1 3>&-; printf %s $? >&3; } 4>&- | tee -a "$Log" 1>&4; } 3>&1)
exec 4>&-
exit "$exitstatus"
exit "$exitstatus"

View File

@@ -4,6 +4,20 @@ if %errorlevel% == 0 (
echo | set /p printed_str="Using system-wide Node "
call node.exe --version
call node.exe %*
) else (
call powershell.exe -NoLogo -ExecutionPolicy Bypass -File "%~dp0\node_.ps1" %*
exit /b %errorlevel%
)
call powershell -NoLogo -ExecutionPolicy Bypass -File "%~dp0\node_.ps1" Download-Node
for /f "tokens=* USEBACKQ" %%s in (`
call powershell -NoLogo -ExecutionPolicy Bypass -File "%~dp0\node_.ps1" Get-Path
`) do (
set "PATH=%%s;%PATH%"
)
where node.exe >nul 2>nul
if %errorlevel% == 0 (
echo | set /p printed_str="Using vendored Node "
call node.exe --version
call node.exe %*
exit /b %errorlevel%
)
echo "build.bat: Failed to bootstrap Node!"
exit /b 1

View File

@@ -1,23 +1,9 @@
## bootstrap/node_.ps1
##
## Node bootstrapping script for Windows.
##
## Automatically downloads a Node version to a cache directory and invokes it.
##
## The underscore in the name is so that typing `bootstrap/node` into
## PowerShell finds the `.bat` file first, which ensures this script executes
## regardless of ExecutionPolicy.
## Downloads a Node version to a cache directory and invokes it.
#Requires -Version 4.0
$Host.ui.RawUI.WindowTitle = "starting :: node $Args"
$ErrorActionPreference = "Stop"
## This forces UTF-8 encoding across all powershell built-ins
$OutputEncoding = [System.Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$PSDefaultParameterValues['*:Encoding'] = 'utf8'
function ExtractVersion {
function Extract-Variable {
param([string] $Path, [string] $Key)
foreach ($Line in Get-Content $Path) {
if ($Line.StartsWith("export $Key=")) {
@@ -27,31 +13,46 @@ function ExtractVersion {
throw "Couldn't find value for $Key in $Path"
}
function Download-Node {
if (Test-Path $NodeTarget -PathType Leaf) {
return
}
Write-Output "Downloading Node v$NodeVersion"
New-Item $NodeTargetDir -ItemType Directory -ErrorAction silentlyContinue | Out-Null
$WebClient = New-Object Net.WebClient
$WebClient.DownloadFile($NodeSource, $NodeTarget)
}
## Convenience variables
$BaseDir = Split-Path $script:MyInvocation.MyCommand.Path
$Cache = "$BaseDir/.cache"
$Cache = "$BaseDir\.cache"
if ($Env:TG_BOOTSTRAP_CACHE) {
$Cache = $Env:TG_BOOTSTRAP_CACHE
}
$NodeVersion = ExtractVersion -Path "$BaseDir/../../dependencies.sh" -Key "NODE_VERSION_PRECISE"
$NodeDir = "$Cache/node-v$NodeVersion"
$NodeExe = "$NodeDir/node.exe"
$NodeVersion = Extract-Variable -Path "$BaseDir\..\..\dependencies.sh" -Key "NODE_VERSION_PRECISE"
$NodeSource = "https://nodejs.org/download/release/v$NodeVersion/win-x86/node.exe"
$NodeTargetDir = "$Cache\node-v$NodeVersion"
$NodeTarget = "$NodeTargetDir\node.exe"
## Download and unzip Node
if (!(Test-Path $NodeExe -PathType Leaf)) {
$Host.ui.RawUI.WindowTitle = "Downloading Node $NodeVersion..."
New-Item $NodeDir -ItemType Directory -ErrorAction silentlyContinue | Out-Null
Invoke-WebRequest `
"https://nodejs.org/download/release/v$NodeVersion/win-x86/node.exe" `
-OutFile $NodeExe `
-ErrorAction Stop
## Just print the path and exit
if ($Args.length -eq 1 -and $Args[0] -eq "Get-Path") {
Write-Output "$NodeTargetDir"
exit 0
}
## Just download node and exit
if ($Args.length -eq 1 -and $Args[0] -eq "Download-Node") {
Download-Node
exit 0
}
## Download node
Download-Node
## Set PATH so that recursive calls find it
$Env:PATH = "$NodeDir;$ENV:Path"
$Env:PATH = "$NodeTargetDir;$ENV:Path"
## Invoke Node with all command-line arguments
$Host.ui.RawUI.WindowTitle = "node $Args"
$ErrorActionPreference = "Continue"
& "$NodeExe" @Args
& "$NodeTarget" @Args
exit $LastExitCode

View File

@@ -77,6 +77,7 @@ fi
# Use pip to install our requirements
if [ ! -f "$PythonDir/requirements.txt" ] || [ "$(b2sum < "$Sdk/requirements.txt")" != "$(b2sum < "$PythonDir/requirements.txt")" ]; then
echo "Updating dependencies..."
"$PythonExe" -m pip install -U wheel
"$PythonExe" -m pip install -U pip -r "$Sdk/requirements.txt"
cp "$Sdk/requirements.txt" "$PythonDir/requirements.txt"
echo "---"

View File

@@ -6,7 +6,7 @@
*/
const { resolve: resolvePath } = require('path');
const { resolveGlob } = require('./cbt/fs');
const { resolveGlob, stat } = require('./cbt/fs');
const { exec } = require('./cbt/process');
const { Task, runTasks } = require('./cbt/task');
const { regQuery } = require('./cbt/winreg');
@@ -16,11 +16,11 @@ process.chdir(resolvePath(__dirname, '../../'));
const taskTgui = new Task('tgui')
.depends('tgui/.yarn/releases/*')
.depends('tgui/.yarn/install-state.gz')
.depends('tgui/yarn.lock')
.depends('tgui/webpack.config.js')
.depends('tgui/**/package.json')
.depends('tgui/packages/**/*.js')
.depends('tgui/packages/**/*.jsx')
.depends('tgui/packages/**/*.+(js|jsx|ts|tsx|cjs|mjs|scss)')
.provides('tgui/public/tgui.bundle.css')
.provides('tgui/public/tgui.bundle.js')
.provides('tgui/public/tgui-common.bundle.js')
@@ -29,9 +29,9 @@ const taskTgui = new Task('tgui')
.build(async () => {
// Instead of calling `tgui/bin/tgui`, we reproduce the whole pipeline
// here for maximum compilation speed.
const yarnRelease = resolveGlob('./tgui/.yarn/releases/yarn-*.cjs')[0]
const yarnPath = resolveGlob('./tgui/.yarn/releases/yarn-*.cjs')[0]
.replace('/tgui/', '/');
const yarn = args => exec('node', [yarnRelease, ...args], {
const yarn = args => exec('node', [yarnPath, ...args], {
cwd: './tgui',
});
await yarn(['install']);
@@ -48,29 +48,54 @@ const taskDm = new Task('dm')
.depends('modular_skyrat/**') // SKYRAT EDIT ADDITION -- check modular_skyrat too pls, build.js
.depends('tgui/public/tgui.html')
.depends('tgui/public/*.bundle.*')
.depends('tgui/public/*.chunk.*')
.depends('tgstation.dme')
.provides('tgstation.dmb')
.provides('tgstation.rsc')
.build(async () => {
let compiler = 'dm';
// Let's do some registry queries on Windows, because dm is not in PATH.
if (process.platform === 'win32') {
const installPath = (
await regQuery(
'HKLM\\Software\\Dantom\\BYOND',
'installpath')
|| await regQuery(
'HKLM\\SOFTWARE\\WOW6432Node\\Dantom\\BYOND',
'installpath')
);
if (installPath) {
compiler = resolvePath(installPath, 'bin/dm.exe');
const dmPath = await (async () => {
// Search in array of paths
const paths = [
...(process.env.DM_EXE && process.env.DM_EXE.split(',')),
'C:\\Program Files\\BYOND\\bin\\dm.exe',
'C:\\Program Files (x86)\\BYOND\\bin\\dm.exe',
['reg', 'HKLM\\Software\\Dantom\\BYOND', 'installpath'],
['reg', 'HKLM\\SOFTWARE\\WOW6432Node\\Dantom\\BYOND', 'installpath'],
];
const isFile = path => {
try {
const fstat = stat(path);
return fstat && fstat.isFile();
}
catch (err) {}
return false;
};
for (let path of paths) {
// Resolve a registry key
if (Array.isArray(path)) {
const [type, ...args] = path;
path = await regQuery(...args);
}
if (!path) {
continue;
}
// Check if path exists
if (isFile(path)) {
return path;
}
if (isFile(path + '/dm.exe')) {
return path + '/dm.exe';
}
if (isFile(path + '/bin/dm.exe')) {
return path + '/bin/dm.exe';
}
}
} else {
compiler = 'DreamMaker';
}
await exec(compiler, ['tgstation.dme']);
// Default paths
return (
process.platform === 'win32' && 'dm.exe'
|| 'DreamMaker'
);
})();
await exec(dmPath, ['tgstation.dme']);
});
// Frontend
@@ -79,8 +104,8 @@ const tasksToRun = [
taskDm,
];
if (process.env['TG_BUILD_TGS_MODE']) {
if (process.env.TG_BUILD_TGS_MODE) {
tasksToRun.pop();
}
runTasks(tasksToRun);
runTasks(tasksToRun);

View File

@@ -133,4 +133,4 @@ module.exports = {
stat,
resolveGlob,
compareFiles,
};
};

View File

@@ -78,13 +78,10 @@ const exec = (executable, args, options) => {
}
const child = spawn(executable, args, options);
children.add(child);
child.stdout.on('data', data => {
process.stdout.write(data);
});
child.stderr.on('data', data => {
process.stderr.write(data);
});
child.stdout.pipe(process.stdout, { end: false });
child.stderr.pipe(process.stderr, { end: false });
child.stdin.end();
child.on('error', err => reject(err));
child.on('exit', code => {
children.delete(child);
if (code !== 0) {
@@ -101,4 +98,5 @@ const exec = (executable, args, options) => {
module.exports = {
exec,
ExitError,
};

View File

@@ -5,8 +5,6 @@ tools/deploy.sh ci_test
mkdir ci_test/config
#test config
cp -r config/* ci_test/config/
mv ci_test/config/config.txt ci_test/config/original_config.txt
cp tools/ci/ci_config.txt ci_test/config/config.txt
cd ci_test