@cedarjs/cli 2.7.1-next.0 → 2.8.0-rc.37

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,7 +1,7 @@
1
1
  import { Listr } from "listr2";
2
2
  import pascalcase from "pascalcase";
3
3
  import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
4
- import { pluralize } from "../../../lib/cedarPluralize.js";
4
+ import { pluralize } from "@cedarjs/utils/cedarPluralize";
5
5
  import c from "../../../lib/colors.js";
6
6
  import {
7
7
  deleteFilesTask,
@@ -1,6 +1,6 @@
1
1
  import pascalcase from "pascalcase";
2
2
  import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
3
- import { isPlural, singularize } from "../../../lib/cedarPluralize.js";
3
+ import { isPlural, singularize } from "@cedarjs/utils/cedarPluralize";
4
4
  import { nameVariants, transformTSToJS } from "../../../lib/index.js";
5
5
  import { isWordPluralizable } from "../../../lib/pluralHelpers.js";
6
6
  import { addFunctionToRollback } from "../../../lib/rollback.js";
@@ -1,6 +1,6 @@
1
1
  import { paramCase } from "change-case";
2
2
  import pascalcase from "pascalcase";
3
- import { pluralize, isPlural, isSingular } from "../../lib/cedarPluralize.js";
3
+ import { pluralize, isPlural, isSingular } from "@cedarjs/utils/cedarPluralize";
4
4
  const pathName = (path, name) => {
5
5
  let routePath = path;
6
6
  if (path && path.startsWith("{") && path.endsWith("}")) {
@@ -9,7 +9,7 @@ import pascalcase from "pascalcase";
9
9
  import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
10
10
  import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
11
11
  import { getConfig } from "@cedarjs/project-config";
12
- import { pluralize, singularize } from "../../../lib/cedarPluralize.js";
12
+ import { pluralize, singularize } from "@cedarjs/utils/cedarPluralize";
13
13
  import c from "../../../lib/colors.js";
14
14
  import {
15
15
  generateTemplate,
@@ -6,7 +6,7 @@ import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
6
6
  import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
7
7
  import { getConfig } from "@cedarjs/project-config";
8
8
  import { errorTelemetry } from "@cedarjs/telemetry";
9
- import { pluralize } from "../../../lib/cedarPluralize.js";
9
+ import { pluralize } from "@cedarjs/utils/cedarPluralize";
10
10
  import c from "../../../lib/colors.js";
11
11
  import { transformTSToJS, writeFilesTask } from "../../../lib/index.js";
12
12
  import {
@@ -1,7 +1,7 @@
1
1
  import path from "node:path";
2
2
  import camelcase from "camelcase";
3
3
  import { dbReexportsPrismaClient } from "@cedarjs/internal/dist/project";
4
- import { pluralize, singularize } from "../../../lib/cedarPluralize.js";
4
+ import { pluralize, singularize } from "@cedarjs/utils/cedarPluralize";
5
5
  import { transformTSToJS } from "../../../lib/index.js";
6
6
  import { getSchema, verifyModelName } from "../../../lib/schemaHelpers.js";
7
7
  import { relationsForModel } from "../helpers.js";
@@ -117,8 +117,12 @@ const addLiveQueryListenerToGraphqlHandler = ({ force }) => {
117
117
  };
118
118
  }
119
119
  if (!hasImport) {
120
+ const loggerImportIndex = contentLines.findIndex(
121
+ (line) => /import { logger } from ['"]src\/lib\/logger['"]/.test(line)
122
+ );
123
+ const insertIndex = loggerImportIndex >= 0 ? loggerImportIndex : lastImportIndex + 1;
120
124
  contentLines.splice(
121
- lastImportIndex + 1,
125
+ insertIndex,
122
126
  0,
123
127
  "import { startLiveQueryListener } from 'src/lib/liveQueriesListener'"
124
128
  );
@@ -128,8 +132,11 @@ const addLiveQueryListenerToGraphqlHandler = ({ force }) => {
128
132
  contentLines.splice(
129
133
  handlerIndexAfterImport,
130
134
  0,
131
- "",
132
- "void startLiveQueryListener()"
135
+ "// Fire-and-forget: we intentionally don't await this so it doesn't block the",
136
+ "// GraphQL handler from being registered. The listener doesn't need to be ready",
137
+ "// before the first request is handled.",
138
+ "void startLiveQueryListener()",
139
+ ""
133
140
  );
134
141
  }
135
142
  fs.writeFileSync(graphqlHandlerPath, contentLines.join("\n"));
@@ -259,8 +266,8 @@ const handler = async ({ force }) => {
259
266
  Apply the migration to activate Postgres notifications:
260
267
  ${c.highlight("\n\xA0\xA0yarn cedar prisma migrate dev\n")}
261
268
 
262
- Then run the API server and use @live queries with invalidation keys
263
- based on your GraphQL types and fields.
269
+ You're then ready to use @live queries to get real-time updates as
270
+ soon as something in your database changes.
264
271
  `;
265
272
  }
266
273
  }
@@ -1,6 +1,7 @@
1
1
  import { Client } from 'pg'
2
2
 
3
3
  import { liveQueryStore } from '@cedarjs/realtime'
4
+ import { pluralize } from '@cedarjs/utils/cedarPluralize'
4
5
 
5
6
  import { logger } from 'src/lib/logger'
6
7
 
@@ -18,10 +19,14 @@ interface GetKeysToInvalidateArgs {
18
19
  }
19
20
 
20
21
  function getKeysToInvalidate({ table, recordId }: GetKeysToInvalidateArgs) {
22
+ // Using `toLowerCase()` rather than `toLocaleLowerCase()` because we want
23
+ // consistent casing across all locales.
24
+ const typeName = table.charAt(0).toLowerCase() + table.slice(1)
25
+
21
26
  const keys = [
22
- `Query.${table}`,
23
- `Query.${table.toLocaleLowerCase()}`,
24
- `${table}:${recordId}`
27
+ `Query.${typeName}`,
28
+ `Query.${pluralize(typeName)}`,
29
+ `${typeName}:${recordId}`,
25
30
  ]
26
31
 
27
32
  return keys
@@ -188,7 +188,7 @@ const handler = async ({
188
188
  }
189
189
  if (preUpgradeMessage) {
190
190
  console.log("");
191
- console.log(` \u{1F4E3} ${c.info("Pre-upgrade Message:")}`);
191
+ console.log(` \u{1F4E3} ${c.info("Pre-upgrade Script Messages:")}`);
192
192
  console.log(" " + preUpgradeMessage.replace(/\n/g, "\n "));
193
193
  }
194
194
  };
package/dist/lib/index.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  resolveFile as internalResolveFile,
19
19
  findUp
20
20
  } from "@cedarjs/project-config";
21
- import { pluralize, singularize } from "./cedarPluralize.js";
21
+ import { pluralize, singularize } from "@cedarjs/utils/cedarPluralize";
22
22
  import c from "./colors.js";
23
23
  import { addFileToRollback } from "./rollback.js";
24
24
  const nameVariants = (name) => {
@@ -1,5 +1,9 @@
1
1
  import prompts from "prompts";
2
- import { isSingular, isPlural, addSingularPlural } from "./cedarPluralize.js";
2
+ import {
3
+ isSingular,
4
+ isPlural,
5
+ addSingularPlural
6
+ } from "@cedarjs/utils/cedarPluralize";
3
7
  const isWordPluralizable = (word) => {
4
8
  return isPlural(word) !== isSingular(word);
5
9
  };
@@ -1,6 +1,6 @@
1
1
  import prismaInternals from "@prisma/internals";
2
2
  import { getSchemaPath } from "@cedarjs/project-config";
3
- import { singularize, isPlural } from "./cedarPluralize.js";
3
+ import { singularize, isPlural } from "@cedarjs/utils/cedarPluralize";
4
4
  import { ensureUniquePlural } from "./pluralHelpers.js";
5
5
  import { getPaths } from "./index.js";
6
6
  const { getConfig, getDMMF, getSchemaWithPath } = prismaInternals;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/cli",
3
- "version": "2.7.1-next.0+ef2bf2525",
3
+ "version": "2.8.0-rc.37",
4
4
  "description": "The CedarJS Command Line",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,16 +34,17 @@
34
34
  "@babel/parser": "7.29.0",
35
35
  "@babel/preset-typescript": "7.28.5",
36
36
  "@babel/runtime-corejs3": "7.29.0",
37
- "@cedarjs/api-server": "2.7.1-next.0+ef2bf2525",
38
- "@cedarjs/cli-helpers": "2.7.1-next.0+ef2bf2525",
39
- "@cedarjs/fastify-web": "2.7.1-next.0+ef2bf2525",
40
- "@cedarjs/internal": "2.7.1-next.0+ef2bf2525",
41
- "@cedarjs/prerender": "2.7.1-next.0+ef2bf2525",
42
- "@cedarjs/project-config": "2.7.1-next.0+ef2bf2525",
43
- "@cedarjs/structure": "2.7.1-next.0+ef2bf2525",
44
- "@cedarjs/telemetry": "2.7.1-next.0+ef2bf2525",
45
- "@cedarjs/web-server": "2.7.1-next.0+ef2bf2525",
46
- "@listr2/prompt-adapter-enquirer": "2.0.16",
37
+ "@cedarjs/api-server": "2.8.0-rc.37",
38
+ "@cedarjs/cli-helpers": "2.8.0-rc.37",
39
+ "@cedarjs/fastify-web": "2.8.0-rc.37",
40
+ "@cedarjs/internal": "2.8.0-rc.37",
41
+ "@cedarjs/prerender": "2.8.0-rc.37",
42
+ "@cedarjs/project-config": "2.8.0-rc.37",
43
+ "@cedarjs/structure": "2.8.0-rc.37",
44
+ "@cedarjs/telemetry": "2.8.0-rc.37",
45
+ "@cedarjs/utils": "2.8.0-rc.37",
46
+ "@cedarjs/web-server": "2.8.0-rc.37",
47
+ "@listr2/prompt-adapter-enquirer": "4.2.1",
47
48
  "@opentelemetry/api": "1.9.0",
48
49
  "@opentelemetry/core": "1.30.1",
49
50
  "@opentelemetry/exporter-trace-otlp-http": "0.57.2",
@@ -68,10 +69,10 @@
68
69
  "execa": "5.1.1",
69
70
  "fast-glob": "3.3.3",
70
71
  "humanize-string": "2.1.0",
71
- "jscodeshift": "17.0.0",
72
+ "jscodeshift": "17.3.0",
72
73
  "jsonc-parser": "3.3.1",
73
74
  "latest-version": "9.0.0",
74
- "listr2": "7.0.2",
75
+ "listr2": "10.2.1",
75
76
  "lodash": "4.17.23",
76
77
  "pascalcase": "1.0.0",
77
78
  "pluralize": "8.0.0",
@@ -84,7 +85,7 @@
84
85
  "semver": "7.7.4",
85
86
  "smol-toml": "1.6.0",
86
87
  "string-env-interpolation": "1.0.1",
87
- "systeminformation": "5.31.1",
88
+ "systeminformation": "5.31.2",
88
89
  "termi-link": "1.1.0",
89
90
  "title-case": "3.0.3",
90
91
  "unionfs": "4.6.0",
@@ -106,5 +107,5 @@
106
107
  "publishConfig": {
107
108
  "access": "public"
108
109
  },
109
- "gitHead": "ef2bf2525e8fbeada576b4bab5d1b4b358354ae0"
110
+ "gitHead": "e57be2b0c6a75810c0a1af5e4e935fd07d08dec8"
110
111
  }
@@ -1,56 +0,0 @@
1
- import plurals from "pluralize";
2
- const mappings = {
3
- toSingular: {},
4
- toPlural: {}
5
- };
6
- function lastWord(str) {
7
- const capitals = str.match(/[A-Z]/g);
8
- const lastIndex = str.lastIndexOf(capitals?.slice(-1)[0]);
9
- return lastIndex >= 0 ? str.slice(lastIndex) : str;
10
- }
11
- function pluralize(word) {
12
- if (mappings.toPlural[word]) {
13
- return mappings.toPlural[word];
14
- }
15
- const singular = lastWord(word);
16
- const base = word.slice(0, word.length - singular.length);
17
- if (mappings.toPlural[singular]) {
18
- return base + mappings.toPlural[singular];
19
- }
20
- return base + plurals.plural(singular);
21
- }
22
- function singularize(word) {
23
- if (mappings.toSingular[word]) {
24
- return mappings.toSingular[word];
25
- }
26
- const plural = lastWord(word);
27
- const base = word.slice(0, word.length - plural.length);
28
- if (mappings.toSingular[plural]) {
29
- return base + mappings.toSingular[plural];
30
- }
31
- return base + plurals.singular(plural);
32
- }
33
- function isPlural(word) {
34
- return plurals.isPlural(lastWord(word));
35
- }
36
- function isSingular(word) {
37
- return plurals.isSingular(lastWord(word));
38
- }
39
- function addSingularPlural(singular, plural) {
40
- const existingPlural = Object.keys(mappings.toSingular).find(
41
- (key) => mappings.toSingular[key] === singular
42
- );
43
- delete mappings.toSingular[existingPlural];
44
- delete mappings.toPlural[existingPlural];
45
- mappings.toPlural[singular] = plural;
46
- mappings.toPlural[plural] = plural;
47
- mappings.toSingular[plural] = singular;
48
- mappings.toSingular[singular] = singular;
49
- }
50
- export {
51
- addSingularPlural,
52
- isPlural,
53
- isSingular,
54
- pluralize,
55
- singularize
56
- };