File tree Expand file tree Collapse file tree 6 files changed +78
-2
lines changed
common-storybook/src/plugins Expand file tree Collapse file tree 6 files changed +78
-2
lines changed Original file line number Diff line number Diff line change 11import { defineConfig } from 'vite'
22import 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
57export default defineConfig ( {
8+ define : {
9+ ...packageVersions
10+ } ,
611 plugins : [
712 vue ( )
813 // TODO: Doesn't work
Original file line number Diff line number Diff line change 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 - Z 0 - 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+ // }
Original file line number Diff line number Diff line change 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" : {
Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff line change 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" : {
Original file line number Diff line number Diff line change @@ -40,3 +40,31 @@ This website uses [Storybook](https://storybook.js.org/) to display our document
4040---
4141
4242Maintained 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 >
You can’t perform that action at this time.
0 commit comments