nwui-cli 0.3.5 → 0.4.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/build/index.js +15 -3
  3. package/build/install-component.js +121 -34
  4. package/build/login.js +10 -2
  5. package/build/utils/env.js +4 -1
  6. package/my-expo-app-2/app/+html.tsx +46 -0
  7. package/my-expo-app-2/app/+not-found.tsx +33 -0
  8. package/my-expo-app-2/app/_layout.tsx +22 -0
  9. package/my-expo-app-2/app/details.tsx +17 -0
  10. package/my-expo-app-2/app/index.tsx +23 -0
  11. package/my-expo-app-2/app-env.d.ts +2 -0
  12. package/my-expo-app-2/app.json +48 -0
  13. package/my-expo-app-2/assets/adaptive-icon.png +0 -0
  14. package/my-expo-app-2/assets/favicon.png +0 -0
  15. package/my-expo-app-2/assets/icon.png +0 -0
  16. package/my-expo-app-2/assets/splash.png +0 -0
  17. package/my-expo-app-2/babel.config.js +18 -0
  18. package/my-expo-app-2/cesconfig.json +35 -0
  19. package/my-expo-app-2/components/Button.tsx +19 -0
  20. package/my-expo-app-2/components/Container.tsx +9 -0
  21. package/my-expo-app-2/components/EditScreenInfo.tsx +34 -0
  22. package/my-expo-app-2/components/ScreenContent.tsx +25 -0
  23. package/my-expo-app-2/components/nativewindui/ActivityIndicator.tsx +13 -0
  24. package/my-expo-app-2/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.ios.tsx +97 -0
  25. package/my-expo-app-2/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.tsx +264 -0
  26. package/my-expo-app-2/components/nativewindui/AdaptiveSearchHeader/index.ts +1 -0
  27. package/my-expo-app-2/components/nativewindui/AdaptiveSearchHeader/types.ts +95 -0
  28. package/my-expo-app-2/components/nativewindui/Alert/Alert.ios.tsx +65 -0
  29. package/my-expo-app-2/components/nativewindui/Alert/Alert.tsx +291 -0
  30. package/my-expo-app-2/components/nativewindui/Alert/index.ts +1 -0
  31. package/my-expo-app-2/components/nativewindui/Alert/types.ts +27 -0
  32. package/my-expo-app-2/components/nativewindui/Badge.tsx +84 -0
  33. package/my-expo-app-2/components/nativewindui/Button.tsx +156 -0
  34. package/my-expo-app-2/components/nativewindui/Checkbox.tsx +61 -0
  35. package/my-expo-app-2/components/nativewindui/ContextMenu/ContextMenu.ios.tsx +221 -0
  36. package/my-expo-app-2/components/nativewindui/ContextMenu/ContextMenu.tsx +420 -0
  37. package/my-expo-app-2/components/nativewindui/ContextMenu/index.ts +1 -0
  38. package/my-expo-app-2/components/nativewindui/ContextMenu/types.ts +91 -0
  39. package/my-expo-app-2/components/nativewindui/ContextMenu/utils.ts +14 -0
  40. package/my-expo-app-2/components/nativewindui/DrawerContent.tsx +145 -0
  41. package/my-expo-app-2/components/nativewindui/DropdownMenu/DropdownMenu.ios.tsx +168 -0
  42. package/my-expo-app-2/components/nativewindui/DropdownMenu/DropdownMenu.tsx +330 -0
  43. package/my-expo-app-2/components/nativewindui/DropdownMenu/index.ts +1 -0
  44. package/my-expo-app-2/components/nativewindui/DropdownMenu/types.ts +93 -0
  45. package/my-expo-app-2/components/nativewindui/DropdownMenu/utils.ts +14 -0
  46. package/my-expo-app-2/components/nativewindui/Form.tsx +125 -0
  47. package/my-expo-app-2/components/nativewindui/LargeTitleHeader/LargeTitleHeader.ios.tsx +99 -0
  48. package/my-expo-app-2/components/nativewindui/LargeTitleHeader/LargeTitleHeader.tsx +288 -0
  49. package/my-expo-app-2/components/nativewindui/LargeTitleHeader/index.ts +1 -0
  50. package/my-expo-app-2/components/nativewindui/LargeTitleHeader/types.ts +89 -0
  51. package/my-expo-app-2/components/nativewindui/List.tsx +433 -0
  52. package/my-expo-app-2/components/nativewindui/SearchInput/SearchInput.ios.tsx +177 -0
  53. package/my-expo-app-2/components/nativewindui/SearchInput/SearchInput.tsx +86 -0
  54. package/my-expo-app-2/components/nativewindui/SearchInput/index.tsx +1 -0
  55. package/my-expo-app-2/components/nativewindui/SearchInput/types.ts +12 -0
  56. package/my-expo-app-2/components/nativewindui/SegmentedControl/SegmentedControl.ios.tsx +31 -0
  57. package/my-expo-app-2/components/nativewindui/SegmentedControl/SegmentedControl.tsx +55 -0
  58. package/my-expo-app-2/components/nativewindui/SegmentedControl/index.ts +1 -0
  59. package/my-expo-app-2/components/nativewindui/SegmentedControl/types.ts +15 -0
  60. package/my-expo-app-2/components/nativewindui/Stepper.tsx +62 -0
  61. package/my-expo-app-2/components/nativewindui/Text.tsx +55 -0
  62. package/my-expo-app-2/components/nativewindui/TextField/TextField.ios.tsx +85 -0
  63. package/my-expo-app-2/components/nativewindui/TextField/TextField.tsx +326 -0
  64. package/my-expo-app-2/components/nativewindui/TextField/index.tsx +1 -0
  65. package/my-expo-app-2/components/nativewindui/TextField/types.ts +26 -0
  66. package/my-expo-app-2/components/nativewindui/Toolbar.tsx +116 -0
  67. package/my-expo-app-2/global.css +3 -0
  68. package/my-expo-app-2/metro.config.js +12 -0
  69. package/my-expo-app-2/package-lock.json +19162 -0
  70. package/my-expo-app-2/package.json +74 -0
  71. package/my-expo-app-2/prettier.config.js +11 -0
  72. package/my-expo-app-2/tailwind.config.js +11 -0
  73. package/my-expo-app-3/app/+html.tsx +46 -0
  74. package/my-expo-app-3/app/+not-found.tsx +33 -0
  75. package/my-expo-app-3/app/_layout.tsx +22 -0
  76. package/my-expo-app-3/app/details.tsx +17 -0
  77. package/my-expo-app-3/app/index.tsx +23 -0
  78. package/my-expo-app-3/app-env.d.ts +2 -0
  79. package/my-expo-app-3/app.json +48 -0
  80. package/my-expo-app-3/assets/adaptive-icon.png +0 -0
  81. package/my-expo-app-3/assets/favicon.png +0 -0
  82. package/my-expo-app-3/assets/icon.png +0 -0
  83. package/my-expo-app-3/assets/splash.png +0 -0
  84. package/my-expo-app-3/babel.config.js +18 -0
  85. package/my-expo-app-3/cesconfig.json +35 -0
  86. package/my-expo-app-3/components/Button.tsx +19 -0
  87. package/my-expo-app-3/components/Container.tsx +9 -0
  88. package/my-expo-app-3/components/EditScreenInfo.tsx +34 -0
  89. package/my-expo-app-3/components/ScreenContent.tsx +25 -0
  90. package/my-expo-app-3/components/nativewindui/ActivityIndicator.tsx +13 -0
  91. package/my-expo-app-3/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.ios.tsx +97 -0
  92. package/my-expo-app-3/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.tsx +264 -0
  93. package/my-expo-app-3/components/nativewindui/AdaptiveSearchHeader/index.ts +1 -0
  94. package/my-expo-app-3/components/nativewindui/AdaptiveSearchHeader/types.ts +95 -0
  95. package/my-expo-app-3/components/nativewindui/Alert/Alert.ios.tsx +65 -0
  96. package/my-expo-app-3/components/nativewindui/Alert/Alert.tsx +291 -0
  97. package/my-expo-app-3/components/nativewindui/Alert/index.ts +1 -0
  98. package/my-expo-app-3/components/nativewindui/Alert/types.ts +27 -0
  99. package/my-expo-app-3/components/nativewindui/Badge.tsx +84 -0
  100. package/my-expo-app-3/components/nativewindui/Button.tsx +156 -0
  101. package/my-expo-app-3/components/nativewindui/Checkbox.tsx +61 -0
  102. package/my-expo-app-3/components/nativewindui/ContextMenu/ContextMenu.ios.tsx +221 -0
  103. package/my-expo-app-3/components/nativewindui/ContextMenu/ContextMenu.tsx +420 -0
  104. package/my-expo-app-3/components/nativewindui/ContextMenu/index.ts +1 -0
  105. package/my-expo-app-3/components/nativewindui/ContextMenu/types.ts +91 -0
  106. package/my-expo-app-3/components/nativewindui/ContextMenu/utils.ts +14 -0
  107. package/my-expo-app-3/components/nativewindui/DrawerContent.tsx +145 -0
  108. package/my-expo-app-3/components/nativewindui/DropdownMenu/DropdownMenu.ios.tsx +168 -0
  109. package/my-expo-app-3/components/nativewindui/DropdownMenu/DropdownMenu.tsx +330 -0
  110. package/my-expo-app-3/components/nativewindui/DropdownMenu/index.ts +1 -0
  111. package/my-expo-app-3/components/nativewindui/DropdownMenu/types.ts +93 -0
  112. package/my-expo-app-3/components/nativewindui/DropdownMenu/utils.ts +14 -0
  113. package/my-expo-app-3/components/nativewindui/Form.tsx +125 -0
  114. package/my-expo-app-3/components/nativewindui/LargeTitleHeader/LargeTitleHeader.ios.tsx +99 -0
  115. package/my-expo-app-3/components/nativewindui/LargeTitleHeader/LargeTitleHeader.tsx +288 -0
  116. package/my-expo-app-3/components/nativewindui/LargeTitleHeader/index.ts +1 -0
  117. package/my-expo-app-3/components/nativewindui/LargeTitleHeader/types.ts +89 -0
  118. package/my-expo-app-3/components/nativewindui/List.tsx +433 -0
  119. package/my-expo-app-3/components/nativewindui/SearchInput/SearchInput.ios.tsx +177 -0
  120. package/my-expo-app-3/components/nativewindui/SearchInput/SearchInput.tsx +86 -0
  121. package/my-expo-app-3/components/nativewindui/SearchInput/index.tsx +1 -0
  122. package/my-expo-app-3/components/nativewindui/SearchInput/types.ts +12 -0
  123. package/my-expo-app-3/components/nativewindui/SegmentedControl/SegmentedControl.ios.tsx +31 -0
  124. package/my-expo-app-3/components/nativewindui/SegmentedControl/SegmentedControl.tsx +55 -0
  125. package/my-expo-app-3/components/nativewindui/SegmentedControl/index.ts +1 -0
  126. package/my-expo-app-3/components/nativewindui/SegmentedControl/types.ts +15 -0
  127. package/my-expo-app-3/components/nativewindui/Stepper.tsx +62 -0
  128. package/my-expo-app-3/components/nativewindui/Text.tsx +55 -0
  129. package/my-expo-app-3/components/nativewindui/TextField/TextField.ios.tsx +85 -0
  130. package/my-expo-app-3/components/nativewindui/TextField/TextField.tsx +326 -0
  131. package/my-expo-app-3/components/nativewindui/TextField/index.tsx +1 -0
  132. package/my-expo-app-3/components/nativewindui/TextField/types.ts +26 -0
  133. package/my-expo-app-3/components/nativewindui/Toolbar.tsx +116 -0
  134. package/my-expo-app-3/components/nativewindui/examples/selectable-text.tsx +43 -0
  135. package/my-expo-app-3/components/nativewindui/examples/text.tsx +43 -0
  136. package/my-expo-app-3/global.css +3 -0
  137. package/my-expo-app-3/metro.config.js +12 -0
  138. package/my-expo-app-3/package-lock.json +19141 -0
  139. package/my-expo-app-3/package.json +73 -0
  140. package/my-expo-app-3/prettier.config.js +11 -0
  141. package/my-expo-app-3/tailwind.config.js +11 -0
  142. package/my-expo-app-test-case/app/+html.tsx +46 -0
  143. package/my-expo-app-test-case/app/+not-found.tsx +33 -0
  144. package/my-expo-app-test-case/app/_layout.tsx +22 -0
  145. package/my-expo-app-test-case/app/details.tsx +17 -0
  146. package/my-expo-app-test-case/app/index.tsx +23 -0
  147. package/my-expo-app-test-case/app-env.d.ts +2 -0
  148. package/my-expo-app-test-case/app.json +48 -0
  149. package/my-expo-app-test-case/assets/adaptive-icon.png +0 -0
  150. package/my-expo-app-test-case/assets/favicon.png +0 -0
  151. package/my-expo-app-test-case/assets/icon.png +0 -0
  152. package/my-expo-app-test-case/assets/splash.png +0 -0
  153. package/my-expo-app-test-case/babel.config.js +18 -0
  154. package/my-expo-app-test-case/cesconfig.json +35 -0
  155. package/my-expo-app-test-case/components/Button.tsx +19 -0
  156. package/my-expo-app-test-case/components/Container.tsx +9 -0
  157. package/my-expo-app-test-case/components/EditScreenInfo.tsx +34 -0
  158. package/my-expo-app-test-case/components/ScreenContent.tsx +25 -0
  159. package/my-expo-app-test-case/components/nativewindui/ActivityIndicator.tsx +13 -0
  160. package/my-expo-app-test-case/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.ios.tsx +97 -0
  161. package/my-expo-app-test-case/components/nativewindui/AdaptiveSearchHeader/AdaptiveSearchHeader.tsx +264 -0
  162. package/my-expo-app-test-case/components/nativewindui/AdaptiveSearchHeader/index.ts +1 -0
  163. package/my-expo-app-test-case/components/nativewindui/AdaptiveSearchHeader/types.ts +95 -0
  164. package/my-expo-app-test-case/components/nativewindui/Alert/Alert.ios.tsx +65 -0
  165. package/my-expo-app-test-case/components/nativewindui/Alert/Alert.tsx +291 -0
  166. package/my-expo-app-test-case/components/nativewindui/Alert/index.ts +1 -0
  167. package/my-expo-app-test-case/components/nativewindui/Alert/types.ts +27 -0
  168. package/my-expo-app-test-case/components/nativewindui/Badge.tsx +84 -0
  169. package/my-expo-app-test-case/components/nativewindui/Button.tsx +156 -0
  170. package/my-expo-app-test-case/components/nativewindui/Checkbox.tsx +61 -0
  171. package/my-expo-app-test-case/components/nativewindui/ContextMenu/ContextMenu.ios.tsx +221 -0
  172. package/my-expo-app-test-case/components/nativewindui/ContextMenu/ContextMenu.tsx +420 -0
  173. package/my-expo-app-test-case/components/nativewindui/ContextMenu/index.ts +1 -0
  174. package/my-expo-app-test-case/components/nativewindui/ContextMenu/types.ts +91 -0
  175. package/my-expo-app-test-case/components/nativewindui/ContextMenu/utils.ts +14 -0
  176. package/my-expo-app-test-case/components/nativewindui/DrawerContent.tsx +145 -0
  177. package/my-expo-app-test-case/components/nativewindui/DropdownMenu/DropdownMenu.ios.tsx +168 -0
  178. package/my-expo-app-test-case/components/nativewindui/DropdownMenu/DropdownMenu.tsx +330 -0
  179. package/my-expo-app-test-case/components/nativewindui/DropdownMenu/index.ts +1 -0
  180. package/my-expo-app-test-case/components/nativewindui/DropdownMenu/types.ts +93 -0
  181. package/my-expo-app-test-case/components/nativewindui/DropdownMenu/utils.ts +14 -0
  182. package/my-expo-app-test-case/components/nativewindui/Form.tsx +125 -0
  183. package/my-expo-app-test-case/components/nativewindui/LargeTitleHeader/LargeTitleHeader.ios.tsx +99 -0
  184. package/my-expo-app-test-case/components/nativewindui/LargeTitleHeader/LargeTitleHeader.tsx +288 -0
  185. package/my-expo-app-test-case/components/nativewindui/LargeTitleHeader/index.ts +1 -0
  186. package/my-expo-app-test-case/components/nativewindui/LargeTitleHeader/types.ts +89 -0
  187. package/my-expo-app-test-case/components/nativewindui/List.tsx +433 -0
  188. package/my-expo-app-test-case/components/nativewindui/SearchInput/SearchInput.ios.tsx +177 -0
  189. package/my-expo-app-test-case/components/nativewindui/SearchInput/SearchInput.tsx +86 -0
  190. package/my-expo-app-test-case/components/nativewindui/SearchInput/index.tsx +1 -0
  191. package/my-expo-app-test-case/components/nativewindui/SearchInput/types.ts +12 -0
  192. package/my-expo-app-test-case/components/nativewindui/SegmentedControl/SegmentedControl.ios.tsx +31 -0
  193. package/my-expo-app-test-case/components/nativewindui/SegmentedControl/SegmentedControl.tsx +55 -0
  194. package/my-expo-app-test-case/components/nativewindui/SegmentedControl/index.ts +1 -0
  195. package/my-expo-app-test-case/components/nativewindui/SegmentedControl/types.ts +15 -0
  196. package/my-expo-app-test-case/components/nativewindui/Stepper.tsx +62 -0
  197. package/my-expo-app-test-case/components/nativewindui/Text.tsx +55 -0
  198. package/my-expo-app-test-case/components/nativewindui/TextField/TextField.ios.tsx +85 -0
  199. package/my-expo-app-test-case/components/nativewindui/TextField/TextField.tsx +326 -0
  200. package/my-expo-app-test-case/components/nativewindui/TextField/index.tsx +1 -0
  201. package/my-expo-app-test-case/components/nativewindui/TextField/types.ts +26 -0
  202. package/my-expo-app-test-case/components/nativewindui/Toolbar.tsx +116 -0
  203. package/my-expo-app-test-case/components/nativewindui/examples/a-user-created-file.tsx +0 -0
  204. package/my-expo-app-test-case/components/nativewindui/examples/selectable-text.tsx +43 -0
  205. package/my-expo-app-test-case/components/nativewindui/examples/text.tsx +43 -0
  206. package/my-expo-app-test-case/global.css +3 -0
  207. package/my-expo-app-test-case/metro.config.js +12 -0
  208. package/my-expo-app-test-case/package-lock.json +19141 -0
  209. package/my-expo-app-test-case/package.json +73 -0
  210. package/my-expo-app-test-case/prettier.config.js +11 -0
  211. package/my-expo-app-test-case/tailwind.config.js +11 -0
  212. package/package.json +4 -3
@@ -0,0 +1,4 @@
1
+
2
+ > nwui@0.3.6 build /Users/sammoore/git/ronintechnologies/nativewindui/apps/cli
3
+ > tsc && chmod +x ./build/index.js
4
+
package/build/index.js CHANGED
@@ -19,14 +19,26 @@ const main = async () => {
19
19
  switch (process.argv[2]) {
20
20
  case 'add':
21
21
  const args = process.argv.slice(3);
22
+ let bigExamplesWithDependencies = false;
22
23
  let overwrite = false;
24
+ let ignoreExpoRouterMissing = false;
23
25
  let directory = undefined;
24
- while (['--overwrite', '-d'].includes(args[0])) {
26
+ while (['--big-examples-with-deps', '--overwrite', '--yes', '-d'].includes(args[0])) {
25
27
  switch (args[0]) {
28
+ case '--big-examples-with-deps':
29
+ bigExamplesWithDependencies = true;
30
+ args.shift();
31
+ break;
26
32
  case '--overwrite':
27
33
  overwrite = true;
28
34
  args.shift();
29
35
  break;
36
+ case '--yes':
37
+ overwrite = true;
38
+ ignoreExpoRouterMissing = true;
39
+ env.EXPO_NO_GIT_STATUS = true;
40
+ args.shift();
41
+ break;
30
42
  case '-d':
31
43
  args.shift();
32
44
  const exists = await fs.access(path.resolve(args[0]))
@@ -43,7 +55,7 @@ const main = async () => {
43
55
  }
44
56
  }
45
57
  // remaining args are components
46
- await installComponent(args, overwrite, directory);
58
+ await installComponent(args, overwrite, directory, bigExamplesWithDependencies, ignoreExpoRouterMissing);
47
59
  break;
48
60
  case 'init':
49
61
  const manualInstallationURL = `${env.API_BASE_URL}/installation/manual`;
@@ -64,7 +76,7 @@ const main = async () => {
64
76
  break;
65
77
  default:
66
78
  console.log('Usage:');
67
- console.log("\tadd [--overwrite] [-d directory] [componentName | 'all' | 'free' | 'paid' | 'screens' [...]]");
79
+ console.log("\tadd [--overwrite] [-d directory] [--yes] [componentName | 'all' | 'free' | 'paid' | 'screens' [...]]");
68
80
  console.log("\tinit");
69
81
  console.log("\tlogin");
70
82
  console.log("");
@@ -8,7 +8,7 @@ import { env } from './utils/env.js';
8
8
  import * as git from './utils/git.js';
9
9
  import { isLoggedIn, login } from './login.js';
10
10
  import { confirmAsync } from './utils/prompts.js';
11
- export const installComponent = async (slugs, overwrite = false, directory = `.${path.sep}`) => {
11
+ export const installComponent = async (slugs, overwrite = false, directory = `.${path.sep}`, bigExamplesWithDependencies = false, ignoreExpoRouterMissing = false) => {
12
12
  const cwd = path.resolve(directory);
13
13
  let spinner = ora({ text: 'Fetching component metadata...' });
14
14
  spinner.start();
@@ -50,13 +50,14 @@ export const installComponent = async (slugs, overwrite = false, directory = `.$
50
50
  }
51
51
  catch (err) {
52
52
  spinner.stop();
53
- console.error('error:', err);
54
53
  if (err?.code === 'ENOENT' || err?.exitCode === 1) {
55
- const confirmation = await confirmAsync({
56
- message: `The working directory provided does not appear to be an expo-router project. Continue anyway?`,
57
- });
58
- if (!confirmation) {
59
- throw 'aborted';
54
+ if (!ignoreExpoRouterMissing) {
55
+ const confirmation = await confirmAsync({
56
+ message: `The working directory provided does not appear to be an expo-router project. Continue anyway?`,
57
+ });
58
+ if (!confirmation) {
59
+ throw 'aborted';
60
+ }
60
61
  }
61
62
  spinner.stopAndPersist({ text: "Ignored expo-router." });
62
63
  }
@@ -75,16 +76,7 @@ export const installComponent = async (slugs, overwrite = false, directory = `.$
75
76
  console.error('error checking git:', err);
76
77
  return;
77
78
  }
78
- const components = await Promise.all(Array.from(componentSlugs).map(async (slug) => {
79
- try {
80
- return await fetchComponent(slug);
81
- }
82
- catch (err) {
83
- console.error('error grabbing component:', err);
84
- throw err;
85
- }
86
- }));
87
- const resolved = await getRecursiveComponentDependencies(components);
79
+ const resolved = await getRecursiveComponentDependencies(componentSlugs, bigExamplesWithDependencies);
88
80
  if (env.NODE_ENV === 'development') {
89
81
  console.log('components:', componentSlugs);
90
82
  console.log('resolution:', resolved);
@@ -118,14 +110,11 @@ export const installComponent = async (slugs, overwrite = false, directory = `.$
118
110
  const dirs = new Set(
119
111
  // remove file name
120
112
  additionalFiles.map(additionalFile => additionalFile.path.replace(/[/][^/]*$/, '')));
121
- const resolveNormalizedPath = (filePath) => {
122
- return path.join(cwd, ...filePath.replace(/^[~][/]/, '').split('/'));
123
- };
124
113
  // Create necessary directories
125
114
  // NOTE: do not Promise.all, so users get a singular error and comprehensible output
126
115
  for (const dir of dirs) {
127
116
  try {
128
- await fs.mkdir(resolveNormalizedPath(dir), { recursive: true });
117
+ await fs.mkdir(resolveNormalizedPath(cwd, dir), { recursive: true });
129
118
  }
130
119
  catch (err) {
131
120
  if (typeof err === 'object' && err && 'code' in err && err.code === 'EEXIST') {
@@ -142,7 +131,7 @@ export const installComponent = async (slugs, overwrite = false, directory = `.$
142
131
  if (additionalFile.path === '~/app/_layout.tsx') {
143
132
  continue;
144
133
  }
145
- const normalizedPath = resolveNormalizedPath(additionalFile.path);
134
+ const normalizedPath = resolveNormalizedPath(cwd, additionalFile.path);
146
135
  if (!overwrite) {
147
136
  try {
148
137
  await fs.access(normalizedPath);
@@ -163,19 +152,80 @@ export const installComponent = async (slugs, overwrite = false, directory = `.$
163
152
  }
164
153
  }
165
154
  try {
166
- await fs.writeFile(resolveNormalizedPath(additionalFile.path), additionalFile.code);
155
+ await fs.writeFile(resolveNormalizedPath(cwd, additionalFile.path), additionalFile.code);
167
156
  }
168
157
  catch (err) {
169
158
  throw err;
170
159
  }
171
160
  }
172
161
  spinner.stopAndPersist({ text: 'Component files installed.' });
173
- spinner = ora({ text: 'Installing example files...' });
162
+ await deleteDeprecatedFiles(resolved, cwd);
163
+ if (bigExamplesWithDependencies) {
164
+ await installExamples(resolved, cwd, overwrite);
165
+ }
166
+ console.log("");
167
+ };
168
+ const resolveNormalizedPath = (cwd, filePath) => {
169
+ return path.join(cwd, ...filePath.replace(/^[~][/]/, '').split('/'));
170
+ };
171
+ const deletedComponentSlugsWithReplacements = [
172
+ ['selectable-text', 'text']
173
+ ];
174
+ async function deleteDeprecatedFiles(resolved, cwd) {
175
+ let spinner = ora({ text: 'Cleaning up old files...' });
176
+ spinner.start();
177
+ // old examples directory
178
+ // to be as unintrusive as possible, we:
179
+ // - only delete example files associated with components requested for installation
180
+ // - delete example files associatd with components that no longer exists
181
+ // - do not assume & delete the entire `~/components/nativewindui/examples` folder
182
+ const oldExamplesDir = `~/components/nativewindui/examples`;
183
+ try {
184
+ await fs.access(resolveNormalizedPath(cwd, oldExamplesDir)).catch(() => {
185
+ if (env.NODE_ENV === 'development')
186
+ console.log('no examples folder found');
187
+ throw 'examples not found';
188
+ });
189
+ // old examples dir found, try to delete relevant example files
190
+ const exampleFileSlugs = Array.from(resolved.components.entries())
191
+ .map(([slug, _component]) => slug);
192
+ // only remove deprecated components' examples if their replacement was requested for install
193
+ deletedComponentSlugsWithReplacements.forEach(([deletedSlug, replacementSlug]) => {
194
+ if (exampleFileSlugs.includes(replacementSlug)) {
195
+ exampleFileSlugs.push(deletedSlug);
196
+ }
197
+ });
198
+ // remove each relevant old example file if it exists
199
+ for (const slug of exampleFileSlugs) {
200
+ const exampleFilePath = `${oldExamplesDir}/${slug}.tsx`;
201
+ const normalizedPath = resolveNormalizedPath(cwd, exampleFilePath);
202
+ try {
203
+ // force will simply not throw errors/exceptions if the file does not exist
204
+ await fs.rm(normalizedPath, { force: true });
205
+ }
206
+ catch (err) {
207
+ // do nothing on failure
208
+ if (env.NODE_ENV === 'development') {
209
+ console.error(`error cleaning up old example file ${slug}:`, err);
210
+ }
211
+ }
212
+ }
213
+ }
214
+ catch (err) {
215
+ if (err !== 'examples not found') {
216
+ console.error('error cleaning up depreated files:', err ? (err.message || err) : 'unknown');
217
+ // do not re-throw, clean up is not required
218
+ }
219
+ }
220
+ spinner.stopAndPersist({ text: 'Cleaned up old files.' });
221
+ }
222
+ async function installExamples(resolved, cwd, overwrite) {
223
+ let spinner = ora({ text: 'Installing example files...' });
174
224
  spinner.start();
175
225
  // create example usage file
176
- const examplesDir = '~/components/nativewindui/examples';
226
+ const examplesDir = '~/components/nativewindui-examples';
177
227
  try {
178
- await fs.mkdir(resolveNormalizedPath(examplesDir), { recursive: true });
228
+ await fs.mkdir(resolveNormalizedPath(cwd, examplesDir), { recursive: true });
179
229
  }
180
230
  catch (err) {
181
231
  if (typeof err === 'object' && err && 'code' in err && err.code === 'EEXIST') {
@@ -185,15 +235,17 @@ export const installComponent = async (slugs, overwrite = false, directory = `.$
185
235
  throw err;
186
236
  }
187
237
  }
188
- const exampleFiles = Array.from(resolved.components.entries())
189
- .map(([slug, component]) => ({ slug, code: component.implementationCode }));
238
+ const exampleFiles = Array.from(resolved.components.entries()).map(([slug, component]) => ({
239
+ slug,
240
+ code: component.type === "component" ? component.implementationCode : null,
241
+ }));
190
242
  // Create the example usage files
191
243
  // NOTE: do not Promise.all (see above)
192
244
  for (const exampleFile of exampleFiles) {
193
245
  if (!exampleFile.code)
194
246
  continue;
195
247
  const exampleFilePath = `${examplesDir}/${exampleFile.slug}.tsx`;
196
- const normalizedPath = resolveNormalizedPath(exampleFilePath);
248
+ const normalizedPath = resolveNormalizedPath(cwd, exampleFilePath);
197
249
  if (!overwrite) {
198
250
  try {
199
251
  await fs.access(normalizedPath);
@@ -214,16 +266,45 @@ export const installComponent = async (slugs, overwrite = false, directory = `.$
214
266
  }
215
267
  }
216
268
  try {
217
- await fs.writeFile(resolveNormalizedPath(exampleFilePath), exampleFile.code);
269
+ await fs.writeFile(resolveNormalizedPath(cwd, exampleFilePath), exampleFile.code);
218
270
  }
219
271
  catch (err) {
220
272
  throw err;
221
273
  }
222
274
  }
223
275
  spinner.stopAndPersist({ text: `Example usage files installed to ${examplesDir}` });
224
- console.log("");
225
- };
226
- async function getRecursiveComponentDependencies(components) {
276
+ }
277
+ async function getRecursiveComponentDependencies(componentSlugs,
278
+ // install components, primitives and libraries for the example usages if true.
279
+ bigExamplesWithDependencies) {
280
+ const components = await Promise.all(Array.from(componentSlugs).map(async (slug) => {
281
+ try {
282
+ return await fetchComponent(slug);
283
+ }
284
+ catch (err) {
285
+ console.error('error grabbing component:', err);
286
+ throw err;
287
+ }
288
+ }));
289
+ if (bigExamplesWithDependencies) {
290
+ const exampleComponentDependencies = new Set(components.flatMap((c) => {
291
+ if (c.type !== 'component')
292
+ return [];
293
+ return (c.exampleDependencies || [])
294
+ .filter(dep => dep.type === 'component')
295
+ .filter(dep => !componentSlugs.has(dep.name))
296
+ .map(dep => dep.url.replace('/component/', ''));
297
+ }));
298
+ components.push(...(await Promise.all(Array.from(exampleComponentDependencies).map(async (slug) => {
299
+ try {
300
+ return await fetchComponent(slug);
301
+ }
302
+ catch (err) {
303
+ console.error('error grabbing component:', err);
304
+ throw err;
305
+ }
306
+ }))));
307
+ }
227
308
  const resolved = {
228
309
  libraries: new Set(),
229
310
  primitives: new Set(),
@@ -234,7 +315,13 @@ async function getRecursiveComponentDependencies(components) {
234
315
  }
235
316
  // recursively (in case of nwui components, not libraries or primitives) adds deps to resolved
236
317
  async function applyDependenciesToResolved(component) {
237
- await Promise.all((component.dependencies || []).map(async (dependency) => {
318
+ const dependencies = component.dependencies || [];
319
+ if (bigExamplesWithDependencies && component.type === 'component') {
320
+ // do not recursively install components to prevent infinite loop
321
+ // callers of this function should add components into the components argument
322
+ dependencies.push(...((component.exampleDependencies || []).filter(dep => dep.type != 'component')));
323
+ }
324
+ await Promise.all((dependencies).map(async (dependency) => {
238
325
  switch (dependency.type) {
239
326
  case 'library':
240
327
  resolved.libraries.add(dependency.name);
package/build/login.js CHANGED
@@ -40,12 +40,20 @@ export const isLoggedIn = async () => {
40
40
  *
41
41
  * Returns whether login was successful/completed, but also may throw for some login failures.
42
42
  */
43
- export const login = async () => {
43
+ export const login = async (secondAttempt = false) => {
44
44
  let { user, session } = await checkAndRefreshSession() || { user: null, session: null };
45
45
  if (!user || !session) {
46
46
  const { data, error } = await supabase.auth.signInAnonymously();
47
47
  if (error || user === null || session === null) {
48
- console.error('error:', error);
48
+ if (!secondAttempt && error === null && user === null && session === null) {
49
+ // likely supabase/localStorage emulation layer having a weird incompatibility
50
+ // occurs when the localStorage has not yet been persisted to disk
51
+ if (process.env.NODE_ENV === 'development') {
52
+ console.error('failure to do signInAnonymously (maybe storage issue?), retrying...');
53
+ }
54
+ // after the error occurs, an empty localStorage has been persisted on disk, so retry once
55
+ return login(true);
56
+ }
49
57
  throw error;
50
58
  }
51
59
  user = data.user;
@@ -7,13 +7,16 @@ class ExpoEnv {
7
7
  get EXPO_NO_GIT_STATUS() {
8
8
  return trueish(process.env["EXPO_NO_GIT_STATUS"] || "");
9
9
  }
10
+ set EXPO_NO_GIT_STATUS(value) {
11
+ process.env["EXPO_NO_GIT_STATUS"] = value ? "1" : "0";
12
+ }
10
13
  }
11
14
  ;
12
15
  class Env extends ExpoEnv {
13
16
  get API_BASE_URL() {
14
17
  return process.env["API_BASE_URL"] || (this.NODE_ENV === "development"
15
18
  ? 'http://localhost:3000'
16
- : 'https://staging.nativewindui.com');
19
+ : 'https://nativewindui.com');
17
20
  }
18
21
  get NODE_ENV() {
19
22
  return process.env.NODE_ENV || "production";
@@ -0,0 +1,46 @@
1
+ import { ScrollViewStyleReset } from 'expo-router/html';
2
+
3
+ // This file is web-only and used to configure the root HTML for every
4
+ // web page during static rendering.
5
+ // The contents of this function only run in Node.js environments and
6
+ // do not have access to the DOM or browser APIs.
7
+ export default function Root({ children }: { children: React.ReactNode }) {
8
+ return (
9
+ <html lang="en">
10
+ <head>
11
+ <meta charSet="utf-8" />
12
+ <meta httpEquiv="X-UA-Compatible" content="IE=edge" />
13
+
14
+ {/*
15
+ This viewport disables scaling which makes the mobile website act more like a native app.
16
+ However this does reduce built-in accessibility. If you want to enable scaling, use this instead:
17
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
18
+ */}
19
+ <meta
20
+ name="viewport"
21
+ content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1.00001,viewport-fit=cover"
22
+ />
23
+ {/*
24
+ Disable body scrolling on web. This makes ScrollView components work closer to how they do on native.
25
+ However, body scrolling is often nice to have for mobile web. If you want to enable it, remove this line.
26
+ */}
27
+ <ScrollViewStyleReset />
28
+
29
+ {/* Using raw CSS styles as an escape-hatch to ensure the background color never flickers in dark-mode. */}
30
+ <style dangerouslySetInnerHTML={{ __html: responsiveBackground }} />
31
+ {/* Add any additional <head> elements that you want globally available on web... */}
32
+ </head>
33
+ <body>{children}</body>
34
+ </html>
35
+ );
36
+ }
37
+
38
+ const responsiveBackground = `
39
+ body {
40
+ background-color: #fff;
41
+ }
42
+ @media (prefers-color-scheme: dark) {
43
+ body {
44
+ background-color: #000;
45
+ }
46
+ }`;
@@ -0,0 +1,33 @@
1
+ import { Link, Stack } from 'expo-router';
2
+
3
+ import { Text } from 'react-native';
4
+
5
+ import { Container } from '~/components/Container';
6
+
7
+
8
+ export default function NotFoundScreen() {
9
+
10
+
11
+
12
+
13
+ return (
14
+
15
+ <>
16
+ <Stack.Screen options={{ title: "Oops!" }} />
17
+ <Container>
18
+ <Text className={styles.title}>This screen doesn't exist.</Text>
19
+ <Link href="/" className={styles.link}>
20
+ <Text className={styles.linkText}>Go to home screen!</Text>
21
+ </Link>
22
+ </Container>
23
+ </>
24
+
25
+ );
26
+ }
27
+
28
+
29
+ const styles = {
30
+ title: `text-xl font-bold`,
31
+ link: `mt-4 pt-4`,
32
+ linkText: `text-base text-[#2e78b7]`,
33
+ };
@@ -0,0 +1,22 @@
1
+
2
+ import '../global.css';
3
+
4
+
5
+
6
+
7
+
8
+
9
+ import { Stack } from "expo-router";
10
+
11
+
12
+
13
+ export default function Layout() {
14
+
15
+
16
+
17
+ return (
18
+
19
+ <Stack />
20
+
21
+ );
22
+ }
@@ -0,0 +1,17 @@
1
+ import { Stack, useLocalSearchParams } from 'expo-router';
2
+
3
+ import { Container } from '~/components/Container';
4
+ import { ScreenContent } from '~/components/ScreenContent';
5
+
6
+ export default function Details() {
7
+ const { name } = useLocalSearchParams();
8
+
9
+ return (
10
+ <>
11
+ <Stack.Screen options={{ title: 'Details' }} />
12
+ <Container>
13
+ <ScreenContent path="screens/details.tsx" title={`Showing details for user ${name}`} />
14
+ </Container>
15
+ </>
16
+ );
17
+ }
@@ -0,0 +1,23 @@
1
+ import { Stack, Link } from 'expo-router';
2
+
3
+ import { Button } from '~/components/Button';
4
+ import { Container } from '~/components/Container';
5
+ import { ScreenContent } from '~/components/ScreenContent';
6
+
7
+
8
+
9
+ export default function Home() {
10
+ return (
11
+ <>
12
+ <Stack.Screen options={{ title: 'Home' }} />
13
+ <Container>
14
+ <ScreenContent path="app/index.tsx" title="Home">
15
+
16
+ </ScreenContent>
17
+ <Link href={{ pathname: '/details', params: { name: 'Dan' } }} asChild>
18
+ <Button title="Show Details" />
19
+ </Link>
20
+ </Container>
21
+ </>
22
+ );
23
+ }
@@ -0,0 +1,2 @@
1
+ // @ts-ignore
2
+ /// <reference types="nativewind/types" />
@@ -0,0 +1,48 @@
1
+ {
2
+ "expo": {
3
+ "name": "my-expo-app",
4
+ "slug": "my-expo-app",
5
+ "version": "1.0.0",
6
+
7
+ "scheme": "my-expo-app",
8
+ "web": {
9
+ "bundler": "metro",
10
+ "output": "static",
11
+ "favicon": "./assets/favicon.png"
12
+ },
13
+ "plugins": [
14
+ "expo-router"
15
+
16
+
17
+ ],
18
+ "experiments": {
19
+ "typedRoutes": true
20
+
21
+ ,"tsconfigPaths": true
22
+
23
+ },
24
+
25
+ "orientation": "portrait",
26
+ "icon": "./assets/icon.png",
27
+
28
+ "userInterfaceStyle": "light",
29
+
30
+ "splash": {
31
+ "image": "./assets/splash.png",
32
+ "resizeMode": "contain",
33
+ "backgroundColor": "#ffffff"
34
+ },
35
+ "assetBundlePatterns": [
36
+ "**/*"
37
+ ],
38
+ "ios": {
39
+ "supportsTablet": true
40
+ },
41
+ "android": {
42
+ "adaptiveIcon": {
43
+ "foregroundImage": "./assets/adaptive-icon.png",
44
+ "backgroundColor": "#ffffff"
45
+ }
46
+ }
47
+ }
48
+ }
Binary file
Binary file
Binary file
@@ -0,0 +1,18 @@
1
+ module.exports = function(api) {
2
+ api.cache(true);
3
+ let plugins = [];
4
+
5
+
6
+
7
+
8
+
9
+ return {
10
+
11
+ presets: [
12
+ ['babel-preset-expo', { jsxImportSource: 'nativewind' }],
13
+ 'nativewind/babel',
14
+ ],
15
+
16
+ plugins,
17
+ };
18
+ };
@@ -0,0 +1,35 @@
1
+ {
2
+ "cesVersion": "2.11.16",
3
+ "projectName": "my-expo-app",
4
+ "packages": [
5
+ {
6
+ "name": "expo-router",
7
+ "type": "navigation",
8
+ "options": {
9
+ "type": "stack"
10
+ }
11
+ },
12
+ {
13
+ "name": "nativewind",
14
+ "type": "styling"
15
+ }
16
+ ],
17
+ "flags": {
18
+ "noGit": false,
19
+ "noInstall": true,
20
+ "overwrite": false,
21
+ "importAlias": true,
22
+ "packageManager": "npm",
23
+ "eas": false
24
+ },
25
+ "packageManager": {
26
+ "type": "npm",
27
+ "version": "10.5.0"
28
+ },
29
+ "os": {
30
+ "type": "Darwin",
31
+ "platform": "darwin",
32
+ "arch": "arm64",
33
+ "kernelVersion": "23.3.0"
34
+ }
35
+ }
@@ -0,0 +1,19 @@
1
+ import { forwardRef } from 'react';
2
+ import { Text, TouchableOpacity, TouchableOpacityProps } from 'react-native';
3
+
4
+ type ButtonProps = {
5
+ title: string;
6
+ } & TouchableOpacityProps;
7
+
8
+ export const Button = forwardRef<TouchableOpacity, ButtonProps>(({ title, ...touchableProps }, ref) => {
9
+ return (
10
+ <TouchableOpacity ref={ref} {...touchableProps} className={`${styles.button} ${touchableProps.className}`}>
11
+ <Text className={styles.buttonText}>{title}</Text>
12
+ </TouchableOpacity>
13
+ );
14
+ });
15
+
16
+ const styles = {
17
+ button: 'items-center bg-indigo-500 rounded-[28px] shadow-md p-4',
18
+ buttonText: 'text-white text-lg font-semibold text-center',
19
+ };
@@ -0,0 +1,9 @@
1
+ import { SafeAreaView } from 'react-native';
2
+
3
+ export const Container = ({ children }: { children: React.ReactNode }) => {
4
+ return <SafeAreaView className={styles.container}>{children}</SafeAreaView>;
5
+ };
6
+
7
+ const styles = {
8
+ container: "flex flex-1 p-6"
9
+ };
@@ -0,0 +1,34 @@
1
+ import { Text, View } from 'react-native';
2
+
3
+
4
+
5
+
6
+ export const EditScreenInfo = ({ path }: { path: string }) => {
7
+
8
+ const title = "Open up the code for this screen:"
9
+ const description = "Change any of the text, save the file, and your app will automatically update."
10
+
11
+ return (
12
+ <View>
13
+ <View className={styles.getStartedContainer}>
14
+ <Text className={styles.getStartedText}>{title}</Text>
15
+ <View className={styles.codeHighlightContainer + styles.homeScreenFilename}>
16
+ <Text>{path}</Text>
17
+ </View>
18
+ <Text className={styles.getStartedText}>
19
+ {description}
20
+ </Text>
21
+ </View>
22
+ </View>
23
+ );
24
+ };
25
+
26
+ const styles = {
27
+ codeHighlightContainer: `rounded-md px-1`,
28
+ getStartedContainer: `items-center mx-12`,
29
+ getStartedText: `text-lg leading-6 text-center`,
30
+ helpContainer: `items-center mx-5 mt-4`,
31
+ helpLink: `py-4`,
32
+ helpLinkText: `text-center`,
33
+ homeScreenFilename: `my-2`,
34
+ };