[build-utils][cli] Update link to project-configuration (#9439)

The link to the documentation has changed.
It is now available under https://vercel.com/docs/concepts/projects/project-configuration

This updates:
- link generation `https://vercel.com/docs/configuration#project/*` -> `https://vercel.com/docs/concepts/projects/project-configuration#*`
-  Updates test files
- Updates static references of https://vercel.com/docs/configuration across the repo
This commit is contained in:
Felix Haus
2023-02-14 17:44:24 +01:00
committed by GitHub
parent 8f49969585
commit 1d3f2b5a62
7 changed files with 54 additions and 27 deletions

View File

@@ -11,4 +11,4 @@ Remove the `functions` config from your `now.json` or `vercel.json` to take adva
### Useful Links ### Useful Links
- [Functions Config Documentation](https://vercel.com/docs/configuration?query=functions#project/functions) - [Functions Config Documentation](https://vercel.com/docs/concepts/projects/project-configuration#functions)

View File

@@ -11,6 +11,6 @@ Migrate from using legacy `routes` to the new `rewrites`, `redirects`, and `head
### Useful Links ### Useful Links
- [Rewrites Documentation](https://vercel.com/docs/configuration?query=rewrites#project/rewrites) - [Rewrites Documentation](https://vercel.com/docs/concepts/projects/project-configuration#rewrites)
- [Redirects Documentation](https://vercel.com/docs/configuration?query=rewrites#project/redirects) - [Redirects Documentation](https://vercel.com/docs/concepts/projects/project-configuration#redirects)
- [Headers Documentation](https://vercel.com/docs/configuration?query=rewrites#project/headers) - [Headers Documentation](https://vercel.com/docs/concepts/projects/project-configuration#headers)

View File

@@ -44,7 +44,8 @@ export function getPrettyError(obj: {
message?: string; message?: string;
params: any; params: any;
}): NowBuildError { }): NowBuildError {
const docsUrl = 'https://vercel.com/docs/configuration'; const docsUrl =
'https://vercel.com/docs/concepts/projects/project-configuration';
try { try {
const { dataPath, params, message: ajvMessage } = obj; const { dataPath, params, message: ajvMessage } = obj;
const prop = getTopLevelPropertyName(dataPath); const prop = getTopLevelPropertyName(dataPath);
@@ -63,7 +64,7 @@ export function getPrettyError(obj: {
return new NowBuildError({ return new NowBuildError({
code: 'INVALID_VERCEL_CONFIG', code: 'INVALID_VERCEL_CONFIG',
message: message, message: message,
link: prop ? `${docsUrl}#project/${prop.toLowerCase()}` : docsUrl, link: prop ? `${docsUrl}#${prop.toLowerCase()}` : docsUrl,
action: 'View Documentation', action: 'View Documentation',
}); });
} catch (e) { } catch (e) {

View File

@@ -701,7 +701,7 @@ function expandBuild(files: string[], build: Builder): Builder[] {
throw new NowBuildError({ throw new NowBuildError({
code: `invalid_build_specification`, code: `invalid_build_specification`,
message: 'Field `use` is missing in build specification', message: 'Field `use` is missing in build specification',
link: 'https://vercel.com/docs/configuration#project/builds', link: 'https://vercel.com/docs/concepts/projects/project-configuration#builds',
action: 'View Documentation', action: 'View Documentation',
}); });
} }
@@ -711,7 +711,7 @@ function expandBuild(files: string[], build: Builder): Builder[] {
throw new NowBuildError({ throw new NowBuildError({
code: `invalid_build_specification`, code: `invalid_build_specification`,
message: 'A build `src` path resolves to an empty string', message: 'A build `src` path resolves to an empty string',
link: 'https://vercel.com/docs/configuration#project/builds', link: 'https://vercel.com/docs/concepts/projects/project-configuration#builds',
action: 'View Documentation', action: 'View Documentation',
}); });
} }

View File

@@ -1967,7 +1967,11 @@ test('try to create a builds deployments with wrong now.json', async t => {
'Error: Invalid now.json - should NOT have additional property `builder`. Did you mean `builds`?' 'Error: Invalid now.json - should NOT have additional property `builder`. Did you mean `builds`?'
) )
); );
t.true(stderr.includes('https://vercel.com/docs/configuration')); t.true(
stderr.includes(
'https://vercel.com/docs/concepts/projects/project-configuration'
)
);
}); });
test('try to create a builds deployments with wrong vercel.json', async t => { test('try to create a builds deployments with wrong vercel.json', async t => {
@@ -1991,7 +1995,11 @@ test('try to create a builds deployments with wrong vercel.json', async t => {
'Error: Invalid vercel.json - should NOT have additional property `fake`. Please remove it.' 'Error: Invalid vercel.json - should NOT have additional property `fake`. Please remove it.'
) )
); );
t.true(stderr.includes('https://vercel.com/docs/configuration')); t.true(
stderr.includes(
'https://vercel.com/docs/concepts/projects/project-configuration'
)
);
}); });
test('try to create a builds deployments with wrong `build.env` property', async t => { test('try to create a builds deployments with wrong `build.env` property', async t => {
@@ -2014,7 +2022,9 @@ test('try to create a builds deployments with wrong `build.env` property', async
formatOutput({ stdout, stderr }) formatOutput({ stdout, stderr })
); );
t.true( t.true(
stderr.includes('https://vercel.com/docs/configuration'), stderr.includes(
'https://vercel.com/docs/concepts/projects/project-configuration'
),
formatOutput({ stdout, stderr }) formatOutput({ stdout, stderr })
); );
}); });

View File

@@ -1080,7 +1080,7 @@ describe('build', () => {
await expect(client.stderr).toOutput( await expect(client.stderr).toOutput(
'Error: Invalid vercel.json - `rewrites[2]` should NOT have additional property `src`. Did you mean `source`?' + 'Error: Invalid vercel.json - `rewrites[2]` should NOT have additional property `src`. Did you mean `source`?' +
'\n' + '\n' +
'View Documentation: https://vercel.com/docs/configuration#project/rewrites' 'View Documentation: https://vercel.com/docs/concepts/projects/project-configuration#rewrites'
); );
const builds = await fs.readJSON(join(output, 'builds.json')); const builds = await fs.readJSON(join(output, 'builds.json'));
expect(builds.builds).toBeUndefined(); expect(builds.builds).toBeUndefined();
@@ -1091,7 +1091,7 @@ describe('build', () => {
stack: expect.stringContaining('at validateConfig'), stack: expect.stringContaining('at validateConfig'),
hideStackTrace: true, hideStackTrace: true,
code: 'INVALID_VERCEL_CONFIG', code: 'INVALID_VERCEL_CONFIG',
link: 'https://vercel.com/docs/configuration#project/rewrites', link: 'https://vercel.com/docs/concepts/projects/project-configuration#rewrites',
action: 'View Documentation', action: 'View Documentation',
}); });
const configJson = await fs.readJSON(join(output, 'config.json')); const configJson = await fs.readJSON(join(output, 'config.json'));

View File

@@ -41,7 +41,7 @@ describe('validateConfig', () => {
'Invalid vercel.json - `rewrites[0]` should NOT have additional property `src`. Did you mean `source`?' 'Invalid vercel.json - `rewrites[0]` should NOT have additional property `src`. Did you mean `source`?'
); );
expect(error!.link).toEqual( expect(error!.link).toEqual(
'https://vercel.com/docs/configuration#project/rewrites' 'https://vercel.com/docs/concepts/projects/project-configuration#rewrites'
); );
}); });
@@ -54,7 +54,7 @@ describe('validateConfig', () => {
'Invalid vercel.json - `routes[0]` should NOT have additional property `source`. Did you mean `src`?' 'Invalid vercel.json - `routes[0]` should NOT have additional property `source`. Did you mean `src`?'
); );
expect(error!.link).toEqual( expect(error!.link).toEqual(
'https://vercel.com/docs/configuration#project/routes' 'https://vercel.com/docs/concepts/projects/project-configuration#routes'
); );
}); });
@@ -67,7 +67,7 @@ describe('validateConfig', () => {
'Invalid vercel.json - `routes` should be array.' 'Invalid vercel.json - `routes` should be array.'
); );
expect(error!.link).toEqual( expect(error!.link).toEqual(
'https://vercel.com/docs/configuration#project/routes' 'https://vercel.com/docs/concepts/projects/project-configuration#routes'
); );
}); });
@@ -84,7 +84,7 @@ describe('validateConfig', () => {
'Invalid vercel.json - `redirects[0]` missing required property `source`.' 'Invalid vercel.json - `redirects[0]` missing required property `source`.'
); );
expect(error!.link).toEqual( expect(error!.link).toEqual(
'https://vercel.com/docs/configuration#project/redirects' 'https://vercel.com/docs/concepts/projects/project-configuration#redirects'
); );
}); });
@@ -97,7 +97,7 @@ describe('validateConfig', () => {
'Invalid vercel.json - `redirects[0].permanent` should be boolean.' 'Invalid vercel.json - `redirects[0].permanent` should be boolean.'
); );
expect(error!.link).toEqual( expect(error!.link).toEqual(
'https://vercel.com/docs/configuration#project/redirects' 'https://vercel.com/docs/concepts/projects/project-configuration#redirects'
); );
}); });
@@ -110,7 +110,7 @@ describe('validateConfig', () => {
'Invalid vercel.json - `cleanUrls` should be boolean.' 'Invalid vercel.json - `cleanUrls` should be boolean.'
); );
expect(error!.link).toEqual( expect(error!.link).toEqual(
'https://vercel.com/docs/configuration#project/cleanurls' 'https://vercel.com/docs/concepts/projects/project-configuration#cleanurls'
); );
}); });
@@ -123,7 +123,7 @@ describe('validateConfig', () => {
'Invalid vercel.json - `trailingSlash` should be boolean.' 'Invalid vercel.json - `trailingSlash` should be boolean.'
); );
expect(error!.link).toEqual( expect(error!.link).toEqual(
'https://vercel.com/docs/configuration#project/trailingslash' 'https://vercel.com/docs/concepts/projects/project-configuration#trailingslash'
); );
}); });
@@ -136,7 +136,7 @@ describe('validateConfig', () => {
'Invalid vercel.json - `headers[0]` should NOT have additional property `Content-Type`. Please remove it.' 'Invalid vercel.json - `headers[0]` should NOT have additional property `Content-Type`. Please remove it.'
); );
expect(error!.link).toEqual( expect(error!.link).toEqual(
'https://vercel.com/docs/configuration#project/headers' 'https://vercel.com/docs/concepts/projects/project-configuration#headers'
); );
}); });
@@ -149,7 +149,7 @@ describe('validateConfig', () => {
'Invalid vercel.json - `headers[0].source` should be string.' 'Invalid vercel.json - `headers[0].source` should be string.'
); );
expect(error!.link).toEqual( expect(error!.link).toEqual(
'https://vercel.com/docs/configuration#project/headers' 'https://vercel.com/docs/concepts/projects/project-configuration#headers'
); );
}); });
@@ -162,7 +162,7 @@ describe('validateConfig', () => {
'Invalid vercel.json - `headers[0]` should NOT have additional property `stuff`. Please remove it.' 'Invalid vercel.json - `headers[0]` should NOT have additional property `stuff`. Please remove it.'
); );
expect(error!.link).toEqual( expect(error!.link).toEqual(
'https://vercel.com/docs/configuration#project/headers' 'https://vercel.com/docs/concepts/projects/project-configuration#headers'
); );
}); });
@@ -175,7 +175,7 @@ describe('validateConfig', () => {
'Invalid vercel.json - `headers[0].headers[0]` should NOT have additional property `Content-Type`. Please remove it.' 'Invalid vercel.json - `headers[0].headers[0]` should NOT have additional property `Content-Type`. Please remove it.'
); );
expect(error!.link).toEqual( expect(error!.link).toEqual(
'https://vercel.com/docs/configuration#project/headers' 'https://vercel.com/docs/concepts/projects/project-configuration#headers'
); );
}); });
@@ -190,7 +190,7 @@ describe('validateConfig', () => {
'Invalid vercel.json - `headers[0].headers[0]` should NOT have additional property `val`. Please remove it.' 'Invalid vercel.json - `headers[0].headers[0]` should NOT have additional property `val`. Please remove it.'
); );
expect(error!.link).toEqual( expect(error!.link).toEqual(
'https://vercel.com/docs/configuration#project/headers' 'https://vercel.com/docs/concepts/projects/project-configuration#headers'
); );
}); });
@@ -205,7 +205,7 @@ describe('validateConfig', () => {
'Invalid vercel.json - `redirects` should NOT have more than 1024 items.' 'Invalid vercel.json - `redirects` should NOT have more than 1024 items.'
); );
expect(error!.link).toEqual( expect(error!.link).toEqual(
'https://vercel.com/docs/configuration#project/redirects' 'https://vercel.com/docs/concepts/projects/project-configuration#redirects'
); );
}); });
@@ -229,7 +229,23 @@ describe('validateConfig', () => {
'Invalid vercel.json - `headers[1].headers` should NOT have more than 1024 items.' 'Invalid vercel.json - `headers[1].headers` should NOT have more than 1024 items.'
); );
expect(error!.link).toEqual( expect(error!.link).toEqual(
'https://vercel.com/docs/configuration#project/headers' 'https://vercel.com/docs/concepts/projects/project-configuration#headers'
);
});
it('should error with invalid memory value', async () => {
const error = validateConfig({
functions: {
'api/test.js': {
memory: 127,
},
},
});
expect(error!.message).toEqual(
"Invalid vercel.json - `functions['api/test.js'].memory` should be equal to one of the allowed values."
);
expect(error!.link).toEqual(
'https://vercel.com/docs/concepts/projects/project-configuration#functions'
); );
}); });