@cedarjs/cli 0.7.2-next.2 → 0.7.2-next.49
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/experimental/util.js +3 -3
- package/dist/commands/generate/realtime/realtimeHandler.js +16 -12
- package/dist/commands/setup/realtime/realtimeHandler.js +16 -3
- package/dist/commands/setup/ui/libraries/tailwindcssHandler.js +1 -1
- package/dist/commands/testEsm.js +36 -0
- package/dist/commands/testHandlerEsm.js +86 -0
- package/dist/index.js +3 -1
- package/package.json +12 -12
|
@@ -40,7 +40,7 @@ const printTaskEpilogue = (command, description, topicId) => {
|
|
|
40
40
|
const isServerFileSetup = () => {
|
|
41
41
|
if (!serverFileExists()) {
|
|
42
42
|
throw new Error(
|
|
43
|
-
"
|
|
43
|
+
"CedarJS Realtime requires a serverful environment. Please run `yarn cedarjs setup server-file` first."
|
|
44
44
|
);
|
|
45
45
|
}
|
|
46
46
|
return true;
|
|
@@ -53,9 +53,9 @@ const realtimeExists = () => {
|
|
|
53
53
|
return fs.existsSync(realtimePath);
|
|
54
54
|
};
|
|
55
55
|
const isRealtimeSetup = () => {
|
|
56
|
-
if (!realtimeExists) {
|
|
56
|
+
if (!realtimeExists()) {
|
|
57
57
|
throw new Error(
|
|
58
|
-
"Adding realtime events requires that
|
|
58
|
+
"Adding realtime events requires that CedarJS Realtime is setup. Please run `yarn cedarjs setup realtime` first."
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
return true;
|
|
@@ -5,6 +5,7 @@ import pascalcase from "pascalcase";
|
|
|
5
5
|
import pluralize, { singular } from "pluralize";
|
|
6
6
|
import prompts from "prompts";
|
|
7
7
|
import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
|
|
8
|
+
import { projectIsEsm } from "@cedarjs/project-config";
|
|
8
9
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
9
10
|
import c from "../../../lib/colors.js";
|
|
10
11
|
import {
|
|
@@ -34,7 +35,7 @@ const templateVariables = (name) => {
|
|
|
34
35
|
subscriptionServiceResolver: `publishTo${pascalcase(name)}Channel`
|
|
35
36
|
};
|
|
36
37
|
};
|
|
37
|
-
async function handler({ name, type, force, verbose }) {
|
|
38
|
+
async function handler({ name, type, force, verbose, silent }) {
|
|
38
39
|
const redwoodPaths = getPaths();
|
|
39
40
|
const ts = isTypeScriptProject();
|
|
40
41
|
name = singular(name.toLowerCase());
|
|
@@ -112,6 +113,16 @@ async function handler({ name, type, force, verbose }) {
|
|
|
112
113
|
exampleFile,
|
|
113
114
|
exampleSubscriptionTemplateContent
|
|
114
115
|
);
|
|
116
|
+
let blankTemplateContent = await generateTemplate(
|
|
117
|
+
setupScriptContent,
|
|
118
|
+
templateVariables(name)
|
|
119
|
+
);
|
|
120
|
+
if (projectIsEsm()) {
|
|
121
|
+
blankTemplateContent = blankTemplateContent.replace(
|
|
122
|
+
"import gql from 'graphql-tag'",
|
|
123
|
+
"import { gql } from 'graphql-tag'"
|
|
124
|
+
);
|
|
125
|
+
}
|
|
115
126
|
return [
|
|
116
127
|
writeFile(
|
|
117
128
|
sdlFile,
|
|
@@ -127,16 +138,9 @@ async function handler({ name, type, force, verbose }) {
|
|
|
127
138
|
overwriteExisting: force
|
|
128
139
|
}
|
|
129
140
|
),
|
|
130
|
-
writeFile(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
setupScriptContent,
|
|
134
|
-
templateVariables(name)
|
|
135
|
-
),
|
|
136
|
-
{
|
|
137
|
-
overwriteExisting: force
|
|
138
|
-
}
|
|
139
|
-
)
|
|
141
|
+
writeFile(exampleFile, blankTemplateContent, {
|
|
142
|
+
overwriteExisting: force
|
|
143
|
+
})
|
|
140
144
|
];
|
|
141
145
|
}
|
|
142
146
|
},
|
|
@@ -199,7 +203,7 @@ async function handler({ name, type, force, verbose }) {
|
|
|
199
203
|
],
|
|
200
204
|
{
|
|
201
205
|
rendererOptions: { collapseSubtasks: false, persistentOutput: true },
|
|
202
|
-
renderer: verbose ? "verbose" : "default"
|
|
206
|
+
renderer: silent ? "silent" : verbose ? "verbose" : "default"
|
|
203
207
|
}
|
|
204
208
|
);
|
|
205
209
|
try {
|
|
@@ -3,6 +3,7 @@ import fs from "fs-extra";
|
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
4
|
import { addApiPackages } from "@cedarjs/cli-helpers";
|
|
5
5
|
import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
|
|
6
|
+
import { projectIsEsm } from "@cedarjs/project-config";
|
|
6
7
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
7
8
|
import c from "../../../lib/colors.js";
|
|
8
9
|
import { getPaths, transformTSToJS, writeFile } from "../../../lib/index.js";
|
|
@@ -50,7 +51,7 @@ async function handler({ force, includeExamples, verbose }) {
|
|
|
50
51
|
title: "Adding Countdown example subscription ...",
|
|
51
52
|
enabled: () => includeExamples,
|
|
52
53
|
task: async () => {
|
|
53
|
-
|
|
54
|
+
let exampleSubscriptionTemplateContent = fs.readFileSync(
|
|
54
55
|
path.resolve(
|
|
55
56
|
import.meta.dirname,
|
|
56
57
|
"templates",
|
|
@@ -60,6 +61,12 @@ async function handler({ force, includeExamples, verbose }) {
|
|
|
60
61
|
),
|
|
61
62
|
"utf-8"
|
|
62
63
|
);
|
|
64
|
+
if (projectIsEsm()) {
|
|
65
|
+
exampleSubscriptionTemplateContent = exampleSubscriptionTemplateContent.replace(
|
|
66
|
+
"import gql from 'graphql-tag'",
|
|
67
|
+
"import { gql } from 'graphql-tag'"
|
|
68
|
+
);
|
|
69
|
+
}
|
|
63
70
|
const exampleFile = path.join(
|
|
64
71
|
redwoodPaths.api.subscriptions,
|
|
65
72
|
"countdown",
|
|
@@ -111,16 +118,22 @@ async function handler({ force, includeExamples, verbose }) {
|
|
|
111
118
|
`rooms.${isTypeScriptProject() ? "ts" : "js"}`
|
|
112
119
|
);
|
|
113
120
|
const serviceContent = ts ? exampleServiceTemplateContent : await transformTSToJS(serviceFile, exampleServiceTemplateContent);
|
|
114
|
-
|
|
121
|
+
let exampleSubscriptionTemplateContent = fs.readFileSync(
|
|
115
122
|
path.resolve(
|
|
116
123
|
import.meta.dirname,
|
|
117
124
|
"templates",
|
|
118
125
|
"subscriptions",
|
|
119
126
|
"newMessage",
|
|
120
|
-
|
|
127
|
+
"newMessage.ts.template"
|
|
121
128
|
),
|
|
122
129
|
"utf-8"
|
|
123
130
|
);
|
|
131
|
+
if (projectIsEsm()) {
|
|
132
|
+
exampleSubscriptionTemplateContent = exampleSubscriptionTemplateContent.replace(
|
|
133
|
+
"import gql from 'graphql-tag'",
|
|
134
|
+
"import { gql } from 'graphql-tag'"
|
|
135
|
+
);
|
|
136
|
+
}
|
|
124
137
|
const exampleFile = path.join(
|
|
125
138
|
redwoodPaths.api.subscriptions,
|
|
126
139
|
"newMessage",
|
|
@@ -188,7 +188,7 @@ const handler = async ({ force, install }) => {
|
|
|
188
188
|
const newTailwindConfig = 'const { join } = require("node:path");\n\n' + tailwindConfig.replace(
|
|
189
189
|
"content: []",
|
|
190
190
|
"content: [join(__dirname, '../src/**/*.{js,jsx,ts,tsx}')]"
|
|
191
|
-
);
|
|
191
|
+
).replace("export default {", "module.exports = {");
|
|
192
192
|
fs.writeFileSync(tailwindConfigPath, newTailwindConfig);
|
|
193
193
|
}
|
|
194
194
|
},
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { terminalLink } from "termi-link";
|
|
2
|
+
import c from "../lib/colors.js";
|
|
3
|
+
import { sides } 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: sides(),
|
|
14
|
+
description: "Which side(s) to test, and/or a regular expression to match against your test files to filter by",
|
|
15
|
+
type: "array"
|
|
16
|
+
}).option("db-push", {
|
|
17
|
+
describe: "Syncs the test database with your Prisma schema without requiring a migration. It creates a test database if it doesn't already exist.",
|
|
18
|
+
type: "boolean",
|
|
19
|
+
default: true
|
|
20
|
+
}).epilogue(
|
|
21
|
+
`For all available flags, run vitest cli directly ${vitestTip}
|
|
22
|
+
|
|
23
|
+
Also see the ${cliDocsLink}
|
|
24
|
+
`
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
const handler = async (options) => {
|
|
28
|
+
const { handler: handler2 } = await import("./testHandlerEsm.js");
|
|
29
|
+
return handler2(options);
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
builder,
|
|
33
|
+
command,
|
|
34
|
+
description,
|
|
35
|
+
handler
|
|
36
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import execa from "execa";
|
|
2
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
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
|
+
const handler = async ({
|
|
8
|
+
filter: filterParams = [],
|
|
9
|
+
dbPush = true,
|
|
10
|
+
...others
|
|
11
|
+
}) => {
|
|
12
|
+
recordTelemetryAttributes({
|
|
13
|
+
command: "test",
|
|
14
|
+
dbPush
|
|
15
|
+
});
|
|
16
|
+
let watch = true;
|
|
17
|
+
const rwjsPaths = getPaths();
|
|
18
|
+
const forwardVitestFlags = Object.keys(others).flatMap((flagName) => {
|
|
19
|
+
if (["db-push", "loadEnvFiles", "$0", "_"].includes(flagName)) {
|
|
20
|
+
return [];
|
|
21
|
+
} else {
|
|
22
|
+
const flag = flagName.length > 1 ? `--${flagName}` : `-${flagName}`;
|
|
23
|
+
const flagValue = others[flagName];
|
|
24
|
+
if (flagName === "watch") {
|
|
25
|
+
watch = flagValue === true;
|
|
26
|
+
} else if (flagName === "run" && flagValue) {
|
|
27
|
+
watch = false;
|
|
28
|
+
}
|
|
29
|
+
if (Array.isArray(flagValue)) {
|
|
30
|
+
return flagValue.flatMap((val) => [flag, val]);
|
|
31
|
+
} else {
|
|
32
|
+
return [flag, flagValue];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const sides = filterParams.filter(
|
|
37
|
+
(filterString) => project.sides().includes(filterString)
|
|
38
|
+
);
|
|
39
|
+
const vitestFilterArgs = [
|
|
40
|
+
...filterParams.filter(
|
|
41
|
+
(filterString) => !project.sides().includes(filterString)
|
|
42
|
+
)
|
|
43
|
+
];
|
|
44
|
+
const vitestArgs = [
|
|
45
|
+
...vitestFilterArgs,
|
|
46
|
+
...forwardVitestFlags,
|
|
47
|
+
"--passWithNoTests"
|
|
48
|
+
].filter((flagOrValue) => flagOrValue !== null);
|
|
49
|
+
if (process.env.CI) {
|
|
50
|
+
vitestArgs.push("--run");
|
|
51
|
+
}
|
|
52
|
+
if (!sides.length) {
|
|
53
|
+
project.sides().forEach((side) => sides.push(side));
|
|
54
|
+
}
|
|
55
|
+
sides.forEach((side) => vitestArgs.push("--project", side));
|
|
56
|
+
try {
|
|
57
|
+
const cacheDirDb = `file:${ensurePosixPath(
|
|
58
|
+
rwjsPaths.generated.base
|
|
59
|
+
)}/test.db`;
|
|
60
|
+
const DATABASE_URL = process.env.TEST_DATABASE_URL || cacheDirDb;
|
|
61
|
+
if (sides.includes("api") && !dbPush) {
|
|
62
|
+
process.env.SKIP_DB_PUSH = "1";
|
|
63
|
+
}
|
|
64
|
+
const runCommand = async () => {
|
|
65
|
+
await execa("yarn vitest", vitestArgs, {
|
|
66
|
+
cwd: rwjsPaths.base,
|
|
67
|
+
shell: true,
|
|
68
|
+
stdio: "inherit",
|
|
69
|
+
env: { DATABASE_URL }
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
if (watch) {
|
|
73
|
+
await runCommand();
|
|
74
|
+
} else {
|
|
75
|
+
await timedTelemetry(process.argv, { type: "test" }, async () => {
|
|
76
|
+
await runCommand();
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
} catch (e) {
|
|
80
|
+
errorTelemetry(process.argv, e.message);
|
|
81
|
+
process.exit(e?.exitCode || 1);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
export {
|
|
85
|
+
handler
|
|
86
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import fs from "fs-extra";
|
|
|
5
5
|
import { hideBin, Parser } from "yargs/helpers";
|
|
6
6
|
import yargs from "yargs/yargs";
|
|
7
7
|
import { loadEnvFiles, recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
8
|
+
import { projectIsEsm } from "@cedarjs/project-config";
|
|
8
9
|
import { telemetryMiddleware } from "@cedarjs/telemetry";
|
|
9
10
|
import * as buildCommand from "./commands/build.js";
|
|
10
11
|
import * as checkCommand from "./commands/check.js";
|
|
@@ -25,6 +26,7 @@ import * as serveCommand from "./commands/serve.js";
|
|
|
25
26
|
import * as setupCommand from "./commands/setup.js";
|
|
26
27
|
import * as studioCommand from "./commands/studio.js";
|
|
27
28
|
import * as testCommand from "./commands/test.js";
|
|
29
|
+
import * as testCommandEsm from "./commands/testEsm.js";
|
|
28
30
|
import * as tstojsCommand from "./commands/ts-to-js.js";
|
|
29
31
|
import * as typeCheckCommand from "./commands/type-check.js";
|
|
30
32
|
import * as upgradeCommand from "./commands/upgrade.js";
|
|
@@ -126,7 +128,7 @@ async function runYargs() {
|
|
|
126
128
|
}).example(
|
|
127
129
|
"yarn rw g page home /",
|
|
128
130
|
"Create a page component named 'Home' at path '/'"
|
|
129
|
-
).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);
|
|
131
|
+
).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(projectIsEsm() ? testCommandEsm : testCommand).command(tstojsCommand).command(typeCheckCommand).command(upgradeCommand);
|
|
130
132
|
await loadPlugins(yarg);
|
|
131
133
|
const pkgJson = await import("../package.json", { with: { type: "json" } });
|
|
132
134
|
yarg.version(pkgJson.default["version"]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "0.7.2-next.
|
|
3
|
+
"version": "0.7.2-next.49+eaf36e897",
|
|
4
4
|
"description": "The Redwood Command Line",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,15 +32,15 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/preset-typescript": "7.27.1",
|
|
34
34
|
"@babel/runtime-corejs3": "7.27.6",
|
|
35
|
-
"@cedarjs/api-server": "0.7.2-next.
|
|
36
|
-
"@cedarjs/cli-helpers": "0.7.2-next.
|
|
37
|
-
"@cedarjs/fastify-web": "0.7.2-next.
|
|
38
|
-
"@cedarjs/internal": "0.7.2-next.
|
|
39
|
-
"@cedarjs/prerender": "0.7.2-next.
|
|
40
|
-
"@cedarjs/project-config": "0.7.2-next.
|
|
41
|
-
"@cedarjs/structure": "0.7.2-next.
|
|
42
|
-
"@cedarjs/telemetry": "0.7.2-next.
|
|
43
|
-
"@cedarjs/web-server": "0.7.2-next.
|
|
35
|
+
"@cedarjs/api-server": "0.7.2-next.49+eaf36e897",
|
|
36
|
+
"@cedarjs/cli-helpers": "0.7.2-next.49+eaf36e897",
|
|
37
|
+
"@cedarjs/fastify-web": "0.7.2-next.49+eaf36e897",
|
|
38
|
+
"@cedarjs/internal": "0.7.2-next.49+eaf36e897",
|
|
39
|
+
"@cedarjs/prerender": "0.7.2-next.49+eaf36e897",
|
|
40
|
+
"@cedarjs/project-config": "0.7.2-next.49+eaf36e897",
|
|
41
|
+
"@cedarjs/structure": "0.7.2-next.49+eaf36e897",
|
|
42
|
+
"@cedarjs/telemetry": "0.7.2-next.49+eaf36e897",
|
|
43
|
+
"@cedarjs/web-server": "0.7.2-next.49+eaf36e897",
|
|
44
44
|
"@listr2/prompt-adapter-enquirer": "2.0.16",
|
|
45
45
|
"@opentelemetry/api": "1.8.0",
|
|
46
46
|
"@opentelemetry/core": "1.22.0",
|
|
@@ -95,12 +95,12 @@
|
|
|
95
95
|
"@types/archiver": "^6",
|
|
96
96
|
"memfs": "4.17.2",
|
|
97
97
|
"node-ssh": "13.2.1",
|
|
98
|
-
"tsx": "4.20.
|
|
98
|
+
"tsx": "4.20.4",
|
|
99
99
|
"typescript": "5.6.2",
|
|
100
100
|
"vitest": "3.2.4"
|
|
101
101
|
},
|
|
102
102
|
"publishConfig": {
|
|
103
103
|
"access": "public"
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "eaf36e897609e775295faca150fe4a3b448841e3"
|
|
106
106
|
}
|