@cedarjs/cli 5.0.7-next.338 → 5.0.7
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/README.md +10 -7
- package/dist/cfw.js +1 -3
- package/dist/commands/build/buildHandler.js +6 -14
- package/dist/commands/console.js +3 -5
- package/dist/commands/consoleHandler.js +75 -0
- package/dist/commands/dev/devHandler.js +4 -71
- package/dist/commands/dev.js +4 -7
- package/dist/commands/execHandler.js +0 -12
- package/dist/commands/experimental/setupOpentelemetryHandler.js +1 -1
- package/dist/commands/generate/helpers.js +0 -16
- package/dist/commands/generate/job/jobHandler.js +7 -5
- package/dist/commands/generate/package/filesTask.js +0 -12
- package/dist/commands/generate/package/packageHandler.js +11 -18
- package/dist/commands/generate/package/templates/test.ts.template +2 -2
- package/dist/commands/generate/scaffold/scaffoldHandler.js +19 -138
- package/dist/commands/generate/script/templates/script.ts.template +4 -9
- package/dist/commands/generate/sdl/sdlHandler.js +44 -113
- package/dist/commands/generate/sdl/templates/sdl.js.template +1 -2
- package/dist/commands/generate/sdl/templates/sdl.ts.template +1 -2
- package/dist/commands/generate/service/serviceHandler.js +6 -17
- package/dist/commands/generate/yargsHandlerHelpers.js +6 -0
- package/dist/commands/lint.js +61 -1
- package/dist/commands/prismaHandler.js +7 -4
- package/dist/commands/serve.js +24 -23
- package/dist/commands/serveBothHandler.js +4 -4
- package/dist/commands/setup/auth/auth.js +1 -1
- package/dist/commands/setup/deploy/helpers/index.js +39 -9
- package/dist/commands/setup/deploy/providers/flightcontrolHandler.js +5 -17
- package/dist/commands/setup/deploy/providers/renderHandler.js +21 -27
- package/dist/commands/setup/deploy/templates/render.js +16 -29
- package/dist/commands/setup/docker/templates/Dockerfile.yarn +5 -2
- package/dist/commands/setup/docker/templates/docker-compose.dev.yml +1 -1
- package/dist/commands/setup/docker/templates/docker-compose.prod.yml +5 -2
- package/dist/commands/setup/graphql/features/fragments/appGqlConfigTransform.js +3 -6
- package/dist/commands/setup/monitoring/sentry/sentryHandler.js +4 -9
- package/dist/commands/setup/neon/neon.js +3 -13
- package/dist/commands/setup/neon/neonHandler.js +258 -141
- package/dist/commands/setup/ui/libraries/chakra-uiHandler.js +1 -3
- package/dist/commands/setup/ui/libraries/mantineHandler.js +1 -3
- package/dist/commands/setup/ui/libraries/tailwindcssHandler.js +1 -0
- package/dist/commands/setup/uploads/uploadsHandler.js +5 -6
- package/dist/commands/setup.js +1 -2
- package/dist/commands/test/testHandlerEsm.js +1 -1
- package/dist/commands/upgrade/preUpgradeScripts.js +9 -9
- package/dist/commands/upgrade/upgradeHandler.js +32 -42
- package/dist/lib/background.js +1 -20
- package/dist/lib/exec.js +8 -5
- package/dist/lib/extendFile.js +1 -1
- package/dist/lib/index.js +6 -22
- package/dist/lib/updateCheck.js +6 -34
- package/dist/telemetry/resource.js +8 -3
- package/package.json +27 -26
- package/dist/commands/generate/package/templates/vitest.config.ts.template +0 -9
- package/dist/commands/generate/sdl/stubFiles.js +0 -132
- package/dist/commands/setup/database/database.js +0 -15
- package/dist/commands/setup/database/postgres.js +0 -19
- package/dist/commands/setup/database/postgresHandler.js +0 -194
- /package/dist/commands/setup/{database → neon}/templates/db.ts.template +0 -0
|
@@ -33,7 +33,6 @@ const handler = async (upgradeOptions) => {
|
|
|
33
33
|
});
|
|
34
34
|
let preUpgradeMessage = "";
|
|
35
35
|
let preUpgradeError = "";
|
|
36
|
-
const notBlockedByPreUpgradeChecks = (ctx) => force || !ctx.preUpgradeError;
|
|
37
36
|
const tasks = new Listr(
|
|
38
37
|
[
|
|
39
38
|
{
|
|
@@ -88,46 +87,39 @@ const handler = async (upgradeOptions) => {
|
|
|
88
87
|
{
|
|
89
88
|
title: "Updating your CedarJS version",
|
|
90
89
|
task: (ctx) => updateCedarJSDepsForAllSides(ctx, { dryRun, verbose }),
|
|
91
|
-
enabled: (ctx) => !!ctx.versionToUpgradeTo &&
|
|
90
|
+
enabled: (ctx) => !!ctx.versionToUpgradeTo && !ctx.preUpgradeError
|
|
92
91
|
},
|
|
93
92
|
{
|
|
94
93
|
title: "Updating other packages in your package.json(s)",
|
|
95
94
|
task: (ctx) => updatePackageVersionsFromTemplate(ctx, { dryRun, verbose }),
|
|
96
|
-
|
|
97
|
-
// project and adds back any the project is missing, which resurrects
|
|
98
|
-
// packages people have deliberately removed — a project that moved off
|
|
99
|
-
// SQLite gets better-sqlite3 back, for example. That's too blunt for
|
|
100
|
-
// regular upgrades, but people running canary are already signed up
|
|
101
|
-
// for rougher edges.
|
|
102
|
-
// https://github.com/redwoodjs/redwood/pull/8855
|
|
103
|
-
enabled: (ctx) => String(ctx.versionToUpgradeTo).includes("canary") && notBlockedByPreUpgradeChecks(ctx)
|
|
95
|
+
enabled: (ctx) => String(ctx.versionToUpgradeTo).includes("canary") && !ctx.preUpgradeError
|
|
104
96
|
},
|
|
105
97
|
{
|
|
106
98
|
title: "Downloading yarn patches",
|
|
107
99
|
task: (ctx) => downloadYarnPatches(ctx, { dryRun, verbose }),
|
|
108
|
-
enabled: (ctx) => String(ctx.versionToUpgradeTo).includes("canary") &&
|
|
100
|
+
enabled: (ctx) => String(ctx.versionToUpgradeTo).includes("canary") && !ctx.preUpgradeError
|
|
109
101
|
},
|
|
110
102
|
{
|
|
111
103
|
title: "Removing CLI cache",
|
|
112
104
|
task: () => removeCliCache({ dryRun, verbose }),
|
|
113
|
-
enabled: (ctx) =>
|
|
105
|
+
enabled: (ctx) => !ctx.preUpgradeError
|
|
114
106
|
},
|
|
115
107
|
{
|
|
116
108
|
title: `Running ${getPackageManager()} ${install()}`,
|
|
117
109
|
task: () => packageManagerInstall({ verbose }),
|
|
118
|
-
enabled: (ctx) =>
|
|
110
|
+
enabled: (ctx) => !ctx.preUpgradeError,
|
|
119
111
|
skip: () => !!dryRun
|
|
120
112
|
},
|
|
121
113
|
{
|
|
122
114
|
title: "Refreshing the Prisma client",
|
|
123
115
|
task: (_ctx, task) => refreshPrismaClient(task, { verbose }),
|
|
124
|
-
enabled: (ctx) =>
|
|
116
|
+
enabled: (ctx) => !ctx.preUpgradeError,
|
|
125
117
|
skip: () => !!dryRun
|
|
126
118
|
},
|
|
127
119
|
{
|
|
128
120
|
title: "De-duplicating dependencies",
|
|
129
121
|
skip: () => !!dryRun || !dedupe2,
|
|
130
|
-
enabled: (ctx) => dedupeIsSupported() &&
|
|
122
|
+
enabled: (ctx) => dedupeIsSupported() && !ctx.preUpgradeError,
|
|
131
123
|
task: (_ctx, task) => dedupeDeps(task, { verbose })
|
|
132
124
|
},
|
|
133
125
|
{
|
|
@@ -311,22 +303,6 @@ function updateCedarJSDepsForAllSides(ctx, options) {
|
|
|
311
303
|
})
|
|
312
304
|
);
|
|
313
305
|
}
|
|
314
|
-
function mergeTemplateDependencies(field, templatePackageJson, localPackageJson, messages, { dryRun, verbose } = {}) {
|
|
315
|
-
const templateDeps = templatePackageJson[field];
|
|
316
|
-
if (!templateDeps) {
|
|
317
|
-
return;
|
|
318
|
-
}
|
|
319
|
-
for (const [depName, depVersion] of Object.entries(templateDeps)) {
|
|
320
|
-
if (depName.startsWith("@cedarjs/")) {
|
|
321
|
-
continue;
|
|
322
|
-
}
|
|
323
|
-
const localDeps = localPackageJson[field] ??= {};
|
|
324
|
-
if (verbose || dryRun) {
|
|
325
|
-
messages.push(` - ${depName}: ${localDeps[depName]} => ${depVersion}`);
|
|
326
|
-
}
|
|
327
|
-
localDeps[depName] = depVersion;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
306
|
async function updatePackageVersionsFromTemplate(ctx, { dryRun, verbose }) {
|
|
331
307
|
if (!ctx.versionToUpgradeTo) {
|
|
332
308
|
throw new Error("Failed to upgrade");
|
|
@@ -362,15 +338,30 @@ async function updatePackageVersionsFromTemplate(ctx, { dryRun, verbose }) {
|
|
|
362
338
|
const localPackageJsonText = fs.readFileSync(pkgJsonPath, "utf-8");
|
|
363
339
|
const localPackageJson = JSON.parse(localPackageJsonText);
|
|
364
340
|
const messages = [];
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
341
|
+
Object.entries(templatePackageJson.dependencies || {}).forEach(
|
|
342
|
+
([depName, depVersion]) => {
|
|
343
|
+
if (!depName.startsWith("@cedarjs/")) {
|
|
344
|
+
if (verbose || dryRun) {
|
|
345
|
+
messages.push(
|
|
346
|
+
` - ${depName}: ${localPackageJson.dependencies[depName]} => ${depVersion}`
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
localPackageJson.dependencies[depName] = depVersion;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
);
|
|
353
|
+
Object.entries(templatePackageJson.devDependencies || {}).forEach(
|
|
354
|
+
([depName, depVersion]) => {
|
|
355
|
+
if (!depName.startsWith("@cedarjs/")) {
|
|
356
|
+
if (verbose || dryRun) {
|
|
357
|
+
messages.push(
|
|
358
|
+
` - ${depName}: ${localPackageJson.devDependencies[depName]} => ${depVersion}`
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
localPackageJson.devDependencies[depName] = depVersion;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
);
|
|
374
365
|
if (messages.length > 0) {
|
|
375
366
|
task.title = task.title + "\n" + messages.join("\n");
|
|
376
367
|
}
|
|
@@ -478,6 +469,5 @@ async function dedupeDeps(_task, { verbose }) {
|
|
|
478
469
|
await packageManagerInstall({ verbose });
|
|
479
470
|
}
|
|
480
471
|
export {
|
|
481
|
-
handler
|
|
482
|
-
mergeTemplateDependencies
|
|
472
|
+
handler
|
|
483
473
|
};
|
package/dist/lib/background.js
CHANGED
|
@@ -3,23 +3,6 @@ import fs from "node:fs";
|
|
|
3
3
|
import os from "os";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { getPaths } from "@cedarjs/project-config";
|
|
6
|
-
function quoteForWindowsShell(arg) {
|
|
7
|
-
let quoted = '"';
|
|
8
|
-
let backslashes = 0;
|
|
9
|
-
for (const char of arg) {
|
|
10
|
-
if (char === "\\") {
|
|
11
|
-
backslashes += 1;
|
|
12
|
-
continue;
|
|
13
|
-
}
|
|
14
|
-
if (char === '"') {
|
|
15
|
-
quoted += "\\".repeat(backslashes * 2 + 1) + '"';
|
|
16
|
-
} else {
|
|
17
|
-
quoted += "\\".repeat(backslashes) + char;
|
|
18
|
-
}
|
|
19
|
-
backslashes = 0;
|
|
20
|
-
}
|
|
21
|
-
return quoted + "\\".repeat(backslashes * 2) + '"';
|
|
22
|
-
}
|
|
23
6
|
function spawnBackgroundProcess(name, cmd, args) {
|
|
24
7
|
const logDirectory = path.join(getPaths().generated.base, "logs");
|
|
25
8
|
fs.mkdirSync(logDirectory, { recursive: true });
|
|
@@ -54,8 +37,7 @@ function spawnBackgroundProcess(name, cmd, args) {
|
|
|
54
37
|
shell: true,
|
|
55
38
|
stdio: ["ignore", stdout, stderr]
|
|
56
39
|
};
|
|
57
|
-
const
|
|
58
|
-
const child = spawn(command, spawnOptions);
|
|
40
|
+
const child = spawn(cmd + " " + args.join(" "), spawnOptions);
|
|
59
41
|
child.unref();
|
|
60
42
|
} else {
|
|
61
43
|
const spawnOptions = {
|
|
@@ -69,6 +51,5 @@ function spawnBackgroundProcess(name, cmd, args) {
|
|
|
69
51
|
fs.closeSync(stderr);
|
|
70
52
|
}
|
|
71
53
|
export {
|
|
72
|
-
quoteForWindowsShell,
|
|
73
54
|
spawnBackgroundProcess
|
|
74
55
|
};
|
package/dist/lib/exec.js
CHANGED
|
@@ -54,16 +54,19 @@ async function runScriptFunction({
|
|
|
54
54
|
nodeRunnerEnv: {}
|
|
55
55
|
},
|
|
56
56
|
resolve: {
|
|
57
|
-
// `$api/` and `api/` imports are handled by
|
|
58
|
-
// cedarjsResolveCedarStyleImportsPlugin below, which also resolves
|
|
59
|
-
// Cedar's directory named modules (`$api/src/services/posts` ->
|
|
60
|
-
// posts/posts.ts) and leaves an actual `api` npm package alone. The web
|
|
61
|
-
// side equivalents have no plugin support, so they stay aliases
|
|
62
57
|
alias: [
|
|
58
|
+
{
|
|
59
|
+
find: /^\$api\//,
|
|
60
|
+
replacement: getPaths().api.base + "/"
|
|
61
|
+
},
|
|
63
62
|
{
|
|
64
63
|
find: /^\$web\//,
|
|
65
64
|
replacement: getPaths().web.base + "/"
|
|
66
65
|
},
|
|
66
|
+
{
|
|
67
|
+
find: /^api\//,
|
|
68
|
+
replacement: getPaths().api.base + "/"
|
|
69
|
+
},
|
|
67
70
|
{
|
|
68
71
|
find: /^web\//,
|
|
69
72
|
replacement: getPaths().web.base + "/"
|
package/dist/lib/extendFile.js
CHANGED
|
@@ -56,7 +56,7 @@ function insertComponent(content, {
|
|
|
56
56
|
"Exactly one of (around | within) must be defined. Choose one."
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
|
-
const target =
|
|
59
|
+
const target = around ?? within;
|
|
60
60
|
const findTagIndex = (regex) => content.findIndex((line) => regex.test(line));
|
|
61
61
|
let open = findTagIndex(new RegExp(`([^\\S\r
|
|
62
62
|
]*)<${target}\\s*(.*)\\s*>`));
|
package/dist/lib/index.js
CHANGED
|
@@ -305,35 +305,20 @@ const cleanupEmptyDirsTask = (files) => {
|
|
|
305
305
|
})
|
|
306
306
|
);
|
|
307
307
|
};
|
|
308
|
-
function wrapWithSet(routesContent, layout, routes, newLineAndIndent, props = {}
|
|
308
|
+
function wrapWithSet(routesContent, layout, routes, newLineAndIndent, props = {}) {
|
|
309
309
|
const [_, indentOne, indentTwo] = routesContent.match(
|
|
310
310
|
/([ \t]*)<Router.*?>[^<]*[\r\n]+([ \t]+)/
|
|
311
311
|
) || ["", "", ""];
|
|
312
312
|
const oneLevelIndent = indentTwo.slice(0, indentTwo.length - indentOne.length);
|
|
313
|
+
const newRoutesWithExtraIndent = routes.map((route) => oneLevelIndent + route);
|
|
313
314
|
const propsString = Object.entries(props).map((values) => `${values[0]}="${values[1]}"`).join(" ");
|
|
314
|
-
if (!privateSetProps) {
|
|
315
|
-
const newRoutesWithExtraIndent2 = routes.map(
|
|
316
|
-
(route) => oneLevelIndent + route
|
|
317
|
-
);
|
|
318
|
-
return [
|
|
319
|
-
`<Set wrap={${layout}}${propsString && " " + propsString}>`,
|
|
320
|
-
...newRoutesWithExtraIndent2,
|
|
321
|
-
`</Set>`
|
|
322
|
-
].join(newLineAndIndent);
|
|
323
|
-
}
|
|
324
|
-
const privateSetPropsString = Object.entries(privateSetProps).map((values) => `${values[0]}="${values[1]}"`).join(" ");
|
|
325
|
-
const newRoutesWithExtraIndent = routes.map(
|
|
326
|
-
(route) => oneLevelIndent + oneLevelIndent + route
|
|
327
|
-
);
|
|
328
315
|
return [
|
|
329
|
-
`<
|
|
330
|
-
`${oneLevelIndent}<Set wrap={${layout}}${propsString && " " + propsString}>`,
|
|
316
|
+
`<Set wrap={${layout}}${propsString && " " + propsString}>`,
|
|
331
317
|
...newRoutesWithExtraIndent,
|
|
332
|
-
|
|
333
|
-
`</PrivateSet>`
|
|
318
|
+
`</Set>`
|
|
334
319
|
].join(newLineAndIndent);
|
|
335
320
|
}
|
|
336
|
-
function addRoutesToRouterTask(routes, layout, setProps = {}
|
|
321
|
+
function addRoutesToRouterTask(routes, layout, setProps = {}) {
|
|
337
322
|
const cedarPaths = getPaths();
|
|
338
323
|
const routesContent = readFile(cedarPaths.web.routes).toString();
|
|
339
324
|
let newRoutes = routes.filter((route) => !routesContent.match(route));
|
|
@@ -357,8 +342,7 @@ ${route}`);
|
|
|
357
342
|
layout,
|
|
358
343
|
newRoutes,
|
|
359
344
|
newLineAndIndent,
|
|
360
|
-
setProps
|
|
361
|
-
privateSetProps
|
|
345
|
+
setProps
|
|
362
346
|
) : newRoutes.join(newLineAndIndent);
|
|
363
347
|
const newRoutesContent = routesContent.replace(
|
|
364
348
|
routerStart,
|
package/dist/lib/updateCheck.js
CHANGED
|
@@ -24,35 +24,15 @@ function getPersistenceDirectory() {
|
|
|
24
24
|
persistenceDirectory = path.join(getPaths().generated.base, "updateCheck");
|
|
25
25
|
return persistenceDirectory;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
let version;
|
|
27
|
+
async function check() {
|
|
29
28
|
try {
|
|
29
|
+
console.time("Update Check");
|
|
30
30
|
const packageJson = JSON.parse(
|
|
31
31
|
fs.readFileSync(path.join(getPaths().base, "package.json"), "utf-8")
|
|
32
32
|
);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
if (typeof version === "string" && semver.valid(version)) {
|
|
38
|
-
return version;
|
|
39
|
-
}
|
|
40
|
-
return void 0;
|
|
41
|
-
}
|
|
42
|
-
async function check() {
|
|
43
|
-
try {
|
|
44
|
-
console.time("Update Check");
|
|
45
|
-
const localVersion = getLocalVersion();
|
|
46
|
-
if (!localVersion) {
|
|
47
|
-
console.log(
|
|
48
|
-
"Skipping update check: no pinned @cedarjs/core version found"
|
|
49
|
-
);
|
|
50
|
-
updateUpdateDataFile({
|
|
51
|
-
localVersion: "0.0.0",
|
|
52
|
-
remoteVersions: /* @__PURE__ */ new Map(),
|
|
53
|
-
checkedAt: (/* @__PURE__ */ new Date()).getTime()
|
|
54
|
-
});
|
|
55
|
-
return;
|
|
33
|
+
let localVersion = packageJson.devDependencies["@cedarjs/core"];
|
|
34
|
+
while (!/\d/.test(localVersion.charAt(0))) {
|
|
35
|
+
localVersion = localVersion.substring(1);
|
|
56
36
|
}
|
|
57
37
|
console.log(`Detected the current version of Cedar: '${localVersion}'`);
|
|
58
38
|
const remoteVersions = /* @__PURE__ */ new Map();
|
|
@@ -89,24 +69,16 @@ function shouldCheck() {
|
|
|
89
69
|
return false;
|
|
90
70
|
}
|
|
91
71
|
const data = readUpdateDataFile();
|
|
92
|
-
const localVersion = getLocalVersion();
|
|
93
|
-
if (localVersion && localVersion !== data.localVersion) {
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
72
|
return data.checkedAt < (/* @__PURE__ */ new Date()).getTime() - CHECK_PERIOD;
|
|
97
73
|
}
|
|
98
74
|
function shouldShow() {
|
|
99
75
|
if (isLockSet(SHOW_LOCK_IDENTIFIER)) {
|
|
100
76
|
return false;
|
|
101
77
|
}
|
|
102
|
-
const localVersion = getLocalVersion();
|
|
103
|
-
if (!localVersion) {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
78
|
const data = readUpdateDataFile();
|
|
107
79
|
let newerVersion = false;
|
|
108
80
|
data.remoteVersions.forEach((version) => {
|
|
109
|
-
newerVersion ||= semver.gt(version, localVersion);
|
|
81
|
+
newerVersion ||= semver.gt(version, data.localVersion);
|
|
110
82
|
});
|
|
111
83
|
return data.shownAt < (/* @__PURE__ */ new Date()).getTime() - SHOW_PERIOD && newerVersion;
|
|
112
84
|
}
|
|
@@ -7,10 +7,13 @@ import system from "systeminformation";
|
|
|
7
7
|
import { v4 as uuidv4, validate as validateUUID } from "uuid";
|
|
8
8
|
import { getPaths, getRawConfig } from "@cedarjs/project-config";
|
|
9
9
|
import { RWProject } from "@cedarjs/structure/dist/model/RWProject";
|
|
10
|
+
import {
|
|
11
|
+
name as _packageName,
|
|
12
|
+
version as _packageVersion
|
|
13
|
+
} from "../../package.js";
|
|
14
|
+
const packageName = _packageName;
|
|
15
|
+
const packageVersion = _packageVersion;
|
|
10
16
|
async function getResources() {
|
|
11
|
-
const packageJson = await import("../../package.json", { with: { type: "json" } });
|
|
12
|
-
const packageName = packageJson.default["name"];
|
|
13
|
-
const packageVersion = packageJson.default["version"];
|
|
14
17
|
let UID = uuidv4();
|
|
15
18
|
try {
|
|
16
19
|
const telemetryFile = path.join(getPaths().generated.base, "telemetry.txt");
|
|
@@ -86,6 +89,8 @@ async function getResources() {
|
|
|
86
89
|
complexity,
|
|
87
90
|
sides,
|
|
88
91
|
experiments: JSON.stringify(experiments),
|
|
92
|
+
webBundler: "vite",
|
|
93
|
+
// Hardcoded because this is now the only supported bundler
|
|
89
94
|
uid: UID
|
|
90
95
|
};
|
|
91
96
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "5.0.7
|
|
3
|
+
"version": "5.0.7",
|
|
4
4
|
"description": "The CedarJS Command Line",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,23 +31,20 @@
|
|
|
31
31
|
"test:watch": "vitest watch"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@babel/
|
|
35
|
-
"@babel/parser": "7.29.8",
|
|
34
|
+
"@babel/parser": "7.29.7",
|
|
36
35
|
"@babel/preset-typescript": "7.29.7",
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"@cedarjs/
|
|
40
|
-
"@cedarjs/
|
|
41
|
-
"@cedarjs/
|
|
42
|
-
"@cedarjs/
|
|
43
|
-
"@cedarjs/
|
|
44
|
-
"@cedarjs/
|
|
45
|
-
"@cedarjs/
|
|
46
|
-
"@cedarjs/
|
|
47
|
-
"@cedarjs/
|
|
48
|
-
"@
|
|
49
|
-
"@cedarjs/web-server": "5.0.7-next.338",
|
|
50
|
-
"@listr2/prompt-adapter-enquirer": "4.3.0",
|
|
36
|
+
"@cedarjs/api-server": "5.0.7",
|
|
37
|
+
"@cedarjs/cli-helpers": "5.0.7",
|
|
38
|
+
"@cedarjs/fastify-web": "5.0.7",
|
|
39
|
+
"@cedarjs/internal": "5.0.7",
|
|
40
|
+
"@cedarjs/prerender": "5.0.7",
|
|
41
|
+
"@cedarjs/project-config": "5.0.7",
|
|
42
|
+
"@cedarjs/structure": "5.0.7",
|
|
43
|
+
"@cedarjs/telemetry": "5.0.7",
|
|
44
|
+
"@cedarjs/utils": "5.0.7",
|
|
45
|
+
"@cedarjs/vite": "5.0.7",
|
|
46
|
+
"@cedarjs/web-server": "5.0.7",
|
|
47
|
+
"@listr2/prompt-adapter-enquirer": "4.2.1",
|
|
51
48
|
"@opentelemetry/api": "1.9.1",
|
|
52
49
|
"@opentelemetry/core": "1.30.1",
|
|
53
50
|
"@opentelemetry/exporter-trace-otlp-http": "0.57.2",
|
|
@@ -55,7 +52,7 @@
|
|
|
55
52
|
"@opentelemetry/sdk-trace-node": "1.30.1",
|
|
56
53
|
"@opentelemetry/semantic-conventions": "1.41.1",
|
|
57
54
|
"@prisma/internals": "7.8.0",
|
|
58
|
-
"ansis": "4.
|
|
55
|
+
"ansis": "4.2.0",
|
|
59
56
|
"archiver": "7.0.1",
|
|
60
57
|
"boxen": "5.1.2",
|
|
61
58
|
"camel-case": "4.1.2",
|
|
@@ -64,6 +61,7 @@
|
|
|
64
61
|
"ci-info": "4.4.0",
|
|
65
62
|
"concurrently": "9.2.4",
|
|
66
63
|
"configstore": "7.1.0",
|
|
64
|
+
"cross-env": "7.0.3",
|
|
67
65
|
"decamelize": "6.0.1",
|
|
68
66
|
"dotenv-defaults": "5.0.2",
|
|
69
67
|
"enquirer": "2.4.1",
|
|
@@ -71,7 +69,7 @@
|
|
|
71
69
|
"execa": "5.1.1",
|
|
72
70
|
"fast-glob": "3.3.3",
|
|
73
71
|
"humanize-string": "2.1.0",
|
|
74
|
-
"jscodeshift": "17.
|
|
72
|
+
"jscodeshift": "17.3.0",
|
|
75
73
|
"jsonc-parser": "3.3.1",
|
|
76
74
|
"latest-version": "9.0.0",
|
|
77
75
|
"listr2": "10.2.2",
|
|
@@ -82,11 +80,13 @@
|
|
|
82
80
|
"prettier": "3.8.4",
|
|
83
81
|
"prisma": "7.8.0",
|
|
84
82
|
"prompts": "2.4.2",
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
83
|
+
"recast": "0.23.11",
|
|
84
|
+
"rimraf": "6.1.3",
|
|
85
|
+
"semver": "7.7.4",
|
|
86
|
+
"smol-toml": "1.6.1",
|
|
87
|
+
"srvx": "0.11.16",
|
|
88
88
|
"string-env-interpolation": "1.0.1",
|
|
89
|
-
"systeminformation": "5.
|
|
89
|
+
"systeminformation": "5.31.7",
|
|
90
90
|
"termi-link": "1.1.0",
|
|
91
91
|
"title-case": "3.0.3",
|
|
92
92
|
"unionfs": "4.6.0",
|
|
@@ -94,14 +94,15 @@
|
|
|
94
94
|
"yargs": "17.7.3"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
97
|
-
"@
|
|
97
|
+
"@babel/cli": "7.29.7",
|
|
98
|
+
"@babel/core": "^7.26.10",
|
|
98
99
|
"@prisma/dmmf": "7.8.0",
|
|
99
100
|
"@types/archiver": "^7.0.0",
|
|
100
|
-
"memfs": "4.
|
|
101
|
+
"memfs": "4.64.0",
|
|
101
102
|
"node-ssh": "13.2.1",
|
|
102
103
|
"ts-dedent": "2.3.0",
|
|
103
104
|
"typescript": "5.9.3",
|
|
104
|
-
"vitest": "
|
|
105
|
+
"vitest": "3.2.6"
|
|
105
106
|
},
|
|
106
107
|
"engines": {
|
|
107
108
|
"node": ">=24"
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import crypto from "node:crypto";
|
|
2
|
-
import fs from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { Listr } from "listr2";
|
|
5
|
-
import { getPaths } from "@cedarjs/project-config";
|
|
6
|
-
import { writeFile } from "../../../lib/index.js";
|
|
7
|
-
import { getSchema } from "../../../lib/schemaHelpers.js";
|
|
8
|
-
const STUB_HASH_MARKER = "@cedar-generator-stub-hash";
|
|
9
|
-
const STUB_HASH_MARKER_REGEX = new RegExp(
|
|
10
|
-
`^// ${STUB_HASH_MARKER} ([0-9a-f]+)$`,
|
|
11
|
-
"m"
|
|
12
|
-
);
|
|
13
|
-
function stubHash(contents) {
|
|
14
|
-
return crypto.createHash("sha256").update(contents).digest("hex").slice(0, 16);
|
|
15
|
-
}
|
|
16
|
-
function addStubHeader({
|
|
17
|
-
content,
|
|
18
|
-
stubModel,
|
|
19
|
-
generatedFor
|
|
20
|
-
}) {
|
|
21
|
-
const body = "\n\n" + content;
|
|
22
|
-
const marker = `// ${STUB_HASH_MARKER} PLACEHOLDER`;
|
|
23
|
-
const header = [
|
|
24
|
-
`// Generated as a read-only stub by \`cedar generate sdl ${generatedFor}\`,`,
|
|
25
|
-
`// because ${generatedFor} has a relation to ${stubModel}, which had no SDL yet.`,
|
|
26
|
-
`// Run \`cedar generate sdl ${stubModel}\` to replace this stub with the real thing.`,
|
|
27
|
-
`// If you edit this file, the hash below will stop matching and you'll`,
|
|
28
|
-
`// need to pass \`--force\` to overwrite it.`,
|
|
29
|
-
marker
|
|
30
|
-
].join("\n");
|
|
31
|
-
const contentToHash = header + body;
|
|
32
|
-
const hash = stubHash(contentToHash);
|
|
33
|
-
const finalMarker = `// ${STUB_HASH_MARKER} ${hash}`;
|
|
34
|
-
return (header + body).replace(marker, finalMarker);
|
|
35
|
-
}
|
|
36
|
-
function isPristineStub(contents) {
|
|
37
|
-
const match = STUB_HASH_MARKER_REGEX.exec(contents);
|
|
38
|
-
if (!match) {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
const contentToHash = contents.replace(
|
|
42
|
-
match[0],
|
|
43
|
-
`// ${STUB_HASH_MARKER} PLACEHOLDER`
|
|
44
|
-
);
|
|
45
|
-
return stubHash(contentToHash) === match[1];
|
|
46
|
-
}
|
|
47
|
-
function readExistingSdlFiles() {
|
|
48
|
-
const graphqlDir = getPaths().api.graphql;
|
|
49
|
-
if (!fs.existsSync(graphqlDir)) {
|
|
50
|
-
return [];
|
|
51
|
-
}
|
|
52
|
-
const contents = [];
|
|
53
|
-
const dirsToWalk = [graphqlDir];
|
|
54
|
-
while (dirsToWalk.length > 0) {
|
|
55
|
-
const dir = dirsToWalk.shift();
|
|
56
|
-
if (!dir) {
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
60
|
-
const entryPath = path.join(dir, entry.name);
|
|
61
|
-
if (entry.isDirectory()) {
|
|
62
|
-
dirsToWalk.push(entryPath);
|
|
63
|
-
} else if (/\.sdl\.(js|ts)$/.test(entry.name)) {
|
|
64
|
-
contents.push(fs.readFileSync(entryPath, "utf-8"));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return contents;
|
|
69
|
-
}
|
|
70
|
-
async function missingRelatedModels(modelName) {
|
|
71
|
-
const existingSdls = readExistingSdlFiles();
|
|
72
|
-
const isDefined = (typeName) => existingSdls.some(
|
|
73
|
-
(sdl) => new RegExp(`\\btype\\s+${typeName}\\b`).test(sdl)
|
|
74
|
-
);
|
|
75
|
-
const seen = /* @__PURE__ */ new Set([modelName]);
|
|
76
|
-
const missing = [];
|
|
77
|
-
const queue = [modelName];
|
|
78
|
-
while (queue.length > 0) {
|
|
79
|
-
const current = queue.shift();
|
|
80
|
-
if (!current) {
|
|
81
|
-
break;
|
|
82
|
-
}
|
|
83
|
-
const model = await getSchema(current);
|
|
84
|
-
if (!model || !("fields" in model)) {
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
for (const field of model.fields) {
|
|
88
|
-
if (!field.relationName || seen.has(field.type)) {
|
|
89
|
-
continue;
|
|
90
|
-
}
|
|
91
|
-
seen.add(field.type);
|
|
92
|
-
queue.push(field.type);
|
|
93
|
-
if (!isDefined(field.type)) {
|
|
94
|
-
missing.push(field.type);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return missing;
|
|
99
|
-
}
|
|
100
|
-
function writeFilesWithStubsTask(files, { overwriteExisting = false } = {}) {
|
|
101
|
-
const { base } = getPaths();
|
|
102
|
-
return new Listr(
|
|
103
|
-
Object.entries(files).map(([file, contents]) => ({
|
|
104
|
-
title: `...waiting to write file \`./${path.relative(base, file)}\`...`,
|
|
105
|
-
task: (_ctx, task) => {
|
|
106
|
-
let canOverwrite = overwriteExisting;
|
|
107
|
-
if (!canOverwrite && fs.existsSync(file)) {
|
|
108
|
-
const existingContents = fs.readFileSync(file, "utf-8");
|
|
109
|
-
if (isPristineStub(existingContents)) {
|
|
110
|
-
canOverwrite = true;
|
|
111
|
-
} else if (STUB_HASH_MARKER_REGEX.test(existingContents)) {
|
|
112
|
-
throw new Error(
|
|
113
|
-
`${file} started out as a generated stub, but has since been edited. Use \`--force\` to overwrite it.`
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return writeFile(
|
|
118
|
-
file,
|
|
119
|
-
contents,
|
|
120
|
-
{ overwriteExisting: canOverwrite },
|
|
121
|
-
task
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
}))
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
export {
|
|
128
|
-
addStubHeader,
|
|
129
|
-
isPristineStub,
|
|
130
|
-
missingRelatedModels,
|
|
131
|
-
writeFilesWithStubsTask
|
|
132
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { terminalLink } from "termi-link";
|
|
2
|
-
import * as setupDatabasePostgres from "./postgres.js";
|
|
3
|
-
const command = "database <command>";
|
|
4
|
-
const description = "Switch your project's database";
|
|
5
|
-
const builder = (yargs) => yargs.command(setupDatabasePostgres).demandCommand().epilogue(
|
|
6
|
-
`Also see the ${terminalLink(
|
|
7
|
-
"CedarJS CLI Reference",
|
|
8
|
-
"https://cedarjs.com/docs/cli-commands#setup"
|
|
9
|
-
)}`
|
|
10
|
-
);
|
|
11
|
-
export {
|
|
12
|
-
builder,
|
|
13
|
-
command,
|
|
14
|
-
description
|
|
15
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
2
|
-
const command = "postgres";
|
|
3
|
-
const description = "Switch your project from SQLite to PostgreSQL (schema, dependencies, and database adapter)";
|
|
4
|
-
function builder(yargs) {
|
|
5
|
-
return yargs;
|
|
6
|
-
}
|
|
7
|
-
async function handler() {
|
|
8
|
-
recordTelemetryAttributes({
|
|
9
|
-
command: "setup database postgres"
|
|
10
|
-
});
|
|
11
|
-
const { handler: handler2 } = await import("./postgresHandler.js");
|
|
12
|
-
return handler2();
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
builder,
|
|
16
|
-
command,
|
|
17
|
-
description,
|
|
18
|
-
handler
|
|
19
|
-
};
|