Skip to content

Commit 7c44794

Browse files
SakshiKoli-CSclaude
andcommitted
refactor(projects): move CreateRequest to types.ts and keep the create parts' constants private
Follow-up to the ProjectCreator split, from the review of it: - ProjectSource and EnvironmentBuilder imported the CreateRequest type from project.create.ts, which imports both of them, so the orchestrator and its collaborators depended on each other. Type-only today, but one value import away from a real load-order cycle. CreateRequest now lives in projects/types.ts with the other request shapes, and only the command and the tests import project.create.ts. - The split carried export along with six constants that nothing outside their own file uses - NO_DEPLOYMENT_STATUS and FIRST_LOOKUP_ATTEMPTS in project.follow.ts, GIT_NAMESPACE_PAGE_SIZE in project.source.ts, DEFAULT_ENVIRONMENT_NAME, DUPLICATE_PROJECT_NAME_CODE and PROJECT_RENAME_ATTEMPTS in project.create.ts - which made each collaborator look like it offered more than its one class. They are module-private. - AGENTS.md said ProjectCreator applies the --server-cmd framework check once the framework is known; EnvironmentBuilder does. No behaviour change; ProjectCreator keeps its timing field, which the command test reads to check the real clock is passed through. #claude_code# 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 12208ba commit 7c44794

8 files changed

Lines changed: 34 additions & 34 deletions

File tree

‎.talismanrc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fileignoreconfig:
1212
- filename: src/transport/auth-strategy.test.ts
1313
checksum: a4f3e3ea7db10dbf82abbac0207d2231ee740916f476fcda836a2268505295ef
1414
- filename: src/projects/types.ts
15-
checksum: 563a1f339c7b1ba1a366e8cac087a52805af21d46f07e4078716358ed99270f5
15+
checksum: 6139553ef747421f5b7ee701f82dcdb7071f0cb614c977967a2cb3974495e43c
1616
- filename: src/projects/projects.api.ts
1717
checksum: 29d53afdfa763ea00f8922e7ff48459a88d6acccc865c14831cbc6070c657dda
1818
- filename: src/core/service-context.test.ts

‎AGENTS.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,8 @@ The framework gate is the declarative rule `onlyWithValueOf('server-cmd', 'frame
619619
exported as `serverCommandFrameworkGate` and declared in `static rules` with `gitOnlyFlagRules`
620620
(`--branch`, `--namespace`, `--repo` only with `--type GitHub`). A rule judges its gate only when the
621621
user supplied the gate: with `--framework` on argv, a bad pairing costs exit 2 and nothing on the
622-
wire. When the framework is prompted or detected later, `ProjectCreator` applies the same check
622+
wire. When the framework is prompted or detected later, `EnvironmentBuilder` in
623+
`src/projects/project.environment.ts` applies the same check
623624
(`requireValueOf`) once it knows the framework, still before `POST /projects`.
624625

625626
**Without a terminal, create uses what it can infer.** The framework is the detected one (exit 2 naming

‎src/projects/project.create.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type { ApiErrorEntry } from '../transport/errors';
1414
import { LaunchApiError } from '../transport/errors';
1515
import { GitConnectionMissingError } from '../git/git.errors';
1616
import type { ApiSurface } from '../resources';
17-
import type { CreateRequest } from './project.create';
17+
import type { CreateRequest } from './types';
1818
import { ProjectCreator } from './project.create';
1919
import { SITE_OPEN_DELAY_MS } from './project.follow';
2020
import { UPLOAD_PROGRESS_LABEL } from './project.source';

‎src/projects/project.create.ts‎

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import { askText } from '../core/prompt';
77
import type { ServiceContext } from '../core/service-context';
88
import { messageOf } from '../core/values';
99
import type { WatchTiming } from '../deployments/deployment.watcher';
10-
import type { ResponseMode, ToggleValue } from '../environments/environment.inputs';
1110
import { ENVIRONMENT_NAME_MAX_LENGTH } from '../environments/environment.inputs';
12-
import type { FrameworkPreset } from '../environments/frameworks';
1311
import { repositoryLabel } from '../git/git.presenter';
1412
import { repositorySearchTerm } from '../git/git.prompt';
1513
import type { LocalGitHubRepository } from '../git/local-repository';
@@ -37,30 +35,12 @@ import {
3735
renameRetryLimitLine,
3836
} from './project.presenter';
3937
import { ProjectSource } from './project.source';
40-
import type { CreateProjectInput, IdentifiedProject } from './types';
38+
import type { CreateProjectInput, CreateRequest, IdentifiedProject } from './types';
4139
import { PROJECT_NAME_MAX_LENGTH } from './types';
4240

43-
export const DEFAULT_ENVIRONMENT_NAME = 'Default';
44-
export const DUPLICATE_PROJECT_NAME_CODE = 'launch.PROJECT.DUPLICATE_NAME';
45-
export const PROJECT_RENAME_ATTEMPTS = 3;
46-
47-
export interface CreateRequest {
48-
org: string;
49-
dataDir: string;
50-
configPath: string;
51-
type?: ProjectTypeChoice;
52-
name?: string;
53-
description?: string;
54-
envName?: string;
55-
branch?: string;
56-
framework?: FrameworkPreset;
57-
buildCmd?: string;
58-
outputDir?: string;
59-
serverCmd?: string;
60-
resMode?: ResponseMode;
61-
autoDeploy?: ToggleValue;
62-
csAuth?: ToggleValue;
63-
}
41+
const DEFAULT_ENVIRONMENT_NAME = 'Default';
42+
const DUPLICATE_PROJECT_NAME_CODE = 'launch.PROJECT.DUPLICATE_NAME';
43+
const PROJECT_RENAME_ATTEMPTS = 3;
6444

6545
function shownPath(path: string): string {
6646
const absolute = resolve(path);

‎src/projects/project.environment.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ import {
1212
SERVER_COMMAND_FRAMEWORKS,
1313
} from '../environments/frameworks';
1414
import type { CreateEnvironmentInput } from '../environments/types';
15-
import type { CreateRequest } from './project.create';
1615
import { CREATE_PROMPT_REMEDIES } from './project.inputs';
1716
import type { SourceSelection } from './project.source';
18-
import type { DetectedFramework } from './types';
17+
import type { CreateRequest, DetectedFramework } from './types';
1918

2019
function emptyEnvironmentVariables(): [] {
2120
return [];

‎src/projects/project.follow.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import type { Environment } from '../environments/types';
1111
import { deploymentFailureMessage, deploymentUrlLine } from './project.presenter';
1212
import type { IdentifiedProject } from './types';
1313

14-
export const NO_DEPLOYMENT_STATUS = 'NONE';
15-
export const FIRST_LOOKUP_ATTEMPTS = 3;
14+
const NO_DEPLOYMENT_STATUS = 'NONE';
15+
const FIRST_LOOKUP_ATTEMPTS = 3;
1616
export const SITE_OPEN_DELAY_MS = 6000;
1717

1818
interface Survivors {

‎src/projects/project.source.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ import type { GitNamespacesPage, GitRepository } from '../git/types';
1414
import { GIT_PROVIDER_GITHUB } from '../git/types';
1515
import { LaunchApiError } from '../transport/errors';
1616
import { archiveDirectory } from './project.archive';
17-
import type { CreateRequest } from './project.create';
1817
import { needInput } from './project.inputs';
1918
import { PREPARING_ARCHIVE } from './project.presenter';
2019
import { refuseArchiveOutsideLimits, uploadArchive } from './project.upload';
21-
import type { DetectedFramework, SignedUploadUrl } from './types';
20+
import type { CreateRequest, DetectedFramework, SignedUploadUrl } from './types';
2221

2322
export const UPLOAD_PROGRESS_LABEL = 'Uploading project.zip';
24-
export const GIT_NAMESPACE_PAGE_SIZE = 100;
23+
const GIT_NAMESPACE_PAGE_SIZE = 100;
2524

2625
export interface SourceSelection {
2726
detected: DetectedFramework;

‎src/projects/types.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import type { Pagination } from '../core/render';
2+
import type { ResponseMode, ToggleValue } from '../environments/environment.inputs';
3+
import type { FrameworkPreset } from '../environments/frameworks';
24
import type { CreateEnvironmentInput } from '../environments/types';
5+
import type { ProjectTypeChoice } from './project.inputs';
36

47
export type { Pagination };
58

@@ -96,3 +99,21 @@ export interface ProjectsPage {
9699
pagination: Pagination;
97100
projects: Project[];
98101
}
102+
103+
export interface CreateRequest {
104+
org: string;
105+
dataDir: string;
106+
configPath: string;
107+
type?: ProjectTypeChoice;
108+
name?: string;
109+
description?: string;
110+
envName?: string;
111+
branch?: string;
112+
framework?: FrameworkPreset;
113+
buildCmd?: string;
114+
outputDir?: string;
115+
serverCmd?: string;
116+
resMode?: ResponseMode;
117+
autoDeploy?: ToggleValue;
118+
csAuth?: ToggleValue;
119+
}

0 commit comments

Comments
 (0)