Skip to content

Commit

Permalink
Add version info to the base class
Browse files Browse the repository at this point in the history
  • Loading branch information
bendera committed Nov 24, 2023
1 parent 192803e commit a6e12e2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ jobs:
run: node scripts/update-changelog.mjs
if: ${{ github.event.inputs.releaseChannel == 'stable' }}

- name: Update version number in the base class
run: node scripts/update-version-number.mjs

- name: Tagging
run: |
git add .
Expand Down
33 changes: 33 additions & 0 deletions scripts/update-version-number.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import fs from 'fs';
import util from 'util';
import path, {dirname} from 'path';
import {fileURLToPath} from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const readFile = util.promisify(fs.readFile);
const writeFile = util.promisify(fs.writeFile);

const BASE_CLASS_PATH = path.join(
__dirname,
'..',
'src',
'includes',
'VscElement.ts'
);

async function main() {
const pkgPath = path.join(__dirname, '..', 'package.json');
const pkg = JSON.parse(fs.readFileSync(pkgPath).toString());
const {version} = pkg;

const fc = await readFile(BASE_CLASS_PATH, 'utf-8');
const newContent = fc.replace(/readonly version = '[a-z0-9-]+';/g, `readonly version = '${version}';`);

await writeFile(BASE_CLASS_PATH, newContent);

console.log('VscElement.ts updated successfully');
}

main();
5 changes: 4 additions & 1 deletion src/includes/VscElement.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import {LitElement} from 'lit';

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

0 comments on commit a6e12e2

Please sign in to comment.