diff --git a/cli/src/api/new.ts b/cli/src/api/new.ts index cc7267ae..4ff2e5a1 100644 --- a/cli/src/api/new.ts +++ b/cli/src/api/new.ts @@ -28,6 +28,7 @@ import { gitIgnore, npmIgnore, } from './templates/index.js' +import { WasiTargetName } from './templates/ci-template.js' const debug = debugFactory('new') @@ -211,6 +212,9 @@ function generateGithubWorkflow(options: NewOptions): Output | null { content: createGithubActionsCIYml( options.targets, options.packageManager as SupportedPackageManager, + (options.targets.find((t) => + t.includes('wasm32-wasi'), + ) as WasiTargetName) ?? 'wasm32-wasi-preview1-threads', ), } } diff --git a/cli/src/api/templates/ci-template.ts b/cli/src/api/templates/ci-template.ts index f8243ebb..66c398c1 100644 --- a/cli/src/api/templates/ci-template.ts +++ b/cli/src/api/templates/ci-template.ts @@ -7,7 +7,7 @@ export type WasiTargetName = export const YAML = ( packageManager: SupportedPackageManager, - wasiTargetName?: WasiTargetName, + wasiTargetName: WasiTargetName, ) => ` name: CI @@ -100,8 +100,6 @@ jobs: sudo apt-get install gcc-s390x-linux-gnu -y build: ${packageManager} build --platform --target s390x-unknown-linux-gnu - host: ubuntu-latest - target: 'wasm32-wasi-preview1-threads' - build: ${packageManager} build --platform --target wasm32-wasi-preview1-threads target: '${wasiTargetName}' build: ${packageManager} build --platform --target ${wasiTargetName} diff --git a/cli/src/api/templates/ci.yml.ts b/cli/src/api/templates/ci.yml.ts index 68fa9606..7d3fa16c 100644 --- a/cli/src/api/templates/ci.yml.ts +++ b/cli/src/api/templates/ci.yml.ts @@ -22,7 +22,7 @@ const UNIVERSAL_MACOS = 'universal-macOS' export const createGithubActionsCIYml = ( targets: string[], packageManager: SupportedPackageManager, - wasiTargetName?: WasiTargetName, + wasiTargetName: WasiTargetName, ) => { const allTargets = new Set( targets.flatMap((t) => { @@ -129,7 +129,12 @@ export const createGithubActionsCIYml = ( fullTemplate.jobs.publish.needs = requiredSteps - return dump(fullTemplate, { - lineWidth: 1000, - }) + try { + return dump(fullTemplate, { + lineWidth: 1000, + }) + } catch (err) { + console.info(fullTemplate) + throw err + } } diff --git a/cli/src/commands/new.ts b/cli/src/commands/new.ts index d3f6b198..48abc93a 100644 --- a/cli/src/commands/new.ts +++ b/cli/src/commands/new.ts @@ -39,13 +39,7 @@ export class NewCommand extends BaseNewCommand { if (this.interactive) { const targetPath: string = cmdOptions.path ? cmdOptions.path - : await inquirer - .prompt({ - type: 'input', - name: 'path', - message: 'Target path to create the project, relative to cwd', - }) - .then(({ path }) => path) + : await inquirerProjectPath() cmdOptions.path = targetPath return { ...cmdOptions, @@ -142,3 +136,18 @@ export class NewCommand extends BaseNewCommand { return enableGithubActions } } + +async function inquirerProjectPath(): Promise { + return inquirer + .prompt({ + type: 'input', + name: 'path', + message: 'Target path to create the project, relative to cwd.', + }) + .then(({ path }) => { + if (!path) { + return inquirerProjectPath() + } + return path + }) +}