@cedarjs/cli 7.0.0 → 8.0.0-canary.3263
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 +2 -1
- package/dist/commands/build.js +1 -1
- package/dist/commands/check.js +2 -1
- package/dist/commands/deploy/baremetal/baremetalHandler.js +1 -1
- package/dist/commands/deploy/baremetal.js +1 -1
- package/dist/commands/deploy/flightcontrolHandler.js +1 -1
- package/dist/commands/deploy/helpers/deployHandler.js +1 -1
- package/dist/commands/deploy/netlify.js +1 -1
- package/dist/commands/deploy/renderHandler.js +1 -1
- package/dist/commands/deploy/serverlessHandler.js +2 -1
- package/dist/commands/deploy/vercel.js +1 -1
- package/dist/commands/destroy/handlerHelpers.js +1 -1
- package/dist/commands/destroy/page/pageHandler.js +2 -1
- package/dist/commands/destroy/scaffold/scaffoldHandler.js +2 -1
- package/dist/commands/destroy/sdl/sdlHandler.js +2 -1
- package/dist/commands/dev/devHandler.js +3 -4
- package/dist/commands/dev/packageWatchCommands.js +8 -3
- package/dist/commands/dev.js +1 -1
- package/dist/commands/execHandler.js +2 -1
- package/dist/commands/experimental/live-queries/liveQueries.js +1 -1
- package/dist/commands/experimental/live-queries/liveQueriesHandler.js +3 -3
- package/dist/commands/experimental/setupInngest.js +1 -1
- package/dist/commands/experimental/setupInngestHandler.js +1 -1
- package/dist/commands/experimental/setupOpentelemetry.js +1 -1
- package/dist/commands/experimental/setupOpentelemetryHandler.js +2 -1
- package/dist/commands/experimental/setupReactCompiler.js +1 -1
- package/dist/commands/experimental/setupReactCompilerHandler.js +4 -4
- package/dist/commands/experimental/setupRsc.js +1 -1
- package/dist/commands/experimental/setupRscHandler.js +2 -1
- package/dist/commands/experimental/setupStreamingSsr.js +1 -1
- package/dist/commands/experimental/setupStreamingSsrHandler.js +3 -2
- package/dist/commands/generate/cell/cell.js +20 -0
- package/dist/commands/generate/cell/cellHandler.js +68 -20
- package/dist/commands/generate/cell/templates/cell.tsx.template +21 -2
- package/dist/commands/generate/cell/templates/cellFragment.tsx.template +43 -0
- package/dist/commands/generate/cell/templates/cellList.tsx.template +21 -2
- package/dist/commands/generate/cell/templates/storiesFragment.tsx.template +23 -0
- package/dist/commands/generate/cell/templates/test.js.template +1 -1
- package/dist/commands/generate/cell/templates/testFragment.js.template +30 -0
- package/dist/commands/generate/dataMigration/dataMigration.js +2 -1
- package/dist/commands/generate/dbAuth/dbAuthHandler.js +23 -3
- package/dist/commands/generate/dbAuth/templates/login.oauth.tsx.template +164 -0
- package/dist/commands/generate/dbAuth/templates/signup.oauth.tsx.template +147 -0
- package/dist/commands/generate/directive/directiveHandler.js +2 -1
- package/dist/commands/generate/function/functionHandler.js +2 -1
- package/dist/commands/generate/job/jobHandler.js +2 -1
- package/dist/commands/generate/model/modelHandler.js +2 -1
- package/dist/commands/generate/ogImage/ogImageHandler.js +2 -1
- package/dist/commands/generate/package/filesTask.js +9 -12
- package/dist/commands/generate/package/packageHandler.js +3 -4
- package/dist/commands/generate/page/pageHandler.js +2 -1
- package/dist/commands/generate/realtime/realtime.js +1 -1
- package/dist/commands/generate/realtime/realtimeHandler.js +2 -9
- package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.ts.template +1 -1
- package/dist/commands/generate/scaffold/scaffoldHandler.js +10 -5
- package/dist/commands/generate/scaffold/templates/components/NameForm.tsx.template +3 -3
- package/dist/commands/generate/scaffold/templates/lib/formatters.test.tsx.template +11 -0
- package/dist/commands/generate/scaffold/templates/lib/formatters.tsx.template +13 -1
- package/dist/commands/generate/script/scriptHandler.js +2 -1
- package/dist/commands/generate/sdl/sdlHandler.js +2 -1
- package/dist/commands/generate/secret/secret.js +1 -1
- package/dist/commands/generate/service/serviceHandler.js +47 -38
- package/dist/commands/generate/service/templates/service.ts.template +22 -8
- package/dist/commands/generate/service/templates/test.ts.template +1 -1
- package/dist/commands/generate/yargsCommandHelpers.js +1 -1
- package/dist/commands/generate/yargsHandlerHelpers.js +2 -1
- package/dist/commands/generate.js +1 -1
- package/dist/commands/info.js +1 -1
- package/dist/commands/lint.js +1 -1
- package/dist/commands/prerenderHandler.js +11 -4
- package/dist/commands/prismaHandler.js +7 -2
- package/dist/commands/record/init.js +1 -1
- package/dist/commands/serve.js +2 -1
- package/dist/commands/setup/auth/auth.js +2 -4
- package/dist/commands/setup/cache/cache.js +1 -1
- package/dist/commands/setup/cache/cacheHandler.js +2 -1
- package/dist/commands/setup/database/postgres.js +1 -1
- package/dist/commands/setup/database/postgresHandler.js +3 -1
- package/dist/commands/setup/deploy/providers/baremetalHandler.js +2 -1
- package/dist/commands/setup/deploy/providers/coherence.js +1 -1
- package/dist/commands/setup/deploy/providers/coherenceHandler.js +7 -6
- package/dist/commands/setup/deploy/providers/flightcontrolHandler.js +2 -1
- package/dist/commands/setup/deploy/providers/netlifyHandler.js +2 -1
- package/dist/commands/setup/deploy/providers/renderHandler.js +2 -1
- package/dist/commands/setup/deploy/providers/serverlessHandler.js +2 -1
- package/dist/commands/setup/deploy/providers/universalDeployHandler.js +4 -6
- package/dist/commands/setup/deploy/providers/vercelHandler.js +2 -1
- package/dist/commands/setup/docker/docker.js +1 -1
- package/dist/commands/setup/docker/dockerHandler.js +2 -1
- package/dist/commands/setup/generator/generator.js +1 -1
- package/dist/commands/setup/generator/generatorHandler.js +1 -1
- package/dist/commands/setup/graphql/features/fragments/fragments.js +1 -1
- package/dist/commands/setup/graphql/features/fragments/fragmentsHandler.js +3 -5
- package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocuments.js +1 -1
- package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocumentsHandler.js +2 -1
- package/dist/commands/setup/i18n/i18n.js +1 -1
- package/dist/commands/setup/i18n/i18nHandler.js +1 -1
- package/dist/commands/setup/jobs/jobs.js +1 -1
- package/dist/commands/setup/jobs/jobsHandler.js +2 -1
- package/dist/commands/setup/mailer/mailer.js +1 -1
- package/dist/commands/setup/mailer/mailerHandler.js +2 -1
- package/dist/commands/setup/middleware/ogImage/ogImage.js +1 -1
- package/dist/commands/setup/middleware/ogImage/ogImageHandler.js +2 -1
- package/dist/commands/setup/monitoring/sentry/sentry.js +1 -1
- package/dist/commands/setup/monitoring/sentry/sentryHandler.js +8 -7
- package/dist/commands/setup/neon/neon.js +1 -1
- package/dist/commands/setup/neon/neonHandler.js +5 -9
- package/dist/commands/setup/package/package.js +1 -1
- package/dist/commands/setup/package/packageHandler.js +4 -4
- package/dist/commands/setup/realtime/addRealtimeToGraphql.js +1 -1
- package/dist/commands/setup/realtime/realtime.js +1 -1
- package/dist/commands/setup/realtime/realtimeHandler.js +4 -16
- package/dist/commands/setup/realtime/templates/subscriptions/countdown/countdown.ts.template +1 -1
- package/dist/commands/setup/realtime/templates/subscriptions/newMessage/newMessage.ts.template +1 -1
- package/dist/commands/setup/server-file/serverFile.js +1 -1
- package/dist/commands/setup/server-file/serverFileHandler.js +2 -1
- package/dist/commands/setup/tenancy/authCodemod.js +66 -0
- package/dist/commands/setup/tenancy/dbCodemod.js +64 -0
- package/dist/commands/setup/tenancy/graphqlCodemod.js +88 -0
- package/dist/commands/setup/tenancy/preflight.js +49 -0
- package/dist/commands/setup/tenancy/schemaPrisma.js +81 -0
- package/dist/commands/setup/tenancy/signupCodemod.js +153 -0
- package/dist/commands/setup/tenancy/templates/InvitePage.tsx.template +63 -0
- package/dist/commands/setup/tenancy/templates/OrgScope.tsx.template +40 -0
- package/dist/commands/setup/tenancy/templates/ensureDefaultOrganizations.dataMigration.ts.template +39 -0
- package/dist/commands/setup/tenancy/templates/organizations.scenarios.ts.template +59 -0
- package/dist/commands/setup/tenancy/templates/organizations.sdl.ts.template +89 -0
- package/dist/commands/setup/tenancy/templates/organizations.test.ts.template +389 -0
- package/dist/commands/setup/tenancy/templates/organizations.ts.template +394 -0
- package/dist/commands/setup/tenancy/templates/requireMembership.test.ts.template +35 -0
- package/dist/commands/setup/tenancy/templates/requireMembership.ts.template +25 -0
- package/dist/commands/setup/tenancy/tenancy.js +30 -0
- package/dist/commands/setup/tenancy/tenancyHandler.js +425 -0
- package/dist/commands/setup/ui/libraries/chakra-uiHandler.js +2 -1
- package/dist/commands/setup/ui/libraries/mantineHandler.js +2 -1
- package/dist/commands/setup/ui/libraries/tailwindcssHandler.js +2 -1
- package/dist/commands/setup/uploads/schemaPrisma.js +41 -0
- package/dist/commands/setup/uploads/serverFile.js +151 -0
- package/dist/commands/setup/uploads/templates/requireUploadToken.ts.template +15 -0
- package/dist/commands/setup/uploads/templates/srcLibUploads.ts.template +23 -24
- package/dist/commands/setup/uploads/templates/uploads.sdl.ts.template +79 -0
- package/dist/commands/setup/uploads/templates/uploads.ts.template +89 -0
- package/dist/commands/setup/uploads/templates/withDataUri.ts.template +14 -0
- package/dist/commands/setup/uploads/templates/withSignedUrl.ts.template +16 -0
- package/dist/commands/setup/uploads/uploads.js +49 -7
- package/dist/commands/setup/uploads/uploadsHandler.js +256 -69
- package/dist/commands/setup.js +2 -1
- package/dist/commands/studio.js +1 -1
- package/dist/commands/test/testHandler.js +25 -71
- package/dist/commands/test/viteVersionCheck.js +75 -0
- package/dist/commands/test.js +10 -18
- package/dist/commands/type-checkHandler.js +1 -1
- package/dist/commands/upgrade/preUpgradeScripts.js +3 -3
- package/dist/commands/upgrade/upgrade.js +1 -1
- package/dist/commands/upgrade/upgradeHandler.js +2 -1
- package/dist/index.js +5 -8
- package/dist/lib/exit.js +1 -1
- package/dist/lib/index.js +6 -25
- package/dist/lib/loadEnvFiles.js +1 -1
- package/dist/lib/plugin.js +1 -1
- package/dist/lib/test.js +1 -1
- package/dist/lib/updateCheck.js +4 -4
- package/dist/middleware/checkNodeVersion.js +4 -4
- package/package.json +18 -18
- package/dist/commands/setup/uploads/dbCodemod.js +0 -28
- package/dist/commands/setup/uploads/templates/signedUrl.ts.template +0 -21
- package/dist/commands/test/testHandlerEsm.js +0 -109
- package/dist/commands/testEsm.js +0 -41
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
recordTelemetryAttributes
|
|
9
|
-
} from "@cedarjs/cli-helpers";
|
|
4
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
5
|
+
import { getPaths } from "@cedarjs/cli-helpers/paths";
|
|
6
|
+
import { isTypeScriptProject } from "@cedarjs/cli-helpers/project";
|
|
7
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
10
8
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
11
9
|
import { printSetupNotes } from "../../../../lib/index.js";
|
|
12
10
|
const notes = [
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
|
-
import {
|
|
4
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
5
5
|
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
6
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
6
7
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
7
8
|
import {
|
|
8
9
|
addPackagesTask,
|
|
@@ -3,7 +3,8 @@ import { createRequire } from "node:module";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import execa from "execa";
|
|
5
5
|
import { Listr } from "listr2";
|
|
6
|
-
import {
|
|
6
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
7
|
+
import { writeFile } from "@cedarjs/cli-helpers/fileHelpers";
|
|
7
8
|
import { dedupe } from "@cedarjs/cli-helpers/packageManager";
|
|
8
9
|
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
9
10
|
import { addWorkspacePackages } from "@cedarjs/cli-helpers/packageManager/packages";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { terminalLink } from "termi-link";
|
|
4
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
4
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
5
5
|
const command = "generator <name>";
|
|
6
6
|
const description = "Copies generator templates locally for customization";
|
|
7
7
|
const EXCLUDE_GENERATORS = ["dataMigration", "dbAuth", "generator", "secret"];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
|
-
import { colors as c } from "@cedarjs/cli-helpers";
|
|
4
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
5
5
|
import { getPaths } from "../../../lib/index.js";
|
|
6
6
|
const SIDE_MAP = {
|
|
7
7
|
web: ["cell", "component", "layout", "page", "scaffold"],
|
|
@@ -2,12 +2,10 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
4
|
import { format } from "prettier";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
getPrettierOptions,
|
|
8
|
-
setTomlSetting
|
|
9
|
-
} from "@cedarjs/cli-helpers";
|
|
5
|
+
import { colors } from "@cedarjs/cli-helpers/colors";
|
|
6
|
+
import { getPrettierOptions } from "@cedarjs/cli-helpers/fileHelpers";
|
|
10
7
|
import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
8
|
+
import { setTomlSetting } from "@cedarjs/cli-helpers/project";
|
|
11
9
|
import { getConfig, getPaths } from "@cedarjs/project-config";
|
|
12
10
|
import { runTransform } from "../../../../../lib/runTransform.js";
|
|
13
11
|
const command = "fragments";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
2
2
|
const command = "trusted-documents";
|
|
3
3
|
const description = "Set up Trusted Documents for GraphQL";
|
|
4
4
|
function builder(yargs) {
|
|
@@ -2,8 +2,9 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
4
|
import { format } from "prettier";
|
|
5
|
-
import { getPrettierOptions
|
|
5
|
+
import { getPrettierOptions } from "@cedarjs/cli-helpers/fileHelpers";
|
|
6
6
|
import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
7
|
+
import { setTomlSetting } from "@cedarjs/cli-helpers/project";
|
|
7
8
|
import { getConfig, getPaths, resolveFile } from "@cedarjs/project-config";
|
|
8
9
|
import { runTransform } from "../../../../../lib/runTransform.js";
|
|
9
10
|
async function handler({ force }) {
|
|
@@ -2,7 +2,7 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
4
|
import { terminalLink } from "termi-link";
|
|
5
|
-
import { colors as c } from "@cedarjs/cli-helpers";
|
|
5
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
6
6
|
import { addWorkspacePackages } from "@cedarjs/cli-helpers/packageManager/packages";
|
|
7
7
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
8
8
|
import extendStorybookConfiguration from "../../../lib/configureStorybook.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { terminalLink } from "termi-link";
|
|
2
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
2
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
3
3
|
const command = "jobs";
|
|
4
4
|
const description = "Sets up the config file and parent directory for background jobs";
|
|
5
5
|
const builder = (yargs) => {
|
|
@@ -3,7 +3,8 @@ import * as path from "node:path";
|
|
|
3
3
|
import prismaInternals from "@prisma/internals";
|
|
4
4
|
import { Listr } from "listr2";
|
|
5
5
|
import { terminalLink } from "termi-link";
|
|
6
|
-
import {
|
|
6
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
7
|
+
import { addApiPackages } from "@cedarjs/cli-helpers/installHelpers";
|
|
7
8
|
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
8
9
|
import { getSchemaPath, getPrismaSchemas } from "@cedarjs/project-config";
|
|
9
10
|
import { getPaths, transformTSToJS, writeFile } from "../../../lib/index.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
2
2
|
const command = "mailer";
|
|
3
3
|
const description = "Setup the Cedar mailer. This will install the required packages and add the required initial configuration to your Cedar app.";
|
|
4
4
|
const builder = (yargs) => {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
|
-
import {
|
|
4
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
5
|
+
import { addApiPackages } from "@cedarjs/cli-helpers/installHelpers";
|
|
5
6
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
6
7
|
import { getPaths, transformTSToJS, writeFile } from "../../../lib/index.js";
|
|
7
8
|
import { isTypeScriptProject } from "../../../lib/project.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
2
2
|
const command = "og-image";
|
|
3
3
|
const aliases = ["ogImage", "ogimage"];
|
|
4
4
|
const description = "Set up OG Image generation middleware";
|
|
@@ -2,7 +2,8 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
4
|
import { format } from "prettier";
|
|
5
|
-
import {
|
|
5
|
+
import { getPrettierOptions } from "@cedarjs/cli-helpers/fileHelpers";
|
|
6
|
+
import { addWebPackages } from "@cedarjs/cli-helpers/installHelpers";
|
|
6
7
|
import { getConfig, getPaths } from "@cedarjs/project-config";
|
|
7
8
|
import { runTransform } from "../../../../lib/runTransform.js";
|
|
8
9
|
async function handler({ force }) {
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
|
+
import { colors } from "@cedarjs/cli-helpers/colors";
|
|
5
|
+
import { prettify, writeFilesTask } from "@cedarjs/cli-helpers/fileHelpers";
|
|
4
6
|
import {
|
|
5
7
|
addApiPackages,
|
|
8
|
+
addWebPackages
|
|
9
|
+
} from "@cedarjs/cli-helpers/installHelpers";
|
|
10
|
+
import { getPaths } from "@cedarjs/cli-helpers/paths";
|
|
11
|
+
import {
|
|
6
12
|
addEnvVarTask,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
getPaths,
|
|
10
|
-
isTypeScriptProject,
|
|
11
|
-
prettify,
|
|
12
|
-
writeFilesTask
|
|
13
|
-
} from "@cedarjs/cli-helpers";
|
|
13
|
+
isTypeScriptProject
|
|
14
|
+
} from "@cedarjs/cli-helpers/project";
|
|
14
15
|
import { getConfigPath } from "@cedarjs/project-config";
|
|
15
16
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
16
17
|
const rwPaths = getPaths();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
1
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
2
2
|
const command = "neon";
|
|
3
3
|
const description = "Provision a Neon Postgres database and configure your project";
|
|
4
4
|
function builder(yargs) {
|
|
@@ -3,8 +3,11 @@ import path from "node:path";
|
|
|
3
3
|
import execa from "execa";
|
|
4
4
|
import { Listr } from "listr2";
|
|
5
5
|
import prompts from "prompts";
|
|
6
|
-
import { colors
|
|
6
|
+
import { colors } from "@cedarjs/cli-helpers/colors";
|
|
7
|
+
import { installPackages } from "@cedarjs/cli-helpers/installHelpers";
|
|
7
8
|
import { prettyPrintCedarCommand } from "@cedarjs/cli-helpers/packageManager";
|
|
9
|
+
import { getPaths } from "@cedarjs/cli-helpers/paths";
|
|
10
|
+
import { requireTTYOrExit } from "@cedarjs/cli-helpers/tty";
|
|
8
11
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
9
12
|
import {
|
|
10
13
|
checkProjectShape,
|
|
@@ -54,14 +57,7 @@ async function handler({ force, migrations, verbose }) {
|
|
|
54
57
|
}
|
|
55
58
|
let runMigrations = migrations;
|
|
56
59
|
if (!skipProvisioning && runMigrations === void 0) {
|
|
57
|
-
|
|
58
|
-
const error = new Error(
|
|
59
|
-
"Cannot prompt for confirmation in a non-interactive terminal. Please pass --migrations or --no-migrations explicitly."
|
|
60
|
-
);
|
|
61
|
-
errorTelemetry(process.argv, error.message);
|
|
62
|
-
console.error(colors.error(error.message));
|
|
63
|
-
process.exit(1);
|
|
64
|
-
}
|
|
60
|
+
requireTTYOrExit("--migrations or --no-migrations");
|
|
65
61
|
const response = await prompts({
|
|
66
62
|
type: "toggle",
|
|
67
63
|
name: "runMigrations",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { terminalLink } from "termi-link";
|
|
2
|
-
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
2
|
+
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers/telemetry";
|
|
3
3
|
const command = "package <npm-package>";
|
|
4
4
|
const description = "Run a bin from an NPM package with version compatibility checks";
|
|
5
5
|
const builder = (yargs) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import enq from "enquirer";
|
|
2
|
-
import
|
|
3
|
-
import { getCompatibilityData } from "@cedarjs/cli-helpers";
|
|
2
|
+
import { isGreaterThanOrEqual, isLessThan, tryParse } from "verkit";
|
|
4
3
|
import { dlx } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
4
|
+
import { getCompatibilityData } from "@cedarjs/cli-helpers/version";
|
|
5
5
|
import { getPaths } from "@cedarjs/project-config";
|
|
6
6
|
async function handler({
|
|
7
7
|
npmPackage,
|
|
@@ -16,7 +16,7 @@ async function handler({
|
|
|
16
16
|
console.log(
|
|
17
17
|
"No compatibility check will be performed because you used the --force flag."
|
|
18
18
|
);
|
|
19
|
-
if (
|
|
19
|
+
if (tryParse(packageVersion) !== null && isLessThan(packageVersion, "1.0.0")) {
|
|
20
20
|
console.log(
|
|
21
21
|
"Be aware that this package is under version 1.0.0 and so should be considered experimental."
|
|
22
22
|
);
|
|
@@ -86,7 +86,7 @@ The latest version compatible with your project is ${latestCompatibleVersionText
|
|
|
86
86
|
await runPackage(packageName, versionToUse, additionalOptionsToForward);
|
|
87
87
|
}
|
|
88
88
|
async function showExperimentalWarning(version) {
|
|
89
|
-
if (version === void 0 ||
|
|
89
|
+
if (version === void 0 || tryParse(version) === null || isGreaterThanOrEqual(version, "1.0.0")) {
|
|
90
90
|
return;
|
|
91
91
|
}
|
|
92
92
|
const decision = await promptWithChoices(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { isTypeScriptProject } from "@cedarjs/cli-helpers";
|
|
3
|
+
import { isTypeScriptProject } from "@cedarjs/cli-helpers/project";
|
|
4
4
|
import { getPaths } from "@cedarjs/project-config";
|
|
5
5
|
function addRealtimeToGraphqlHandler(ctx, task, force) {
|
|
6
6
|
const graphqlHandlerPath = path.join(
|
|
@@ -2,10 +2,10 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
4
|
import prompts from "prompts";
|
|
5
|
-
import {
|
|
5
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
6
|
+
import { addApiPackages } from "@cedarjs/cli-helpers/installHelpers";
|
|
6
7
|
import { runBinSync } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
7
8
|
import { generate as generateTypes } from "@cedarjs/internal/dist/generate/generate";
|
|
8
|
-
import { projectIsEsm } from "@cedarjs/project-config";
|
|
9
9
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
10
10
|
import { getPaths, transformTSToJS, writeFile } from "../../../lib/index.js";
|
|
11
11
|
import { isTypeScriptProject, serverFileExists } from "../../../lib/project.js";
|
|
@@ -77,7 +77,7 @@ async function handler(args) {
|
|
|
77
77
|
title: "Adding Countdown example subscription...",
|
|
78
78
|
enabled: () => includeExamples,
|
|
79
79
|
task: async () => {
|
|
80
|
-
|
|
80
|
+
const exampleSubscriptionTemplateContent = fs.readFileSync(
|
|
81
81
|
path.resolve(
|
|
82
82
|
import.meta.dirname,
|
|
83
83
|
"templates",
|
|
@@ -87,12 +87,6 @@ async function handler(args) {
|
|
|
87
87
|
),
|
|
88
88
|
"utf-8"
|
|
89
89
|
);
|
|
90
|
-
if (projectIsEsm()) {
|
|
91
|
-
exampleSubscriptionTemplateContent = exampleSubscriptionTemplateContent.replace(
|
|
92
|
-
"import gql from 'graphql-tag'",
|
|
93
|
-
"import { gql } from 'graphql-tag'"
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
90
|
const exampleFile = path.join(
|
|
97
91
|
cedarPaths.api.subscriptions,
|
|
98
92
|
"countdown",
|
|
@@ -144,7 +138,7 @@ async function handler(args) {
|
|
|
144
138
|
`rooms.${isTypeScriptProject() ? "ts" : "js"}`
|
|
145
139
|
);
|
|
146
140
|
const serviceContent = ts ? exampleServiceTemplateContent : await transformTSToJS(serviceFile, exampleServiceTemplateContent);
|
|
147
|
-
|
|
141
|
+
const exampleSubscriptionTemplateContent = fs.readFileSync(
|
|
148
142
|
path.resolve(
|
|
149
143
|
import.meta.dirname,
|
|
150
144
|
"templates",
|
|
@@ -154,12 +148,6 @@ async function handler(args) {
|
|
|
154
148
|
),
|
|
155
149
|
"utf-8"
|
|
156
150
|
);
|
|
157
|
-
if (projectIsEsm()) {
|
|
158
|
-
exampleSubscriptionTemplateContent = exampleSubscriptionTemplateContent.replace(
|
|
159
|
-
"import gql from 'graphql-tag'",
|
|
160
|
-
"import { gql } from 'graphql-tag'"
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
151
|
const exampleFile = path.join(
|
|
164
152
|
cedarPaths.api.subscriptions,
|
|
165
153
|
"newMessage",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
|
-
import {
|
|
4
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
5
|
+
import { addApiPackages } from "@cedarjs/cli-helpers/installHelpers";
|
|
5
6
|
import { errorTelemetry } from "@cedarjs/telemetry";
|
|
6
7
|
import { getPaths, transformTSToJS, writeFile } from "../../../lib/index.js";
|
|
7
8
|
import { isTypeScriptProject } from "../../../lib/project.js";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import j from "jscodeshift";
|
|
2
|
+
function buildMembershipsSelectProperty() {
|
|
3
|
+
const snippet = `
|
|
4
|
+
const __tenancySnippet = {
|
|
5
|
+
memberships: {
|
|
6
|
+
select: {
|
|
7
|
+
id: true,
|
|
8
|
+
organizationId: true,
|
|
9
|
+
role: true,
|
|
10
|
+
organization: { select: { id: true, slug: true, name: true } },
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
const property = j.withParser("ts")(snippet).find(j.ObjectProperty, { key: { name: "memberships" } }).nodes()[0];
|
|
16
|
+
if (!property) {
|
|
17
|
+
throw new Error("CEDAR_CODEMOD_ERR_AUTH_SHAPE_NOT_FOUND");
|
|
18
|
+
}
|
|
19
|
+
return property;
|
|
20
|
+
}
|
|
21
|
+
function transform(fileInfo) {
|
|
22
|
+
const root = j.withParser("tsx")(fileInfo.source);
|
|
23
|
+
let selectFound = false;
|
|
24
|
+
root.find(j.CallExpression, {
|
|
25
|
+
callee: {
|
|
26
|
+
type: "MemberExpression",
|
|
27
|
+
object: {
|
|
28
|
+
type: "MemberExpression",
|
|
29
|
+
object: { name: "db" },
|
|
30
|
+
property: { name: "user" }
|
|
31
|
+
},
|
|
32
|
+
property: { name: "findUnique" }
|
|
33
|
+
}
|
|
34
|
+
}).forEach((path) => {
|
|
35
|
+
const [args] = path.node.arguments;
|
|
36
|
+
if (!j.ObjectExpression.check(args)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const selectProperty = args.properties.find(
|
|
40
|
+
(prop) => j.ObjectProperty.check(prop) && j.Identifier.check(prop.key) && prop.key.name === "select"
|
|
41
|
+
);
|
|
42
|
+
if (!selectProperty || !j.ObjectProperty.check(selectProperty) || !j.ObjectExpression.check(selectProperty.value)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const alreadyHasMemberships = selectProperty.value.properties.some(
|
|
46
|
+
(prop) => j.ObjectProperty.check(prop) && j.Identifier.check(prop.key) && prop.key.name === "memberships"
|
|
47
|
+
);
|
|
48
|
+
if (!alreadyHasMemberships) {
|
|
49
|
+
selectProperty.value.properties.push(buildMembershipsSelectProperty());
|
|
50
|
+
}
|
|
51
|
+
selectFound = true;
|
|
52
|
+
});
|
|
53
|
+
if (!selectFound) {
|
|
54
|
+
throw new Error("CEDAR_CODEMOD_ERR_AUTH_SHAPE_NOT_FOUND");
|
|
55
|
+
}
|
|
56
|
+
const tenancyExportSnippet = `export { hasOrgRole, requireMembership } from '@cedarjs/tenancy'
|
|
57
|
+
`;
|
|
58
|
+
const tenancyExport = j.withParser("ts")(tenancyExportSnippet).find(j.ExportNamedDeclaration).nodes()[0];
|
|
59
|
+
root.find(j.Program).forEach((path) => {
|
|
60
|
+
path.node.body.push(tenancyExport);
|
|
61
|
+
});
|
|
62
|
+
return root.toSource();
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
transform as default
|
|
66
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import j from "jscodeshift";
|
|
2
|
+
const DEFAULT_GLOBAL_MODELS = ["user", "organization", "membership"];
|
|
3
|
+
function transform(fileInfo, _api, options) {
|
|
4
|
+
const root = j.withParser("tsx")(fileInfo.source);
|
|
5
|
+
const tenantField = typeof options.tenantField === "string" ? options.tenantField : void 0;
|
|
6
|
+
const imports = root.find(j.ImportDeclaration);
|
|
7
|
+
imports.at(-1).insertAfter(
|
|
8
|
+
j.importDeclaration(
|
|
9
|
+
[j.importSpecifier(j.identifier("createTenancyExtension"))],
|
|
10
|
+
j.literal("@cedarjs/tenancy")
|
|
11
|
+
)
|
|
12
|
+
);
|
|
13
|
+
const configProperties = [
|
|
14
|
+
...tenantField ? [
|
|
15
|
+
j.objectProperty(
|
|
16
|
+
j.identifier("tenantField"),
|
|
17
|
+
j.stringLiteral(tenantField)
|
|
18
|
+
)
|
|
19
|
+
] : [],
|
|
20
|
+
j.objectProperty(
|
|
21
|
+
j.identifier("models"),
|
|
22
|
+
j.objectExpression([
|
|
23
|
+
j.objectProperty(
|
|
24
|
+
j.identifier("allExcept"),
|
|
25
|
+
j.arrayExpression(
|
|
26
|
+
DEFAULT_GLOBAL_MODELS.map((name) => j.stringLiteral(name))
|
|
27
|
+
)
|
|
28
|
+
)
|
|
29
|
+
])
|
|
30
|
+
)
|
|
31
|
+
];
|
|
32
|
+
let found = false;
|
|
33
|
+
root.find(j.VariableDeclaration, { declarations: [{ id: { name: "db" } }] }).forEach((path) => {
|
|
34
|
+
const dbDeclaration = path.node.declarations[0];
|
|
35
|
+
if (!j.VariableDeclarator.check(dbDeclaration)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (j.NewExpression.check(dbDeclaration.init)) {
|
|
39
|
+
throw new Error("CEDAR_CODEMOD_ERR_OLD_FORMAT");
|
|
40
|
+
}
|
|
41
|
+
if (!j.Expression.check(dbDeclaration.init)) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
found = true;
|
|
45
|
+
const extensionCall = j.callExpression(
|
|
46
|
+
j.identifier("createTenancyExtension"),
|
|
47
|
+
[j.objectExpression(configProperties)]
|
|
48
|
+
);
|
|
49
|
+
dbDeclaration.init = j.callExpression(
|
|
50
|
+
j.memberExpression(dbDeclaration.init, j.identifier("$extends")),
|
|
51
|
+
[extensionCall]
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
if (!found) {
|
|
55
|
+
throw new Error("CEDAR_CODEMOD_ERR_DB_SHAPE_NOT_FOUND");
|
|
56
|
+
}
|
|
57
|
+
return root.toSource().replace(
|
|
58
|
+
"createTenancyExtension(",
|
|
59
|
+
"createTenancyExtension<typeof prismaClient>("
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
transform as default
|
|
64
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import j from "jscodeshift";
|
|
2
|
+
function buildContextProperty() {
|
|
3
|
+
const snippet = `
|
|
4
|
+
const __tenancySnippet = {
|
|
5
|
+
context: async ({ context: gqlContext }) => {
|
|
6
|
+
const { currentUser, event, request, params } = gqlContext
|
|
7
|
+
|
|
8
|
+
// A user whose getCurrentUser result doesn't carry memberships
|
|
9
|
+
// can't be matched to an organization, so the request runs with
|
|
10
|
+
// no current organization set.
|
|
11
|
+
if (!isUserWithMemberships(currentUser)) {
|
|
12
|
+
return {}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Yoga can populate either \`event\` (Lambda-style deployments) or
|
|
16
|
+
// \`request\` (Fetch-API-style deployments); resolveCurrentOrg reads
|
|
17
|
+
// the organization header off either.
|
|
18
|
+
const requestEvent = event ?? request
|
|
19
|
+
|
|
20
|
+
if (!requestEvent) {
|
|
21
|
+
return {}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const currentOrg = await resolveCurrentOrg({
|
|
25
|
+
event: requestEvent,
|
|
26
|
+
variables: params.variables,
|
|
27
|
+
currentUser,
|
|
28
|
+
lookupOrg: async (idOrSlug) =>
|
|
29
|
+
(await db.organization.findUnique({
|
|
30
|
+
where: { id: idOrSlug },
|
|
31
|
+
select: { id: true, slug: true },
|
|
32
|
+
})) ??
|
|
33
|
+
db.organization.findUnique({
|
|
34
|
+
where: { slug: idOrSlug },
|
|
35
|
+
select: { id: true, slug: true },
|
|
36
|
+
}),
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
return { currentOrg }
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
const property = j.withParser("ts")(snippet).find(j.ObjectProperty, { key: { name: "context" } }).nodes()[0];
|
|
44
|
+
if (!property) {
|
|
45
|
+
throw new Error("CEDAR_CODEMOD_ERR_GRAPHQL_HANDLER_NOT_FOUND");
|
|
46
|
+
}
|
|
47
|
+
return property;
|
|
48
|
+
}
|
|
49
|
+
function addNamedImport(root, names, source) {
|
|
50
|
+
const imports = root.find(j.ImportDeclaration);
|
|
51
|
+
imports.at(-1).insertAfter(
|
|
52
|
+
j.importDeclaration(
|
|
53
|
+
names.map((name) => j.importSpecifier(j.identifier(name))),
|
|
54
|
+
j.literal(source)
|
|
55
|
+
)
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
function transform(fileInfo) {
|
|
59
|
+
const root = j.withParser("tsx")(fileInfo.source);
|
|
60
|
+
const handlerCalls = root.find(j.CallExpression, {
|
|
61
|
+
callee: { name: "createGraphQLHandler" }
|
|
62
|
+
});
|
|
63
|
+
if (handlerCalls.length === 0) {
|
|
64
|
+
throw new Error("CEDAR_CODEMOD_ERR_GRAPHQL_HANDLER_NOT_FOUND");
|
|
65
|
+
}
|
|
66
|
+
handlerCalls.forEach((path) => {
|
|
67
|
+
const [config] = path.node.arguments;
|
|
68
|
+
if (!j.ObjectExpression.check(config)) {
|
|
69
|
+
throw new Error("CEDAR_CODEMOD_ERR_GRAPHQL_HANDLER_NOT_FOUND");
|
|
70
|
+
}
|
|
71
|
+
const hasContext = config.properties.some(
|
|
72
|
+
(prop) => j.ObjectProperty.check(prop) && j.Identifier.check(prop.key) && prop.key.name === "context"
|
|
73
|
+
);
|
|
74
|
+
if (hasContext) {
|
|
75
|
+
throw new Error("CEDAR_CODEMOD_ERR_GRAPHQL_CONTEXT_EXISTS");
|
|
76
|
+
}
|
|
77
|
+
config.properties.push(buildContextProperty());
|
|
78
|
+
});
|
|
79
|
+
addNamedImport(
|
|
80
|
+
root,
|
|
81
|
+
["isUserWithMemberships", "resolveCurrentOrg"],
|
|
82
|
+
"@cedarjs/tenancy"
|
|
83
|
+
);
|
|
84
|
+
return root.toSource();
|
|
85
|
+
}
|
|
86
|
+
export {
|
|
87
|
+
transform as default
|
|
88
|
+
};
|