@cedarjs/cli 7.0.0-canary.2984 → 7.0.0-canary.2985
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/dev/devHandler.js +1 -3
- package/dist/commands/generate/cell/templates/test.js.template +1 -1
- package/dist/commands/generate/cell/templates/testFragment.js.template +1 -1
- package/dist/commands/generate/package/filesTask.js +9 -12
- package/dist/commands/generate/package/packageHandler.js +1 -3
- package/dist/commands/generate/realtime/realtimeHandler.js +1 -8
- package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.ts.template +1 -1
- package/dist/commands/generate/service/templates/test.ts.template +1 -1
- package/dist/commands/prerenderHandler.js +3 -3
- package/dist/commands/setup/realtime/realtimeHandler.js +2 -15
- package/dist/commands/setup/realtime/templates/subscriptions/countdown/countdown.ts.template +1 -1
- package/dist/commands/setup/realtime/templates/subscriptions/newMessage/newMessage.ts.template +1 -1
- package/dist/commands/test/testHandler.js +21 -71
- package/dist/commands/test.js +9 -17
- package/dist/index.js +2 -3
- package/package.json +13 -13
- package/dist/commands/test/testHandlerEsm.js +0 -100
- package/dist/commands/testEsm.js +0 -41
|
@@ -244,15 +244,13 @@ const handler = async ({
|
|
|
244
244
|
});
|
|
245
245
|
} else {
|
|
246
246
|
if (workspace.includes("api")) {
|
|
247
|
-
const isEsm = rootPackageJson.type === "module";
|
|
248
|
-
const serverWatchCommand = isEsm ? `cedarjs-api-server-watch` : `cedar-api-server-watch`;
|
|
249
247
|
const cedarConfigPath = getConfigPath();
|
|
250
248
|
jobs.push({
|
|
251
249
|
name: "api",
|
|
252
250
|
command: formatRunBinCommand("nodemon", [
|
|
253
251
|
"--quiet",
|
|
254
252
|
`--watch "${cedarConfigPath}"`,
|
|
255
|
-
`--exec "${formatRunBinCommand(
|
|
253
|
+
`--exec "${formatRunBinCommand("cedar-api-server-watch")} --port ${apiAvailablePort} ${getApiDebugFlag(apiDebugPort, apiAvailablePort)} | ${formatRunBinCommand("cedar-log-formatter")}"`
|
|
256
254
|
]),
|
|
257
255
|
env: {
|
|
258
256
|
NODE_ENV: "development",
|
|
@@ -7,7 +7,7 @@ import { standard } from './${pascalName}Cell.mock'
|
|
|
7
7
|
// and can fail without adjustments, e.g. Float and DateTime types.
|
|
8
8
|
// Please refer to the RedwoodJS Testing Docs:
|
|
9
9
|
// https://cedarjs.com/docs/testing#testing-cells
|
|
10
|
-
// https://cedarjs.com/docs/testing#
|
|
10
|
+
// https://cedarjs.com/docs/testing#expect-type-considerations
|
|
11
11
|
|
|
12
12
|
describe('${pascalName}Cell', () => {
|
|
13
13
|
it('renders Loading successfully', () => {
|
|
@@ -7,7 +7,7 @@ import { standard } from './${pascalName}Cell.mock'
|
|
|
7
7
|
// and can fail without adjustments, e.g. Float and DateTime types.
|
|
8
8
|
// Please refer to the RedwoodJS Testing Docs:
|
|
9
9
|
// https://cedarjs.com/docs/testing#testing-cells
|
|
10
|
-
// https://cedarjs.com/docs/testing#
|
|
10
|
+
// https://cedarjs.com/docs/testing#expect-type-considerations
|
|
11
11
|
|
|
12
12
|
describe('${pascalName}Cell', () => {
|
|
13
13
|
it('renders Empty successfully', async () => {
|
|
@@ -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,15 @@ const files = async ({
|
|
|
59
58
|
outputPath: path.join(folderName, "src", `${fileName}.test${extension}`)
|
|
60
59
|
});
|
|
61
60
|
outputFiles.push(testFile);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
outputFiles.push(vitestConfigFile);
|
|
72
|
-
}
|
|
61
|
+
const vitestConfigFile = await templateForFile({
|
|
62
|
+
name,
|
|
63
|
+
side: "packages",
|
|
64
|
+
generator: "package",
|
|
65
|
+
templatePath: "vitest.config.ts.template",
|
|
66
|
+
templateVars: { folderName, ...rest },
|
|
67
|
+
outputPath: path.join(folderName, `vitest.config${extension}`)
|
|
68
|
+
});
|
|
69
|
+
outputFiles.push(vitestConfigFile);
|
|
73
70
|
}
|
|
74
71
|
return outputFiles.reduce(async (accP, [outputPath, content]) => {
|
|
75
72
|
const acc = await accP;
|
|
@@ -11,7 +11,7 @@ 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";
|
|
@@ -342,8 +342,6 @@ const handler = async ({
|
|
|
342
342
|
task: async (ctx) => {
|
|
343
343
|
packageFiles = await files({
|
|
344
344
|
...ctx.nameVariants,
|
|
345
|
-
// Only Vitest projects get a config generated for them
|
|
346
|
-
esm: projectIsEsm(),
|
|
347
345
|
...rest
|
|
348
346
|
});
|
|
349
347
|
return writeFilesTask(packageFiles, { overwriteExisting: force });
|
|
@@ -6,7 +6,6 @@ import pluralize from "pluralize";
|
|
|
6
6
|
import prompts from "prompts";
|
|
7
7
|
import { colors as c } from "@cedarjs/cli-helpers";
|
|
8
8
|
import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
|
|
9
|
-
import { projectIsEsm } from "@cedarjs/project-config";
|
|
10
9
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
11
10
|
import {
|
|
12
11
|
generateTemplate,
|
|
@@ -120,16 +119,10 @@ async function handler({
|
|
|
120
119
|
exampleFile,
|
|
121
120
|
exampleSubscriptionTemplateContent
|
|
122
121
|
);
|
|
123
|
-
|
|
122
|
+
const blankTemplateContent = await generateTemplate(
|
|
124
123
|
setupScriptContent,
|
|
125
124
|
templateVariables(name)
|
|
126
125
|
);
|
|
127
|
-
if (projectIsEsm()) {
|
|
128
|
-
blankTemplateContent = blankTemplateContent.replace(
|
|
129
|
-
"import gql from 'graphql-tag'",
|
|
130
|
-
"import { gql } from 'graphql-tag'"
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
126
|
return [
|
|
134
127
|
writeFile(
|
|
135
128
|
sdlFile,
|
|
@@ -40,7 +40,7 @@ import type { StandardScenario } from './${pluralCamelName}.scenarios.js'
|
|
|
40
40
|
// and can fail without adjustments, e.g. Float.
|
|
41
41
|
// Please refer to the RedwoodJS Testing Docs:
|
|
42
42
|
// https://cedarjs.com/docs/testing#testing-services
|
|
43
|
-
// https://cedarjs.com/docs/testing#
|
|
43
|
+
// https://cedarjs.com/docs/testing#expect-type-considerations
|
|
44
44
|
|
|
45
45
|
describe('${pluralCamelName}', () => {
|
|
46
46
|
scenario('returns all ${pluralCamelName}', async (scenario: StandardScenario) => {
|
|
@@ -3,7 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
4
|
import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
|
|
5
5
|
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
6
|
-
import { getConfig, getPaths
|
|
6
|
+
import { getConfig, getPaths } from "@cedarjs/project-config";
|
|
7
7
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
8
8
|
import { runScriptFunction } from "../lib/exec.js";
|
|
9
9
|
import { configureBabel } from "../lib/execBabel.js";
|
|
@@ -93,7 +93,7 @@ async function expandRouteParameters(route) {
|
|
|
93
93
|
return [route];
|
|
94
94
|
}
|
|
95
95
|
const getTasks = async (dryrun, routerPathFilter = null) => {
|
|
96
|
-
const detector =
|
|
96
|
+
const detector = await import("@cedarjs/prerender/detection");
|
|
97
97
|
const detectedRoutes = detector.detectPrerenderRoutes();
|
|
98
98
|
const prerenderRoutes = detectedRoutes.filter(hasPath).map(normalizeRoute);
|
|
99
99
|
if (prerenderRoutes.length === 0) {
|
|
@@ -116,7 +116,7 @@ const getTasks = async (dryrun, routerPathFilter = null) => {
|
|
|
116
116
|
const expandedRouteParameters = await Promise.all(
|
|
117
117
|
prerenderRoutes.map((route) => expandRouteParameters(route))
|
|
118
118
|
);
|
|
119
|
-
const prerenderer =
|
|
119
|
+
const prerenderer = await import("@cedarjs/prerender");
|
|
120
120
|
const listrTasks = expandedRouteParameters.flatMap((routesToPrerender) => {
|
|
121
121
|
const queryCache = {};
|
|
122
122
|
const shouldFold = routesToPrerender.length > 16;
|
|
@@ -5,7 +5,6 @@ import prompts from "prompts";
|
|
|
5
5
|
import { addApiPackages, colors as c } from "@cedarjs/cli-helpers";
|
|
6
6
|
import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
7
7
|
import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
|
|
8
|
-
import { projectIsEsm } from "@cedarjs/project-config";
|
|
9
8
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
10
9
|
import { getPaths, transformTSToJS, writeFile } from "../../../lib/index.js";
|
|
11
10
|
import { isTypeScriptProject, serverFileExists } from "../../../lib/project.js";
|
|
@@ -77,7 +76,7 @@ async function handler(args) {
|
|
|
77
76
|
title: "Adding Countdown example subscription...",
|
|
78
77
|
enabled: () => includeExamples,
|
|
79
78
|
task: async () => {
|
|
80
|
-
|
|
79
|
+
const exampleSubscriptionTemplateContent = fs.readFileSync(
|
|
81
80
|
path.resolve(
|
|
82
81
|
import.meta.dirname,
|
|
83
82
|
"templates",
|
|
@@ -87,12 +86,6 @@ async function handler(args) {
|
|
|
87
86
|
),
|
|
88
87
|
"utf-8"
|
|
89
88
|
);
|
|
90
|
-
if (projectIsEsm()) {
|
|
91
|
-
exampleSubscriptionTemplateContent = exampleSubscriptionTemplateContent.replace(
|
|
92
|
-
"import gql from 'graphql-tag'",
|
|
93
|
-
"import { gql } from 'graphql-tag'"
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
89
|
const exampleFile = path.join(
|
|
97
90
|
cedarPaths.api.subscriptions,
|
|
98
91
|
"countdown",
|
|
@@ -144,7 +137,7 @@ async function handler(args) {
|
|
|
144
137
|
`rooms.${isTypeScriptProject() ? "ts" : "js"}`
|
|
145
138
|
);
|
|
146
139
|
const serviceContent = ts ? exampleServiceTemplateContent : await transformTSToJS(serviceFile, exampleServiceTemplateContent);
|
|
147
|
-
|
|
140
|
+
const exampleSubscriptionTemplateContent = fs.readFileSync(
|
|
148
141
|
path.resolve(
|
|
149
142
|
import.meta.dirname,
|
|
150
143
|
"templates",
|
|
@@ -154,12 +147,6 @@ async function handler(args) {
|
|
|
154
147
|
),
|
|
155
148
|
"utf-8"
|
|
156
149
|
);
|
|
157
|
-
if (projectIsEsm()) {
|
|
158
|
-
exampleSubscriptionTemplateContent = exampleSubscriptionTemplateContent.replace(
|
|
159
|
-
"import gql from 'graphql-tag'",
|
|
160
|
-
"import { gql } from 'graphql-tag'"
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
150
|
const exampleFile = path.join(
|
|
164
151
|
cedarPaths.api.subscriptions,
|
|
165
152
|
"newMessage",
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import execa from "execa";
|
|
4
|
-
import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
5
2
|
import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
6
3
|
import { ensurePosixPath } from "@cedarjs/project-config";
|
|
7
4
|
import { errorTelemetry, timedTelemetry } from "@cedarjs/telemetry";
|
|
@@ -17,73 +14,29 @@ function getExitCode(value) {
|
|
|
17
14
|
}
|
|
18
15
|
return value.exitCode;
|
|
19
16
|
}
|
|
20
|
-
function isInGitRepository() {
|
|
21
|
-
try {
|
|
22
|
-
execa.commandSync("git rev-parse --is-inside-work-tree");
|
|
23
|
-
return true;
|
|
24
|
-
} catch {
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function isInMercurialRepository() {
|
|
29
|
-
try {
|
|
30
|
-
execa.commandSync("hg --cwd . root");
|
|
31
|
-
return true;
|
|
32
|
-
} catch {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function isJestConfigFile(sides) {
|
|
37
|
-
for (const side of sides) {
|
|
38
|
-
try {
|
|
39
|
-
const jestConfigExists = fs.existsSync(path.join(side, "jest.config.js")) || fs.existsSync(path.join(side, "jest.config.ts"));
|
|
40
|
-
if (!jestConfigExists) {
|
|
41
|
-
console.error(
|
|
42
|
-
c.error(
|
|
43
|
-
`
|
|
44
|
-
Error: Missing Jest config file ${side}/jest.config.js
|
|
45
|
-
To add this file, run \`npx @cedarjs/codemods update-jest-config\`
|
|
46
|
-
`
|
|
47
|
-
)
|
|
48
|
-
);
|
|
49
|
-
throw new Error(`Error: Jest config file not found in ${side} side`);
|
|
50
|
-
}
|
|
51
|
-
} catch (error) {
|
|
52
|
-
const message = hasStringMessage(error) ? error.message : `Error: Jest config file not found in ${side} side`;
|
|
53
|
-
errorTelemetry(process.argv, message);
|
|
54
|
-
process.exit(getExitCode(error) ?? 1);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
17
|
const handler = async ({
|
|
59
18
|
filter: filterParams = [],
|
|
60
|
-
watch = true,
|
|
61
|
-
collectCoverage = false,
|
|
62
19
|
dbPush = true,
|
|
63
20
|
force = false,
|
|
64
21
|
...others
|
|
65
22
|
}) => {
|
|
66
23
|
recordTelemetryAttributes({
|
|
67
24
|
command: "test",
|
|
68
|
-
watch,
|
|
69
|
-
collectCoverage,
|
|
70
25
|
dbPush
|
|
71
26
|
});
|
|
27
|
+
let watch = true;
|
|
72
28
|
const rwjsPaths = getPaths();
|
|
73
|
-
const
|
|
74
|
-
if ([
|
|
75
|
-
"collect-coverage",
|
|
76
|
-
"db-push",
|
|
77
|
-
"force",
|
|
78
|
-
"loadEnvFiles",
|
|
79
|
-
"watch",
|
|
80
|
-
"$0",
|
|
81
|
-
"_"
|
|
82
|
-
].includes(flagName)) {
|
|
29
|
+
const forwardVitestFlags = Object.keys(others).flatMap((flagName) => {
|
|
30
|
+
if (["db-push", "force", "loadEnvFiles", "$0", "_"].includes(flagName)) {
|
|
83
31
|
return [];
|
|
84
32
|
}
|
|
85
33
|
const flag = flagName.length > 1 ? `--${flagName}` : `-${flagName}`;
|
|
86
34
|
const flagValue = others[flagName];
|
|
35
|
+
if (flagName === "watch") {
|
|
36
|
+
watch = flagValue === true;
|
|
37
|
+
} else if (flagName === "run" && flagValue) {
|
|
38
|
+
watch = false;
|
|
39
|
+
}
|
|
87
40
|
if (Array.isArray(flagValue)) {
|
|
88
41
|
return flagValue.flatMap((val) => [flag, val]);
|
|
89
42
|
}
|
|
@@ -92,28 +45,25 @@ const handler = async ({
|
|
|
92
45
|
const sides = filterParams.filter(
|
|
93
46
|
(filterString) => project.workspaces().includes(filterString)
|
|
94
47
|
);
|
|
95
|
-
const
|
|
48
|
+
const vitestFilterArgs = [
|
|
96
49
|
...filterParams.filter(
|
|
97
50
|
(filterString) => !project.workspaces().includes(filterString)
|
|
98
51
|
)
|
|
99
52
|
];
|
|
100
|
-
const
|
|
101
|
-
...
|
|
102
|
-
...
|
|
103
|
-
collectCoverage ? "--collectCoverage" : null,
|
|
53
|
+
const vitestArgs = [
|
|
54
|
+
...vitestFilterArgs,
|
|
55
|
+
...forwardVitestFlags,
|
|
104
56
|
"--passWithNoTests"
|
|
105
57
|
].filter((flagOrValue) => flagOrValue !== null);
|
|
106
|
-
if (
|
|
107
|
-
|
|
108
|
-
jestArgs.push(hasSourceControl ? "--watch" : "--watchAll");
|
|
109
|
-
}
|
|
110
|
-
if (!sides.length) {
|
|
111
|
-
project.workspaces().forEach((side) => sides.push(side));
|
|
58
|
+
if (process.env.CI) {
|
|
59
|
+
vitestArgs.push("--run");
|
|
112
60
|
}
|
|
113
|
-
if (
|
|
114
|
-
|
|
61
|
+
if (!others["config"]) {
|
|
62
|
+
sides.forEach((side) => vitestArgs.push("--project", side));
|
|
63
|
+
if (!sides.length) {
|
|
64
|
+
project.workspaces().forEach((side) => sides.push(side));
|
|
65
|
+
}
|
|
115
66
|
}
|
|
116
|
-
isJestConfigFile(sides);
|
|
117
67
|
try {
|
|
118
68
|
const cacheDirDb = `file:${ensurePosixPath(
|
|
119
69
|
rwjsPaths.generated.base
|
|
@@ -126,7 +76,7 @@ const handler = async ({
|
|
|
126
76
|
await warnIfNonStandardDatasourceUrl({ force });
|
|
127
77
|
}
|
|
128
78
|
const runCommand = async () => {
|
|
129
|
-
await runBin("
|
|
79
|
+
await runBin("vitest", vitestArgs, {
|
|
130
80
|
cwd: rwjsPaths.base,
|
|
131
81
|
stdio: "inherit",
|
|
132
82
|
env: { ...process.env, DATABASE_URL }
|
package/dist/commands/test.js
CHANGED
|
@@ -2,38 +2,30 @@ import { terminalLink } from "termi-link";
|
|
|
2
2
|
import { colors as c } from "@cedarjs/cli-helpers";
|
|
3
3
|
import { workspaces } from "../lib/project.js";
|
|
4
4
|
const command = "test [filter..]";
|
|
5
|
-
const description = "Run
|
|
5
|
+
const description = "Run Vitest tests. Defaults to watch mode";
|
|
6
6
|
const builder = (yargs) => {
|
|
7
|
+
const cliDocsLink = terminalLink(
|
|
8
|
+
"CedarJS CLI Reference",
|
|
9
|
+
"https://cedarjs.com/docs/cli-commands#test"
|
|
10
|
+
);
|
|
11
|
+
const vitestTip = c.tip("yarn vitest --help");
|
|
7
12
|
yargs.strict(false).positional("filter", {
|
|
8
13
|
default: workspaces(),
|
|
9
14
|
description: "Which side(s) to test, and/or a regular expression to match against your test files to filter by",
|
|
10
15
|
type: "string",
|
|
11
16
|
array: true
|
|
12
|
-
}).option("watch", {
|
|
13
|
-
describe: "Run tests related to changed files based on hg/git. Specify the name or path to a file to focus on a specific set of tests",
|
|
14
|
-
type: "boolean",
|
|
15
|
-
default: true
|
|
16
|
-
}).option("collect-coverage", {
|
|
17
|
-
describe: "Show test coverage summary and output info to coverage directory",
|
|
18
|
-
type: "boolean",
|
|
19
|
-
default: false
|
|
20
17
|
}).option("db-push", {
|
|
21
18
|
describe: "Syncs the test database with your Prisma schema without requiring a migration. It creates a test database if it doesn't already exist.",
|
|
22
19
|
type: "boolean",
|
|
23
20
|
default: true
|
|
24
21
|
}).option("force", {
|
|
25
|
-
describe: "
|
|
22
|
+
describe: "Skip any confirmation prompts and run tests without interruption. Useful in CI or scripted environments.",
|
|
26
23
|
type: "boolean",
|
|
27
24
|
default: false
|
|
28
25
|
}).epilogue(
|
|
29
|
-
`For all available flags, run
|
|
30
|
-
"yarn jest --help"
|
|
31
|
-
)}
|
|
26
|
+
`For all available flags, run vitest cli directly ${vitestTip}
|
|
32
27
|
|
|
33
|
-
Also see the ${
|
|
34
|
-
"CedarJS CLI Reference",
|
|
35
|
-
"https://cedarjs.com/docs/cli-commands#test"
|
|
36
|
-
)}
|
|
28
|
+
Also see the ${cliDocsLink}
|
|
37
29
|
`
|
|
38
30
|
);
|
|
39
31
|
};
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
recordTelemetryAttributes,
|
|
10
10
|
colors as c
|
|
11
11
|
} from "@cedarjs/cli-helpers";
|
|
12
|
-
import { findUp,
|
|
12
|
+
import { findUp, getConfigPath } from "@cedarjs/project-config";
|
|
13
13
|
import { telemetryMiddleware } from "@cedarjs/telemetry";
|
|
14
14
|
import * as buildCommand from "./commands/build.js";
|
|
15
15
|
import * as checkCommand from "./commands/check.js";
|
|
@@ -30,7 +30,6 @@ import * as serveCommand from "./commands/serve.js";
|
|
|
30
30
|
import * as setupCommand from "./commands/setup.js";
|
|
31
31
|
import * as studioCommand from "./commands/studio.js";
|
|
32
32
|
import * as testCommand from "./commands/test.js";
|
|
33
|
-
import * as testCommandEsm from "./commands/testEsm.js";
|
|
34
33
|
import * as tstojsCommand from "./commands/ts-to-js.js";
|
|
35
34
|
import * as typeCheckCommand from "./commands/type-check.js";
|
|
36
35
|
import * as upgradeCommand from "./commands/upgrade/upgrade.js";
|
|
@@ -135,7 +134,7 @@ async function runYargs() {
|
|
|
135
134
|
}).example(
|
|
136
135
|
"yarn cedar g page home /",
|
|
137
136
|
"Create a page component named 'Home' at path '/'"
|
|
138
|
-
).demandCommand().strict().exitProcess(false).alias("h", "help").command(buildCommand).command(checkCommand).command(consoleCommand).command(deployCommand).command(destroyCommand).command(devCommand).command(execCommand).command(experimentalCommand).command(generateCommand).command(infoCommand).command(jobsCommand).command(lintCommand).command(prerenderCommand).command(prismaCommand).command(recordCommand).command(serveCommand).command(setupCommand).command(studioCommand).command(
|
|
137
|
+
).demandCommand().strict().exitProcess(false).alias("h", "help").command(buildCommand).command(checkCommand).command(consoleCommand).command(deployCommand).command(destroyCommand).command(devCommand).command(execCommand).command(experimentalCommand).command(generateCommand).command(infoCommand).command(jobsCommand).command(lintCommand).command(prerenderCommand).command(prismaCommand).command(recordCommand).command(serveCommand).command(setupCommand).command(studioCommand).command(testCommand).command(tstojsCommand).command(typeCheckCommand).command(upgradeCommand);
|
|
139
138
|
await loadPlugins(yarg);
|
|
140
139
|
const pkgJson = await import("../package.json", { with: { type: "json" } });
|
|
141
140
|
yarg.version(pkgJson.default["version"]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "7.0.0-canary.
|
|
3
|
+
"version": "7.0.0-canary.2985",
|
|
4
4
|
"description": "The CedarJS Command Line",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -36,17 +36,17 @@
|
|
|
36
36
|
"@babel/preset-typescript": "7.29.7",
|
|
37
37
|
"@babel/traverse": "7.29.8",
|
|
38
38
|
"@babel/types": "7.29.8",
|
|
39
|
-
"@cedarjs/api-server": "7.0.0-canary.
|
|
40
|
-
"@cedarjs/babel-config": "7.0.0-canary.
|
|
41
|
-
"@cedarjs/cli-helpers": "7.0.0-canary.
|
|
42
|
-
"@cedarjs/internal": "7.0.0-canary.
|
|
43
|
-
"@cedarjs/prerender": "7.0.0-canary.
|
|
44
|
-
"@cedarjs/project-config": "7.0.0-canary.
|
|
45
|
-
"@cedarjs/structure": "7.0.0-canary.
|
|
46
|
-
"@cedarjs/telemetry": "7.0.0-canary.
|
|
47
|
-
"@cedarjs/utils": "7.0.0-canary.
|
|
48
|
-
"@cedarjs/vite": "7.0.0-canary.
|
|
49
|
-
"@cedarjs/web-server": "7.0.0-canary.
|
|
39
|
+
"@cedarjs/api-server": "7.0.0-canary.2985",
|
|
40
|
+
"@cedarjs/babel-config": "7.0.0-canary.2985",
|
|
41
|
+
"@cedarjs/cli-helpers": "7.0.0-canary.2985",
|
|
42
|
+
"@cedarjs/internal": "7.0.0-canary.2985",
|
|
43
|
+
"@cedarjs/prerender": "7.0.0-canary.2985",
|
|
44
|
+
"@cedarjs/project-config": "7.0.0-canary.2985",
|
|
45
|
+
"@cedarjs/structure": "7.0.0-canary.2985",
|
|
46
|
+
"@cedarjs/telemetry": "7.0.0-canary.2985",
|
|
47
|
+
"@cedarjs/utils": "7.0.0-canary.2985",
|
|
48
|
+
"@cedarjs/vite": "7.0.0-canary.2985",
|
|
49
|
+
"@cedarjs/web-server": "7.0.0-canary.2985",
|
|
50
50
|
"@listr2/prompt-adapter-enquirer": "4.3.0",
|
|
51
51
|
"@opentelemetry/api": "1.9.1",
|
|
52
52
|
"@opentelemetry/core": "1.30.1",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"yargs": "17.7.3"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
97
|
-
"@cedarjs/framework-tools": "7.0.0-canary.
|
|
97
|
+
"@cedarjs/framework-tools": "7.0.0-canary.2985",
|
|
98
98
|
"@prisma/dmmf": "7.8.0",
|
|
99
99
|
"@types/archiver": "^7.0.0",
|
|
100
100
|
"memfs": "4.68.1",
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
2
|
-
import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
3
|
-
import { ensurePosixPath } from "@cedarjs/project-config";
|
|
4
|
-
import { errorTelemetry, timedTelemetry } from "@cedarjs/telemetry";
|
|
5
|
-
import { getPaths } from "../../lib/index.js";
|
|
6
|
-
import * as project from "../../lib/project.js";
|
|
7
|
-
import { warnIfNonStandardDatasourceUrl } from "./datasourceWarning.js";
|
|
8
|
-
function hasStringMessage(value) {
|
|
9
|
-
return typeof value === "object" && value !== null && "message" in value && value.message === "string";
|
|
10
|
-
}
|
|
11
|
-
function getExitCode(value) {
|
|
12
|
-
if (!value || typeof value !== "object" || !("exitCode" in value) || typeof value.exitCode !== "number") {
|
|
13
|
-
return void 0;
|
|
14
|
-
}
|
|
15
|
-
return value.exitCode;
|
|
16
|
-
}
|
|
17
|
-
const handler = async ({
|
|
18
|
-
filter: filterParams = [],
|
|
19
|
-
dbPush = true,
|
|
20
|
-
force = false,
|
|
21
|
-
...others
|
|
22
|
-
}) => {
|
|
23
|
-
recordTelemetryAttributes({
|
|
24
|
-
command: "test",
|
|
25
|
-
dbPush
|
|
26
|
-
});
|
|
27
|
-
let watch = true;
|
|
28
|
-
const rwjsPaths = getPaths();
|
|
29
|
-
const forwardVitestFlags = Object.keys(others).flatMap((flagName) => {
|
|
30
|
-
if (["db-push", "force", "loadEnvFiles", "$0", "_"].includes(flagName)) {
|
|
31
|
-
return [];
|
|
32
|
-
}
|
|
33
|
-
const flag = flagName.length > 1 ? `--${flagName}` : `-${flagName}`;
|
|
34
|
-
const flagValue = others[flagName];
|
|
35
|
-
if (flagName === "watch") {
|
|
36
|
-
watch = flagValue === true;
|
|
37
|
-
} else if (flagName === "run" && flagValue) {
|
|
38
|
-
watch = false;
|
|
39
|
-
}
|
|
40
|
-
if (Array.isArray(flagValue)) {
|
|
41
|
-
return flagValue.flatMap((val) => [flag, val]);
|
|
42
|
-
}
|
|
43
|
-
return [flag, flagValue];
|
|
44
|
-
});
|
|
45
|
-
const sides = filterParams.filter(
|
|
46
|
-
(filterString) => project.workspaces().includes(filterString)
|
|
47
|
-
);
|
|
48
|
-
const vitestFilterArgs = [
|
|
49
|
-
...filterParams.filter(
|
|
50
|
-
(filterString) => !project.workspaces().includes(filterString)
|
|
51
|
-
)
|
|
52
|
-
];
|
|
53
|
-
const vitestArgs = [
|
|
54
|
-
...vitestFilterArgs,
|
|
55
|
-
...forwardVitestFlags,
|
|
56
|
-
"--passWithNoTests"
|
|
57
|
-
].filter((flagOrValue) => flagOrValue !== null);
|
|
58
|
-
if (process.env.CI) {
|
|
59
|
-
vitestArgs.push("--run");
|
|
60
|
-
}
|
|
61
|
-
if (!others["config"]) {
|
|
62
|
-
sides.forEach((side) => vitestArgs.push("--project", side));
|
|
63
|
-
if (!sides.length) {
|
|
64
|
-
project.workspaces().forEach((side) => sides.push(side));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
try {
|
|
68
|
-
const cacheDirDb = `file:${ensurePosixPath(
|
|
69
|
-
rwjsPaths.generated.base
|
|
70
|
-
)}/test.db`;
|
|
71
|
-
const DATABASE_URL = process.env.TEST_DATABASE_URL || cacheDirDb;
|
|
72
|
-
if (sides.includes("api") && !dbPush) {
|
|
73
|
-
process.env.SKIP_DB_PUSH = "1";
|
|
74
|
-
}
|
|
75
|
-
if (sides.includes("api")) {
|
|
76
|
-
await warnIfNonStandardDatasourceUrl({ force });
|
|
77
|
-
}
|
|
78
|
-
const runCommand = async () => {
|
|
79
|
-
await runBin("vitest", vitestArgs, {
|
|
80
|
-
cwd: rwjsPaths.base,
|
|
81
|
-
stdio: "inherit",
|
|
82
|
-
env: { ...process.env, DATABASE_URL }
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
if (watch) {
|
|
86
|
-
await runCommand();
|
|
87
|
-
} else {
|
|
88
|
-
await timedTelemetry(process.argv, { type: "test" }, async () => {
|
|
89
|
-
await runCommand();
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
} catch (error) {
|
|
93
|
-
const message = hasStringMessage(error) ? error.message : "Test command failed";
|
|
94
|
-
errorTelemetry(process.argv, message);
|
|
95
|
-
process.exit(getExitCode(error) ?? 1);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
export {
|
|
99
|
-
handler
|
|
100
|
-
};
|
package/dist/commands/testEsm.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { terminalLink } from "termi-link";
|
|
2
|
-
import { colors as c } from "@cedarjs/cli-helpers";
|
|
3
|
-
import { workspaces } from "../lib/project.js";
|
|
4
|
-
const command = "test [filter..]";
|
|
5
|
-
const description = "Run Vitest tests. Defaults to watch mode";
|
|
6
|
-
const builder = (yargs) => {
|
|
7
|
-
const cliDocsLink = terminalLink(
|
|
8
|
-
"CedarJS CLI Reference",
|
|
9
|
-
"https://cedarjs.com/docs/cli-commands#test"
|
|
10
|
-
);
|
|
11
|
-
const vitestTip = c.tip("yarn vitest --help");
|
|
12
|
-
yargs.strict(false).positional("filter", {
|
|
13
|
-
default: workspaces(),
|
|
14
|
-
description: "Which side(s) to test, and/or a regular expression to match against your test files to filter by",
|
|
15
|
-
type: "string",
|
|
16
|
-
array: true
|
|
17
|
-
}).option("db-push", {
|
|
18
|
-
describe: "Syncs the test database with your Prisma schema without requiring a migration. It creates a test database if it doesn't already exist.",
|
|
19
|
-
type: "boolean",
|
|
20
|
-
default: true
|
|
21
|
-
}).option("force", {
|
|
22
|
-
describe: "Skip any confirmation prompts and run tests without interruption. Useful in CI or scripted environments.",
|
|
23
|
-
type: "boolean",
|
|
24
|
-
default: false
|
|
25
|
-
}).epilogue(
|
|
26
|
-
`For all available flags, run vitest cli directly ${vitestTip}
|
|
27
|
-
|
|
28
|
-
Also see the ${cliDocsLink}
|
|
29
|
-
`
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
const handler = async (options) => {
|
|
33
|
-
const { handler: handler2 } = await import("./test/testHandlerEsm.js");
|
|
34
|
-
return handler2(options);
|
|
35
|
-
};
|
|
36
|
-
export {
|
|
37
|
-
builder,
|
|
38
|
-
command,
|
|
39
|
-
description,
|
|
40
|
-
handler
|
|
41
|
-
};
|