@cedarjs/cli 5.0.7-next.338 → 5.0.7-rc.3
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
package/README.md
CHANGED
|
@@ -238,9 +238,12 @@ export const builder = (yargs) => {
|
|
|
238
238
|
|
|
239
239
|
...
|
|
240
240
|
|
|
241
|
-
.option('
|
|
242
|
-
default:
|
|
243
|
-
description:
|
|
241
|
+
.option('stats', {
|
|
242
|
+
default: false,
|
|
243
|
+
description: `Use ${terminalLink(
|
|
244
|
+
'Webpack Bundle Analyzer',
|
|
245
|
+
'https://github.com/webpack-contrib/webpack-bundle-analyzer'
|
|
246
|
+
)}`,
|
|
244
247
|
type: 'boolean',
|
|
245
248
|
})
|
|
246
249
|
.option('verbose', {
|
|
@@ -255,11 +258,11 @@ export const builder = (yargs) => {
|
|
|
255
258
|
}
|
|
256
259
|
```
|
|
257
260
|
|
|
258
|
-
These two calls to `options` configure this command to have options `--
|
|
261
|
+
These two calls to `options` configure this command to have options `--stats` and `--verbose`:
|
|
259
262
|
|
|
260
263
|
```terminal
|
|
261
|
-
yarn
|
|
262
|
-
yarn
|
|
264
|
+
yarn rw build --stats
|
|
265
|
+
yarn rw build --verbose
|
|
263
266
|
```
|
|
264
267
|
|
|
265
268
|
For the full list of what properties you can use to compose the options object, see [options(key, [opt])](https://yargs.js.org/docs/#api-optionskey-opt).
|
|
@@ -277,8 +280,8 @@ While `build`'s `handler` is too long to reproduce here in full, to get the poin
|
|
|
277
280
|
|
|
278
281
|
export const handler = async ({
|
|
279
282
|
side = ['api', 'web'],
|
|
280
|
-
prerender = true,
|
|
281
283
|
verbose = false,
|
|
284
|
+
stats = false,
|
|
282
285
|
}) => {
|
|
283
286
|
|
|
284
287
|
...
|
package/dist/cfw.js
CHANGED
|
@@ -40,8 +40,6 @@ try {
|
|
|
40
40
|
// CEDAR_DISABLE_TELEMETRY
|
|
41
41
|
env: { CEDAR_CWD: projectPath }
|
|
42
42
|
});
|
|
43
|
-
} catch
|
|
43
|
+
} catch {
|
|
44
44
|
console.log();
|
|
45
|
-
const exitCode = e && typeof e === "object" && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
46
|
-
process.exit(exitCode);
|
|
47
45
|
}
|
|
@@ -181,14 +181,10 @@ Run ` + c.info(formatCedarCommand(["build"])) + " (without specifying a workspac
|
|
|
181
181
|
"@cedarjs/vite/bins/cedar-vite-build.mjs"
|
|
182
182
|
);
|
|
183
183
|
await execa(
|
|
184
|
-
|
|
185
|
-
[
|
|
186
|
-
buildBinPath,
|
|
187
|
-
`--webDir=${cedarPaths.web.base}`,
|
|
188
|
-
`--verbose=${verbose}`
|
|
189
|
-
],
|
|
184
|
+
`node ${buildBinPath} --webDir="${cedarPaths.web.base}" --verbose=${verbose}`,
|
|
190
185
|
{
|
|
191
186
|
stdio: verbose ? "inherit" : "pipe",
|
|
187
|
+
shell: true,
|
|
192
188
|
cwd: cedarPaths.web.base
|
|
193
189
|
}
|
|
194
190
|
);
|
|
@@ -227,16 +223,12 @@ Run ` + c.info(formatCedarCommand(["build"])) + " (without specifying a workspac
|
|
|
227
223
|
"@cedarjs/vite/bins/cedar-vite-build.mjs"
|
|
228
224
|
);
|
|
229
225
|
await execa(
|
|
230
|
-
|
|
231
|
-
[
|
|
232
|
-
buildBinPath,
|
|
233
|
-
`--webDir=${cedarPaths.web.base}`,
|
|
234
|
-
`--verbose=${verbose}`
|
|
235
|
-
],
|
|
226
|
+
`node ${buildBinPath} --webDir="${cedarPaths.web.base}" --verbose=${verbose}`,
|
|
236
227
|
{
|
|
237
228
|
stdio: verbose ? "inherit" : "pipe",
|
|
238
|
-
|
|
239
|
-
//
|
|
229
|
+
shell: true,
|
|
230
|
+
// `cwd` is needed for the package manager (e.g. yarn) to find the
|
|
231
|
+
// cedar-vite-build binary
|
|
240
232
|
// It won't change process.cwd for anything else here, in this
|
|
241
233
|
// process
|
|
242
234
|
cwd: cedarPaths.web.base
|
package/dist/commands/console.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
const command = "console";
|
|
2
2
|
const aliases = ["c"];
|
|
3
|
-
const description = "Launch an interactive
|
|
3
|
+
const description = "Launch an interactive Redwood shell (experimental)";
|
|
4
4
|
const handler = async () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
);
|
|
8
|
-
process.exit(1);
|
|
5
|
+
const { handler: handler2 } = await import("./consoleHandler.js");
|
|
6
|
+
return handler2();
|
|
9
7
|
};
|
|
10
8
|
export {
|
|
11
9
|
aliases,
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import repl from "node:repl";
|
|
5
|
+
import { registerApiSideBabelHook } from "@cedarjs/babel-config";
|
|
6
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
7
|
+
import { getPaths } from "../lib/index.js";
|
|
8
|
+
const paths = getPaths();
|
|
9
|
+
function isREPLServerWithHistory(replServer) {
|
|
10
|
+
return "history" in replServer && "lines" in replServer;
|
|
11
|
+
}
|
|
12
|
+
const loadPrismaClient = (replContext) => {
|
|
13
|
+
const createdRequire = createRequire(import.meta.url);
|
|
14
|
+
const { db } = createdRequire(path.join(paths.api.lib, "db"));
|
|
15
|
+
db[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")] = "PrismaClient";
|
|
16
|
+
replContext.db = db;
|
|
17
|
+
};
|
|
18
|
+
const consoleHistoryFile = path.join(paths.generated.base, "console_history");
|
|
19
|
+
const persistConsoleHistory = (r) => {
|
|
20
|
+
const lines = isREPLServerWithHistory(r) ? r.lines : [];
|
|
21
|
+
fs.appendFileSync(
|
|
22
|
+
consoleHistoryFile,
|
|
23
|
+
lines.filter((line) => line.trim()).join("\n") + "\n",
|
|
24
|
+
"utf8"
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
const loadConsoleHistory = async (r) => {
|
|
28
|
+
try {
|
|
29
|
+
const history = await fs.promises.readFile(consoleHistoryFile, "utf8");
|
|
30
|
+
if (isREPLServerWithHistory(r)) {
|
|
31
|
+
history.split("\n").reverse().map((line) => r.history.push(line));
|
|
32
|
+
}
|
|
33
|
+
} catch {
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const handler = (_options) => {
|
|
37
|
+
recordTelemetryAttributes({
|
|
38
|
+
command: "console"
|
|
39
|
+
});
|
|
40
|
+
registerApiSideBabelHook({
|
|
41
|
+
plugins: [
|
|
42
|
+
[
|
|
43
|
+
"babel-plugin-module-resolver",
|
|
44
|
+
{
|
|
45
|
+
alias: {
|
|
46
|
+
src: paths.api.src
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"rwjs-console-module-resolver"
|
|
50
|
+
]
|
|
51
|
+
]
|
|
52
|
+
});
|
|
53
|
+
const r = repl.start();
|
|
54
|
+
const defaultEval = r.eval;
|
|
55
|
+
const asyncEval = (cmd, context, filename, callback) => {
|
|
56
|
+
defaultEval.call(r, cmd, context, filename, async (err, result) => {
|
|
57
|
+
if (err) {
|
|
58
|
+
callback(err, null);
|
|
59
|
+
} else {
|
|
60
|
+
try {
|
|
61
|
+
callback(null, await Promise.resolve(result));
|
|
62
|
+
} catch (err2) {
|
|
63
|
+
callback(err2 instanceof Error ? err2 : new Error(String(err2)), null);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
r.eval = asyncEval;
|
|
69
|
+
loadConsoleHistory(r);
|
|
70
|
+
r.addListener("close", () => persistConsoleHistory(r));
|
|
71
|
+
loadPrismaClient(r.context);
|
|
72
|
+
};
|
|
73
|
+
export {
|
|
74
|
+
handler
|
|
75
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
2
|
import path from "node:path";
|
|
4
3
|
import { Writable } from "node:stream";
|
|
5
4
|
import concurrently from "concurrently";
|
|
@@ -8,7 +7,6 @@ import { formatRunBinCommand } from "@cedarjs/cli-helpers/packageManager/display
|
|
|
8
7
|
import { shutdownPort } from "@cedarjs/internal/dist/dev";
|
|
9
8
|
import { generateGqlormArtifacts } from "@cedarjs/internal/dist/generate/gqlormSchema";
|
|
10
9
|
import { getConfig, getConfigPath } from "@cedarjs/project-config";
|
|
11
|
-
import { getPackageManager } from "@cedarjs/project-config/packageManager";
|
|
12
10
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
13
11
|
import { exitWithError } from "../../lib/exit.js";
|
|
14
12
|
import { generatePrismaClient } from "../../lib/generatePrismaClient.js";
|
|
@@ -17,39 +15,13 @@ import { getFreePort } from "../../lib/ports.js";
|
|
|
17
15
|
import { serverFileExists } from "../../lib/project.js";
|
|
18
16
|
import { getApiDebugFlag } from "./apiDebugFlag.js";
|
|
19
17
|
import { getPackageWatchCommands } from "./packageWatchCommands.js";
|
|
20
|
-
const createdRequire = createRequire(import.meta.url);
|
|
21
|
-
function formatViteDevBinCommand(binName, extraNodeArgs = "") {
|
|
22
|
-
let vitePackageJsonPath;
|
|
23
|
-
let vitePackageJson;
|
|
24
|
-
try {
|
|
25
|
-
vitePackageJsonPath = createdRequire.resolve("@cedarjs/vite/package.json");
|
|
26
|
-
vitePackageJson = createdRequire("@cedarjs/vite/package.json");
|
|
27
|
-
} catch (e) {
|
|
28
|
-
const message = e instanceof Error ? e.message : String(e);
|
|
29
|
-
throw new Error(
|
|
30
|
-
`Could not resolve @cedarjs/vite, which the dev server needs to run. Is it installed? (${message})`
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
const binRelativePath = vitePackageJson.bin?.[binName];
|
|
34
|
-
if (!binRelativePath) {
|
|
35
|
-
throw new Error(
|
|
36
|
-
`@cedarjs/vite does not declare a "${binName}" bin. This is a bug in CedarJS.`
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
const binPath = path.join(path.dirname(vitePackageJsonPath), binRelativePath);
|
|
40
|
-
const nodeLauncher = getPackageManager() === "yarn" ? "yarn node" : "node";
|
|
41
|
-
const flags = extraNodeArgs ? `${extraNodeArgs} ` : "";
|
|
42
|
-
return `${nodeLauncher} ${flags}"${binPath}"`;
|
|
43
|
-
}
|
|
44
18
|
const handler = async ({
|
|
45
19
|
workspace = ["api", "web", "packages/*"],
|
|
46
20
|
forward = "",
|
|
47
21
|
generate = true,
|
|
48
22
|
apiDebugPort,
|
|
49
23
|
debugBrk,
|
|
50
|
-
ud = false
|
|
51
|
-
nodeArgs = "",
|
|
52
|
-
jobs: jobsOption
|
|
24
|
+
ud = false
|
|
53
25
|
}) => {
|
|
54
26
|
recordTelemetryAttributes({
|
|
55
27
|
command: "dev",
|
|
@@ -202,16 +174,11 @@ const handler = async ({
|
|
|
202
174
|
return null;
|
|
203
175
|
}
|
|
204
176
|
return [
|
|
205
|
-
|
|
177
|
+
`${formatRunBinCommand("cross-env", ["NODE_ENV=development", "cedar-unified-dev"])}`,
|
|
206
178
|
` --port ${webAvailablePort}`,
|
|
207
179
|
` --apiPort ${apiAvailablePort}`,
|
|
208
180
|
getApiDebugFlag(apiDebugPort, apiAvailablePort),
|
|
209
181
|
debugBrk ? "--debug-brk" : "",
|
|
210
|
-
// `cedar-unified-dev` starts its own in-process jobs worker pool (see
|
|
211
|
-
// `jobsDevMiddleware.ts`) rather than relying on the nodemon-wrapped
|
|
212
|
-
// worker pushed below, so `--no-jobs` has to be forwarded explicitly -
|
|
213
|
-
// it isn't part of `forward` unless the user passed it after `--`.
|
|
214
|
-
jobsOption === false ? "--no-jobs" : "",
|
|
215
182
|
forward
|
|
216
183
|
].join(" ").replace(/\s+/g, " ").trim();
|
|
217
184
|
};
|
|
@@ -263,16 +230,13 @@ const handler = async ({
|
|
|
263
230
|
});
|
|
264
231
|
}
|
|
265
232
|
if (workspace.includes("web")) {
|
|
266
|
-
let webCommand = `${
|
|
233
|
+
let webCommand = `${formatRunBinCommand("cross-env", ["NODE_ENV=development", "cedar-vite-dev"])} ${forward}`;
|
|
267
234
|
if (streamingSsrEnabled) {
|
|
268
|
-
webCommand = `${
|
|
235
|
+
webCommand = `${formatRunBinCommand("cross-env", ["NODE_ENV=development", "cedar-dev-fe"])} ${forward}`;
|
|
269
236
|
}
|
|
270
237
|
jobs.push({
|
|
271
238
|
name: "web",
|
|
272
239
|
command: webCommand,
|
|
273
|
-
env: {
|
|
274
|
-
NODE_ENV: "development"
|
|
275
|
-
},
|
|
276
240
|
prefixColor: "blue",
|
|
277
241
|
cwd: cedarPaths.web.base,
|
|
278
242
|
runWhen: () => fs.existsSync(cedarPaths.web.src)
|
|
@@ -286,37 +250,6 @@ const handler = async ({
|
|
|
286
250
|
prefixColor: "green"
|
|
287
251
|
});
|
|
288
252
|
}
|
|
289
|
-
const jobsConfigured = jobsOption !== false && workspace.includes("api") && !!cedarPaths.api.jobsConfig && // `getPaths()` resolves `jobsConfig` once and caches it in-process, so
|
|
290
|
-
// if `api/src/lib/jobs.ts` is deleted mid-session the cached path would
|
|
291
|
-
// otherwise still look "configured". Guard against starting a worker
|
|
292
|
-
// that can't load a jobs config that no longer exists.
|
|
293
|
-
fs.existsSync(cedarPaths.api.jobsConfig) && fs.existsSync(cedarPaths.api.jobs) && // Job files always live in `api/src/jobs/<ComponentName>Job/`
|
|
294
|
-
// subdirectories (see `generate/job/jobHandler.ts`), so entries here are
|
|
295
|
-
// directories, not files — only the `.keep` placeholder (and any stray
|
|
296
|
-
// dotfiles, e.g. `.DS_Store`) should be excluded.
|
|
297
|
-
fs.readdirSync(cedarPaths.api.jobs).some((entry) => !entry.startsWith("."));
|
|
298
|
-
if (jobsConfigured && unifiedDevCommand) {
|
|
299
|
-
} else if (jobsConfigured) {
|
|
300
|
-
jobs.push({
|
|
301
|
-
name: "jobs",
|
|
302
|
-
// `cedar-jobs work` loads its config and job files from `api/dist`
|
|
303
|
-
// (compiled output), not `api/src`. That dist output is only written
|
|
304
|
-
// once the `api` watcher's initial build finishes, which happens
|
|
305
|
-
// asynchronously — so on a clean `cedar dev` start there's a window
|
|
306
|
-
// where `api/dist` doesn't exist yet and the worker would exit
|
|
307
|
-
// immediately. Wrapping it in nodemon (same tool the `api` job above
|
|
308
|
-
// uses) means it retries as soon as `api/dist` changes, instead of
|
|
309
|
-
// staying dead for the rest of the session. This also means the
|
|
310
|
-
// worker restarts automatically whenever job code is rebuilt, since
|
|
311
|
-
// Node's ESM cache would otherwise keep serving stale job code.
|
|
312
|
-
command: formatRunBinCommand("nodemon", [
|
|
313
|
-
"--quiet",
|
|
314
|
-
`--watch "${cedarPaths.api.dist}"`,
|
|
315
|
-
`--exec "${formatRunBinCommand("cedar-jobs", ["work"])}"`
|
|
316
|
-
]),
|
|
317
|
-
prefixColor: "magenta"
|
|
318
|
-
});
|
|
319
|
-
}
|
|
320
253
|
const packageWorkspaces = workspace.filter(
|
|
321
254
|
(w) => w !== "api" && w !== "web" && w !== "gen"
|
|
322
255
|
);
|
package/dist/commands/dev.js
CHANGED
|
@@ -13,7 +13,10 @@ const builder = (yargs) => {
|
|
|
13
13
|
}).option("forward", {
|
|
14
14
|
alias: "fwd",
|
|
15
15
|
description: 'String of one or more vite dev server config options, for example: `--fwd="--port=1234 --open=false"`',
|
|
16
|
-
type: "string"
|
|
16
|
+
type: "string",
|
|
17
|
+
// The reason `forward` is hidden is that it's been broken with Vite and
|
|
18
|
+
// it's not clear how to fix it.
|
|
19
|
+
hidden: true
|
|
17
20
|
}).option("generate", {
|
|
18
21
|
type: "boolean",
|
|
19
22
|
default: true,
|
|
@@ -28,12 +31,6 @@ const builder = (yargs) => {
|
|
|
28
31
|
type: "boolean",
|
|
29
32
|
default: false,
|
|
30
33
|
description: "Use the unified Vite dev server that handles both web and API in a single process (experimental)."
|
|
31
|
-
}).option("nodeArgs", {
|
|
32
|
-
type: "string",
|
|
33
|
-
description: 'CLI args to pass to the node process running the web dev server, for example: `--node-args="--inspect --max-old-space-size=8192"`.'
|
|
34
|
-
}).option("jobs", {
|
|
35
|
-
type: "boolean",
|
|
36
|
-
description: "Start the background jobs worker alongside the other dev servers when jobs are configured (`cedar setup jobs` + at least one `cedar g job`). Pass `--no-jobs` to opt out and run `cedar jobs work` yourself instead."
|
|
37
34
|
}).middleware(() => {
|
|
38
35
|
const check = checkNodeVersion();
|
|
39
36
|
if (check.ok) {
|
|
@@ -3,7 +3,6 @@ import path from "node:path";
|
|
|
3
3
|
import { context } from "@opentelemetry/api";
|
|
4
4
|
import { suppressTracing } from "@opentelemetry/core";
|
|
5
5
|
import { Listr } from "listr2";
|
|
6
|
-
import { Parser } from "yargs/helpers";
|
|
7
6
|
import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
|
|
8
7
|
import { findScripts } from "@cedarjs/internal/dist/files";
|
|
9
8
|
import { runScriptFunction } from "../lib/exec.js";
|
|
@@ -51,17 +50,6 @@ const handler = async (args) => {
|
|
|
51
50
|
delete scriptArgs.l;
|
|
52
51
|
delete scriptArgs.s;
|
|
53
52
|
delete scriptArgs.silent;
|
|
54
|
-
if (Array.isArray(scriptArgs._)) {
|
|
55
|
-
const dashBlockIndex = scriptArgs._.findIndex(
|
|
56
|
-
(arg) => typeof arg === "string" && arg.startsWith("-")
|
|
57
|
-
);
|
|
58
|
-
if (dashBlockIndex !== -1) {
|
|
59
|
-
const unparsedTail = scriptArgs._.splice(dashBlockIndex);
|
|
60
|
-
const { _: reparsedPositionals, ...reparsedFlags } = Parser(unparsedTail);
|
|
61
|
-
scriptArgs._.push(...reparsedPositionals);
|
|
62
|
-
Object.assign(scriptArgs, reparsedFlags);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
53
|
const scriptPath = resolveScriptPath(name);
|
|
66
54
|
if (!scriptPath) {
|
|
67
55
|
console.error(
|
|
@@ -114,7 +114,7 @@ const handler = async ({
|
|
|
114
114
|
},
|
|
115
115
|
task: (_ctx, task) => {
|
|
116
116
|
task.output = [
|
|
117
|
-
"Please add the following to your '
|
|
117
|
+
"Please add the following to your 'redwoodFastifyGraphQLServer' plugin options to enable OTel for your graphql",
|
|
118
118
|
"openTelemetryOptions: {",
|
|
119
119
|
" resolvers: true,",
|
|
120
120
|
" result: true,",
|
|
@@ -23,20 +23,6 @@ const validateName = (name) => {
|
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
const SENSITIVE_FIELDS = [
|
|
27
|
-
"hashedPassword",
|
|
28
|
-
"salt",
|
|
29
|
-
"resetToken",
|
|
30
|
-
"resetTokenExpiresAt",
|
|
31
|
-
"webAuthnChallenge"
|
|
32
|
-
];
|
|
33
|
-
const redactedModelFields = (fieldNames) => {
|
|
34
|
-
const sensitive = fieldNames.filter((name) => SENSITIVE_FIELDS.includes(name));
|
|
35
|
-
if (sensitive.length === 1 && sensitive[0] === "salt") {
|
|
36
|
-
return [];
|
|
37
|
-
}
|
|
38
|
-
return sensitive;
|
|
39
|
-
};
|
|
40
26
|
const relationsForModel = (model) => {
|
|
41
27
|
return model?.fields.filter((f) => f.relationName).map((field) => {
|
|
42
28
|
return field.name;
|
|
@@ -74,13 +60,11 @@ const mapPrismaScalarToPagePropTsType = (scalarType) => {
|
|
|
74
60
|
return prismaScalarToTsType[scalarType] || "unknown";
|
|
75
61
|
};
|
|
76
62
|
export {
|
|
77
|
-
SENSITIVE_FIELDS,
|
|
78
63
|
forcePluralizeWord,
|
|
79
64
|
intForeignKeysForModel,
|
|
80
65
|
mapPrismaScalarToPagePropTsType,
|
|
81
66
|
mapRouteParamTypeToTsType,
|
|
82
67
|
pathName,
|
|
83
|
-
redactedModelFields,
|
|
84
68
|
relationsForModel,
|
|
85
69
|
removeGeneratorName,
|
|
86
70
|
validateName
|
|
@@ -97,11 +97,13 @@ const handler = async ({
|
|
|
97
97
|
{
|
|
98
98
|
title: "Cleaning up...",
|
|
99
99
|
task: () => {
|
|
100
|
-
runBinSync(
|
|
101
|
-
"
|
|
102
|
-
|
|
103
|
-
{
|
|
104
|
-
|
|
100
|
+
runBinSync("eslint", [
|
|
101
|
+
"--fix",
|
|
102
|
+
"--config",
|
|
103
|
+
`${getPaths().base}/node_modules/@cedarjs/eslint-config/shared.js`,
|
|
104
|
+
`${getPaths().api.jobsConfig}`,
|
|
105
|
+
...Object.keys(jobFiles)
|
|
106
|
+
]);
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
],
|
|
@@ -8,7 +8,6 @@ const files = async ({
|
|
|
8
8
|
fileName,
|
|
9
9
|
typescript,
|
|
10
10
|
tests: generateTests = true,
|
|
11
|
-
esm = false,
|
|
12
11
|
...rest
|
|
13
12
|
}) => {
|
|
14
13
|
const extension = typescript ? ".ts" : ".js";
|
|
@@ -59,17 +58,6 @@ const files = async ({
|
|
|
59
58
|
outputPath: path.join(folderName, "src", `${fileName}.test${extension}`)
|
|
60
59
|
});
|
|
61
60
|
outputFiles.push(testFile);
|
|
62
|
-
if (esm) {
|
|
63
|
-
const vitestConfigFile = await templateForFile({
|
|
64
|
-
name,
|
|
65
|
-
side: "packages",
|
|
66
|
-
generator: "package",
|
|
67
|
-
templatePath: "vitest.config.ts.template",
|
|
68
|
-
templateVars: { folderName, ...rest },
|
|
69
|
-
outputPath: path.join(folderName, `vitest.config${extension}`)
|
|
70
|
-
});
|
|
71
|
-
outputFiles.push(vitestConfigFile);
|
|
72
|
-
}
|
|
73
61
|
}
|
|
74
62
|
return outputFiles.reduce(async (accP, [outputPath, content]) => {
|
|
75
63
|
const acc = await accP;
|
|
@@ -11,11 +11,11 @@ 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
13
|
import { addWorkspaceDir } from "@cedarjs/cli-helpers/packageManager/workspaces";
|
|
14
|
-
import { getConfig
|
|
14
|
+
import { getConfig } from "@cedarjs/project-config";
|
|
15
15
|
import { getPackageManager } from "@cedarjs/project-config/packageManager";
|
|
16
16
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
17
17
|
import { getPaths, writeFilesTask } from "../../../lib/index.js";
|
|
18
|
-
import {
|
|
18
|
+
import { prepareForRollback } from "../../../lib/rollback.js";
|
|
19
19
|
import { files } from "./filesTask.js";
|
|
20
20
|
function nameVariants(nameArg) {
|
|
21
21
|
const base = path.basename(getPaths().base);
|
|
@@ -32,10 +32,8 @@ async function updateTsconfig(task) {
|
|
|
32
32
|
path: path.join(getPaths().api.base, "tsconfig.json"),
|
|
33
33
|
expectedModule: "node20",
|
|
34
34
|
// While Cedar doesn't officially endorse NodeNext, it will still work
|
|
35
|
-
// here, so we'll keep it
|
|
36
|
-
|
|
37
|
-
// extensionless scaffold/generator imports resolve correctly.
|
|
38
|
-
acceptable: ["node20", "nodenext", "esnext"]
|
|
35
|
+
// here, so we'll keep it
|
|
36
|
+
acceptable: ["node20", "nodenext"]
|
|
39
37
|
},
|
|
40
38
|
{
|
|
41
39
|
name: "web",
|
|
@@ -248,9 +246,6 @@ function updateWorkspaceTsconfigReferences(task, folderName, targetWorkspaces) {
|
|
|
248
246
|
async function installAndBuild(folderName) {
|
|
249
247
|
const packagePath = path.join("packages", folderName);
|
|
250
248
|
await installPackages({ stdio: "inherit", cwd: getPaths().base });
|
|
251
|
-
addFileToRollback(
|
|
252
|
-
path.join(getPaths().base, packagePath, "tsconfig.tsbuildinfo")
|
|
253
|
-
);
|
|
254
249
|
await runScript("build", [], { stdio: "inherit", cwd: packagePath });
|
|
255
250
|
}
|
|
256
251
|
const handler = async ({
|
|
@@ -340,12 +335,7 @@ const handler = async ({
|
|
|
340
335
|
{
|
|
341
336
|
title: "Generating package files...",
|
|
342
337
|
task: async (ctx) => {
|
|
343
|
-
packageFiles = await files({
|
|
344
|
-
...ctx.nameVariants,
|
|
345
|
-
// Only Vitest projects get a config generated for them
|
|
346
|
-
esm: projectIsEsm(),
|
|
347
|
-
...rest
|
|
348
|
-
});
|
|
338
|
+
packageFiles = await files({ ...ctx.nameVariants, ...rest });
|
|
349
339
|
return writeFilesTask(packageFiles, { overwriteExisting: force });
|
|
350
340
|
}
|
|
351
341
|
},
|
|
@@ -417,9 +407,12 @@ const handler = async ({
|
|
|
417
407
|
{
|
|
418
408
|
title: "Cleaning up...",
|
|
419
409
|
task: () => {
|
|
420
|
-
runBinSync("eslint", [
|
|
421
|
-
|
|
422
|
-
|
|
410
|
+
runBinSync("eslint", [
|
|
411
|
+
"--fix",
|
|
412
|
+
"--config",
|
|
413
|
+
`${getPaths().base}/node_modules/@cedarjs/eslint-config/index.js`,
|
|
414
|
+
...Object.keys(packageFiles)
|
|
415
|
+
]);
|
|
423
416
|
}
|
|
424
417
|
}
|
|
425
418
|
],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ${camelName} } from './index.js'
|
|
2
2
|
|
|
3
3
|
describe('${camelName}', () => {
|
|
4
|
-
it('should not throw any errors', () => {
|
|
5
|
-
expect(
|
|
4
|
+
it('should not throw any errors', async () => {
|
|
5
|
+
expect(${camelName}()).not.toThrow()
|
|
6
6
|
})
|
|
7
7
|
})
|