nx-factory-cli 2.1.20 → 2.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import path from "path";
2
2
  import { writeFile, ensureDir } from "../../../files.js";
3
+ import { scopedPackageName } from "../../../config.js";
3
4
  export const workosScaffolder = {
4
5
  label: "WorkOS AuthKit",
5
6
  dependencies: {
@@ -13,21 +14,22 @@ export const workosScaffolder = {
13
14
  react: "^18 || ^19",
14
15
  "react-dom": "^18 || ^19",
15
16
  },
16
- async scaffold(pkgDir, _opts) {
17
+ async scaffold(pkgDir, opts) {
18
+ const authPackageName = scopedPackageName(opts.scope, "auth");
17
19
  await ensureDir(path.join(pkgDir, "."));
18
20
  // ── index.ts ──────────────────────────────────────────────────────────
19
21
  await writeFile(path.join(pkgDir, "index.ts"), `/**
20
- * @workspace/auth — WorkOS AuthKit latest setup.
22
+ * ${authPackageName} — WorkOS AuthKit latest setup.
21
23
  *
22
24
  * Prefer sub-path imports:
23
- * import { getUser, withAuth } from "@workspace/auth/server"
24
- * import { useAuth } from "@workspace/auth/client"
25
- * import { authMiddleware } from "@workspace/auth/next"
25
+ * import { getUser, withAuth } from "${authPackageName}/server"
26
+ * import { useAuth } from "${authPackageName}/client"
27
+ * import { authMiddleware } from "${authPackageName}/next"
26
28
  */
27
29
  export * from "./server.js";
28
30
  export * from "./client.js";
29
31
  `);
30
- await writeFile(path.join(pkgDir, "next.ts"), `/** Next.js adapter for @workspace/auth (WorkOS). */
32
+ await writeFile(path.join(pkgDir, "next.ts"), `/** Next.js adapter for ${authPackageName} (WorkOS). */
31
33
  export {
32
34
  authMiddleware,
33
35
  buildMiddleware,
@@ -45,18 +47,18 @@ export {
45
47
  * - handleAuth() — still the catch-all callback handler
46
48
  *
47
49
  * @example Server Component (manual check)
48
- * import { getUser } from "@workspace/auth/server";
50
+ * import { getUser } from "${authPackageName}/server";
49
51
  * const { user } = await getUser();
50
52
  * if (!user) redirect("/sign-in");
51
53
  *
52
54
  * @example Server Component (HOC — auto-redirects)
53
- * import { withAuth } from "@workspace/auth/server";
55
+ * import { withAuth } from "${authPackageName}/server";
54
56
  * export default withAuth(async function Page({ user }) {
55
57
  * return <h1>Hello {user.firstName}</h1>;
56
58
  * });
57
59
  *
58
60
  * @example Sign-in redirect
59
- * import { getSignInUrl } from "@workspace/auth/server";
61
+ * import { getSignInUrl } from "${authPackageName}/server";
60
62
  * redirect(await getSignInUrl());
61
63
  */
62
64
 
@@ -82,7 +84,7 @@ export type {
82
84
  * Low-level WorkOS Node SDK.
83
85
  * Use for organization management, directory sync, audit logs, etc.
84
86
  *
85
- * import { workos } from "@workspace/auth/server";
87
+ * import { workos } from "${authPackageName}/server";
86
88
  * const orgs = await workos.organizations.listOrganizations();
87
89
  */
88
90
  import WorkOS from "@workos-inc/node";
@@ -102,14 +104,14 @@ export const workosClientId = process.env.WORKOS_CLIENT_ID!;
102
104
  * The AuthKitProvider is required at the root of apps that use useAuth().
103
105
  *
104
106
  * @example Root layout
105
- * import { AuthKitProvider } from "@workspace/auth/client";
107
+ * import { AuthKitProvider } from "${authPackageName}/client";
106
108
  * export default function Layout({ children }) {
107
109
  * return <AuthKitProvider>{children}</AuthKitProvider>;
108
110
  * }
109
111
  *
110
112
  * @example Any client component
111
113
  * "use client";
112
- * import { useAuth } from "@workspace/auth/client";
114
+ * import { useAuth } from "${authPackageName}/client";
113
115
  * const { user, loading, getAccessToken } = useAuth();
114
116
  */
115
117
  "use client";
@@ -127,7 +129,7 @@ export {
127
129
  * Quick start — copy into apps/<your-app>/middleware.ts:
128
130
  *
129
131
  * import type { NextRequest } from "next/server";
130
- * import { authMiddleware, middlewareConfig } from "@workspace/auth/middleware";
132
+ * import { authMiddleware, middlewareConfig } from "${authPackageName}/middleware";
131
133
  *
132
134
  * export default function middleware(request: NextRequest) {
133
135
  * return authMiddleware(request);
@@ -137,9 +139,9 @@ export {
137
139
  *
138
140
  * Custom public paths:
139
141
  *
140
- * import { buildMiddleware } from "@workspace/auth/middleware";
142
+ * import { buildMiddleware } from "${authPackageName}/middleware";
141
143
  * export default buildMiddleware({ unauthenticatedPaths: ["/", "/about"] });
142
- * export { middlewareConfig as config } from "@workspace/auth/middleware";
144
+ * export { middlewareConfig as config } from "${authPackageName}/middleware";
143
145
  */
144
146
  import { authkitMiddleware } from "@workos-inc/authkit-nextjs";
145
147
  import type { AuthkitMiddlewareOptions } from "@workos-inc/authkit-nextjs";
@@ -204,7 +206,7 @@ WORKOS_COOKIE_PASSWORD=REPLACE_WITH_RANDOM_32_CHAR_STRING
204
206
  NEXT_PUBLIC_APP_URL=http://localhost:3000
205
207
  `);
206
208
  // ── README.md ─────────────────────────────────────────────────────────────
207
- await writeFile(path.join(pkgDir, "README.md"), `# @workspace/auth — WorkOS AuthKit v1+
209
+ await writeFile(path.join(pkgDir, "README.md"), `# ${authPackageName} — WorkOS AuthKit v1+
208
210
 
209
211
  Shared authentication powered by [WorkOS AuthKit](https://workos.com/docs/user-management) — enterprise SSO, SCIM, MFA, magic auth, and a hosted sign-in UI.
210
212
 
@@ -225,20 +227,20 @@ Fill in from your [WorkOS Dashboard](https://dashboard.workos.com):
225
227
 
226
228
  ### 2. Add the dependency
227
229
  \`\`\`json
228
- { "dependencies": { "@workspace/auth": "workspace:*" } }
230
+ { "dependencies": { "${authPackageName}": "workspace:*" } }
229
231
  \`\`\`
230
232
 
231
233
  ### 3. Add the callback route
232
234
  \`\`\`ts
233
235
  // apps/<your-app>/app/callback/route.ts
234
- export { handleAuth as GET } from "@workspace/auth/server";
236
+ export { handleAuth as GET } from "${authPackageName}/server";
235
237
  \`\`\`
236
238
 
237
239
  ### 4. Add the middleware
238
240
  \`\`\`ts
239
241
  // apps/<your-app>/middleware.ts
240
242
  import type { NextRequest } from "next/server";
241
- import { authMiddleware, middlewareConfig } from "@workspace/auth/next";
243
+ import { authMiddleware, middlewareConfig } from "${authPackageName}/next";
242
244
 
243
245
  export default function middleware(request: NextRequest) {
244
246
  return authMiddleware(request);
@@ -250,7 +252,7 @@ export const config = middlewareConfig;
250
252
  ### 5. Wrap your layout with AuthKitProvider
251
253
  \`\`\`tsx
252
254
  // apps/<your-app>/app/layout.tsx
253
- import { AuthKitProvider } from "@workspace/auth/client";
255
+ import { AuthKitProvider } from "${authPackageName}/client";
254
256
  export default function Layout({ children }) {
255
257
  return <AuthKitProvider>{children}</AuthKitProvider>;
256
258
  }
@@ -259,22 +261,22 @@ export default function Layout({ children }) {
259
261
  ### 6. Use in your pages
260
262
  \`\`\`tsx
261
263
  // Server component — HOC (auto-redirects if not signed in)
262
- import { withAuth } from "@workspace/auth/server";
264
+ import { withAuth } from "${authPackageName}/server";
263
265
  export default withAuth(async function Page({ user }) {
264
266
  return <h1>Hello, {user.firstName}</h1>;
265
267
  });
266
268
 
267
269
  // Server component — manual
268
- import { getUser } from "@workspace/auth/server";
270
+ import { getUser } from "${authPackageName}/server";
269
271
  const { user } = await getUser();
270
272
 
271
273
  // Client component
272
274
  "use client";
273
- import { useAuth } from "@workspace/auth/client";
275
+ import { useAuth } from "${authPackageName}/client";
274
276
  const { user, loading } = useAuth();
275
277
 
276
278
  // Sign-in redirect page
277
- import { getSignInUrl } from "@workspace/auth/server";
279
+ import { getSignInUrl } from "${authPackageName}/server";
278
280
  import { redirect } from "next/navigation";
279
281
  export default async function SignIn() { redirect(await getSignInUrl()); }
280
282
  \`\`\`
@@ -283,10 +285,10 @@ export default async function SignIn() { redirect(await getSignInUrl()); }
283
285
 
284
286
  | Sub-path | Key exports |
285
287
  |---|---|
286
- | \`@workspace/auth/server\` | \`getUser()\`, \`withAuth()\`, \`getSignInUrl()\`, \`handleAuth\`, \`workos\`, \`signOut()\` |
287
- | \`@workspace/auth/client\` | \`useAuth\`, \`AuthKitProvider\` |
288
- | \`@workspace/auth/middleware\` | \`authMiddleware\`, \`buildMiddleware()\`, \`middlewareConfig\` |
289
- | \`@workspace/auth/next\` | \`authMiddleware\`, \`buildMiddleware()\`, \`middlewareConfig\` |
288
+ | \`${authPackageName}/server\` | \`getUser()\`, \`withAuth()\`, \`getSignInUrl()\`, \`handleAuth\`, \`workos\`, \`signOut()\` |
289
+ | \`${authPackageName}/client\` | \`useAuth\`, \`AuthKitProvider\` |
290
+ | \`${authPackageName}/middleware\` | \`authMiddleware\`, \`buildMiddleware()\`, \`middlewareConfig\` |
291
+ | \`${authPackageName}/next\` | \`authMiddleware\`, \`buildMiddleware()\`, \`middlewareConfig\` |
290
292
  `);
291
293
  },
292
294
  };
@@ -1 +1 @@
1
- {"version":3,"file":"workos.js","sourceRoot":"","sources":["../../../../src/setups/auth/systems/workos.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGzD,MAAM,CAAC,MAAM,gBAAgB,GAA0B;IACrD,KAAK,EAAE,gBAAgB;IAEvB,YAAY,EAAE;QACZ,4BAA4B,EAAE,QAAQ;QACtC,kBAAkB,EAAY,QAAQ;KACvC;IAED,eAAe,EAAE;QACf,cAAc,EAAE,SAAS;KAC1B;IAED,gBAAgB,EAAE;QAChB,KAAK,EAAQ,YAAY;QACzB,WAAW,EAAE,YAAY;KAC1B;IAED,KAAK,CAAC,QAAQ,CAAC,MAAc,EAAE,KAAyB;QACtD,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;QAExC,yEAAyE;QACzE,MAAM,SAAS,CACb,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,EAC7B;;;;;;;;;;CAUL,CACI,CAAC;QAEF,MAAM,SAAS,CACb,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,EAC5B;;;;;;CAML,CACI,CAAC;QAEF,yEAAyE;QACzE,+DAA+D;QAC/D,MAAM,SAAS,CACb,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAA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E,CAAC;QAEF,4EAA4E;QAC5E,MAAM,SAAS,CACd,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,EACjC;;;;;;;;;;;;;;CAcF,CACE,CAAC;QAEF,6EAA6E;QAC7E,MAAM,SAAS,CACd,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,EAC9B,KAAK,eAAe;;;;;;;;;;;;;;;;;;;;;uBAqBA,eAAe;;;;;;qCAMD,eAAe;;;;;;;oDAOA,eAAe;;;;;;;;;;;;mCAYhC,eAAe;;;;;;;;;4BAStB,eAAe;;;;;;2BAMhB,eAAe;;;;;2BAKf,eAAe;;;;gCAIV,eAAe;;;;;;;;;MASzC,eAAe;MACf,eAAe;MACf,eAAe;MACf,eAAe;CACpB,CACE,CAAC;IACH,CAAC;CACD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nx-factory-cli",
3
- "version": "2.1.20",
3
+ "version": "2.1.22",
4
4
  "description": "CLI to initialize and manage an Nx monorepo with shared shadcn/ui components + Tailwind v4",
5
5
  "type": "module",
6
6
  "bin": {