@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/extendFile.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
function fileIncludes(
|
|
3
|
-
return fs.existsSync(
|
|
2
|
+
function fileIncludes(filePath, str) {
|
|
3
|
+
return fs.existsSync(filePath) && fs.readFileSync(filePath).toString().includes(str);
|
|
4
4
|
}
|
|
5
|
-
function extendJSXFile(
|
|
5
|
+
function extendJSXFile(filePath, {
|
|
6
6
|
insertComponent: {
|
|
7
7
|
name = void 0,
|
|
8
8
|
props = void 0,
|
|
@@ -14,7 +14,7 @@ function extendJSXFile(path, {
|
|
|
14
14
|
imports = [],
|
|
15
15
|
moduleScopeLines = []
|
|
16
16
|
}) {
|
|
17
|
-
const content = fs.readFileSync(
|
|
17
|
+
const content = fs.readFileSync(filePath).toString().split("\n");
|
|
18
18
|
if (moduleScopeLines?.length) {
|
|
19
19
|
content.splice(
|
|
20
20
|
content.findLastIndex((l) => l.trimStart().startsWith("import")) + 1,
|
|
@@ -41,15 +41,22 @@ function extendJSXFile(path, {
|
|
|
41
41
|
insertAfter
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
-
fs.writeFileSync(
|
|
44
|
+
fs.writeFileSync(filePath, content.join("\n"));
|
|
45
45
|
}
|
|
46
|
-
function insertComponent(content, {
|
|
46
|
+
function insertComponent(content, {
|
|
47
|
+
component,
|
|
48
|
+
props,
|
|
49
|
+
around,
|
|
50
|
+
within,
|
|
51
|
+
insertBefore,
|
|
52
|
+
insertAfter
|
|
53
|
+
}) {
|
|
47
54
|
if (around && within || !(around || within)) {
|
|
48
55
|
throw new Error(
|
|
49
56
|
"Exactly one of (around | within) must be defined. Choose one."
|
|
50
57
|
);
|
|
51
58
|
}
|
|
52
|
-
const target = around ?? within
|
|
59
|
+
const target = `(?:${around ?? within})`;
|
|
53
60
|
const findTagIndex = (regex) => content.findIndex((line) => regex.test(line));
|
|
54
61
|
let open = findTagIndex(new RegExp(`([^\\S\r
|
|
55
62
|
]*)<${target}\\s*(.*)\\s*>`));
|
|
@@ -62,16 +69,16 @@ function insertComponent(content, { component, props, around, within, insertBefo
|
|
|
62
69
|
open++;
|
|
63
70
|
close--;
|
|
64
71
|
}
|
|
65
|
-
const
|
|
72
|
+
const depthMatch = content[open].match(/([^\S\r\n]*).*/);
|
|
73
|
+
const componentDepth = depthMatch?.[1] ?? "";
|
|
66
74
|
content.splice(
|
|
67
75
|
open,
|
|
68
76
|
close - open,
|
|
69
|
-
|
|
70
|
-
insertBefore && componentDepth + insertBefore,
|
|
77
|
+
...insertBefore ? [componentDepth + insertBefore] : [],
|
|
71
78
|
componentDepth + buildOpeningTag(component, props),
|
|
72
79
|
...content.slice(open, close).map((line) => " " + line),
|
|
73
80
|
componentDepth + `</${component}>`,
|
|
74
|
-
insertAfter
|
|
81
|
+
...insertAfter ? [componentDepth + insertAfter] : []
|
|
75
82
|
);
|
|
76
83
|
}
|
|
77
84
|
function buildOpeningTag(componentName, props) {
|
|
@@ -92,11 +99,14 @@ function buildOpeningTag(componentName, props) {
|
|
|
92
99
|
const possibleSpace = propsString.length ? " " : "";
|
|
93
100
|
return `<${componentName}${possibleSpace}${propsString}>`;
|
|
94
101
|
}
|
|
95
|
-
function objectToComponentProps(obj, options = {
|
|
102
|
+
function objectToComponentProps(obj, options = {
|
|
103
|
+
exclude: [],
|
|
104
|
+
raw: false
|
|
105
|
+
}) {
|
|
96
106
|
const props = [];
|
|
97
107
|
const doRaw = (key) => options.raw === true || Array.isArray(options.raw) && options.raw.includes(key);
|
|
98
108
|
for (const [key, value] of Object.entries(obj)) {
|
|
99
|
-
if (options.exclude
|
|
109
|
+
if (options.exclude?.includes(key)) {
|
|
100
110
|
continue;
|
|
101
111
|
}
|
|
102
112
|
if (doRaw(key)) {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
import fs from "node:fs";
|
|
2
3
|
import { createRequire } from "node:module";
|
|
3
4
|
import path from "node:path";
|
|
4
|
-
import {
|
|
5
|
+
import { getConfig, getPrismaSchemas } from "@cedarjs/project-config";
|
|
6
|
+
import { runCommandTask, getPaths } from "./index.js";
|
|
5
7
|
const generatePrismaCommand = async () => {
|
|
8
|
+
const config = getConfig();
|
|
6
9
|
const createdRequire = createRequire(import.meta.url);
|
|
7
10
|
const prismaIndexPath = createdRequire.resolve("prisma/build/index.js");
|
|
8
11
|
return {
|
|
@@ -10,22 +13,52 @@ const generatePrismaCommand = async () => {
|
|
|
10
13
|
args: [
|
|
11
14
|
prismaIndexPath,
|
|
12
15
|
"generate",
|
|
13
|
-
`--config=${getPaths().api.prismaConfig}
|
|
16
|
+
`--config=${getPaths().api.prismaConfig}`,
|
|
17
|
+
...config.api.prismaGenerateArgs
|
|
14
18
|
]
|
|
15
19
|
};
|
|
16
20
|
};
|
|
17
|
-
|
|
21
|
+
async function computePrismaSchemaHash() {
|
|
22
|
+
try {
|
|
23
|
+
const hash = createHash("sha256");
|
|
24
|
+
const configPath = getPaths().api.prismaConfig;
|
|
25
|
+
if (fs.existsSync(configPath)) {
|
|
26
|
+
hash.update(fs.readFileSync(configPath));
|
|
27
|
+
}
|
|
28
|
+
const { schemas } = await getPrismaSchemas();
|
|
29
|
+
for (const schema of schemas) {
|
|
30
|
+
hash.update(schema[1]);
|
|
31
|
+
}
|
|
32
|
+
return hash.digest("hex");
|
|
33
|
+
} catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function getHashFilePath() {
|
|
38
|
+
const generatedBase = getPaths().generated.base;
|
|
39
|
+
return path.join(generatedBase, "prisma-schema-hash");
|
|
40
|
+
}
|
|
41
|
+
function getStoredSchemaHash() {
|
|
42
|
+
const hashFile = getHashFilePath();
|
|
43
|
+
if (fs.existsSync(hashFile)) {
|
|
44
|
+
return fs.readFileSync(hashFile, "utf-8").trim();
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
function storeSchemaHash(hash) {
|
|
49
|
+
const hashFile = getHashFilePath();
|
|
50
|
+
fs.mkdirSync(path.dirname(hashFile), { recursive: true });
|
|
51
|
+
fs.writeFileSync(hashFile, hash);
|
|
52
|
+
}
|
|
53
|
+
async function generatePrismaClient({
|
|
18
54
|
verbose = true,
|
|
19
|
-
force =
|
|
55
|
+
force = false,
|
|
20
56
|
silent = false
|
|
21
|
-
}
|
|
57
|
+
} = {}) {
|
|
58
|
+
const hash = await computePrismaSchemaHash();
|
|
22
59
|
if (!force) {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
"node_modules/.prisma/client/index.js"
|
|
26
|
-
);
|
|
27
|
-
const prismaClientFile = fs.readFileSync(prismaClientPath, "utf8");
|
|
28
|
-
if (!prismaClientFile.includes("@prisma/client did not initialize yet.") && prismaClientFile.includes("exports.Prisma.")) {
|
|
60
|
+
const storedHash = hash ? getStoredSchemaHash() : null;
|
|
61
|
+
if (hash !== null && hash === storedHash) {
|
|
29
62
|
return;
|
|
30
63
|
}
|
|
31
64
|
}
|
|
@@ -41,7 +74,10 @@ const generatePrismaClient = async ({
|
|
|
41
74
|
silent
|
|
42
75
|
}
|
|
43
76
|
);
|
|
44
|
-
|
|
77
|
+
if (hash !== null) {
|
|
78
|
+
storeSchemaHash(hash);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
45
81
|
export {
|
|
46
82
|
generatePrismaClient,
|
|
47
83
|
generatePrismaCommand
|
package/dist/lib/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import https from "https";
|
|
2
1
|
import fs from "node:fs";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import https from "node:https";
|
|
3
|
+
import path from "node:path";
|
|
5
4
|
import boxen from "boxen";
|
|
6
5
|
import camelcase from "camelcase";
|
|
7
6
|
import { paramCase } from "change-case";
|
|
@@ -12,16 +11,21 @@ import memoize from "lodash/memoize.js";
|
|
|
12
11
|
import template from "lodash/template.js";
|
|
13
12
|
import pascalcase from "pascalcase";
|
|
14
13
|
import { format } from "prettier";
|
|
14
|
+
import { colors as c } from "@cedarjs/cli-helpers/colors";
|
|
15
15
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
addRootPackages,
|
|
17
|
+
addWorkspacePackages
|
|
18
|
+
} from "@cedarjs/cli-helpers/packageManager/packages";
|
|
19
|
+
import { transpileTSToJS } from "@cedarjs/cli-helpers/transpileTSToJS";
|
|
20
|
+
import {
|
|
21
|
+
getConfig as getCedarConfig,
|
|
22
|
+
getPaths as getCedarPaths,
|
|
18
23
|
resolveFile as internalResolveFile,
|
|
19
24
|
findUp
|
|
20
25
|
} from "@cedarjs/project-config";
|
|
21
|
-
import { pluralize, singularize } from "
|
|
22
|
-
import c from "./colors.js";
|
|
26
|
+
import { pluralize, singularize } from "@cedarjs/utils/cedarPluralize";
|
|
23
27
|
import { addFileToRollback } from "./rollback.js";
|
|
24
|
-
|
|
28
|
+
function nameVariants(name) {
|
|
25
29
|
const normalizedName = pascalcase(paramCase(singularize(name)));
|
|
26
30
|
return {
|
|
27
31
|
pascalName: pascalcase(paramCase(name)),
|
|
@@ -35,8 +39,8 @@ const nameVariants = (name) => {
|
|
|
35
39
|
singularConstantName: decamelize(normalizedName).toUpperCase(),
|
|
36
40
|
pluralConstantName: decamelize(pluralize(normalizedName)).toUpperCase()
|
|
37
41
|
};
|
|
38
|
-
}
|
|
39
|
-
|
|
42
|
+
}
|
|
43
|
+
function generateTemplate(templateFilename, { name, ...rest }) {
|
|
40
44
|
try {
|
|
41
45
|
const templateFn = template(readFile(templateFilename).toString());
|
|
42
46
|
const renderedTemplate = templateFn({
|
|
@@ -46,18 +50,22 @@ const generateTemplate = (templateFilename, { name, ...rest }) => {
|
|
|
46
50
|
});
|
|
47
51
|
return prettify(templateFilename, renderedTemplate);
|
|
48
52
|
} catch (error) {
|
|
49
|
-
|
|
50
|
-
|
|
53
|
+
const originalMessage = error instanceof Error ? error.message : String(error);
|
|
54
|
+
const wrappedError = new Error(
|
|
55
|
+
`Error applying template at ${templateFilename} for ${name}: ` + originalMessage
|
|
56
|
+
);
|
|
57
|
+
throw wrappedError;
|
|
51
58
|
}
|
|
52
|
-
}
|
|
59
|
+
}
|
|
53
60
|
const prettify = async (templateFilename, renderedTemplate) => {
|
|
54
|
-
const
|
|
61
|
+
const parserMap = {
|
|
55
62
|
".css": "css",
|
|
56
63
|
".js": "babel",
|
|
57
64
|
".jsx": "babel",
|
|
58
65
|
".ts": "babel-ts",
|
|
59
66
|
".tsx": "babel-ts"
|
|
60
|
-
}
|
|
67
|
+
};
|
|
68
|
+
const parser = parserMap[path.extname(templateFilename.replace(".template", ""))];
|
|
61
69
|
if (typeof parser === "undefined") {
|
|
62
70
|
return renderedTemplate;
|
|
63
71
|
}
|
|
@@ -128,30 +136,43 @@ async function getInstalledCedarVersion() {
|
|
|
128
136
|
const packageJson = await import("../../package.json", { with: { type: "json" } });
|
|
129
137
|
return packageJson.default.version;
|
|
130
138
|
} catch (e) {
|
|
139
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
131
140
|
console.error(c.error("Could not find installed Cedar version"));
|
|
141
|
+
console.error(c.error(message));
|
|
132
142
|
process.exit(1);
|
|
133
143
|
}
|
|
134
144
|
}
|
|
135
|
-
const bytes = (contents) => Buffer.byteLength(contents, "utf8");
|
|
136
145
|
const _getPaths = () => {
|
|
137
146
|
try {
|
|
138
|
-
return
|
|
147
|
+
return getCedarPaths();
|
|
139
148
|
} catch (e) {
|
|
140
|
-
|
|
149
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
150
|
+
console.error(c.error(message));
|
|
141
151
|
process.exit(1);
|
|
142
152
|
}
|
|
143
153
|
};
|
|
144
154
|
const getPaths = memoize(_getPaths);
|
|
145
155
|
const resolveFile = internalResolveFile;
|
|
146
|
-
const getGraphqlPath = () =>
|
|
156
|
+
const getGraphqlPath = () => {
|
|
157
|
+
const functionsDir = getPaths().api.functions;
|
|
158
|
+
if (!functionsDir) {
|
|
159
|
+
throw new Error("Could not resolve the API functions directory");
|
|
160
|
+
}
|
|
161
|
+
return resolveFile(path.join(functionsDir, "graphql"));
|
|
162
|
+
};
|
|
147
163
|
const graphFunctionDoesExist = () => {
|
|
148
|
-
|
|
164
|
+
const graphqlPath = getGraphqlPath();
|
|
165
|
+
if (!graphqlPath) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
return fs.existsSync(graphqlPath);
|
|
149
169
|
};
|
|
150
170
|
const getConfig = () => {
|
|
151
171
|
try {
|
|
152
|
-
return
|
|
172
|
+
return getCedarConfig();
|
|
153
173
|
} catch (e) {
|
|
154
|
-
|
|
174
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
175
|
+
console.error(c.error(message));
|
|
155
176
|
process.exit(1);
|
|
156
177
|
}
|
|
157
178
|
};
|
|
@@ -162,7 +183,7 @@ const getPrettierOptions = async () => {
|
|
|
162
183
|
const prettierConfigPath = fs.existsSync(cjsPath) ? cjsPath : mjsPath;
|
|
163
184
|
const { default: prettierOptions } = await import(`file://${prettierConfigPath}`);
|
|
164
185
|
return prettierOptions;
|
|
165
|
-
} catch
|
|
186
|
+
} catch {
|
|
166
187
|
if (process.env.VITEST_POOL_ID !== void 0) {
|
|
167
188
|
return {
|
|
168
189
|
trailingComma: "es5",
|
|
@@ -185,33 +206,32 @@ const getPrettierOptions = async () => {
|
|
|
185
206
|
}
|
|
186
207
|
};
|
|
187
208
|
const transformTSToJS = async (filename, content) => {
|
|
188
|
-
|
|
189
|
-
filename,
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
return prettify(filename.replace(/\.ts(x)?$/, ".js$1"), code);
|
|
209
|
+
return prettify(
|
|
210
|
+
filename.replace(/\.ts(x)?$/, ".js$1"),
|
|
211
|
+
transpileTSToJS(filename, content)
|
|
212
|
+
);
|
|
213
|
+
};
|
|
214
|
+
const transformTSToJSMap = async (files, typescript) => {
|
|
215
|
+
return files.reduce(
|
|
216
|
+
async (accP, [outputPath, content]) => {
|
|
217
|
+
const acc = await accP;
|
|
218
|
+
const template2 = typescript ? content : await transformTSToJS(outputPath, content);
|
|
219
|
+
return {
|
|
220
|
+
[outputPath]: template2,
|
|
221
|
+
...acc
|
|
222
|
+
};
|
|
223
|
+
},
|
|
224
|
+
Promise.resolve({})
|
|
225
|
+
);
|
|
206
226
|
};
|
|
207
|
-
const writeFilesTask = (files, options) => {
|
|
227
|
+
const writeFilesTask = (files, options = {}) => {
|
|
208
228
|
const { base } = getPaths();
|
|
209
229
|
return new Listr(
|
|
210
230
|
Object.keys(files).map((file) => {
|
|
211
231
|
const contents = files[file];
|
|
212
232
|
return {
|
|
213
233
|
title: `...waiting to write file \`./${path.relative(base, file)}\`...`,
|
|
214
|
-
task: (
|
|
234
|
+
task: (_ctx, task) => writeFile(file, contents, options, task)
|
|
215
235
|
};
|
|
216
236
|
})
|
|
217
237
|
);
|
|
@@ -266,27 +286,44 @@ const cleanupEmptyDirsTask = (files) => {
|
|
|
266
286
|
})
|
|
267
287
|
);
|
|
268
288
|
};
|
|
269
|
-
|
|
289
|
+
function wrapWithSet(routesContent, layout, routes, newLineAndIndent, props = {}, privateSetProps) {
|
|
270
290
|
const [_, indentOne, indentTwo] = routesContent.match(
|
|
271
291
|
/([ \t]*)<Router.*?>[^<]*[\r\n]+([ \t]+)/
|
|
272
|
-
) || ["",
|
|
292
|
+
) || ["", "", ""];
|
|
273
293
|
const oneLevelIndent = indentTwo.slice(0, indentTwo.length - indentOne.length);
|
|
274
|
-
const newRoutesWithExtraIndent = routes.map((route) => oneLevelIndent + route);
|
|
275
294
|
const propsString = Object.entries(props).map((values) => `${values[0]}="${values[1]}"`).join(" ");
|
|
295
|
+
if (!privateSetProps) {
|
|
296
|
+
const newRoutesWithExtraIndent2 = routes.map(
|
|
297
|
+
(route) => oneLevelIndent + route
|
|
298
|
+
);
|
|
299
|
+
return [
|
|
300
|
+
`<Set wrap={${layout}}${propsString && " " + propsString}>`,
|
|
301
|
+
...newRoutesWithExtraIndent2,
|
|
302
|
+
`</Set>`
|
|
303
|
+
].join(newLineAndIndent);
|
|
304
|
+
}
|
|
305
|
+
const privateSetPropsString = Object.entries(privateSetProps).map((values) => `${values[0]}="${values[1]}"`).join(" ");
|
|
306
|
+
const newRoutesWithExtraIndent = routes.map(
|
|
307
|
+
(route) => oneLevelIndent + oneLevelIndent + route
|
|
308
|
+
);
|
|
276
309
|
return [
|
|
277
|
-
`<
|
|
310
|
+
`<PrivateSet${privateSetPropsString && " " + privateSetPropsString}>`,
|
|
311
|
+
`${oneLevelIndent}<Set wrap={${layout}}${propsString && " " + propsString}>`,
|
|
278
312
|
...newRoutesWithExtraIndent,
|
|
279
|
-
|
|
313
|
+
`${oneLevelIndent}</Set>`,
|
|
314
|
+
`</PrivateSet>`
|
|
280
315
|
].join(newLineAndIndent);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
const
|
|
284
|
-
const routesContent = readFile(
|
|
316
|
+
}
|
|
317
|
+
function addRoutesToRouterTask(routes, layout, setProps = {}, privateSetProps) {
|
|
318
|
+
const cedarPaths = getPaths();
|
|
319
|
+
const routesContent = readFile(cedarPaths.web.routes).toString();
|
|
285
320
|
let newRoutes = routes.filter((route) => !routesContent.match(route));
|
|
286
321
|
if (newRoutes.length) {
|
|
287
|
-
const
|
|
288
|
-
|
|
289
|
-
|
|
322
|
+
const routerMatch = routesContent.match(/\s*<Router(.*?)>(\s*)/s);
|
|
323
|
+
if (!routerMatch) {
|
|
324
|
+
throw new Error("Could not find a <Router> element in the routes file");
|
|
325
|
+
}
|
|
326
|
+
const [routerStart, routerParams, newLineAndIndent] = routerMatch;
|
|
290
327
|
if (/trailingSlashes={?(["'])always\1}?/.test(routerParams)) {
|
|
291
328
|
newRoutes = newRoutes.map((route) => {
|
|
292
329
|
if (route.length > 2e3) {
|
|
@@ -301,17 +338,18 @@ ${route}`);
|
|
|
301
338
|
layout,
|
|
302
339
|
newRoutes,
|
|
303
340
|
newLineAndIndent,
|
|
304
|
-
setProps
|
|
341
|
+
setProps,
|
|
342
|
+
privateSetProps
|
|
305
343
|
) : newRoutes.join(newLineAndIndent);
|
|
306
344
|
const newRoutesContent = routesContent.replace(
|
|
307
345
|
routerStart,
|
|
308
346
|
`${routerStart + routesBatch + newLineAndIndent}`
|
|
309
347
|
);
|
|
310
|
-
writeFile(
|
|
348
|
+
writeFile(cedarPaths.web.routes, newRoutesContent, {
|
|
311
349
|
overwriteExisting: true
|
|
312
350
|
});
|
|
313
351
|
}
|
|
314
|
-
}
|
|
352
|
+
}
|
|
315
353
|
const addScaffoldImport = () => {
|
|
316
354
|
const appJsPath = getPaths().web.app;
|
|
317
355
|
let appJsContents = readFile(appJsPath).toString();
|
|
@@ -325,11 +363,13 @@ const addScaffoldImport = () => {
|
|
|
325
363
|
writeFile(appJsPath, appJsContents, { overwriteExisting: true });
|
|
326
364
|
return "Added scaffold import to App.{jsx,tsx}";
|
|
327
365
|
};
|
|
328
|
-
|
|
366
|
+
function removeEmtpySet(routesContent, layout) {
|
|
329
367
|
const setWithLayoutReg = new RegExp(
|
|
330
368
|
`\\s*<Set[^>]*wrap={${layout}}[^<]*>([^<]*)</Set>`
|
|
331
369
|
);
|
|
332
|
-
const
|
|
370
|
+
const match = routesContent.match(setWithLayoutReg);
|
|
371
|
+
const matchedSet = match?.[0] ?? "";
|
|
372
|
+
const childContent = match?.[1] ?? "";
|
|
333
373
|
if (!matchedSet) {
|
|
334
374
|
return routesContent;
|
|
335
375
|
}
|
|
@@ -338,19 +378,19 @@ const removeEmtpySet = (routesContent, layout) => {
|
|
|
338
378
|
return routesContent;
|
|
339
379
|
}
|
|
340
380
|
return routesContent.replace(setWithLayoutReg, "");
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
const
|
|
344
|
-
const routesContent = readFile(
|
|
381
|
+
}
|
|
382
|
+
function removeRoutesFromRouterTask(routes, layout) {
|
|
383
|
+
const cedarPaths = getPaths();
|
|
384
|
+
const routesContent = readFile(cedarPaths.web.routes).toString();
|
|
345
385
|
const newRoutesContent = routes.reduce((content, route) => {
|
|
346
386
|
const matchRouteByName = new RegExp(`\\s*<Route[^>]*name="${route}"[^>]*/>`);
|
|
347
387
|
return content.replace(matchRouteByName, "");
|
|
348
388
|
}, routesContent);
|
|
349
389
|
const routesWithoutEmptySet = layout ? removeEmtpySet(newRoutesContent, layout) : newRoutesContent;
|
|
350
|
-
writeFile(
|
|
390
|
+
writeFile(cedarPaths.web.routes, routesWithoutEmptySet, {
|
|
351
391
|
overwriteExisting: true
|
|
352
392
|
});
|
|
353
|
-
}
|
|
393
|
+
}
|
|
354
394
|
const addPackagesTask = async ({
|
|
355
395
|
packages,
|
|
356
396
|
side = "project",
|
|
@@ -364,57 +404,48 @@ const addPackagesTask = async ({
|
|
|
364
404
|
return pkg;
|
|
365
405
|
}
|
|
366
406
|
});
|
|
367
|
-
let installCommand;
|
|
368
|
-
if (side !== "project") {
|
|
369
|
-
installCommand = [
|
|
370
|
-
"yarn",
|
|
371
|
-
[
|
|
372
|
-
"workspace",
|
|
373
|
-
side,
|
|
374
|
-
"add",
|
|
375
|
-
devDependency && "--dev",
|
|
376
|
-
...packagesWithSameRWVersion
|
|
377
|
-
].filter(Boolean)
|
|
378
|
-
];
|
|
379
|
-
} else {
|
|
380
|
-
installCommand = [
|
|
381
|
-
"yarn",
|
|
382
|
-
["add", devDependency && "--dev", ...packagesWithSameRWVersion].filter(
|
|
383
|
-
Boolean
|
|
384
|
-
)
|
|
385
|
-
];
|
|
386
|
-
}
|
|
387
407
|
return {
|
|
388
408
|
title: `Adding dependencies to ${side}`,
|
|
389
409
|
task: async () => {
|
|
390
|
-
|
|
410
|
+
if (side !== "project") {
|
|
411
|
+
await addWorkspacePackages(side, packagesWithSameRWVersion, {
|
|
412
|
+
dev: devDependency
|
|
413
|
+
});
|
|
414
|
+
} else {
|
|
415
|
+
await addRootPackages(packagesWithSameRWVersion, {
|
|
416
|
+
dev: devDependency
|
|
417
|
+
});
|
|
418
|
+
}
|
|
391
419
|
}
|
|
392
420
|
};
|
|
393
421
|
};
|
|
394
|
-
const runCommandTask = async (commands, { verbose, silent }) => {
|
|
422
|
+
const runCommandTask = async (commands, { verbose, silent } = {}) => {
|
|
395
423
|
const tasks = new Listr(
|
|
396
|
-
commands.map(
|
|
397
|
-
title,
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
424
|
+
commands.map(
|
|
425
|
+
({ title, cmd, args = [], opts = {}, cwd = getPaths().base }) => ({
|
|
426
|
+
title,
|
|
427
|
+
task: async () => {
|
|
428
|
+
return execa(cmd, args, {
|
|
429
|
+
cwd,
|
|
430
|
+
stdio: verbose && !silent ? "inherit" : "pipe",
|
|
431
|
+
extendEnv: true,
|
|
432
|
+
cleanup: true,
|
|
433
|
+
...opts
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
})
|
|
437
|
+
),
|
|
408
438
|
{
|
|
409
439
|
renderer: silent ? "silent" : verbose ? "verbose" : "default",
|
|
410
|
-
rendererOptions: { collapseSubtasks: false
|
|
440
|
+
rendererOptions: { collapseSubtasks: false }
|
|
411
441
|
}
|
|
412
442
|
);
|
|
413
443
|
try {
|
|
414
444
|
await tasks.run();
|
|
415
445
|
return true;
|
|
416
446
|
} catch (e) {
|
|
417
|
-
|
|
447
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
448
|
+
console.log(c.error(message));
|
|
418
449
|
return false;
|
|
419
450
|
}
|
|
420
451
|
};
|
|
@@ -428,8 +459,8 @@ const getDefaultArgs = (builder) => {
|
|
|
428
459
|
);
|
|
429
460
|
};
|
|
430
461
|
const usingVSCode = () => {
|
|
431
|
-
const
|
|
432
|
-
const VS_CODE_PATH = path.join(
|
|
462
|
+
const cedarPaths = getPaths();
|
|
463
|
+
const VS_CODE_PATH = path.join(cedarPaths.base, ".vscode");
|
|
433
464
|
return fs.existsSync(VS_CODE_PATH);
|
|
434
465
|
};
|
|
435
466
|
const printSetupNotes = (notes) => {
|
|
@@ -441,7 +472,7 @@ const printSetupNotes = (notes) => {
|
|
|
441
472
|
${boxen(notes.join("\n"), {
|
|
442
473
|
padding: { top: 1, bottom: 1, right: 1, left: 1 },
|
|
443
474
|
margin: 1,
|
|
444
|
-
|
|
475
|
+
borderColor: "gray"
|
|
445
476
|
})}
|
|
446
477
|
`;
|
|
447
478
|
}
|
|
@@ -452,7 +483,6 @@ export {
|
|
|
452
483
|
addPackagesTask,
|
|
453
484
|
addRoutesToRouterTask,
|
|
454
485
|
addScaffoldImport,
|
|
455
|
-
bytes,
|
|
456
486
|
cleanupEmptyDirsTask,
|
|
457
487
|
deleteFile,
|
|
458
488
|
deleteFilesTask,
|
|
@@ -475,6 +505,7 @@ export {
|
|
|
475
505
|
runCommandTask,
|
|
476
506
|
saveRemoteFileToDisk,
|
|
477
507
|
transformTSToJS,
|
|
508
|
+
transformTSToJSMap,
|
|
478
509
|
usingVSCode,
|
|
479
510
|
writeFile,
|
|
480
511
|
writeFilesTask
|
package/dist/lib/loadEnvFiles.js
CHANGED
package/dist/lib/locking.js
CHANGED
|
@@ -32,11 +32,15 @@ function unsetLock(identifier) {
|
|
|
32
32
|
}
|
|
33
33
|
function isLockSet(identifier) {
|
|
34
34
|
const lockfilePath = path.join(getPaths().generated.base, "locks", identifier);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
let createdAt;
|
|
36
|
+
try {
|
|
37
|
+
createdAt = fs.statSync(lockfilePath).birthtimeMs;
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (isErrorWithCode(error, "ENOENT")) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
throw error;
|
|
38
43
|
}
|
|
39
|
-
const createdAt = fs.statSync(lockfilePath).birthtimeMs;
|
|
40
44
|
if (Date.now() - createdAt > 36e5) {
|
|
41
45
|
unsetLock(identifier);
|
|
42
46
|
return false;
|
|
@@ -16,9 +16,12 @@ function sieve(...listRulePairs) {
|
|
|
16
16
|
}
|
|
17
17
|
return result;
|
|
18
18
|
}
|
|
19
|
+
function isAnyFn(value) {
|
|
20
|
+
return typeof value === "function";
|
|
21
|
+
}
|
|
19
22
|
function forEachFunctionOn(object, callback) {
|
|
20
23
|
forOwn(object, (value, key) => {
|
|
21
|
-
if (
|
|
24
|
+
if (isAnyFn(value)) {
|
|
22
25
|
callback(key, value);
|
|
23
26
|
}
|
|
24
27
|
});
|