Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate changing link to documentation using git tag from RGBDS #69

Merged
merged 3 commits into from
Feb 15, 2025

Conversation

SelvinPL
Copy link
Contributor

Closes #66

For testing remeber to clear the changes(undo the patches) to binjgb and rgbds.
You may use this commands from rgbds-live root directory:

cd rgbds && git clean -fd && git reset --hard && cd ../binjgb && git clean -fd && git reset --hard && cd ..

Then you are ready to execute ./build.sh
In other case build may fail as build is trying to apply patches every time

Copy link
Member

@avivace avivace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks @SelvinPL !

build.sh Outdated
@@ -4,6 +4,10 @@ set -eu

test -d binjgb/out || ./build-binjgb.sh
test -f rgbds/rgbasm.wasm || ./build-rgbds.sh

#store rgbds version tag for use in vite build
export VITE_RGBDS_VERSION=$(git --git-dir=rgbds/.git -c safe.directory='*' describe --tags --always)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we setting this here in "build.sh"? This basically makes it mandatory to rebuild everything just to export this value, which could be done afterwards (or just anytime before npm run build/ serve... Isn't there a way to make this part of the npm run command?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't find a way to do this via command line ... I'm not good with node and npm run set environment variables search results aren't helpful

also doesn't
export VITE_RGBDS_VERSION=$(git --git-dir=rgbds/.git -c safe.directory='*' describe --tags --always) would export to the current console env variable VITE_RGBDS_VERSION
if so then every consecutive npm run build will use this value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe, maybe build.sh may create .env file with this variable ... This should work, but I need to check this (and because RL stuff it need to wait 'till weekend)

Copy link
Member

@avivace avivace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I've quickly checked, and it should be enough to add
VITE_RGBDS_VERSION=$(git --git-dir=rgbds/.git -c safe.directory='*' describe --tags --always)

in the npm script. So, in package.json, something like:

"scripts": {
"dev": "VITE_RGBDS_VERSION=$(git --git-dir=rgbds/.git -c safe.directory='*' describe --tags --always) && vite",

should work

@SelvinPL
Copy link
Contributor Author

So, I've quickly checked, and it should be enough to add VITE_RGBDS_VERSION=$(git --git-dir=rgbds/.git -c safe.directory='*' describe --tags --always)

in the npm script. So, in package.json, something like:

"scripts": { "dev": "VITE_RGBDS_VERSION=$(git --git-dir=rgbds/.git -c safe.directory='*' describe --tags --always) && vite",

should work

or maybe changing vite.config.js (as you need to change build not only dev and this should works for both)

import { defineConfig, loadEnv } from 'vite';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import { execSync } from 'node:child_process';

export default defineConfig(({ command, mode, isSsrBuild, isPreview }) => {
	//tested on both win and linux execute git command and store result in process.env.VITE_RGBDS_VERSION
	process.env.VITE_RGBDS_VERSION = execSync("git --git-dir=rgbds/.git -c safe.directory='*' describe --tags --always").toString("utf8");
	return {
  base: '/rgbds-live/',
  build: {
    target: ['chrome109', 'safari15.6', 'firefox102'],
    outDir: 'www',
    chunkSizeWarningLimit: 1000,
  },
  resolve: {
    alias: {
      ace: 'ace-builds/src-noconflict/',
    },
  },
  plugins: [
    viteStaticCopy({
      targets: [
        {
          src: './node_modules/ace-builds/src-noconflict/**',
          dest: 'assets/ace',
        },
      ],
    }),
  ],
}});

@SelvinPL
Copy link
Contributor Author

SelvinPL commented Feb 13, 2025

build vs dev see Deploy to GitHub Pages is using build
dev starts a local test server

@avivace
Copy link
Member

avivace commented Feb 14, 2025

Cool, I like this last option @SelvinPL

@avivace avivace merged commit 3312e35 into gbdev:master Feb 15, 2025
1 check passed
@SelvinPL SelvinPL deleted the feature/auto_doc_link branch March 4, 2025 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automate the documentation link change
2 participants