MCPcopy
hub / github.com/QwikDev/qwik / getVersion

Function getVersion

scripts/release.ts:15–48  ·  view source on GitHub ↗
(distTag?: string)

Source from the content-addressed store, hash-verified

13let version: string;
14
15export async function getVersion(distTag?: string) {
16 if (!version) {
17 const __dirname = fileURLToPath(new URL('.', import.meta.url));
18 // Qwik is the source of truth for the version
19 const qwikDir = join(__dirname, '..', 'packages', 'qwik');
20 const qwikPkg = await readPackageJson(qwikDir);
21 let v = qwikPkg.version;
22 if (!distTag || distTag === 'dev') {
23 v += '-dev';
24 // add the current short commit hash
25 // when in github actions, get from environment
26 try {
27 const gitSha = process.env.GITHUB_SHA;
28 const gitCommit = gitSha || (await execa('git', ['rev-parse', 'HEAD'])).stdout;
29 v += `+${gitCommit.slice(0, 7)}`;
30 } catch (e) {
31 // git not found
32 }
33 const gitStatus = await execa('git', ['status', '--porcelain']);
34 if (gitStatus.stdout !== '') {
35 const d = new Date();
36 v += '-';
37 v += String(d.getUTCFullYear());
38 v += String(d.getUTCMonth() + 1).padStart(2, '0');
39 v += String(d.getUTCDate()).padStart(2, '0');
40 v += String(d.getUTCHours()).padStart(2, '0');
41 v += String(d.getUTCMinutes()).padStart(2, '0');
42 v += String(d.getUTCSeconds()).padStart(2, '0');
43 }
44 }
45 version = v;
46 }
47 return version;
48}
49export async function setDistVersion(config: BuildConfig) {
50 config.distVersion = await getVersion(config.setDistTag);
51}

Callers 2

setDistVersionFunction · 0.85
setReleaseVersionFunction · 0.85

Calls 2

readPackageJsonFunction · 0.90
joinFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…