MCPcopy
hub / github.com/changesets/changesets / parse

Function parse

packages/config/src/index.ts:103–602  ·  view source on GitHub ↗
(json: WrittenConfig, packages: Packages)

Source from the content-addressed store, hash-verified

101};
102
103export let parse = (json: WrittenConfig, packages: Packages): Config => {
104 let messages = [];
105 let pkgNames: readonly string[] = packages.packages.map(
106 ({ packageJson }) => packageJson.name
107 );
108
109 if (
110 json.changelog !== undefined &&
111 json.changelog !== false &&
112 typeof json.changelog !== "string" &&
113 !(
114 isArray(json.changelog) &&
115 json.changelog.length === 2 &&
116 typeof json.changelog[0] === "string"
117 )
118 ) {
119 messages.push(
120 `The \`changelog\` option is set as ${JSON.stringify(
121 json.changelog,
122 null,
123 2
124 )} when the only valid values are undefined, false, a module path(e.g. "@changesets/cli/changelog" or "./some-module") or a tuple with a module path and config for the changelog generator(e.g. ["@changesets/cli/changelog", { someOption: true }])`
125 );
126 }
127
128 let normalizedAccess: WrittenConfig["access"] = json.access;
129 if ((json.access as string) === "private") {
130 normalizedAccess = "restricted";
131 warn(
132 'The `access` option is set as "private", but this is actually not a valid value - the correct form is "restricted".'
133 );
134 }
135 if (
136 normalizedAccess !== undefined &&
137 normalizedAccess !== "restricted" &&
138 normalizedAccess !== "public"
139 ) {
140 messages.push(
141 `The \`access\` option is set as ${JSON.stringify(
142 normalizedAccess,
143 null,
144 2
145 )} when the only valid values are undefined, "public" or "restricted"`
146 );
147 }
148
149 if (
150 json.commit !== undefined &&
151 typeof json.commit !== "boolean" &&
152 typeof json.commit !== "string" &&
153 !(
154 isArray(json.commit) &&
155 json.commit.length === 2 &&
156 typeof json.commit[0] === "string"
157 )
158 ) {
159 messages.push(
160 `The \`commit\` option is set as ${JSON.stringify(

Callers 7

getChangesetFunction · 0.85
index.test.tsFile · 0.85
index.test.tsFile · 0.85
getChangesetsFunction · 0.85
index.test.tsFile · 0.85
readFunction · 0.85
index.tsFile · 0.85

Calls 9

warnFunction · 0.90
getDependentsGraphFunction · 0.90
shouldSkipPackageFunction · 0.90
isArrayFunction · 0.85
getUnmatchedPatternsFunction · 0.85
flattenFunction · 0.85

Tested by 1

getChangesetFunction · 0.68