( targetPath: string = process.cwd(), nonInteractive = false, )
| 943 | } |
| 944 | |
| 945 | export async function initExtension( |
| 946 | targetPath: string = process.cwd(), |
| 947 | nonInteractive = false, |
| 948 | ): Promise<boolean> { |
| 949 | const resolvedPath = resolve(targetPath); |
| 950 | const manifestPath = join(resolvedPath, "manifest.json"); |
| 951 | |
| 952 | if (existsSync(manifestPath)) { |
| 953 | if (nonInteractive) { |
| 954 | console.log( |
| 955 | "manifest.json already exists. Use --force to overwrite in non-interactive mode.", |
| 956 | ); |
| 957 | return false; |
| 958 | } |
| 959 | const overwrite = await confirm({ |
| 960 | message: "manifest.json already exists. Overwrite?", |
| 961 | default: false, |
| 962 | }); |
| 963 | if (!overwrite) { |
| 964 | console.log("Cancelled"); |
| 965 | return false; |
| 966 | } |
| 967 | } |
| 968 | |
| 969 | if (!nonInteractive) { |
| 970 | console.log( |
| 971 | "This utility will help you create a manifest.json file for your MCPB bundle.", |
| 972 | ); |
| 973 | console.log("Press ^C at any time to quit.\n"); |
| 974 | } else { |
| 975 | console.log("Creating manifest.json with default values..."); |
| 976 | } |
| 977 | |
| 978 | try { |
| 979 | const packageData = readPackageJson(resolvedPath); |
| 980 | |
| 981 | // Prompt for all information or use defaults |
| 982 | const basicInfo = nonInteractive |
| 983 | ? getDefaultBasicInfo(packageData, resolvedPath) |
| 984 | : await promptBasicInfo(packageData, resolvedPath); |
| 985 | const longDescription = nonInteractive |
| 986 | ? undefined |
| 987 | : await promptLongDescription(basicInfo.description); |
| 988 | const authorInfo = nonInteractive |
| 989 | ? getDefaultAuthorInfo(packageData) |
| 990 | : await promptAuthorInfo(packageData); |
| 991 | const urls = nonInteractive |
| 992 | ? { homepage: "", documentation: "", support: "" } |
| 993 | : await promptUrls(); |
| 994 | const visualAssets = nonInteractive |
| 995 | ? { icon: "", icons: [], screenshots: [] } |
| 996 | : await promptVisualAssets(); |
| 997 | // const localization = nonInteractive |
| 998 | // ? undefined |
| 999 | // : await promptLocalization(); |
| 1000 | const serverConfig = nonInteractive |
| 1001 | ? getDefaultServerConfig(packageData) |
| 1002 | : await promptServerConfig(packageData); |
no test coverage detected
searching dependent graphs…