@tamagui/cli 1.1.6 → 1.1.8

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.
package/dist/cjs/dev.js CHANGED
@@ -31,8 +31,8 @@ var import_path = require("path");
31
31
  var import_vite_plugin = require("@tamagui/vite-plugin");
32
32
  var import_chalk = __toESM(require("chalk"));
33
33
  var import_express = __toESM(require("express"));
34
- var import_express_http_proxy = __toESM(require("express-http-proxy"));
35
34
  var import_fs_extra = __toESM(require("fs-extra"));
35
+ var import_kill_port = __toESM(require("kill-port"));
36
36
  var import_morgan = __toESM(require("morgan"));
37
37
  var import_vite = require("vite");
38
38
  var import_tamaguiConfigUtils = require("./tamaguiConfigUtils.js");
@@ -70,25 +70,88 @@ const dev = async (options) => {
70
70
  ]);
71
71
  const info = (_b = server.httpServer) == null ? void 0 : _b.address();
72
72
  const app = (0, import_express.default)();
73
+ const cleanup = async () => {
74
+ console.log("cleaning up");
75
+ await server.close();
76
+ };
77
+ process.on(`uncaughtException`, (e) => {
78
+ console.log("wtdf", e);
79
+ });
80
+ [`exit`, `SIGINT`, `SIGUSR1`, `SIGUSR2`, `SIGTERM`].forEach((eventType) => {
81
+ process.on(eventType, cleanup);
82
+ });
83
+ const port = 19e3;
73
84
  app.disable("x-powered-by");
74
85
  app.use(import_express.default.static(paths.dotDir, { maxAge: "2h" }));
75
86
  app.use((0, import_morgan.default)("tiny"));
87
+ app.get("/status", (req, res) => {
88
+ res.status(200).send();
89
+ });
76
90
  app.get("/conf", async (req, res) => {
77
91
  const conf = await import_fs_extra.default.readJSON(paths.conf);
78
92
  res.status(200).json(conf);
79
93
  });
80
94
  app.get("/index.bundle", async (req, res) => {
81
95
  const output = (await import_fs_extra.default.readFile(outputJsPath)).toString();
82
- res.status(200).send(output);
96
+ res.status(200);
97
+ res.header("Content-Type", "text/javascript");
98
+ res.send(output);
99
+ });
100
+ const defaultResponse = {
101
+ name: "myapp",
102
+ slug: "myapp",
103
+ scheme: "myapp",
104
+ version: "1.0.0",
105
+ jsEngine: "jsc",
106
+ orientation: "portrait",
107
+ icon: "./assets/icon.png",
108
+ userInterfaceStyle: "light",
109
+ splash: {
110
+ image: "./assets/splash.png",
111
+ resizeMode: "contain",
112
+ backgroundColor: "#ffffff",
113
+ imageUrl: "http://127.0.0.1:8081/assets/./assets/splash.png"
114
+ },
115
+ updates: { fallbackToCacheTimeout: 0 },
116
+ assetBundlePatterns: ["**/*"],
117
+ ios: { supportsTablet: true, bundleIdentifier: "com.natew.myapp" },
118
+ android: {
119
+ package: "com.tamagui.myapp",
120
+ adaptiveIcon: {
121
+ foregroundImage: "./assets/adaptive-icon.png",
122
+ backgroundColor: "#FFFFFF",
123
+ foregroundImageUrl: "http://127.0.0.1:8081/assets/./assets/adaptive-icon.png"
124
+ }
125
+ },
126
+ web: { favicon: "./assets/favicon.png" },
127
+ extra: { eas: { projectId: "061b4470-78c7-4d6a-b850-8167fb0a3434" } },
128
+ _internal: {
129
+ isDebug: false,
130
+ projectRoot: "/Users/n8/tamagui/apps/kitchen-sink",
131
+ dynamicConfigPath: null,
132
+ staticConfigPath: "/Users/n8/tamagui/apps/kitchen-sink/app.json",
133
+ packageJsonPath: "/Users/n8/tamagui/apps/kitchen-sink/package.json"
134
+ },
135
+ sdkVersion: "47.0.0",
136
+ platforms: ["ios", "android", "web"],
137
+ iconUrl: `http://127.0.0.1:${port}/assets/./assets/icon.png`,
138
+ debuggerHost: `127.0.0.1:${port}`,
139
+ logUrl: `http://127.0.0.1:${port}/logs`,
140
+ developer: { tool: "expo-cli", projectRoot: "/Users/n8/tamagui/apps/kitchen-sink" },
141
+ packagerOpts: { dev: true },
142
+ mainModuleName: "index",
143
+ __flipperHack: "React Native packager is running",
144
+ hostUri: `127.0.0.1:${port}`,
145
+ bundleUrl: `http://127.0.0.1:${port}/index.bundle?platform=ios&dev=true&hot=false`,
146
+ id: "@anonymous/myapp-473c4543-3c36-4786-9db1-c66a62ac9b78"
147
+ };
148
+ app.get("/", (req, res) => {
149
+ res.status(200).json(defaultResponse);
83
150
  });
84
- app.use("/", (0, import_express_http_proxy.default)(`${info.address}:${info.port}`));
85
- const port = 8081;
151
+ await (0, import_kill_port.default)(port);
86
152
  app.listen(port);
87
153
  console.log(`Listening on`, import_chalk.default.green(`http://localhost:${port}`));
88
154
  server.printUrls();
89
- process.on("beforeExit", () => {
90
- server.close();
91
- });
92
155
  await (0, import_utils.closeEvent)(server);
93
156
  };
94
157
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/dev.ts"],
4
- "sourcesContent": ["import { AddressInfo } from 'net'\nimport { join } from 'path'\n\nimport { nativePlugin, tamaguiPlugin } from '@tamagui/vite-plugin'\nimport chalk from 'chalk'\nimport express from 'express'\nimport proxy from 'express-http-proxy'\nimport fs from 'fs-extra'\nimport morgan from 'morgan'\nimport { build, createServer } from 'vite'\n\nimport { watchTamaguiConfig } from './tamaguiConfigUtils.js'\nimport { ResolvedOptions } from './types.js'\nimport { closeEvent } from './utils.js'\n\nexport const dev = async (options: ResolvedOptions) => {\n const { root, mode, paths } = options\n\n process.chdir(process.cwd())\n\n const plugins = [\n tamaguiPlugin({\n components: ['tamagui'],\n }),\n nativePlugin(),\n ]\n\n const buildOutput = await build({\n plugins,\n root,\n })\n const outputJsFile = 'output' in buildOutput ? buildOutput.output[0]?.fileName : null\n\n if (!outputJsFile) {\n throw new Error(`No js?`)\n }\n\n const outputJsPath = join(process.cwd(), 'dist', outputJsFile)\n\n const server = await createServer({\n root,\n server: {\n port: options.port,\n host: options.host || 'localhost',\n },\n plugins,\n })\n\n // these can be lazy loaded (eventually should put in own process)\n await Promise.all([\n server.listen(),\n //\n watchTamaguiConfig(options),\n // generateTypes(options),\n ])\n\n const info = server.httpServer?.address() as AddressInfo\n const app = express()\n\n app.disable('x-powered-by')\n app.use(express.static(paths.dotDir, { maxAge: '2h' }))\n app.use(morgan('tiny'))\n\n // studio specific - move out eventually to studioPlugin\n\n app.get('/conf', async (req, res) => {\n const conf = await fs.readJSON(paths.conf)\n res.status(200).json(conf)\n })\n\n // /index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=dish.motion:2811:36)\n app.get('/index.bundle', async (req, res) => {\n const output = (await fs.readFile(outputJsPath)).toString()\n res.status(200).send(output)\n })\n\n app.use('/', proxy(`${info.address}:${info.port}`))\n\n // react native port\n const port = 8081\n app.listen(port)\n\n // eslint-disable-next-line no-console\n console.log(`Listening on`, chalk.green(`http://localhost:${port}`))\n server.printUrls()\n\n process.on('beforeExit', () => {\n server.close()\n })\n\n await closeEvent(server)\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,kBAAqB;AAErB,yBAA4C;AAC5C,mBAAkB;AAClB,qBAAoB;AACpB,gCAAkB;AAClB,sBAAe;AACf,oBAAmB;AACnB,kBAAoC;AAEpC,gCAAmC;AAEnC,mBAA2B;AAEpB,MAAM,MAAM,OAAO,YAA6B;AAfvD;AAgBE,QAAM,EAAE,MAAM,MAAM,MAAM,IAAI;AAE9B,UAAQ,MAAM,QAAQ,IAAI,CAAC;AAE3B,QAAM,UAAU;AAAA,QACd,kCAAc;AAAA,MACZ,YAAY,CAAC,SAAS;AAAA,IACxB,CAAC;AAAA,QACD,iCAAa;AAAA,EACf;AAEA,QAAM,cAAc,UAAM,mBAAM;AAAA,IAC9B;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,eAAe,YAAY,eAAc,iBAAY,OAAO,OAAnB,mBAAuB,WAAW;AAEjF,MAAI,CAAC,cAAc;AACjB,UAAM,IAAI,MAAM,QAAQ;AAAA,EAC1B;AAEA,QAAM,mBAAe,kBAAK,QAAQ,IAAI,GAAG,QAAQ,YAAY;AAE7D,QAAM,SAAS,UAAM,0BAAa;AAAA,IAChC;AAAA,IACA,QAAQ;AAAA,MACN,MAAM,QAAQ;AAAA,MACd,MAAM,QAAQ,QAAQ;AAAA,IACxB;AAAA,IACA;AAAA,EACF,CAAC;AAGD,QAAM,QAAQ,IAAI;AAAA,IAChB,OAAO,OAAO;AAAA,QAEd,8CAAmB,OAAO;AAAA,EAE5B,CAAC;AAED,QAAM,QAAO,YAAO,eAAP,mBAAmB;AAChC,QAAM,UAAM,eAAAA,SAAQ;AAEpB,MAAI,QAAQ,cAAc;AAC1B,MAAI,IAAI,eAAAA,QAAQ,OAAO,MAAM,QAAQ,EAAE,QAAQ,KAAK,CAAC,CAAC;AACtD,MAAI,QAAI,cAAAC,SAAO,MAAM,CAAC;AAItB,MAAI,IAAI,SAAS,OAAO,KAAK,QAAQ;AACnC,UAAM,OAAO,MAAM,gBAAAC,QAAG,SAAS,MAAM,IAAI;AACzC,QAAI,OAAO,GAAG,EAAE,KAAK,IAAI;AAAA,EAC3B,CAAC;AAGD,MAAI,IAAI,iBAAiB,OAAO,KAAK,QAAQ;AAC3C,UAAM,UAAU,MAAM,gBAAAA,QAAG,SAAS,YAAY,GAAG,SAAS;AAC1D,QAAI,OAAO,GAAG,EAAE,KAAK,MAAM;AAAA,EAC7B,CAAC;AAED,MAAI,IAAI,SAAK,0BAAAC,SAAM,GAAG,KAAK,WAAW,KAAK,MAAM,CAAC;AAGlD,QAAM,OAAO;AACb,MAAI,OAAO,IAAI;AAGf,UAAQ,IAAI,gBAAgB,aAAAC,QAAM,MAAM,oBAAoB,MAAM,CAAC;AACnE,SAAO,UAAU;AAEjB,UAAQ,GAAG,cAAc,MAAM;AAC7B,WAAO,MAAM;AAAA,EACf,CAAC;AAED,YAAM,yBAAW,MAAM;AACzB;",
6
- "names": ["express", "morgan", "fs", "proxy", "chalk"]
4
+ "sourcesContent": ["import { AddressInfo } from 'net'\nimport { join } from 'path'\n\nimport { nativePlugin, tamaguiPlugin } from '@tamagui/vite-plugin'\nimport chalk from 'chalk'\nimport express from 'express'\nimport proxy from 'express-http-proxy'\nimport fs from 'fs-extra'\nimport killPort from 'kill-port'\nimport morgan from 'morgan'\nimport { build, createServer } from 'vite'\n\nimport { watchTamaguiConfig } from './tamaguiConfigUtils.js'\nimport { ResolvedOptions } from './types.js'\nimport { closeEvent } from './utils.js'\n\nexport const dev = async (options: ResolvedOptions) => {\n const { root, mode, paths } = options\n\n process.chdir(process.cwd())\n\n const plugins = [\n tamaguiPlugin({\n components: ['tamagui'],\n }),\n nativePlugin(),\n ]\n\n const buildOutput = await build({\n plugins,\n root,\n })\n const outputJsFile = 'output' in buildOutput ? buildOutput.output[0]?.fileName : null\n if (!outputJsFile) {\n throw new Error(`No js?`)\n }\n const outputJsPath = join(process.cwd(), 'dist', outputJsFile)\n\n const server = await createServer({\n root,\n server: {\n port: options.port,\n host: options.host || 'localhost',\n },\n plugins,\n })\n\n // these can be lazy loaded (eventually should put in own process)\n await Promise.all([\n server.listen(),\n //\n watchTamaguiConfig(options),\n // generateTypes(options),\n ])\n\n const info = server.httpServer?.address() as AddressInfo\n const app = express()\n\n const cleanup = async () => {\n console.log('cleaning up')\n await server.close()\n }\n\n process.on(`uncaughtException`, (e) => {\n console.log('wtdf', e)\n })\n ;[`exit`, `SIGINT`, `SIGUSR1`, `SIGUSR2`, `SIGTERM`].forEach((eventType) => {\n process.on(eventType, cleanup)\n })\n\n // react native port (it scans 19000 +5)\n const port = 19000\n\n app.disable('x-powered-by')\n app.use(express.static(paths.dotDir, { maxAge: '2h' }))\n app.use(morgan('tiny'))\n\n // studio specific - move out eventually to studioPlugin\n\n app.get('/status', (req, res) => {\n res.status(200).send()\n })\n\n app.get('/conf', async (req, res) => {\n const conf = await fs.readJSON(paths.conf)\n res.status(200).json(conf)\n })\n\n // /index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=dish.motion:2811:36)\n app.get('/index.bundle', async (req, res) => {\n const output = (await fs.readFile(outputJsPath)).toString()\n\n res.status(200)\n res.header('Content-Type', 'text/javascript')\n res.send(output)\n })\n\n const defaultResponse = {\n name: 'myapp',\n slug: 'myapp',\n scheme: 'myapp',\n version: '1.0.0',\n jsEngine: 'jsc',\n orientation: 'portrait',\n icon: './assets/icon.png',\n userInterfaceStyle: 'light',\n splash: {\n image: './assets/splash.png',\n resizeMode: 'contain',\n backgroundColor: '#ffffff',\n imageUrl: 'http://127.0.0.1:8081/assets/./assets/splash.png',\n },\n updates: { fallbackToCacheTimeout: 0 },\n assetBundlePatterns: ['**/*'],\n ios: { supportsTablet: true, bundleIdentifier: 'com.natew.myapp' },\n android: {\n package: 'com.tamagui.myapp',\n adaptiveIcon: {\n foregroundImage: './assets/adaptive-icon.png',\n backgroundColor: '#FFFFFF',\n foregroundImageUrl: 'http://127.0.0.1:8081/assets/./assets/adaptive-icon.png',\n },\n },\n web: { favicon: './assets/favicon.png' },\n extra: { eas: { projectId: '061b4470-78c7-4d6a-b850-8167fb0a3434' } },\n _internal: {\n isDebug: false,\n projectRoot: '/Users/n8/tamagui/apps/kitchen-sink',\n dynamicConfigPath: null,\n staticConfigPath: '/Users/n8/tamagui/apps/kitchen-sink/app.json',\n packageJsonPath: '/Users/n8/tamagui/apps/kitchen-sink/package.json',\n },\n sdkVersion: '47.0.0',\n platforms: ['ios', 'android', 'web'],\n iconUrl: `http://127.0.0.1:${port}/assets/./assets/icon.png`,\n debuggerHost: `127.0.0.1:${port}`,\n logUrl: `http://127.0.0.1:${port}/logs`,\n developer: { tool: 'expo-cli', projectRoot: '/Users/n8/tamagui/apps/kitchen-sink' },\n packagerOpts: { dev: true },\n mainModuleName: 'index',\n __flipperHack: 'React Native packager is running',\n hostUri: `127.0.0.1:${port}`,\n bundleUrl: `http://127.0.0.1:${port}/index.bundle?platform=ios&dev=true&hot=false`,\n id: '@anonymous/myapp-473c4543-3c36-4786-9db1-c66a62ac9b78',\n }\n\n app.get('/', (req, res) => {\n res.status(200).json(defaultResponse)\n })\n\n // app.use('/', proxy(`${info.address}:${info.port}`))\n\n await killPort(port)\n app.listen(port)\n\n // eslint-disable-next-line no-console\n console.log(`Listening on`, chalk.green(`http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c;AAAA,QACZ,iBAAiB;AAAA,QACjB,iBAAiB;AAAA,QACjB,oBAAoB;AAAA,MACtB;AAAA,IACF;AAAA,IACA,KAAK,EAAE,SAAS,uBAAuB;AAAA,IACvC,OAAO,EAAE,KAAK,EAAE,WAAW,uCAAuC,EAAE;AAAA,IACpE,WAAW;AAAA,MACT,SAAS;AAAA,MACT,aAAa;AAAA,MACb,mBAAmB;AAAA,MACnB,kBAAkB;AAAA,MAClB,iBAAiB;AAAA,IACnB;AAAA,IACA,YAAY;AAAA,IACZ,WAAW,CAAC,OAAO,WAAW,KAAK;AAAA,IACnC,SAAS,oBAAoB;AAAA,IAC7B,cAAc,aAAa;AAAA,IAC3B,QAAQ,oBAAoB;AAAA,IAC5B,WAAW,EAAE,MAAM,YAAY,aAAa,sCAAsC;AAAA,IAClF,cAAc,EAAE,KAAK,KAAK;AAAA,IAC1B,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,SAAS,aAAa;AAAA,IACtB,WAAW,oBAAoB;AAAA,IAC/B,IAAI;AAAA,EACN;AAEA,MAAI,IAAI,KAAK,CAAC,KAAK,QAAQ;AACzB,QAAI,OAAO,GAAG,EAAE,KAAK,eAAe;AAAA,EACtC,CAAC;AAID,YAAM,iBAAAC,SAAS,IAAI;AACnB,MAAI,OAAO,IAAI;AAGf,UAAQ,IAAI,gBAAgB,aAAAC,QAAM,MAAM,oBAAoB,MAAM,CAAC;AACnE,SAAO,UAAU;AAEjB,YAAM,yBAAW,MAAM;AACzB;",
6
+ "names": ["express", "morgan", "fs", "killPort", "chalk"]
7
7
  }
package/dist/esm/dev.js CHANGED
@@ -2,8 +2,8 @@ import { join } from "path";
2
2
  import { nativePlugin, tamaguiPlugin } from "@tamagui/vite-plugin";
3
3
  import chalk from "chalk";
4
4
  import express from "express";
5
- import proxy from "express-http-proxy";
6
5
  import fs from "fs-extra";
6
+ import killPort from "kill-port";
7
7
  import morgan from "morgan";
8
8
  import { build, createServer } from "vite";
9
9
  import { watchTamaguiConfig } from "./tamaguiConfigUtils.js";
@@ -41,25 +41,88 @@ const dev = async (options) => {
41
41
  ]);
42
42
  const info = (_b = server.httpServer) == null ? void 0 : _b.address();
43
43
  const app = express();
44
+ const cleanup = async () => {
45
+ console.log("cleaning up");
46
+ await server.close();
47
+ };
48
+ process.on(`uncaughtException`, (e) => {
49
+ console.log("wtdf", e);
50
+ });
51
+ [`exit`, `SIGINT`, `SIGUSR1`, `SIGUSR2`, `SIGTERM`].forEach((eventType) => {
52
+ process.on(eventType, cleanup);
53
+ });
54
+ const port = 19e3;
44
55
  app.disable("x-powered-by");
45
56
  app.use(express.static(paths.dotDir, { maxAge: "2h" }));
46
57
  app.use(morgan("tiny"));
58
+ app.get("/status", (req, res) => {
59
+ res.status(200).send();
60
+ });
47
61
  app.get("/conf", async (req, res) => {
48
62
  const conf = await fs.readJSON(paths.conf);
49
63
  res.status(200).json(conf);
50
64
  });
51
65
  app.get("/index.bundle", async (req, res) => {
52
66
  const output = (await fs.readFile(outputJsPath)).toString();
53
- res.status(200).send(output);
67
+ res.status(200);
68
+ res.header("Content-Type", "text/javascript");
69
+ res.send(output);
70
+ });
71
+ const defaultResponse = {
72
+ name: "myapp",
73
+ slug: "myapp",
74
+ scheme: "myapp",
75
+ version: "1.0.0",
76
+ jsEngine: "jsc",
77
+ orientation: "portrait",
78
+ icon: "./assets/icon.png",
79
+ userInterfaceStyle: "light",
80
+ splash: {
81
+ image: "./assets/splash.png",
82
+ resizeMode: "contain",
83
+ backgroundColor: "#ffffff",
84
+ imageUrl: "http://127.0.0.1:8081/assets/./assets/splash.png"
85
+ },
86
+ updates: { fallbackToCacheTimeout: 0 },
87
+ assetBundlePatterns: ["**/*"],
88
+ ios: { supportsTablet: true, bundleIdentifier: "com.natew.myapp" },
89
+ android: {
90
+ package: "com.tamagui.myapp",
91
+ adaptiveIcon: {
92
+ foregroundImage: "./assets/adaptive-icon.png",
93
+ backgroundColor: "#FFFFFF",
94
+ foregroundImageUrl: "http://127.0.0.1:8081/assets/./assets/adaptive-icon.png"
95
+ }
96
+ },
97
+ web: { favicon: "./assets/favicon.png" },
98
+ extra: { eas: { projectId: "061b4470-78c7-4d6a-b850-8167fb0a3434" } },
99
+ _internal: {
100
+ isDebug: false,
101
+ projectRoot: "/Users/n8/tamagui/apps/kitchen-sink",
102
+ dynamicConfigPath: null,
103
+ staticConfigPath: "/Users/n8/tamagui/apps/kitchen-sink/app.json",
104
+ packageJsonPath: "/Users/n8/tamagui/apps/kitchen-sink/package.json"
105
+ },
106
+ sdkVersion: "47.0.0",
107
+ platforms: ["ios", "android", "web"],
108
+ iconUrl: `http://127.0.0.1:${port}/assets/./assets/icon.png`,
109
+ debuggerHost: `127.0.0.1:${port}`,
110
+ logUrl: `http://127.0.0.1:${port}/logs`,
111
+ developer: { tool: "expo-cli", projectRoot: "/Users/n8/tamagui/apps/kitchen-sink" },
112
+ packagerOpts: { dev: true },
113
+ mainModuleName: "index",
114
+ __flipperHack: "React Native packager is running",
115
+ hostUri: `127.0.0.1:${port}`,
116
+ bundleUrl: `http://127.0.0.1:${port}/index.bundle?platform=ios&dev=true&hot=false`,
117
+ id: "@anonymous/myapp-473c4543-3c36-4786-9db1-c66a62ac9b78"
118
+ };
119
+ app.get("/", (req, res) => {
120
+ res.status(200).json(defaultResponse);
54
121
  });
55
- app.use("/", proxy(`${info.address}:${info.port}`));
56
- const port = 8081;
122
+ await killPort(port);
57
123
  app.listen(port);
58
124
  console.log(`Listening on`, chalk.green(`http://localhost:${port}`));
59
125
  server.printUrls();
60
- process.on("beforeExit", () => {
61
- server.close();
62
- });
63
126
  await closeEvent(server);
64
127
  };
65
128
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/dev.ts"],
4
- "sourcesContent": ["import { AddressInfo } from 'net'\nimport { join } from 'path'\n\nimport { nativePlugin, tamaguiPlugin } from '@tamagui/vite-plugin'\nimport chalk from 'chalk'\nimport express from 'express'\nimport proxy from 'express-http-proxy'\nimport fs from 'fs-extra'\nimport morgan from 'morgan'\nimport { build, createServer } from 'vite'\n\nimport { watchTamaguiConfig } from './tamaguiConfigUtils.js'\nimport { ResolvedOptions } from './types.js'\nimport { closeEvent } from './utils.js'\n\nexport const dev = async (options: ResolvedOptions) => {\n const { root, mode, paths } = options\n\n process.chdir(process.cwd())\n\n const plugins = [\n tamaguiPlugin({\n components: ['tamagui'],\n }),\n nativePlugin(),\n ]\n\n const buildOutput = await build({\n plugins,\n root,\n })\n const outputJsFile = 'output' in buildOutput ? buildOutput.output[0]?.fileName : null\n\n if (!outputJsFile) {\n throw new Error(`No js?`)\n }\n\n const outputJsPath = join(process.cwd(), 'dist', outputJsFile)\n\n const server = await createServer({\n root,\n server: {\n port: options.port,\n host: options.host || 'localhost',\n },\n plugins,\n })\n\n // these can be lazy loaded (eventually should put in own process)\n await Promise.all([\n server.listen(),\n //\n watchTamaguiConfig(options),\n // generateTypes(options),\n ])\n\n const info = server.httpServer?.address() as AddressInfo\n const app = express()\n\n app.disable('x-powered-by')\n app.use(express.static(paths.dotDir, { maxAge: '2h' }))\n app.use(morgan('tiny'))\n\n // studio specific - move out eventually to studioPlugin\n\n app.get('/conf', async (req, res) => {\n const conf = await fs.readJSON(paths.conf)\n res.status(200).json(conf)\n })\n\n // /index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=dish.motion:2811:36)\n app.get('/index.bundle', async (req, res) => {\n const output = (await fs.readFile(outputJsPath)).toString()\n res.status(200).send(output)\n })\n\n app.use('/', proxy(`${info.address}:${info.port}`))\n\n // react native port\n const port = 8081\n app.listen(port)\n\n // eslint-disable-next-line no-console\n console.log(`Listening on`, chalk.green(`http://localhost:${port}`))\n server.printUrls()\n\n process.on('beforeExit', () => {\n server.close()\n })\n\n await closeEvent(server)\n}\n"],
5
- "mappings": "AACA,SAAS,YAAY;AAErB,SAAS,cAAc,qBAAqB;AAC5C,OAAO,WAAW;AAClB,OAAO,aAAa;AACpB,OAAO,WAAW;AAClB,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O,KAAK,QAAQ;AAC3C,UAAM,UAAU,MAAM,GAAG,SAAS,YAAY,GAAG,SAAS;AAC1D,QAAI,OAAO,GAAG,EAAE,KAAK,MAAM;AAAA,EAC7B,CAAC;AAED,MAAI,IAAI,KAAK,MAAM,GAAG,KAAK,WAAW,KAAK,MAAM,CAAC;AAGlD,QAAM,OAAO;AACb,MAAI,OAAO,IAAI;AAGf,UAAQ,IAAI,gBAAgB,MAAM,MAAM,oBAAoB,MAAM,CAAC;AACnE,SAAO,UAAU;AAEjB,UAAQ,GAAG,cAAc,MAAM;AAC7B,WAAO,MAAM;AAAA,EACf,CAAC;AAED,QAAM,WAAW,MAAM;AACzB;",
4
+ "sourcesContent": ["import { AddressInfo } from 'net'\nimport { join } from 'path'\n\nimport { nativePlugin, tamaguiPlugin } from '@tamagui/vite-plugin'\nimport chalk from 'chalk'\nimport express from 'express'\nimport proxy from 'express-http-proxy'\nimport fs from 'fs-extra'\nimport killPort from 'kill-port'\nimport morgan from 'morgan'\nimport { build, createServer } from 'vite'\n\nimport { watchTamaguiConfig } from './tamaguiConfigUtils.js'\nimport { ResolvedOptions } from './types.js'\nimport { closeEvent } from './utils.js'\n\nexport const dev = async (options: ResolvedOptions) => {\n const { root, mode, paths } = options\n\n process.chdir(process.cwd())\n\n const plugins = [\n tamaguiPlugin({\n components: ['tamagui'],\n }),\n nativePlugin(),\n ]\n\n const buildOutput = await build({\n plugins,\n root,\n })\n const outputJsFile = 'output' in buildOutput ? buildOutput.output[0]?.fileName : null\n if (!outputJsFile) {\n throw new Error(`No js?`)\n }\n const outputJsPath = join(process.cwd(), 'dist', outputJsFile)\n\n const server = await createServer({\n root,\n server: {\n port: options.port,\n host: options.host || 'localhost',\n },\n plugins,\n })\n\n // these can be lazy loaded (eventually should put in own process)\n await Promise.all([\n server.listen(),\n //\n watchTamaguiConfig(options),\n // generateTypes(options),\n ])\n\n const info = server.httpServer?.address() as AddressInfo\n const app = express()\n\n const cleanup = async () => {\n console.log('cleaning up')\n await server.close()\n }\n\n process.on(`uncaughtException`, (e) => {\n console.log('wtdf', e)\n })\n ;[`exit`, `SIGINT`, `SIGUSR1`, `SIGUSR2`, `SIGTERM`].forEach((eventType) => {\n process.on(eventType, cleanup)\n })\n\n // react native port (it scans 19000 +5)\n const port = 19000\n\n app.disable('x-powered-by')\n app.use(express.static(paths.dotDir, { maxAge: '2h' }))\n app.use(morgan('tiny'))\n\n // studio specific - move out eventually to studioPlugin\n\n app.get('/status', (req, res) => {\n res.status(200).send()\n })\n\n app.get('/conf', async (req, res) => {\n const conf = await fs.readJSON(paths.conf)\n res.status(200).json(conf)\n })\n\n // /index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=dish.motion:2811:36)\n app.get('/index.bundle', async (req, res) => {\n const output = (await fs.readFile(outputJsPath)).toString()\n\n res.status(200)\n res.header('Content-Type', 'text/javascript')\n res.send(output)\n })\n\n const defaultResponse = {\n name: 'myapp',\n slug: 'myapp',\n scheme: 'myapp',\n version: '1.0.0',\n jsEngine: 'jsc',\n orientation: 'portrait',\n icon: './assets/icon.png',\n userInterfaceStyle: 'light',\n splash: {\n image: './assets/splash.png',\n resizeMode: 'contain',\n backgroundColor: '#ffffff',\n imageUrl: 'http://127.0.0.1:8081/assets/./assets/splash.png',\n },\n updates: { fallbackToCacheTimeout: 0 },\n assetBundlePatterns: ['**/*'],\n ios: { supportsTablet: true, bundleIdentifier: 'com.natew.myapp' },\n android: {\n package: 'com.tamagui.myapp',\n adaptiveIcon: {\n foregroundImage: './assets/adaptive-icon.png',\n backgroundColor: '#FFFFFF',\n foregroundImageUrl: 'http://127.0.0.1:8081/assets/./assets/adaptive-icon.png',\n },\n },\n web: { favicon: './assets/favicon.png' },\n extra: { eas: { projectId: '061b4470-78c7-4d6a-b850-8167fb0a3434' } },\n _internal: {\n isDebug: false,\n projectRoot: '/Users/n8/tamagui/apps/kitchen-sink',\n dynamicConfigPath: null,\n staticConfigPath: '/Users/n8/tamagui/apps/kitchen-sink/app.json',\n packageJsonPath: '/Users/n8/tamagui/apps/kitchen-sink/package.json',\n },\n sdkVersion: '47.0.0',\n platforms: ['ios', 'android', 'web'],\n iconUrl: `http://127.0.0.1:${port}/assets/./assets/icon.png`,\n debuggerHost: `127.0.0.1:${port}`,\n logUrl: `http://127.0.0.1:${port}/logs`,\n developer: { tool: 'expo-cli', projectRoot: '/Users/n8/tamagui/apps/kitchen-sink' },\n packagerOpts: { dev: true },\n mainModuleName: 'index',\n __flipperHack: 'React Native packager is running',\n hostUri: `127.0.0.1:${port}`,\n bundleUrl: `http://127.0.0.1:${port}/index.bundle?platform=ios&dev=true&hot=false`,\n id: '@anonymous/myapp-473c4543-3c36-4786-9db1-c66a62ac9b78',\n }\n\n app.get('/', (req, res) => {\n res.status(200).json(defaultResponse)\n })\n\n // app.use('/', proxy(`${info.address}:${info.port}`))\n\n await killPort(port)\n app.listen(port)\n\n // eslint-disable-next-line no-console\n console.log(`Listening on`, chalk.green(`http://localhost:${port}`))\n server.printUrls()\n\n await closeEvent(server)\n}\n"],
5
+ "mappings": "AACA,SAAS,YAAY;AAErB,SAAS,cAAc,qBAAqB;AAC5C,OAAO,WAAW;AAClB,OAAO,aAAa;AAEpB,OAAO,QAAQ;AACf,OAAO,cAAc;AACrB,OAAO,YAAY;AACnB,SAAS,OAAO,oBAAoB;AAEpC,SAAS,0BAA0B;AAEnC,SAAS,kBAAkB;AAEpB,MAAM,MAAM,OAAO,YAA6B;AAhBvD;AAiBE,QAAM,EAAE,MAAM,MAAM,MAAM,IAAI;AAE9B,UAAQ,MAAM,QAAQ,IAAI,CAAC;AAE3B,QAAM,UAAU;AAAA,IACd,cAAc;AAAA,MACZ,YAAY,CAAC,SAAS;AAAA,IACxB,CAAC;AAAA,IACD,aAAa;AAAA,EACf;AAEA,QAAM,cAAc,MAAM,MAAM;AAAA,IAC9B;AAAA,IACA;AAAA,EACF,CAAC;AACD,QAAM,eAAe,YAAY,eAAc,iBAAY,OAAO,OAAnB,mBAAuB,WAA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C,KAAK,QAAQ;AACzB,QAAI,OAAO,GAAG,EAAE,KAAK,eAAe;AAAA,EACtC,CAAC;AAID,QAAM,SAAS,IAAI;AACnB,MAAI,OAAO,IAAI;AAGf,UAAQ,IAAI,gBAAgB,MAAM,MAAM,oBAAoB,MAAM,CAAC;AACnE,SAAO,UAAU;AAEjB,QAAM,WAAW,MAAM;AACzB;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/cli",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "source": "src/index.ts",
5
5
  "types": "./types/index.d.ts",
6
6
  "module": "dist/esm",
@@ -32,9 +32,9 @@
32
32
  "clean:build": "tamagui-build clean:build"
33
33
  },
34
34
  "dependencies": {
35
- "@tamagui/build": "^1.1.6",
36
- "@tamagui/static": "^1.1.6",
37
- "@tamagui/vite-plugin": "^1.1.6",
35
+ "@tamagui/build": "^1.1.8",
36
+ "@tamagui/static": "^1.1.8",
37
+ "@tamagui/vite-plugin": "^1.1.8",
38
38
  "@types/compression": "^1.7.2",
39
39
  "@types/morgan": "^1.9.3",
40
40
  "arg": "^5.0.2",
@@ -49,6 +49,7 @@
49
49
  "fs-extra": "^10.1.0",
50
50
  "get-port": "^6.1.2",
51
51
  "graphology": "^0.24.1",
52
+ "kill-port": "^2.0.1",
52
53
  "lodash.debounce": "^4.0.8",
53
54
  "morgan": "^1.10.0",
54
55
  "ts-morph": "^15.1.0",
@@ -58,6 +59,6 @@
58
59
  "zx": "^7.1.1"
59
60
  },
60
61
  "devDependencies": {
61
- "@takeout/studio": "^1.1.6"
62
+ "@takeout/studio": "^1.1.8"
62
63
  }
63
64
  }
package/src/dev.ts CHANGED
@@ -6,6 +6,7 @@ import chalk from 'chalk'
6
6
  import express from 'express'
7
7
  import proxy from 'express-http-proxy'
8
8
  import fs from 'fs-extra'
9
+ import killPort from 'kill-port'
9
10
  import morgan from 'morgan'
10
11
  import { build, createServer } from 'vite'
11
12
 
@@ -30,11 +31,9 @@ export const dev = async (options: ResolvedOptions) => {
30
31
  root,
31
32
  })
32
33
  const outputJsFile = 'output' in buildOutput ? buildOutput.output[0]?.fileName : null
33
-
34
34
  if (!outputJsFile) {
35
35
  throw new Error(`No js?`)
36
36
  }
37
-
38
37
  const outputJsPath = join(process.cwd(), 'dist', outputJsFile)
39
38
 
40
39
  const server = await createServer({
@@ -57,12 +56,31 @@ export const dev = async (options: ResolvedOptions) => {
57
56
  const info = server.httpServer?.address() as AddressInfo
58
57
  const app = express()
59
58
 
59
+ const cleanup = async () => {
60
+ console.log('cleaning up')
61
+ await server.close()
62
+ }
63
+
64
+ process.on(`uncaughtException`, (e) => {
65
+ console.log('wtdf', e)
66
+ })
67
+ ;[`exit`, `SIGINT`, `SIGUSR1`, `SIGUSR2`, `SIGTERM`].forEach((eventType) => {
68
+ process.on(eventType, cleanup)
69
+ })
70
+
71
+ // react native port (it scans 19000 +5)
72
+ const port = 19000
73
+
60
74
  app.disable('x-powered-by')
61
75
  app.use(express.static(paths.dotDir, { maxAge: '2h' }))
62
76
  app.use(morgan('tiny'))
63
77
 
64
78
  // studio specific - move out eventually to studioPlugin
65
79
 
80
+ app.get('/status', (req, res) => {
81
+ res.status(200).send()
82
+ })
83
+
66
84
  app.get('/conf', async (req, res) => {
67
85
  const conf = await fs.readJSON(paths.conf)
68
86
  res.status(200).json(conf)
@@ -71,22 +89,73 @@ export const dev = async (options: ResolvedOptions) => {
71
89
  // /index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=dish.motion:2811:36)
72
90
  app.get('/index.bundle', async (req, res) => {
73
91
  const output = (await fs.readFile(outputJsPath)).toString()
74
- res.status(200).send(output)
92
+
93
+ res.status(200)
94
+ res.header('Content-Type', 'text/javascript')
95
+ res.send(output)
96
+ })
97
+
98
+ const defaultResponse = {
99
+ name: 'myapp',
100
+ slug: 'myapp',
101
+ scheme: 'myapp',
102
+ version: '1.0.0',
103
+ jsEngine: 'jsc',
104
+ orientation: 'portrait',
105
+ icon: './assets/icon.png',
106
+ userInterfaceStyle: 'light',
107
+ splash: {
108
+ image: './assets/splash.png',
109
+ resizeMode: 'contain',
110
+ backgroundColor: '#ffffff',
111
+ imageUrl: 'http://127.0.0.1:8081/assets/./assets/splash.png',
112
+ },
113
+ updates: { fallbackToCacheTimeout: 0 },
114
+ assetBundlePatterns: ['**/*'],
115
+ ios: { supportsTablet: true, bundleIdentifier: 'com.natew.myapp' },
116
+ android: {
117
+ package: 'com.tamagui.myapp',
118
+ adaptiveIcon: {
119
+ foregroundImage: './assets/adaptive-icon.png',
120
+ backgroundColor: '#FFFFFF',
121
+ foregroundImageUrl: 'http://127.0.0.1:8081/assets/./assets/adaptive-icon.png',
122
+ },
123
+ },
124
+ web: { favicon: './assets/favicon.png' },
125
+ extra: { eas: { projectId: '061b4470-78c7-4d6a-b850-8167fb0a3434' } },
126
+ _internal: {
127
+ isDebug: false,
128
+ projectRoot: '/Users/n8/tamagui/apps/kitchen-sink',
129
+ dynamicConfigPath: null,
130
+ staticConfigPath: '/Users/n8/tamagui/apps/kitchen-sink/app.json',
131
+ packageJsonPath: '/Users/n8/tamagui/apps/kitchen-sink/package.json',
132
+ },
133
+ sdkVersion: '47.0.0',
134
+ platforms: ['ios', 'android', 'web'],
135
+ iconUrl: `http://127.0.0.1:${port}/assets/./assets/icon.png`,
136
+ debuggerHost: `127.0.0.1:${port}`,
137
+ logUrl: `http://127.0.0.1:${port}/logs`,
138
+ developer: { tool: 'expo-cli', projectRoot: '/Users/n8/tamagui/apps/kitchen-sink' },
139
+ packagerOpts: { dev: true },
140
+ mainModuleName: 'index',
141
+ __flipperHack: 'React Native packager is running',
142
+ hostUri: `127.0.0.1:${port}`,
143
+ bundleUrl: `http://127.0.0.1:${port}/index.bundle?platform=ios&dev=true&hot=false`,
144
+ id: '@anonymous/myapp-473c4543-3c36-4786-9db1-c66a62ac9b78',
145
+ }
146
+
147
+ app.get('/', (req, res) => {
148
+ res.status(200).json(defaultResponse)
75
149
  })
76
150
 
77
- app.use('/', proxy(`${info.address}:${info.port}`))
151
+ // app.use('/', proxy(`${info.address}:${info.port}`))
78
152
 
79
- // react native port
80
- const port = 8081
153
+ await killPort(port)
81
154
  app.listen(port)
82
155
 
83
156
  // eslint-disable-next-line no-console
84
157
  console.log(`Listening on`, chalk.green(`http://localhost:${port}`))
85
158
  server.printUrls()
86
159
 
87
- process.on('beforeExit', () => {
88
- server.close()
89
- })
90
-
91
160
  await closeEvent(server)
92
161
  }