|
1 | 1 | import { Command, Option } from 'commander'; |
2 | 2 | import { execa } from 'execa'; |
3 | | -import { existsSync } from 'node:fs'; |
4 | 3 | import { copyFile, cp, writeFile } from 'node:fs/promises'; |
5 | 4 | import { join } from 'node:path'; |
6 | 5 |
|
@@ -77,53 +76,21 @@ export async function buildCatalystProject(projectUuid: string): Promise<void> { |
77 | 76 | } |
78 | 77 |
|
79 | 78 | export const build = new Command('build') |
80 | | - .allowUnknownOption() |
81 | | - // The unknown options end up in program.args, not in program.opts(). Commander does not take a guess at how to interpret the unknown options. |
82 | | - .argument( |
83 | | - '[next-build-options...]', |
84 | | - 'Next.js `build` options (see: https://nextjs.org/docs/app/api-reference/cli/next#next-build-options)', |
85 | | - ) |
86 | 79 | .addOption( |
87 | 80 | new Option( |
88 | 81 | '--project-uuid <uuid>', |
89 | 82 | 'Project UUID to be included in the deployment configuration.', |
90 | 83 | ).env('CATALYST_PROJECT_UUID'), |
91 | 84 | ) |
92 | | - .addOption( |
93 | | - new Option('--framework <framework>', 'The framework to use for the build.').choices([ |
94 | | - 'nextjs', |
95 | | - 'catalyst', |
96 | | - ]), |
97 | | - ) |
98 | | - .action(async (nextBuildOptions, options) => { |
99 | | - const coreDir = process.cwd(); |
| 85 | + .action(async (options) => { |
100 | 86 | const config = getProjectConfig(); |
101 | | - const framework = options.framework ?? config.get('framework'); |
102 | | - |
103 | | - if (framework === 'nextjs') { |
104 | | - const nextBin = join('node_modules', '.bin', 'next'); |
| 87 | + const projectUuid = options.projectUuid ?? config.get('projectUuid'); |
105 | 88 |
|
106 | | - if (!existsSync(nextBin)) { |
107 | | - throw new Error( |
108 | | - `Next.js is not installed in ${coreDir}. Are you in a valid Next.js project?`, |
109 | | - ); |
110 | | - } |
111 | | - |
112 | | - await execa(nextBin, ['build', ...nextBuildOptions], { |
113 | | - stdio: 'inherit', |
114 | | - cwd: coreDir, |
115 | | - }); |
| 89 | + if (!projectUuid) { |
| 90 | + throw new Error( |
| 91 | + 'Project UUID is required. Please run `catalyst project create` or `catalyst project link` or this command again with --project-uuid <uuid>.', |
| 92 | + ); |
116 | 93 | } |
117 | 94 |
|
118 | | - if (framework === 'catalyst') { |
119 | | - const projectUuid = options.projectUuid ?? config.get('projectUuid'); |
120 | | - |
121 | | - if (!projectUuid) { |
122 | | - throw new Error( |
123 | | - 'Project UUID is required. Please run `catalyst project create` or `catalyst project link` or this command again with --project-uuid <uuid>.', |
124 | | - ); |
125 | | - } |
126 | | - |
127 | | - await buildCatalystProject(projectUuid); |
128 | | - } |
| 95 | + await buildCatalystProject(projectUuid); |
129 | 96 | }); |
0 commit comments