@cedarjs/cli 9.0.0-canary.1784 → 9.0.0-canary.3124
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/README.md +7 -10
- package/dist/cfw.js +10 -6
- package/dist/commands/build/buildHandler.js +220 -45
- package/dist/commands/build/buildPackagesTask.js +21 -20
- package/dist/commands/build.js +13 -2
- package/dist/commands/check.js +4 -6
- package/dist/commands/console.js +6 -4
- package/dist/commands/deploy/baremetal/SshExecutor.js +13 -4
- package/dist/commands/deploy/baremetal/baremetalHandler.js +116 -50
- package/dist/commands/deploy/baremetal.js +11 -4
- package/dist/commands/deploy/flightcontrolHandler.js +28 -15
- package/dist/commands/deploy/helpers/deployHandler.js +11 -6
- package/dist/commands/deploy/netlify.js +1 -1
- package/dist/commands/deploy/packing/nft.js +1 -2
- package/dist/commands/deploy/render.js +1 -1
- package/dist/commands/deploy/renderHandler.js +24 -13
- package/dist/commands/deploy/serverlessHandler.js +69 -27
- package/dist/commands/deploy/vercel.js +1 -1
- 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 +17 -17
- package/dist/commands/destroy/helpers.js +8 -2
- package/dist/commands/destroy/layout/layout.js +1 -2
- package/dist/commands/destroy/page/pageHandler.js +3 -3
- package/dist/commands/destroy/scaffold/scaffoldHandler.js +31 -12
- package/dist/commands/destroy/sdl/sdlHandler.js +3 -3
- package/dist/commands/dev/apiDebugFlag.js +5 -4
- package/dist/commands/dev/devHandler.js +219 -68
- package/dist/commands/dev/packageWatchCommands.js +8 -3
- package/dist/commands/dev.js +16 -6
- package/dist/commands/execHandler.js +49 -29
- package/dist/commands/experimental/live-queries/liveQueries.js +32 -0
- package/dist/commands/experimental/live-queries/liveQueriesHandler.js +448 -0
- package/dist/commands/experimental/live-queries/templates/liveQueriesListener.ts.template +153 -0
- package/dist/commands/experimental/live-queries/templates/migration.sql.template +100 -0
- package/dist/commands/experimental/setupInngest.js +2 -2
- package/dist/commands/experimental/setupInngestHandler.js +13 -12
- package/dist/commands/experimental/setupOpentelemetry.js +2 -2
- package/dist/commands/experimental/setupOpentelemetryHandler.js +14 -10
- package/dist/commands/experimental/setupReactCompiler.js +2 -2
- package/dist/commands/experimental/setupReactCompilerHandler.js +48 -33
- package/dist/commands/experimental/setupRsc.js +1 -1
- package/dist/commands/experimental/setupRscHandler.js +20 -16
- package/dist/commands/experimental/setupStreamingSsr.js +2 -2
- package/dist/commands/experimental/setupStreamingSsrHandler.js +49 -34
- package/dist/commands/experimental/templates/opentelemetry.ts.template +2 -1
- 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/templates/streamingSsr/tsconfig.json.template +6 -6
- package/dist/commands/experimental/util.js +27 -25
- package/dist/commands/experimental.js +3 -2
- package/dist/commands/generate/cell/cell.js +20 -0
- package/dist/commands/generate/cell/cellHandler.js +89 -40
- 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/component/componentHandler.js +14 -16
- package/dist/commands/generate/dataMigration/dataMigration.js +36 -18
- package/dist/commands/generate/dataMigration/templates/dataMigration.js.template +1 -1
- package/dist/commands/generate/dataMigration/templates/dataMigration.ts.template +1 -1
- package/dist/commands/generate/dbAuth/dbAuth.js +1 -0
- package/dist/commands/generate/dbAuth/dbAuthHandler.js +63 -34
- 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 +14 -16
- package/dist/commands/generate/function/function.js +1 -0
- package/dist/commands/generate/function/functionHandler.js +14 -19
- package/dist/commands/generate/helpers.js +34 -18
- package/dist/commands/generate/job/job.js +1 -0
- package/dist/commands/generate/job/jobHandler.js +20 -24
- 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 +11 -5
- package/dist/commands/generate/ogImage/ogImage.js +1 -0
- package/dist/commands/generate/ogImage/ogImageHandler.js +18 -11
- package/dist/commands/generate/package/filesTask.js +9 -0
- package/dist/commands/generate/package/packageHandler.js +50 -61
- package/dist/commands/generate/package/templates/test.ts.template +2 -2
- package/dist/commands/generate/package/templates/vitest.config.ts.template +9 -0
- package/dist/commands/generate/page/pageHandler.js +27 -24
- package/dist/commands/generate/realtime/realtime.js +2 -2
- package/dist/commands/generate/realtime/realtimeHandler.js +51 -32
- package/dist/commands/generate/realtime/templates/subscriptions/blank/blank.ts.template +1 -1
- package/dist/commands/generate/scaffold/scaffold.js +1 -0
- package/dist/commands/generate/scaffold/scaffoldHandler.js +176 -49
- package/dist/commands/generate/scaffold/templates/lib/formatters.tsx.template +1 -1
- package/dist/commands/generate/script/script.js +1 -0
- package/dist/commands/generate/script/scriptHandler.js +10 -6
- package/dist/commands/generate/script/templates/script.ts.template +9 -4
- package/dist/commands/generate/script/templates/tsconfig.json.template +16 -2
- package/dist/commands/generate/sdl/sdl.js +4 -3
- package/dist/commands/generate/sdl/sdlHandler.js +135 -46
- package/dist/commands/generate/sdl/stubFiles.js +132 -0
- package/dist/commands/generate/sdl/templates/sdl.js.template +2 -1
- package/dist/commands/generate/sdl/templates/sdl.ts.template +2 -1
- package/dist/commands/generate/secret/secret.js +20 -20
- package/dist/commands/generate/service/service.js +5 -5
- package/dist/commands/generate/service/serviceHandler.js +126 -61
- package/dist/commands/generate/service/templates/scenarios.ts.template +4 -2
- package/dist/commands/generate/service/templates/service.ts.template +22 -8
- package/dist/commands/generate/service/templates/test.ts.template +2 -2
- package/dist/commands/generate/yargsCommandHelpers.js +7 -2
- package/dist/commands/generate/yargsHandlerHelpers.js +20 -18
- package/dist/commands/generate.js +4 -4
- package/dist/commands/info.js +2 -2
- package/dist/commands/jobsHandler.js +7 -4
- package/dist/commands/lint.js +26 -69
- package/dist/commands/prerenderHandler.js +95 -58
- package/dist/commands/prismaHandler.js +51 -26
- package/dist/commands/record/init.js +2 -2
- package/dist/commands/record.js +4 -3
- package/dist/commands/serve.js +245 -31
- package/dist/commands/serveApiHandler.js +7 -6
- package/dist/commands/serveBothHandler.js +22 -13
- package/dist/commands/serveWebHandler.js +3 -2
- package/dist/commands/setup/auth/auth.js +15 -11
- package/dist/commands/setup/cache/cache.js +1 -1
- package/dist/commands/setup/cache/cacheHandler.js +15 -9
- package/dist/commands/setup/database/database.js +15 -0
- package/dist/commands/setup/database/postgres.js +19 -0
- package/dist/commands/setup/database/postgresHandler.js +196 -0
- package/dist/commands/setup/database/templates/db.ts.template +32 -0
- 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 +132 -6
- package/dist/commands/setup/deploy/providers/baremetalHandler.js +28 -6
- package/dist/commands/setup/deploy/providers/coherence.js +1 -1
- package/dist/commands/setup/deploy/providers/coherenceHandler.js +60 -31
- package/dist/commands/setup/deploy/providers/flightcontrolHandler.js +69 -51
- package/dist/commands/setup/deploy/providers/netlify.js +6 -0
- package/dist/commands/setup/deploy/providers/netlifyHandler.js +114 -13
- package/dist/commands/setup/deploy/providers/renderHandler.js +44 -41
- package/dist/commands/setup/deploy/providers/serverlessHandler.js +7 -5
- package/dist/commands/setup/deploy/providers/universal-deploy.js +11 -0
- package/dist/commands/setup/deploy/providers/universalDeployHandler.js +186 -0
- package/dist/commands/setup/deploy/providers/vercel.js +6 -0
- package/dist/commands/setup/deploy/providers/vercelHandler.js +115 -14
- 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/deploy/templates/render.js +32 -17
- package/dist/commands/setup/docker/docker.js +2 -2
- package/dist/commands/setup/docker/dockerHandler.js +74 -39
- 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} +4 -7
- package/dist/commands/setup/docker/templates/docker-compose.dev.yml +3 -3
- package/dist/commands/setup/docker/templates/docker-compose.prod.yml +2 -5
- package/dist/commands/setup/docker/templates/dockerignore +1 -0
- package/dist/commands/setup/generator/generator.js +1 -1
- package/dist/commands/setup/generator/generatorHandler.js +5 -4
- package/dist/commands/setup/graphql/features/fragments/appGqlConfigTransform.js +6 -3
- package/dist/commands/setup/graphql/features/fragments/fragments.js +1 -1
- package/dist/commands/setup/graphql/features/fragments/fragmentsHandler.js +5 -7
- package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocuments.js +1 -1
- package/dist/commands/setup/graphql/features/trustedDocuments/trustedDocumentsHandler.js +4 -3
- package/dist/commands/setup/i18n/i18n.js +1 -1
- package/dist/commands/setup/i18n/i18nHandler.js +21 -17
- package/dist/commands/setup/jobs/jobs.js +1 -1
- package/dist/commands/setup/jobs/jobsHandler.js +17 -12
- package/dist/commands/setup/mailer/mailer.js +1 -1
- package/dist/commands/setup/mailer/mailerHandler.js +13 -11
- 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 +18 -12
- package/dist/commands/setup/neon/neon.js +35 -0
- package/dist/commands/setup/neon/neonHandler.js +264 -0
- package/dist/commands/setup/package/package.js +1 -1
- package/dist/commands/setup/package/packageHandler.js +18 -14
- 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 +26 -37
- package/dist/commands/setup/realtime/templates/realtime.ts.template +1 -1
- 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 +18 -10
- 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/helpers/helpers.js +5 -1
- package/dist/commands/setup/ui/libraries/chakra-uiHandler.js +16 -8
- package/dist/commands/setup/ui/libraries/mantineHandler.js +26 -16
- package/dist/commands/setup/ui/libraries/tailwindcssHandler.js +40 -29
- 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 +266 -72
- package/dist/commands/setup.js +5 -4
- package/dist/commands/studio.js +1 -1
- package/dist/commands/studioHandler.js +2 -2
- package/dist/commands/test/datasourceWarning.js +42 -0
- package/dist/commands/test/testHandler.js +104 -0
- package/dist/commands/test/viteVersionCheck.js +75 -0
- package/dist/commands/test.js +16 -19
- package/dist/commands/type-check.js +2 -1
- package/dist/commands/type-checkHandler.js +25 -18
- package/dist/commands/upgrade/preUpgradeScripts.js +11 -11
- package/dist/commands/upgrade/upgrade.js +4 -2
- package/dist/commands/upgrade/upgradeHandler.js +97 -73
- package/dist/index.js +15 -11
- package/dist/lib/background.js +22 -1
- package/dist/lib/configureStorybook.js +2 -2
- package/dist/lib/exec.js +68 -63
- package/dist/lib/exit.js +20 -5
- package/dist/lib/extendFile.js +23 -13
- package/dist/lib/generatePrismaClient.js +48 -12
- package/dist/lib/index.js +137 -106
- package/dist/lib/loadEnvFiles.js +1 -1
- package/dist/lib/locking.js +8 -4
- package/dist/lib/merge/algorithms.js +4 -1
- package/dist/lib/merge/index.js +78 -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 +13 -7
- package/dist/lib/pluralHelpers.js +6 -2
- package/dist/lib/project.js +3 -1
- package/dist/lib/rollback.js +7 -7
- package/dist/lib/schemaHelpers.js +16 -19
- package/dist/lib/test.js +20 -5
- package/dist/lib/updateCheck.js +47 -18
- package/dist/middleware/checkNodeVersion.js +9 -4
- package/dist/middleware/{detectProjectRxVersion.js → detectProjectCedarVersion.js} +2 -2
- 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 -12
- package/dist/telemetry/send.js +14 -10
- package/dist/testLib/cells.js +5 -3
- package/package.json +44 -41
- package/LICENSE +0 -21
- package/dist/commands/consoleHandler.js +0 -68
- package/dist/commands/setup/tsconfig/tsconfig.js +0 -25
- package/dist/commands/setup/tsconfig/tsconfigHandler.js +0 -59
- package/dist/commands/setup/uploads/dbCodemod.js +0 -28
- package/dist/commands/setup/uploads/templates/signedUrl.ts.template +0 -21
- 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 -83
- package/dist/commands/testEsm.js +0 -36
- package/dist/commands/testHandler.js +0 -137
- package/dist/commands/testHandlerEsm.js +0 -85
- package/dist/commands/ts-to-js.js +0 -20
- package/dist/lib/cedarPluralize.js +0 -56
- package/dist/lib/colors.js +0 -18
- package/dist/testLib/getFilesWithPattern.js +0 -21
- /package/dist/{index.d.js → global.d.js} +0 -0
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import prismaInternals from "@prisma/internals";
|
|
2
|
-
import {
|
|
3
|
-
import { singularize, isPlural } from "
|
|
2
|
+
import { getPrismaSchemas } from "@cedarjs/project-config";
|
|
3
|
+
import { singularize, isPlural } from "@cedarjs/utils/cedarPluralize";
|
|
4
4
|
import { ensureUniquePlural } from "./pluralHelpers.js";
|
|
5
|
-
|
|
6
|
-
const { getConfig, getDMMF, getSchemaWithPath } = prismaInternals;
|
|
5
|
+
const { getConfig, getDMMF } = prismaInternals;
|
|
7
6
|
const schemaMemo = {};
|
|
8
7
|
const getExistingModelName = async (name) => {
|
|
9
8
|
if (!name) {
|
|
10
9
|
return void 0;
|
|
11
10
|
}
|
|
12
11
|
const modelName = name.replace(/[_-]/g, "").toLowerCase();
|
|
13
|
-
for (
|
|
12
|
+
for (const model of Object.values(schemaMemo)) {
|
|
14
13
|
if (model.name.toLowerCase() === modelName) {
|
|
15
14
|
return model.name;
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
17
|
const schema = (await getSchemaDefinitions()).datamodel;
|
|
19
|
-
for (
|
|
18
|
+
for (const model of schema.models) {
|
|
20
19
|
if (model.name.toLowerCase() === modelName) {
|
|
21
20
|
return model.name;
|
|
22
21
|
}
|
|
@@ -37,25 +36,24 @@ const getSchema = async (name) => {
|
|
|
37
36
|
if (schemaMemo[modelName]) {
|
|
38
37
|
return schemaMemo[modelName];
|
|
39
38
|
}
|
|
40
|
-
const model = schema.models.find((
|
|
39
|
+
const model = schema.models.find((m) => m.name === modelName);
|
|
41
40
|
if (!model) {
|
|
42
41
|
return void 0;
|
|
43
42
|
}
|
|
44
|
-
model.fields.
|
|
43
|
+
const enrichedFields = model.fields.map((field) => {
|
|
45
44
|
const fieldEnum = schema.enums.find((e) => field.type === e.name);
|
|
46
|
-
|
|
47
|
-
field.enumValues = fieldEnum.values;
|
|
48
|
-
}
|
|
45
|
+
return fieldEnum ? { ...field, enumValues: fieldEnum.values } : { ...field };
|
|
49
46
|
});
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
const enrichedModel = { ...model, fields: enrichedFields };
|
|
48
|
+
schemaMemo[modelName] = enrichedModel;
|
|
49
|
+
return enrichedModel;
|
|
52
50
|
};
|
|
53
51
|
const getEnum = async (name) => {
|
|
54
52
|
const schema = await getSchemaDefinitions();
|
|
55
53
|
if (!name) {
|
|
56
|
-
return schema.metadata.datamodel.enums;
|
|
54
|
+
return [...schema.metadata.datamodel.enums];
|
|
57
55
|
}
|
|
58
|
-
const model = schema.datamodel.enums.find((
|
|
56
|
+
const model = schema.datamodel.enums.find((e) => e.name === name);
|
|
59
57
|
if (!model) {
|
|
60
58
|
throw new Error(
|
|
61
59
|
`No enum schema definition found for \`${name}\` in schema.prisma file`
|
|
@@ -64,13 +62,12 @@ const getEnum = async (name) => {
|
|
|
64
62
|
return model;
|
|
65
63
|
};
|
|
66
64
|
const getDataModel = async () => {
|
|
67
|
-
const
|
|
68
|
-
const schemaPath = await getSchemaPath(prismaConfigPath);
|
|
69
|
-
const result = await getSchemaWithPath(schemaPath);
|
|
65
|
+
const result = await getPrismaSchemas();
|
|
70
66
|
return result.schemas;
|
|
71
67
|
};
|
|
72
68
|
const getSchemaDefinitions = async () => {
|
|
73
|
-
|
|
69
|
+
const document = await getDMMF({ datamodel: await getDataModel() });
|
|
70
|
+
return document;
|
|
74
71
|
};
|
|
75
72
|
const getSchemaConfig = async () => {
|
|
76
73
|
return getConfig({
|
package/dist/lib/test.js
CHANGED
|
@@ -26,6 +26,7 @@ vi.mock("@cedarjs/project-config", async (importOriginal) => {
|
|
|
26
26
|
),
|
|
27
27
|
dataMigrations: path.join(BASE_PATH, "./api/dataMigrations"),
|
|
28
28
|
src: path.join(BASE_PATH, "./api/src"),
|
|
29
|
+
lib: path.join(BASE_PATH, "./api/src/lib"),
|
|
29
30
|
jobs: path.join(BASE_PATH, "./api/src/jobs"),
|
|
30
31
|
services: path.join(BASE_PATH, "./api/src/services"),
|
|
31
32
|
directives: path.join(BASE_PATH, "./api/src/directives"),
|
|
@@ -48,11 +49,11 @@ vi.mock("@cedarjs/project-config", async (importOriginal) => {
|
|
|
48
49
|
packages: path.join(BASE_PATH, "packages"),
|
|
49
50
|
generatorTemplates: path.join(BASE_PATH, "generatorTemplates"),
|
|
50
51
|
generated: {
|
|
51
|
-
base: path.join(BASE_PATH, ".
|
|
52
|
-
schema: path.join(BASE_PATH, ".
|
|
52
|
+
base: path.join(BASE_PATH, ".cedar"),
|
|
53
|
+
schema: path.join(BASE_PATH, ".cedar/schema.graphql"),
|
|
53
54
|
types: {
|
|
54
|
-
includes: path.join(BASE_PATH, ".
|
|
55
|
-
mirror: path.join(BASE_PATH, ".
|
|
55
|
+
includes: path.join(BASE_PATH, ".cedar/types/includes"),
|
|
56
|
+
mirror: path.join(BASE_PATH, ".cedar/types/mirror")
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
};
|
|
@@ -60,12 +61,26 @@ vi.mock("@cedarjs/project-config", async (importOriginal) => {
|
|
|
60
61
|
getSchemaPath: () => {
|
|
61
62
|
return path.join(globalThis.__dirname, "fixtures", "schema.prisma");
|
|
62
63
|
},
|
|
64
|
+
getPrismaSchemas: async () => {
|
|
65
|
+
const schemaPath = path.join(
|
|
66
|
+
globalThis.__dirname,
|
|
67
|
+
"fixtures",
|
|
68
|
+
"schema.prisma"
|
|
69
|
+
);
|
|
70
|
+
return {
|
|
71
|
+
schemas: [[schemaPath, fs.readFileSync(schemaPath, "utf-8")]]
|
|
72
|
+
};
|
|
73
|
+
},
|
|
63
74
|
getDataMigrationsPath: () => {
|
|
64
75
|
return path.join(globalThis.__dirname, "fixtures", "migrations");
|
|
65
76
|
}
|
|
66
77
|
};
|
|
67
78
|
});
|
|
68
|
-
vi.mock("@cedarjs/
|
|
79
|
+
vi.mock("@cedarjs/project-config/packageManager", () => ({
|
|
80
|
+
getPackageManager: vi.fn(() => "yarn"),
|
|
81
|
+
resetPackageManagerCache: vi.fn()
|
|
82
|
+
}));
|
|
83
|
+
vi.mock("@cedarjs/cli-helpers/project", async (importOriginal) => {
|
|
69
84
|
const originalCliHelpers = await importOriginal();
|
|
70
85
|
return {
|
|
71
86
|
...originalCliHelpers,
|
package/dist/lib/updateCheck.js
CHANGED
|
@@ -3,7 +3,9 @@ import path from "path";
|
|
|
3
3
|
import ansis from "ansis";
|
|
4
4
|
import boxen from "boxen";
|
|
5
5
|
import latestVersion from "latest-version";
|
|
6
|
-
import
|
|
6
|
+
import { isGreater, isValid } from "verkit";
|
|
7
|
+
import { formatCedarCommand } from "@cedarjs/cli-helpers/packageManager/display";
|
|
8
|
+
import { getNodeRunnerArgs } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
7
9
|
import { getConfig } from "@cedarjs/project-config";
|
|
8
10
|
import { spawnBackgroundProcess } from "./background.js";
|
|
9
11
|
import { isLockSet, setLock, unsetLock } from "./locking.js";
|
|
@@ -13,7 +15,7 @@ const SHOW_PERIOD = 24 * 60 * 6e4;
|
|
|
13
15
|
const DEFAULT_DATETIME_MS = 9466848e5;
|
|
14
16
|
const CHECK_LOCK_IDENTIFIER = "UPDATE_CHECK";
|
|
15
17
|
const SHOW_LOCK_IDENTIFIER = "UPDATE_CHECK_SHOW";
|
|
16
|
-
const EXCLUDED_COMMANDS = ["upgrade"
|
|
18
|
+
const EXCLUDED_COMMANDS = ["upgrade"];
|
|
17
19
|
let persistenceDirectory;
|
|
18
20
|
function getPersistenceDirectory() {
|
|
19
21
|
if (persistenceDirectory) {
|
|
@@ -22,15 +24,35 @@ function getPersistenceDirectory() {
|
|
|
22
24
|
persistenceDirectory = path.join(getPaths().generated.base, "updateCheck");
|
|
23
25
|
return persistenceDirectory;
|
|
24
26
|
}
|
|
25
|
-
|
|
27
|
+
function getLocalVersion() {
|
|
28
|
+
let version;
|
|
26
29
|
try {
|
|
27
|
-
console.time("Update Check");
|
|
28
30
|
const packageJson = JSON.parse(
|
|
29
31
|
fs.readFileSync(path.join(getPaths().base, "package.json"), "utf-8")
|
|
30
32
|
);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
version = packageJson.devDependencies?.["@cedarjs/core"];
|
|
34
|
+
} catch {
|
|
35
|
+
return void 0;
|
|
36
|
+
}
|
|
37
|
+
if (typeof version === "string" && isValid(version)) {
|
|
38
|
+
return version;
|
|
39
|
+
}
|
|
40
|
+
return void 0;
|
|
41
|
+
}
|
|
42
|
+
async function check() {
|
|
43
|
+
try {
|
|
44
|
+
console.time("Update Check");
|
|
45
|
+
const localVersion = getLocalVersion();
|
|
46
|
+
if (!localVersion) {
|
|
47
|
+
console.log(
|
|
48
|
+
"Skipping update check: no pinned @cedarjs/core version found"
|
|
49
|
+
);
|
|
50
|
+
updateUpdateDataFile({
|
|
51
|
+
localVersion: "0.0.0",
|
|
52
|
+
remoteVersions: /* @__PURE__ */ new Map(),
|
|
53
|
+
checkedAt: (/* @__PURE__ */ new Date()).getTime()
|
|
54
|
+
});
|
|
55
|
+
return;
|
|
34
56
|
}
|
|
35
57
|
console.log(`Detected the current version of Cedar: '${localVersion}'`);
|
|
36
58
|
const remoteVersions = /* @__PURE__ */ new Map();
|
|
@@ -67,16 +89,24 @@ function shouldCheck() {
|
|
|
67
89
|
return false;
|
|
68
90
|
}
|
|
69
91
|
const data = readUpdateDataFile();
|
|
92
|
+
const localVersion = getLocalVersion();
|
|
93
|
+
if (localVersion && localVersion !== data.localVersion) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
70
96
|
return data.checkedAt < (/* @__PURE__ */ new Date()).getTime() - CHECK_PERIOD;
|
|
71
97
|
}
|
|
72
98
|
function shouldShow() {
|
|
73
99
|
if (isLockSet(SHOW_LOCK_IDENTIFIER)) {
|
|
74
100
|
return false;
|
|
75
101
|
}
|
|
102
|
+
const localVersion = getLocalVersion();
|
|
103
|
+
if (!localVersion) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
76
106
|
const data = readUpdateDataFile();
|
|
77
107
|
let newerVersion = false;
|
|
78
108
|
data.remoteVersions.forEach((version) => {
|
|
79
|
-
newerVersion ||=
|
|
109
|
+
newerVersion ||= isGreater(version, localVersion);
|
|
80
110
|
});
|
|
81
111
|
return data.shownAt < (/* @__PURE__ */ new Date()).getTime() - SHOW_PERIOD && newerVersion;
|
|
82
112
|
}
|
|
@@ -88,9 +118,9 @@ function getUpdateMessage() {
|
|
|
88
118
|
const data = readUpdateDataFile();
|
|
89
119
|
const localTag = extractTagFromVersion(data.localVersion) || "latest";
|
|
90
120
|
let updateCount = 0;
|
|
91
|
-
let message =
|
|
121
|
+
let message = ` New updates to Cedar are available via \`${formatCedarCommand(["upgrade#REPLACEME#"])}\` `;
|
|
92
122
|
data.remoteVersions.forEach((version, tag) => {
|
|
93
|
-
if (
|
|
123
|
+
if (isGreater(version, data.localVersion)) {
|
|
94
124
|
updateCount += 1;
|
|
95
125
|
if (tag === localTag) {
|
|
96
126
|
message += `
|
|
@@ -180,20 +210,19 @@ function updateCheckMiddleware(argv) {
|
|
|
180
210
|
if (EXCLUDED_COMMANDS.includes(argv._[0])) {
|
|
181
211
|
return;
|
|
182
212
|
}
|
|
183
|
-
if (
|
|
213
|
+
if (shouldCheck()) {
|
|
214
|
+
setLock(CHECK_LOCK_IDENTIFIER);
|
|
215
|
+
const [bgCmd, bgCmdArgs] = getNodeRunnerArgs(
|
|
216
|
+
path.join(import.meta.dirname, "updateCheckExecute.js")
|
|
217
|
+
);
|
|
218
|
+
spawnBackgroundProcess("updateCheck", bgCmd, bgCmdArgs);
|
|
219
|
+
} else if (shouldShow()) {
|
|
184
220
|
setLock(SHOW_LOCK_IDENTIFIER);
|
|
185
221
|
process.on("exit", () => {
|
|
186
222
|
showUpdateMessage();
|
|
187
223
|
unsetLock(SHOW_LOCK_IDENTIFIER);
|
|
188
224
|
});
|
|
189
225
|
}
|
|
190
|
-
if (shouldCheck()) {
|
|
191
|
-
setLock(CHECK_LOCK_IDENTIFIER);
|
|
192
|
-
spawnBackgroundProcess("updateCheck", "yarn", [
|
|
193
|
-
"node",
|
|
194
|
-
path.join(import.meta.dirname, "updateCheckExecute.js")
|
|
195
|
-
]);
|
|
196
|
-
}
|
|
197
226
|
}
|
|
198
227
|
export {
|
|
199
228
|
CHECK_LOCK_IDENTIFIER,
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import c from "
|
|
1
|
+
import { clean, isGreaterOrEqual } from "verkit";
|
|
2
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
3
3
|
function checkNodeVersion() {
|
|
4
4
|
const checks = { ok: true };
|
|
5
5
|
const pVersion = process.version;
|
|
6
|
-
const pVersionC =
|
|
6
|
+
const pVersionC = clean(pVersion);
|
|
7
7
|
const LOWER_BOUND = "v24.0.0";
|
|
8
|
-
if (
|
|
8
|
+
if (!pVersionC) {
|
|
9
|
+
checks.ok = false;
|
|
10
|
+
checks.message = `Invalid Node.js version: ${pVersion}`;
|
|
11
|
+
return checks;
|
|
12
|
+
}
|
|
13
|
+
if (isGreaterOrEqual(pVersionC, LOWER_BOUND)) {
|
|
9
14
|
return checks;
|
|
10
15
|
}
|
|
11
16
|
checks.ok = false;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getInstalledCedarVersion } from "../lib/index.js";
|
|
2
|
-
async function
|
|
2
|
+
async function detectCedarVersion(argv) {
|
|
3
3
|
if (!argv.rwVersion) {
|
|
4
4
|
return {
|
|
5
5
|
rwVersion: await getInstalledCedarVersion()
|
|
@@ -8,5 +8,5 @@ async function detectRxVersion(argv) {
|
|
|
8
8
|
return {};
|
|
9
9
|
}
|
|
10
10
|
export {
|
|
11
|
-
|
|
11
|
+
detectCedarVersion
|
|
12
12
|
};
|
package/dist/plugin.js
CHANGED
|
@@ -59,8 +59,6 @@ async function loadPlugins(yargs) {
|
|
|
59
59
|
yargs.command({
|
|
60
60
|
command: `${namespace} <command>`,
|
|
61
61
|
describe: `Commands from ${namespace}`,
|
|
62
|
-
builder: () => {
|
|
63
|
-
},
|
|
64
62
|
handler: () => {
|
|
65
63
|
}
|
|
66
64
|
});
|
|
@@ -97,6 +95,7 @@ async function loadPlugins(yargs) {
|
|
|
97
95
|
describe: `Commands from ${namespaceInUse}`,
|
|
98
96
|
builder: (yargs2) => {
|
|
99
97
|
yargs2.command(commands).demandCommand();
|
|
98
|
+
return yargs2;
|
|
100
99
|
},
|
|
101
100
|
handler: () => {
|
|
102
101
|
}
|
|
@@ -108,7 +107,7 @@ async function loadPlugins(yargs) {
|
|
|
108
107
|
}
|
|
109
108
|
const packagesToLoad = /* @__PURE__ */ new Set();
|
|
110
109
|
for (const [packageName, cacheEntry] of Object.entries(pluginCommandCache)) {
|
|
111
|
-
if (packageName === "_builtin") {
|
|
110
|
+
if (packageName === "_builtin" || Array.isArray(cacheEntry)) {
|
|
112
111
|
continue;
|
|
113
112
|
}
|
|
114
113
|
const commandFirstWords = [];
|
|
@@ -134,6 +133,9 @@ async function loadPlugins(yargs) {
|
|
|
134
133
|
const commandsToRegister = [];
|
|
135
134
|
if (foundMatchingPackage) {
|
|
136
135
|
const packageToLoad = packagesToLoad.values().next().value;
|
|
136
|
+
if (!packageToLoad) {
|
|
137
|
+
throw new Error(`Invalid first value in ${packagesToLoad}`);
|
|
138
|
+
}
|
|
137
139
|
const commands = await loadCommandsFromCacheOrPackage(
|
|
138
140
|
packageToLoad,
|
|
139
141
|
pluginCommandCache,
|
|
@@ -160,6 +162,7 @@ async function loadPlugins(yargs) {
|
|
|
160
162
|
describe: `Commands from ${namespaceInUse}`,
|
|
161
163
|
builder: (yargs2) => {
|
|
162
164
|
yargs2.command(commandsToRegister).demandCommand();
|
|
165
|
+
return yargs2;
|
|
163
166
|
},
|
|
164
167
|
handler: () => {
|
|
165
168
|
}
|
|
@@ -173,8 +176,6 @@ async function loadPlugins(yargs) {
|
|
|
173
176
|
yargs.command({
|
|
174
177
|
command: `${namespace} <command>`,
|
|
175
178
|
describe: `Commands from ${namespace}`,
|
|
176
|
-
builder: () => {
|
|
177
|
-
},
|
|
178
179
|
handler: () => {
|
|
179
180
|
}
|
|
180
181
|
});
|
|
@@ -185,24 +186,29 @@ async function loadPlugins(yargs) {
|
|
|
185
186
|
}
|
|
186
187
|
async function loadCommandsFromCacheOrPackage(packageName, cache, autoInstall, readFromCache) {
|
|
187
188
|
let cacheEntry = void 0;
|
|
188
|
-
if (readFromCache) {
|
|
189
|
-
|
|
189
|
+
if (readFromCache && cache) {
|
|
190
|
+
const entry = cache[packageName];
|
|
191
|
+
if (entry && !Array.isArray(entry)) {
|
|
192
|
+
cacheEntry = entry;
|
|
193
|
+
}
|
|
190
194
|
}
|
|
191
195
|
if (cacheEntry !== void 0) {
|
|
192
196
|
const commands = Object.entries(cacheEntry).map(([command, info]) => {
|
|
193
197
|
return {
|
|
194
198
|
command,
|
|
195
199
|
describe: info.description,
|
|
196
|
-
aliases: info.aliases
|
|
200
|
+
aliases: info.aliases,
|
|
201
|
+
handler: () => {
|
|
202
|
+
}
|
|
197
203
|
};
|
|
198
204
|
});
|
|
199
205
|
return commands;
|
|
200
206
|
}
|
|
201
207
|
const plugin = await loadPluginPackage(packageName, void 0, autoInstall);
|
|
202
208
|
if (plugin) {
|
|
203
|
-
const
|
|
209
|
+
const rawCommands = plugin.commands ?? [];
|
|
204
210
|
const cacheUpdate = {};
|
|
205
|
-
for (const command of
|
|
211
|
+
for (const command of rawCommands) {
|
|
206
212
|
const info = {
|
|
207
213
|
aliases: command.aliases,
|
|
208
214
|
description: command.description
|
|
@@ -211,10 +217,10 @@ async function loadCommandsFromCacheOrPackage(packageName, cache, autoInstall, r
|
|
|
211
217
|
cacheUpdate[command.command] = info;
|
|
212
218
|
}
|
|
213
219
|
}
|
|
214
|
-
if (Object.keys(cacheUpdate).length > 0) {
|
|
220
|
+
if (cache && Object.keys(cacheUpdate).length > 0) {
|
|
215
221
|
cache[packageName] = cacheUpdate;
|
|
216
222
|
}
|
|
217
|
-
return commands;
|
|
223
|
+
return plugin.commands ?? [];
|
|
218
224
|
}
|
|
219
225
|
return [];
|
|
220
226
|
}
|
|
@@ -32,19 +32,26 @@ class CustomFileExporter {
|
|
|
32
32
|
* @param spans the list of sampled Spans to be exported.
|
|
33
33
|
*/
|
|
34
34
|
export(spans, resultCallback) {
|
|
35
|
-
for (
|
|
36
|
-
const span = spans[i];
|
|
37
|
-
delete span["_spanProcessor"];
|
|
35
|
+
for (const span of spans) {
|
|
38
36
|
fs.appendFileSync(
|
|
39
37
|
this.#storageFilePath,
|
|
40
|
-
JSON.stringify(
|
|
38
|
+
JSON.stringify(
|
|
39
|
+
span,
|
|
40
|
+
(key, value) => {
|
|
41
|
+
if (key === "_spanProcessor") {
|
|
42
|
+
return void 0;
|
|
43
|
+
}
|
|
44
|
+
return value;
|
|
45
|
+
},
|
|
46
|
+
2
|
|
47
|
+
)
|
|
41
48
|
);
|
|
42
49
|
fs.appendFileSync(this.#storageFilePath, ",");
|
|
43
50
|
}
|
|
44
51
|
resultCallback({ code: 0 });
|
|
45
52
|
}
|
|
46
53
|
/** Stops the exporter. */
|
|
47
|
-
shutdown() {
|
|
54
|
+
async shutdown() {
|
|
48
55
|
if (!this.#isShutdown) {
|
|
49
56
|
fs.truncateSync(
|
|
50
57
|
this.#storageFilePath,
|
package/dist/telemetry/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
SamplingDecision
|
|
8
8
|
} from "@opentelemetry/sdk-trace-node";
|
|
9
9
|
import { hideBin } from "yargs/helpers";
|
|
10
|
+
import { getNodeRunnerArgs } from "@cedarjs/cli-helpers/packageManager/exec";
|
|
10
11
|
import { spawnBackgroundProcess } from "../lib/background.js";
|
|
11
12
|
import { CustomFileExporter } from "./exporter.js";
|
|
12
13
|
let traceProvider;
|
|
@@ -69,10 +70,10 @@ function shutdownTelemetry() {
|
|
|
69
70
|
opentelemetry.trace.getActiveSpan()?.end();
|
|
70
71
|
}
|
|
71
72
|
traceExporter?.shutdown();
|
|
72
|
-
|
|
73
|
-
"node",
|
|
73
|
+
const [cmd, args] = getNodeRunnerArgs(
|
|
74
74
|
path.join(import.meta.dirname, "send.js")
|
|
75
|
-
|
|
75
|
+
);
|
|
76
|
+
spawnBackgroundProcess("telemetry", cmd, args);
|
|
76
77
|
} catch (error) {
|
|
77
78
|
console.error("Telemetry error");
|
|
78
79
|
console.error(error);
|
|
@@ -7,11 +7,10 @@ import system from "systeminformation";
|
|
|
7
7
|
import { v4 as uuidv4, validate as validateUUID } from "uuid";
|
|
8
8
|
import { getPaths, getRawConfig } from "@cedarjs/project-config";
|
|
9
9
|
import { RWProject } from "@cedarjs/structure/dist/model/RWProject";
|
|
10
|
-
import {
|
|
11
|
-
name as packageName,
|
|
12
|
-
version as packageVersion
|
|
13
|
-
} from "../../package.js";
|
|
14
10
|
async function getResources() {
|
|
11
|
+
const packageJson = await import("../../package.json", { with: { type: "json" } });
|
|
12
|
+
const packageName = packageJson.default["name"];
|
|
13
|
+
const packageVersion = packageJson.default["version"];
|
|
15
14
|
let UID = uuidv4();
|
|
16
15
|
try {
|
|
17
16
|
const telemetryFile = path.join(getPaths().generated.base, "telemetry.txt");
|
|
@@ -29,7 +28,7 @@ async function getResources() {
|
|
|
29
28
|
fs.writeFileSync(telemetryFile, UID);
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
|
-
} catch
|
|
31
|
+
} catch {
|
|
33
32
|
}
|
|
34
33
|
const info = JSON.parse(
|
|
35
34
|
await envinfo.run(
|
|
@@ -55,11 +54,11 @@ async function getResources() {
|
|
|
55
54
|
developmentEnvironment = "gitpod";
|
|
56
55
|
}
|
|
57
56
|
const experiments = Object.keys(getRawConfig()["experimental"] || {});
|
|
58
|
-
const project = new RWProject(
|
|
59
|
-
projectRoot: getPaths().base
|
|
60
|
-
});
|
|
57
|
+
const project = new RWProject();
|
|
61
58
|
const routes = project.getRouter().routes;
|
|
62
|
-
const prerenderedRoutes = routes.filter(
|
|
59
|
+
const prerenderedRoutes = routes.filter(
|
|
60
|
+
(route) => route.hasPrerender
|
|
61
|
+
);
|
|
63
62
|
const complexity = [
|
|
64
63
|
routes.length,
|
|
65
64
|
prerenderedRoutes.length,
|
|
@@ -81,14 +80,12 @@ async function getResources() {
|
|
|
81
80
|
"cpu.count": cpu.physicalCores,
|
|
82
81
|
"memory.gb": Math.round(mem.total / 1073741824),
|
|
83
82
|
"env.node_env": process.env.NODE_ENV || null,
|
|
84
|
-
"ci.redwood": !!process.env.
|
|
83
|
+
"ci.redwood": !!process.env.CEDAR_CI,
|
|
85
84
|
"ci.isci": ci.isCI,
|
|
86
85
|
"dev.environment": developmentEnvironment,
|
|
87
86
|
complexity,
|
|
88
87
|
sides,
|
|
89
88
|
experiments: JSON.stringify(experiments),
|
|
90
|
-
webBundler: "vite",
|
|
91
|
-
// Hardcoded because this is now the only supported bundler
|
|
92
89
|
uid: UID
|
|
93
90
|
};
|
|
94
91
|
}
|
package/dist/telemetry/send.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "path";
|
|
3
|
+
import { ExportResultCode } from "@opentelemetry/core";
|
|
3
4
|
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
4
5
|
import { Resource } from "@opentelemetry/resources";
|
|
5
6
|
import { getPaths } from "@cedarjs/project-config";
|
|
6
7
|
import { getResources } from "./resource.js";
|
|
7
8
|
async function main() {
|
|
8
9
|
console.log(
|
|
9
|
-
"You can disable telemetry by:\n - setting the '
|
|
10
|
+
"You can disable telemetry by:\n - setting the 'CEDAR_DISABLE_TELEMETRY' environment variable\n - passing the '--no-telemetry' flag when using the CLI"
|
|
10
11
|
);
|
|
11
12
|
console.log(
|
|
12
|
-
"Information about
|
|
13
|
+
"Information about Cedar telemetry can be found at:\n - https://telemetry.redwoodjs.com\n"
|
|
13
14
|
);
|
|
14
15
|
const telemetryDir = path.join(getPaths().generated.base, "telemetry");
|
|
15
16
|
fs.mkdirSync(telemetryDir, { recursive: true });
|
|
@@ -20,7 +21,7 @@ async function main() {
|
|
|
20
21
|
const customResourceData = await getResources();
|
|
21
22
|
console.timeEnd("Computed resource information");
|
|
22
23
|
const resource = Resource.default().merge(new Resource(customResourceData));
|
|
23
|
-
const url = process.env.REDWOOD_REDIRECT_TELEMETRY || "https://quark.quantumparticle.io/v1/traces";
|
|
24
|
+
const url = process.env.CEDAR_REDIRECT_TELEMETRY || process.env.REDWOOD_REDIRECT_TELEMETRY || "https://quark.quantumparticle.io/v1/traces";
|
|
24
25
|
const traceExporter = new OTLPTraceExporter({
|
|
25
26
|
url
|
|
26
27
|
});
|
|
@@ -53,14 +54,17 @@ async function main() {
|
|
|
53
54
|
span.spanContext = () => span._spanContext;
|
|
54
55
|
span.events = [];
|
|
55
56
|
}
|
|
56
|
-
traceExporter.export(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
traceExporter.export(
|
|
58
|
+
spans,
|
|
59
|
+
({ code, error }) => {
|
|
60
|
+
if (code !== ExportResultCode.SUCCESS) {
|
|
61
|
+
console.error("Encountered:");
|
|
62
|
+
console.error(error);
|
|
63
|
+
console.error("while exporting the following spans:");
|
|
64
|
+
console.error(spans);
|
|
65
|
+
}
|
|
62
66
|
}
|
|
63
|
-
|
|
67
|
+
);
|
|
64
68
|
fs.writeFileSync(
|
|
65
69
|
path.join(telemetryDir, `_${file}`),
|
|
66
70
|
JSON.stringify(spans, null, 2)
|
package/dist/testLib/cells.js
CHANGED
|
@@ -117,9 +117,11 @@ const getCellGqlQuery = (ast) => {
|
|
|
117
117
|
traverse(ast, {
|
|
118
118
|
ExportNamedDeclaration({ node }) {
|
|
119
119
|
if (node.exportKind === "value" && types.isVariableDeclaration(node.declaration)) {
|
|
120
|
-
const exportedQueryNode = node.declaration.declarations.find(
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
const exportedQueryNode = node.declaration.declarations.find(
|
|
121
|
+
(d) => {
|
|
122
|
+
return types.isIdentifier(d.id) && d.id.name === "QUERY" && types.isTaggedTemplateExpression(d.init);
|
|
123
|
+
}
|
|
124
|
+
);
|
|
123
125
|
if (exportedQueryNode) {
|
|
124
126
|
const templateExpression = exportedQueryNode.init;
|
|
125
127
|
cellQuery = templateExpression.quasi.quasis[0].value.raw;
|