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

[ci] release (beta) #12072

Merged
merged 1 commit into from
Oct 1, 2024
Merged

[ci] release (beta) #12072

merged 1 commit into from
Oct 1, 2024

Conversation

astrobot-houston
Copy link
Contributor

@astrobot-houston astrobot-houston commented Sep 25, 2024

This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to next, this PR will be updated.

⚠️⚠️⚠️⚠️⚠️⚠️

next is currently in pre mode so this branch has prereleases rather than normal releases. If you want to exit prereleases, run changeset pre exit on next.

⚠️⚠️⚠️⚠️⚠️⚠️

Releases

[email protected]

Minor Changes

  • #12047 21b5e80 Thanks @rgodha24! - Adds a new optional parser property to the built-in file() loader for content collections to support additional file types such as toml and csv.

    The file() loader now accepts a second argument that defines a parser function. This allows you to specify a custom parser (e.g. toml.parse or csv-parse) to create a collection from a file's contents. The file() loader will automatically detect and parse JSON and YAML files (based on their file extension) with no need for a parser.

    This works with any type of custom file formats including csv and toml. The following example defines a content collection dogs using a .toml file.

    [[dogs]]
    id = "..."
    age = "..."
    
    [[dogs]]
    id = "..."
    age = "..."

    After importing TOML's parser, you can load the dogs collection into your project by passing both a file path and parser to the file() loader.

    import { defineCollection } from "astro:content"
    import { file } from "astro/loaders"
    import { parse as parseToml } from "toml"
    
    const dogs = defineCollection({
      loader: file("src/data/dogs.toml", { parser: (text) => parseToml(text).dogs }),
      schema: /* ... */
    })
    
    // it also works with CSVs!
    import { parse as parseCsv } from "csv-parse/sync";
    
    const cats = defineCollection({
      loader: file("src/data/cats.csv", { parser: (text) => parseCsv(text, { columns: true, skipEmptyLines: true })})
    });

    The parser argument also allows you to load a single collection from a nested JSON document. For example, this JSON file contains multiple collections:

    { "dogs": [{}], "cats": [{}] }

    You can seperate these collections by passing a custom parser to the file() loader like so:

    const dogs = defineCollection({
      loader: file('src/data/pets.json', { parser: (text) => JSON.parse(text).dogs }),
    });
    const cats = defineCollection({
      loader: file('src/data/pets.json', { parser: (text) => JSON.parse(text).cats }),
    });

    And it continues to work with maps of id to data

    bubbles:
      breed: 'Goldfish'
      age: 2
    finn:
      breed: 'Betta'
      age: 1
    const fish = defineCollection({
      loader: file('src/data/fish.yaml'),
      schema: z.object({ breed: z.string(), age: z.number() }),
    });
  • #12071 61d248e Thanks @Princesseuh! - astro add no longer automatically sets output: 'server'. Since the default value of output now allows for server-rendered pages, it no longer makes sense to default to full server builds when you add an adapter

  • #11963 0a1036e Thanks @florian-lefebvre! - Adds a new createCodegenDir() function to the astro:config:setup hook in the Integrations API

    In 4.14, we introduced the injectTypes utility on the astro:config:done hook. It can create .d.ts files and make their types available to user's projects automatically. Under the hood, it creates a file in <root>/.astro/integrations/<normalized_integration_name>.

    While the .astro directory has always been the preferred place to write code generated files, it has also been prone to mistakes. For example, you can write a .astro/types.d.ts file, breaking Astro types. Or you can create a file that overrides a file created by another integration.

    In this release, <root>/.astro/integrations/<normalized_integration_name> can now be retrieved in the astro:config:setup hook by calling createCodegenDir(). It allows you to have a dedicated folder, avoiding conflicts with another integration or Astro itself. This directory is created by calling this function so it's safe to write files to it directly:

    import { writeFileSync } from 'node:fs';
    
    const integration = {
      name: 'my-integration',
      hooks: {
        'astro:config:setup': ({ createCodegenDir }) => {
          const codegenDir = createCodegenDir();
          writeFileSync(new URL('cache.json', codegenDir), '{}', 'utf-8');
        },
      },
    };
  • #12081 8679954 Thanks @florian-lefebvre! - Removes the experimental contentCollectionsCache introduced in 3.5.0.

    Astro Content Layer API independently solves some of the caching and performance issues with legacy content collections that this strategy attempted to address. This feature has been replaced with continued work on improvements to the content layer. If you were using this experimental feature, you must now remove the flag from your Astro config as it no longer exists:

    export default defineConfig({
        experimental: {
    -        contentCollectionsCache: true
        }
    })

    The cacheManifest boolean argument is no longer passed to the astro:build:done integration hook:

    const integration = {
        name: "my-integration",
        hooks: {
            "astro:build:done": ({
    -            cacheManifest,
                logger
            }) => {}
        }
    }

Patch Changes

@astrojs/[email protected]

Patch Changes

@astrojs/[email protected]

Patch Changes

@astrojs/[email protected]

Patch Changes

@astrojs/[email protected]

Patch Changes

@astrojs/[email protected]

Patch Changes

@github-actions github-actions bot added pkg: example Related to an example package (scope) pkg: astro Related to the core `astro` package (scope) labels Sep 25, 2024
@github-actions github-actions bot force-pushed the changeset-release/next branch 8 times, most recently from 945f8ae to f1399f1 Compare October 1, 2024 12:29
@florian-lefebvre florian-lefebvre merged commit ece0344 into next Oct 1, 2024
@florian-lefebvre florian-lefebvre deleted the changeset-release/next branch October 1, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) pkg: example Related to an example package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants