@cedarjs/cli 4.2.1-next.0 → 4.2.1-next.258
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/cfw.js +8 -6
- package/dist/commands/build/buildHandler.js +43 -42
- package/dist/commands/build/buildPackagesTask.js +6 -6
- package/dist/commands/build.js +7 -1
- package/dist/commands/deploy/baremetal/SshExecutor.js +13 -4
- package/dist/commands/deploy/baremetal/baremetalHandler.js +117 -65
- package/dist/commands/deploy/baremetal.js +24 -3
- package/dist/commands/deploy/flightcontrolHandler.js +16 -14
- package/dist/commands/deploy/helpers/deployHandler.js +10 -5
- package/dist/commands/deploy/packing/nft.js +1 -2
- package/dist/commands/deploy/render.js +1 -1
- package/dist/commands/deploy/renderHandler.js +22 -12
- package/dist/commands/deploy/serverlessHandler.js +67 -25
- package/dist/commands/destroy/component/component.js +2 -3
- package/dist/commands/destroy/directive/directive.js +1 -3
- package/dist/commands/destroy/directive/directiveHandler.js +2 -4
- package/dist/commands/destroy/function/function.js +1 -3
- package/dist/commands/destroy/handlerHelpers.js +16 -16
- package/dist/commands/destroy/helpers.js +8 -2
- package/dist/commands/destroy/layout/layout.js +1 -2
- package/dist/commands/destroy/page/pageHandler.js +1 -1
- package/dist/commands/destroy/scaffold/scaffoldHandler.js +28 -9
- package/dist/commands/destroy/sdl/sdlHandler.js +1 -1
- package/dist/commands/dev/devHandler.js +25 -25
- package/dist/commands/dev.js +3 -0
- package/dist/commands/experimental/live-queries/liveQueriesHandler.js +110 -4
- package/dist/commands/experimental/setupInngest.js +1 -1
- package/dist/commands/experimental/setupInngestHandler.js +12 -11
- package/dist/commands/experimental/setupOpentelemetry.js +1 -1
- package/dist/commands/experimental/setupOpentelemetryHandler.js +11 -7
- package/dist/commands/experimental/setupReactCompiler.js +1 -1
- package/dist/commands/experimental/setupReactCompilerHandler.js +45 -30
- package/dist/commands/experimental/setupRscHandler.js +14 -11
- package/dist/commands/experimental/setupStreamingSsr.js +1 -1
- package/dist/commands/experimental/setupStreamingSsrHandler.js +46 -31
- package/dist/commands/experimental/templates/rsc/Document.tsx.template +1 -1
- package/dist/commands/experimental/templates/rsc/entry.client.tsx.template +8 -8
- package/dist/commands/experimental/templates/streamingSsr/Document.tsx.template +1 -1
- package/dist/commands/experimental/templates/streamingSsr/entry.client.tsx.template +6 -6
- package/dist/commands/experimental/util.js +3 -2
- package/dist/commands/generate/cell/cellHandler.js +22 -21
- package/dist/commands/generate/component/componentHandler.js +14 -16
- package/dist/commands/generate/dataMigration/dataMigration.js +24 -13
- package/dist/commands/generate/dbAuth/dbAuth.js +1 -0
- package/dist/commands/generate/dbAuth/dbAuthHandler.js +40 -30
- package/dist/commands/generate/directive/directiveHandler.js +12 -14
- package/dist/commands/generate/function/function.js +1 -0
- package/dist/commands/generate/function/functionHandler.js +12 -17
- package/dist/commands/generate/helpers.js +17 -17
- package/dist/commands/generate/job/job.js +1 -0
- package/dist/commands/generate/job/jobHandler.js +15 -17
- package/dist/commands/generate/layout/layoutHandler.js +13 -16
- package/dist/commands/generate/model/model.js +1 -0
- package/dist/commands/generate/model/modelHandler.js +9 -3
- package/dist/commands/generate/ogImage/ogImage.js +1 -0
- package/dist/commands/generate/ogImage/ogImageHandler.js +16 -9
- package/dist/commands/generate/package/packageHandler.js +32 -49
- package/dist/commands/generate/page/pageHandler.js +25 -22
- package/dist/commands/generate/realtime/realtime.js +1 -1
- package/dist/commands/generate/realtime/realtimeHandler.js +46 -20
- package/dist/commands/generate/scaffold/scaffold.js +1 -0
- package/dist/commands/generate/scaffold/scaffoldHandler.js +35 -27
- package/dist/commands/generate/script/script.js +1 -0
- package/dist/commands/generate/script/templates/tsconfig.json.template +14 -0
- package/dist/commands/generate/sdl/sdl.js +4 -3
- package/dist/commands/generate/sdl/sdlHandler.js +38 -18
- package/dist/commands/generate/secret/secret.js +19 -19
- package/dist/commands/generate/service/service.js +5 -5
- package/dist/commands/generate/service/serviceHandler.js +59 -22
- package/dist/commands/generate/yargsCommandHelpers.js +6 -1
- package/dist/commands/generate/yargsHandlerHelpers.js +18 -10
- package/dist/commands/generate.js +3 -10
- package/dist/commands/jobsHandler.js +3 -2
- package/dist/commands/prismaHandler.js +10 -9
- package/dist/commands/serve.js +84 -137
- package/dist/commands/serveApiHandler.js +5 -5
- package/dist/commands/serveBothHandler.js +10 -7
- package/dist/commands/serveWebHandler.js +2 -2
- package/dist/commands/setup/auth/auth.js +12 -6
- package/dist/commands/setup/cache/cacheHandler.js +11 -6
- package/dist/commands/setup/deploy/deploy.js +4 -3
- package/dist/commands/setup/deploy/helpers/helpers.js +5 -1
- package/dist/commands/setup/deploy/helpers/index.js +157 -5
- package/dist/commands/setup/deploy/providers/baremetalHandler.js +26 -4
- package/dist/commands/setup/deploy/providers/coherenceHandler.js +53 -25
- package/dist/commands/setup/deploy/providers/flightcontrolHandler.js +33 -23
- package/dist/commands/setup/deploy/providers/netlify.js +6 -0
- package/dist/commands/setup/deploy/providers/netlifyHandler.js +112 -11
- package/dist/commands/setup/deploy/providers/renderHandler.js +10 -5
- package/dist/commands/setup/deploy/providers/serverlessHandler.js +5 -3
- package/dist/commands/setup/deploy/providers/universal-deploy.js +11 -0
- package/dist/commands/setup/deploy/providers/universalDeployHandler.js +188 -0
- package/dist/commands/setup/deploy/providers/vercel.js +6 -0
- package/dist/commands/setup/deploy/providers/vercelHandler.js +113 -12
- package/dist/commands/setup/deploy/templates/baremetal.js +3 -2
- package/dist/commands/setup/deploy/templates/flightcontrol.js +60 -49
- package/dist/commands/setup/deploy/templates/netlify.js +2 -1
- package/dist/commands/setup/deploy/templates/netlifyUD.js +31 -0
- package/dist/commands/setup/docker/docker.js +1 -1
- package/dist/commands/setup/docker/dockerHandler.js +72 -37
- package/dist/commands/setup/docker/templates/Dockerfile.npm +119 -0
- package/dist/commands/setup/docker/templates/Dockerfile.pnpm +112 -0
- package/dist/commands/setup/docker/templates/{Dockerfile → Dockerfile.yarn} +1 -1
- package/dist/commands/setup/docker/templates/docker-compose.dev.yml +2 -2
- package/dist/commands/setup/generator/generatorHandler.js +4 -3
- package/dist/commands/setup/graphql/features/fragments/fragmentsHandler.js +2 -2
- package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocumentsHandler.js +2 -2
- package/dist/commands/setup/i18n/i18nHandler.js +18 -15
- package/dist/commands/setup/jobs/jobsHandler.js +10 -5
- package/dist/commands/setup/mailer/mailerHandler.js +11 -9
- package/dist/commands/setup/package/packageHandler.js +14 -10
- package/dist/commands/setup/realtime/realtimeHandler.js +22 -20
- package/dist/commands/setup/server-file/serverFileHandler.js +16 -8
- package/dist/commands/setup/tsconfig/tsconfigHandler.js +5 -3
- package/dist/commands/setup/ui/helpers/helpers.js +5 -1
- package/dist/commands/setup/ui/libraries/chakra-uiHandler.js +11 -5
- package/dist/commands/setup/ui/libraries/mantineHandler.js +21 -13
- package/dist/commands/setup/ui/libraries/tailwindcssHandler.js +38 -26
- package/dist/commands/setup/uploads/uploadsHandler.js +7 -4
- package/dist/commands/setup.js +1 -2
- package/dist/commands/test/testHandler.js +2 -1
- package/dist/commands/test/testHandlerEsm.js +2 -2
- package/dist/commands/type-checkHandler.js +4 -6
- package/dist/commands/upgrade/upgradeHandler.js +2 -4
- package/dist/index.js +10 -4
- package/dist/lib/configureStorybook.js +2 -2
- package/dist/lib/exec.js +36 -24
- package/dist/lib/exit.js +19 -4
- package/dist/lib/extendFile.js +22 -12
- package/dist/lib/index.js +119 -85
- package/dist/lib/merge/algorithms.js +4 -1
- package/dist/lib/merge/index.js +76 -41
- package/dist/lib/merge/semanticIdentity.js +18 -6
- package/dist/lib/merge/strategy.js +86 -36
- package/dist/lib/packages.js +23 -13
- package/dist/lib/plugin.js +12 -5
- package/dist/lib/pluralHelpers.js +1 -1
- package/dist/lib/project.js +3 -1
- package/dist/lib/rollback.js +7 -7
- package/dist/lib/schemaHelpers.js +12 -12
- package/dist/lib/test.js +4 -0
- package/dist/lib/updateCheck.js +6 -4
- package/dist/middleware/checkNodeVersion.js +5 -0
- package/dist/plugin.js +18 -12
- package/dist/telemetry/exporter.js +12 -5
- package/dist/telemetry/index.js +4 -3
- package/dist/telemetry/resource.js +9 -5
- package/dist/telemetry/send.js +14 -10
- package/package.json +15 -12
- package/dist/commands/setup/vite/templates/vite.config.ts.template +0 -19
- package/dist/commands/setup/vite/vite.js +0 -38
- package/dist/commands/setup/vite/viteHandler.js +0 -82
- /package/dist/{index.d.js → global.d.js} +0 -0
|
@@ -1,55 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
startCommand: "yarn cedar deploy flightcontrol api --serve",
|
|
21
|
-
port: 8911,
|
|
22
|
-
healthCheckPath: "/graphql/health",
|
|
23
|
-
ci: {
|
|
24
|
-
type: "ec2"
|
|
25
|
-
},
|
|
26
|
-
envVariables: {
|
|
27
|
-
CEDAR_WEB_URL: {
|
|
28
|
-
fromService: { id: "cedar-web", value: "origin" }
|
|
29
|
-
}
|
|
30
|
-
}
|
|
1
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
2
|
+
function getFlightcontrolConfig() {
|
|
3
|
+
const apiBuildCommand = formatCedarCommand(["deploy", "flightcontrol", "api"]);
|
|
4
|
+
const apiStartCommand = formatCedarCommand([
|
|
5
|
+
"deploy",
|
|
6
|
+
"flightcontrol",
|
|
7
|
+
"api",
|
|
8
|
+
"--serve"
|
|
9
|
+
]);
|
|
10
|
+
const webBuildCommand = formatCedarCommand(["deploy", "flightcontrol", "web"]);
|
|
11
|
+
return {
|
|
12
|
+
$schema: "https://app.flightcontrol.dev/schema.json",
|
|
13
|
+
environments: [
|
|
14
|
+
{
|
|
15
|
+
id: "development",
|
|
16
|
+
name: "Development",
|
|
17
|
+
region: "us-east-1",
|
|
18
|
+
source: {
|
|
19
|
+
branch: "main"
|
|
31
20
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
21
|
+
services: [
|
|
22
|
+
{
|
|
23
|
+
id: "cedar-api",
|
|
24
|
+
name: "Cedar API",
|
|
25
|
+
type: "web",
|
|
26
|
+
buildType: "nixpacks",
|
|
27
|
+
cpu: 0.5,
|
|
28
|
+
memory: 1,
|
|
29
|
+
buildCommand: apiBuildCommand,
|
|
30
|
+
startCommand: apiStartCommand,
|
|
31
|
+
port: 8911,
|
|
32
|
+
healthCheckPath: "/graphql/health",
|
|
33
|
+
ci: {
|
|
34
|
+
type: "ec2"
|
|
35
|
+
},
|
|
36
|
+
envVariables: {
|
|
37
|
+
CEDAR_WEB_URL: {
|
|
38
|
+
fromService: { id: "cedar-web", value: "origin" }
|
|
39
|
+
}
|
|
40
|
+
}
|
|
42
41
|
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
{
|
|
43
|
+
id: "cedar-web",
|
|
44
|
+
name: "Cedar Web",
|
|
45
|
+
type: "static",
|
|
46
|
+
buildType: "nixpacks",
|
|
47
|
+
singlePageApp: true,
|
|
48
|
+
buildCommand: webBuildCommand,
|
|
49
|
+
outputDirectory: "web/dist",
|
|
50
|
+
ci: {
|
|
51
|
+
type: "ec2"
|
|
52
|
+
},
|
|
53
|
+
envVariables: {
|
|
54
|
+
CEDAR_API_URL: {
|
|
55
|
+
fromService: { id: "cedar-api", value: "origin" }
|
|
56
|
+
}
|
|
46
57
|
}
|
|
47
58
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
};
|
|
63
|
+
}
|
|
53
64
|
const postgresDatabaseService = {
|
|
54
65
|
id: "db",
|
|
55
66
|
name: "Database",
|
|
@@ -79,7 +90,7 @@ const databaseEnvVariables = {
|
|
|
79
90
|
};
|
|
80
91
|
export {
|
|
81
92
|
databaseEnvVariables,
|
|
82
|
-
|
|
93
|
+
getFlightcontrolConfig,
|
|
83
94
|
mysqlDatabaseService,
|
|
84
95
|
postgresDatabaseService
|
|
85
96
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
1
2
|
import { getConfig } from "../../../../lib/index.js";
|
|
2
3
|
const config = getConfig();
|
|
3
4
|
const NETLIFY_TOML = `[build]
|
|
4
|
-
command = "
|
|
5
|
+
command = "${formatCedarCommand(["deploy", "netlify"])}"
|
|
5
6
|
publish = "web/dist"
|
|
6
7
|
functions = "api/dist/functions"
|
|
7
8
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
2
|
+
import { getConfig } from "../../../../lib/index.js";
|
|
3
|
+
const config = getConfig();
|
|
4
|
+
const NETLIFY_UD_TOML = `[build]
|
|
5
|
+
command = "${formatCedarCommand(["build", "--ud", "--apiRootPath=/.api/functions"])} && ${formatCedarCommand(["prisma", "migrate", "deploy"])} && ${formatCedarCommand(["data-migrate", "up"])}"
|
|
6
|
+
publish = "web/dist"
|
|
7
|
+
|
|
8
|
+
[build.environment]
|
|
9
|
+
NODE_VERSION = "24"
|
|
10
|
+
|
|
11
|
+
[functions]
|
|
12
|
+
directory = "api/dist/ud"
|
|
13
|
+
|
|
14
|
+
# To use Netlify Dev, install Netlify's CLI (\`netlify-cli\`) from NPM and use
|
|
15
|
+
# \`netlify link\` to connect your local project to a site on Netlify. Then run
|
|
16
|
+
# \`netlify dev\`.
|
|
17
|
+
#
|
|
18
|
+
# Quick links to the docs:
|
|
19
|
+
# - Netlify Dev https://docs.netlify.com/api-and-cli-guides/cli-guides/local-development
|
|
20
|
+
# - Netlify's CLI https://docs.netlify.com/api-and-cli-guides/cli-guides/get-started-with-cli/
|
|
21
|
+
# - \`netlify link\` https://cli.netlify.com/commands/link/
|
|
22
|
+
[dev]
|
|
23
|
+
framework = "cedarjs"
|
|
24
|
+
# Make sure \`targetPort\` matches \`web.port\` in your cedar.toml file
|
|
25
|
+
targetPort = ${config.web.port}
|
|
26
|
+
# Point your browser to this port to access your app
|
|
27
|
+
port = 8888
|
|
28
|
+
`;
|
|
29
|
+
export {
|
|
30
|
+
NETLIFY_UD_TOML
|
|
31
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
2
2
|
const command = "docker";
|
|
3
|
-
const description = "Setup the default
|
|
3
|
+
const description = "Setup the default Cedar Dockerfile";
|
|
4
4
|
function builder(yargs) {
|
|
5
5
|
yargs.option("force", {
|
|
6
6
|
alias: "f",
|
|
@@ -4,15 +4,20 @@ import path from "node:path";
|
|
|
4
4
|
import execa from "execa";
|
|
5
5
|
import { Listr } from "listr2";
|
|
6
6
|
import { writeFile, colors as c } from "@cedarjs/cli-helpers";
|
|
7
|
+
import { dedupe } from "@cedarjs/cli-helpers/packageManager";
|
|
8
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
9
|
+
import { addWorkspacePackages } from "@cedarjs/cli-helpers/packageManager/packages";
|
|
7
10
|
import { getConfig, getConfigPath, getPaths } from "@cedarjs/project-config";
|
|
11
|
+
import { getPackageManager } from "@cedarjs/project-config/packageManager";
|
|
8
12
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
9
13
|
async function handler({ force }) {
|
|
10
14
|
const TEMPLATE_DIR = path.join(import.meta.dirname, "templates");
|
|
15
|
+
const pm = getPackageManager();
|
|
11
16
|
let dockerfileTemplateContent = fs.readFileSync(
|
|
12
|
-
path.resolve(TEMPLATE_DIR,
|
|
17
|
+
path.resolve(TEMPLATE_DIR, `Dockerfile.${pm}`),
|
|
13
18
|
"utf-8"
|
|
14
19
|
);
|
|
15
|
-
|
|
20
|
+
let dockerComposeDevTemplateContent = fs.readFileSync(
|
|
16
21
|
path.resolve(TEMPLATE_DIR, "docker-compose.dev.yml"),
|
|
17
22
|
"utf-8"
|
|
18
23
|
);
|
|
@@ -36,31 +41,46 @@ async function handler({ force }) {
|
|
|
36
41
|
const dockerignoreFilePath = path.join(getPaths().base, ".dockerignore");
|
|
37
42
|
const configTomlPath = getConfigPath();
|
|
38
43
|
const configFileName = path.basename(configTomlPath);
|
|
44
|
+
dockerComposeDevTemplateContent = dockerComposeDevTemplateContent.replace(/'{{DEV_CMD}}'/g, formatCedarCommand(["dev"])).replace(/{{CEDAR_CMD}}/g, formatCedarCommand([]));
|
|
39
45
|
const tasks = new Listr(
|
|
40
46
|
[
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
// The yarn workspace-tools plugin only exists for yarn.
|
|
48
|
+
// For pnpm, pnpm install --prod --filter api is built-in. Workspaces are
|
|
49
|
+
// a first-class feature with no plugin needed. For npm, there's no
|
|
50
|
+
// workspace-focus equivalent at all, so npm ci --omit=dev installs
|
|
51
|
+
// production deps for all workspaces (slightly less optimized but
|
|
52
|
+
// functionally correct).
|
|
53
|
+
...pm === "yarn" ? [
|
|
54
|
+
{
|
|
55
|
+
title: "Adding the official yarn workspace-tools plugin...",
|
|
56
|
+
task: async (_, task) => {
|
|
57
|
+
const { stdout } = await execa(
|
|
58
|
+
"yarn",
|
|
59
|
+
["plugin", "runtime", "--json"],
|
|
60
|
+
{
|
|
61
|
+
cwd: getPaths().base
|
|
62
|
+
}
|
|
51
63
|
);
|
|
52
|
-
|
|
64
|
+
const hasWorkspaceToolsPlugin = stdout.trim().split("\n").map((line) => JSON.parse(line)).some(
|
|
65
|
+
({ name }) => name === "@yarnpkg/plugin-workspace-tools"
|
|
66
|
+
);
|
|
67
|
+
if (hasWorkspaceToolsPlugin) {
|
|
68
|
+
task.skip(
|
|
69
|
+
"The official yarn workspace-tools plugin is already installed"
|
|
70
|
+
);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
return execa("yarn", ["plugin", "import", "workspace-tools"], {
|
|
74
|
+
cwd: getPaths().base
|
|
75
|
+
}).stdout;
|
|
53
76
|
}
|
|
54
|
-
return execa.command("yarn plugin import workspace-tools", {
|
|
55
|
-
cwd: getPaths().base
|
|
56
|
-
}).stdout;
|
|
57
77
|
}
|
|
58
|
-
|
|
78
|
+
] : [],
|
|
59
79
|
{
|
|
60
80
|
title: "Adding @cedarjs/api-server and @cedarjs/web-server...",
|
|
61
81
|
task: async (_ctx, task) => {
|
|
62
82
|
const apiServerPackageName = "@cedarjs/api-server";
|
|
63
|
-
const { dependencies: apiDependencies } = JSON.parse(
|
|
83
|
+
const { dependencies: apiDependencies = {} } = JSON.parse(
|
|
64
84
|
fs.readFileSync(
|
|
65
85
|
path.join(getPaths().api.base, "package.json"),
|
|
66
86
|
"utf-8"
|
|
@@ -68,7 +88,7 @@ async function handler({ force }) {
|
|
|
68
88
|
);
|
|
69
89
|
const hasApiServerPackage = Object.keys(apiDependencies).includes(apiServerPackageName);
|
|
70
90
|
const webServerPackageName = "@cedarjs/web-server";
|
|
71
|
-
const { dependencies: webDependencies } = JSON.parse(
|
|
91
|
+
const { dependencies: webDependencies = {} } = JSON.parse(
|
|
72
92
|
fs.readFileSync(
|
|
73
93
|
path.join(getPaths().web.base, "package.json"),
|
|
74
94
|
"utf-8"
|
|
@@ -83,25 +103,26 @@ async function handler({ force }) {
|
|
|
83
103
|
}
|
|
84
104
|
if (!hasApiServerPackage) {
|
|
85
105
|
const apiServerPackageVersion = await getVersionOfRedwoodPackageToInstall(apiServerPackageName);
|
|
86
|
-
await
|
|
87
|
-
|
|
88
|
-
{
|
|
89
|
-
|
|
90
|
-
}
|
|
106
|
+
await addWorkspacePackages(
|
|
107
|
+
"api",
|
|
108
|
+
[`${apiServerPackageName}@${apiServerPackageVersion}`],
|
|
109
|
+
{ cwd: getPaths().base }
|
|
91
110
|
);
|
|
92
111
|
}
|
|
93
112
|
if (!hasWebServerPackage) {
|
|
94
113
|
const webServerPackageVersion = await getVersionOfRedwoodPackageToInstall(webServerPackageName);
|
|
95
|
-
await
|
|
96
|
-
|
|
97
|
-
{
|
|
98
|
-
|
|
99
|
-
}
|
|
114
|
+
await addWorkspacePackages(
|
|
115
|
+
"web",
|
|
116
|
+
[`${webServerPackageName}@${webServerPackageVersion}`],
|
|
117
|
+
{ cwd: getPaths().base }
|
|
100
118
|
);
|
|
101
119
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
120
|
+
const dedupeCommand = dedupe();
|
|
121
|
+
if (dedupeCommand) {
|
|
122
|
+
await execa(getPackageManager(), [dedupeCommand], {
|
|
123
|
+
cwd: getPaths().base
|
|
124
|
+
});
|
|
125
|
+
}
|
|
105
126
|
}
|
|
106
127
|
},
|
|
107
128
|
{
|
|
@@ -233,7 +254,7 @@ async function handler({ force }) {
|
|
|
233
254
|
"Then, connect to the container and migrate your database:",
|
|
234
255
|
"",
|
|
235
256
|
" docker compose -f ./docker-compose.dev.yml run --rm -it console /bin/bash",
|
|
236
|
-
" root@...:/home/node/app#
|
|
257
|
+
" root@...:/home/node/app# " + formatCedarCommand(["prisma", "migrate", "dev"]),
|
|
237
258
|
"",
|
|
238
259
|
"We assume you're using Postgres. If you're not, you'll need to make other changes to switch over.",
|
|
239
260
|
"Lastly, ensure you have Docker. If you don't, see https://docs.docker.com/desktop/",
|
|
@@ -243,9 +264,11 @@ async function handler({ force }) {
|
|
|
243
264
|
].join("\n")
|
|
244
265
|
);
|
|
245
266
|
} catch (e) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
process.
|
|
267
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
268
|
+
const exitCode = e instanceof Error && "exitCode" in e && typeof e.exitCode === "number" ? e.exitCode : 1;
|
|
269
|
+
errorTelemetry(process.argv, msg);
|
|
270
|
+
console.error(c.error(msg));
|
|
271
|
+
process.exit(exitCode);
|
|
249
272
|
}
|
|
250
273
|
}
|
|
251
274
|
async function getVersionOfRedwoodPackageToInstall(module) {
|
|
@@ -253,9 +276,21 @@ async function getVersionOfRedwoodPackageToInstall(module) {
|
|
|
253
276
|
const packageJsonPath = createdRequire.resolve("@cedarjs/cli/package.json", {
|
|
254
277
|
paths: [getPaths().base]
|
|
255
278
|
});
|
|
256
|
-
let { version } = JSON.parse(
|
|
279
|
+
let { version = "" } = JSON.parse(
|
|
280
|
+
fs.readFileSync(packageJsonPath, "utf8")
|
|
281
|
+
);
|
|
257
282
|
const packumentP = await fetch(`https://registry.npmjs.org/${module}`);
|
|
258
283
|
const packument = await packumentP.json();
|
|
284
|
+
if (packument.error) {
|
|
285
|
+
throw new Error(
|
|
286
|
+
`Couldn't fetch packument for ${module}: ${packument.error}`
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
if (!packument.versions || typeof packument.versions !== "object" || Array.isArray(packument.versions)) {
|
|
290
|
+
throw new Error(
|
|
291
|
+
`Couldn't fetch packument for ${module}: invalid versions field`
|
|
292
|
+
);
|
|
293
|
+
}
|
|
259
294
|
if (version.includes("+")) {
|
|
260
295
|
version = version.split("+")[0];
|
|
261
296
|
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# base
|
|
2
|
+
# ----
|
|
3
|
+
FROM node:24-bookworm-slim as base
|
|
4
|
+
|
|
5
|
+
RUN npm install --global corepack
|
|
6
|
+
|
|
7
|
+
# We tried to make the Dockerfile as lean as possible. In some cases, that
|
|
8
|
+
# means we excluded a dependency your project needs.
|
|
9
|
+
# By far the most common is Python. If you're running into build errors
|
|
10
|
+
# because `python3` isn't available, add `python3 make gcc \` before the
|
|
11
|
+
# `openssl \` line below and in other stages as necessary:
|
|
12
|
+
RUN apt-get update && apt-get install -y \
|
|
13
|
+
openssl \
|
|
14
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
15
|
+
|
|
16
|
+
USER node
|
|
17
|
+
WORKDIR /home/node/app
|
|
18
|
+
|
|
19
|
+
COPY --chown=node:node package*.json .
|
|
20
|
+
COPY --chown=node:node api/package.json api/
|
|
21
|
+
COPY --chown=node:node web/package.json web/
|
|
22
|
+
|
|
23
|
+
RUN --mount=type=cache,target=/home/node/.npm,uid=1000 \
|
|
24
|
+
npm ci
|
|
25
|
+
|
|
26
|
+
COPY --chown=node:node cedar.toml* redwood.toml* ./
|
|
27
|
+
COPY --chown=node:node graphql.config.cjs .
|
|
28
|
+
COPY --chown=node:node .env.defaults .env.defaults
|
|
29
|
+
|
|
30
|
+
# api build
|
|
31
|
+
# ---------
|
|
32
|
+
FROM base as api_build
|
|
33
|
+
|
|
34
|
+
COPY --chown=node:node api api
|
|
35
|
+
RUN npx --yes cedar build api
|
|
36
|
+
|
|
37
|
+
# web prerender build
|
|
38
|
+
# -------------------
|
|
39
|
+
FROM api_build as web_build_with_prerender
|
|
40
|
+
|
|
41
|
+
COPY --chown=node:node web web
|
|
42
|
+
RUN npx --yes cedar build web
|
|
43
|
+
|
|
44
|
+
# web build
|
|
45
|
+
# ---------
|
|
46
|
+
FROM base as web_build
|
|
47
|
+
|
|
48
|
+
COPY --chown=node:node web web
|
|
49
|
+
RUN npx --yes cedar build web --no-prerender
|
|
50
|
+
|
|
51
|
+
# api serve
|
|
52
|
+
# ---------
|
|
53
|
+
FROM node:24-bookworm-slim as api_serve
|
|
54
|
+
|
|
55
|
+
RUN npm install --global corepack
|
|
56
|
+
|
|
57
|
+
RUN apt-get update && apt-get install -y \
|
|
58
|
+
openssl \
|
|
59
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
60
|
+
|
|
61
|
+
USER node
|
|
62
|
+
WORKDIR /home/node/app
|
|
63
|
+
|
|
64
|
+
# npm doesn't have a workspace focus command, so we copy all workspace
|
|
65
|
+
# package.json files and install production deps for all workspaces.
|
|
66
|
+
COPY --chown=node:node package*.json .
|
|
67
|
+
COPY --chown=node:node api/package.json api/
|
|
68
|
+
COPY --chown=node:node web/package.json web/
|
|
69
|
+
|
|
70
|
+
RUN --mount=type=cache,target=/home/node/.npm,uid=1000 \
|
|
71
|
+
npm ci --omit=dev
|
|
72
|
+
|
|
73
|
+
COPY --chown=node:node cedar.toml* redwood.toml* ./
|
|
74
|
+
COPY --chown=node:node graphql.config.cjs .
|
|
75
|
+
COPY --chown=node:node .env.defaults .env.defaults
|
|
76
|
+
|
|
77
|
+
COPY --chown=node:node --from=api_build /home/node/app/api/dist /home/node/app/api/dist
|
|
78
|
+
COPY --chown=node:node --from=api_build /home/node/app/api/db /home/node/app/api/db
|
|
79
|
+
COPY --chown=node:node --from=api_build /home/node/app/node_modules/.prisma /home/node/app/node_modules/.prisma
|
|
80
|
+
|
|
81
|
+
ENV NODE_ENV=production
|
|
82
|
+
|
|
83
|
+
CMD ["node_modules/.bin/cedarjs-server", "api"]
|
|
84
|
+
|
|
85
|
+
# web serve
|
|
86
|
+
# ---------
|
|
87
|
+
FROM node:24-bookworm-slim as web_serve
|
|
88
|
+
|
|
89
|
+
RUN npm install --global corepack
|
|
90
|
+
|
|
91
|
+
USER node
|
|
92
|
+
WORKDIR /home/node/app
|
|
93
|
+
|
|
94
|
+
COPY --chown=node:node package*.json .
|
|
95
|
+
COPY --chown=node:node api/package.json api/
|
|
96
|
+
COPY --chown=node:node web/package.json web/
|
|
97
|
+
|
|
98
|
+
RUN --mount=type=cache,target=/home/node/.npm,uid=1000 \
|
|
99
|
+
npm ci --omit=dev
|
|
100
|
+
|
|
101
|
+
COPY --chown=node:node cedar.toml* redwood.toml* ./
|
|
102
|
+
COPY --chown=node:node graphql.config.cjs .
|
|
103
|
+
COPY --chown=node:node .env.defaults .env.defaults
|
|
104
|
+
|
|
105
|
+
COPY --chown=node:node --from=web_build /home/node/app/web/dist /home/node/app/web/dist
|
|
106
|
+
|
|
107
|
+
ENV NODE_ENV=production \
|
|
108
|
+
API_PROXY_TARGET=http://api:8911
|
|
109
|
+
|
|
110
|
+
# We use the shell form here for variable expansion.
|
|
111
|
+
CMD node_modules/.bin/cedar-web-server --api-proxy-target $API_PROXY_TARGET
|
|
112
|
+
|
|
113
|
+
# console
|
|
114
|
+
# -------
|
|
115
|
+
FROM base as console
|
|
116
|
+
|
|
117
|
+
COPY --chown=node:node api api
|
|
118
|
+
COPY --chown=node:node web web
|
|
119
|
+
COPY --chown=node:node scripts scripts
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# base
|
|
2
|
+
# ----
|
|
3
|
+
FROM node:24-bookworm-slim as base
|
|
4
|
+
|
|
5
|
+
RUN npm install --global corepack
|
|
6
|
+
|
|
7
|
+
RUN apt-get update && apt-get install -y \
|
|
8
|
+
openssl \
|
|
9
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
10
|
+
|
|
11
|
+
USER node
|
|
12
|
+
WORKDIR /home/node/app
|
|
13
|
+
|
|
14
|
+
COPY --chown=node:node package.json .
|
|
15
|
+
COPY --chown=node:node pnpm-lock.yaml .
|
|
16
|
+
COPY --chown=node:node pnpm-workspace.yaml .
|
|
17
|
+
COPY --chown=node:node api/package.json api/
|
|
18
|
+
COPY --chown=node:node web/package.json web/
|
|
19
|
+
|
|
20
|
+
RUN --mount=type=cache,id=pnpm,target=/home/node/.pnpm/store,uid=1000 \
|
|
21
|
+
pnpm install --frozen-lockfile --store-dir /home/node/.pnpm/store
|
|
22
|
+
|
|
23
|
+
COPY --chown=node:node cedar.toml* redwood.toml* ./
|
|
24
|
+
COPY --chown=node:node graphql.config.cjs .
|
|
25
|
+
COPY --chown=node:node .env.defaults .env.defaults
|
|
26
|
+
|
|
27
|
+
# api build
|
|
28
|
+
# ---------
|
|
29
|
+
FROM base as api_build
|
|
30
|
+
|
|
31
|
+
COPY --chown=node:node api api
|
|
32
|
+
RUN pnpm exec cedar build api
|
|
33
|
+
|
|
34
|
+
# web prerender build
|
|
35
|
+
# -------------------
|
|
36
|
+
FROM api_build as web_build_with_prerender
|
|
37
|
+
|
|
38
|
+
COPY --chown=node:node web web
|
|
39
|
+
RUN pnpm exec cedar build web
|
|
40
|
+
|
|
41
|
+
# web build
|
|
42
|
+
# ---------
|
|
43
|
+
FROM base as web_build
|
|
44
|
+
|
|
45
|
+
COPY --chown=node:node web web
|
|
46
|
+
RUN pnpm exec cedar build web --no-prerender
|
|
47
|
+
|
|
48
|
+
# deploy
|
|
49
|
+
# ------
|
|
50
|
+
FROM api_build as deploy
|
|
51
|
+
|
|
52
|
+
COPY --chown=node:node --from=web_build /home/node/app/web/dist /home/node/app/web/dist
|
|
53
|
+
|
|
54
|
+
RUN pnpm deploy --filter=api --prod /home/node/app/dist/api
|
|
55
|
+
RUN pnpm deploy --filter=web --prod /home/node/app/dist/web
|
|
56
|
+
|
|
57
|
+
# api serve
|
|
58
|
+
# ---------
|
|
59
|
+
FROM node:24-bookworm-slim as api_serve
|
|
60
|
+
|
|
61
|
+
RUN npm install --global corepack
|
|
62
|
+
|
|
63
|
+
RUN apt-get update && apt-get install -y \
|
|
64
|
+
openssl \
|
|
65
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
66
|
+
|
|
67
|
+
USER node
|
|
68
|
+
WORKDIR /home/node/app
|
|
69
|
+
|
|
70
|
+
COPY --chown=node:node cedar.toml* redwood.toml* ./
|
|
71
|
+
COPY --chown=node:node graphql.config.cjs .
|
|
72
|
+
COPY --chown=node:node .env.defaults .env.defaults
|
|
73
|
+
|
|
74
|
+
COPY --chown=node:node --from=deploy /home/node/app/dist/api /home/node/app
|
|
75
|
+
|
|
76
|
+
COPY --chown=node:node --from=api_build /home/node/app/api/dist /home/node/app/api/dist
|
|
77
|
+
COPY --chown=node:node --from=api_build /home/node/app/api/db /home/node/app/api/db
|
|
78
|
+
COPY --chown=node:node --from=api_build /home/node/app/node_modules/.prisma /home/node/app/node_modules/.prisma
|
|
79
|
+
|
|
80
|
+
ENV NODE_ENV=production
|
|
81
|
+
|
|
82
|
+
CMD ["node_modules/.bin/cedarjs-server", "api"]
|
|
83
|
+
|
|
84
|
+
# web serve
|
|
85
|
+
# ---------
|
|
86
|
+
FROM node:24-bookworm-slim as web_serve
|
|
87
|
+
|
|
88
|
+
RUN npm install --global corepack
|
|
89
|
+
|
|
90
|
+
USER node
|
|
91
|
+
WORKDIR /home/node/app
|
|
92
|
+
|
|
93
|
+
COPY --chown=node:node cedar.toml* redwood.toml* ./
|
|
94
|
+
COPY --chown=node:node graphql.config.cjs .
|
|
95
|
+
COPY --chown=node:node .env.defaults .env.defaults
|
|
96
|
+
|
|
97
|
+
COPY --chown=node:node --from=deploy /home/node/app/dist/web /home/node/app
|
|
98
|
+
|
|
99
|
+
COPY --chown=node:node --from=web_build /home/node/app/web/dist /home/node/app/web/dist
|
|
100
|
+
|
|
101
|
+
ENV NODE_ENV=production \
|
|
102
|
+
API_PROXY_TARGET=http://api:8911
|
|
103
|
+
|
|
104
|
+
CMD node_modules/.bin/cedar-web-server --api-proxy-target $API_PROXY_TARGET
|
|
105
|
+
|
|
106
|
+
# console
|
|
107
|
+
# -------
|
|
108
|
+
FROM base as console
|
|
109
|
+
|
|
110
|
+
COPY --chown=node:node api api
|
|
111
|
+
COPY --chown=node:node web web
|
|
112
|
+
COPY --chown=node:node scripts scripts
|
|
@@ -132,7 +132,7 @@ ENV NODE_ENV=production \
|
|
|
132
132
|
API_PROXY_TARGET=http://api:8911
|
|
133
133
|
|
|
134
134
|
# We use the shell form here for variable expansion.
|
|
135
|
-
CMD
|
|
135
|
+
CMD node_modules/.bin/cedar-web-server --api-proxy-target $API_PROXY_TARGET
|
|
136
136
|
|
|
137
137
|
# console
|
|
138
138
|
# -------
|
|
@@ -4,7 +4,7 @@ services:
|
|
|
4
4
|
context: .
|
|
5
5
|
dockerfile: ./Dockerfile
|
|
6
6
|
target: base
|
|
7
|
-
command:
|
|
7
|
+
command: '{{DEV_CMD}}'
|
|
8
8
|
volumes:
|
|
9
9
|
- .:/home/node/app
|
|
10
10
|
- node_modules:/home/node/app/node_modules
|
|
@@ -36,7 +36,7 @@ services:
|
|
|
36
36
|
#
|
|
37
37
|
# ```
|
|
38
38
|
# docker compose -f ./docker-compose.dev.yml run --rm -it console /bin/bash
|
|
39
|
-
# root@...:/home/node/app#
|
|
39
|
+
# root@...:/home/node/app# {{CEDAR_CMD}} prisma migrate dev
|
|
40
40
|
# ```
|
|
41
41
|
console:
|
|
42
42
|
user: root
|
|
@@ -36,7 +36,7 @@ const tasks = ({ name, force }) => {
|
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
title: "Destination:",
|
|
39
|
-
task: (
|
|
39
|
+
task: (_ctx, task) => {
|
|
40
40
|
task.title = ` Wrote templates to ${destination.replace(
|
|
41
41
|
getPaths().base,
|
|
42
42
|
""
|
|
@@ -44,7 +44,7 @@ const tasks = ({ name, force }) => {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
],
|
|
47
|
-
{ rendererOptions: { collapseSubtasks: false }
|
|
47
|
+
{ rendererOptions: { collapseSubtasks: false } }
|
|
48
48
|
);
|
|
49
49
|
};
|
|
50
50
|
const handler = async ({ name, force }) => {
|
|
@@ -52,7 +52,8 @@ const handler = async ({ name, force }) => {
|
|
|
52
52
|
try {
|
|
53
53
|
await t.run();
|
|
54
54
|
} catch (e) {
|
|
55
|
-
|
|
55
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
56
|
+
console.log(c.error(message));
|
|
56
57
|
}
|
|
57
58
|
};
|
|
58
59
|
export {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import execa from "execa";
|
|
4
3
|
import { Listr } from "listr2";
|
|
5
4
|
import { format } from "prettier";
|
|
6
5
|
import {
|
|
@@ -8,6 +7,7 @@ import {
|
|
|
8
7
|
getPrettierOptions,
|
|
9
8
|
setTomlSetting
|
|
10
9
|
} from "@cedarjs/cli-helpers";
|
|
10
|
+
import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
11
11
|
import { getConfig, getPaths } from "@cedarjs/project-config";
|
|
12
12
|
import { runTransform } from "../../../../../lib/runTransform.js";
|
|
13
13
|
const command = "fragments";
|
|
@@ -34,7 +34,7 @@ async function handler({ force }) {
|
|
|
34
34
|
{
|
|
35
35
|
title: "Generate possibleTypes.ts",
|
|
36
36
|
task: () => {
|
|
37
|
-
|
|
37
|
+
runBinSync("cedar", ["generate", "types"], { stdio: "ignore" });
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
{
|