@cedarjs/cli 5.0.0-canary.2542 → 5.0.0-canary.2543

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.
@@ -19,7 +19,6 @@ import { generate } from "@cedarjs/internal/dist/generate/generate";
19
19
  import { generateGqlormArtifacts } from "@cedarjs/internal/dist/generate/gqlormSchema";
20
20
  import { loadAndValidateSdls } from "@cedarjs/internal/dist/validateSchema";
21
21
  import { detectPrerenderRoutes } from "@cedarjs/prerender/detection";
22
- import {} from "@cedarjs/project-config";
23
22
  import { timedTelemetry } from "@cedarjs/telemetry";
24
23
  import { buildCedarApp } from "@cedarjs/vite/build";
25
24
  import { buildUDApiServer } from "@cedarjs/vite/buildUDApiServer";
@@ -99,12 +98,9 @@ const handler = async ({
99
98
  const prismaSchemaExists = fs.existsSync(cedarPaths.api.prismaConfig);
100
99
  const prerenderRoutes = prerender && workspace.includes("web") ? detectPrerenderRoutes() : [];
101
100
  const shouldGeneratePrismaClient = prisma && prismaSchemaExists && (workspace.includes("api") || prerenderRoutes.length > 0);
102
- const packageJsonPath = path.join(cedarPaths.base, "package.json");
103
- const packageJson = JSON.parse(
104
- fs.readFileSync(packageJsonPath, "utf8")
101
+ const nonApiWebWorkspaces = workspace.filter(
102
+ (w) => w !== "api" && w !== "web"
105
103
  );
106
- const packageJsonWorkspaces = packageJson.workspaces;
107
- const nonApiWebWorkspaces = Array.isArray(packageJsonWorkspaces) && packageJsonWorkspaces.length > 2 ? workspace.filter((w) => w !== "api" && w !== "web") : [];
108
104
  const gqlFeaturesTaskTitle = `Generating types needed for ${[
109
105
  useFragments && "GraphQL Fragments",
110
106
  useTrustedDocuments && "Trusted Documents"
@@ -10,7 +10,9 @@ import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
10
10
  import { workspacePackageSpecifier } from "@cedarjs/cli-helpers/packageManager";
11
11
  import { runScript, runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
12
12
  import { installPackages } from "@cedarjs/cli-helpers/packageManager/packages";
13
+ import { addWorkspaceDir } from "@cedarjs/cli-helpers/packageManager/workspaces";
13
14
  import { getConfig } from "@cedarjs/project-config";
15
+ import { getPackageManager } from "@cedarjs/project-config/packageManager";
14
16
  import { errorTelemetry } from "@cedarjs/telemetry";
15
17
  import { getPaths, writeFilesTask } from "../../../lib/index.js";
16
18
  import { prepareForRollback } from "../../../lib/rollback.js";
@@ -283,34 +285,12 @@ const handler = async ({ name, force, ...rest }) => {
283
285
  },
284
286
  {
285
287
  title: "Updating workspace config...",
286
- task: async (ctx, task) => {
287
- const rootPackageJsonPath = path.join(getPaths().base, "package.json");
288
- const packageJson = JSON.parse(
289
- await fs.promises.readFile(rootPackageJsonPath, "utf8")
290
- );
291
- if (!Array.isArray(packageJson.workspaces)) {
292
- throw new Error(
293
- "Invalid workspace config in " + rootPackageJsonPath
294
- );
295
- }
288
+ task: (ctx, task) => {
289
+ const pm = getPackageManager();
296
290
  const packagePath = `packages/${ctx.nameVariants.folderName}`;
297
- const hasWildcardPackagesWorkspace = packageJson.workspaces.includes("packages/*");
298
- const hasNamedPackagesWorkspace = packageJson.workspaces.includes(packagePath);
299
- const hasOtherNamedPackages = packageJson.workspaces.some(
300
- (workspace) => workspace.startsWith("packages/") && workspace !== packagePath
301
- );
302
- if (hasWildcardPackagesWorkspace || hasNamedPackagesWorkspace) {
291
+ const result = addWorkspaceDir(getPaths().base, packagePath, pm);
292
+ if (result === "exists") {
303
293
  task.skip("Workspaces already configured");
304
- } else {
305
- if (hasOtherNamedPackages) {
306
- packageJson.workspaces.push(packagePath);
307
- } else {
308
- packageJson.workspaces.push("packages/*");
309
- }
310
- await fs.promises.writeFile(
311
- rootPackageJsonPath,
312
- JSON.stringify(packageJson, null, 2)
313
- );
314
294
  }
315
295
  }
316
296
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/cli",
3
- "version": "5.0.0-canary.2542",
3
+ "version": "5.0.0-canary.2543",
4
4
  "description": "The CedarJS Command Line",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,17 +33,17 @@
33
33
  "dependencies": {
34
34
  "@babel/parser": "7.29.7",
35
35
  "@babel/preset-typescript": "7.29.7",
36
- "@cedarjs/api-server": "5.0.0-canary.2542",
37
- "@cedarjs/cli-helpers": "5.0.0-canary.2542",
38
- "@cedarjs/fastify-web": "5.0.0-canary.2542",
39
- "@cedarjs/internal": "5.0.0-canary.2542",
40
- "@cedarjs/prerender": "5.0.0-canary.2542",
41
- "@cedarjs/project-config": "5.0.0-canary.2542",
42
- "@cedarjs/structure": "5.0.0-canary.2542",
43
- "@cedarjs/telemetry": "5.0.0-canary.2542",
44
- "@cedarjs/utils": "5.0.0-canary.2542",
45
- "@cedarjs/vite": "5.0.0-canary.2542",
46
- "@cedarjs/web-server": "5.0.0-canary.2542",
36
+ "@cedarjs/api-server": "5.0.0-canary.2543",
37
+ "@cedarjs/cli-helpers": "5.0.0-canary.2543",
38
+ "@cedarjs/fastify-web": "5.0.0-canary.2543",
39
+ "@cedarjs/internal": "5.0.0-canary.2543",
40
+ "@cedarjs/prerender": "5.0.0-canary.2543",
41
+ "@cedarjs/project-config": "5.0.0-canary.2543",
42
+ "@cedarjs/structure": "5.0.0-canary.2543",
43
+ "@cedarjs/telemetry": "5.0.0-canary.2543",
44
+ "@cedarjs/utils": "5.0.0-canary.2543",
45
+ "@cedarjs/vite": "5.0.0-canary.2543",
46
+ "@cedarjs/web-server": "5.0.0-canary.2543",
47
47
  "@listr2/prompt-adapter-enquirer": "4.2.1",
48
48
  "@opentelemetry/api": "1.9.1",
49
49
  "@opentelemetry/core": "1.30.1",