@cedarjs/cli 2.1.2-next.0 → 2.2.0-rc.101
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/{rwfw.js → cfw.js} +11 -14
- package/dist/commands/consoleHandler.js +1 -1
- package/dist/commands/deploy/baremetal/baremetalHandler.js +1 -1
- package/dist/commands/deploy/serverlessHandler.js +1 -1
- package/dist/commands/destroy/scaffold/scaffoldHandler.js +1 -1
- package/dist/commands/generate/cell/cellHandler.js +1 -1
- package/dist/commands/generate/cell/templates/test.js.template +2 -2
- package/dist/commands/generate/component/templates/test.tsx.template +1 -1
- package/dist/commands/generate/dbAuth/dbAuth.js +1 -1
- package/dist/commands/generate/dbAuth/dbAuthHandler.js +1 -1
- package/dist/commands/generate/directive/directiveHandler.js +6 -16
- package/dist/commands/generate/directive/templates/transformer.directive.ts.template +1 -1
- package/dist/commands/generate/directive/templates/validator.directive.ts.template +1 -1
- package/dist/commands/generate/function/functionHandler.js +10 -35
- package/dist/commands/generate/function/templates/function.ts.template +3 -3
- package/dist/commands/generate/function/templates/scenarios.ts.template +1 -1
- package/dist/commands/generate/function/templates/test.ts.template +2 -2
- package/dist/commands/generate/helpers.js +1 -1
- package/dist/commands/generate/job/jobHandler.js +26 -35
- package/dist/commands/generate/job/templates/scenarios.ts.template +1 -1
- package/dist/commands/generate/layout/templates/test.tsx.template +1 -1
- package/dist/commands/generate/model/model.js +1 -1
- package/dist/commands/generate/page/templates/test.tsx.template +1 -1
- package/dist/commands/generate/scaffold/scaffoldHandler.js +1 -1
- package/dist/commands/generate/sdl/sdlHandler.js +14 -47
- package/dist/commands/generate/service/serviceHandler.js +18 -21
- package/dist/commands/generate/service/templates/test.ts.template +2 -2
- package/dist/commands/generate/yargsCommandHelpers.js +12 -4
- package/dist/commands/generate/yargsHandlerHelpers.js +38 -14
- package/dist/commands/prerenderHandler.js +2 -2
- package/dist/commands/record.js +1 -1
- package/dist/commands/setup/auth/auth.js +1 -1
- package/dist/commands/setup/cache/cacheHandler.js +1 -1
- package/dist/commands/setup/deploy/providers/baremetalHandler.js +1 -1
- package/dist/commands/setup/deploy/providers/netlifyHandler.js +1 -1
- package/dist/commands/setup/deploy/providers/serverless.js +1 -1
- package/dist/commands/setup/deploy/providers/serverlessHandler.js +3 -3
- package/dist/commands/setup/deploy/providers/vercelHandler.js +1 -1
- package/dist/commands/setup/deploy/templates/baremetal.js +1 -1
- package/dist/commands/setup/docker/dockerHandler.js +1 -1
- package/dist/commands/setup/tsconfig/tsconfigHandler.js +1 -1
- package/dist/commands/setup/uploads/uploadsHandler.js +3 -3
- package/dist/commands/upgrade.js +269 -13
- package/dist/lib/exit.js +5 -9
- package/dist/lib/index.js +1 -1
- package/dist/lib/pluralHelpers.js +1 -1
- package/dist/lib/schemaHelpers.js +1 -1
- package/package.json +26 -25
- /package/dist/lib/{rwPluralize.js → cedarPluralize.js} +0 -0
|
@@ -1,12 +1,10 @@
|
|
|
1
|
+
import path from "node:path";
|
|
1
2
|
import camelcase from "camelcase";
|
|
3
|
+
import { pluralize, singularize } from "../../../lib/cedarPluralize.js";
|
|
2
4
|
import { transformTSToJS } from "../../../lib/index.js";
|
|
3
|
-
import { pluralize, singularize } from "../../../lib/rwPluralize.js";
|
|
4
5
|
import { getSchema, verifyModelName } from "../../../lib/schemaHelpers.js";
|
|
5
6
|
import { relationsForModel } from "../helpers.js";
|
|
6
|
-
import {
|
|
7
|
-
createHandler,
|
|
8
|
-
templateForComponentFile
|
|
9
|
-
} from "../yargsHandlerHelpers.js";
|
|
7
|
+
import { createHandler, templateForFile } from "../yargsHandlerHelpers.js";
|
|
10
8
|
const DEFAULT_SCENARIO_NAMES = ["one", "two"];
|
|
11
9
|
const parseSchema = async (model) => {
|
|
12
10
|
const schema = await getSchema(model);
|
|
@@ -221,24 +219,23 @@ const files = async ({
|
|
|
221
219
|
const componentName = camelcase(pluralize(name));
|
|
222
220
|
const model = name;
|
|
223
221
|
const idName = await getIdName(model);
|
|
224
|
-
const extension = "ts";
|
|
225
222
|
const modelRelations = relations || relationsForModel(await getSchema(model));
|
|
226
|
-
const serviceFile = await
|
|
223
|
+
const serviceFile = await templateForFile({
|
|
227
224
|
name,
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
apiPathSection: "services",
|
|
225
|
+
side: "api",
|
|
226
|
+
sidePathSection: "services",
|
|
231
227
|
generator: "service",
|
|
232
|
-
|
|
228
|
+
outputPath: path.join(componentName, componentName + ".ts"),
|
|
229
|
+
templatePath: "service.ts.template",
|
|
233
230
|
templateVars: { relations: modelRelations, idName, ...rest }
|
|
234
231
|
});
|
|
235
|
-
const testFile = await
|
|
232
|
+
const testFile = await templateForFile({
|
|
236
233
|
name,
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
apiPathSection: "services",
|
|
234
|
+
side: "api",
|
|
235
|
+
sidePathSection: "services",
|
|
240
236
|
generator: "service",
|
|
241
|
-
|
|
237
|
+
outputPath: path.join(componentName, componentName + ".test.ts"),
|
|
238
|
+
templatePath: "test.ts.template",
|
|
242
239
|
templateVars: {
|
|
243
240
|
relations: relations || [],
|
|
244
241
|
create: await fieldsToInput(model),
|
|
@@ -252,13 +249,13 @@ const files = async ({
|
|
|
252
249
|
...rest
|
|
253
250
|
}
|
|
254
251
|
});
|
|
255
|
-
const scenariosFile = await
|
|
252
|
+
const scenariosFile = await templateForFile({
|
|
256
253
|
name,
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
apiPathSection: "services",
|
|
254
|
+
side: "api",
|
|
255
|
+
sidePathSection: "services",
|
|
260
256
|
generator: "service",
|
|
261
|
-
|
|
257
|
+
outputPath: path.join(componentName, componentName + ".scenarios.ts"),
|
|
258
|
+
templatePath: "scenarios.ts.template",
|
|
262
259
|
templateVars: {
|
|
263
260
|
scenario: await buildScenario(model),
|
|
264
261
|
stringifiedScenario: await buildStringifiedScenario(model),
|
|
@@ -39,8 +39,8 @@ import type { StandardScenario } from './${pluralCamelName}.scenarios.js'
|
|
|
39
39
|
// Generated boilerplate tests do not account for all circumstances
|
|
40
40
|
// and can fail without adjustments, e.g. Float.
|
|
41
41
|
// Please refer to the RedwoodJS Testing Docs:
|
|
42
|
-
// https://
|
|
43
|
-
// https://
|
|
42
|
+
// https://cedarjs.com/docs/testing#testing-services
|
|
43
|
+
// https://cedarjs.com/docs/testing#jest-expect-type-considerations
|
|
44
44
|
|
|
45
45
|
describe('${pluralCamelName}', () => {
|
|
46
46
|
scenario('returns all ${pluralCamelName}', async (scenario: StandardScenario) => {
|
|
@@ -28,7 +28,12 @@ function createCommand(componentName, positionalsObj = {}) {
|
|
|
28
28
|
function createDescription(componentName) {
|
|
29
29
|
return `Generate a ${componentName} component`;
|
|
30
30
|
}
|
|
31
|
-
function createBuilder({
|
|
31
|
+
function createBuilder({
|
|
32
|
+
componentName,
|
|
33
|
+
optionsObj,
|
|
34
|
+
positionalsObj,
|
|
35
|
+
addStories
|
|
36
|
+
}) {
|
|
32
37
|
return (yargs) => {
|
|
33
38
|
yargs.positional("name", {
|
|
34
39
|
description: `Name of the ${componentName}`,
|
|
@@ -41,9 +46,6 @@ function createBuilder({ componentName, optionsObj, positionalsObj }) {
|
|
|
41
46
|
).option("tests", {
|
|
42
47
|
description: "Generate test files",
|
|
43
48
|
type: "boolean"
|
|
44
|
-
}).option("stories", {
|
|
45
|
-
description: "Generate storybook files",
|
|
46
|
-
type: "boolean"
|
|
47
49
|
}).option("verbose", {
|
|
48
50
|
description: "Print all logs",
|
|
49
51
|
type: "boolean",
|
|
@@ -53,6 +55,12 @@ function createBuilder({ componentName, optionsObj, positionalsObj }) {
|
|
|
53
55
|
type: "boolean",
|
|
54
56
|
default: true
|
|
55
57
|
});
|
|
58
|
+
if (addStories || typeof addStories === "undefined") {
|
|
59
|
+
yargs.option("stories", {
|
|
60
|
+
description: "Generate storybook files",
|
|
61
|
+
type: "boolean"
|
|
62
|
+
});
|
|
63
|
+
}
|
|
56
64
|
Object.entries(positionalsObj || {}).forEach(([option, config]) => {
|
|
57
65
|
yargs.positional(option, config);
|
|
58
66
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { camelCase } from "change-case";
|
|
3
4
|
import { Listr } from "listr2";
|
|
4
5
|
import pascalcase from "pascalcase";
|
|
5
6
|
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
@@ -35,34 +36,56 @@ const customOrDefaultTemplatePath = ({
|
|
|
35
36
|
return defaultPath;
|
|
36
37
|
}
|
|
37
38
|
};
|
|
38
|
-
const
|
|
39
|
+
const templateForFile = async ({
|
|
39
40
|
name,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
webPathSection,
|
|
43
|
-
apiPathSection,
|
|
41
|
+
side,
|
|
42
|
+
sidePathSection,
|
|
44
43
|
generator,
|
|
44
|
+
outputPath,
|
|
45
45
|
templatePath,
|
|
46
|
-
templateVars
|
|
47
|
-
componentName,
|
|
48
|
-
outputPath
|
|
46
|
+
templateVars
|
|
49
47
|
}) => {
|
|
50
|
-
const basePath =
|
|
51
|
-
const
|
|
52
|
-
const componentOutputPath = outputPath || path.join(basePath, outputComponentName, outputComponentName + extension);
|
|
48
|
+
const basePath = getPaths()[side][sidePathSection];
|
|
49
|
+
const fullOutputPath = path.join(basePath, outputPath);
|
|
53
50
|
const fullTemplatePath = customOrDefaultTemplatePath({
|
|
54
51
|
generator,
|
|
55
52
|
templatePath,
|
|
56
|
-
side
|
|
53
|
+
side
|
|
57
54
|
});
|
|
58
55
|
const content = await generateTemplate(fullTemplatePath, {
|
|
59
56
|
name,
|
|
60
57
|
outputPath: ensurePosixPath(
|
|
61
|
-
`./${path.relative(getPaths().base,
|
|
58
|
+
`./${path.relative(getPaths().base, fullOutputPath)}`
|
|
62
59
|
),
|
|
63
60
|
...templateVars
|
|
64
61
|
});
|
|
65
|
-
return [
|
|
62
|
+
return [fullOutputPath, content];
|
|
63
|
+
};
|
|
64
|
+
const templateForComponentFile = async ({
|
|
65
|
+
name,
|
|
66
|
+
suffix = "",
|
|
67
|
+
extension = ".js",
|
|
68
|
+
webPathSection,
|
|
69
|
+
apiPathSection,
|
|
70
|
+
generator,
|
|
71
|
+
templatePath,
|
|
72
|
+
templateVars
|
|
73
|
+
}) => {
|
|
74
|
+
const side = webPathSection ? "web" : "api";
|
|
75
|
+
const caseFn = side === "web" ? pascalcase : camelCase;
|
|
76
|
+
const componentName = caseFn(name) + suffix;
|
|
77
|
+
const outputPath = path.join(componentName, componentName + extension);
|
|
78
|
+
return templateForFile({
|
|
79
|
+
name,
|
|
80
|
+
suffix,
|
|
81
|
+
extension,
|
|
82
|
+
side,
|
|
83
|
+
sidePathSection: webPathSection || apiPathSection,
|
|
84
|
+
generator,
|
|
85
|
+
outputPath,
|
|
86
|
+
templatePath,
|
|
87
|
+
templateVars
|
|
88
|
+
});
|
|
66
89
|
};
|
|
67
90
|
const validateName = (name) => {
|
|
68
91
|
if (name.match(/^\W/)) {
|
|
@@ -151,5 +174,6 @@ export {
|
|
|
151
174
|
createYargsForComponentGeneration,
|
|
152
175
|
customOrDefaultTemplatePath,
|
|
153
176
|
templateForComponentFile,
|
|
177
|
+
templateForFile,
|
|
154
178
|
validateName
|
|
155
179
|
};
|
|
@@ -268,12 +268,12 @@ const handler = async ({ path: routerPath, dryRun, verbose }) => {
|
|
|
268
268
|
);
|
|
269
269
|
console.log(
|
|
270
270
|
c.info(
|
|
271
|
-
"- Avoid using `window` in the initial render path through your React components without checks. \n See https://
|
|
271
|
+
"- Avoid using `window` in the initial render path through your React components without checks. \n See https://cedarjs.com/docs/prerender#prerender-utils"
|
|
272
272
|
)
|
|
273
273
|
);
|
|
274
274
|
console.log(
|
|
275
275
|
c.info(
|
|
276
|
-
"- Avoid prerendering Cells with authenticated queries, by conditionally rendering them.\n See https://
|
|
276
|
+
"- Avoid prerendering Cells with authenticated queries, by conditionally rendering them.\n See https://cedarjs.com/docs/prerender#common-warnings--errors"
|
|
277
277
|
)
|
|
278
278
|
);
|
|
279
279
|
}
|
package/dist/commands/record.js
CHANGED
|
@@ -4,7 +4,7 @@ import { terminalLink } from "termi-link";
|
|
|
4
4
|
const builder = (yargs) => yargs.command({ command, description, handler }).demandCommand().epilogue(
|
|
5
5
|
`Also see the ${terminalLink(
|
|
6
6
|
"RedwoodRecord Docs",
|
|
7
|
-
"https://
|
|
7
|
+
"https://cedarjs.com/docs/redwoodrecord"
|
|
8
8
|
)}
|
|
9
9
|
`
|
|
10
10
|
);
|
|
@@ -181,7 +181,7 @@ function directToCustomAuthCommand(provider) {
|
|
|
181
181
|
});
|
|
182
182
|
const customAuthLink = terminalLink(
|
|
183
183
|
"Custom Auth",
|
|
184
|
-
"https://
|
|
184
|
+
"https://cedarjs.com/docs/auth/custom"
|
|
185
185
|
);
|
|
186
186
|
console.log(
|
|
187
187
|
`${provider} is no longer supported out of the box. But you can still integrate it yourself with ${customAuthLink}`
|
|
@@ -51,7 +51,7 @@ const handler = async ({ client, force }) => {
|
|
|
51
51
|
task.title = `One more thing...
|
|
52
52
|
|
|
53
53
|
${c.tip("Check out the Service Cache docs for config and usage:")}
|
|
54
|
-
${c.link("https://
|
|
54
|
+
${c.link("https://cedarjs.com/docs/services#caching")}
|
|
55
55
|
`;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -28,7 +28,7 @@ const files = [
|
|
|
28
28
|
const notes = [
|
|
29
29
|
"You are almost ready to go BAREMETAL!",
|
|
30
30
|
"",
|
|
31
|
-
"See https://
|
|
31
|
+
"See https://cedarjs.com/docs/deploy/baremetal for the remaining",
|
|
32
32
|
"config and setup required before you can perform your first deploy."
|
|
33
33
|
];
|
|
34
34
|
const handler = async ({ force }) => {
|
|
@@ -14,7 +14,7 @@ const files = [
|
|
|
14
14
|
];
|
|
15
15
|
const notes = [
|
|
16
16
|
"You are ready to deploy to Netlify!",
|
|
17
|
-
"See: https://
|
|
17
|
+
"See: https://cedarjs.com/docs/deploy/netlify"
|
|
18
18
|
];
|
|
19
19
|
const handler = async ({ force }) => {
|
|
20
20
|
recordTelemetryAttributes({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHandler } from "../helpers/helpers.js";
|
|
2
2
|
const command = "serverless";
|
|
3
|
-
const description = "[DEPRECATED]\nSetup Serverless Framework AWS deploy\nFor more information:\nhttps://
|
|
3
|
+
const description = "[DEPRECATED]\nSetup Serverless Framework AWS deploy\nFor more information:\nhttps://cedarjs.com/docs/deploy/serverless";
|
|
4
4
|
const aliases = ["aws-serverless"];
|
|
5
5
|
const handler = createHandler("serverless");
|
|
6
6
|
export {
|
|
@@ -21,12 +21,12 @@ const notes = [
|
|
|
21
21
|
c.error("DEPRECATED option not officially supported"),
|
|
22
22
|
"",
|
|
23
23
|
"For more information:",
|
|
24
|
-
"https://
|
|
24
|
+
"https://cedarjs.com/docs/deploy/serverless",
|
|
25
25
|
"",
|
|
26
26
|
"",
|
|
27
27
|
c.success("You're almost ready to deploy using the Serverless framework!"),
|
|
28
28
|
"",
|
|
29
|
-
"\u2022 See https://
|
|
29
|
+
"\u2022 See https://cedarjs.com/docs/deploy#serverless-deploy for more info. If you ",
|
|
30
30
|
" want to give it a shot, open your `.env` file and add your AWS credentials,",
|
|
31
31
|
" then run: ",
|
|
32
32
|
"",
|
|
@@ -77,7 +77,7 @@ const updateRedwoodTomlTask = () => {
|
|
|
77
77
|
const content = fs.readFileSync(configPath).toString();
|
|
78
78
|
const newContent = content.replace(
|
|
79
79
|
/apiUrl.*?\n/m,
|
|
80
|
-
'apiUrl = "${API_URL:/api}" # Set API_URL in production to the Serverless deploy endpoint of your api service, see https://
|
|
80
|
+
'apiUrl = "${API_URL:/api}" # Set API_URL in production to the Serverless deploy endpoint of your api service, see https://cedarjs.com/docs/deploy/serverless-deploy\n'
|
|
81
81
|
);
|
|
82
82
|
fs.writeFileSync(configPath, newContent);
|
|
83
83
|
}
|
|
@@ -25,7 +25,7 @@ const DEPLOY = `# This file contains config for a baremetal deployment
|
|
|
25
25
|
# * passphrase - used if your private key has a passphrase
|
|
26
26
|
# * agentForward - set to \`true\` to forward the client machine's ssh credentials
|
|
27
27
|
#
|
|
28
|
-
# See https://
|
|
28
|
+
# See https://cedarjs.com/docs/deploy/baremetal for more info
|
|
29
29
|
|
|
30
30
|
[[production.servers]]
|
|
31
31
|
host = "server.com"
|
|
@@ -233,7 +233,7 @@ async function handler({ force }) {
|
|
|
233
233
|
"Lastly, ensure you have Docker. If you don't, see https://docs.docker.com/desktop/",
|
|
234
234
|
"",
|
|
235
235
|
"There's a lot in the Dockerfile and there's a reason for every line.",
|
|
236
|
-
"Be sure to check out the docs: https://
|
|
236
|
+
"Be sure to check out the docs: https://cedarjs.com/docs/docker"
|
|
237
237
|
].join("\n")
|
|
238
238
|
);
|
|
239
239
|
} catch (e) {
|
|
@@ -39,7 +39,7 @@ const handler = async ({ force }) => {
|
|
|
39
39
|
task.title = `One more thing...
|
|
40
40
|
|
|
41
41
|
${c.tip("Quick link to the docs on configuring TypeScript")}
|
|
42
|
-
${c.link("https://
|
|
42
|
+
${c.link("https://cedarjs.com/docs/typescript")}
|
|
43
43
|
`;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -77,11 +77,11 @@ const handler = async ({ force }) => {
|
|
|
77
77
|
if (transformResult.error) {
|
|
78
78
|
if (transformResult.error === "RW_CODEMOD_ERR_OLD_FORMAT") {
|
|
79
79
|
throw new Error(
|
|
80
|
-
"It looks like your src/lib/db file is using the old format. Please update it as per the v8 upgrade guide: https://
|
|
80
|
+
"It looks like your src/lib/db file is using the old format. Please update it as per the v8 upgrade guide: https://cedarjs.com/docs/upgrade-guides/v8#database-file-structure-change. And run again. \n\nYou can also manually modify your api/src/lib/db to include the prisma extension: https://cedarjs.com/docs/uploads/#attaching-the-prisma-extension"
|
|
81
81
|
);
|
|
82
82
|
}
|
|
83
83
|
throw new Error(
|
|
84
|
-
"Could not add the prisma extension. \n Please modify your api/src/lib/db to include the prisma extension: https://
|
|
84
|
+
"Could not add the prisma extension. \n Please modify your api/src/lib/db to include the prisma extension: https://cedarjs.com/docs/uploads/#attaching-the-prisma-extension"
|
|
85
85
|
);
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -124,7 +124,7 @@ const handler = async ({ force }) => {
|
|
|
124
124
|
|
|
125
125
|
|
|
126
126
|
Check out the docs for more info:
|
|
127
|
-
${c.link("https://
|
|
127
|
+
${c.link("https://cedarjs.com/docs/uploads")}
|
|
128
128
|
|
|
129
129
|
`;
|
|
130
130
|
}
|