@cedarjs/cli 1.0.0-canary.13052 → 1.0.0-canary.13053
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/generate/script/scriptHandler.js +15 -14
- package/dist/commands/generate/yargsHandlerHelpers.js +2 -1
- package/dist/commands/setup/generator/generator.js +1 -7
- package/dist/commands/setup/generator/generatorHandler.js +7 -3
- package/dist/lib/test.js +1 -2
- package/package.json +11 -11
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
4
|
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
5
5
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
@@ -11,26 +11,27 @@ import {
|
|
|
11
11
|
} from "../../../lib/index.js";
|
|
12
12
|
import { prepareForRollback } from "../../../lib/rollback.js";
|
|
13
13
|
import { validateName } from "../helpers.js";
|
|
14
|
-
|
|
15
|
-
import.meta.dirname,
|
|
16
|
-
"templates",
|
|
17
|
-
"script.ts.template"
|
|
18
|
-
);
|
|
19
|
-
const TSCONFIG_TEMPLATE = path.resolve(
|
|
20
|
-
import.meta.dirname,
|
|
21
|
-
"templates",
|
|
22
|
-
"tsconfig.json.template"
|
|
23
|
-
);
|
|
14
|
+
import { customOrDefaultTemplatePath } from "../yargsHandlerHelpers.js";
|
|
24
15
|
const files = async ({ name, typescript = false }) => {
|
|
25
16
|
const outputFilename = `${name}.${typescript ? "ts" : "js"}`;
|
|
26
17
|
const outputPath = path.join(getPaths().scripts, outputFilename);
|
|
27
18
|
const scriptTsConfigPath = path.join(getPaths().scripts, "tsconfig.json");
|
|
28
|
-
const
|
|
19
|
+
const templatePath = customOrDefaultTemplatePath({
|
|
20
|
+
side: "scripts",
|
|
21
|
+
generator: "script",
|
|
22
|
+
templatePath: "script.ts.template"
|
|
23
|
+
});
|
|
24
|
+
const template = fs.readFileSync(templatePath, "utf-8");
|
|
25
|
+
const tsconfigTemplatePath = customOrDefaultTemplatePath({
|
|
26
|
+
side: "scripts",
|
|
27
|
+
generator: "script",
|
|
28
|
+
templatePath: "tsconfig.json.template"
|
|
29
|
+
});
|
|
29
30
|
return {
|
|
30
31
|
[outputPath]: typescript ? template : await transformTSToJS(outputPath, template),
|
|
31
32
|
// Add tsconfig for type and cmd+click support if project is TS
|
|
32
33
|
...typescript && !fs.existsSync(scriptTsConfigPath) && {
|
|
33
|
-
[scriptTsConfigPath]: fs.readFileSync(
|
|
34
|
+
[scriptTsConfigPath]: fs.readFileSync(tsconfigTemplatePath, "utf-8")
|
|
34
35
|
}
|
|
35
36
|
};
|
|
36
37
|
};
|
|
@@ -4,13 +4,7 @@ import { terminalLink } from "termi-link";
|
|
|
4
4
|
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
5
5
|
const command = "generator <name>";
|
|
6
6
|
const description = "Copies generator templates locally for customization";
|
|
7
|
-
const EXCLUDE_GENERATORS = [
|
|
8
|
-
"dataMigration",
|
|
9
|
-
"dbAuth",
|
|
10
|
-
"generator",
|
|
11
|
-
"script",
|
|
12
|
-
"secret"
|
|
13
|
-
];
|
|
7
|
+
const EXCLUDE_GENERATORS = ["dataMigration", "dbAuth", "generator", "secret"];
|
|
14
8
|
const builder = (yargs) => {
|
|
15
9
|
const availableGenerators = fs.readdirSync(path.join(import.meta.dirname, "../../generate"), {
|
|
16
10
|
withFileTypes: true
|
|
@@ -5,17 +5,21 @@ import c from "../../../lib/colors.js";
|
|
|
5
5
|
import { getPaths } from "../../../lib/index.js";
|
|
6
6
|
const SIDE_MAP = {
|
|
7
7
|
web: ["cell", "component", "layout", "page", "scaffold"],
|
|
8
|
-
api: ["function", "sdl", "service"]
|
|
8
|
+
api: ["function", "sdl", "service"],
|
|
9
|
+
scripts: ["script"]
|
|
9
10
|
};
|
|
10
11
|
const copyGenerator = (name, { force }) => {
|
|
11
|
-
const side = SIDE_MAP[
|
|
12
|
+
const side = Object.keys(SIDE_MAP).find((key) => SIDE_MAP[key].includes(name));
|
|
13
|
+
if (!side) {
|
|
14
|
+
throw new Error(`Invalid generator name: ${name}`);
|
|
15
|
+
}
|
|
12
16
|
const from = path.join(
|
|
13
17
|
import.meta.dirname,
|
|
14
18
|
"../../generate",
|
|
15
19
|
name,
|
|
16
20
|
"templates"
|
|
17
21
|
);
|
|
18
|
-
const to = path.join(getPaths()
|
|
22
|
+
const to = path.join(getPaths().generatorTemplates, side, name);
|
|
19
23
|
fse.copySync(from, to, { overwrite: force, errorOnExist: true });
|
|
20
24
|
return to;
|
|
21
25
|
};
|
package/dist/lib/test.js
CHANGED
|
@@ -25,7 +25,6 @@ vi.mock("@cedarjs/project-config", async (importOriginal) => {
|
|
|
25
25
|
"prisma.config.cjs"
|
|
26
26
|
),
|
|
27
27
|
dataMigrations: path.join(BASE_PATH, "./api/dataMigrations"),
|
|
28
|
-
generators: path.join(BASE_PATH, "./api/generators"),
|
|
29
28
|
src: path.join(BASE_PATH, "./api/src"),
|
|
30
29
|
jobs: path.join(BASE_PATH, "./api/src/jobs"),
|
|
31
30
|
services: path.join(BASE_PATH, "./api/src/services"),
|
|
@@ -37,7 +36,6 @@ vi.mock("@cedarjs/project-config", async (importOriginal) => {
|
|
|
37
36
|
base: path.join(BASE_PATH, "./web"),
|
|
38
37
|
config: path.join(BASE_PATH, "./web/config"),
|
|
39
38
|
src: path.join(BASE_PATH, "./web/src"),
|
|
40
|
-
generators: path.join(BASE_PATH, "./web/generators"),
|
|
41
39
|
routes: path.join(BASE_PATH, "web/src/Routes.js"),
|
|
42
40
|
components: path.join(BASE_PATH, "/web/src/components"),
|
|
43
41
|
layouts: path.join(BASE_PATH, "/web/src/layouts"),
|
|
@@ -45,6 +43,7 @@ vi.mock("@cedarjs/project-config", async (importOriginal) => {
|
|
|
45
43
|
app: path.join(BASE_PATH, "/web/src/App.js")
|
|
46
44
|
},
|
|
47
45
|
scripts: path.join(BASE_PATH, "scripts"),
|
|
46
|
+
generatorTemplates: path.join(BASE_PATH, "generatorTemplates"),
|
|
48
47
|
generated: {
|
|
49
48
|
base: path.join(BASE_PATH, ".redwood"),
|
|
50
49
|
schema: path.join(BASE_PATH, ".redwood/schema.graphql"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/cli",
|
|
3
|
-
"version": "1.0.0-canary.
|
|
3
|
+
"version": "1.0.0-canary.13053+a2d2ae402",
|
|
4
4
|
"description": "The CedarJS Command Line",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@babel/preset-typescript": "7.28.5",
|
|
33
33
|
"@babel/runtime-corejs3": "7.28.4",
|
|
34
|
-
"@cedarjs/api-server": "1.0.0-canary.
|
|
35
|
-
"@cedarjs/cli-helpers": "1.0.0-canary.
|
|
36
|
-
"@cedarjs/fastify-web": "1.0.0-canary.
|
|
37
|
-
"@cedarjs/internal": "1.0.0-canary.
|
|
38
|
-
"@cedarjs/prerender": "1.0.0-canary.
|
|
39
|
-
"@cedarjs/project-config": "1.0.0-canary.
|
|
40
|
-
"@cedarjs/structure": "1.0.0-canary.
|
|
41
|
-
"@cedarjs/telemetry": "1.0.0-canary.
|
|
42
|
-
"@cedarjs/web-server": "1.0.0-canary.
|
|
34
|
+
"@cedarjs/api-server": "1.0.0-canary.13053",
|
|
35
|
+
"@cedarjs/cli-helpers": "1.0.0-canary.13053",
|
|
36
|
+
"@cedarjs/fastify-web": "1.0.0-canary.13053",
|
|
37
|
+
"@cedarjs/internal": "1.0.0-canary.13053",
|
|
38
|
+
"@cedarjs/prerender": "1.0.0-canary.13053",
|
|
39
|
+
"@cedarjs/project-config": "1.0.0-canary.13053",
|
|
40
|
+
"@cedarjs/structure": "1.0.0-canary.13053",
|
|
41
|
+
"@cedarjs/telemetry": "1.0.0-canary.13053",
|
|
42
|
+
"@cedarjs/web-server": "1.0.0-canary.13053",
|
|
43
43
|
"@listr2/prompt-adapter-enquirer": "2.0.16",
|
|
44
44
|
"@opentelemetry/api": "1.8.0",
|
|
45
45
|
"@opentelemetry/core": "1.22.0",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"publishConfig": {
|
|
103
103
|
"access": "public"
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "a2d2ae402ab934d33b5824a5444d0c865a9e3624"
|
|
106
106
|
}
|