mirror of
https://github.com/hanzoai/core-js.git
synced 2026-09-24 16:58:15 +00:00
Fix versions dropdowns & build local script
This commit is contained in:
+5
-1
@@ -8,7 +8,11 @@ node_modules/
|
||||
.DS_Store
|
||||
.idea
|
||||
|
||||
/docs/web/blog/index.md
|
||||
/bundles/
|
||||
/docs/web/blog/
|
||||
/docs/web/changelog.md
|
||||
/docs/web/contributing.md
|
||||
/docs/web/security.md
|
||||
/packages/core-js/features/
|
||||
/packages/core-js/es/index.js
|
||||
/packages/core-js/full/index.js
|
||||
|
||||
+12
-3
@@ -1,22 +1,31 @@
|
||||
import {
|
||||
hasDocs, copyBlogPosts, copyBabelStandalone, copyCommonFiles, buildAndCopyCoreJS, buildWeb, getCurrentBranch,
|
||||
isExists, copyBlogPosts, copyBabelStandalone, copyCommonFiles, buildAndCopyCoreJS, buildWeb, getCurrentBranch,
|
||||
} from './scripts/helpers.mjs';
|
||||
import { join } from 'node:path';
|
||||
|
||||
const BUILD_SRC_DIR = './';
|
||||
const BUNDLES_DIR = 'bundles';
|
||||
|
||||
async function hasDocsLocal(srcDir) {
|
||||
const target = join(srcDir, 'docs/web/docs');
|
||||
console.log(`Checking if docs exist in "${ target }"...`);
|
||||
if (!await isExists(target)) {
|
||||
throw new Error(`Docs not found in "${ target }".`);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
console.time('Finished in');
|
||||
const targetBranch = await getCurrentBranch(BUILD_SRC_DIR);
|
||||
|
||||
const version = { branch: targetBranch, label: targetBranch };
|
||||
await hasDocs(version, BUILD_SRC_DIR);
|
||||
await hasDocsLocal(BUILD_SRC_DIR);
|
||||
await buildAndCopyCoreJS(version, false, BUILD_SRC_DIR, BUNDLES_DIR);
|
||||
|
||||
await copyBabelStandalone(BUILD_SRC_DIR);
|
||||
await copyBlogPosts(BUILD_SRC_DIR);
|
||||
await copyCommonFiles(BUILD_SRC_DIR);
|
||||
await buildWeb(targetBranch, BUILD_SRC_DIR);
|
||||
await buildWeb(targetBranch, BUILD_SRC_DIR, true);
|
||||
console.timeEnd('Finished in');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
+24
-25
@@ -1,12 +1,11 @@
|
||||
/* eslint-disable no-console -- needed for logging */
|
||||
import childProcess from 'node:child_process';
|
||||
import { constants } from 'node:fs';
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { cp, access, readdir, readFile } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
import { promisify } from 'node:util';
|
||||
|
||||
const exec = promisify(childProcess.exec);
|
||||
const { cp, access, readdir, readFile } = fs;
|
||||
|
||||
const BABEL_PATH = 'website/node_modules/@babel/standalone/babel.min.js';
|
||||
|
||||
@@ -40,8 +39,8 @@ export async function copyBabelStandalone(srcDir) {
|
||||
console.log('Copying Babel standalone...');
|
||||
await installDependencies(`${ srcDir }website`);
|
||||
console.time('Copied Babel standalone');
|
||||
const babelPath = `${ srcDir }${ BABEL_PATH }`;
|
||||
const destPath = `${ srcDir }website/src/public/babel.min.js`;
|
||||
const babelPath = join(srcDir, BABEL_PATH);
|
||||
const destPath = join(srcDir, 'website/src/public/babel.min.js');
|
||||
await cp(babelPath, destPath);
|
||||
console.timeEnd('Copied Babel standalone');
|
||||
}
|
||||
@@ -49,13 +48,13 @@ export async function copyBabelStandalone(srcDir) {
|
||||
export async function copyBlogPosts(srcDir) {
|
||||
console.log('Copying blog posts...');
|
||||
console.time('Copied blog posts');
|
||||
const fromDir = `${ srcDir }docs/`;
|
||||
const toDir = `${ srcDir }docs/web/blog/`;
|
||||
const fromDir = join(srcDir, 'docs/');
|
||||
const toDir = join(srcDir, 'docs/web/blog/');
|
||||
const entries = await readdir(fromDir, { withFileTypes: true });
|
||||
for (const entry of entries) {
|
||||
if (entry.isFile()) {
|
||||
const srcFile = path.join(fromDir, entry.name);
|
||||
const destFile = path.join(toDir, entry.name);
|
||||
const srcFile = join(fromDir, entry.name);
|
||||
const destFile = join(toDir, entry.name);
|
||||
await cp(srcFile, destFile);
|
||||
}
|
||||
}
|
||||
@@ -65,11 +64,10 @@ export async function copyBlogPosts(srcDir) {
|
||||
export async function copyCommonFiles(srcDir) {
|
||||
console.log('Copying common files...');
|
||||
console.time('Copied common files');
|
||||
const fromDir = `${ srcDir }`;
|
||||
const toDir = `${ srcDir }docs/web/`;
|
||||
await cp(`${ fromDir }CHANGELOG.md`, `${ toDir }changelog.md`);
|
||||
await cp(`${ fromDir }CONTRIBUTING.md`, `${ toDir }contributing.md`);
|
||||
await cp(`${ fromDir }SECURITY.md`, `${ toDir }security.md`);
|
||||
const toDir = join(srcDir, 'docs/web/');
|
||||
await cp(`${ srcDir }CHANGELOG.md`, `${ toDir }changelog.md`);
|
||||
await cp(`${ srcDir }CONTRIBUTING.md`, `${ toDir }contributing.md`);
|
||||
await cp(`${ srcDir }SECURITY.md`, `${ toDir }security.md`);
|
||||
console.timeEnd('Copied common files');
|
||||
}
|
||||
|
||||
@@ -81,10 +79,10 @@ export async function buildAndCopyCoreJS(version, checkout, srcDir, destDir) {
|
||||
|
||||
if (await isExists(targetBundlePath)) {
|
||||
console.time('Core JS bundles copied');
|
||||
const bundlePath = `${ targetBundlePath }core-js-bundle.js`;
|
||||
const destBundlePath = `${ srcDir }website/src/public/bundles/${ name }/core-js-bundle.js`;
|
||||
const esmodulesBundlePath = `${ targetBundlePath }core-js-bundle-esmodules.js`;
|
||||
const esmodulesDestBundlePath = `${ srcDir }website/src/public/bundles/${ name }/core-js-bundle-esmodules.js`;
|
||||
const bundlePath = join(targetBundlePath, 'core-js-bundle.js');
|
||||
const destBundlePath = join(srcDir, 'website/src/public/bundles/', name, 'core-js-bundle.js');
|
||||
const esmodulesBundlePath = join(targetBundlePath, 'core-js-bundle-esmodules.js');
|
||||
const esmodulesDestBundlePath = join(srcDir, 'website/src/public/bundles/', name, 'core-js-bundle-esmodules.js');
|
||||
await cp(bundlePath, destBundlePath);
|
||||
await cp(esmodulesBundlePath, esmodulesDestBundlePath);
|
||||
console.timeEnd('Core JS bundles copied');
|
||||
@@ -97,16 +95,16 @@ export async function buildAndCopyCoreJS(version, checkout, srcDir, destDir) {
|
||||
}
|
||||
await installDependencies(srcDir);
|
||||
await exec('npm run bundle-package', { cwd: srcDir });
|
||||
const bundlePath = `${ srcDir }packages/core-js-bundle/minified.js`;
|
||||
const destPath = `${ srcDir }website/src/public/bundles/${ name }/core-js-bundle.js`;
|
||||
const destBundlePath = `${ targetBundlePath }core-js-bundle.js`;
|
||||
const bundlePath = join(srcDir, 'packages/core-js-bundle/minified.js');
|
||||
const destPath = join(srcDir, 'website/src/public/bundles/', name, 'core-js-bundle.js');
|
||||
const destBundlePath = join(targetBundlePath, 'core-js-bundle.js');
|
||||
await cp(bundlePath, destPath);
|
||||
await cp(bundlePath, destBundlePath);
|
||||
|
||||
await exec('npm run bundle-package esmodules', { cwd: srcDir });
|
||||
const esmodulesBundlePath = `${ srcDir }packages/core-js-bundle/minified.js`;
|
||||
const esmodulesDestBundlePath = `${ srcDir }website/src/public/bundles/${ name }/core-js-bundle-esmodules.js`;
|
||||
const destEsmodulesBundlePath = `${ targetBundlePath }core-js-bundle-esmodules.js`;
|
||||
const esmodulesBundlePath = join(srcDir, 'packages/core-js-bundle/minified.js');
|
||||
const esmodulesDestBundlePath = join(srcDir, 'website/src/public/bundles/', name, 'core-js-bundle-esmodules.js');
|
||||
const destEsmodulesBundlePath = join(targetBundlePath, 'core-js-bundle-esmodules.js');
|
||||
await cp(esmodulesBundlePath, esmodulesDestBundlePath);
|
||||
await cp(esmodulesBundlePath, destEsmodulesBundlePath);
|
||||
console.timeEnd('Core JS bundles built');
|
||||
@@ -120,11 +118,12 @@ export async function checkoutVersion(version, execDir) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function buildWeb(branch, execDir) {
|
||||
export async function buildWeb(branch, execDir, local = false) {
|
||||
console.log('Building web...');
|
||||
console.time('Built web');
|
||||
let command = 'npm run build-web';
|
||||
if (branch) command += ` branch=${ branch }`;
|
||||
if (local) command += ' local';
|
||||
const stdout = await exec(command, { cwd: execDir });
|
||||
console.timeEnd('Built web');
|
||||
return stdout;
|
||||
|
||||
+10
-11
@@ -3,12 +3,11 @@ import {
|
||||
hasDocs, copyBlogPosts, copyBabelStandalone, copyCommonFiles, buildAndCopyCoreJS, buildWeb, getDefaultVersion, readJSON,
|
||||
} from './helpers.mjs';
|
||||
import childProcess from 'node:child_process';
|
||||
import fs from 'node:fs/promises';
|
||||
import { cp, readdir, readlink } from 'node:fs/promises';
|
||||
import { promisify } from 'node:util';
|
||||
import path from 'node:path';
|
||||
import { resolve, join } from 'node:path';
|
||||
|
||||
const exec = promisify(childProcess.exec);
|
||||
const { cp, readdir, readlink } = fs;
|
||||
|
||||
const SRC_DIR = 'core-js';
|
||||
const BUILDS_ROOT_DIR = 'builds';
|
||||
@@ -62,8 +61,8 @@ async function cloneRepo() {
|
||||
async function switchToLatestBuild() {
|
||||
console.log('Switching to the latest build...');
|
||||
console.time('Switched to the latest build');
|
||||
const absoluteBuildPath = path.resolve(`${ BUILD_DIR }${ BUILD_RESULT_DIR }`);
|
||||
const absoluteLatestPath = path.resolve('./latest');
|
||||
const absoluteBuildPath = resolve(`${ BUILD_DIR }${ BUILD_RESULT_DIR }`);
|
||||
const absoluteLatestPath = resolve('./latest');
|
||||
console.log(absoluteBuildPath, absoluteLatestPath);
|
||||
await exec('rm -f ./latest');
|
||||
await exec(`ln -sf ${ absoluteBuildPath } ${ absoluteLatestPath }`);
|
||||
@@ -117,8 +116,8 @@ async function prepareBuilder(targetBranch) {
|
||||
async function switchBranchToLatestBuild(name) {
|
||||
console.log(`Switching branch "${ name }" to the latest build...`);
|
||||
console.time(`Switched branch "${ name }" to the latest build`);
|
||||
const absoluteBuildPath = path.resolve(`${ BUILD_DIR }${ BUILD_RESULT_DIR }`);
|
||||
const absoluteLatestPath = path.resolve(`./branches/${ name }`);
|
||||
const absoluteBuildPath = resolve(`${ BUILD_DIR }${ BUILD_RESULT_DIR }`);
|
||||
const absoluteLatestPath = resolve(`./branches/${ name }`);
|
||||
await exec(`rm -f ./branches/${ name }`);
|
||||
await exec(`ln -sf ${ absoluteBuildPath } ${ absoluteLatestPath }`);
|
||||
console.timeEnd(`Switched branch "${ name }" to the latest build`);
|
||||
@@ -159,8 +158,8 @@ async function clearOldBuilds() {
|
||||
const builds = await readdir(BUILDS_ROOT_DIR);
|
||||
for (const build of builds) {
|
||||
if (!excluded.includes(build)) {
|
||||
await exec(`rm -rf ${ path.join('./', BUILDS_ROOT_DIR, '/', build) }`);
|
||||
console.log(`Build removed: "${ path.join('./', BUILDS_ROOT_DIR, '/', build) }"`);
|
||||
await exec(`rm -rf ${ join('./', BUILDS_ROOT_DIR, '/', build) }`);
|
||||
console.log(`Build removed: "${ join('./', BUILDS_ROOT_DIR, '/', build) }"`);
|
||||
}
|
||||
}
|
||||
console.timeEnd('Cleared old builds');
|
||||
@@ -170,8 +169,8 @@ async function createLastDocsLink() {
|
||||
console.log('Creating last docs link...');
|
||||
console.time('Created last docs link');
|
||||
const defaultVersion = await getDefaultVersion(VERSIONS_FILE);
|
||||
const absoluteBuildPath = path.resolve(`${ BUILD_DIR }${ BUILD_RESULT_DIR }/${ defaultVersion }/docs/`);
|
||||
const absoluteLastDocsPath = path.resolve(`${ BUILD_DIR }${ BUILD_RESULT_DIR }/docs/`);
|
||||
const absoluteBuildPath = resolve(`${ BUILD_DIR }${ BUILD_RESULT_DIR }/${ defaultVersion }/docs/`);
|
||||
const absoluteLastDocsPath = resolve(`${ BUILD_DIR }${ BUILD_RESULT_DIR }/docs/`);
|
||||
await exec(`ln -s ${ absoluteBuildPath } ${ absoluteLastDocsPath }`);
|
||||
console.timeEnd('Created last docs link');
|
||||
}
|
||||
|
||||
@@ -459,7 +459,8 @@ main {
|
||||
|
||||
& > a {
|
||||
display: block;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
width: 90%;
|
||||
|
||||
&::after {
|
||||
content: '';
|
||||
|
||||
Reference in New Issue
Block a user