UNPKG

gluestack-ui

Version:

A CLI tool for easily adding components from gluestack to your projects.

147 lines (146 loc) 6.48 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; (function (factory) { if (typeof module === "object" && typeof module.exports === "object") { var v = factory(require, exports); if (v !== undefined) module.exports = v; } else if (typeof define === "function" && define.amd) { define(["require", "exports", "./config", "fs-extra", "path", "os"], factory); } })(function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getComponentDependencies = void 0; exports.getProjectBasedDependencies = getProjectBasedDependencies; const config_1 = require("./config"); const fs_extra_1 = __importDefault(require("fs-extra")); const path_1 = require("path"); const os_1 = __importDefault(require("os")); const _homeDir = os_1.default.homedir(); const projectBasedDependencies = { 'nextjs': { dependencies: { 'react-native-web': '^0.19.12', 'nativewind': '^4.1.23', 'tailwindcss': '^3.4.17', 'react-aria': '^3.33.0', '@expo/html-elements': '^0.10.1', 'tailwind-variants': '^0.1.20', '@legendapp/motion': '^2.3.0', 'react-native-svg': '^15.13.0', 'dom-helpers': '^5.2.1', 'react-stately': '^3.39.0', '@gluestack-ui/core': '^3.0.10', '@gluestack-ui/utils': '^3.0.7', '@gluestack/ui-next-adapter': '^3.0.3', "react-native-safe-area-context": "^5.6.1", 'react-native-reanimated': '~4.1.0', 'react-native-worklets': '^0.5.1', }, devDependencies: { '@types/react-native': '0.72.8', 'autoprefixer': '^10.4.21', 'postcss': '^8.5.4', '@react-native/assets-registry': '^0.79.3', }, }, 'expo': { dependencies: { 'nativewind': '^4.1.23', 'tailwindcss': '^3.4.17', "react-native-safe-area-context": "^5.6.1", 'react-native-reanimated': '~4.1.0', 'react-native-worklets': '^0.5.1', 'react-aria': '^3.33.0', '@expo/html-elements': '^0.10.1', 'tailwind-variants': '^0.1.20', '@legendapp/motion': '^2.3.0', 'react-native-svg': '^15.13.0', 'react-stately': '^3.39.0', '@gluestack-ui/core': '^3.0.10', '@gluestack-ui/utils': '^3.0.7', }, }, 'react-native-cli': { dependencies: { 'nativewind': '^4.1.23', 'tailwindcss': '^3.4.17', "react-native-safe-area-context": "^5.6.1", 'react-aria': '^3.33.0', '@expo/html-elements': '^0.10.1', 'tailwind-variants': '^0.1.20', '@legendapp/motion': '^2.3.0', 'react-native-svg': '^15.13.0', 'react-stately': '^3.39.0', 'react-native-reanimated': '~4.1.0', 'react-native-worklets': '^0.5.1', '@gluestack-ui/core': '^3.0.10', '@gluestack-ui/utils': '^3.0.7', }, devDependencies: { 'babel-plugin-module-resolver': '^5.0.0', }, }, }; // Get project based dependencies function getProjectBasedDependencies(projectType, style) { return __awaiter(this, void 0, void 0, function* () { var _a; try { if (style === config_1.config.nativeWindRootPath && projectType && projectType !== 'library') { return { dependencies: projectBasedDependencies[projectType].dependencies, devDependencies: ((_a = projectBasedDependencies[projectType]) === null || _a === void 0 ? void 0 : _a.devDependencies) || {}, }; } return { dependencies: {}, devDependencies: {} }; } catch (error) { throw new Error(error.message); } }); } // Get dependencies for a component by reading its dependencies.json file const getComponentDependencies = (componentName) => __awaiter(void 0, void 0, void 0, function* () { try { const dependenciesPath = (0, path_1.join)(_homeDir, config_1.config.gluestackDir, config_1.config.componentsResourcePath, componentName, 'dependencies.json'); if (fs_extra_1.default.existsSync(dependenciesPath)) { const dependenciesContent = yield fs_extra_1.default.readJSON(dependenciesPath); return { dependencies: dependenciesContent.dependencies || {}, devDependencies: dependenciesContent.devDependencies || {}, additionalComponents: dependenciesContent.components || [], hooks: dependenciesContent.hooks || [], }; } return { dependencies: {}, devDependencies: {}, additionalComponents: [], hooks: [], }; } catch (error) { return { dependencies: {}, devDependencies: {}, additionalComponents: [], hooks: [], }; } }); exports.getComponentDependencies = getComponentDependencies; });