Skip to content

Commit 9ca6010

Browse files
adding version numbers to docs
1 parent ecf61cd commit 9ca6010

File tree

6 files changed

+78
-2
lines changed

6 files changed

+78
-2
lines changed

apps/vue-storybook/vite.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import { defineConfig } from 'vite'
22
import vue from '@vitejs/plugin-vue'
3+
import packageVersions from '@explorer-1/common-storybook/src/plugins/package-versions.js'
4+
35
// import Components from 'unplugin-vue-components/vite'
46

57
export default defineConfig({
8+
define: {
9+
...packageVersions
10+
},
611
plugins: [
712
vue()
813
// TODO: Doesn't work
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { fileURLToPath } from 'url'
2+
import path from 'path'
3+
import fs from 'fs'
4+
5+
// Helper function to read versions from all packages
6+
function getPackageVersions() {
7+
const versions = {}
8+
9+
// Resolve the absolute path to the 'packages' directory from the root of the monorepo
10+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
11+
const packagesDir = path.resolve(__dirname, '../../../../', 'packages')
12+
13+
// Loop through all directories in 'packages'
14+
const packageFolders = fs.readdirSync(packagesDir)
15+
16+
for (const folder of packageFolders) {
17+
const packagePath = path.join(packagesDir, folder, 'package.json')
18+
19+
// Check if package.json exists
20+
if (fs.existsSync(packagePath)) {
21+
const { name, version } = JSON.parse(fs.readFileSync(packagePath, 'utf8'))
22+
23+
// Create a global constant name, e.g., 'VERSION_LIBRARY_A'
24+
// Replace non-alphanumeric characters for a valid constant name
25+
const constName = name.toUpperCase().replace(/[^A-Z0-9]/g, '_')
26+
27+
versions[`__VERSION_${constName}__`] = version
28+
}
29+
}
30+
console.log(versions)
31+
return versions
32+
}
33+
34+
export const packageVersions = getPackageVersions()
35+
// Example result:
36+
// {
37+
// "__VERSION_REPO_LIBRARY_A__": "\"1.2.3\"",
38+
// "__VERSION_REPO_LIBRARY_B__": "\"4.5.6\""
39+
// }

packages/common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"author": "DesignLab",
1010
"repository": {
1111
"type": "git",
12-
"url": "https://github.com/nasa-jpl/explorer-1"
12+
"url": "https://github.com/nasa-jpl/explorer-1/tree/main/packages/common"
1313
},
1414
"prettier": "@explorer-1/prettier-config",
1515
"devDependencies": {

packages/html/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
"private": true,
44
"version": "0.0.3",
55
"type": "module",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/nasa-jpl/explorer-1/"
9+
},
610
"scripts": {
711
"dev": "vite",
812
"build": "pnpm build:fontfiles && pnpm build:vite && pnpm build:fontcss",

packages/vue/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"author": "DesignLab",
99
"repository": {
1010
"type": "git",
11-
"url": "https://github.com/nasa-jpl/explorer-1"
11+
"url": "https://github.com/nasa-jpl/explorer-1/tree/main/packages/vue"
1212
},
1313
"type": "module",
1414
"scripts": {

packages/vue/src/docs/introduction.docs.mdx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,31 @@ This website uses [Storybook](https://storybook.js.org/) to display our document
4040
---
4141

4242
Maintained by [DesignLab](https://www.behance.net/JPL-DesignLab)
43+
44+
<div>
45+
<table
46+
class="w-auto text-left"
47+
style={{ width: 'unset' }}
48+
>
49+
<thead>
50+
<tr class="text-left">
51+
<th>Package</th>
52+
<th>Version</th>
53+
</tr>
54+
</thead>
55+
<tbody>
56+
<tr>
57+
<td>[@explorer-1/common](https://www.npmjs.com/package/@explorer-1/common)</td>
58+
<td>
59+
<code>{packageVersions.__VERSION__EXPLORER_1_COMMON__}</code>
60+
</td>
61+
</tr>
62+
<tr>
63+
<td>[@explorer-1/vue](https://www.npmjs.com/package/@explorer-1/vue)</td>
64+
<td>
65+
<code>{packageVersions.__VERSION__EXPLORER_1_VUE__}</code>
66+
</td>
67+
</tr>
68+
</tbody>
69+
</table>
70+
</div>

0 commit comments

Comments
 (0)