core: change build script to plain javascript

This commit is contained in:
undefined committed 2021-04-16 22:06:07 +08:00
1 parent 6c5532e298
commit b0df7024e6
8 files changed
+27 -59

No files matched your search

+1 -1
View File
@@ -24,7 +24,7 @@ tsconfig.json
# Project Rules # Project Rules
## Core ## Core
packages/**/*.js packages/**/*.js
!/build/build.js !/build/*.js
!**/bin/*.js !**/bin/*.js
!*.page.js !*.page.js
!/install/jssh.d.ts !/install/jssh.d.ts
-1
View File
@@ -18,7 +18,6 @@ const compilerOptionsBase = {
const config = { const config = {
compilerOptions: compilerOptionsBase, compilerOptions: compilerOptionsBase,
references: [ references: [
{ path: 'tsconfig.build.json' },
{ path: 'packages/hydrooj' }, { path: 'packages/hydrooj' },
], ],
files: [], files: [],
+1 -2
View File
@@ -1,8 +1,7 @@
/* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable import/no-extraneous-dependencies */
import spawn from 'cross-spawn'; const spawn = require('cross-spawn');
const args = ['jest', '--coverage']; const args = ['jest', '--coverage'];
const [, , argv2, argv3] = process.argv; const [, , argv2, argv3] = process.argv;
if (argv2 && !argv2.startsWith('-')) { if (argv2 && !argv2.startsWith('-')) {
+7 -8
View File
@@ -3,12 +3,11 @@
/* eslint-disable consistent-return */ /* eslint-disable consistent-return */
/* eslint-disable no-await-in-loop */ /* eslint-disable no-await-in-loop */
/* eslint-disable import/no-dynamic-require */ /* eslint-disable import/no-dynamic-require */
import { gt } from 'semver';
import latest from 'latest-version'; const { gt } = require('semver');
import ora from 'ora'; const latest = require('latest-version');
import { const ora = require('ora');
PackageJson, getWorkspaces, spawnAsync, const { getWorkspaces, spawnAsync } = require('./utils');
} from './utils';
const { const {
CI, GITHUB_EVENT_NAME, GITHUB_REF, CI, GITHUB_EVENT_NAME, GITHUB_REF,
@@ -28,12 +27,12 @@ if (CI && (!tag || GITHUB_EVENT_NAME !== 'push')) {
} }
const spinner = ora(); const spinner = ora();
const bumpMap: Record<string, string> = {}; const bumpMap = {};
let progress = 0; let progress = 0;
spinner.start(`Loading workspaces (0/${folders.length})`); spinner.start(`Loading workspaces (0/${folders.length})`);
await Promise.all(folders.map(async (name) => { await Promise.all(folders.map(async (name) => {
let meta: PackageJson; let meta;
try { try {
meta = require(`../${name}/package.json`); meta = require(`../${name}/package.json`);
if (!meta.private) { if (!meta.private) {
+8 -9
View File
@@ -1,13 +1,12 @@
/* eslint-disable no-console */ /* eslint-disable no-console */
/* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable import/no-extraneous-dependencies */
import os from 'os'; const os = require('os');
import path from 'path'; const path = require('path');
import cluster from 'cluster'; const cluster = require('cluster');
import fs from 'fs-extra'; const fs = require('fs-extra');
import { filter } from 'lodash'; const { filter } = require('lodash');
import { argv } from 'yargs'; const { argv } = require('yargs');
// @ts-ignore const hydro = require('hydrooj');
import * as hydro from 'hydrooj';
if (!cluster.isMaster) { if (!cluster.isMaster) {
// Forked by hydro // Forked by hydro
@@ -25,7 +24,7 @@ if (!cluster.isMaster) {
fs.writeFileSync(addonPath, JSON.stringify(addons, null, 2)); fs.writeFileSync(addonPath, JSON.stringify(addons, null, 2));
try { try {
const ui = argv.ui as string || '@hydrooj/ui-default'; const ui = argv.ui || '@hydrooj/ui-default';
require.resolve(ui); require.resolve(ui);
addons = [ui, ...addons]; addons = [ui, ...addons];
} catch (e) { } catch (e) {
+10 -14
View File
@@ -1,11 +1,11 @@
/* eslint-disable no-console */ /* eslint-disable no-console */
/* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable import/no-extraneous-dependencies */
import globby from 'globby'; const globby = require('globby');
import spawn from 'cross-spawn'; const spawn = require('cross-spawn');
export const cwd = process.cwd(); const cwd = process.cwd();
export function getWorkspaces() { function getWorkspaces() {
return globby(require('../package').workspaces, { return globby(require('../package').workspaces, {
cwd, cwd,
deep: 0, deep: 0,
@@ -14,15 +14,7 @@ export function getWorkspaces() {
}); });
} }
export type DependencyType = 'dependencies' | 'devDependencies' | 'peerDependencies' | 'optionalDependencies'; function spawnSync(command: string, silent?: boolean) {
export interface PackageJson extends Partial<Record<DependencyType, Record<string, string>>> {
name?: string
private?: boolean
version?: string
}
export function spawnSync(command: string, silent?: boolean) {
if (!silent) console.log(`$ ${command}`); if (!silent) console.log(`$ ${command}`);
const args = command.split(/\s+/); const args = command.split(/\s+/);
const result = spawn.sync(args[0], [...args.slice(1), '--color'], { cwd, encoding: 'utf8' }); const result = spawn.sync(args[0], [...args.slice(1), '--color'], { cwd, encoding: 'utf8' });
@@ -34,7 +26,7 @@ export function spawnSync(command: string, silent?: boolean) {
} }
} }
export function spawnAsync(command: string) { function spawnAsync(command: string) {
const args = command.split(/\s+/); const args = command.split(/\s+/);
const child = spawn(args[0], args.slice(1), { stdio: 'inherit' }); const child = spawn(args[0], args.slice(1), { stdio: 'inherit' });
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@@ -42,3 +34,7 @@ export function spawnAsync(command: string) {
child.on('error', reject); child.on('error', reject);
}); });
} }
module.exports = {
cwd, spawnSync, spawnAsync, getWorkspaces,
};
-3
View File
@@ -2,9 +2,6 @@
"name": "@hydrooj/hydrojudge", "name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js", "bin": "bin/hydrojudge.js",
"version": "2.5.1", "version": "2.5.1",
"os": [
"linux"
],
"main": "package.json", "main": "package.json",
"author": "undefined <i@undefined.moe>", "author": "undefined <i@undefined.moe>",
"repository": "https://github.com/hydro-dev/Hydro.git", "repository": "https://github.com/hydro-dev/Hydro.git",
-21
View File
@@ -1,21 +0,0 @@
{
"compilerOptions": {
"target": "es2019",
"module": "commonjs",
"esModuleInterop": true,
"moduleResolution": "node",
"declaration": true,
"sourceMap": true,
"composite": true,
"strictBindCallApply": true,
"experimentalDecorators": true,
"outDir": "build",
"rootDir": "build"
},
"include": [
"build"
],
"exclude": [
"packages"
]
}