@decohere/scaffold 0.0.1-dev.18 → 0.0.1-dev.20261105.46
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/LICENSE +15 -0
- package/commonjs/src/add-api.action.js +37 -0
- package/commonjs/src/add-api.command.js +39 -0
- package/commonjs/src/add.command.js +22 -0
- package/commonjs/src/add.module.js +24 -0
- package/commonjs/src/auth0-configure.action.js +28 -0
- package/commonjs/src/auth0-configure.command.js +24 -0
- package/commonjs/src/auth0-login.action.js +28 -0
- package/commonjs/src/auth0-login.command.js +23 -0
- package/commonjs/src/auth0.command.js +22 -0
- package/commonjs/src/auth0.module.js +28 -0
- package/commonjs/src/cli.js +8 -0
- package/commonjs/src/create.command.js +22 -0
- package/commonjs/src/create.module.js +24 -0
- package/commonjs/src/domain/prompt.js +62 -0
- package/commonjs/src/index.js +48 -0
- package/commonjs/src/models/compose.model.js +258 -0
- package/commonjs/src/models/config-yaml.model.js +86 -0
- package/commonjs/src/models/const.js +30 -0
- package/commonjs/src/models/dev-container.model.js +172 -0
- package/commonjs/src/models/docker-image.model.js +277 -0
- package/commonjs/src/models/env-file.model.js +48 -0
- package/commonjs/src/models/gitignore.model.js +48 -0
- package/commonjs/src/models/launch-json.model.js +70 -0
- package/commonjs/src/models/package-json.model.js +156 -0
- package/commonjs/src/models/project.model.js +132 -0
- package/commonjs/src/models/source-file.js +4 -0
- package/commonjs/src/models/tsconfig.model.js +32 -0
- package/commonjs/src/models/vitest-config.model.js +33 -0
- package/commonjs/src/models/vscode-settings.model.js +29 -0
- package/commonjs/src/program.js +64 -0
- package/commonjs/src/resolve-target-dir.js +17 -0
- package/commonjs/src/services/scaffold.service.js +60 -0
- package/commonjs/src/version.js +55 -0
- package/commonjs/src/webapi/api-name.js +93 -0
- package/commonjs/src/webapi/auth0-commands.js +250 -0
- package/commonjs/src/webapi/authorize-scopes.js +79 -0
- package/commonjs/src/webapi/cli-options.js +99 -0
- package/commonjs/src/webapi/const.js +54 -0
- package/commonjs/src/webapi/create-api.js +265 -0
- package/commonjs/src/webapi/devcontainer/codebase-rag-mcp.js +164 -0
- package/commonjs/src/webapi/devcontainer/codebase-rag-mcp.ts +182 -0
- package/commonjs/src/webapi/devcontainer/host-scripts.js +50 -0
- package/commonjs/src/webapi/devcontainer/templates/codebase-rag.env.example +3 -0
- package/commonjs/src/webapi/devcontainer/templates/initialize.sh +169 -0
- package/commonjs/src/webapi/devcontainer/templates/post-create.sh +35 -0
- package/commonjs/src/webapi/devcontainer/templates/post-start.sh +65 -0
- package/commonjs/src/webapi/devcontainer/templates/tty-prompt.sh +38 -0
- package/commonjs/src/webapi/features/auth.feature.js +408 -0
- package/commonjs/src/webapi/features/auth0-cli.js +472 -0
- package/commonjs/src/webapi/features/biome-format.js +47 -0
- package/commonjs/src/webapi/features/database.feature.js +433 -0
- package/commonjs/src/webapi/features/finalize.feature.js +93 -0
- package/commonjs/src/webapi/features/postman.feature.js +322 -0
- package/commonjs/src/webapi/models/api-package-json.model.js +58 -0
- package/commonjs/src/webapi/models/auth-config.model.js +24 -0
- package/commonjs/src/webapi/models/controller-source-file.model.js +190 -0
- package/commonjs/src/webapi/models/github-ci.model.js +193 -0
- package/commonjs/src/webapi/models/main-source-file.model.js +165 -0
- package/commonjs/src/webapi/models/production-dockerfile.model.js +75 -0
- package/commonjs/src/webapi/models/sample-files.model.js +58 -0
- package/commonjs/src/webapi/models/webapi-image.model.js +25 -0
- package/commonjs/src/webapi/postman/hello-openapi.js +173 -0
- package/commonjs/src/webapi/postman/local-view.js +182 -0
- package/commonjs/src/webapi/postman/openapi-to-postman.js +238 -0
- package/commonjs/src/webapi/workspace-readme.js +109 -0
- package/commonjs/src/webapi.action.js +28 -0
- package/commonjs/src/webapi.command.js +43 -0
- package/es6/src/add-api.action.js +27 -0
- package/es6/src/add-api.command.js +29 -0
- package/es6/src/add.command.js +12 -0
- package/es6/src/add.module.js +14 -0
- package/es6/src/auth0-configure.action.js +18 -0
- package/es6/src/auth0-configure.command.js +14 -0
- package/es6/src/auth0-login.action.js +18 -0
- package/es6/src/auth0-login.command.js +13 -0
- package/es6/src/auth0.command.js +12 -0
- package/es6/src/auth0.module.js +18 -0
- package/es6/src/cli.js +4 -0
- package/es6/src/create.command.js +12 -0
- package/es6/src/create.module.js +14 -0
- package/es6/src/domain/prompt.js +41 -0
- package/es6/src/index.js +9 -0
- package/es6/src/models/compose.model.js +254 -0
- package/es6/src/models/config-yaml.model.js +74 -0
- package/es6/src/models/const.js +20 -0
- package/es6/src/models/dev-container.model.js +162 -0
- package/es6/src/models/docker-image.model.js +235 -0
- package/es6/src/models/env-file.model.js +44 -0
- package/es6/src/models/gitignore.model.js +38 -0
- package/es6/src/models/launch-json.model.js +60 -0
- package/es6/src/models/package-json.model.js +141 -0
- package/es6/src/models/project.model.js +117 -0
- package/es6/src/models/source-file.js +1 -0
- package/es6/src/models/tsconfig.model.js +22 -0
- package/es6/src/models/vitest-config.model.js +23 -0
- package/es6/src/models/vscode-settings.model.js +19 -0
- package/es6/src/program.js +50 -0
- package/es6/src/resolve-target-dir.js +7 -0
- package/es6/src/services/scaffold.service.js +50 -0
- package/es6/src/version.js +34 -0
- package/es6/src/webapi/api-name.js +57 -0
- package/es6/src/webapi/auth0-commands.js +185 -0
- package/es6/src/webapi/authorize-scopes.js +55 -0
- package/es6/src/webapi/cli-options.js +34 -0
- package/es6/src/webapi/const.js +21 -0
- package/es6/src/webapi/create-api.js +245 -0
- package/es6/src/webapi/devcontainer/codebase-rag-mcp.js +154 -0
- package/es6/src/webapi/devcontainer/codebase-rag-mcp.ts +182 -0
- package/es6/src/webapi/devcontainer/host-scripts.js +29 -0
- package/es6/src/webapi/devcontainer/templates/codebase-rag.env.example +3 -0
- package/es6/src/webapi/devcontainer/templates/initialize.sh +169 -0
- package/es6/src/webapi/devcontainer/templates/post-create.sh +35 -0
- package/es6/src/webapi/devcontainer/templates/post-start.sh +65 -0
- package/es6/src/webapi/devcontainer/templates/tty-prompt.sh +38 -0
- package/es6/src/webapi/features/auth.feature.js +357 -0
- package/es6/src/webapi/features/auth0-cli.js +406 -0
- package/es6/src/webapi/features/biome-format.js +40 -0
- package/es6/src/webapi/features/database.feature.js +423 -0
- package/es6/src/webapi/features/finalize.feature.js +83 -0
- package/es6/src/webapi/features/postman.feature.js +256 -0
- package/es6/src/webapi/models/api-package-json.model.js +53 -0
- package/es6/src/webapi/models/auth-config.model.js +20 -0
- package/es6/src/webapi/models/controller-source-file.model.js +181 -0
- package/{src/webapi/models/github-ci.model.ts → es6/src/webapi/models/github-ci.model.js} +27 -29
- package/es6/src/webapi/models/main-source-file.model.js +161 -0
- package/es6/src/webapi/models/production-dockerfile.model.js +66 -0
- package/es6/src/webapi/models/sample-files.model.js +40 -0
- package/es6/src/webapi/models/webapi-image.model.js +18 -0
- package/es6/src/webapi/postman/hello-openapi.js +166 -0
- package/es6/src/webapi/postman/local-view.js +167 -0
- package/es6/src/webapi/postman/openapi-to-postman.js +179 -0
- package/es6/src/webapi/workspace-readme.js +88 -0
- package/es6/src/webapi.action.js +18 -0
- package/es6/src/webapi.command.js +33 -0
- package/package.json +19 -9
- package/types/src/add-api.action.d.ts +13 -0
- package/types/src/add-api.command.d.ts +7 -0
- package/types/src/add.command.d.ts +6 -0
- package/types/src/add.module.d.ts +14 -0
- package/types/src/auth0-configure.action.d.ts +7 -0
- package/types/src/auth0-configure.command.d.ts +6 -0
- package/types/src/auth0-login.action.d.ts +4 -0
- package/types/src/auth0-login.command.d.ts +6 -0
- package/types/src/auth0.command.d.ts +6 -0
- package/types/src/auth0.module.d.ts +18 -0
- package/types/src/cli.d.ts +2 -0
- package/types/src/create.command.d.ts +6 -0
- package/types/src/create.module.d.ts +14 -0
- package/types/src/domain/prompt.d.ts +4 -0
- package/{src/index.ts → types/src/index.d.ts} +4 -0
- package/types/src/models/compose.model.d.ts +73 -0
- package/types/src/models/config-yaml.model.d.ts +27 -0
- package/types/src/models/const.d.ts +20 -0
- package/types/src/models/dev-container.model.d.ts +49 -0
- package/types/src/models/docker-image.model.d.ts +90 -0
- package/types/src/models/env-file.model.d.ts +16 -0
- package/types/src/models/gitignore.model.d.ts +9 -0
- package/types/src/models/launch-json.model.d.ts +7 -0
- package/types/src/models/package-json.model.d.ts +36 -0
- package/types/src/models/project.model.d.ts +60 -0
- package/{src/models/source-file.ts → types/src/models/source-file.d.ts} +4 -6
- package/types/src/models/tsconfig.model.d.ts +5 -0
- package/types/src/models/vitest-config.model.d.ts +5 -0
- package/types/src/models/vscode-settings.model.d.ts +7 -0
- package/types/src/program.d.ts +8 -0
- package/{src/resolve-target-dir.ts → types/src/resolve-target-dir.d.ts} +1 -4
- package/types/src/services/scaffold.service.d.ts +22 -0
- package/types/src/version.d.ts +6 -0
- package/types/src/webapi/api-name.d.ts +14 -0
- package/types/src/webapi/auth0-commands.d.ts +11 -0
- package/types/src/webapi/authorize-scopes.d.ts +7 -0
- package/types/src/webapi/cli-options.d.ts +6 -0
- package/{src/webapi/const.ts → types/src/webapi/const.d.ts} +9 -21
- package/types/src/webapi/create-api.d.ts +15 -0
- package/types/src/webapi/devcontainer/codebase-rag-mcp.d.ts +32 -0
- package/types/src/webapi/devcontainer/codebase-rag-mcp.ts +182 -0
- package/types/src/webapi/devcontainer/host-scripts.d.ts +7 -0
- package/types/src/webapi/devcontainer/templates/codebase-rag.env.example +3 -0
- package/types/src/webapi/devcontainer/templates/initialize.sh +169 -0
- package/types/src/webapi/devcontainer/templates/post-create.sh +35 -0
- package/types/src/webapi/devcontainer/templates/post-start.sh +65 -0
- package/types/src/webapi/devcontainer/templates/tty-prompt.sh +38 -0
- package/types/src/webapi/features/auth.feature.d.ts +10 -0
- package/types/src/webapi/features/auth0-cli.d.ts +84 -0
- package/types/src/webapi/features/biome-format.d.ts +5 -0
- package/types/src/webapi/features/database.feature.d.ts +7 -0
- package/types/src/webapi/features/finalize.feature.d.ts +2 -0
- package/types/src/webapi/features/postman.feature.d.ts +16 -0
- package/types/src/webapi/models/api-package-json.model.d.ts +18 -0
- package/types/src/webapi/models/auth-config.model.d.ts +26 -0
- package/types/src/webapi/models/controller-source-file.model.d.ts +46 -0
- package/types/src/webapi/models/github-ci.model.d.ts +9 -0
- package/types/src/webapi/models/main-source-file.model.d.ts +54 -0
- package/types/src/webapi/models/production-dockerfile.model.d.ts +18 -0
- package/types/src/webapi/models/sample-files.model.d.ts +7 -0
- package/types/src/webapi/models/webapi-image.model.d.ts +12 -0
- package/types/src/webapi/postman/hello-openapi.d.ts +19 -0
- package/types/src/webapi/postman/local-view.d.ts +17 -0
- package/types/src/webapi/postman/openapi-to-postman.d.ts +62 -0
- package/types/src/webapi/workspace-readme.d.ts +18 -0
- package/types/src/webapi.action.d.ts +14 -0
- package/types/src/webapi.command.d.ts +11 -0
- package/src/add-api.action.ts +0 -25
- package/src/add-api.command.ts +0 -31
- package/src/add.command.ts +0 -20
- package/src/add.module.ts +0 -11
- package/src/cli.ts +0 -4
- package/src/create.command.ts +0 -20
- package/src/create.module.ts +0 -11
- package/src/domain/prompt.ts +0 -50
- package/src/models/compose.model.ts +0 -205
- package/src/models/config-yaml.model.ts +0 -83
- package/src/models/const.ts +0 -20
- package/src/models/dev-container.model.ts +0 -136
- package/src/models/docker-image.model.ts +0 -343
- package/src/models/env-file.model.ts +0 -45
- package/src/models/gitignore.model.ts +0 -35
- package/src/models/launch-json.model.ts +0 -60
- package/src/models/package-json.model.ts +0 -169
- package/src/models/project.model.ts +0 -141
- package/src/models/tsconfig.model.ts +0 -29
- package/src/models/vitest-config.model.ts +0 -26
- package/src/models/vscode-settings.model.ts +0 -24
- package/src/program.ts +0 -63
- package/src/services/scaffold.service.ts +0 -89
- package/src/version.ts +0 -56
- package/src/webapi/api-name.ts +0 -73
- package/src/webapi/cli-options.ts +0 -56
- package/src/webapi/create-api.ts +0 -275
- package/src/webapi/devcontainer/host-scripts.ts +0 -35
- package/src/webapi/features/auth.feature.ts +0 -454
- package/src/webapi/features/auth0-cli.ts +0 -421
- package/src/webapi/features/biome-format.ts +0 -34
- package/src/webapi/features/database.feature.ts +0 -522
- package/src/webapi/features/finalize.feature.ts +0 -112
- package/src/webapi/features/postman.feature.ts +0 -287
- package/src/webapi/models/api-package-json.model.ts +0 -60
- package/src/webapi/models/auth-config.model.ts +0 -36
- package/src/webapi/models/controller-source-file.model.ts +0 -232
- package/src/webapi/models/main-source-file.model.ts +0 -208
- package/src/webapi/models/production-dockerfile.model.ts +0 -162
- package/src/webapi/models/sample-files.model.ts +0 -45
- package/src/webapi/models/webapi-image.model.ts +0 -21
- package/src/webapi/postman/hello-openapi.ts +0 -92
- package/src/webapi/postman/local-view.ts +0 -195
- package/src/webapi/postman/openapi-to-postman.ts +0 -208
- package/src/webapi/workspace-readme.ts +0 -192
- package/src/webapi.action.ts +0 -22
- package/src/webapi.command.ts +0 -41
- package/tests/auth-postman.wiring.spec.ts +0 -263
- package/tests/auth0-cli.spec.ts +0 -232
- package/tests/biome-format.spec.ts +0 -49
- package/tests/cli.integration.spec.ts +0 -658
- package/tests/compose.model.spec.ts +0 -51
- package/tests/container-image.model.spec.ts +0 -162
- package/tests/dev-container.model.spec.ts +0 -29
- package/tests/devcontainer-base-image.spec.ts +0 -32
- package/tests/hello-di-inject.scaffold.spec.ts +0 -18
- package/tests/hello-route.contract.spec.ts +0 -94
- package/tests/package-json.order.spec.ts +0 -59
- package/tests/postman-from-openapi.spec.ts +0 -197
- package/tests/seed-devcontainer-templates.ts +0 -40
- package/tests/webapi/devcontainer/codebase-rag-mcp.spec.ts +0 -96
package/src/webapi/create-api.ts
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
|
-
import { basename, join, resolve } from "node:path";
|
|
3
|
-
import { DockerCompose } from "../models/compose.model.js";
|
|
4
|
-
import { ConfigYaml } from "../models/config-yaml.model.js";
|
|
5
|
-
import { WELL_KNOWN_FILES } from "../models/const.js";
|
|
6
|
-
import { DevContainer } from "../models/dev-container.model.js";
|
|
7
|
-
import { commandHistory } from "../models/docker-image.model.js";
|
|
8
|
-
import { EnvFile } from "../models/env-file.model.js";
|
|
9
|
-
import { Gitignore } from "../models/gitignore.model.js";
|
|
10
|
-
import { LaunchJson } from "../models/launch-json.model.js";
|
|
11
|
-
import { PackageJson } from "../models/package-json.model.js";
|
|
12
|
-
import { MonoRepoScaffold, ProjectScaffold } from "../models/project.model.js";
|
|
13
|
-
import { TsConfig } from "../models/tsconfig.model.js";
|
|
14
|
-
import { VitestConfig } from "../models/vitest-config.model.js";
|
|
15
|
-
import { VSCodeSettings } from "../models/vscode-settings.model.js";
|
|
16
|
-
import { ScaffoldService } from "../services/scaffold.service.js";
|
|
17
|
-
import {
|
|
18
|
-
CreateCliError,
|
|
19
|
-
isDecohereWorkspace,
|
|
20
|
-
listExistingApiNames,
|
|
21
|
-
parseApiNames,
|
|
22
|
-
} from "./api-name.js";
|
|
23
|
-
import {
|
|
24
|
-
DEFAULT_WEBAPI_NAME,
|
|
25
|
-
webapiPackageName,
|
|
26
|
-
webapiPort,
|
|
27
|
-
webapiProjectDir,
|
|
28
|
-
webapiReleaseEntry,
|
|
29
|
-
} from "./const.js";
|
|
30
|
-
import { DevContainerHostScripts } from "./devcontainer/host-scripts.js";
|
|
31
|
-
import { AuthFeature } from "./features/auth.feature.js";
|
|
32
|
-
import { DatabaseFeature } from "./features/database.feature.js";
|
|
33
|
-
import { FinalizeFeature } from "./features/finalize.feature.js";
|
|
34
|
-
import { PostmanFeature } from "./features/postman.feature.js";
|
|
35
|
-
import { ApiPackageJson } from "./models/api-package-json.model.js";
|
|
36
|
-
import { ControllerSourceFile } from "./models/controller-source-file.model.js";
|
|
37
|
-
import { GithubCiWorkflows } from "./models/github-ci.model.js";
|
|
38
|
-
import { MainSourceFile } from "./models/main-source-file.model.js";
|
|
39
|
-
import { WebapiProductionDockerfile } from "./models/production-dockerfile.model.js";
|
|
40
|
-
import { SampleConfigModel, SampleServiceModel } from "./models/sample-files.model.js";
|
|
41
|
-
import { WebapiDevContainer } from "./models/webapi-image.model.js";
|
|
42
|
-
|
|
43
|
-
export { WEBAPI_PROJECT_DIR, WEBAPI_RELEASE_ENTRY } from "./const.js";
|
|
44
|
-
|
|
45
|
-
export type ApiOptions = {
|
|
46
|
-
d?: string;
|
|
47
|
-
/** Host project name (directory basename). Required when scaffolding into `/workspace`. */
|
|
48
|
-
projectName?: string;
|
|
49
|
-
/** API slugs under `projects/`. Default `["api"]`. Repeatable `--name`. */
|
|
50
|
-
names?: string[];
|
|
51
|
-
/** Add APIs to an existing Decohere workspace instead of creating a new one. */
|
|
52
|
-
add?: boolean;
|
|
53
|
-
authProvider?: "auth0" | "none";
|
|
54
|
-
databaseProvider?: "none" | "postgres/typeorm";
|
|
55
|
-
postmanProvider?: "api" | "local" | "none";
|
|
56
|
-
installDependencies?: "yes" | "no";
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const features = [DatabaseFeature, AuthFeature, PostmanFeature, FinalizeFeature];
|
|
60
|
-
|
|
61
|
-
export async function scaffoldApi(cliOptions: ApiOptions) {
|
|
62
|
-
const targetDir = resolve(cliOptions.d ?? ".");
|
|
63
|
-
const projectName =
|
|
64
|
-
cliOptions.projectName?.trim() ||
|
|
65
|
-
process.env.DECOHERE_PROJECT_NAME?.trim() ||
|
|
66
|
-
basename(targetDir);
|
|
67
|
-
const names = parseApiNames(cliOptions.names);
|
|
68
|
-
const workspace = cliOptions.add
|
|
69
|
-
? createAddWorkspace(targetDir, projectName, names)
|
|
70
|
-
: createWorkspace(targetDir, projectName, names);
|
|
71
|
-
await ScaffoldService.scaffold(workspace, { ...cliOptions, names }, features);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function createWorkspace(
|
|
75
|
-
targetDir: string,
|
|
76
|
-
projectName: string,
|
|
77
|
-
apiNames: readonly string[],
|
|
78
|
-
): MonoRepoScaffold {
|
|
79
|
-
const monoRepo = new MonoRepoScaffold();
|
|
80
|
-
monoRepo.targetDir = targetDir;
|
|
81
|
-
monoRepo.setName(projectName);
|
|
82
|
-
const name = monoRepo.name;
|
|
83
|
-
|
|
84
|
-
const compose = new DockerCompose()
|
|
85
|
-
.setProjectName(name)
|
|
86
|
-
.addHeaderComment(
|
|
87
|
-
"Merge .cursor/mcp.json in the service command. postStartCommand runs after Cursor's first MCP snapshot.",
|
|
88
|
-
)
|
|
89
|
-
.addNetwork(name, { name: `samples-${name}` })
|
|
90
|
-
.addService("devcontainer", {
|
|
91
|
-
build: ".",
|
|
92
|
-
volumes: [
|
|
93
|
-
// Workspace-local (created by initialize.sh as the host user).
|
|
94
|
-
// Do NOT bind ${HOME}/.npm/... — Docker creates missing host paths as root.
|
|
95
|
-
"./npm-auth:/home/node/.npm-config",
|
|
96
|
-
"./gh-auth:/home/node/.config/gh",
|
|
97
|
-
"webapi-node-modules:/workspace/node_modules",
|
|
98
|
-
// Named volume (not a Cursor-only mount) so CLI recreates keep Up-arrow history.
|
|
99
|
-
`${commandHistory.volumeName}:${commandHistory.dir}`,
|
|
100
|
-
],
|
|
101
|
-
env_file: ["./gh.env"],
|
|
102
|
-
environment: { NPM_CONFIG_USERCONFIG: "/home/node/.npm-config/.npmrc" },
|
|
103
|
-
command:
|
|
104
|
-
"'bash -c \"CODEBASE_RAG_WORKSPACE=/workspace node --experimental-strip-types /workspace/.devcontainer/codebase-rag-mcp.ts merge || true && exec sleep infinity\"'",
|
|
105
|
-
networks: [name],
|
|
106
|
-
})
|
|
107
|
-
.addVolume("webapi-node-modules")
|
|
108
|
-
.addVolume(commandHistory.volumeName);
|
|
109
|
-
|
|
110
|
-
const installCmd = "bash .devcontainer/post-create.sh";
|
|
111
|
-
const devContainer = new DevContainer()
|
|
112
|
-
.addExtension("biomejs.biome", "vitest.explorer")
|
|
113
|
-
.setInitializeCommand("bash .devcontainer/initialize.sh")
|
|
114
|
-
.setPostCreateCommand(installCmd)
|
|
115
|
-
.setUpdateContentCommand(installCmd)
|
|
116
|
-
.setPostStartCommand("bash .devcontainer/post-start.sh")
|
|
117
|
-
.useCompose();
|
|
118
|
-
|
|
119
|
-
for (const [index, apiName] of apiNames.entries()) {
|
|
120
|
-
const port = webapiPort(index);
|
|
121
|
-
devContainer.forwardPort(port);
|
|
122
|
-
devContainer.setPortAttributes(port, {
|
|
123
|
-
label: apiName === DEFAULT_WEBAPI_NAME ? "API" : apiName,
|
|
124
|
-
requireLocalPort: true,
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// Workspace-level models (repo root)
|
|
129
|
-
monoRepo.addModel(compose);
|
|
130
|
-
monoRepo.addModel(devContainer);
|
|
131
|
-
monoRepo.addModel(new WebapiDevContainer());
|
|
132
|
-
monoRepo.addModel(new WebapiProductionDockerfile(apiNames));
|
|
133
|
-
monoRepo.addModel(new GithubCiWorkflows());
|
|
134
|
-
monoRepo.addModel(new VSCodeSettings(name));
|
|
135
|
-
monoRepo.addModel(new LaunchJson(apiNames));
|
|
136
|
-
monoRepo.addModel(new TsConfig());
|
|
137
|
-
monoRepo.addModel(new VitestConfig());
|
|
138
|
-
monoRepo.addModel(new PackageJson(`${name}.api`, { apiNames, workspaceName: name }));
|
|
139
|
-
monoRepo.addModel(new ConfigYaml(WELL_KNOWN_FILES.CONFIG_YAML, "config/config.yaml", ""));
|
|
140
|
-
monoRepo.addModel(
|
|
141
|
-
new ConfigYaml(WELL_KNOWN_FILES.CONFIG_DEV_YAML, "config/config.dev.yaml", ""),
|
|
142
|
-
);
|
|
143
|
-
monoRepo.addModel(new Gitignore());
|
|
144
|
-
monoRepo.addModel(new EnvFile());
|
|
145
|
-
monoRepo.addFile(new DevContainerHostScripts());
|
|
146
|
-
|
|
147
|
-
// Biome formatter/linter config
|
|
148
|
-
monoRepo.addFile({
|
|
149
|
-
files: () => [
|
|
150
|
-
{
|
|
151
|
-
filePath: "biome.json",
|
|
152
|
-
content: JSON.stringify(
|
|
153
|
-
{
|
|
154
|
-
$schema: "https://biomejs.dev/schemas/2.0.0/schema.json",
|
|
155
|
-
files: {
|
|
156
|
-
includes: ["**/*.ts", "**/*.js", "**/*.json", "**/*.yml", "**/*.yaml"],
|
|
157
|
-
},
|
|
158
|
-
assist: { actions: { source: { organizeImports: "on" } } },
|
|
159
|
-
vcs: { enabled: true, clientKind: "git", useIgnoreFile: true },
|
|
160
|
-
formatter: {
|
|
161
|
-
enabled: true,
|
|
162
|
-
formatWithErrors: true,
|
|
163
|
-
indentStyle: "tab",
|
|
164
|
-
lineWidth: 95,
|
|
165
|
-
},
|
|
166
|
-
javascript: { parser: { unsafeParameterDecoratorsEnabled: true } },
|
|
167
|
-
linter: {
|
|
168
|
-
rules: {
|
|
169
|
-
style: {
|
|
170
|
-
useConsistentMemberAccessibility: {
|
|
171
|
-
level: "error",
|
|
172
|
-
options: { accessibility: "explicit" },
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
overrides: [
|
|
178
|
-
{
|
|
179
|
-
includes: ["**/*.json"],
|
|
180
|
-
formatter: { indentStyle: "space", indentWidth: 2 },
|
|
181
|
-
},
|
|
182
|
-
],
|
|
183
|
-
},
|
|
184
|
-
null,
|
|
185
|
-
2,
|
|
186
|
-
),
|
|
187
|
-
},
|
|
188
|
-
],
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
for (const apiName of apiNames) {
|
|
192
|
-
addApiProject(monoRepo, name, apiName);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
return monoRepo;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
function createAddWorkspace(
|
|
199
|
-
targetDir: string,
|
|
200
|
-
projectName: string,
|
|
201
|
-
apiNames: readonly string[],
|
|
202
|
-
): MonoRepoScaffold {
|
|
203
|
-
if (!isDecohereWorkspace(targetDir)) {
|
|
204
|
-
throw new CreateCliError(
|
|
205
|
-
`Not a Decohere workspace: ${targetDir}. Scaffold one first with \`npx @decohere/create webapi\`.`,
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
const existing = listExistingApiNames(targetDir);
|
|
210
|
-
for (const apiName of apiNames) {
|
|
211
|
-
if (existing.includes(apiName)) {
|
|
212
|
-
throw new CreateCliError(
|
|
213
|
-
`API "${apiName}" already exists at ${webapiProjectDir(apiName)}.`,
|
|
214
|
-
);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const monoRepo = new MonoRepoScaffold();
|
|
219
|
-
monoRepo.targetDir = targetDir;
|
|
220
|
-
monoRepo.setName(projectName);
|
|
221
|
-
const name = monoRepo.name;
|
|
222
|
-
|
|
223
|
-
const pkg = PackageJson.fromFile(join(targetDir, "package.json"));
|
|
224
|
-
monoRepo.addModel(pkg);
|
|
225
|
-
monoRepo.addModel(
|
|
226
|
-
existsSync(join(targetDir, ".env"))
|
|
227
|
-
? EnvFile.fromFile(join(targetDir, ".env"))
|
|
228
|
-
: new EnvFile(),
|
|
229
|
-
);
|
|
230
|
-
monoRepo.addModel(
|
|
231
|
-
existsSync(join(targetDir, "config/config.yaml"))
|
|
232
|
-
? ConfigYaml.fromFile(
|
|
233
|
-
WELL_KNOWN_FILES.CONFIG_YAML,
|
|
234
|
-
"config/config.yaml",
|
|
235
|
-
join(targetDir, "config/config.yaml"),
|
|
236
|
-
)
|
|
237
|
-
: new ConfigYaml(WELL_KNOWN_FILES.CONFIG_YAML, "config/config.yaml", ""),
|
|
238
|
-
);
|
|
239
|
-
monoRepo.addModel(
|
|
240
|
-
existsSync(join(targetDir, "config/config.dev.yaml"))
|
|
241
|
-
? ConfigYaml.fromFile(
|
|
242
|
-
WELL_KNOWN_FILES.CONFIG_DEV_YAML,
|
|
243
|
-
"config/config.dev.yaml",
|
|
244
|
-
join(targetDir, "config/config.dev.yaml"),
|
|
245
|
-
)
|
|
246
|
-
: new ConfigYaml(WELL_KNOWN_FILES.CONFIG_DEV_YAML, "config/config.dev.yaml", ""),
|
|
247
|
-
);
|
|
248
|
-
|
|
249
|
-
for (const [offset, apiName] of apiNames.entries()) {
|
|
250
|
-
const port = webapiPort(existing.length + offset);
|
|
251
|
-
pkg.addScript(`start:${apiName}`, `node ${webapiReleaseEntry(apiName)}`);
|
|
252
|
-
pkg.addScript(
|
|
253
|
-
`dev:${apiName}`,
|
|
254
|
-
`PORT=${port} flux serve --project ${webapiPackageName(name, apiName)}`,
|
|
255
|
-
);
|
|
256
|
-
addApiProject(monoRepo, name, apiName);
|
|
257
|
-
}
|
|
258
|
-
monoRepo.addModel(new WebapiProductionDockerfile(apiNames, { namedOnly: true }));
|
|
259
|
-
|
|
260
|
-
return monoRepo;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
function addApiProject(
|
|
264
|
-
monoRepo: MonoRepoScaffold,
|
|
265
|
-
workspaceName: string,
|
|
266
|
-
apiName: string,
|
|
267
|
-
): void {
|
|
268
|
-
const apiProject = new ProjectScaffold(webapiProjectDir(apiName));
|
|
269
|
-
apiProject.addModel(new ApiPackageJson(workspaceName, apiName));
|
|
270
|
-
apiProject.addModel(new MainSourceFile(`${workspaceName}.${apiName}`));
|
|
271
|
-
apiProject.addModel(new ControllerSourceFile());
|
|
272
|
-
apiProject.addFile(new SampleConfigModel());
|
|
273
|
-
apiProject.addFile(new SampleServiceModel());
|
|
274
|
-
monoRepo.addProject(apiProject);
|
|
275
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
import type { SourceFile, SourceFileProvider } from "../../models/source-file.js";
|
|
4
|
-
|
|
5
|
-
const TEMPLATE_FILES = [
|
|
6
|
-
"initialize.sh",
|
|
7
|
-
"post-create.sh",
|
|
8
|
-
"post-start.sh",
|
|
9
|
-
"tty-prompt.sh",
|
|
10
|
-
"codebase-rag.env.example",
|
|
11
|
-
] as const;
|
|
12
|
-
|
|
13
|
-
export function devcontainerTemplatePath(name: string): string {
|
|
14
|
-
return fileURLToPath(new URL(`./templates/${name}`, import.meta.url));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function codebaseRagMcpSourcePath(): string {
|
|
18
|
-
return fileURLToPath(new URL("./codebase-rag-mcp.ts", import.meta.url));
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/** Host + container scripts for the scaffolded Dev Container. */
|
|
22
|
-
export class DevContainerHostScripts implements SourceFileProvider {
|
|
23
|
-
public files(): SourceFile[] {
|
|
24
|
-
return [
|
|
25
|
-
...TEMPLATE_FILES.map((name) => ({
|
|
26
|
-
filePath: `.devcontainer/${name}`,
|
|
27
|
-
content: readFileSync(devcontainerTemplatePath(name), "utf8"),
|
|
28
|
-
})),
|
|
29
|
-
{
|
|
30
|
-
filePath: ".devcontainer/codebase-rag-mcp.ts",
|
|
31
|
-
content: readFileSync(codebaseRagMcpSourcePath(), "utf8"),
|
|
32
|
-
},
|
|
33
|
-
];
|
|
34
|
-
}
|
|
35
|
-
}
|