Skip to content

Commit

Permalink
Revert "feat: use new --yes flag on nwui"
Browse files Browse the repository at this point in the history
This reverts commit d5fe3d3.
  • Loading branch information
danstepanov committed Aug 20, 2024
1 parent cedfb31 commit 163ab51
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 55 deletions.
15 changes: 9 additions & 6 deletions cli/__tests__/cli-integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,17 @@ for (const packageManager of packageManagers) {

expect(fileList).toMatchSnapshot(`${finalFlags.join(', ')}-file-list`);

Check failure on line 142 in cli/__tests__/cli-integration.test.ts

View workflow job for this annotation

GitHub Actions / build-and-test

error: expect(received).toMatchSnapshot(expected)

Expected: "./myTestProject ./myTestProject/app ./myTestProject/app.json ./myTestProject/app/(drawer) ./myTestProject/app/(drawer)/(tabs) ./myTestProject/app/(drawer)/(tabs)/_layout.tsx ./myTestProject/app/(drawer)/(tabs)/index.tsx ./myTestProject/app/(drawer)/(tabs)/two.tsx ./myTestProject/app/(drawer)/_layout.tsx ./myTestProject/app/(drawer)/index.tsx ./myTestProject/app/+html.tsx ./myTestProject/app/+not-found.tsx ./myTestProject/app/_layout.tsx ./myTestProject/app/modal.tsx ./myTestProject/assets ./myTestProject/assets/adaptive-icon.png ./myTestProject/assets/favicon.png ./myTestProject/assets/icon.png ./myTestProject/assets/splash.png ./myTestProject/babel.config.js ./myTestProject/bun.lockb ./myTestProject/cesconfig.json ./myTestProject/components ./myTestProject/components/BackButton.tsx ./myTestProject/components/Button.tsx ./myTestProject/components/Container.tsx ./myTestProject/components/EditScreenInfo.tsx ./myTestProject/components/HeaderButton.tsx ./myTestProject/components/ScreenContent.tsx ./myTestProject/components/TabBarIcon.tsx ./myTestProject/components/ThemeToggle.tsx ./myTestProject/components/nativewindui ./myTestProject/components/nativewindui/DatePicker ./myTestProject/components/nativewindui/DatePicker/DatePicker.android.tsx ./myTestProject/components/nativewindui/DatePicker/DatePicker.tsx ./myTestProject/components/nativewindui/DatePicker/index.ts ./myTestProject/components/nativewindui/Picker.tsx ./myTestProject/components/nativewindui/Text.tsx ./myTestProject/components/nativewindui/examples ./myTestProject/components/nativewindui/examples/date-picker.tsx ./myTestProject/components/nativewindui/examples/picker.tsx ./myTestProject/components/nativewindui/examples/text.tsx ./myTestProject/global.css ./myTestProject/lib ./myTestProject/lib/cn.ts ./myTestProject/lib/useColorScheme.tsx ./myTestProject/lib/useHeaderSearchBar.tsx ./myTestProject/metro.config.js ./myTestProject/nativewind-env.d.ts ./myTestProject/package.json ./myTestProject/prettier.config.js ./myTestProject/tailwind.config.js ./myTestProject/theme ./myTestProject/theme/colors.ts ./myTestProject/theme/index.ts ./myTestProject/tsconfig.json " Received: "./myTestProject ./myTestProject/app ./myTestProject/app.json ./myTestProject/app/(drawer) ./myTestProject/app/(drawer)/(tabs) ./myTestProject/app/(drawer)/(tabs)/_layout.tsx ./myTestProject/app/(drawer)/(tabs)/index.tsx ./myTestProject/app/(drawer)/(tabs)/two.tsx ./myTestProject/app/(drawer)/_layout.tsx ./myTestProject/app/(drawer)/index.tsx ./myTestProject/app/+html.tsx ./myTestProject/app/+not-found.tsx ./myTestProject/app/_layout.tsx ./myTestProject/app/modal.tsx ./myTestProject/assets ./myTestProject/assets/adaptive-icon.png ./myTestProject/assets/favicon.png ./myTestProject/assets/icon.png ./myTestProject/assets/splash.png ./myTestProject/babel.config.js ./myTestProject/bun.lockb ./myTestProject/cesconfig.json ./myTestProject/components ./myTestProject/components/BackButton.tsx ./myTestProject/components/Button.tsx ./myTestProject/components/Container.tsx ./myTestProject/components/EditScreenInfo.tsx ./myTestProject/components/HeaderButton.tsx ./myTestProject/components/ScreenContent.tsx ./myTestProject/components/TabBarIcon.tsx ./myTestProject/components/ThemeToggle.tsx ./myTestProject/components/nativewindui ./myTestProject/components/nativewindui/DatePicker ./myTestProject/components/nativewindui/DatePicker/DatePicker.android.tsx ./myTestProject/components/nativewindui/DatePicker/DatePicker.tsx ./myTestProject/components/nativewindui/DatePicker/index.ts ./myTestProject/components/nativewindui/Picker.tsx ./myTestProject/components/nativewindui/Text.tsx ./myTestProject/global.css ./myTestProject/lib ./myTestProject/lib/cn.ts ./myTestProject/lib/useColorScheme.tsx ./myTestProject/lib/useHeaderSearchBar.tsx ./myTestProject/metro.config.js ./myTestProject/nativewind-env.d.ts ./myTestProject/package.json ./myTestProject/prettier.config.js ./myTestProject/tailwind.config.js ./myTestProject/theme ./myTestProject/theme/colors.ts ./myTestProject/theme/index.ts ./myTestProject/tsconfig.

const { stderr, stdout, exitCode } = await Bun.$`cd ${projectName} && bun run tsc --noEmit`;
// once nwui cli examples are fixed we can remove this
if (!finalFlags.includes('--nativewindui')) {
const { stderr, stdout, exitCode } = await Bun.$`cd ${projectName} && bun run tsc --noEmit`;

if (exitCode !== 0) {
console.warn('stdout', stdout.toString());
console.warn('stderr', stderr.toString());
}
if (exitCode !== 0) {
console.warn('stdout', stdout.toString());
console.warn('stderr', stderr.toString());
}

expect(exitCode).toBe(0);
expect(exitCode).toBe(0);
}
});
}
}
Expand Down
43 changes: 0 additions & 43 deletions cli/src/utilities/generateNWUI.ts

This file was deleted.

44 changes: 38 additions & 6 deletions cli/src/utilities/printOutput.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { outro, spinner } from '@clack/prompts';
import { Toolbox } from 'gluegun/build/types/domain/toolbox';
import { nativeWindUIOptions } from '../constants';
import { AvailablePackages, CliResults } from '../types';
import { copyBaseAssets } from './copyBaseAssets';
import { generateNWUI } from './generateNWUI';
import { getPackageManager, getPackageManagerRunnerX } from './getPackageManager';
import { easConfigure } from './runEasConfigure';
import { ONLY_ERRORS, runSystemCommand } from './systemCommand';
Expand Down Expand Up @@ -78,8 +78,6 @@ export async function printOutput(

s.stop('Packages updated!');

await generateNWUI(cliResults, toolbox);

s.start(`Cleaning up your project...`);

// format the files with prettier and eslint using installed packages.
Expand All @@ -92,11 +90,10 @@ export async function printOutput(

s.stop('Project files formatted!');
} else {
await generateNWUI(cliResults, toolbox);

s.start(`formatting your project using ${runnerType} prettier...`);
s.start(`No installation found.\nCleaning up your project using ${runnerType}...`);

// Running prettier using global runners against the template.
// Use --no-config to prevent using project's config (that may have plugins/dependencies)
await runSystemCommand({
toolbox,
command: `${runnerType} prettier "${projectName}/**/*.{json,js,jsx,ts,tsx}" --no-config --write`,
Expand All @@ -107,6 +104,41 @@ export async function printOutput(
s.stop('Project files formatted!');
}

const isNativeWindUISelected = cliResults.packages.some((p) => p.name === 'nativewindui');

if (isNativeWindUISelected) {
const nativeWindUIComponents =
cliResults.packages.find((p) => p.name === 'nativewindui').options.selectedComponents ?? [];

// we do this to account for older stored config e.g that has selectable text in it
const onlySupportedComponents = nativeWindUIComponents.filter((component) =>
nativeWindUIOptions.includes(component)
);

const finalComponents = Array.from(new Set([...onlySupportedComponents, 'text']));

s.start(`Adding nativewindui components...`);

await runSystemCommand({
command: `${runnerType} --yes nwui-cli@latest add --overwrite -d ${cliResults.projectName} ${finalComponents.join(' ')}`,
errorMessage: 'Error adding nativewindui components',
toolbox,
stdio: ONLY_ERRORS,

// for some reason running as shell breaks nwui when running in ci
shell: false,

// this is how we pass env variables to the child process when not running as shell
env: {
...process.env,
EXPO_NO_GIT_STATUS: '1',
...(process.env.NODE_ENV === 'development' ? { API_BASE_URL: 'https://nativewindui.com' } : {})
}
});

s.stop('Nativewindui components added!');
}

if (!options.noGit && !flags.noGit && process.env.NODE_ENV !== 'test') {
s.start(`Initializing git...`);
// initialize git repo and add first commit
Expand Down

0 comments on commit 163ab51

Please sign in to comment.