实现小游戏与小程序项目创建发布
This commit is contained in:
@@ -11,7 +11,7 @@ import {
|
||||
} from 'node:fs/promises';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join, sep } from 'node:path';
|
||||
import type { ProjectConfig } from '../../shared/project-config';
|
||||
import type { ProjectConfig, ProjectType } from '../../shared/project-config';
|
||||
import { createInitialProjectConfig, readProjectConfig } from './project-config';
|
||||
|
||||
type StagedProjectEntries = {
|
||||
@@ -27,6 +27,7 @@ export type ProjectDirectoryInitializationResult = {
|
||||
export type ProjectDirectoryInitializationInput = {
|
||||
projectPath: string;
|
||||
defaultModel?: string | null;
|
||||
projectType?: ProjectType;
|
||||
allowExistingDirectory: boolean;
|
||||
};
|
||||
|
||||
@@ -210,6 +211,9 @@ export async function initializeProjectDirectory(
|
||||
await requireExistingDirectory(input.projectPath);
|
||||
const existing = await readProjectConfig(input.projectPath);
|
||||
if (existing.status === 'valid') {
|
||||
if (input.projectType !== undefined && input.projectType !== existing.config.projectType) {
|
||||
throw new Error('已有项目类型不可更改');
|
||||
}
|
||||
return { config: existing.config, reusedExistingConfig: true };
|
||||
}
|
||||
if (existing.status === 'invalid') {
|
||||
@@ -228,6 +232,7 @@ export async function initializeProjectDirectory(
|
||||
try {
|
||||
config = await createInitialProjectConfig(stagingPath, {
|
||||
defaultModel: input.defaultModel,
|
||||
projectType: input.projectType,
|
||||
});
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
|
||||
Reference in New Issue
Block a user