Skip to content

Commit a6e12e2

Browse files
committed
Add version info to the base class
1 parent 192803e commit a6e12e2

3 files changed

Lines changed: 40 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ jobs:
7575
run: node scripts/update-changelog.mjs
7676
if: ${{ github.event.inputs.releaseChannel == 'stable' }}
7777

78+
- name: Update version number in the base class
79+
run: node scripts/update-version-number.mjs
80+
7881
- name: Tagging
7982
run: |
8083
git add .

scripts/update-version-number.mjs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import fs from 'fs';
2+
import util from 'util';
3+
import path, {dirname} from 'path';
4+
import {fileURLToPath} from 'url';
5+
6+
const __filename = fileURLToPath(import.meta.url);
7+
const __dirname = dirname(__filename);
8+
9+
const readFile = util.promisify(fs.readFile);
10+
const writeFile = util.promisify(fs.writeFile);
11+
12+
const BASE_CLASS_PATH = path.join(
13+
__dirname,
14+
'..',
15+
'src',
16+
'includes',
17+
'VscElement.ts'
18+
);
19+
20+
async function main() {
21+
const pkgPath = path.join(__dirname, '..', 'package.json');
22+
const pkg = JSON.parse(fs.readFileSync(pkgPath).toString());
23+
const {version} = pkg;
24+
25+
const fc = await readFile(BASE_CLASS_PATH, 'utf-8');
26+
const newContent = fc.replace(/readonly version = '[a-z0-9-]+';/g, `readonly version = '${version}';`);
27+
28+
await writeFile(BASE_CLASS_PATH, newContent);
29+
30+
console.log('VscElement.ts updated successfully');
31+
}
32+
33+
main();

src/includes/VscElement.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
import {LitElement} from 'lit';
22

3-
export class VscElement extends LitElement {}
3+
export class VscElement extends LitElement {
4+
/** VSC Element version */
5+
public readonly version = '1.0.0-pre.5';
6+
}

0 commit comments

Comments
 (0)