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