@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
package/dist/lib/merge/index.js
CHANGED
|
@@ -8,9 +8,6 @@ import { forEachFunctionOn, nodeIs } from "./algorithms.js";
|
|
|
8
8
|
import { semanticIdentity } from "./semanticIdentity.js";
|
|
9
9
|
import { isOpaque } from "./strategy.js";
|
|
10
10
|
function extractProperty(property, fromObject) {
|
|
11
|
-
if (property === void 0) {
|
|
12
|
-
return void 0;
|
|
13
|
-
}
|
|
14
11
|
const tmp = fromObject[property];
|
|
15
12
|
delete fromObject[property];
|
|
16
13
|
return tmp;
|
|
@@ -29,7 +26,7 @@ function getProgramPath(ast) {
|
|
|
29
26
|
return programPath;
|
|
30
27
|
}
|
|
31
28
|
function skipChildren(path) {
|
|
32
|
-
for (const key of VISITOR_KEYS[path.type]) {
|
|
29
|
+
for (const key of VISITOR_KEYS[path.type] ?? []) {
|
|
33
30
|
path.skipKey(key);
|
|
34
31
|
}
|
|
35
32
|
}
|
|
@@ -46,6 +43,7 @@ function makeProxy(path) {
|
|
|
46
43
|
if (property === "path") {
|
|
47
44
|
throw new Error("You can't set a path on a proxy!");
|
|
48
45
|
} else {
|
|
46
|
+
;
|
|
49
47
|
target.node[property] = value;
|
|
50
48
|
return true;
|
|
51
49
|
}
|
|
@@ -59,7 +57,7 @@ function expressionUses(exp, ...ids) {
|
|
|
59
57
|
let result = false;
|
|
60
58
|
exp.traverse({
|
|
61
59
|
Identifier(path) {
|
|
62
|
-
if (!path.parentPath
|
|
60
|
+
if (!path.parentPath?.isNodeType("VariableDeclarator") && ids.includes(path.node.name)) {
|
|
63
61
|
result = true;
|
|
64
62
|
return;
|
|
65
63
|
}
|
|
@@ -69,22 +67,37 @@ function expressionUses(exp, ...ids) {
|
|
|
69
67
|
}
|
|
70
68
|
function insertBeforeFirstUsage(expression, program) {
|
|
71
69
|
const body = program.get("body");
|
|
72
|
-
const
|
|
73
|
-
|
|
70
|
+
const bindingIds = Object.keys(
|
|
71
|
+
expression.getBindingIdentifiers()
|
|
74
72
|
);
|
|
75
|
-
|
|
73
|
+
const pos = body.findIndex((exp) => expressionUses(exp, ...bindingIds));
|
|
74
|
+
if (pos !== -1) {
|
|
75
|
+
return body[pos].insertBefore(expression.node);
|
|
76
|
+
} else {
|
|
77
|
+
return program.pushContainer("body", expression.node);
|
|
78
|
+
}
|
|
76
79
|
}
|
|
77
80
|
function insertAfterLastImport(expression, program) {
|
|
78
81
|
const body = program.get("body");
|
|
79
|
-
|
|
82
|
+
let lastImportIdx = -1;
|
|
83
|
+
for (let i = 0; i < body.length; i++) {
|
|
84
|
+
if (body[i].isNodeType("ImportDeclaration")) {
|
|
85
|
+
lastImportIdx = i;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return body[lastImportIdx].insertAfter(expression.node);
|
|
80
89
|
}
|
|
81
90
|
function prune(path) {
|
|
82
|
-
switch (path.parentPath
|
|
91
|
+
switch (path.parentPath?.type) {
|
|
92
|
+
// If pruning 'path' would yield an ill-formed parent (e.g, '{foo:}' or 'const x;'), prune it.
|
|
83
93
|
case "ObjectProperty":
|
|
84
94
|
case "VariableDeclarator":
|
|
85
95
|
return path.parentPath.remove();
|
|
86
96
|
default:
|
|
87
|
-
console.log(
|
|
97
|
+
console.log(
|
|
98
|
+
`Warning: default prune strategy for ${path.parentPath?.type}`
|
|
99
|
+
);
|
|
100
|
+
// eslint-disable-next-line no-fallthrough
|
|
88
101
|
case "Program":
|
|
89
102
|
case "ArrayExpression":
|
|
90
103
|
return path.remove();
|
|
@@ -93,6 +106,7 @@ function prune(path) {
|
|
|
93
106
|
function stripTrailingCommentsStrategy() {
|
|
94
107
|
return {
|
|
95
108
|
enter(path) {
|
|
109
|
+
;
|
|
96
110
|
path.node.trailingComments = [];
|
|
97
111
|
}
|
|
98
112
|
};
|
|
@@ -102,48 +116,71 @@ function mergeAST(baseAST, extAST, strategy = {}) {
|
|
|
102
116
|
const identities = {};
|
|
103
117
|
const baseVisitor = { ...stripTrailingCommentsStrategy() };
|
|
104
118
|
const extVisitor = { ...stripTrailingCommentsStrategy() };
|
|
105
|
-
forEachFunctionOn(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
skipChildren(path);
|
|
119
|
+
forEachFunctionOn(
|
|
120
|
+
strategy,
|
|
121
|
+
(typename, strat) => {
|
|
122
|
+
extVisitor[typename] = {
|
|
123
|
+
enter(path) {
|
|
124
|
+
const id = identity(path);
|
|
125
|
+
if (id) {
|
|
126
|
+
;
|
|
127
|
+
(identities[id] ||= []).push(path);
|
|
128
|
+
}
|
|
116
129
|
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
130
|
+
};
|
|
131
|
+
baseVisitor[typename] = {
|
|
132
|
+
enter(path) {
|
|
133
|
+
if (isOpaque(strat)) {
|
|
134
|
+
skipChildren(path);
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
exit(path) {
|
|
138
|
+
const exts = extractProperty(identity(path), identities);
|
|
139
|
+
if (exts) {
|
|
140
|
+
const proxyPath = makeProxy(path);
|
|
141
|
+
exts.map(makeProxy).forEach((ext) => {
|
|
142
|
+
;
|
|
143
|
+
strat(proxyPath, ext);
|
|
144
|
+
prune(ext.path);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
126
147
|
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
traverse(
|
|
131
|
-
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
);
|
|
151
|
+
traverse(
|
|
152
|
+
extAST,
|
|
153
|
+
extVisitor
|
|
154
|
+
);
|
|
155
|
+
traverse(
|
|
156
|
+
baseAST,
|
|
157
|
+
baseVisitor
|
|
158
|
+
);
|
|
132
159
|
const baseProgram = getProgramPath(baseAST);
|
|
160
|
+
const body = getProgramPath(extAST).get("body");
|
|
133
161
|
const [imports, others] = partition(
|
|
134
|
-
|
|
135
|
-
nodeIs(
|
|
162
|
+
body,
|
|
163
|
+
// nodeIs returns (node: Node) => boolean; here we have NodePaths, so we
|
|
164
|
+
// check path.node to stay type-safe.
|
|
165
|
+
(path) => nodeIs("ImportDeclaration")(path.node)
|
|
136
166
|
);
|
|
137
167
|
imports.forEach((exp) => insertAfterLastImport(exp, baseProgram));
|
|
138
|
-
forEachRight(
|
|
168
|
+
forEachRight(
|
|
169
|
+
others,
|
|
170
|
+
(exp) => insertBeforeFirstUsage(exp, baseProgram)
|
|
171
|
+
);
|
|
139
172
|
}
|
|
140
173
|
async function merge(base, extension, strategy) {
|
|
141
174
|
function parseReact(code2) {
|
|
142
|
-
|
|
143
|
-
filename: "merged.tsx",
|
|
175
|
+
const result = parse(code2, {
|
|
144
176
|
// required to prevent babel error. The .tsx is relevant
|
|
177
|
+
filename: "merged.tsx",
|
|
145
178
|
presets: ["@babel/preset-typescript"]
|
|
146
179
|
});
|
|
180
|
+
if (result === null) {
|
|
181
|
+
throw new Error("Failed to parse code");
|
|
182
|
+
}
|
|
183
|
+
return result;
|
|
147
184
|
}
|
|
148
185
|
const baseAST = parseReact(base);
|
|
149
186
|
const extAST = parseReact(extension);
|
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
function semanticIdentity(path) {
|
|
2
2
|
const identity = {
|
|
3
|
-
get(
|
|
4
|
-
return
|
|
3
|
+
get(p) {
|
|
4
|
+
return p.type in this ? this[p.type](p) : [p.type ?? "unknown"];
|
|
5
5
|
},
|
|
6
|
-
ObjectProperty: (
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
ObjectProperty: (p) => {
|
|
7
|
+
const key = p.node.key;
|
|
8
|
+
if (key.type !== "Identifier") {
|
|
9
|
+
return [p.type];
|
|
10
|
+
}
|
|
11
|
+
return [key.name];
|
|
12
|
+
},
|
|
13
|
+
VariableDeclarator: (p) => {
|
|
14
|
+
const id = p.node.id;
|
|
15
|
+
if (id.type !== "Identifier") {
|
|
16
|
+
return [p.type];
|
|
17
|
+
}
|
|
18
|
+
return [id.name];
|
|
19
|
+
},
|
|
20
|
+
ImportDeclaration: (p) => [
|
|
9
21
|
"ImportDeclaration",
|
|
10
22
|
"source",
|
|
11
|
-
|
|
23
|
+
p.node.source.value
|
|
12
24
|
]
|
|
13
25
|
};
|
|
14
26
|
return path.getAncestry().reduce((acc, i) => [...identity.get(i), ...acc], []).join(".");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as t from "@babel/types";
|
|
2
2
|
import uniqWith from "lodash/uniqWith.js";
|
|
3
3
|
import { nodeIs, sieve } from "./algorithms.js";
|
|
4
|
-
const OPAQUE_UID_TAG = "
|
|
4
|
+
const OPAQUE_UID_TAG = "CEDAR_MERGE_OPAQUE_UID_Q2xldmVyIHlvdSEgSGF2ZSBhIGNvb2tpZS4=";
|
|
5
5
|
function requireSameType(base, ext) {
|
|
6
6
|
if (base.path.type !== ext.path.type) {
|
|
7
7
|
throw new Error(
|
|
@@ -17,9 +17,21 @@ function requireStrategyExists(base, _ext, strategy, strategyName) {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
const strictEquality = (lhs, rhs) => lhs === rhs;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
function hasName(v) {
|
|
21
|
+
return typeof v === "object" && v !== null && "name" in v;
|
|
22
|
+
}
|
|
23
|
+
function hasKey(v) {
|
|
24
|
+
return typeof v === "object" && v !== null && "key" in v;
|
|
25
|
+
}
|
|
26
|
+
function hasKeyName(v) {
|
|
27
|
+
return hasKey(v) && hasName(v.key);
|
|
28
|
+
}
|
|
29
|
+
function hasValue(v) {
|
|
30
|
+
return typeof v === "object" && v !== null && "value" in v;
|
|
31
|
+
}
|
|
32
|
+
const byName = (lhs, rhs) => hasName(lhs) && hasName(rhs) && lhs.name === rhs.name;
|
|
33
|
+
const byKeyName = (lhs, rhs) => hasKeyName(lhs) && hasKeyName(rhs) && lhs.key.name === rhs.key.name;
|
|
34
|
+
const byValue = (lhs, rhs) => hasValue(lhs) && hasValue(rhs) && lhs.value === rhs.value;
|
|
23
35
|
function defaultEquality(baseContainer, extContainer) {
|
|
24
36
|
const sample = baseContainer.length && baseContainer[0] || extContainer.length && extContainer[0];
|
|
25
37
|
const defaults = {
|
|
@@ -30,14 +42,13 @@ function defaultEquality(baseContainer, extContainer) {
|
|
|
30
42
|
ObjectProperty: byKeyName,
|
|
31
43
|
StringLiteral: byValue
|
|
32
44
|
};
|
|
33
|
-
return sample && sample.type in defaults ? defaults[sample.type] : strictEquality;
|
|
45
|
+
return sample && typeof sample === "object" && "type" in sample && typeof sample.type === "string" && sample.type in defaults ? defaults[sample.type] : strictEquality;
|
|
34
46
|
}
|
|
35
|
-
function opaquely(
|
|
36
|
-
|
|
37
|
-
return strategy;
|
|
47
|
+
function opaquely(reducer) {
|
|
48
|
+
return Object.assign(reducer, { [OPAQUE_UID_TAG]: true });
|
|
38
49
|
}
|
|
39
|
-
function isOpaque(
|
|
40
|
-
return
|
|
50
|
+
function isOpaque(fn) {
|
|
51
|
+
return OPAQUE_UID_TAG in fn && fn[OPAQUE_UID_TAG] === true;
|
|
41
52
|
}
|
|
42
53
|
const keepBase = opaquely(() => {
|
|
43
54
|
});
|
|
@@ -47,20 +58,36 @@ const keepBoth = opaquely((base, ext) => {
|
|
|
47
58
|
const keepExtension = opaquely((base, ext) => {
|
|
48
59
|
base.path.replaceWith(ext.path);
|
|
49
60
|
});
|
|
50
|
-
const keepBothStatementParents = opaquely(
|
|
51
|
-
base
|
|
52
|
-
|
|
61
|
+
const keepBothStatementParents = opaquely(
|
|
62
|
+
(base, ext) => {
|
|
63
|
+
const extParent = ext.path.getStatementParent();
|
|
64
|
+
if (extParent) {
|
|
65
|
+
base.path.getStatementParent()?.insertAfter(extParent.node);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
);
|
|
53
69
|
const interleaveStrategy = {
|
|
54
|
-
ImportDeclaration(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
70
|
+
ImportDeclaration(base, ext) {
|
|
71
|
+
if (!t.isImportDeclaration(base) || !t.isImportDeclaration(ext)) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const baseSpecs = base.specifiers;
|
|
75
|
+
const extSpecs = ext.specifiers;
|
|
76
|
+
const importSpecifierEquality = (lhs, rhs) => {
|
|
77
|
+
if (lhs.type !== rhs.type) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
if (lhs.type === "ImportSpecifier" && rhs.type === "ImportSpecifier") {
|
|
81
|
+
return lhs.imported.type === "Identifier" && rhs.imported.type === "Identifier" && lhs.imported.name === rhs.imported.name && lhs.local?.name === rhs.local?.name;
|
|
82
|
+
}
|
|
83
|
+
return lhs.local?.name === rhs.local?.name;
|
|
84
|
+
};
|
|
58
85
|
const uniqueSpecifiersOfType = (type) => uniqWith(
|
|
59
86
|
[...baseSpecs, ...extSpecs].filter(nodeIs(type)),
|
|
60
87
|
importSpecifierEquality
|
|
61
88
|
);
|
|
62
89
|
if (!baseSpecs.length !== !extSpecs.length) {
|
|
63
|
-
return keepBothStatementParents(
|
|
90
|
+
return keepBothStatementParents(base, ext);
|
|
64
91
|
}
|
|
65
92
|
const defaultPosition = (specs) => specs.some(nodeIs("ImportDefaultSpecifier")) ? -1 : 0;
|
|
66
93
|
const namespacePosition = (specs) => specs.some(nodeIs("ImportNamespaceSpecifier")) || specs.some(nodeIs("ImportSpecifier")) ? -1 : specs.length;
|
|
@@ -70,10 +97,10 @@ const interleaveStrategy = {
|
|
|
70
97
|
[uniqueSpecifiersOfType("ImportNamespaceSpecifier"), namespacePosition],
|
|
71
98
|
[uniqueSpecifiersOfType("ImportSpecifier"), importPosition]
|
|
72
99
|
);
|
|
73
|
-
|
|
100
|
+
base.specifiers = firstSpecifierList;
|
|
74
101
|
if (rest.length) {
|
|
75
|
-
|
|
76
|
-
rest.map((specs) => t.importDeclaration(specs,
|
|
102
|
+
base.path.insertAfter(
|
|
103
|
+
rest.map((specs) => t.importDeclaration(specs, base.source))
|
|
77
104
|
);
|
|
78
105
|
}
|
|
79
106
|
}
|
|
@@ -81,47 +108,70 @@ const interleaveStrategy = {
|
|
|
81
108
|
function interleave(base, ext) {
|
|
82
109
|
requireSameType(base, ext);
|
|
83
110
|
requireStrategyExists(base, ext, interleaveStrategy, "interleave");
|
|
84
|
-
|
|
111
|
+
interleaveStrategy[base.path.type]?.(base, ext);
|
|
85
112
|
}
|
|
86
113
|
const concatStrategy = {
|
|
87
114
|
ArrayExpression(base, ext) {
|
|
115
|
+
if (!t.isArrayExpression(base) || !t.isArrayExpression(ext)) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
88
118
|
base.elements = [...base.elements, ...ext.elements];
|
|
89
119
|
},
|
|
90
120
|
ObjectExpression(base, ext) {
|
|
121
|
+
if (!t.isObjectExpression(base) || !t.isObjectExpression(ext)) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
91
124
|
base.properties = [...base.properties, ...ext.properties];
|
|
92
125
|
},
|
|
93
126
|
StringLiteral(base, ext) {
|
|
127
|
+
if (!t.isStringLiteral(base) || !t.isStringLiteral(ext)) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
94
130
|
base.value = base.value.concat(ext.value);
|
|
95
131
|
}
|
|
96
132
|
};
|
|
97
133
|
function concat(base, ext) {
|
|
98
134
|
requireSameType(base, ext);
|
|
99
135
|
requireStrategyExists(base, ext, concatStrategy, "concat");
|
|
100
|
-
|
|
136
|
+
concatStrategy[base.path.type]?.(base, ext);
|
|
101
137
|
}
|
|
102
138
|
const concatUniqueStrategy = {
|
|
103
139
|
ArrayExpression(base, ext, eq) {
|
|
104
|
-
|
|
105
|
-
|
|
140
|
+
if (!t.isArrayExpression(base) || !t.isArrayExpression(ext)) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const equalFn = eq ?? defaultEquality(base.elements, ext.elements);
|
|
144
|
+
base.elements = uniqWith([...base.elements, ...ext.elements], equalFn);
|
|
106
145
|
},
|
|
107
146
|
ObjectExpression(base, ext, eq) {
|
|
108
|
-
|
|
109
|
-
|
|
147
|
+
if (!t.isObjectExpression(base) || !t.isObjectExpression(ext)) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const equalFn = eq ?? defaultEquality(base.properties, ext.properties);
|
|
151
|
+
base.properties = uniqWith([...base.properties, ...ext.properties], equalFn);
|
|
110
152
|
}
|
|
111
153
|
};
|
|
112
154
|
function concatUnique(baseOrEq, ext) {
|
|
113
|
-
if (
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
155
|
+
if (typeof baseOrEq === "function") {
|
|
156
|
+
const eq = baseOrEq;
|
|
157
|
+
return (base2, innerExt) => {
|
|
158
|
+
requireSameType(base2, innerExt);
|
|
159
|
+
requireStrategyExists(
|
|
160
|
+
base2,
|
|
161
|
+
innerExt,
|
|
162
|
+
concatUniqueStrategy,
|
|
163
|
+
"concatUnique"
|
|
164
|
+
);
|
|
165
|
+
concatUniqueStrategy[base2.path.type]?.(base2, innerExt, eq);
|
|
118
166
|
};
|
|
119
167
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return concatUniqueStrategy[baseOrEq.path.type](baseOrEq, ext);
|
|
168
|
+
const base = baseOrEq;
|
|
169
|
+
if (!ext) {
|
|
170
|
+
return;
|
|
124
171
|
}
|
|
172
|
+
requireSameType(base, ext);
|
|
173
|
+
requireStrategyExists(base, ext, concatUniqueStrategy, "concatUnique");
|
|
174
|
+
concatUniqueStrategy[base.path.type]?.(base, ext);
|
|
125
175
|
}
|
|
126
176
|
export {
|
|
127
177
|
concat,
|
package/dist/lib/packages.js
CHANGED
|
@@ -2,22 +2,26 @@ import fs from "node:fs";
|
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import execa from "execa";
|
|
5
|
+
import { dedupe } from "@cedarjs/cli-helpers/packageManager";
|
|
6
|
+
import { addRootPackages } from "@cedarjs/cli-helpers/packageManager/packages";
|
|
7
|
+
import { getPackageManager } from "@cedarjs/project-config/packageManager";
|
|
5
8
|
import { getPaths } from "./index.js";
|
|
6
9
|
async function installModule(name, version = void 0) {
|
|
7
10
|
if (isModuleInstalled(name)) {
|
|
8
11
|
return false;
|
|
9
12
|
}
|
|
10
13
|
if (version === void 0) {
|
|
11
|
-
return
|
|
14
|
+
return installCedarModule(name);
|
|
12
15
|
} else {
|
|
13
|
-
await
|
|
16
|
+
await addRootPackages([`${name}@${version}`], {
|
|
17
|
+
dev: true,
|
|
14
18
|
stdio: "inherit",
|
|
15
19
|
cwd: getPaths().base
|
|
16
20
|
});
|
|
17
21
|
}
|
|
18
22
|
return true;
|
|
19
23
|
}
|
|
20
|
-
async function
|
|
24
|
+
async function installCedarModule(module) {
|
|
21
25
|
const packageJson = await import("@cedarjs/cli/package.json", { with: { type: "json" } });
|
|
22
26
|
let version = packageJson.default.version;
|
|
23
27
|
if (!isModuleInstalled(module)) {
|
|
@@ -35,21 +39,27 @@ async function installRedwoodModule(module) {
|
|
|
35
39
|
}
|
|
36
40
|
} catch (error) {
|
|
37
41
|
throw new Error(
|
|
38
|
-
`Couldn't fetch packument for ${module}: ${error.message}`
|
|
42
|
+
`Couldn't fetch packument for ${module}: ${error instanceof Error ? error.message : String(error)}`
|
|
39
43
|
);
|
|
40
44
|
}
|
|
41
|
-
const versionIsPublished = Object.keys(packument.versions).includes(
|
|
45
|
+
const versionIsPublished = Object.keys(packument.versions ?? {}).includes(
|
|
46
|
+
version
|
|
47
|
+
);
|
|
42
48
|
if (!versionIsPublished) {
|
|
43
49
|
version = "canary";
|
|
44
50
|
}
|
|
45
|
-
await
|
|
46
|
-
|
|
47
|
-
cwd: getPaths().base
|
|
48
|
-
});
|
|
49
|
-
await execa.command(`yarn dedupe`, {
|
|
51
|
+
await addRootPackages([`${module}@${version}`], {
|
|
52
|
+
dev: true,
|
|
50
53
|
stdio: "inherit",
|
|
51
54
|
cwd: getPaths().base
|
|
52
55
|
});
|
|
56
|
+
const dedupeCommand = dedupe();
|
|
57
|
+
if (dedupeCommand) {
|
|
58
|
+
await execa(getPackageManager(), [dedupeCommand], {
|
|
59
|
+
stdio: "inherit",
|
|
60
|
+
cwd: getPaths().base
|
|
61
|
+
});
|
|
62
|
+
}
|
|
53
63
|
return true;
|
|
54
64
|
}
|
|
55
65
|
return false;
|
|
@@ -66,12 +76,12 @@ function isModuleInstalled(module) {
|
|
|
66
76
|
return true;
|
|
67
77
|
}
|
|
68
78
|
const createdRequire = createRequire(import.meta.url);
|
|
69
|
-
return createdRequire.resolve.paths(`${module}/package.json`)
|
|
79
|
+
return createdRequire.resolve.paths(`${module}/package.json`)?.some((requireResolvePath) => {
|
|
70
80
|
return fs.existsSync(path.join(requireResolvePath, module));
|
|
71
|
-
});
|
|
81
|
+
}) ?? false;
|
|
72
82
|
}
|
|
73
83
|
export {
|
|
84
|
+
installCedarModule,
|
|
74
85
|
installModule,
|
|
75
|
-
installRedwoodModule,
|
|
76
86
|
isModuleInstalled
|
|
77
87
|
};
|
package/dist/lib/plugin.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import ansis from "ansis";
|
|
4
4
|
import enquirer from "enquirer";
|
|
5
|
-
import { getCompatibilityData } from "@cedarjs/cli-helpers";
|
|
5
|
+
import { getCompatibilityData } from "@cedarjs/cli-helpers/version";
|
|
6
6
|
import { installModule, isModuleInstalled } from "./packages.js";
|
|
7
7
|
import { getPaths } from "./index.js";
|
|
8
8
|
const { Select } = enquirer;
|
|
@@ -45,22 +45,28 @@ const PLUGIN_CACHE_BUILTIN = [
|
|
|
45
45
|
"serve",
|
|
46
46
|
"setup",
|
|
47
47
|
"test",
|
|
48
|
-
"ts-to-js",
|
|
49
48
|
"type-check",
|
|
50
49
|
"tsc",
|
|
51
50
|
"tc",
|
|
52
51
|
"upgrade"
|
|
53
52
|
];
|
|
53
|
+
function isErrorWithCode(error, code) {
|
|
54
|
+
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
55
|
+
}
|
|
54
56
|
function loadCommandCache() {
|
|
55
|
-
let pluginCommandCache = PLUGIN_CACHE_DEFAULT;
|
|
57
|
+
let pluginCommandCache = { ...PLUGIN_CACHE_DEFAULT };
|
|
56
58
|
const commandCachePath = path.join(
|
|
57
59
|
getPaths().generated.base,
|
|
58
60
|
PLUGIN_CACHE_FILENAME
|
|
59
61
|
);
|
|
60
62
|
try {
|
|
61
|
-
const localCommandCache = JSON.parse(
|
|
63
|
+
const localCommandCache = JSON.parse(
|
|
64
|
+
fs.readFileSync(commandCachePath, "utf8")
|
|
65
|
+
);
|
|
62
66
|
let valid = true;
|
|
63
|
-
for (const [key, value] of Object.entries(
|
|
67
|
+
for (const [key, value] of Object.entries(
|
|
68
|
+
localCommandCache
|
|
69
|
+
)) {
|
|
64
70
|
if (key === "_builtin") {
|
|
65
71
|
continue;
|
|
66
72
|
}
|
|
@@ -73,7 +79,7 @@ function loadCommandCache() {
|
|
|
73
79
|
};
|
|
74
80
|
}
|
|
75
81
|
} catch (error) {
|
|
76
|
-
if (error
|
|
82
|
+
if (!isErrorWithCode(error, "ENOENT")) {
|
|
77
83
|
console.error(`Error loading plugin command cache at ${commandCachePath}`);
|
|
78
84
|
console.error(error);
|
|
79
85
|
}
|
|
@@ -162,7 +168,7 @@ async function installPluginPackage(packageName, packageVersion) {
|
|
|
162
168
|
console.log(
|
|
163
169
|
"The following error occurred while checking plugin compatibility for automatic installation:"
|
|
164
170
|
);
|
|
165
|
-
const errorMessage = error.message
|
|
171
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
166
172
|
console.log(errorMessage);
|
|
167
173
|
if (errorMessage.includes("does not have a tag") || errorMessage.includes("does not have a version")) {
|
|
168
174
|
process.exit(1);
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import prompts from "prompts";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
isSingular,
|
|
4
|
+
isPlural,
|
|
5
|
+
addSingularPlural
|
|
6
|
+
} from "@cedarjs/utils/cedarPluralize";
|
|
3
7
|
const isWordPluralizable = (word) => {
|
|
4
8
|
return isPlural(word) !== isSingular(word);
|
|
5
9
|
};
|
|
@@ -29,7 +33,7 @@ To continue, the generator requires a unique plural form:`;
|
|
|
29
33
|
const destroyMessage = `Cannot determine the plural of "${model}" originally used to generate the files.
|
|
30
34
|
To continue, the destroy command requires the plural form:`;
|
|
31
35
|
const promptMessage = isDestroyer ? destroyMessage : generateMessage;
|
|
32
|
-
const initialPlural = model.
|
|
36
|
+
const initialPlural = model.endsWith("s") ? `${model}es` : `${model}s`;
|
|
33
37
|
const promptResult = await prompts({
|
|
34
38
|
type: "text",
|
|
35
39
|
name: "plural",
|
package/dist/lib/project.js
CHANGED
|
@@ -5,7 +5,9 @@ const isTypeScriptProject = () => {
|
|
|
5
5
|
const paths = getPaths();
|
|
6
6
|
return fs.existsSync(path.join(paths.web.base, "tsconfig.json")) || fs.existsSync(path.join(paths.api.base, "tsconfig.json"));
|
|
7
7
|
};
|
|
8
|
-
function workspaces({
|
|
8
|
+
function workspaces({
|
|
9
|
+
includePackages = false
|
|
10
|
+
} = {}) {
|
|
9
11
|
const cedarPaths = getPaths();
|
|
10
12
|
let workspaces2 = [];
|
|
11
13
|
if (fs.existsSync(path.join(cedarPaths.web.base, "package.json"))) {
|
package/dist/lib/rollback.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
|
|
3
|
+
const rollback = [];
|
|
4
4
|
function addFunctionToRollback(func, atEnd = false) {
|
|
5
5
|
const step = { type: "func", func };
|
|
6
6
|
if (atEnd) {
|
|
@@ -9,11 +9,11 @@ function addFunctionToRollback(func, atEnd = false) {
|
|
|
9
9
|
rollback.push(step);
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
function addFileToRollback(
|
|
12
|
+
function addFileToRollback(filePath, atEnd = false) {
|
|
13
13
|
const step = {
|
|
14
14
|
type: "file",
|
|
15
|
-
path:
|
|
16
|
-
content: fs.existsSync(
|
|
15
|
+
path: filePath,
|
|
16
|
+
content: fs.existsSync(filePath) ? fs.readFileSync(filePath) : null
|
|
17
17
|
};
|
|
18
18
|
if (atEnd) {
|
|
19
19
|
rollback.unshift(step);
|
|
@@ -21,7 +21,7 @@ function addFileToRollback(path2, atEnd = false) {
|
|
|
21
21
|
rollback.push(step);
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
const executeRollback = async (_, task) => {
|
|
25
25
|
if (task) {
|
|
26
26
|
task.title = "Reverting generator actions...";
|
|
27
27
|
}
|
|
@@ -51,9 +51,9 @@ async function executeRollback(_ = null, task = null) {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
if (task) {
|
|
54
|
-
task.title = `Reverted because: ${task.task.message
|
|
54
|
+
task.title = `Reverted because: ${task.task.message?.error ?? "unknown error"}`;
|
|
55
55
|
}
|
|
56
|
-
}
|
|
56
|
+
};
|
|
57
57
|
function resetRollback() {
|
|
58
58
|
rollback.length = 0;
|
|
59
59
|
}
|