UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

365 lines (362 loc) 9.61 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty; var __copyProps = (to, from, except, desc) => { if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target, mod)); var import_fs = require("fs"), import_path = __toESM(require("path"), 1), import_url = require("url"), import_citty = require("citty"), import_picocolors = __toESM(require("picocolors"), 1); const import_meta = {}; function getPackageVersion() { var dirname; typeof __dirname < "u" ? dirname = __dirname : dirname = import_path.default.dirname((0, import_url.fileURLToPath)(import_meta.url)); var packagePath = import_path.default.join(dirname, "..", "..", "package.json"), packageJson = JSON.parse((0, import_fs.readFileSync)(packagePath, "utf-8")); return packageJson.version; } var version = getPackageVersion(), DOCS_BASE = "https://onestack.dev/docs", docsLinks = { dev: `${DOCS_BASE}/one-dev`, build: `${DOCS_BASE}/one-build`, serve: `${DOCS_BASE}/one-serve`, prebuild: `${DOCS_BASE}/guides-ios-native`, "run:ios": `${DOCS_BASE}/guides-ios-native`, "run:android": `${DOCS_BASE}/guides-ios-native`, clean: `${DOCS_BASE}/configuration`, patch: `${DOCS_BASE}/configuration`, "generate-routes": `${DOCS_BASE}/routing-typed-routes` }; function withDocsLink(description, command) { return `${description} Docs: ${docsLinks[command]}`; } import_path.default.sep !== "/" && console.warn(import_picocolors.default.bgYellow("WARNING: UNSUPPORTED OS") + import_picocolors.default.yellow(" - It appears you\u2019re using Windows, which is currently not supported. You may experience unexpected issues.")); var modes = { development: "development", production: "production" }, dev = (0, import_citty.defineCommand)({ meta: { name: "dev", version, description: withDocsLink("Start the dev server", "dev") }, args: { clean: { type: "boolean" }, host: { type: "string" }, port: { type: "string" }, https: { type: "boolean" }, mode: { type: "string", description: 'If set to "production" you can run the development server but serve the production bundle' }, "debug-bundle": { type: "string", description: "Will output the bundle to a temp file and then serve it from there afterwards allowing you to easily edit the bundle to debug problems." }, debug: { type: "string", description: "Pass debug args to Vite" } }, async run(param) { var { args } = param, { dev: dev2 } = await import("./cli/dev"); await dev2({ ...args, debugBundle: args["debug-bundle"], mode: modes[args.mode] }); } }), buildCommand = (0, import_citty.defineCommand)({ meta: { name: "build", version, description: withDocsLink("Build your app", "build") }, args: { step: { type: "string", required: !1 }, // limit the pages built only: { type: "string", required: !1 }, platform: { type: "string", description: "One of: web, ios, android", default: "web", required: !1 } }, async run(param) { var { args } = param, { build } = await import("./cli/build"), platforms = { ios: "ios", web: "web", android: "android" }; if (args.platform && !platforms[args.platform]) throw new Error(`Invalid platform: ${args.platform}`); var platform = platforms[args.platform] || "web"; await build({ only: args.only, platform, step: args.step }), process.exit(0); } }), serveCommand = (0, import_citty.defineCommand)({ meta: { name: "serve", version, description: withDocsLink("Serve a built app for production", "serve") }, args: { host: { type: "string" }, port: { type: "string" }, compress: { type: "boolean" }, loadEnv: { type: "boolean" } }, async run(param) { var { args } = param, { serve } = await import("./serve"); await serve({ port: args.port ? +args.port : void 0, host: args.host, compress: args.compress, loadEnv: !!args.loadEnv }); } }), prebuild = (0, import_citty.defineCommand)({ meta: { name: "prebuild", version, description: withDocsLink("Prebuild native project", "prebuild") }, args: { platform: { type: "string", description: "ios or android" }, expo: { type: "boolean", description: "expo or non-expo folders", default: !0 }, "no-install": { type: "boolean", description: "skip installing native dependencies", default: !1 } }, async run(param) { var { args } = param; args.install === !1 && (args["no-install"] = !0); var { run } = await import("./cli/prebuild"); await run(args); } }), runIos = (0, import_citty.defineCommand)({ meta: { name: "run:ios", version, description: withDocsLink("Run the iOS app", "run:ios") }, args: {}, async run(param) { var { args } = param, { run } = await import("./cli/runIos"); await run(args); } }), runAndroid = (0, import_citty.defineCommand)({ meta: { name: "run:android", version, description: withDocsLink("Run the Android app", "run:android") }, args: {}, async run(param) { var { args } = param, { run } = await import("./cli/runAndroid"); await run(args); } }), clean = (0, import_citty.defineCommand)({ meta: { name: "clean", version: "0.0.0", description: withDocsLink("Clean build folders", "clean") }, args: {}, async run() { var { clean: vxrnClean } = await import("vxrn"); await vxrnClean({ root: process.cwd() }); } }), patch = (0, import_citty.defineCommand)({ meta: { name: "patch", version: "0.0.0", description: withDocsLink("Apply package patches", "patch") }, args: {}, async run(param) { var { args } = param, { run } = await import("./cli/patch"); await run(args); } }), generateRoutes = (0, import_citty.defineCommand)({ meta: { name: "generate-routes", version, description: withDocsLink("Generate route type definitions", "generate-routes") }, args: { appDir: { type: "string", description: 'Path to app directory (default: "app")' }, typed: { type: "string", description: 'Auto-generate route helpers. Options: "type" (type-only helpers) or "runtime" (runtime helpers)' } }, async run(param) { var { args } = param, { run } = await import("./cli/generateRoutes"); await run(args); } }), subCommands = { dev, clean, build: buildCommand, prebuild, "run:ios": runIos, "run:android": runAndroid, patch, serve: serveCommand, "generate-routes": generateRoutes }, subMain = (0, import_citty.defineCommand)({ meta: { name: "main", version, description: "Welcome to One" }, subCommands }), main = (0, import_citty.defineCommand)({ meta: { name: "main", version, description: "Welcome to One" }, args: { name: { type: "positional", description: "Folder name to place the app into", required: !1 } }, async run(param) { var { args } = param; if (subCommands[args.name]) { (0, import_citty.runMain)(subMain); return; } var { cliMain } = await import("./cli/main"); await cliMain(args); } }), helpIndex = process.argv.indexOf("--help"); if (helpIndex > 0) { var subCommandName = process.argv[helpIndex - 1], subCommand = subCommands[subCommandName]; subCommand && (0, import_citty.showUsage)(subCommand); } else (0, import_citty.runMain)(main); //# sourceMappingURL=cli.native.js.map