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

feat(astro): experimental astro:env #10974

Merged
merged 46 commits into from
Jun 5, 2024
Merged

feat(astro): experimental astro:env #10974

merged 46 commits into from
Jun 5, 2024

Conversation

florian-lefebvre
Copy link
Member

@florian-lefebvre florian-lefebvre commented May 8, 2024

Changes

What to review

I'm mostly looking for reviews on

Also worth reviewing the adapters pr to see how it will be used for real.

Testing

Unit and integration tests

Docs

Added changeset and config reference

florian-lefebvre and others added 7 commits April 22, 2024 10:49
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
Copy link

changeset-bot bot commented May 8, 2024

🦋 Changeset detected

Latest commit: e8cbc6c

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) docs pr A PR that includes documentation for review labels May 8, 2024
@github-actions github-actions bot added the semver: minor Change triggers a `minor` release label May 8, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

@florian-lefebvre florian-lefebvre marked this pull request as ready for review May 8, 2024 15:29
@florian-lefebvre
Copy link
Member Author

!preview astro-env

Copy link
Contributor

github-actions bot commented May 8, 2024

Snapshots have been released for the following packages:

  • @astrojs/mdx@experimental--astro-env
  • astro@experimental--astro-env
  • @astrojs/vercel@experimental--astro-env
  • @astrojs/preact@experimental--astro-env
  • @astrojs/solid-js@experimental--astro-env
  • @astrojs/react@experimental--astro-env
  • @astrojs/vue@experimental--astro-env
  • @astrojs/db@experimental--astro-env
  • @astrojs/web-vitals@experimental--astro-env
Publish Log
🦋  warn ===============================IMPORTANT!===============================
🦋  warn Packages will be released under the experimental--astro-env tag
🦋  warn ----------------------------------------------------------------------
🦋  info npm info astro
🦋  info npm info @astrojs/prism
🦋  info npm info @astrojs/rss
🦋  info npm info create-astro
🦋  info npm info @astrojs/db
🦋  info npm info @astrojs/alpinejs
🦋  info npm info @astrojs/lit
🦋  info npm info @astrojs/markdoc
🦋  info npm info @astrojs/mdx
🦋  info npm info @astrojs/node
🦋  info npm info @astrojs/partytown
🦋  info npm info @astrojs/preact
🦋  info npm info @astrojs/react
🦋  info npm info @astrojs/sitemap
🦋  info npm info @astrojs/solid-js
🦋  info npm info @astrojs/svelte
🦋  info npm info @astrojs/tailwind
🦋  info npm info @astrojs/vercel
🦋  info npm info @astrojs/vue
🦋  info npm info @astrojs/web-vitals
🦋  info npm info @astrojs/internal-helpers
🦋  info npm info @astrojs/markdown-remark
🦋  info npm info @astrojs/telemetry
🦋  info npm info @astrojs/underscore-redirects
🦋  info npm info @astrojs/upgrade
🦋  info astro is being published because our local version (0.0.0-astro-env-20240508155554) has not been published on npm
🦋  warn @astrojs/prism is not being published because version 3.1.0 is already published on npm
🦋  warn @astrojs/rss is not being published because version 4.0.5 is already published on npm
🦋  warn create-astro is not being published because version 4.8.0 is already published on npm
🦋  info @astrojs/db is being published because our local version (0.0.0-astro-env-20240508155554) has not been published on npm
🦋  warn @astrojs/alpinejs is not being published because version 0.4.0 is already published on npm
🦋  warn @astrojs/lit is not being published because version 4.0.1 is already published on npm
🦋  warn @astrojs/markdoc is not being published because version 0.11.0 is already published on npm
🦋  info @astrojs/mdx is being published because our local version (0.0.0-astro-env-20240508155554) has not been published on npm
🦋  warn @astrojs/node is not being published because version 8.2.5 is already published on npm
🦋  warn @astrojs/partytown is not being published because version 2.1.0 is already published on npm
🦋  info @astrojs/preact is being published because our local version (0.0.0-astro-env-20240508155554) has not been published on npm
🦋  info @astrojs/react is being published because our local version (0.0.0-astro-env-20240508155554) has not been published on npm
🦋  warn @astrojs/sitemap is not being published because version 3.1.4 is already published on npm
🦋  info @astrojs/solid-js is being published because our local version (0.0.0-astro-env-20240508155554) has not been published on npm
🦋  warn @astrojs/svelte is not being published because version 5.4.0 is already published on npm
🦋  warn @astrojs/tailwind is not being published because version 5.1.0 is already published on npm
🦋  info @astrojs/vercel is being published because our local version (0.0.0-astro-env-20240508155554) has not been published on npm
🦋  info @astrojs/vue is being published because our local version (0.0.0-astro-env-20240508155554) has not been published on npm
🦋  info @astrojs/web-vitals is being published because our local version (0.0.0-astro-env-20240508155554) has not been published on npm
🦋  warn @astrojs/internal-helpers is not being published because version 0.4.0 is already published on npm
🦋  warn @astrojs/markdown-remark is not being published because version 5.1.0 is already published on npm
🦋  warn @astrojs/telemetry is not being published because version 3.1.0 is already published on npm
🦋  warn @astrojs/underscore-redirects is not being published because version 0.3.3 is already published on npm
🦋  warn @astrojs/upgrade is not being published because version 0.3.0 is already published on npm
🦋  info Publishing "astro" at "0.0.0-astro-env-20240508155554"
🦋  info Publishing "@astrojs/db" at "0.0.0-astro-env-20240508155554"
🦋  info Publishing "@astrojs/mdx" at "0.0.0-astro-env-20240508155554"
🦋  info Publishing "@astrojs/preact" at "0.0.0-astro-env-20240508155554"
🦋  info Publishing "@astrojs/react" at "0.0.0-astro-env-20240508155554"
🦋  info Publishing "@astrojs/solid-js" at "0.0.0-astro-env-20240508155554"
🦋  info Publishing "@astrojs/vercel" at "0.0.0-astro-env-20240508155554"
🦋  info Publishing "@astrojs/vue" at "0.0.0-astro-env-20240508155554"
🦋  info Publishing "@astrojs/web-vitals" at "0.0.0-astro-env-20240508155554"
🦋  success packages published successfully:
🦋  astro@0.0.0-astro-env-20240508155554
🦋  @astrojs/db@0.0.0-astro-env-20240508155554
🦋  @astrojs/mdx@0.0.0-astro-env-20240508155554
🦋  @astrojs/preact@0.0.0-astro-env-20240508155554
🦋  @astrojs/react@0.0.0-astro-env-20240508155554
🦋  @astrojs/solid-js@0.0.0-astro-env-20240508155554
🦋  @astrojs/vercel@0.0.0-astro-env-20240508155554
🦋  @astrojs/vue@0.0.0-astro-env-20240508155554
🦋  @astrojs/web-vitals@0.0.0-astro-env-20240508155554
🦋  Creating git tags...
🦋  New tag:  astro@0.0.0-astro-env-20240508155554
🦋  New tag:  @astrojs/db@0.0.0-astro-env-20240508155554
🦋  New tag:  @astrojs/mdx@0.0.0-astro-env-20240508155554
🦋  New tag:  @astrojs/preact@0.0.0-astro-env-20240508155554
🦋  New tag:  @astrojs/react@0.0.0-astro-env-20240508155554
🦋  New tag:  @astrojs/solid-js@0.0.0-astro-env-20240508155554
🦋  New tag:  @astrojs/vercel@0.0.0-astro-env-20240508155554
🦋  New tag:  @astrojs/vue@0.0.0-astro-env-20240508155554
🦋  New tag:  @astrojs/web-vitals@0.0.0-astro-env-20240508155554
Build Log

> root@0.0.0 build /home/runner/work/astro/astro
> turbo run build --filter=astro --filter=create-astro --filter="@astrojs/*" --filter="@benchmark/*"

• Packages in scope: @astrojs/alpinejs, @astrojs/cloudflare, @astrojs/db, @astrojs/internal-helpers, @astrojs/lit, @astrojs/markdoc, @astrojs/markdown-remark, @astrojs/mdx, @astrojs/netlify, @astrojs/node, @astrojs/partytown, @astrojs/preact, @astrojs/prism, @astrojs/react, @astrojs/rss, @astrojs/sitemap, @astrojs/solid-js, @astrojs/svelte, @astrojs/tailwind, @astrojs/telemetry, @astrojs/underscore-redirects, @astrojs/upgrade, @astrojs/vercel, @astrojs/vue, @astrojs/web-vitals, @benchmark/timer, astro, create-astro
• Running build in 28 packages
• Remote caching enabled
::group::@astrojs/internal-helpers:build
cache miss, executing d55e26d511bd87f7

> @astrojs/internal-helpers@0.4.0 build /home/runner/work/astro/astro/packages/internal-helpers
> astro-scripts build "src/**/*.ts" && tsc -p tsconfig.json

::endgroup::
::group::@astrojs/prism:build
cache miss, executing 39aec3651543094b

> @astrojs/prism@3.1.0 build /home/runner/work/astro/astro/packages/astro-prism
> astro-scripts build "src/**/*.ts" && tsc -p ./tsconfig.json

::endgroup::
::group::@astrojs/upgrade:build
cache miss, executing 3b79f1f7f4e5cd23

> @astrojs/upgrade@0.3.0 build /home/runner/work/astro/astro/packages/upgrade
> astro-scripts build "src/index.ts" --bundle && tsc

::endgroup::
::group::@astrojs/telemetry:build
cache miss, executing ebe95990efee66ca

> @astrojs/telemetry@3.1.0 build /home/runner/work/astro/astro/packages/telemetry
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::create-astro:build
cache miss, executing 5bcf708208b01778

> create-astro@4.8.0 build /home/runner/work/astro/astro/packages/create-astro
> astro-scripts build "src/index.ts" --bundle && tsc

::endgroup::
::group::@astrojs/markdown-remark:build
cache miss, executing 956160e8764f8a14

> @astrojs/markdown-remark@5.1.0 build /home/runner/work/astro/astro/packages/markdown/remark
> astro-scripts build "src/**/*.ts" && tsc -p tsconfig.json

::endgroup::
::group::astro:build
cache miss, executing a55c71722094501c

> astro@0.0.0-astro-env-20240508155554 build /home/runner/work/astro/astro/packages/astro
> pnpm run prebuild && astro-scripts build "src/**/*.{ts,js}" && tsc && pnpm run postbuild


> astro@0.0.0-astro-env-20240508155554 prebuild /home/runner/work/astro/astro/packages/astro
> astro-scripts prebuild --to-string "src/runtime/server/astro-island.ts" "src/runtime/client/{idle,load,media,only,visible}.ts"


> astro@0.0.0-astro-env-20240508155554 postbuild /home/runner/work/astro/astro/packages/astro
> astro-scripts copy "src/**/*.astro" && astro-scripts copy "src/**/*.wasm"

::endgroup::
::group::@benchmark/timer:build
cache miss, executing 481b3722ddf7d2ee

> @benchmark/timer@0.0.0 build /home/runner/work/astro/astro/benchmark/packages/timer
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/underscore-redirects:build
cache miss, executing 919cc01bab3536b1

> @astrojs/underscore-redirects@0.3.3 build /home/runner/work/astro/astro/packages/underscore-redirects
> astro-scripts build "src/**/*.ts" && tsc -p tsconfig.json

::endgroup::
::group::@astrojs/lit:build
cache miss, executing 88c5df56e6156b8b

> @astrojs/lit@4.0.1 build /home/runner/work/astro/astro/packages/integrations/lit
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/partytown:build
cache miss, executing c286d6912ec21c29

> @astrojs/partytown@2.1.0 build /home/runner/work/astro/astro/packages/integrations/partytown
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/node:build
cache miss, executing f31235b1807cce47

> @astrojs/node@8.2.5 build /home/runner/work/astro/astro/packages/integrations/node
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/mdx:build
cache miss, executing 1319def00ca83cb4

> @astrojs/mdx@0.0.0-astro-env-20240508155554 build /home/runner/work/astro/astro/packages/integrations/mdx
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/preact:build
cache miss, executing a8ff2441a6950981

> @astrojs/preact@0.0.0-astro-env-20240508155554 build /home/runner/work/astro/astro/packages/integrations/preact
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/vercel:build
cache miss, executing c560cf35c46fb457

> @astrojs/vercel@0.0.0-astro-env-20240508155554 build /home/runner/work/astro/astro/packages/integrations/vercel
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/svelte:build
cache miss, executing d9db1495090aec5b

> @astrojs/svelte@5.4.0 build /home/runner/work/astro/astro/packages/integrations/svelte
> astro-scripts build "src/index.ts" && astro-scripts build "src/editor.cts" --force-cjs --no-clean-dist && tsc

::endgroup::
::group::@astrojs/vue:build
cache miss, executing 7e0e3f5130d2dd04

> @astrojs/vue@0.0.0-astro-env-20240508155554 build /home/runner/work/astro/astro/packages/integrations/vue
> astro-scripts build "src/index.ts" && astro-scripts build "src/editor.cts" --force-cjs --no-clean-dist && tsc

::endgroup::
::group::@astrojs/rss:build
cache miss, executing cd01a0c1bdff27c8

> @astrojs/rss@4.0.5 build /home/runner/work/astro/astro/packages/astro-rss
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/react:build
cache miss, executing 63d4f0d727b39c7f

> @astrojs/react@0.0.0-astro-env-20240508155554 build /home/runner/work/astro/astro/packages/integrations/react
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/alpinejs:build
cache miss, executing 06b14d8253370afb

> @astrojs/alpinejs@0.4.0 build /home/runner/work/astro/astro/packages/integrations/alpinejs
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/markdoc:build
cache miss, executing ad4e64370f22a62c

> @astrojs/markdoc@0.11.0 build /home/runner/work/astro/astro/packages/integrations/markdoc
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/solid-js:build
cache miss, executing dbc8dfac980f3fdd

> @astrojs/solid-js@0.0.0-astro-env-20240508155554 build /home/runner/work/astro/astro/packages/integrations/solid
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/tailwind:build
cache miss, executing 6475067caa999068

> @astrojs/tailwind@5.1.0 build /home/runner/work/astro/astro/packages/integrations/tailwind
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/sitemap:build
cache miss, executing 5d3ce9528d241cd2

> @astrojs/sitemap@3.1.4 build /home/runner/work/astro/astro/packages/integrations/sitemap
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::
::group::@astrojs/db:build
cache miss, executing 001227c6b2637cc1

> @astrojs/db@0.0.0-astro-env-20240508155554 build /home/runner/work/astro/astro/packages/db
> astro-scripts build "src/**/*.ts" && tsc && pnpm types:virtual


> @astrojs/db@0.0.0-astro-env-20240508155554 types:virtual /home/runner/work/astro/astro/packages/db
> tsc -p ./tsconfig.virtual.json

::endgroup::
::group::@astrojs/web-vitals:build
cache miss, executing ee27fdd413303afc

> @astrojs/web-vitals@0.0.0-astro-env-20240508155554 build /home/runner/work/astro/astro/packages/integrations/web-vitals
> astro-scripts build "src/**/*.ts" && tsc

::endgroup::

 Tasks:    26 successful, 26 total
Cached:    0 cached, 26 total
  Time:    55.726s 

packages/astro/src/env/vite-plugin-env-virtual-mod.ts Outdated Show resolved Hide resolved
packages/astro/src/env/vite-plugin-env-virtual-mod.ts Outdated Show resolved Hide resolved
.changeset/poor-berries-occur.md Show resolved Hide resolved
packages/astro/src/core/app/index.ts Outdated Show resolved Hide resolved
packages/astro/src/runtime/server/astro-env.ts Outdated Show resolved Hide resolved
@florian-lefebvre
Copy link
Member Author

!preview astro-env

florian-lefebvre and others added 2 commits June 3, 2024 17:20
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
florian-lefebvre and others added 2 commits June 4, 2024 08:47
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

Approving for docs with this one update! 🥳

Nooooo wait! We have to do the changeset to match now! UNAPPROVE! lol

packages/astro/src/@types/astro.ts Outdated Show resolved Hide resolved
@@ -382,7 +382,7 @@ async function writeContentFiles({
let contentTypesStr = '';
let dataTypesStr = '';

const collectionSchemasDir = new URL('./collections/', contentPaths.cacheDir);
const collectionSchemasDir = new URL('./collections/', settings.dotAstroDir);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these things changed?

Copy link
Member Author

Choose a reason for hiding this comment

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

All codegen related features need to create files in .astro. The path is not content specific so I extracted it to settings to be able to reuse it across content, actions and env. It will also be helpful when I get to work on withastro/roadmap#887

const numberValidator: ValueValidator = (input) => {
const num = parseFloat(input ?? '');
return {
valid: !isNaN(num),
Copy link
Contributor

Choose a reason for hiding this comment

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

Tested this implementation quite a bit and couldn't find a bug, good job!

Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

Some small nits, but this looks great!

packages/astro/src/env/vite-plugin-env.ts Outdated Show resolved Hide resolved
packages/astro/src/runtime/server/astro-env.ts Outdated Show resolved Hide resolved
packages/astro/test/test-adapter.js Outdated Show resolved Hide resolved
packages/astro/src/env/types.ts Outdated Show resolved Hide resolved
packages/astro/src/env/validators.ts Outdated Show resolved Hide resolved
packages/astro/src/runtime/server/astro-env.ts Outdated Show resolved Hide resolved
Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

Made one small suggestion, but I think otherwise the docs pass my checks! Nicely done @florian-lefebvre !

If either @ematipico or @matthewp has suggestions or comments for the technical accuracy/completeness of the docs, feel free to comment! But from an editing standpoint, I'm happy with what's there!

Copy link
Member

@dreyfus92 dreyfus92 left a comment

Choose a reason for hiding this comment

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

Looking great so far! 😁

@ematipico ematipico merged commit 2668ef9 into main Jun 5, 2024
14 checks passed
@ematipico ematipico deleted the feat/astro-env branch June 5, 2024 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs pr A PR that includes documentation for review pkg: astro Related to the core `astro` package (scope) semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants