A personal website for self-learning interest.
In your terminal, run the following command:
For local execution:
npm run dev
For test with watch
npm run test
For test coverage
npm run test:ci
For linting and prettifier check
npm run lint
For package analysing, do not check-in as it contains alot of security issues.
npm install @next/bundle-analyzer
# Wrap next.config.js with withBundleAnalyzer({...})
npx next build
For BackstopJS - regression for view and approve website design UI Note: that browser executes differently in OS, especially font's. In this case use the approved generated backstopJS snapshots directly from the OS/Docker container.
npm run backstop:test //To test
npm run backstop:approve // Approve the new website ok
- Install Vercel Cli, with
npm i -g vercel
- Pull all the environment into local with
vercel env pull .env.local
. This wil create an environment straight for testing. Incase, there are reset of environment to setup in Vercel, refer to .env file.
Project is tied closely with github.
To create a new change, do a pull request.
- Create a branch for changes in lowercase with no space.
- Commit the changes in the branch.
- Push.
- In github, create a pull request.
- Check that the workflow is executed without error.
- Merge the commit.
In case there is a need to generate a new backstopJS approved page.
- In github, go to Actions tab.
- Select 'Create Approved Snapshot By File'.
- Click on 'Run workflow'
- Enter the vercel/public website to generate an approved website domain. Without http, e.g. https://www.walcron.com to www.walcron.com
- Manually enter a valid branch it can checkout, e.g. develop.
Updating backstopJS snapshot.
--By pull request
- Download the artifacts generated in "Summary" of the latest build. Replace generated snapshot in backstopdata/bitmaps_test//!failed_.png
- replace into bitmaps_reference.
--By action
- Download the artifacts generated in latest requested workflow. Replace generated snapshot in backstop_data/bitmaps_reference/*
- replace into bitmaps_reference.
--Auto approval (Recommended)
- Get the latest pipeline no from snapshotcheck.sh output from previous failed Validation workflow.
- OR view latest running script in github's Actions tab for Validation workflow.
- Execute the command below and it will auto-approve and rerun Validation workflow again.
echo ${running no# +1} > backstopjs.approve
git add backstopjs.approve
git push
Note: Add create PAT, personal profile -> Developer Settings -> Fine Grain Token -> Actions(R)/Commit Statues(RW)/Contents(RW)/Metadata(R)
- Project deployment works differently as there is NO hosting page. Means navigating to the page e.g. https://zelda-auth-react-walcoorperation.vercel.app/ will deal with NO Page found.
- All hosted microservice must be access via the js script, as in https:///walcron-zelda-auth-react.js
- Create a Github PAT (classic), with only read:packages access.
- Login locally into github NPM repo with the PAT.
npm login --scope=@yoonghan --auth-type=legacy --registry=https://npm.pkg.github.com/
- Copy in ~/.npmrc into vercel's variable NPM_RC. Basically the varible will contain:
//npm.pkg.github.com/:_authToken=...
@yoonghan:registry=https://npm.pkg.github.com/
- For accessing private repo, please allow Profile -> Settings -> Personal Access Token (classic), open read:packages (basically th esame as vercel deployment). For more info refer: https://docs.github.com/en/packages/working-with-a-github-packages-registry. Add as Github secret in Settings->Secrets And variable and add NPM_TOKEN key. NOTE: In merge NODE_AUTH_TOKEN is used instead.
- Workflow requires
- registry-url in checkout action,
- NODE_AUTH_TOKEN env. If the workflow is callable, use "secrets: inherit", else secret cannot be shown. To test print with
echo ${#NODE_AUTH_TOKEN}
and should return some integer values.
- NextJS on vercel re-uses .next build cache. This sometimes creates an issue, e.g. a page that was once deployed as AMP will forever be recognized as AMP until the cache is cleared.
- To build without previous build cache; click redeploy button from Vercel dashboard (a menu from the 3 vertical dots) and uncheck "Build with previous build cache".
NextJS for static generation ouput: "export"
in next.config.js
, requires all pages to have removed "use server"
. Generally all pages that requires /api call needs to be removed as well, hence need to figure out how to relink these site directly to walcron.
- To regenerate new Wasm from webassembly, run the command below:
- The scripts include a custom .gitignore.
npm run rust:generate
npm run rust:test //test rust running on browser