Skip to content

Commit

Permalink
Replace ui/scripts/create_versions.sh with js script
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-va committed Nov 6, 2024
1 parent ccef741 commit aa58639
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"start": "npm run webpack-start",
"build-static": "node scripts/environment.js $RELEASE_NAME && node scripts/generateManuals.js && bash scripts/legal_md_to_html.sh",
"webpack-start": "npm run build-static && webpack serve",
"build": "rm -rf dist/* && npm run build-static && rollup --environment mode:production -c && bash scripts/create_versions.sh; find dist -type l -exec rm {} +",
"build": "rm -rf dist/* && npm run build-static && rollup --environment mode:production -c && node scripts/extract_versions.js; find dist -type l -exec rm {} +",
"check": "npm run check-main && npm run check-ut",
"check-main": "tsc src/index.ts --noEmit --allowJs --skipLibCheck --target es2020 --moduleResolution node",
"check-ut": "tsc src/test/*.ts src/test/*.js --noEmit --allowJs --skipLibCheck --esModuleInterop true --target es2020 --moduleResolution node",
Expand Down
10 changes: 0 additions & 10 deletions ui/scripts/create_versions.sh

This file was deleted.

30 changes: 30 additions & 0 deletions ui/scripts/extract_versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {readFileSync, writeFileSync} from 'node:fs';
import * as path from 'node:path';

import * as util from 'node:util';
import {exec as execSync} from 'node:child_process';
const exec = util.promisify(execSync);

const cesiumPackagePath = path.resolve(import.meta.dirname, '../node_modules/cesium/package.json');
const cesiumPackageString = readFileSync(cesiumPackagePath, 'utf-8');
const cesiumVersion = JSON.parse(cesiumPackageString).version;

const commitHash = (await exec('git rev-list HEAD -1')).stdout.trim();

const now = new Date();
const date = new Intl.DateTimeFormat('en-CA', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit',
timeZoneName: 'longOffset',
hourCycle: 'h23'
}).format(now).replace(', ', 'T').replace(' GMT', '');

const versionsFilePath = path.resolve(import.meta.dirname, '../dist/versions.json');
writeFileSync(versionsFilePath, JSON.stringify({
build: date,
commit_hash: commitHash,
cesium: cesiumVersion,
}, null, 2));

0 comments on commit aa58639

Please sign in to comment.