@cedarjs/cli 5.0.0-canary.2487 → 5.0.0-canary.2489
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/build/buildHandler.js +3 -2
- package/dist/commands/deploy/baremetal/SshExecutor.js +13 -4
- package/dist/commands/deploy/helpers/deployHandler.js +6 -2
- package/dist/commands/destroy/directive/directiveHandler.js +2 -4
- package/dist/commands/destroy/handlerHelpers.js +16 -20
- package/dist/commands/generate/cell/cellHandler.js +9 -6
- package/dist/commands/generate/component/componentHandler.js +10 -19
- package/dist/commands/generate/function/functionHandler.js +8 -22
- package/dist/commands/generate/job/jobHandler.js +2 -9
- package/dist/commands/generate/page/pageHandler.js +1 -4
- package/package.json +12 -12
|
@@ -278,13 +278,14 @@ Run ` + c.info(formatCedarCommand(["build"])) + " (without specifying a workspac
|
|
|
278
278
|
return buildUDApiServer({ verbose });
|
|
279
279
|
}
|
|
280
280
|
}
|
|
281
|
-
]
|
|
281
|
+
];
|
|
282
282
|
if (apiRootPath !== void 0) {
|
|
283
283
|
process.env.CEDAR_API_ROOT_PATH = apiRootPath;
|
|
284
284
|
}
|
|
285
285
|
try {
|
|
286
286
|
await timedTelemetry(process.argv, { type: "build" }, async () => {
|
|
287
|
-
const
|
|
287
|
+
const listrTasks = tasks.filter((t) => Boolean(t));
|
|
288
|
+
const jobs = new Listr(listrTasks, {
|
|
288
289
|
renderer: verbose ? "verbose" : void 0
|
|
289
290
|
});
|
|
290
291
|
await jobs.run();
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { NodeSSH } from "node-ssh";
|
|
2
|
+
class ExecError extends Error {
|
|
3
|
+
exitCode;
|
|
4
|
+
constructor(message, exitCode) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = "ExecError";
|
|
7
|
+
this.exitCode = exitCode;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
2
10
|
class SshExecutor {
|
|
11
|
+
ssh;
|
|
12
|
+
verbose;
|
|
3
13
|
constructor(verbose) {
|
|
4
14
|
this.ssh = new NodeSSH();
|
|
5
15
|
this.verbose = verbose;
|
|
@@ -20,12 +30,11 @@ class SshExecutor {
|
|
|
20
30
|
cwd: path
|
|
21
31
|
});
|
|
22
32
|
if (result.code !== 0) {
|
|
23
|
-
|
|
33
|
+
throw new ExecError(
|
|
24
34
|
`Error while running command \`${sshCommand}\` in ${path}
|
|
25
|
-
` + result.stderr
|
|
35
|
+
` + result.stderr,
|
|
36
|
+
result.code
|
|
26
37
|
);
|
|
27
|
-
error.exitCode = result.code;
|
|
28
|
-
throw error;
|
|
29
38
|
}
|
|
30
39
|
return result;
|
|
31
40
|
}
|
|
@@ -2,9 +2,13 @@ import execa from "execa";
|
|
|
2
2
|
import { colors as c } from "@cedarjs/cli-helpers";
|
|
3
3
|
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
4
4
|
import { getPaths } from "@cedarjs/project-config";
|
|
5
|
-
const deployHandler = ({
|
|
5
|
+
const deployHandler = ({
|
|
6
|
+
build,
|
|
7
|
+
prisma,
|
|
8
|
+
dm: dataMigrate
|
|
9
|
+
}) => {
|
|
6
10
|
const paths = getPaths();
|
|
7
|
-
|
|
11
|
+
const commandSet = [];
|
|
8
12
|
if (build) {
|
|
9
13
|
commandSet.push(formatCedarCommand(["build", "--verbose"]));
|
|
10
14
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { files as directiveFiles } from "../../generate/directive/directiveHandler.js";
|
|
2
2
|
import { createHandler } from "../handlerHelpers.js";
|
|
3
|
-
const
|
|
4
|
-
const { builder, tasks } = createHandler({
|
|
3
|
+
const { handler, tasks } = createHandler({
|
|
5
4
|
componentName: "directive",
|
|
6
5
|
filesFn: (args) => directiveFiles({ ...args, type: "validator" })
|
|
7
6
|
});
|
|
8
7
|
export {
|
|
9
|
-
|
|
10
|
-
description,
|
|
8
|
+
handler,
|
|
11
9
|
tasks
|
|
12
10
|
};
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import { Listr } from "listr2";
|
|
2
2
|
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
3
3
|
import { deleteFilesTask } from "../../lib/index.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const f = await filesFn({ name, stories: true, tests: true });
|
|
14
|
-
return deleteFilesTask(f);
|
|
4
|
+
function tasks({ componentName, filesFn, name }) {
|
|
5
|
+
return new Listr(
|
|
6
|
+
[
|
|
7
|
+
{
|
|
8
|
+
title: `Destroying ${componentName} files...`,
|
|
9
|
+
task: async () => {
|
|
10
|
+
const f = await filesFn({ name, stories: true, tests: true });
|
|
11
|
+
return deleteFilesTask(f);
|
|
12
|
+
}
|
|
15
13
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
],
|
|
15
|
+
{ rendererOptions: { collapseSubtasks: false }, exitOnError: true }
|
|
16
|
+
);
|
|
17
|
+
}
|
|
20
18
|
function createHandler({
|
|
21
19
|
componentName,
|
|
22
20
|
preTasksFn = (options) => options,
|
|
@@ -24,11 +22,9 @@ function createHandler({
|
|
|
24
22
|
}) {
|
|
25
23
|
return {
|
|
26
24
|
handler: async (options) => {
|
|
27
|
-
recordTelemetryAttributes({
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
options = await preTasksFn({ ...options, isDestroyer: true });
|
|
31
|
-
await tasks({ componentName, filesFn, name: options.name }).run();
|
|
25
|
+
recordTelemetryAttributes({ command: `destroy ${componentName}` });
|
|
26
|
+
const { name } = await preTasksFn({ ...options, isDestroyer: true });
|
|
27
|
+
await tasks({ componentName, filesFn, name }).run();
|
|
32
28
|
},
|
|
33
29
|
tasks
|
|
34
30
|
};
|
|
@@ -23,7 +23,10 @@ const CEDAR_WEB_PATH_NAME = "components";
|
|
|
23
23
|
const files = async ({
|
|
24
24
|
name,
|
|
25
25
|
typescript = false,
|
|
26
|
-
|
|
26
|
+
list = false,
|
|
27
|
+
query,
|
|
28
|
+
stories,
|
|
29
|
+
tests
|
|
27
30
|
}) => {
|
|
28
31
|
let cellName = removeGeneratorName(name, "cell");
|
|
29
32
|
let idName = "id";
|
|
@@ -32,7 +35,7 @@ const files = async ({
|
|
|
32
35
|
let model = null;
|
|
33
36
|
let templateNameSuffix = "";
|
|
34
37
|
let typeName = cellName;
|
|
35
|
-
const shouldGenerateList = (isWordPluralizable(cellName) ? isPlural(cellName) :
|
|
38
|
+
const shouldGenerateList = (isWordPluralizable(cellName) ? isPlural(cellName) : list) || list;
|
|
36
39
|
try {
|
|
37
40
|
model = await getSchema(pascalcase(singularize(cellName)));
|
|
38
41
|
idName = getIdName(model);
|
|
@@ -46,7 +49,7 @@ const files = async ({
|
|
|
46
49
|
cellName = forcePluralizeWord(cellName);
|
|
47
50
|
templateNameSuffix = "List";
|
|
48
51
|
}
|
|
49
|
-
let operationName =
|
|
52
|
+
let operationName = query;
|
|
50
53
|
if (operationName) {
|
|
51
54
|
const userSpecifiedOperationNameIsUnique = await operationNameIsUnique(operationName);
|
|
52
55
|
if (!userSpecifiedOperationNameIsUnique) {
|
|
@@ -105,13 +108,13 @@ const files = async ({
|
|
|
105
108
|
}
|
|
106
109
|
});
|
|
107
110
|
const files2 = [cellFile];
|
|
108
|
-
if (
|
|
111
|
+
if (stories) {
|
|
109
112
|
files2.push(storiesFile);
|
|
110
113
|
}
|
|
111
|
-
if (
|
|
114
|
+
if (tests) {
|
|
112
115
|
files2.push(testFile);
|
|
113
116
|
}
|
|
114
|
-
if (
|
|
117
|
+
if (stories || tests) {
|
|
115
118
|
files2.push(mockFile);
|
|
116
119
|
}
|
|
117
120
|
return transformTSToJSMap(files2, typescript);
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { transformTSToJSMap } from "../../../lib/index.js";
|
|
2
2
|
import {
|
|
3
3
|
createHandler,
|
|
4
4
|
templateForComponentFile
|
|
5
5
|
} from "../yargsHandlerHelpers.js";
|
|
6
|
-
const
|
|
6
|
+
const CEDAR_WEB_PATH_NAME = "components";
|
|
7
7
|
const files = async ({
|
|
8
8
|
name,
|
|
9
9
|
typescript = false,
|
|
10
|
-
|
|
10
|
+
stories,
|
|
11
|
+
tests
|
|
11
12
|
}) => {
|
|
12
13
|
const extension = typescript ? ".tsx" : ".jsx";
|
|
13
14
|
const componentFile = await templateForComponentFile({
|
|
14
15
|
name,
|
|
15
|
-
webPathSection:
|
|
16
|
+
webPathSection: CEDAR_WEB_PATH_NAME,
|
|
16
17
|
extension,
|
|
17
18
|
generator: "component",
|
|
18
19
|
templatePath: "component.tsx.template"
|
|
@@ -20,37 +21,27 @@ const files = async ({
|
|
|
20
21
|
const testFile = await templateForComponentFile({
|
|
21
22
|
name,
|
|
22
23
|
extension: `.test${extension}`,
|
|
23
|
-
webPathSection:
|
|
24
|
+
webPathSection: CEDAR_WEB_PATH_NAME,
|
|
24
25
|
generator: "component",
|
|
25
26
|
templatePath: "test.tsx.template"
|
|
26
27
|
});
|
|
27
28
|
const storiesFile = await templateForComponentFile({
|
|
28
29
|
name,
|
|
29
30
|
extension: `.stories${extension}`,
|
|
30
|
-
webPathSection:
|
|
31
|
+
webPathSection: CEDAR_WEB_PATH_NAME,
|
|
31
32
|
generator: "component",
|
|
32
33
|
// Using two different template files here because we have a TS-specific
|
|
33
34
|
// information in a comment in the .tsx template
|
|
34
35
|
templatePath: typescript ? "stories.tsx.template" : "stories.jsx.template"
|
|
35
36
|
});
|
|
36
37
|
const files2 = [componentFile];
|
|
37
|
-
if (
|
|
38
|
+
if (stories) {
|
|
38
39
|
files2.push(storiesFile);
|
|
39
40
|
}
|
|
40
|
-
if (
|
|
41
|
+
if (tests) {
|
|
41
42
|
files2.push(testFile);
|
|
42
43
|
}
|
|
43
|
-
return files2
|
|
44
|
-
async (accP, [outputPath, content]) => {
|
|
45
|
-
const acc = await accP;
|
|
46
|
-
const template = typescript ? content : await transformTSToJS(outputPath, content);
|
|
47
|
-
return {
|
|
48
|
-
[outputPath]: template,
|
|
49
|
-
...acc
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
Promise.resolve({})
|
|
53
|
-
);
|
|
44
|
+
return transformTSToJSMap(files2, typescript);
|
|
54
45
|
};
|
|
55
46
|
const handler = createHandler({
|
|
56
47
|
componentName: "component",
|
|
@@ -2,17 +2,17 @@ import { Listr } from "listr2";
|
|
|
2
2
|
import { terminalLink } from "termi-link";
|
|
3
3
|
import { recordTelemetryAttributes, colors as c } from "@cedarjs/cli-helpers";
|
|
4
4
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
5
|
-
import {
|
|
5
|
+
import { transformTSToJSMap, writeFilesTask } from "../../../lib/index.js";
|
|
6
6
|
import { prepareForRollback } from "../../../lib/rollback.js";
|
|
7
7
|
import { validateName } from "../helpers.js";
|
|
8
8
|
import { templateForComponentFile } from "../yargsHandlerHelpers.js";
|
|
9
9
|
const files = async ({
|
|
10
10
|
name,
|
|
11
|
-
typescript
|
|
12
|
-
tests
|
|
11
|
+
typescript = false,
|
|
12
|
+
tests = true,
|
|
13
13
|
...rest
|
|
14
14
|
}) => {
|
|
15
|
-
const extension =
|
|
15
|
+
const extension = typescript ? ".ts" : ".js";
|
|
16
16
|
const outputFiles = [];
|
|
17
17
|
const functionFiles = await templateForComponentFile({
|
|
18
18
|
name,
|
|
@@ -20,10 +20,10 @@ const files = async ({
|
|
|
20
20
|
apiPathSection: "functions",
|
|
21
21
|
generator: "function",
|
|
22
22
|
templatePath: "function.ts.template",
|
|
23
|
-
templateVars: { ...rest, typescript
|
|
23
|
+
templateVars: { ...rest, typescript }
|
|
24
24
|
});
|
|
25
25
|
outputFiles.push(functionFiles);
|
|
26
|
-
if (
|
|
26
|
+
if (tests) {
|
|
27
27
|
const testFile = await templateForComponentFile({
|
|
28
28
|
name,
|
|
29
29
|
extension: `.test${extension}`,
|
|
@@ -43,23 +43,9 @@ const files = async ({
|
|
|
43
43
|
outputFiles.push(testFile);
|
|
44
44
|
outputFiles.push(scenarioFile);
|
|
45
45
|
}
|
|
46
|
-
return outputFiles
|
|
47
|
-
async (accP, [outputPath, content]) => {
|
|
48
|
-
const acc = await accP;
|
|
49
|
-
const template = generateTypescript ? content : await transformTSToJS(outputPath, content);
|
|
50
|
-
return {
|
|
51
|
-
[outputPath]: template,
|
|
52
|
-
...acc
|
|
53
|
-
};
|
|
54
|
-
},
|
|
55
|
-
Promise.resolve({})
|
|
56
|
-
);
|
|
46
|
+
return transformTSToJSMap(outputFiles, typescript);
|
|
57
47
|
};
|
|
58
|
-
const handler = async ({
|
|
59
|
-
name,
|
|
60
|
-
force,
|
|
61
|
-
...rest
|
|
62
|
-
}) => {
|
|
48
|
+
const handler = async ({ name, force, ...rest }) => {
|
|
63
49
|
recordTelemetryAttributes({
|
|
64
50
|
command: "generate function",
|
|
65
51
|
force,
|
|
@@ -7,7 +7,7 @@ import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
|
7
7
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
8
8
|
import {
|
|
9
9
|
getPaths,
|
|
10
|
-
|
|
10
|
+
transformTSToJSMap,
|
|
11
11
|
writeFilesTask
|
|
12
12
|
} from "../../../lib/index.js";
|
|
13
13
|
import { prepareForRollback } from "../../../lib/rollback.js";
|
|
@@ -64,14 +64,7 @@ const files = async ({
|
|
|
64
64
|
outputFiles.push(testFile);
|
|
65
65
|
outputFiles.push(scenarioFile);
|
|
66
66
|
}
|
|
67
|
-
return outputFiles
|
|
68
|
-
const acc = await accP;
|
|
69
|
-
const template = typescript ? content : await transformTSToJS(outputPath, content);
|
|
70
|
-
return {
|
|
71
|
-
[outputPath]: template,
|
|
72
|
-
...acc
|
|
73
|
-
};
|
|
74
|
-
}, Promise.resolve({}));
|
|
67
|
+
return transformTSToJSMap(outputFiles, typescript);
|
|
75
68
|
};
|
|
76
69
|
const handler = async ({ name, force, ...rest }) => {
|
|
77
70
|
recordTelemetryAttributes({
|
|
@@ -21,9 +21,7 @@ import {
|
|
|
21
21
|
removeGeneratorName,
|
|
22
22
|
validateName
|
|
23
23
|
} from "../helpers.js";
|
|
24
|
-
import {
|
|
25
|
-
templateForComponentFile
|
|
26
|
-
} from "../yargsHandlerHelpers.js";
|
|
24
|
+
import { templateForComponentFile } from "../yargsHandlerHelpers.js";
|
|
27
25
|
const COMPONENT_SUFFIX = "Page";
|
|
28
26
|
const CEDAR_WEB_PATH_NAME = "pages";
|
|
29
27
|
function mapRouteParamTypeToDefaultValue(paramType) {
|
|
@@ -163,7 +161,6 @@ const handler = async ({
|
|
|
163
161
|
path = pathName(path, pageName);
|
|
164
162
|
const f = await files({
|
|
165
163
|
name: pageName,
|
|
166
|
-
path,
|
|
167
164
|
tests,
|
|
168
165
|
stories,
|
|
169
166
|
typescript,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "5.0.0-canary.
|
|
3
|
+
"version": "5.0.0-canary.2489",
|
|
4
4
|
"description": "The CedarJS Command Line",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@babel/parser": "7.29.3",
|
|
35
35
|
"@babel/preset-typescript": "7.28.5",
|
|
36
|
-
"@cedarjs/api-server": "5.0.0-canary.
|
|
37
|
-
"@cedarjs/cli-helpers": "5.0.0-canary.
|
|
38
|
-
"@cedarjs/fastify-web": "5.0.0-canary.
|
|
39
|
-
"@cedarjs/internal": "5.0.0-canary.
|
|
40
|
-
"@cedarjs/prerender": "5.0.0-canary.
|
|
41
|
-
"@cedarjs/project-config": "5.0.0-canary.
|
|
42
|
-
"@cedarjs/structure": "5.0.0-canary.
|
|
43
|
-
"@cedarjs/telemetry": "5.0.0-canary.
|
|
44
|
-
"@cedarjs/utils": "5.0.0-canary.
|
|
45
|
-
"@cedarjs/vite": "5.0.0-canary.
|
|
46
|
-
"@cedarjs/web-server": "5.0.0-canary.
|
|
36
|
+
"@cedarjs/api-server": "5.0.0-canary.2489",
|
|
37
|
+
"@cedarjs/cli-helpers": "5.0.0-canary.2489",
|
|
38
|
+
"@cedarjs/fastify-web": "5.0.0-canary.2489",
|
|
39
|
+
"@cedarjs/internal": "5.0.0-canary.2489",
|
|
40
|
+
"@cedarjs/prerender": "5.0.0-canary.2489",
|
|
41
|
+
"@cedarjs/project-config": "5.0.0-canary.2489",
|
|
42
|
+
"@cedarjs/structure": "5.0.0-canary.2489",
|
|
43
|
+
"@cedarjs/telemetry": "5.0.0-canary.2489",
|
|
44
|
+
"@cedarjs/utils": "5.0.0-canary.2489",
|
|
45
|
+
"@cedarjs/vite": "5.0.0-canary.2489",
|
|
46
|
+
"@cedarjs/web-server": "5.0.0-canary.2489",
|
|
47
47
|
"@listr2/prompt-adapter-enquirer": "4.2.1",
|
|
48
48
|
"@opentelemetry/api": "1.9.1",
|
|
49
49
|
"@opentelemetry/core": "1.30.1",
|