create-better-t-stack 3.11.0-pr750.6c25d46 → 3.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +8 -0
- package/dist/index.d.mts +351 -0
- package/dist/index.mjs +4 -0
- package/dist/src-Dc2OdxbP.mjs +7248 -0
- package/package.json +25 -35
- package/templates/addons/turborepo/turbo.json.hbs +5 -0
- package/templates/auth/better-auth/convex/backend/convex/auth.ts.hbs +3 -5
- package/templates/auth/better-auth/convex/backend/convex/privateData.ts.hbs +13 -12
- package/templates/auth/better-auth/convex/web/react/next/src/lib/auth-client.ts.hbs +2 -2
- package/templates/auth/better-auth/convex/web/react/next/src/lib/auth-server.ts.hbs +1 -0
- package/templates/deploy/alchemy/alchemy.run.ts.hbs +2 -2
- package/templates/frontend/react/tanstack-start/src/router.tsx.hbs +17 -29
- package/templates/frontend/react/tanstack-start/src/routes/__root.tsx.hbs +2 -4
- package/bin/create-better-t-stack +0 -98
- package/src/api.ts +0 -203
- package/src/cli.ts +0 -185
- package/src/constants.ts +0 -270
- package/src/helpers/addons/addons-setup.ts +0 -201
- package/src/helpers/addons/examples-setup.ts +0 -137
- package/src/helpers/addons/fumadocs-setup.ts +0 -99
- package/src/helpers/addons/oxlint-setup.ts +0 -36
- package/src/helpers/addons/ruler-setup.ts +0 -135
- package/src/helpers/addons/starlight-setup.ts +0 -45
- package/src/helpers/addons/tauri-setup.ts +0 -90
- package/src/helpers/addons/tui-setup.ts +0 -64
- package/src/helpers/addons/ultracite-setup.ts +0 -228
- package/src/helpers/addons/vite-pwa-setup.ts +0 -59
- package/src/helpers/addons/wxt-setup.ts +0 -86
- package/src/helpers/core/add-addons.ts +0 -85
- package/src/helpers/core/add-deployment.ts +0 -102
- package/src/helpers/core/api-setup.ts +0 -280
- package/src/helpers/core/auth-setup.ts +0 -203
- package/src/helpers/core/backend-setup.ts +0 -69
- package/src/helpers/core/command-handlers.ts +0 -354
- package/src/helpers/core/convex-codegen.ts +0 -14
- package/src/helpers/core/create-project.ts +0 -134
- package/src/helpers/core/create-readme.ts +0 -694
- package/src/helpers/core/db-setup.ts +0 -184
- package/src/helpers/core/detect-project-config.ts +0 -41
- package/src/helpers/core/env-setup.ts +0 -481
- package/src/helpers/core/git.ts +0 -23
- package/src/helpers/core/install-dependencies.ts +0 -29
- package/src/helpers/core/payments-setup.ts +0 -48
- package/src/helpers/core/post-installation.ts +0 -403
- package/src/helpers/core/project-config.ts +0 -250
- package/src/helpers/core/runtime-setup.ts +0 -76
- package/src/helpers/core/template-manager.ts +0 -917
- package/src/helpers/core/workspace-setup.ts +0 -184
- package/src/helpers/database-providers/d1-setup.ts +0 -28
- package/src/helpers/database-providers/docker-compose-setup.ts +0 -50
- package/src/helpers/database-providers/mongodb-atlas-setup.ts +0 -182
- package/src/helpers/database-providers/neon-setup.ts +0 -240
- package/src/helpers/database-providers/planetscale-setup.ts +0 -78
- package/src/helpers/database-providers/prisma-postgres-setup.ts +0 -193
- package/src/helpers/database-providers/supabase-setup.ts +0 -196
- package/src/helpers/database-providers/turso-setup.ts +0 -309
- package/src/helpers/deployment/alchemy/alchemy-combined-setup.ts +0 -80
- package/src/helpers/deployment/alchemy/alchemy-next-setup.ts +0 -52
- package/src/helpers/deployment/alchemy/alchemy-nuxt-setup.ts +0 -105
- package/src/helpers/deployment/alchemy/alchemy-react-router-setup.ts +0 -33
- package/src/helpers/deployment/alchemy/alchemy-solid-setup.ts +0 -33
- package/src/helpers/deployment/alchemy/alchemy-svelte-setup.ts +0 -99
- package/src/helpers/deployment/alchemy/alchemy-tanstack-router-setup.ts +0 -34
- package/src/helpers/deployment/alchemy/alchemy-tanstack-start-setup.ts +0 -99
- package/src/helpers/deployment/alchemy/env-dts-setup.ts +0 -76
- package/src/helpers/deployment/alchemy/index.ts +0 -7
- package/src/helpers/deployment/server-deploy-setup.ts +0 -55
- package/src/helpers/deployment/web-deploy-setup.ts +0 -58
- package/src/index.ts +0 -51
- package/src/prompts/addons.ts +0 -200
- package/src/prompts/api.ts +0 -49
- package/src/prompts/auth.ts +0 -84
- package/src/prompts/backend.ts +0 -83
- package/src/prompts/config-prompts.ts +0 -138
- package/src/prompts/database-setup.ts +0 -112
- package/src/prompts/database.ts +0 -57
- package/src/prompts/examples.ts +0 -60
- package/src/prompts/frontend.ts +0 -118
- package/src/prompts/git.ts +0 -16
- package/src/prompts/install.ts +0 -16
- package/src/prompts/orm.ts +0 -53
- package/src/prompts/package-manager.ts +0 -32
- package/src/prompts/payments.ts +0 -50
- package/src/prompts/project-name.ts +0 -86
- package/src/prompts/runtime.ts +0 -47
- package/src/prompts/server-deploy.ts +0 -91
- package/src/prompts/web-deploy.ts +0 -107
- package/src/tui/app.tsx +0 -1062
- package/src/types.ts +0 -70
- package/src/utils/add-package-deps.ts +0 -57
- package/src/utils/analytics.ts +0 -39
- package/src/utils/better-auth-plugin-setup.ts +0 -71
- package/src/utils/bts-config.ts +0 -122
- package/src/utils/command-exists.ts +0 -16
- package/src/utils/compatibility-rules.ts +0 -337
- package/src/utils/compatibility.ts +0 -11
- package/src/utils/config-processing.ts +0 -130
- package/src/utils/config-validation.ts +0 -470
- package/src/utils/display-config.ts +0 -96
- package/src/utils/docker-utils.ts +0 -70
- package/src/utils/errors.ts +0 -30
- package/src/utils/file-formatter.ts +0 -11
- package/src/utils/generate-reproducible-command.ts +0 -53
- package/src/utils/get-latest-cli-version.ts +0 -27
- package/src/utils/get-package-manager.ts +0 -13
- package/src/utils/open-url.ts +0 -18
- package/src/utils/package-runner.ts +0 -23
- package/src/utils/project-directory.ts +0 -102
- package/src/utils/project-name-validation.ts +0 -43
- package/src/utils/render-title.ts +0 -48
- package/src/utils/setup-catalogs.ts +0 -192
- package/src/utils/sponsors.ts +0 -101
- package/src/utils/telemetry.ts +0 -19
- package/src/utils/template-processor.ts +0 -64
- package/src/utils/templates.ts +0 -94
- package/src/utils/ts-morph.ts +0 -26
- package/src/validation.ts +0 -117
package/src/types.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// Re-export everything from the shared types package
|
|
2
|
-
export {
|
|
3
|
-
// Schemas
|
|
4
|
-
DatabaseSchema,
|
|
5
|
-
ORMSchema,
|
|
6
|
-
BackendSchema,
|
|
7
|
-
RuntimeSchema,
|
|
8
|
-
FrontendSchema,
|
|
9
|
-
AddonsSchema,
|
|
10
|
-
ExamplesSchema,
|
|
11
|
-
PackageManagerSchema,
|
|
12
|
-
DatabaseSetupSchema,
|
|
13
|
-
APISchema,
|
|
14
|
-
AuthSchema,
|
|
15
|
-
PaymentsSchema,
|
|
16
|
-
WebDeploySchema,
|
|
17
|
-
ServerDeploySchema,
|
|
18
|
-
DirectoryConflictSchema,
|
|
19
|
-
TemplateSchema,
|
|
20
|
-
ProjectNameSchema,
|
|
21
|
-
CreateInputSchema,
|
|
22
|
-
AddInputSchema,
|
|
23
|
-
CLIInputSchema,
|
|
24
|
-
ProjectConfigSchema,
|
|
25
|
-
BetterTStackConfigSchema,
|
|
26
|
-
InitResultSchema,
|
|
27
|
-
// Enum value arrays
|
|
28
|
-
DATABASE_VALUES,
|
|
29
|
-
ORM_VALUES,
|
|
30
|
-
BACKEND_VALUES,
|
|
31
|
-
RUNTIME_VALUES,
|
|
32
|
-
FRONTEND_VALUES,
|
|
33
|
-
ADDONS_VALUES,
|
|
34
|
-
EXAMPLES_VALUES,
|
|
35
|
-
PACKAGE_MANAGER_VALUES,
|
|
36
|
-
DATABASE_SETUP_VALUES,
|
|
37
|
-
API_VALUES,
|
|
38
|
-
AUTH_VALUES,
|
|
39
|
-
PAYMENTS_VALUES,
|
|
40
|
-
WEB_DEPLOY_VALUES,
|
|
41
|
-
SERVER_DEPLOY_VALUES,
|
|
42
|
-
DIRECTORY_CONFLICT_VALUES,
|
|
43
|
-
TEMPLATE_VALUES,
|
|
44
|
-
} from "@better-t-stack/types";
|
|
45
|
-
|
|
46
|
-
export type {
|
|
47
|
-
Database,
|
|
48
|
-
ORM,
|
|
49
|
-
Backend,
|
|
50
|
-
Runtime,
|
|
51
|
-
Frontend,
|
|
52
|
-
Addons,
|
|
53
|
-
Examples,
|
|
54
|
-
PackageManager,
|
|
55
|
-
DatabaseSetup,
|
|
56
|
-
API,
|
|
57
|
-
Auth,
|
|
58
|
-
Payments,
|
|
59
|
-
WebDeploy,
|
|
60
|
-
ServerDeploy,
|
|
61
|
-
DirectoryConflict,
|
|
62
|
-
Template,
|
|
63
|
-
ProjectName,
|
|
64
|
-
CreateInput,
|
|
65
|
-
AddInput,
|
|
66
|
-
CLIInput,
|
|
67
|
-
ProjectConfig,
|
|
68
|
-
BetterTStackConfig,
|
|
69
|
-
InitResult,
|
|
70
|
-
} from "@better-t-stack/types";
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import fs from "fs-extra";
|
|
3
|
-
|
|
4
|
-
import { type AvailableDependencies, dependencyVersionMap } from "../constants";
|
|
5
|
-
|
|
6
|
-
export const addPackageDependency = async (opts: {
|
|
7
|
-
dependencies?: AvailableDependencies[];
|
|
8
|
-
devDependencies?: AvailableDependencies[];
|
|
9
|
-
customDependencies?: Record<string, string>;
|
|
10
|
-
customDevDependencies?: Record<string, string>;
|
|
11
|
-
projectDir: string;
|
|
12
|
-
}) => {
|
|
13
|
-
const {
|
|
14
|
-
dependencies = [],
|
|
15
|
-
devDependencies = [],
|
|
16
|
-
customDependencies = {},
|
|
17
|
-
customDevDependencies = {},
|
|
18
|
-
projectDir,
|
|
19
|
-
} = opts;
|
|
20
|
-
|
|
21
|
-
const pkgJsonPath = path.join(projectDir, "package.json");
|
|
22
|
-
|
|
23
|
-
const pkgJson = await fs.readJson(pkgJsonPath);
|
|
24
|
-
|
|
25
|
-
if (!pkgJson.dependencies) pkgJson.dependencies = {};
|
|
26
|
-
if (!pkgJson.devDependencies) pkgJson.devDependencies = {};
|
|
27
|
-
|
|
28
|
-
for (const pkgName of dependencies) {
|
|
29
|
-
const version = dependencyVersionMap[pkgName];
|
|
30
|
-
if (version) {
|
|
31
|
-
pkgJson.dependencies[pkgName] = version;
|
|
32
|
-
} else {
|
|
33
|
-
console.warn(`Warning: Dependency ${pkgName} not found in version map.`);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
for (const pkgName of devDependencies) {
|
|
38
|
-
const version = dependencyVersionMap[pkgName];
|
|
39
|
-
if (version) {
|
|
40
|
-
pkgJson.devDependencies[pkgName] = version;
|
|
41
|
-
} else {
|
|
42
|
-
console.warn(`Warning: Dev dependency ${pkgName} not found in version map.`);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
for (const [pkgName, version] of Object.entries(customDependencies)) {
|
|
47
|
-
pkgJson.dependencies[pkgName] = version;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
for (const [pkgName, version] of Object.entries(customDevDependencies)) {
|
|
51
|
-
pkgJson.devDependencies[pkgName] = version;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
await fs.writeJson(pkgJsonPath, pkgJson, {
|
|
55
|
-
spaces: 2,
|
|
56
|
-
});
|
|
57
|
-
};
|
package/src/utils/analytics.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { ProjectConfig } from "../types";
|
|
2
|
-
import { getLatestCLIVersion } from "./get-latest-cli-version";
|
|
3
|
-
import { isTelemetryEnabled } from "./telemetry";
|
|
4
|
-
|
|
5
|
-
const CONVEX_INGEST_URL = process.env.CONVEX_INGEST_URL;
|
|
6
|
-
|
|
7
|
-
async function sendConvexEvent(payload: Record<string, unknown>) {
|
|
8
|
-
if (!CONVEX_INGEST_URL) return;
|
|
9
|
-
|
|
10
|
-
try {
|
|
11
|
-
await fetch(CONVEX_INGEST_URL, {
|
|
12
|
-
method: "POST",
|
|
13
|
-
headers: {
|
|
14
|
-
"Content-Type": "application/json",
|
|
15
|
-
},
|
|
16
|
-
body: JSON.stringify(payload),
|
|
17
|
-
});
|
|
18
|
-
} catch {}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export async function trackProjectCreation(config: ProjectConfig, disableAnalytics = false) {
|
|
22
|
-
if (!isTelemetryEnabled() || disableAnalytics) return;
|
|
23
|
-
|
|
24
|
-
const {
|
|
25
|
-
projectName: _projectName,
|
|
26
|
-
projectDir: _projectDir,
|
|
27
|
-
relativePath: _relativePath,
|
|
28
|
-
...safeConfig
|
|
29
|
-
} = config;
|
|
30
|
-
|
|
31
|
-
try {
|
|
32
|
-
await sendConvexEvent({
|
|
33
|
-
...safeConfig,
|
|
34
|
-
cli_version: getLatestCLIVersion(),
|
|
35
|
-
node_version: typeof process !== "undefined" ? process.version : "",
|
|
36
|
-
platform: typeof process !== "undefined" ? process.platform : "",
|
|
37
|
-
});
|
|
38
|
-
} catch {}
|
|
39
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { SyntaxKind } from "ts-morph";
|
|
2
|
-
import type { ProjectConfig } from "../types";
|
|
3
|
-
import { ensureArrayProperty, tsProject } from "./ts-morph";
|
|
4
|
-
|
|
5
|
-
export async function setupBetterAuthPlugins(projectDir: string, config: ProjectConfig) {
|
|
6
|
-
const authIndexPath = `${projectDir}/packages/auth/src/index.ts`;
|
|
7
|
-
const authIndexFile = tsProject.addSourceFileAtPath(authIndexPath);
|
|
8
|
-
|
|
9
|
-
if (!authIndexFile) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const pluginsToAdd: string[] = [];
|
|
14
|
-
const importsToAdd: string[] = [];
|
|
15
|
-
|
|
16
|
-
if (config.backend === "self" && config.frontend?.includes("tanstack-start")) {
|
|
17
|
-
pluginsToAdd.push("tanstackStartCookies()");
|
|
18
|
-
importsToAdd.push('import { tanstackStartCookies } from "better-auth/tanstack-start";');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (config.backend === "self" && config.frontend?.includes("next")) {
|
|
22
|
-
pluginsToAdd.push("nextCookies()");
|
|
23
|
-
importsToAdd.push('import { nextCookies } from "better-auth/next-js";');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
config.frontend?.includes("native-bare") ||
|
|
28
|
-
config.frontend?.includes("native-uniwind") ||
|
|
29
|
-
config.frontend?.includes("native-unistyles")
|
|
30
|
-
) {
|
|
31
|
-
pluginsToAdd.push("expo()");
|
|
32
|
-
importsToAdd.push('import { expo } from "@better-auth/expo";');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (pluginsToAdd.length === 0) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
importsToAdd.forEach((importStatement) => {
|
|
40
|
-
const existingImport = authIndexFile.getImportDeclaration((declaration) =>
|
|
41
|
-
declaration.getModuleSpecifierValue().includes(importStatement.split('"')[1]),
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
if (!existingImport) {
|
|
45
|
-
authIndexFile.insertImportDeclaration(0, {
|
|
46
|
-
moduleSpecifier: importStatement.split('"')[1],
|
|
47
|
-
namedImports: [importStatement.split("{")[1].split("}")[0].trim()],
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const betterAuthCall = authIndexFile
|
|
53
|
-
.getDescendantsOfKind(SyntaxKind.CallExpression)
|
|
54
|
-
.find((call) => call.getExpression().getText() === "betterAuth");
|
|
55
|
-
|
|
56
|
-
if (betterAuthCall) {
|
|
57
|
-
const configObject = betterAuthCall.getArguments()[0];
|
|
58
|
-
|
|
59
|
-
if (configObject && configObject.getKind() === SyntaxKind.ObjectLiteralExpression) {
|
|
60
|
-
const objLiteral = configObject.asKindOrThrow(SyntaxKind.ObjectLiteralExpression);
|
|
61
|
-
|
|
62
|
-
const pluginsArray = ensureArrayProperty(objLiteral, "plugins");
|
|
63
|
-
|
|
64
|
-
pluginsToAdd.forEach((plugin) => {
|
|
65
|
-
pluginsArray.addElement(plugin);
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
authIndexFile.save();
|
|
71
|
-
}
|
package/src/utils/bts-config.ts
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import fs from "fs-extra";
|
|
3
|
-
import * as JSONC from "jsonc-parser";
|
|
4
|
-
import type { BetterTStackConfig, ProjectConfig } from "../types";
|
|
5
|
-
import { getLatestCLIVersion } from "./get-latest-cli-version";
|
|
6
|
-
|
|
7
|
-
const BTS_CONFIG_FILE = "bts.jsonc";
|
|
8
|
-
|
|
9
|
-
export async function writeBtsConfig(projectConfig: ProjectConfig) {
|
|
10
|
-
const btsConfig: BetterTStackConfig = {
|
|
11
|
-
version: getLatestCLIVersion(),
|
|
12
|
-
createdAt: new Date().toISOString(),
|
|
13
|
-
database: projectConfig.database,
|
|
14
|
-
orm: projectConfig.orm,
|
|
15
|
-
backend: projectConfig.backend,
|
|
16
|
-
runtime: projectConfig.runtime,
|
|
17
|
-
frontend: projectConfig.frontend,
|
|
18
|
-
addons: projectConfig.addons,
|
|
19
|
-
examples: projectConfig.examples,
|
|
20
|
-
auth: projectConfig.auth,
|
|
21
|
-
payments: projectConfig.payments,
|
|
22
|
-
packageManager: projectConfig.packageManager,
|
|
23
|
-
dbSetup: projectConfig.dbSetup,
|
|
24
|
-
api: projectConfig.api,
|
|
25
|
-
webDeploy: projectConfig.webDeploy,
|
|
26
|
-
serverDeploy: projectConfig.serverDeploy,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const baseContent = {
|
|
30
|
-
$schema: "https://r2.better-t-stack.dev/schema.json",
|
|
31
|
-
version: btsConfig.version,
|
|
32
|
-
createdAt: btsConfig.createdAt,
|
|
33
|
-
database: btsConfig.database,
|
|
34
|
-
orm: btsConfig.orm,
|
|
35
|
-
backend: btsConfig.backend,
|
|
36
|
-
runtime: btsConfig.runtime,
|
|
37
|
-
frontend: btsConfig.frontend,
|
|
38
|
-
addons: btsConfig.addons,
|
|
39
|
-
examples: btsConfig.examples,
|
|
40
|
-
auth: btsConfig.auth,
|
|
41
|
-
payments: btsConfig.payments,
|
|
42
|
-
packageManager: btsConfig.packageManager,
|
|
43
|
-
dbSetup: btsConfig.dbSetup,
|
|
44
|
-
api: btsConfig.api,
|
|
45
|
-
webDeploy: btsConfig.webDeploy,
|
|
46
|
-
serverDeploy: btsConfig.serverDeploy,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
let configContent = JSON.stringify(baseContent);
|
|
50
|
-
|
|
51
|
-
const formatResult = JSONC.format(configContent, undefined, {
|
|
52
|
-
tabSize: 2,
|
|
53
|
-
insertSpaces: true,
|
|
54
|
-
eol: "\n",
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
configContent = JSONC.applyEdits(configContent, formatResult);
|
|
58
|
-
|
|
59
|
-
const finalContent = `// Better-T-Stack configuration file
|
|
60
|
-
// safe to delete
|
|
61
|
-
|
|
62
|
-
${configContent}`;
|
|
63
|
-
const configPath = path.join(projectConfig.projectDir, BTS_CONFIG_FILE);
|
|
64
|
-
await fs.writeFile(configPath, finalContent, "utf-8");
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export async function readBtsConfig(projectDir: string) {
|
|
68
|
-
try {
|
|
69
|
-
const configPath = path.join(projectDir, BTS_CONFIG_FILE);
|
|
70
|
-
|
|
71
|
-
if (!(await fs.pathExists(configPath))) {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const configContent = await fs.readFile(configPath, "utf-8");
|
|
76
|
-
|
|
77
|
-
const errors: JSONC.ParseError[] = [];
|
|
78
|
-
const config = JSONC.parse(configContent, errors, {
|
|
79
|
-
allowTrailingComma: true,
|
|
80
|
-
disallowComments: false,
|
|
81
|
-
}) as BetterTStackConfig;
|
|
82
|
-
|
|
83
|
-
if (errors.length > 0) {
|
|
84
|
-
console.warn("Warning: Found errors parsing bts.jsonc:", errors);
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return config;
|
|
89
|
-
} catch {
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export async function updateBtsConfig(
|
|
95
|
-
projectDir: string,
|
|
96
|
-
updates: Partial<Pick<BetterTStackConfig, "addons" | "webDeploy" | "serverDeploy">>,
|
|
97
|
-
) {
|
|
98
|
-
try {
|
|
99
|
-
const configPath = path.join(projectDir, BTS_CONFIG_FILE);
|
|
100
|
-
|
|
101
|
-
if (!(await fs.pathExists(configPath))) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const configContent = await fs.readFile(configPath, "utf-8");
|
|
106
|
-
|
|
107
|
-
let modifiedContent = configContent;
|
|
108
|
-
|
|
109
|
-
for (const [key, value] of Object.entries(updates)) {
|
|
110
|
-
const editResult = JSONC.modify(modifiedContent, [key], value, {
|
|
111
|
-
formattingOptions: {
|
|
112
|
-
tabSize: 2,
|
|
113
|
-
insertSpaces: true,
|
|
114
|
-
eol: "\n",
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
modifiedContent = JSONC.applyEdits(modifiedContent, editResult);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
await fs.writeFile(configPath, modifiedContent, "utf-8");
|
|
121
|
-
} catch {}
|
|
122
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { $ } from "bun";
|
|
2
|
-
|
|
3
|
-
export async function commandExists(command: string) {
|
|
4
|
-
try {
|
|
5
|
-
const isWindows = process.platform === "win32";
|
|
6
|
-
if (isWindows) {
|
|
7
|
-
const result = await $`where ${command}`.nothrow().quiet();
|
|
8
|
-
return result.exitCode === 0;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const result = await $`which ${command}`.nothrow().quiet();
|
|
12
|
-
return result.exitCode === 0;
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
}
|