@cedarjs/cli 4.0.0-canary.13782 → 4.0.0-canary.13784
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.
- package/dist/commands/{setup → experimental}/live-queries/liveQueries.js +5 -4
- package/dist/commands/{setup → experimental}/live-queries/liveQueriesHandler.js +67 -13
- package/dist/commands/experimental/util.js +24 -23
- package/dist/commands/experimental.js +2 -1
- package/dist/commands/setup.js +1 -2
- package/package.json +12 -12
- /package/dist/commands/{setup → experimental}/live-queries/templates/liveQueriesListener.ts.template +0 -0
- /package/dist/commands/{setup → experimental}/live-queries/templates/migration.sql.template +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
2
|
-
|
|
2
|
+
import { getEpilogue } from "../util.js";
|
|
3
|
+
const command = "setup-live-queries";
|
|
3
4
|
const description = "Setup live query invalidation with Postgres notifications";
|
|
4
5
|
function builder(yargs) {
|
|
5
|
-
yargs.option("force", {
|
|
6
|
+
return yargs.option("force", {
|
|
6
7
|
alias: "f",
|
|
7
8
|
default: false,
|
|
8
9
|
description: "Overwrite existing configuration",
|
|
@@ -12,11 +13,11 @@ function builder(yargs) {
|
|
|
12
13
|
default: false,
|
|
13
14
|
description: "Print more logs",
|
|
14
15
|
type: "boolean"
|
|
15
|
-
});
|
|
16
|
+
}).epilogue(getEpilogue(command, description));
|
|
16
17
|
}
|
|
17
18
|
async function handler(options) {
|
|
18
19
|
recordTelemetryAttributes({
|
|
19
|
-
command:
|
|
20
|
+
command: `experimental ${command}`,
|
|
20
21
|
force: options.force,
|
|
21
22
|
verbose: options.verbose
|
|
22
23
|
});
|
|
@@ -2,7 +2,11 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
4
|
import { addApiPackages, colors as c } from "@cedarjs/cli-helpers";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
getConfigPath,
|
|
7
|
+
getMigrationsPath,
|
|
8
|
+
getSchemaPath
|
|
9
|
+
} from "@cedarjs/project-config";
|
|
6
10
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
7
11
|
import { getPaths, transformTSToJS, writeFile } from "../../../lib/index.js";
|
|
8
12
|
import { isTypeScriptProject } from "../../../lib/project.js";
|
|
@@ -28,10 +32,10 @@ async function getPrismaProvider() {
|
|
|
28
32
|
let stat;
|
|
29
33
|
try {
|
|
30
34
|
stat = fs.statSync(schemaPath);
|
|
31
|
-
} catch
|
|
35
|
+
} catch {
|
|
32
36
|
stat = void 0;
|
|
33
37
|
}
|
|
34
|
-
if (stat
|
|
38
|
+
if (stat?.isDirectory()) {
|
|
35
39
|
const candidate = path.join(schemaPath, "schema.prisma");
|
|
36
40
|
if (fs.existsSync(candidate)) {
|
|
37
41
|
schemaPath = candidate;
|
|
@@ -44,7 +48,7 @@ async function getPrismaProvider() {
|
|
|
44
48
|
}
|
|
45
49
|
const content = fs.readFileSync(schemaPath, "utf-8");
|
|
46
50
|
const match = content.match(/^\s*provider\s*=\s*["']([^"']+)["']/im);
|
|
47
|
-
if (match
|
|
51
|
+
if (match?.[1]) {
|
|
48
52
|
return match[1].toLowerCase();
|
|
49
53
|
}
|
|
50
54
|
return void 0;
|
|
@@ -52,7 +56,7 @@ async function getPrismaProvider() {
|
|
|
52
56
|
return void 0;
|
|
53
57
|
}
|
|
54
58
|
}
|
|
55
|
-
function findExistingLiveQueryMigration(
|
|
59
|
+
function findExistingLiveQueryMigration(migrationsDirectoryPath) {
|
|
56
60
|
if (!fs.existsSync(migrationsDirectoryPath)) {
|
|
57
61
|
return void 0;
|
|
58
62
|
}
|
|
@@ -143,7 +147,7 @@ function addLiveQueryListenerToGraphqlHandler({ force }) {
|
|
|
143
147
|
skipped: false
|
|
144
148
|
};
|
|
145
149
|
}
|
|
146
|
-
async function handler({ force }) {
|
|
150
|
+
async function handler({ force, verbose }) {
|
|
147
151
|
const projectIsTypescript = isTypeScriptProject();
|
|
148
152
|
const apiPackageJson = getApiPackageJson();
|
|
149
153
|
const migrationsPath = await getMigrationsPath(getPaths().api.prismaConfig);
|
|
@@ -160,9 +164,7 @@ async function handler({ force }) {
|
|
|
160
164
|
"templates",
|
|
161
165
|
"liveQueriesListener.ts.template"
|
|
162
166
|
);
|
|
163
|
-
const existingMigrationPath = findExistingLiveQueryMigration(
|
|
164
|
-
migrationsDirectoryPath: migrationsPath
|
|
165
|
-
});
|
|
167
|
+
const existingMigrationPath = findExistingLiveQueryMigration(migrationsPath);
|
|
166
168
|
const migrationDirPath = path.join(
|
|
167
169
|
migrationsPath,
|
|
168
170
|
generateMigrationFolderName()
|
|
@@ -202,6 +204,44 @@ async function handler({ force }) {
|
|
|
202
204
|
}
|
|
203
205
|
}
|
|
204
206
|
},
|
|
207
|
+
{
|
|
208
|
+
title: "Adding [experimental.gqlorm] config...",
|
|
209
|
+
task: (_ctx, task) => {
|
|
210
|
+
const configTomlPath = getConfigPath();
|
|
211
|
+
const configFileName = path.basename(configTomlPath);
|
|
212
|
+
const configContent = fs.readFileSync(configTomlPath, "utf-8");
|
|
213
|
+
if (!configContent.includes("[experimental.gqlorm]")) {
|
|
214
|
+
writeFile(
|
|
215
|
+
configTomlPath,
|
|
216
|
+
configContent.concat(
|
|
217
|
+
"\n\n[experimental.gqlorm]\n enabled = true\n"
|
|
218
|
+
),
|
|
219
|
+
{
|
|
220
|
+
overwriteExisting: true
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
} else {
|
|
224
|
+
if (force) {
|
|
225
|
+
task.output = `Overwriting config in ${configFileName}`;
|
|
226
|
+
writeFile(
|
|
227
|
+
configTomlPath,
|
|
228
|
+
configContent.replace(
|
|
229
|
+
"\n[experimental.gqlorm]\n enabled = false\n",
|
|
230
|
+
"\n[experimental.gqlorm]\n enabled = true\n"
|
|
231
|
+
),
|
|
232
|
+
{
|
|
233
|
+
overwriteExisting: true
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
} else {
|
|
237
|
+
task.skip(
|
|
238
|
+
`The [experimental.gqlorm] config block already exists in ${configFileName}.`
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
rendererOptions: { persistentOutput: true }
|
|
244
|
+
},
|
|
205
245
|
{
|
|
206
246
|
...addApiPackages(["pg@^8.18.0"]),
|
|
207
247
|
title: "Adding pg dependency to your api side...",
|
|
@@ -209,6 +249,7 @@ async function handler({ force }) {
|
|
|
209
249
|
if (hasPgDependency) {
|
|
210
250
|
return "pg is already installed";
|
|
211
251
|
}
|
|
252
|
+
return false;
|
|
212
253
|
}
|
|
213
254
|
},
|
|
214
255
|
{
|
|
@@ -231,6 +272,7 @@ async function handler({ force }) {
|
|
|
231
272
|
);
|
|
232
273
|
return `Existing live query migration found: ${migrationPath2}`;
|
|
233
274
|
}
|
|
275
|
+
return false;
|
|
234
276
|
}
|
|
235
277
|
},
|
|
236
278
|
{
|
|
@@ -272,17 +314,29 @@ async function handler({ force }) {
|
|
|
272
314
|
}
|
|
273
315
|
],
|
|
274
316
|
{
|
|
275
|
-
rendererOptions: { collapseSubtasks: false }
|
|
317
|
+
rendererOptions: { collapseSubtasks: false },
|
|
318
|
+
renderer: verbose ? "verbose" : "default"
|
|
276
319
|
}
|
|
277
320
|
);
|
|
278
321
|
try {
|
|
279
322
|
await tasks.run();
|
|
280
323
|
} catch (e) {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
324
|
+
if (isObject(e) && "message" in e) {
|
|
325
|
+
errorTelemetry(process.argv, e.message);
|
|
326
|
+
console.error(c.error(e.message));
|
|
327
|
+
} else {
|
|
328
|
+
errorTelemetry(process.argv, e);
|
|
329
|
+
console.error(c.error(e));
|
|
330
|
+
}
|
|
331
|
+
process.exit(isObjectWithExitCode(e) ? e.exitCode : 1);
|
|
284
332
|
}
|
|
285
333
|
}
|
|
334
|
+
function isObject(value) {
|
|
335
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
336
|
+
}
|
|
337
|
+
function isObjectWithExitCode(value) {
|
|
338
|
+
return isObject(value) && typeof value.exitCode === "number";
|
|
339
|
+
}
|
|
286
340
|
export {
|
|
287
341
|
handler
|
|
288
342
|
};
|
|
@@ -4,39 +4,40 @@ import ansis from "ansis";
|
|
|
4
4
|
import { terminalLink } from "termi-link";
|
|
5
5
|
import { getPaths } from "../../lib/index.js";
|
|
6
6
|
import { isTypeScriptProject, serverFileExists } from "../../lib/project.js";
|
|
7
|
-
|
|
7
|
+
function link(topicId, isTerminal = false) {
|
|
8
8
|
const communityLink = `https://community.redwoodjs.com/t/${topicId}`;
|
|
9
9
|
if (isTerminal) {
|
|
10
10
|
return terminalLink(communityLink, communityLink);
|
|
11
11
|
} else {
|
|
12
12
|
return communityLink;
|
|
13
13
|
}
|
|
14
|
-
}
|
|
15
|
-
|
|
14
|
+
}
|
|
15
|
+
function getEpilogue(command, description, topicId, isTerminal = false) {
|
|
16
|
+
let epilogue = `This is an experimental feature to: ${description}.
|
|
17
|
+
|
|
18
|
+
If you need help with ${command}, please join our Discord community.
|
|
19
|
+
-> ${terminalLink("", "https://cedarjs.com/discord")}`;
|
|
20
|
+
if (topicId) {
|
|
21
|
+
epilogue += `
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
-> ${link(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
You might also be able to find some information at:
|
|
24
|
+
-> ${link(topicId, isTerminal)}`;
|
|
25
|
+
}
|
|
26
|
+
return epilogue;
|
|
27
|
+
}
|
|
28
|
+
function printTaskEpilogue(command, description, topicId) {
|
|
29
|
+
const orangeLine = ansis.hex("#ff845e")("-".repeat(64));
|
|
23
30
|
console.log(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
------------------------------------------------------------------`
|
|
30
|
-
)}`
|
|
31
|
+
[
|
|
32
|
+
orangeLine,
|
|
33
|
+
`\u{1F9EA} ${ansis.green("Experimental Feature")} \u{1F9EA}`,
|
|
34
|
+
orangeLine
|
|
35
|
+
].join("\n")
|
|
31
36
|
);
|
|
32
37
|
console.log(getEpilogue(command, description, topicId, false));
|
|
33
|
-
console.log(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
)}
|
|
37
|
-
`
|
|
38
|
-
);
|
|
39
|
-
};
|
|
38
|
+
console.log(`${orangeLine}
|
|
39
|
+
`);
|
|
40
|
+
}
|
|
40
41
|
const isServerFileSetup = () => {
|
|
41
42
|
if (!serverFileExists()) {
|
|
42
43
|
throw new Error(
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { terminalLink } from "termi-link";
|
|
2
2
|
import { detectCedarVersion } from "../middleware/detectProjectCedarVersion.js";
|
|
3
|
+
import * as experimentalLiveQueries from "./experimental/live-queries/liveQueries.js";
|
|
3
4
|
import * as experimentalInngest from "./experimental/setupInngest.js";
|
|
4
5
|
import * as experimentalOpenTelemetry from "./experimental/setupOpentelemetry.js";
|
|
5
6
|
import * as experimentalReactCompiler from "./experimental/setupReactCompiler.js";
|
|
@@ -8,7 +9,7 @@ import * as experimentalStreamingSsr from "./experimental/setupStreamingSsr.js";
|
|
|
8
9
|
const command = "experimental <command>";
|
|
9
10
|
const aliases = ["exp"];
|
|
10
11
|
const description = "Run or setup experimental features";
|
|
11
|
-
const builder = (yargs) => yargs.command(experimentalInngest).command(experimentalOpenTelemetry).command(experimentalReactCompiler).command(experimentalRsc).command(experimentalStreamingSsr).demandCommand().middleware(detectCedarVersion).epilogue(
|
|
12
|
+
const builder = (yargs) => yargs.command(experimentalInngest).command(experimentalLiveQueries).command(experimentalOpenTelemetry).command(experimentalReactCompiler).command(experimentalRsc).command(experimentalStreamingSsr).demandCommand().middleware(detectCedarVersion).epilogue(
|
|
12
13
|
`Also see the ${terminalLink(
|
|
13
14
|
"CedarJS CLI Reference",
|
|
14
15
|
"https://cedarjs.com/docs/cli-commands#experimental"
|
package/dist/commands/setup.js
CHANGED
|
@@ -8,7 +8,6 @@ import * as setupGenerator from "./setup/generator/generator.js";
|
|
|
8
8
|
import * as setupGraphql from "./setup/graphql/graphql.js";
|
|
9
9
|
import * as setupI18n from "./setup/i18n/i18n.js";
|
|
10
10
|
import * as setupJobs from "./setup/jobs/jobs.js";
|
|
11
|
-
import * as setupLiveQueries from "./setup/live-queries/liveQueries.js";
|
|
12
11
|
import * as setupMailer from "./setup/mailer/mailer.js";
|
|
13
12
|
import * as setupMiddleware from "./setup/middleware/middleware.js";
|
|
14
13
|
import * as setupMonitoring from "./setup/monitoring/monitoring.js";
|
|
@@ -21,7 +20,7 @@ import * as setupUploads from "./setup/uploads/uploads.js";
|
|
|
21
20
|
import * as setupVite from "./setup/vite/vite.js";
|
|
22
21
|
const command = "setup <command>";
|
|
23
22
|
const description = "Initialize project config and install packages";
|
|
24
|
-
const builder = (yargs) => yargs.command(setupAuth).command(setupCache).command(setupDeploy).command(setupDocker).command(setupGenerator).command(setupGraphql).command(setupI18n).command(setupJobs).command(
|
|
23
|
+
const builder = (yargs) => yargs.command(setupAuth).command(setupCache).command(setupDeploy).command(setupDocker).command(setupGenerator).command(setupGraphql).command(setupI18n).command(setupJobs).command(setupMailer).command(setupMiddleware).command(setupMonitoring).command(setupPackage).command(setupRealtime).command(setupServerFile).command(setupTsconfig).command(setupUi).command(setupUploads).command(setupVite).demandCommand().middleware(detectCedarVersion).epilogue(
|
|
25
24
|
`Also see the ${terminalLink(
|
|
26
25
|
"CedarJS CLI Reference",
|
|
27
26
|
"https://cedarjs.com/docs/cli-commands#setup"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "4.0.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.13784+a1524c1b18",
|
|
4
4
|
"description": "The CedarJS Command Line",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,16 +33,16 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/parser": "7.29.2",
|
|
35
35
|
"@babel/preset-typescript": "7.28.5",
|
|
36
|
-
"@cedarjs/api-server": "4.0.0-canary.
|
|
37
|
-
"@cedarjs/cli-helpers": "4.0.0-canary.
|
|
38
|
-
"@cedarjs/fastify-web": "4.0.0-canary.
|
|
39
|
-
"@cedarjs/internal": "4.0.0-canary.
|
|
40
|
-
"@cedarjs/prerender": "4.0.0-canary.
|
|
41
|
-
"@cedarjs/project-config": "4.0.0-canary.
|
|
42
|
-
"@cedarjs/structure": "4.0.0-canary.
|
|
43
|
-
"@cedarjs/telemetry": "4.0.0-canary.
|
|
44
|
-
"@cedarjs/utils": "4.0.0-canary.
|
|
45
|
-
"@cedarjs/web-server": "4.0.0-canary.
|
|
36
|
+
"@cedarjs/api-server": "4.0.0-canary.13784",
|
|
37
|
+
"@cedarjs/cli-helpers": "4.0.0-canary.13784",
|
|
38
|
+
"@cedarjs/fastify-web": "4.0.0-canary.13784",
|
|
39
|
+
"@cedarjs/internal": "4.0.0-canary.13784",
|
|
40
|
+
"@cedarjs/prerender": "4.0.0-canary.13784",
|
|
41
|
+
"@cedarjs/project-config": "4.0.0-canary.13784",
|
|
42
|
+
"@cedarjs/structure": "4.0.0-canary.13784",
|
|
43
|
+
"@cedarjs/telemetry": "4.0.0-canary.13784",
|
|
44
|
+
"@cedarjs/utils": "4.0.0-canary.13784",
|
|
45
|
+
"@cedarjs/web-server": "4.0.0-canary.13784",
|
|
46
46
|
"@listr2/prompt-adapter-enquirer": "4.2.1",
|
|
47
47
|
"@opentelemetry/api": "1.9.0",
|
|
48
48
|
"@opentelemetry/core": "1.30.1",
|
|
@@ -108,5 +108,5 @@
|
|
|
108
108
|
"publishConfig": {
|
|
109
109
|
"access": "public"
|
|
110
110
|
},
|
|
111
|
-
"gitHead": "
|
|
111
|
+
"gitHead": "a1524c1b18b1def13c0f4520aa638b13bddf630e"
|
|
112
112
|
}
|
/package/dist/commands/{setup → experimental}/live-queries/templates/liveQueriesListener.ts.template
RENAMED
|
File without changes
|
|
File without changes
|