-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nextjs): Add support for create nodes for nextjs (nrwl#20193)
- Loading branch information
1 parent
7ffc328
commit b8d24e6
Showing
20 changed files
with
618 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { | ||
runCLI, | ||
cleanupProject, | ||
newProject, | ||
uniq, | ||
updateJson, | ||
runE2ETests, | ||
directoryExists, | ||
readJson, | ||
} from 'e2e/utils'; | ||
|
||
describe('@nx/next/plugin', () => { | ||
let project: string; | ||
let appName: string; | ||
|
||
beforeAll(() => { | ||
project = newProject(); | ||
appName = uniq('app'); | ||
runCLI( | ||
`generate @nx/next:app ${appName} --project-name-and-root-format=as-provided --no-interactive`, | ||
{ env: { NX_PCV3: 'true' } } | ||
); | ||
|
||
// update package.json to add next as a script | ||
updateJson(`package.json`, (json) => { | ||
json.scripts = json.scripts || {}; | ||
json.scripts.next = 'next'; | ||
return json; | ||
}); | ||
}); | ||
|
||
afterAll(() => cleanupProject()); | ||
|
||
it('nx.json should contain plugin configuration', () => { | ||
const nxJson = readJson('nx.json'); | ||
const nextPlugin = nxJson.plugins.find( | ||
(plugin) => plugin.plugin === '@nx/next/plugin' | ||
); | ||
expect(nextPlugin).toBeDefined(); | ||
expect(nextPlugin.options).toBeDefined(); | ||
expect(nextPlugin.options.buildTargetName).toEqual('build'); | ||
expect(nextPlugin.options.startTargetName).toEqual('start'); | ||
expect(nextPlugin.options.devTargetName).toEqual('dev'); | ||
}); | ||
|
||
it('should build the app', async () => { | ||
const result = runCLI(`build ${appName}`); | ||
// check build output for PCV3 artifacts (e.g. .next directory) are inside the project directory | ||
directoryExists(`${appName}/.next`); | ||
|
||
expect(result).toContain( | ||
`Successfully ran target build for project ${appName}` | ||
); | ||
}, 200_000); | ||
|
||
it('should serve the app', async () => { | ||
if (runE2ETests()) { | ||
const e2eResult = runCLI(`run ${appName}-e2e:e2e --verbose`); | ||
|
||
expect(e2eResult).toContain('All specs passed!'); | ||
} | ||
}, 500_000); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { createNodes, NextPluginOptions } from './src/plugins/plugin'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.