Home >Web Front-end >JS Tutorial >How Changsets reads config.json internally

How Changsets reads config.json internally

Barbara Streisand
Barbara StreisandOriginal
2024-11-28 16:36:11857browse

When you initialise Changesets via the CLI using init command, this command sets up the .changeset folder. It generates a readme and a config file. The config file includes the default options, as well as comments

on what these options represent.

The default config.json generated by init command looks like below:

{
 "commit": false,
 "updateInternalDependencies": "patch",
 "linked": [],
 "access": "restricted",
 "baseBranch": "master",
 "ignore": [],
 "changelog": "@changesets/cli/changelog"
}

Read more about config.json here.

Now that we understand what a config.json is for in using Changesets, let’s look at how CLI package reads this config.json.

In the run function, this try catch block is found:

try {
 config = await read(cwd, packages);
} catch (e) {
 let oldConfigExists = await fs.pathExists(
 path.resolve(cwd, ".changeset/config.js")
 );

read function is part of another package named config.

How Changsets reads config.json internally

As you can see from the above image, fs.readJSON is used in combination with path.join that combines cwd .changesets “config.json”

How Changsets reads config.json internally

parse accepts this config.json read as its first argument and this parse function is a really long function that performs additional operations using this json and packages (second argument).

About us:

At Thinkthroo, we study large open source projects and provide architectural guides. We have developed reusable Components, built with tailwind, that you can use in your project. We offer Next.js, React and Node development services.

Book a meeting with us to discuss your project.

How Changsets reads config.json internally

References:

  1. https://github.com/changesets/changesets/blob/main/packages/cli/src/run.ts#L29

  2. https://github.com/changesets/changesets/blob/main/packages/cli/src/run.ts#L44

  3. https://github.com/changesets/changesets/blob/main/packages/config/src/index.ts#L94

  4. https://github.com/changesets/changesets/blob/main/docs/config-file-options.md

  5. https://github.com/changesets/changesets/blob/main/packages/cli/README.md

The above is the detailed content of How Changsets reads config.json internally. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn