Skip to content

Commit ee637ec

Browse files
committed
Website builders refactoring
1 parent bd5ecf7 commit ee637ec

File tree

9 files changed

+184
-316
lines changed

9 files changed

+184
-316
lines changed

.github/workflows/build-web-for-branch.yml

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- name: Extract branch name
15-
shell: bash
16-
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
17-
id: extract_branch
18-
19-
- name: Checkout code
20-
uses: actions/checkout@v5
21-
with:
22-
ref: ${{ steps.extract_branch.outputs.branch }}
23-
24-
- name: Copy runner file to remote server
25-
uses: garygrossgarten/github-action-scp@0.9.0
26-
with:
27-
local: website/scripts/runner.mjs
28-
remote: /var/www/core-js/runner.mjs
29-
host: ${{ secrets.REMOTE_HOST }}
30-
username: ci
31-
privateKey: ${{ secrets.CI_SSH_KEY }}
32-
33-
- name: Copy runner wrapper file to remote server
34-
uses: garygrossgarten/github-action-scp@0.9.0
35-
with:
36-
local: website/scripts/runner.sh
37-
remote: /var/www/core-js/runner.sh
38-
host: ${{ secrets.REMOTE_HOST }}
39-
username: ci
40-
privateKey: ${{ secrets.CI_SSH_KEY }}
41-
42-
- name: Setup SSH
43-
uses: webfactory/ssh-agent@v0.9.1
44-
with:
45-
ssh-private-key: ${{ secrets.CI_SSH_KEY }}
46-
47-
- name: Make runner.sh executable on remote
48-
run: |
49-
ssh -o StrictHostKeyChecking=no ci@${{ secrets.REMOTE_HOST }} "chmod +x /var/www/core-js/runner.sh"
14+
- uses: .github/workflows/upload-web-builder.yml
5015

5116
- name: Run node runner.mjs on remote server
5217
run: |

.github/workflows/build-web.yml

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212

1313
steps:
14-
- name: Extract branch name
15-
shell: bash
16-
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
17-
id: extract_branch
18-
19-
- name: Checkout code
20-
uses: actions/checkout@v5
21-
with:
22-
ref: ${{ steps.extract_branch.outputs.branch }}
23-
24-
- name: Copy runner file to remote server
25-
uses: garygrossgarten/github-action-scp@0.9.0
26-
with:
27-
local: website/scripts/runner.mjs
28-
remote: /var/www/core-js/runner.mjs
29-
host: ${{ secrets.REMOTE_HOST }}
30-
username: ci
31-
privateKey: ${{ secrets.CI_SSH_KEY }}
32-
33-
- name: Copy runner wrapper file to remote server
34-
uses: garygrossgarten/github-action-scp@0.9.0
35-
with:
36-
local: website/scripts/runner.sh
37-
remote: /var/www/core-js/runner.sh
38-
host: ${{ secrets.REMOTE_HOST }}
39-
username: ci
40-
privateKey: ${{ secrets.CI_SSH_KEY }}
41-
42-
- name: Setup SSH
43-
uses: webfactory/ssh-agent@v0.9.1
44-
with:
45-
ssh-private-key: ${{ secrets.CI_SSH_KEY }}
46-
47-
- name: Make runner.sh executable on remote
48-
run: |
49-
ssh -o StrictHostKeyChecking=no ci@${{ secrets.REMOTE_HOST }} "chmod +x /var/www/core-js/runner.sh"
14+
- uses: .github/workflows/upload-web-builder.yml
5015

5116
- name: Run node runner.mjs on remote server
5217
run: |
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Upload web builder
2+
3+
on: workflow_call
4+
5+
jobs:
6+
run-on-server:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Extract branch name
11+
shell: bash
12+
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
13+
id: extract_branch
14+
15+
- name: Checkout code
16+
uses: actions/checkout@v5
17+
with:
18+
ref: ${{ steps.extract_branch.outputs.branch }}
19+
20+
- name: Copy runner file to remote server
21+
uses: garygrossgarten/github-action-scp@0.9.0
22+
with:
23+
local: website/scripts/runner.mjs
24+
remote: /var/www/core-js/runner.mjs
25+
host: ${{ secrets.REMOTE_HOST }}
26+
username: ci
27+
privateKey: ${{ secrets.CI_SSH_KEY }}
28+
29+
- name: Copy runner wrapper file to remote server
30+
uses: garygrossgarten/github-action-scp@0.9.0
31+
with:
32+
local: website/scripts/runner.sh
33+
remote: /var/www/core-js/runner.sh
34+
host: ${{ secrets.REMOTE_HOST }}
35+
username: ci
36+
privateKey: ${{ secrets.CI_SSH_KEY }}
37+
38+
- name: Copy runner helpers file to remote server
39+
uses: garygrossgarten/github-action-scp@0.9.0
40+
with:
41+
local: website/scripts/helpers.mjs
42+
remote: /var/www/core-js/helpers.mjs
43+
host: ${{ secrets.REMOTE_HOST }}
44+
username: ci
45+
privateKey: ${{ secrets.CI_SSH_KEY }}
46+
47+
- name: Setup SSH
48+
uses: webfactory/ssh-agent@v0.9.1
49+
with:
50+
ssh-private-key: ${{ secrets.CI_SSH_KEY }}
51+
52+
- name: Make runner.sh executable on remote
53+
run: |
54+
ssh -o StrictHostKeyChecking=no ci@${{ secrets.REMOTE_HOST }} "chmod +x /var/www/core-js/runner.sh"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"prepare": "npm run zxi scripts/prepare.mjs",
2020
"build-compat": "npm run zxi scripts/build-compat/index.mjs",
2121
"build-web": "npm run zxi time website/index.mjs",
22-
"build-web-local": "npm run zxi time website/local.mjs",
22+
"build-web-local": "npm run zxi time website/build-local.mjs",
2323
"bundle": "run-s bundle-package bundle-tests",
2424
"bundle-package": "npm run zxi time scripts/bundle-package/bundle-package.mjs",
2525
"bundle-tests": "npm run zxi time cd scripts/bundle-tests/bundle-tests.mjs",

tests/eslint/eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,6 +2392,7 @@ export default [
23922392
'tests/compat/*.mjs',
23932393
'tests/@(compat-@(data|tools)|eslint|entries|observables|promises-aplus|unit-@(karma|node))/**',
23942394
'website/runner.mjs',
2395+
'website/helpers.mjs',
23952396
],
23962397
rules: nodeDev,
23972398
},

website/build-local.mjs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {
2+
hasDocs, copyBlogPosts, copyBabelStandalone, copyCommonFiles, buildAndCopyCoreJS, buildWeb, getCurrentBranch,
3+
} from './scripts/helpers.mjs';
4+
5+
const BUILD_SRC_DIR = './';
6+
const BUNDLES_DIR = 'bundles';
7+
8+
try {
9+
console.time('Finished in');
10+
const targetBranch = await getCurrentBranch(BUILD_SRC_DIR);
11+
12+
const version = { branch: targetBranch, label: targetBranch };
13+
await hasDocs(version, BUILD_SRC_DIR);
14+
await buildAndCopyCoreJS(version, false, BUILD_SRC_DIR, BUNDLES_DIR);
15+
16+
await copyBabelStandalone(BUILD_SRC_DIR);
17+
await copyBlogPosts(BUILD_SRC_DIR);
18+
await copyCommonFiles(BUILD_SRC_DIR);
19+
await buildWeb(targetBranch, BUILD_SRC_DIR);
20+
console.timeEnd('Finished in');
21+
} catch (error) {
22+
console.error(error);
23+
}

website/build.mjs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* eslint-disable import/no-unresolved -- dependencies are not installed */
2+
import { getDefaultVersion } from './scripts/helpers.mjs';
23
import fm from 'front-matter';
34
import { JSDOM } from 'jsdom';
45
import { Marked } from 'marked';
@@ -13,20 +14,13 @@ const branchArg = argv._.find(item => item.startsWith('branch='));
1314
const BRANCH = branchArg ? branchArg.slice('branch='.length) : undefined;
1415
const LOCAL = argv._.includes('local');
1516
const BASE = LOCAL && BRANCH ? '/core-js/website/dist/' : BRANCH ? `/branches/${ BRANCH }/` : '/';
16-
const DEFAULT_VERSION = await getDefaultVersion();
17+
const DEFAULT_VERSION = await getDefaultVersion(config.versionsFile, BRANCH);
1718

1819
let htmlFileName = '';
1920
let docsMenu = '';
2021
let isBlog = false;
2122
let isDocs = false;
2223

23-
async function getDefaultVersion() {
24-
if (BRANCH) return BRANCH;
25-
26-
const versions = await readJson(config.versionsFile);
27-
return versions.find(v => v.default)?.label;
28-
}
29-
3024
async function getAllMdFiles(dir) {
3125
const entries = await readdir(dir, { withFileTypes: true });
3226
const files = [];
@@ -209,12 +203,6 @@ async function buildBlogMenu() {
209203
return menu;
210204
}
211205

212-
// eslint-disable-next-line no-unused-vars -- use it later
213-
async function getVersionTags() {
214-
const tagsString = await $`git tag | grep -E "^v[4-9]\\.[0-9]+\\.[0-9]+$" | sort -V`;
215-
return tagsString.stdout.split('\n');
216-
}
217-
218206
async function getVersionFromMdFile(mdPath) {
219207
const match = mdPath.match(/\/web\/(?<version>[^/]+)\/docs\//);
220208
return match?.groups?.version ?? DEFAULT_VERSION;

0 commit comments

Comments
 (0)