-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat(core): add template support to create-nx-workspace #33468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
View your CI Pipeline Execution ↗ for commit 37eb6d5
☁️ Nx Cloud last updated this comment at |
🐳 We have a release for that!This PR has a release associated with it. You can try it out using this command: npx [email protected] my-workspaceOr just copy this version and use it in your own command: 0.0.0-pr-33468-86c294c
To request a new release for this pull request, mention someone from the Nx team or the |
🐳 We have a release for that!This PR has a release associated with it. You can try it out using this command: npx [email protected] my-workspaceOr just copy this version and use it in your own command: 0.0.0-pr-33468-6e447bb
To request a new release for this pull request, mention someone from the Nx team or the |
🐳 We have a release for that!This PR has a release associated with it. You can try it out using this command: npx [email protected] my-workspaceOr just copy this version and use it in your own command: 0.0.0-pr-33468-7ba12c8
To request a new release for this pull request, mention someone from the Nx team or the |
🐳 We have a release for that!This PR has a release associated with it. You can try it out using this command: npx [email protected] my-workspaceOr just copy this version and use it in your own command: 0.0.0-pr-33468-10b2f55
To request a new release for this pull request, mention someone from the Nx team or the |
🐳 We have a release for that!This PR has a release associated with it. You can try it out using this command: npx [email protected] my-workspaceOr just copy this version and use it in your own command: 0.0.0-pr-33468-1bdc579
To request a new release for this pull request, mention someone from the Nx team or the |
Previously, the template flow was not calling connectToNxCloud generator, which meant no Cloud workspace was created and nxCloudId remained undefined. This caused readNxCloudToken to return undefined. Now the template flow calls connectToNxCloud after installing dependencies, which creates the Cloud workspace and writes nxCloudId to nx.json. The preset flow is unchanged and continues to call connectToNxCloud through the workspace generator as before. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Adds a 'Custom' option to the starter selection that redirects to the original preset-based flow, giving users access to more configuration options including: - Framework selection - Test runner choices - Bundler options - And other preset-specific configurations When 'Custom' is selected, the flow returns 'skip' which triggers the preset flow instead of the template flow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❌ The fix was rejected
These changes fix the workspace creation failures by making the directory parameter optional in the recordStat function. The issue occurred because recordStat was being called before the workspace directory existed, causing require.resolve to fail when trying to locate the nx package from a non-existent path. By making the parameter optional and only using it when provided, we allow the early telemetry call to succeed while preserving full functionality for the post-creation call.
We could not verify this fix.
Suggested Fix changes
diff --git a/packages/create-nx-workspace/bin/create-nx-workspace.ts b/packages/create-nx-workspace/bin/create-nx-workspace.ts
index 8fcca86287..cbbbdc240f 100644
--- a/packages/create-nx-workspace/bin/create-nx-workspace.ts
+++ b/packages/create-nx-workspace/bin/create-nx-workspace.ts
@@ -347,7 +347,6 @@ async function normalizeArgsMiddleware(
command: 'create-nx-workspace',
meta: [startPrefix],
useCloud: argv.nxCloud !== 'skip',
- directory,
});
if (template !== 'custom') {
diff --git a/packages/create-nx-workspace/src/utils/nx/ab-testing.ts b/packages/create-nx-workspace/src/utils/nx/ab-testing.ts
index 3405c9729a..63c36ef4fa 100644
--- a/packages/create-nx-workspace/src/utils/nx/ab-testing.ts
+++ b/packages/create-nx-workspace/src/utils/nx/ab-testing.ts
@@ -261,7 +261,7 @@ export async function recordStat(opts: {
nxVersion: string;
useCloud: boolean;
meta: string[];
- directory: string;
+ directory?: string;
}) {
try {
if (!shouldRecordStats()) {
@@ -271,9 +271,11 @@ export async function recordStat(opts: {
// nx-ignore-next-line
const { getCloudUrl } = require(require.resolve(
'nx/src/nx-cloud/utilities/get-cloud-options',
- {
- paths: [opts.directory],
- }
+ opts.directory
+ ? {
+ paths: [opts.directory],
+ }
+ : undefined
// nx-ignore-next-line
)) as typeof import('nx/src/nx-cloud/utilities/get-cloud-options');
View interactive diff ↗
This fix was rejected by Jack Hsu
🎓 Learn more about Self-Healing CI on nx.dev
This PR simplifies the CNW process so we only prompt for a starter (TS, NPM Packages, React, Angular) and we clone a full example to showcase Nx monorepo for the given starter. This speeds up CNW drastically and allows users to get the workspace in 5-10 seconds vs 1-3 minutes. Users can choose `Custom` to fall back to the previous prompts, which will ask framework, unit test runner, e2e runner, etc. --------- Co-authored-by: Claude <[email protected]>
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
This PR simplifies the CNW process so we only prompt for a starter (TS, NPM Packages, React, Angular) and we clone a full example to showcase Nx monorepo for the given starter. This speeds up CNW drastically and allows users to get the workspace in 5-10 seconds vs 1-3 minutes.
Users can choose
Customto fall back to the previous prompts, which will ask framework, unit test runner, e2e runner, etc.