Skip to content

Commit

Permalink
fix(nx-dev): make sure all redirects are used (#18214)
Browse files Browse the repository at this point in the history
  • Loading branch information
meeroslav authored Jul 20, 2023
1 parent a988be0 commit c4e5685
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 196 deletions.
200 changes: 9 additions & 191 deletions nx-dev/nx-dev/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,199 +28,17 @@ module.exports = withNx({
async redirects() {
const rules = [];

// Tutorials
for (let s of Object.keys(redirectRules.tutorialRedirects)) {
rules.push({
source: s,
destination: redirectRules.tutorialRedirects[s],
permanent: true,
});
// Apply all the redirects from the redirect-rules.js file
for (const section of Object.keys(redirectRules)) {
for (const source of Object.keys(redirectRules[section])) {
rules.push({
source: source,
destination: redirectRules[section][source],
permanent: true,
});
}
}

// Storybook
rules.push({
source: '/(l|latest)/(r|react)/storybook/overview',
destination: '/storybook/overview-react',
permanent: true,
});
rules.push({
source: '/(l|latest)/(a|angular)/storybook/overview',
destination: '/storybook/overview-angular',
permanent: true,
});
rules.push({
source: '/(l|latest)/(a|angular|r|react)/storybook/executors',
destination: '/storybook/executors-storybook',
permanent: true,
});

// Nx Console
rules.push({
source: '/nx-console',
destination: '/using-nx/console',
permanent: true,
});
rules.push({
source: '/(l|latest)/(a|angular)/storybook/overview',
destination: '/storybook/overview-angular',
permanent: true,
});
rules.push({
source: '/(l|latest)/(a|angular|r|react)/storybook/executors',
destination: '/storybook/executors-storybook',
permanent: true,
});

// Customs
for (let s of Object.keys(redirectRules.guideUrls)) {
rules.push({
source: `/l/n${s}`,
destination: redirectRules.guideUrls[s],
permanent: true,
});

rules.push({
source: `/l/r${s}`,
destination: redirectRules.guideUrls[s],
permanent: true,
});

rules.push({
source: `/l/a${s}`,
destination: redirectRules.guideUrls[s],
permanent: true,
});

rules.push({
source: s,
destination: redirectRules.guideUrls[s],
permanent: true,
});
}

// Generic, catch-all
rules.push({
source: '/(l|latest|p|previous)/(a|angular|r|react|n|node)/:path*',
destination: '/:path*',
permanent: true,
});
rules.push({
source: '/(l|latest|p|previous)/:path*',
destination: '/:path*',
permanent: true,
});
rules.push({
source: '/(a|angular|r|react|n|node)/:path*',
destination: '/:path*',
permanent: true,
});

// Schemas (generators & executors)
for (let s of Object.keys(redirectRules.schemaUrls)) {
rules.push({
source: s,
destination: redirectRules.schemaUrls[s],
permanent: true,
});
}

// Api overviews
for (let s of Object.keys(redirectRules.overviewUrls)) {
rules.push({
source: s,
destination: redirectRules.overviewUrls[s],
permanent: true,
});
}
// Api CLI redirection to Nx
for (let s of Object.keys(redirectRules.cliUrls)) {
rules.push({
source: s,
destination: redirectRules.cliUrls[s],
permanent: true,
});
}

// Diataxis doc restructure
for (let s of Object.keys(redirectRules.diataxis)) {
rules.push({
source: s,
destination: redirectRules.diataxis[s],
permanent: true,
});
}
// Recipes doc restructure
for (let s of Object.keys(redirectRules.recipesUrls)) {
rules.push({
source: s,
destination: redirectRules.recipesUrls[s],
permanent: true,
});
}
// Nx Cloud restructure
for (let s of Object.keys(redirectRules.nxCloudUrls)) {
rules.push({
source: s,
destination: redirectRules.nxCloudUrls[s],
permanent: true,
});
}
// Tutorials / Getting started
for (let s of Object.keys(redirectRules.conceptUrls)) {
rules.push({
source: s,
destination: redirectRules.conceptUrls[s],
permanent: true,
});
}

// Packages Indexes
for (let s of Object.keys(redirectRules.packagesIndexes)) {
rules.push({
source: s,
destination: redirectRules.packagesIndexes[s],
permanent: true,
});
}
// Packages Documents
for (let s of Object.keys(redirectRules.packagesDocuments)) {
rules.push({
source: s,
destination: redirectRules.packagesDocuments[s],
permanent: true,
});
}
// Plugins Documents
for (let s of Object.keys(redirectRules.pluginUrls)) {
rules.push({
source: s,
destination: redirectRules.pluginUrls[s],
permanent: true,
});
}
// References
for (let s of Object.keys(redirectRules.referenceUrls)) {
rules.push({
source: s,
destination: redirectRules.referenceUrls[s],
permanent: true,
});
}
// Nesting 5min tutorials in Getting Started
for (let s of Object.keys(redirectRules.nested5minuteTutorialUrls)) {
rules.push({
source: s,
destination: redirectRules.nested5minuteTutorialUrls[s],
permanent: true,
});
}

// Docs
rules.push({
source: '/docs',
destination: '/getting-started/intro',
permanent: true,
});
return rules;
},
});
27 changes: 22 additions & 5 deletions nx-dev/nx-dev/redirect-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,15 +488,15 @@ const standaloneTutorialRedirects = {
'/getting-started/tutorials/react-standalone-tutorial',
'/shared/react-standalone-tutorial/5-summary':
'/getting-started/tutorials/react-standalone-tutorial',
'shared/angular-standalone-tutorial/1-code-generation':
'/shared/angular-standalone-tutorial/1-code-generation':
'/getting-started/tutorials/angular-standalone-tutorial',
'shared/angular-standalone-tutorial/2-project-graph':
'/shared/angular-standalone-tutorial/2-project-graph':
'/getting-started/tutorials/angular-standalone-tutorial',
'shared/angular-standalone-tutorial/3-task-running':
'/shared/angular-standalone-tutorial/3-task-running':
'/getting-started/tutorials/angular-standalone-tutorial',
'shared/angular-standalone-tutorial/4-task-pipelines':
'/shared/angular-standalone-tutorial/4-task-pipelines':
'/getting-started/tutorials/angular-standalone-tutorial',
'shared/angular-standalone-tutorial/5-summary':
'/shared/angular-standalone-tutorial/5-summary':
'/getting-started/tutorials/angular-standalone-tutorial',
};

Expand Down Expand Up @@ -677,6 +677,22 @@ const referenceUrls = {
'/changelog': '/reference/changelog',
};

const missingAndCatchAllRedirects = {
// missing
'/docs': '/getting-started/intro',
// catch all
'/(l|latest|p|previous)/(a|angular|r|react|n|node)/:path*': '/:path*',
'/(l|latest|p|previous)/:path*': '/:path*',
'/(a|angular|r|react|n|node)/:path*': '/:path*',
// Storybook
'/(l|latest)/(r|react)/storybook/overview': '/storybook/overview-react',
'/(l|latest)/(a|angular)/storybook/overview': '/storybook/overview-angular',
'/(l|latest)/(a|angular|r|react)/storybook/executors':
'/storybook/executors-storybook',
// Nx Console
'/nx-console': '/using-nx/console',
};

/**
* Public export API
*/
Expand All @@ -696,4 +712,5 @@ module.exports = {
nested5minuteTutorialUrls,
pluginUrls,
referenceUrls,
missingAndCatchAllRedirects,
};

1 comment on commit c4e5685

@vercel
Copy link

@vercel vercel bot commented on c4e5685 Jul 20, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx-dev-nrwl.vercel.app
nx.dev

Please sign in to comment.