@tamagui/cli 1.0.1-rc.1.4

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 (68) hide show
  1. package/dist/cjs/build.js +81 -0
  2. package/dist/cjs/build.js.map +7 -0
  3. package/dist/cjs/cli.js +94 -0
  4. package/dist/cjs/cli.js.map +7 -0
  5. package/dist/cjs/create.js +2 -0
  6. package/dist/cjs/create.js.map +7 -0
  7. package/dist/cjs/dev.js +75 -0
  8. package/dist/cjs/dev.js.map +7 -0
  9. package/dist/cjs/generate.js +77 -0
  10. package/dist/cjs/generate.js.map +7 -0
  11. package/dist/cjs/index.js +4 -0
  12. package/dist/cjs/index.js.map +7 -0
  13. package/dist/cjs/studio.js +85 -0
  14. package/dist/cjs/studio.js.map +7 -0
  15. package/dist/cjs/tamaguiConfigUtils.js +95 -0
  16. package/dist/cjs/tamaguiConfigUtils.js.map +7 -0
  17. package/dist/cjs/test.js +39 -0
  18. package/dist/cjs/test.js.map +7 -0
  19. package/dist/cjs/types.js +17 -0
  20. package/dist/cjs/types.js.map +7 -0
  21. package/dist/cjs/utils.js +110 -0
  22. package/dist/cjs/utils.js.map +7 -0
  23. package/dist/esm/build.js +50 -0
  24. package/dist/esm/build.js.map +7 -0
  25. package/dist/esm/cli.js +75 -0
  26. package/dist/esm/cli.js.map +7 -0
  27. package/dist/esm/create.js +1 -0
  28. package/dist/esm/create.js.map +7 -0
  29. package/dist/esm/dev.js +45 -0
  30. package/dist/esm/dev.js.map +7 -0
  31. package/dist/esm/generate.js +46 -0
  32. package/dist/esm/generate.js.map +7 -0
  33. package/dist/esm/index.js +3 -0
  34. package/dist/esm/index.js.map +7 -0
  35. package/dist/esm/studio.js +54 -0
  36. package/dist/esm/studio.js.map +7 -0
  37. package/dist/esm/tamaguiConfigUtils.js +64 -0
  38. package/dist/esm/tamaguiConfigUtils.js.map +7 -0
  39. package/dist/esm/test.js +9 -0
  40. package/dist/esm/test.js.map +7 -0
  41. package/dist/esm/types.js +1 -0
  42. package/dist/esm/types.js.map +7 -0
  43. package/dist/esm/utils.js +77 -0
  44. package/dist/esm/utils.js.map +7 -0
  45. package/package.json +62 -0
  46. package/src/build.ts +63 -0
  47. package/src/cli.ts +153 -0
  48. package/src/create.ts +0 -0
  49. package/src/dev.ts +60 -0
  50. package/src/generate.ts +69 -0
  51. package/src/index.ts +3 -0
  52. package/src/studio.ts +69 -0
  53. package/src/tamaguiConfigUtils.ts +85 -0
  54. package/src/test.ts +12 -0
  55. package/src/types.ts +30 -0
  56. package/src/utils.ts +80 -0
  57. package/types/build.d.ts +3 -0
  58. package/types/cli.d.ts +2 -0
  59. package/types/create.d.ts +1 -0
  60. package/types/dev.d.ts +3 -0
  61. package/types/generate.d.ts +7 -0
  62. package/types/index.d.ts +3 -0
  63. package/types/studio.d.ts +3 -0
  64. package/types/tamagui-config.d.ts +5 -0
  65. package/types/tamaguiConfigUtils.d.ts +5 -0
  66. package/types/test.d.ts +3 -0
  67. package/types/types.d.ts +29 -0
  68. package/types/utils.d.ts +8 -0
package/src/test.ts ADDED
@@ -0,0 +1,12 @@
1
+ /* eslint-disable no-console */
2
+ import { ResolvedOptions } from './types.js'
3
+
4
+ export const test = async (options: ResolvedOptions) => {
5
+ const { dev } = await import('./dev.js')
6
+
7
+ // failing on startup "Tamagui error bundling components require() of ES Module"
8
+
9
+ void dev(options)
10
+
11
+ console.log('run tests')
12
+ }
package/src/types.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { TamaguiOptions } from '@tamagui/static'
2
+
3
+ export type UserOptions = {
4
+ root?: string
5
+ host?: string
6
+ tsconfigPath?: string
7
+ tamaguiOptions: Partial<TamaguiOptions>
8
+ debug?: boolean | 'verbose'
9
+ }
10
+
11
+ export type ResolvedOptions = {
12
+ root: string
13
+ host?: string
14
+ mode: 'development' | 'production'
15
+ debug?: UserOptions['debug']
16
+ tsconfigPath: string
17
+ tamaguiOptions: TamaguiOptions
18
+ pkgJson: {
19
+ name?: string
20
+ main?: string
21
+ module?: string
22
+ source?: string
23
+ exports?: Record<string, Record<string, string>>
24
+ }
25
+ paths: {
26
+ dotDir: string
27
+ conf: string
28
+ types: string
29
+ }
30
+ }
package/src/utils.ts ADDED
@@ -0,0 +1,80 @@
1
+ import { join } from 'path'
2
+
3
+ import type { TamaguiOptions, TamaguiProjectInfo } from '@tamagui/static'
4
+ import { loadTamagui as loadTamaguiStatic } from '@tamagui/static'
5
+ import chalk from 'chalk'
6
+ import fs, { pathExists, readJSON } from 'fs-extra'
7
+ import { ViteDevServer } from 'vite'
8
+
9
+ import { ResolvedOptions, UserOptions } from './types.js'
10
+
11
+ export async function getOptions({
12
+ root = process.cwd(),
13
+ tsconfigPath = 'tsconfig.json',
14
+ tamaguiOptions,
15
+ host,
16
+ debug,
17
+ }: Partial<UserOptions> = {}): Promise<ResolvedOptions> {
18
+ const tsConfigFilePath = join(root, tsconfigPath)
19
+ ensure(await fs.pathExists(tsConfigFilePath), `No tsconfig found: ${tsConfigFilePath}`)
20
+ const dotDir = join(root, '.tamagui')
21
+ const pkgJson = await readJSON(join(root, 'package.json'))
22
+
23
+ return {
24
+ mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
25
+ root,
26
+ host,
27
+ pkgJson,
28
+ debug,
29
+ tsconfigPath,
30
+ tamaguiOptions: {
31
+ components: ['tamagui'],
32
+ config: await getDefaultTamaguiConfigPath(),
33
+ ...tamaguiOptions,
34
+ },
35
+ paths: {
36
+ dotDir,
37
+ conf: join(dotDir, 'tamagui.config.json'),
38
+ types: join(dotDir, 'types.json'),
39
+ },
40
+ }
41
+ }
42
+
43
+ export function ensure(condition: boolean, message: string) {
44
+ if (!condition) {
45
+ console.error(chalk.red.bold('Error:'), chalk.yellow(`${message}`))
46
+ process.exit(1)
47
+ }
48
+ }
49
+
50
+ const defaultPaths = ['tamagui.config.ts', join('src', 'tamagui.config.ts')]
51
+ let cachedPath = ''
52
+ async function getDefaultTamaguiConfigPath() {
53
+ if (cachedPath) return cachedPath
54
+ const existing = (await Promise.all(defaultPaths.map((path) => pathExists(path)))).findIndex(
55
+ (x) => !!x
56
+ )
57
+ const found = defaultPaths[existing]
58
+ if (!found) {
59
+ throw new Error(`No found tamagui.config.ts`)
60
+ }
61
+ cachedPath = found
62
+ return found
63
+ }
64
+
65
+ let cached: TamaguiProjectInfo | null = null
66
+ export const loadTamagui = async (opts: Partial<TamaguiOptions>): Promise<TamaguiProjectInfo> => {
67
+ return (cached ??= await loadTamaguiStatic({
68
+ config: await getDefaultTamaguiConfigPath(),
69
+ components: ['tamagui'],
70
+ ...opts,
71
+ }))
72
+ }
73
+
74
+ export function closeEvent(server: ViteDevServer): Promise<void> {
75
+ return new Promise((resolve) => {
76
+ server.ws.on('close', () => {
77
+ return resolve()
78
+ })
79
+ })
80
+ }
@@ -0,0 +1,3 @@
1
+ import { ResolvedOptions } from './types.js';
2
+ export declare const build: (options: ResolvedOptions) => Promise<void>;
3
+ //# sourceMappingURL=build.d.ts.map
package/types/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=create.d.ts.map
package/types/dev.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { ResolvedOptions } from './types.js';
2
+ export declare const dev: (options: ResolvedOptions) => Promise<void>;
3
+ //# sourceMappingURL=dev.d.ts.map
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import { ResolvedOptions } from './types.js';
3
+ export declare function generateTypes(options: ResolvedOptions): Promise<void>;
4
+ export declare function getTypes(options: ResolvedOptions): Promise<{
5
+ [k: string]: (string | undefined)[][];
6
+ }>;
7
+ //# sourceMappingURL=generate.d.ts.map
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import './cli.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,3 @@
1
+ import { ResolvedOptions } from './types.js';
2
+ export declare const studio: (options: ResolvedOptions) => Promise<void>;
3
+ //# sourceMappingURL=studio.d.ts.map
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import { ResolvedOptions } from './types.js';
3
+ export declare function generateTamaguiConfig(options: ResolvedOptions): Promise<void>;
4
+ export declare function watchTamaguiConfig(options: ResolvedOptions): Promise<void>;
5
+ //# sourceMappingURL=tamagui-config.d.ts.map
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import { ResolvedOptions } from './types.js';
3
+ export declare function generateTamaguiConfig(options: ResolvedOptions): Promise<void>;
4
+ export declare function watchTamaguiConfig(options: ResolvedOptions): Promise<void>;
5
+ //# sourceMappingURL=tamaguiConfigUtils.d.ts.map
@@ -0,0 +1,3 @@
1
+ import { ResolvedOptions } from './types.js';
2
+ export declare const test: (options: ResolvedOptions) => Promise<void>;
3
+ //# sourceMappingURL=test.d.ts.map
@@ -0,0 +1,29 @@
1
+ import { TamaguiOptions } from '@tamagui/static';
2
+ export type UserOptions = {
3
+ root?: string;
4
+ host?: string;
5
+ tsconfigPath?: string;
6
+ tamaguiOptions: Partial<TamaguiOptions>;
7
+ debug?: boolean | 'verbose';
8
+ };
9
+ export type ResolvedOptions = {
10
+ root: string;
11
+ host?: string;
12
+ mode: 'development' | 'production';
13
+ debug?: UserOptions['debug'];
14
+ tsconfigPath: string;
15
+ tamaguiOptions: TamaguiOptions;
16
+ pkgJson: {
17
+ name?: string;
18
+ main?: string;
19
+ module?: string;
20
+ source?: string;
21
+ exports?: Record<string, Record<string, string>>;
22
+ };
23
+ paths: {
24
+ dotDir: string;
25
+ conf: string;
26
+ types: string;
27
+ };
28
+ };
29
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,8 @@
1
+ import type { TamaguiOptions, TamaguiProjectInfo } from '@tamagui/static';
2
+ import { ViteDevServer } from 'vite';
3
+ import { ResolvedOptions, UserOptions } from './types.js';
4
+ export declare function getOptions({ root, tsconfigPath, tamaguiOptions, host, debug, }?: Partial<UserOptions>): Promise<ResolvedOptions>;
5
+ export declare function ensure(condition: boolean, message: string): void;
6
+ export declare const loadTamagui: (opts: Partial<TamaguiOptions>) => Promise<TamaguiProjectInfo>;
7
+ export declare function closeEvent(server: ViteDevServer): Promise<void>;
8
+ //# sourceMappingURL=utils.d.ts.map