@react-native-reusables/cli 0.2.11 → 0.2.12
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/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import e from"chalk";var
|
|
2
|
+
import{existsSync as F,promises as w}from"fs";import k from"path";async function y(t,e){if(!F(t))throw new Error(`Source folder does not exist: ${t}`);F(e)||await w.mkdir(e,{recursive:!0});let o=await w.readdir(t,{withFileTypes:!0});for(let i of o){let n=k.join(t,i.name),r=k.join(e,i.name);i.isDirectory()?await y(n,r):i.isFile()&&await w.copyFile(n,r)}}import{createMatchPath as z}from"tsconfig-paths";async function h(t,e){return z(e.absoluteBaseUrl,e.paths)(t,void 0,()=>!0,[".ts",".tsx"])}import{cosmiconfig as A}from"cosmiconfig";import{loadConfig as R}from"tsconfig-paths";import{z as p}from"zod";var x="~/components",j="~/lib",U=A("components",{searchPlaces:["components.json"]}),u=p.object({aliases:p.object({components:p.string(),lib:p.string()})}),W=u.extend({resolvedPaths:p.object({lib:p.string(),components:p.string()})});async function I(t){let e=await B(t);return e?await b(t,e):null}async function b(t,e){let o=await R(t);if(o.resultType==="failed")throw new Error(`Failed to load tsconfig.json. ${o.message??""}`.trim());return W.parse({...e,resolvedPaths:{lib:await h(e.aliases.lib,o),components:await h(e.aliases.components,o)}})}async function B(t){try{let e=await U.search(t);return e?u.parse(e.config):null}catch{throw new Error(`Invalid configuration found in ${t}/components.json.`)}}import d from"chalk";var s={error(...t){console.log(d.red(...t))},warn(...t){console.log(d.yellow(...t))},info(...t){console.log(d.cyan(...t))},success(...t){console.log(d.green(...t))},break(){console.log("")}};function m(t){typeof t=="string"&&(s.error(t),process.exit(1)),t instanceof Error&&(s.error(t.message),process.exit(1)),s.error("Something went wrong. Please try again."),process.exit(1)}import M from"chalk";import{promises as G}from"fs";import J from"ora";import V from"path";import E from"prompts";async function T(t){let e=r=>M.cyan(r),o=await E([{type:"text",name:"components",message:`Configure the import alias for ${e("components")}:`,initial:x},{type:"text",name:"lib",message:`Configure the import alias for ${e("lib")}:`,initial:j}]),i=u.parse({aliases:{lib:o.lib||x,components:o.components||j}}),{proceed:n}=await E({type:"confirm",name:"proceed",message:`Write configuration to ${e("components.json")}. Proceed?`,initial:!0});if(n){s.info("");let r=J("Writing components.json...").start(),l=V.resolve(t,"components.json");await G.writeFile(l,JSON.stringify(i,null,2),"utf8"),r.succeed()}return await b(t,i)}import v from"chalk";import{execSync as N}from"child_process";import{Command as q}from"commander";import{execa as P}from"execa";import H from"fast-glob";import{existsSync as f,promises as c}from"fs";import _ from"ora";import a from"path";import g from"prompts";import{fileURLToPath as Q}from"url";import{z as C}from"zod";var K=Q(import.meta.url),D=a.dirname(K),X=["nativewind","expo-navigation-bar","tailwindcss-animate","class-variance-authority","clsx","tailwind-merge","react-native-svg","lucide-react-native","@rn-primitives/portal"],Y=["tailwind.config.js","nativewind-env.d.ts","global.css","babel.config.js","metro.config.js","lib/utils.ts","lib/useColorScheme.tsx","lib/constants.ts","lib/android-navigation-bar.ts","lib/icons/iconWithClassName.ts"],Z=C.object({cwd:C.string(),overwrite:C.boolean()}),L=new q().name("init").description("Initialize the required configuration for your React Native project").option("-c, --cwd <cwd>","the working directory. defaults to the current directory.",process.cwd()).option("-o, --overwrite","overwrite existing files",!1).action(async t=>{try{let e=Z.parse(t),o=a.resolve(e.cwd);console.log("cwd",o),await tt(o),await et(o),await it(o,e.overwrite)}catch(e){m(e)}});async function tt(t){if(!f(t)||!f(a.join(t,"package.json"))){let{proceed:e}=await g({type:"confirm",name:"proceed",message:"No package.json found. Would you like to create a new project?",initial:!1});e||(s.info("Initialization cancelled."),process.exit(0));let{projectName:o}=await g({type:"text",name:"projectName",message:"What is the name of your project?",initial:"starter-base"}),i=_(`Initializing ${o}...`).start(),n=a.join(t,o);f(n)||await c.mkdir(n,{recursive:!0}),await y(a.join(D,"../__generated/starter-base"),n),await Promise.all([O(a.join(n,"app.json"),"starter-base",o),O(a.join(n,"package.json"),"@rnr/starter-base",o)]),i.stop();let{packageManager:r}=await g({type:"select",name:"packageManager",message:"Which package manager would you like to use?",choices:[{title:"npm",value:"npm"},{title:"yarn",value:"yarn"},{title:"pnpm",value:"pnpm"},{title:"bun",value:"bun"}]});i.start("Installing dependencies..."),await P(r,["install"],{cwd:n}),i.text="Verifying and updating any invalid package versions if needed...",await P("npx",["expo","install","--fix"],{cwd:n}),i.succeed("New project initialized successfully!"),process.exit(0)}}async function O(t,e,o){try{f(t)||(s.error(`The path ${t} does not exist.`),process.exit(1));let n=(await c.readFile(t,"utf8")).replaceAll(e,o);await c.writeFile(t,n)}catch(i){m(i)}}async function et(t){if(await ot(t)){let{proceed:e}=await g({type:"confirm",name:"proceed",message:"The Git repository is dirty (uncommitted changes). It is recommended to commit your changes before proceeding. Do you want to continue?",initial:!1});e||(s.info("Installation cancelled."),process.exit(0))}}async function ot(t){try{return N("git rev-parse --is-inside-work-tree",{cwd:t}),!!N("git status --porcelain",{cwd:t}).toString()}catch{return!1}}async function it(t,e){let o=_("Initializing project...").start();try{let i=await I(t);i||(o.stop(),i=await T(t),o.start());let n=a.join(D,"../__generated/starter-base");await nt(t,o),await rt(t,i,o),o.text="Adding config and utility files...";for(let r of Y)await at(r,n,t,o,e);await st(t,o),o.succeed("Initialization completed successfully!")}catch(i){o.fail("Initialization failed"),m(i),process.exit(1)}}async function nt(t,e){try{e.text="Installing dependencies...",await P("npx",["expo","install",...X],{cwd:t,stdio:"inherit"}),e.text="Dependencies installed successfully"}catch(o){e.fail("Failed to install dependencies"),m(o),process.exit(1)}}var $=["",".","/"];async function rt(t,e,o){try{let i=a.join(t,"tsconfig.json"),n=f(i)?JSON.parse(await c.readFile(i,"utf8")):{},r=e.aliases.components.split("/")[0],l=e.aliases.lib.split("/")[0];if($.includes(r)||$.includes(l))return;let S=n.compilerOptions?.paths??{};if(S[`${r}/*`]?.[0]==="*"&&S[`${l}/*`]?.[0]==="*"){o.succeed("Path aliases already configured");return}o.text="Updating path aliases...",n.compilerOptions={...n.compilerOptions,baseUrl:".",paths:{[`${r}/*`]:["*"],[`${l}/*`]:["*"],...n.compilerOptions?.paths}},await c.writeFile(i,JSON.stringify(n,null,2))}catch(i){o.fail("Failed to update tsconfig.json"),m(i)}}async function at(t,e,o,i,n){let r=a.join(o,t);if(i.stop(),f(r)){if(!n){s.info(`File already exists: ${v.bgCyan(t)} was skipped. To overwrite, run with the ${v.green("--overwrite")} flag.`);return}let{overwrite:l}=await g({type:"confirm",name:"overwrite",message:`File already exists: ${v.yellow(t)}. Would you like to overwrite?`,initial:!1});if(!l){s.info("Skipped");return}}i.start(`Installing ${t}...`),await c.mkdir(a.dirname(r),{recursive:!0}),await c.copyFile(a.join(e,t),r)}async function st(t,e){try{let o=await H(["app/_layout.{ts,tsx,js,jsx}","(app)/_layout.{ts,tsx,js,jsx}"],{cwd:t,ignore:["node_modules/**"]});if(!o.length){e.warn("Could not find the root _layout file");return}let i=a.join(t,o[0]),n=await c.readFile(i,"utf8");n.includes('import "../global.css"')||(e.text="Updating layout file...",await c.writeFile(i,`import "../global.css";
|
|
3
|
+
${n}`),e.succeed(`Updated ${o[0]} with global CSS import`))}catch(o){e.fail("Failed to update layout file"),m(o)}}import{Command as ct}from"commander";process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function lt(){let t=new ct().name("rnr-cli").description("add components and dependencies to your project");t.addCommand(L),t.parse()}lt();
|
|
3
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/logger.ts","../src/utils/handle-error.ts","../src/commands/init.ts","../src/index.ts"],"sourcesContent":["import chalk from \"chalk\"\n\nexport const logger = {\n error(...args: unknown[]) {\n console.log(chalk.red(...args))\n },\n warn(...args: unknown[]) {\n console.log(chalk.yellow(...args))\n },\n info(...args: unknown[]) {\n console.log(chalk.cyan(...args))\n },\n success(...args: unknown[]) {\n console.log(chalk.green(...args))\n },\n break() {\n console.log(\"\")\n },\n}\n","import { logger } from \"@/src/utils/logger\"\n\nexport function handleError(error: unknown) {\n if (typeof error === \"string\") {\n logger.error(error)\n process.exit(1)\n }\n\n if (error instanceof Error) {\n logger.error(error.message)\n process.exit(1)\n }\n\n logger.error(\"Something went wrong. Please try again.\")\n process.exit(1)\n}\n","// import { copyFolder } from '@/src/utils/copy-folder';\n// import { getConfig } from '@/src/utils/get-config';\nimport { handleError } from '@/src/utils/handle-error';\n// import { logger } from '@/src/utils/logger';\n// import { promptForConfig } from '@/src/utils/prompt-for-config';\n// import chalk from 'chalk';\n// import { execSync } from 'child_process';\nimport { Command } from 'commander';\n// import { execa } from 'execa';\n// import glob from 'fast-glob';\n// import { existsSync, promises as fs } from 'fs';\n// import ora, { Ora } from 'ora';\nimport path from 'path';\n// import prompts from 'prompts';\n// import { fileURLToPath } from 'url';\nimport { z } from 'zod';\n\n// const filePath = fileURLToPath(import.meta.url);\n// const fileDir = path.dirname(filePath);\n\n// const REQUIRED_DEPENDENCIES = [\n// 'nativewind',\n// 'expo-navigation-bar',\n// 'tailwindcss-animate',\n// 'class-variance-authority',\n// 'clsx',\n// 'tailwind-merge',\n// 'react-native-svg',\n// 'lucide-react-native',\n// '@rn-primitives/portal',\n// ] as const;\n\n// const TEMPLATE_FILES = [\n// 'tailwind.config.js',\n// 'nativewind-env.d.ts',\n// 'global.css',\n// 'babel.config.js',\n// 'metro.config.js',\n// 'lib/utils.ts',\n// 'lib/useColorScheme.tsx',\n// 'lib/constants.ts',\n// 'lib/android-navigation-bar.ts',\n// 'lib/icons/iconWithClassName.ts',\n// ] as const;\n\nconst initOptionsSchema = z.object({\n cwd: z.string(),\n overwrite: z.boolean(),\n});\n\nexport const init = new Command()\n .name('init')\n .description('Initialize the required configuration for your React Native project')\n .option(\n '-c, --cwd <cwd>',\n 'the working directory. defaults to the current directory.',\n process.cwd()\n )\n .option('-o, --overwrite', 'overwrite existing files', false)\n .action(async (opts) => {\n try {\n const options = initOptionsSchema.parse(opts);\n const cwd = path.resolve(options.cwd);\n\n console.log('cwd', cwd);\n\n // await validateProjectDirectory(cwd);\n // await checkGitStatus(cwd);\n // await initializeProject(cwd, options.overwrite);\n } catch (error) {\n handleError(error);\n }\n });\n\n// async function validateProjectDirectory(cwd: string) {\n// if (!existsSync(cwd) || !existsSync(path.join(cwd, 'package.json'))) {\n// const { proceed } = await prompts({\n// type: 'confirm',\n// name: 'proceed',\n// message: 'No package.json found. Would you like to create a new project?',\n// initial: false,\n// });\n\n// if (!proceed) {\n// logger.info('Initialization cancelled.');\n// process.exit(0);\n// }\n\n// const { projectName } = await prompts({\n// type: 'text',\n// name: 'projectName',\n// message: `What is the name of your project?`,\n// initial: 'starter-base',\n// });\n\n// const spinner = ora(`Initializing ${projectName}...`).start();\n\n// const projectPath = path.join(cwd, projectName);\n// if (!existsSync(projectPath)) {\n// await fs.mkdir(projectPath, { recursive: true });\n// }\n\n// await copyFolder(path.join(fileDir, '../__generated/starter-base'), projectPath);\n\n// await Promise.all([\n// replaceAllInJsonFile(path.join(projectPath, 'app.json'), 'starter-base', projectName),\n// replaceAllInJsonFile(\n// path.join(projectPath, 'package.json'),\n// '@rnr/starter-base',\n// projectName\n// ),\n// ]);\n\n// spinner.stop();\n// const { packageManager } = await prompts({\n// type: 'select',\n// name: 'packageManager',\n// message: 'Which package manager would you like to use?',\n// choices: [\n// { title: 'npm', value: 'npm' },\n// { title: 'yarn', value: 'yarn' },\n// { title: 'pnpm', value: 'pnpm' },\n// { title: 'bun', value: 'bun' },\n// ],\n// });\n\n// spinner.start('Installing dependencies...');\n// await execa(packageManager, ['install'], {\n// cwd: projectPath,\n// });\n// spinner.text = 'Verifying and updating any invalid package versions if needed...';\n// await execa('npx', ['expo', 'install', '--fix'], {\n// cwd: projectPath,\n// });\n\n// spinner.succeed('New project initialized successfully!');\n// process.exit(0);\n// }\n// }\n\n// async function replaceAllInJsonFile(path: string, searchValue: string, replaceValue: string) {\n// try {\n// if (!existsSync(path)) {\n// logger.error(`The path ${path} does not exist.`);\n// process.exit(1);\n// }\n\n// const jsonValue = await fs.readFile(path, 'utf8');\n// const replacedValue = jsonValue.replaceAll(searchValue, replaceValue);\n\n// await fs.writeFile(path, replacedValue);\n// } catch (error) {\n// handleError(error);\n// }\n// }\n\n// async function checkGitStatus(cwd: string) {\n// if (await shouldPromptGitWarning(cwd)) {\n// const { proceed } = await prompts({\n// type: 'confirm',\n// name: 'proceed',\n// message:\n// 'The Git repository is dirty (uncommitted changes). It is recommended to commit your changes before proceeding. Do you want to continue?',\n// initial: false,\n// });\n\n// if (!proceed) {\n// logger.info('Installation cancelled.');\n// process.exit(0);\n// }\n// }\n// }\n\n// async function shouldPromptGitWarning(cwd: string): Promise<boolean> {\n// try {\n// execSync('git rev-parse --is-inside-work-tree', { cwd });\n// const status = execSync('git status --porcelain', { cwd }).toString();\n// return !!status;\n// } catch (error) {\n// return false;\n// }\n// }\n\n// async function initializeProject(cwd: string, overwrite: boolean) {\n// const spinner = ora(`Initializing project...`).start();\n\n// try {\n// let config = await getConfig(cwd);\n\n// if (!config) {\n// spinner.stop();\n// config = await promptForConfig(cwd);\n// spinner.start();\n// }\n\n// const templatesDir = path.join(fileDir, '../__generated/starter-base');\n\n// await installDependencies(cwd, spinner);\n// await updateTsConfig(cwd, config, spinner);\n\n// spinner.text = 'Adding config and utility files...';\n// for (const file of TEMPLATE_FILES) {\n// await copyTemplateFile(file, templatesDir, cwd, spinner, overwrite);\n// }\n\n// await updateLayoutFile(cwd, spinner);\n\n// spinner.succeed('Initialization completed successfully!');\n// } catch (error) {\n// spinner.fail('Initialization failed');\n// handleError(error);\n// process.exit(1);\n// }\n// }\n\n// async function installDependencies(cwd: string, spinner: Ora) {\n// try {\n// spinner.text = 'Installing dependencies...';\n// await execa('npx', ['expo', 'install', ...REQUIRED_DEPENDENCIES], {\n// cwd,\n// stdio: 'inherit',\n// });\n// spinner.text = 'Dependencies installed successfully';\n// } catch (error) {\n// spinner.fail('Failed to install dependencies');\n// handleError(error);\n// process.exit(1);\n// }\n// }\n\n// const NON_PATH_ALIAS_BASES = ['', '.', '/'];\n\n// async function updateTsConfig(cwd: string, config: any, spinner: Ora) {\n// try {\n// const tsconfigPath = path.join(cwd, 'tsconfig.json');\n// const tsconfig = existsSync(tsconfigPath)\n// ? JSON.parse(await fs.readFile(tsconfigPath, 'utf8'))\n// : {};\n\n// const componentBase = config.aliases.components.split('/')[0];\n// const libBase = config.aliases.lib.split('/')[0];\n\n// if (NON_PATH_ALIAS_BASES.includes(componentBase) || NON_PATH_ALIAS_BASES.includes(libBase)) {\n// return;\n// }\n\n// const tsconfigPaths = tsconfig.compilerOptions?.paths ?? {};\n\n// if (\n// tsconfigPaths[`${componentBase}/*`]?.[0] === '*' &&\n// tsconfigPaths[`${libBase}/*`]?.[0] === '*'\n// ) {\n// spinner.succeed('Path aliases already configured');\n// return;\n// }\n\n// spinner.text = 'Updating path aliases...';\n\n// tsconfig.compilerOptions = {\n// ...tsconfig.compilerOptions,\n// baseUrl: '.',\n// paths: {\n// [`${componentBase}/*`]: ['*'],\n// [`${libBase}/*`]: ['*'],\n// ...tsconfig.compilerOptions?.paths,\n// },\n// };\n\n// await fs.writeFile(tsconfigPath, JSON.stringify(tsconfig, null, 2));\n// } catch (error) {\n// spinner.fail('Failed to update tsconfig.json');\n// handleError(error);\n// }\n// }\n\n// async function copyTemplateFile(\n// file: string,\n// templatesDir: string,\n// targetDir: string,\n// spinner: Ora,\n// overwriteFlag: boolean\n// ) {\n// const targetPath = path.join(targetDir, file);\n// spinner.stop();\n\n// if (existsSync(targetPath)) {\n// if (!overwriteFlag) {\n// logger.info(\n// `File already exists: ${chalk.bgCyan(\n// file\n// )} was skipped. To overwrite, run with the ${chalk.green('--overwrite')} flag.`\n// );\n// return;\n// }\n\n// const { overwrite } = await prompts({\n// type: 'confirm',\n// name: 'overwrite',\n// message: `File already exists: ${chalk.yellow(file)}. Would you like to overwrite?`,\n// initial: false,\n// });\n\n// if (!overwrite) {\n// logger.info(`Skipped`);\n// return;\n// }\n// }\n\n// spinner.start(`Installing ${file}...`);\n// await fs.mkdir(path.dirname(targetPath), { recursive: true });\n// await fs.copyFile(path.join(templatesDir, file), targetPath);\n// }\n\n// async function updateLayoutFile(cwd: string, spinner: Ora) {\n// try {\n// const layoutFiles = await glob(\n// ['app/_layout.{ts,tsx,js,jsx}', '(app)/_layout.{ts,tsx,js,jsx}'],\n// {\n// cwd,\n// ignore: ['node_modules/**'],\n// }\n// );\n\n// if (!layoutFiles.length) {\n// spinner.warn('Could not find the root _layout file');\n// return;\n// }\n\n// const layoutPath = path.join(cwd, layoutFiles[0]);\n// const content = await fs.readFile(layoutPath, 'utf8');\n\n// if (!content.includes('import \"../global.css\"')) {\n// spinner.text = 'Updating layout file...';\n// await fs.writeFile(layoutPath, `import \"../global.css\";\\n${content}`);\n// spinner.succeed(`Updated ${layoutFiles[0]} with global CSS import`);\n// }\n// } catch (error) {\n// spinner.fail('Failed to update layout file');\n// handleError(error);\n// }\n// }\n","#!/usr/bin/env node\n// import { add } from '@/src/commands/add';\nimport { init } from '@/src/commands/init';\n\nimport { Command } from 'commander';\n\nprocess.on('SIGINT', () => process.exit(0));\nprocess.on('SIGTERM', () => process.exit(0));\n\nasync function main() {\n const program = new Command()\n .name('rnr-cli')\n .description('add components and dependencies to your project');\n\n program.addCommand(init);\n // program.addCommand(add);\n\n program.parse();\n}\n\nmain();\n"],"mappings":";AAAA,OAAOA,MAAW,QAEX,IAAMC,EAAS,CACpB,SAASC,EAAiB,CACxB,QAAQ,IAAIF,EAAM,IAAI,GAAGE,CAAI,CAAC,CAChC,EACA,QAAQA,EAAiB,CACvB,QAAQ,IAAIF,EAAM,OAAO,GAAGE,CAAI,CAAC,CACnC,EACA,QAAQA,EAAiB,CACvB,QAAQ,IAAIF,EAAM,KAAK,GAAGE,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ptionsSchema","init","opts","options","cwd","error","handleError","Command","main","program","init"]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/copy-folder.ts","../src/utils/resolve-import.ts","../src/utils/get-config.ts","../src/utils/logger.ts","../src/utils/handle-error.ts","../src/utils/prompt-for-config.ts","../src/commands/init.ts","../src/index.ts"],"sourcesContent":["import { existsSync, promises as fs } from 'fs';\nimport path from 'path';\n\nexport async function copyFolder(src: string, dest: string) {\n if (!existsSync(src)) {\n throw new Error(`Source folder does not exist: ${src}`);\n }\n\n if (!existsSync(dest)) {\n await fs.mkdir(dest, { recursive: true });\n }\n\n const entries = await fs.readdir(src, { withFileTypes: true });\n\n for (const entry of entries) {\n const srcPath = path.join(src, entry.name);\n const destPath = path.join(dest, entry.name);\n\n if (entry.isDirectory()) {\n // Recursively copy subdirectories\n await copyFolder(srcPath, destPath);\n } else if (entry.isFile()) {\n // Copy files\n await fs.copyFile(srcPath, destPath);\n }\n }\n}\n","import { createMatchPath, type ConfigLoaderSuccessResult } from \"tsconfig-paths\"\n\nexport async function resolveImport(\n importPath: string,\n config: Pick<ConfigLoaderSuccessResult, \"absoluteBaseUrl\" | \"paths\">\n) {\n return createMatchPath(config.absoluteBaseUrl, config.paths)(\n importPath,\n undefined,\n () => true,\n [\".ts\", \".tsx\"]\n )\n}\n","import { resolveImport } from '@/src/utils/resolve-import';\nimport { cosmiconfig } from 'cosmiconfig';\nimport { loadConfig } from 'tsconfig-paths';\nimport { z } from 'zod';\n\nexport const DEFAULT_COMPONENTS = '~/components';\nexport const DEFAULT_LIB = '~/lib';\n\nconst explorer = cosmiconfig('components', {\n searchPlaces: ['components.json'],\n});\n\nexport const rawConfigSchema = z.object({\n aliases: z.object({\n components: z.string(),\n lib: z.string(),\n }),\n});\n\nexport type RawConfig = z.infer<typeof rawConfigSchema>;\n\nexport const configSchema = rawConfigSchema.extend({\n resolvedPaths: z.object({\n lib: z.string(),\n components: z.string(),\n }),\n});\n\nexport type Config = z.infer<typeof configSchema>;\n\nexport async function getConfig(cwd: string) {\n const config = await getRawConfig(cwd);\n\n if (!config) {\n return null;\n }\n\n return await resolveConfigPaths(cwd, config);\n}\n\nexport async function resolveConfigPaths(cwd: string, config: RawConfig) {\n // Read tsconfig.json.\n const tsConfig = await loadConfig(cwd);\n\n if (tsConfig.resultType === 'failed') {\n throw new Error(`Failed to load tsconfig.json. ${tsConfig.message ?? ''}`.trim());\n }\n\n return configSchema.parse({\n ...config,\n resolvedPaths: {\n lib: await resolveImport(config.aliases['lib'], tsConfig),\n components: await resolveImport(config.aliases['components'], tsConfig),\n },\n });\n}\n\nexport async function getRawConfig(cwd: string): Promise<RawConfig | null> {\n try {\n const configResult = await explorer.search(cwd);\n\n if (!configResult) {\n return null;\n }\n\n return rawConfigSchema.parse(configResult.config);\n } catch (error) {\n throw new Error(`Invalid configuration found in ${cwd}/components.json.`);\n }\n}\n","import chalk from \"chalk\"\n\nexport const logger = {\n error(...args: unknown[]) {\n console.log(chalk.red(...args))\n },\n warn(...args: unknown[]) {\n console.log(chalk.yellow(...args))\n },\n info(...args: unknown[]) {\n console.log(chalk.cyan(...args))\n },\n success(...args: unknown[]) {\n console.log(chalk.green(...args))\n },\n break() {\n console.log(\"\")\n },\n}\n","import { logger } from \"@/src/utils/logger\"\n\nexport function handleError(error: unknown) {\n if (typeof error === \"string\") {\n logger.error(error)\n process.exit(1)\n }\n\n if (error instanceof Error) {\n logger.error(error.message)\n process.exit(1)\n }\n\n logger.error(\"Something went wrong. Please try again.\")\n process.exit(1)\n}\n","import {\n DEFAULT_COMPONENTS,\n DEFAULT_LIB,\n rawConfigSchema,\n resolveConfigPaths,\n} from '@/src/utils/get-config';\nimport { logger } from '@/src/utils/logger';\nimport chalk from 'chalk';\nimport { promises as fs } from 'fs';\nimport ora from 'ora';\nimport path from 'path';\nimport prompts from 'prompts';\n\nexport async function promptForConfig(cwd: string) {\n const highlight = (text: string) => chalk.cyan(text);\n\n const options = await prompts([\n {\n type: 'text',\n name: 'components',\n message: `Configure the import alias for ${highlight('components')}:`,\n initial: DEFAULT_COMPONENTS,\n },\n {\n type: 'text',\n name: 'lib',\n message: `Configure the import alias for ${highlight('lib')}:`,\n initial: DEFAULT_LIB,\n },\n ]);\n\n const config = rawConfigSchema.parse({\n aliases: {\n lib: options.lib || DEFAULT_COMPONENTS,\n components: options.components || DEFAULT_LIB,\n },\n });\n\n const { proceed } = await prompts({\n type: 'confirm',\n name: 'proceed',\n message: `Write configuration to ${highlight('components.json')}. Proceed?`,\n initial: true,\n });\n\n if (proceed) {\n logger.info('');\n const spinner = ora(`Writing components.json...`).start();\n const targetPath = path.resolve(cwd, 'components.json');\n await fs.writeFile(targetPath, JSON.stringify(config, null, 2), 'utf8');\n spinner.succeed();\n }\n\n return await resolveConfigPaths(cwd, config);\n}\n","import { copyFolder } from '@/src/utils/copy-folder';\nimport { getConfig } from '@/src/utils/get-config';\nimport { handleError } from '@/src/utils/handle-error';\nimport { logger } from '@/src/utils/logger';\nimport { promptForConfig } from '@/src/utils/prompt-for-config';\nimport chalk from 'chalk';\nimport { execSync } from 'child_process';\nimport { Command } from 'commander';\nimport { execa } from 'execa';\nimport glob from 'fast-glob';\nimport { existsSync, promises as fs } from 'fs';\nimport ora, { Ora } from 'ora';\nimport path from 'path';\nimport prompts from 'prompts';\nimport { fileURLToPath } from 'url';\nimport { z } from 'zod';\n\nconst filePath = fileURLToPath(import.meta.url);\nconst fileDir = path.dirname(filePath);\n\nconst REQUIRED_DEPENDENCIES = [\n 'nativewind',\n 'expo-navigation-bar',\n 'tailwindcss-animate',\n 'class-variance-authority',\n 'clsx',\n 'tailwind-merge',\n 'react-native-svg',\n 'lucide-react-native',\n '@rn-primitives/portal',\n] as const;\n\nconst TEMPLATE_FILES = [\n 'tailwind.config.js',\n 'nativewind-env.d.ts',\n 'global.css',\n 'babel.config.js',\n 'metro.config.js',\n 'lib/utils.ts',\n 'lib/useColorScheme.tsx',\n 'lib/constants.ts',\n 'lib/android-navigation-bar.ts',\n 'lib/icons/iconWithClassName.ts',\n] as const;\n\nconst initOptionsSchema = z.object({\n cwd: z.string(),\n overwrite: z.boolean(),\n});\n\nexport const init = new Command()\n .name('init')\n .description('Initialize the required configuration for your React Native project')\n .option(\n '-c, --cwd <cwd>',\n 'the working directory. defaults to the current directory.',\n process.cwd()\n )\n .option('-o, --overwrite', 'overwrite existing files', false)\n .action(async (opts) => {\n try {\n const options = initOptionsSchema.parse(opts);\n const cwd = path.resolve(options.cwd);\n\n console.log('cwd', cwd);\n\n await validateProjectDirectory(cwd);\n await checkGitStatus(cwd);\n await initializeProject(cwd, options.overwrite);\n } catch (error) {\n handleError(error);\n }\n });\n\nasync function validateProjectDirectory(cwd: string) {\n if (!existsSync(cwd) || !existsSync(path.join(cwd, 'package.json'))) {\n const { proceed } = await prompts({\n type: 'confirm',\n name: 'proceed',\n message: 'No package.json found. Would you like to create a new project?',\n initial: false,\n });\n\n if (!proceed) {\n logger.info('Initialization cancelled.');\n process.exit(0);\n }\n\n const { projectName } = await prompts({\n type: 'text',\n name: 'projectName',\n message: `What is the name of your project?`,\n initial: 'starter-base',\n });\n\n const spinner = ora(`Initializing ${projectName}...`).start();\n\n const projectPath = path.join(cwd, projectName);\n if (!existsSync(projectPath)) {\n await fs.mkdir(projectPath, { recursive: true });\n }\n\n await copyFolder(path.join(fileDir, '../__generated/starter-base'), projectPath);\n\n await Promise.all([\n replaceAllInJsonFile(path.join(projectPath, 'app.json'), 'starter-base', projectName),\n replaceAllInJsonFile(\n path.join(projectPath, 'package.json'),\n '@rnr/starter-base',\n projectName\n ),\n ]);\n\n spinner.stop();\n const { packageManager } = await prompts({\n type: 'select',\n name: 'packageManager',\n message: 'Which package manager would you like to use?',\n choices: [\n { title: 'npm', value: 'npm' },\n { title: 'yarn', value: 'yarn' },\n { title: 'pnpm', value: 'pnpm' },\n { title: 'bun', value: 'bun' },\n ],\n });\n\n spinner.start('Installing dependencies...');\n await execa(packageManager, ['install'], {\n cwd: projectPath,\n });\n spinner.text = 'Verifying and updating any invalid package versions if needed...';\n await execa('npx', ['expo', 'install', '--fix'], {\n cwd: projectPath,\n });\n\n spinner.succeed('New project initialized successfully!');\n process.exit(0);\n }\n}\n\nasync function replaceAllInJsonFile(path: string, searchValue: string, replaceValue: string) {\n try {\n if (!existsSync(path)) {\n logger.error(`The path ${path} does not exist.`);\n process.exit(1);\n }\n\n const jsonValue = await fs.readFile(path, 'utf8');\n const replacedValue = jsonValue.replaceAll(searchValue, replaceValue);\n\n await fs.writeFile(path, replacedValue);\n } catch (error) {\n handleError(error);\n }\n}\n\nasync function checkGitStatus(cwd: string) {\n if (await shouldPromptGitWarning(cwd)) {\n const { proceed } = await prompts({\n type: 'confirm',\n name: 'proceed',\n message:\n 'The Git repository is dirty (uncommitted changes). It is recommended to commit your changes before proceeding. Do you want to continue?',\n initial: false,\n });\n\n if (!proceed) {\n logger.info('Installation cancelled.');\n process.exit(0);\n }\n }\n}\n\nasync function shouldPromptGitWarning(cwd: string): Promise<boolean> {\n try {\n execSync('git rev-parse --is-inside-work-tree', { cwd });\n const status = execSync('git status --porcelain', { cwd }).toString();\n return !!status;\n } catch (error) {\n return false;\n }\n}\n\nasync function initializeProject(cwd: string, overwrite: boolean) {\n const spinner = ora(`Initializing project...`).start();\n\n try {\n let config = await getConfig(cwd);\n\n if (!config) {\n spinner.stop();\n config = await promptForConfig(cwd);\n spinner.start();\n }\n\n const templatesDir = path.join(fileDir, '../__generated/starter-base');\n\n await installDependencies(cwd, spinner);\n await updateTsConfig(cwd, config, spinner);\n\n spinner.text = 'Adding config and utility files...';\n for (const file of TEMPLATE_FILES) {\n await copyTemplateFile(file, templatesDir, cwd, spinner, overwrite);\n }\n\n await updateLayoutFile(cwd, spinner);\n\n spinner.succeed('Initialization completed successfully!');\n } catch (error) {\n spinner.fail('Initialization failed');\n handleError(error);\n process.exit(1);\n }\n}\n\nasync function installDependencies(cwd: string, spinner: Ora) {\n try {\n spinner.text = 'Installing dependencies...';\n await execa('npx', ['expo', 'install', ...REQUIRED_DEPENDENCIES], {\n cwd,\n stdio: 'inherit',\n });\n spinner.text = 'Dependencies installed successfully';\n } catch (error) {\n spinner.fail('Failed to install dependencies');\n handleError(error);\n process.exit(1);\n }\n}\n\nconst NON_PATH_ALIAS_BASES = ['', '.', '/'];\n\nasync function updateTsConfig(cwd: string, config: any, spinner: Ora) {\n try {\n const tsconfigPath = path.join(cwd, 'tsconfig.json');\n const tsconfig = existsSync(tsconfigPath)\n ? JSON.parse(await fs.readFile(tsconfigPath, 'utf8'))\n : {};\n\n const componentBase = config.aliases.components.split('/')[0];\n const libBase = config.aliases.lib.split('/')[0];\n\n if (NON_PATH_ALIAS_BASES.includes(componentBase) || NON_PATH_ALIAS_BASES.includes(libBase)) {\n return;\n }\n\n const tsconfigPaths = tsconfig.compilerOptions?.paths ?? {};\n\n if (\n tsconfigPaths[`${componentBase}/*`]?.[0] === '*' &&\n tsconfigPaths[`${libBase}/*`]?.[0] === '*'\n ) {\n spinner.succeed('Path aliases already configured');\n return;\n }\n\n spinner.text = 'Updating path aliases...';\n\n tsconfig.compilerOptions = {\n ...tsconfig.compilerOptions,\n baseUrl: '.',\n paths: {\n [`${componentBase}/*`]: ['*'],\n [`${libBase}/*`]: ['*'],\n ...tsconfig.compilerOptions?.paths,\n },\n };\n\n await fs.writeFile(tsconfigPath, JSON.stringify(tsconfig, null, 2));\n } catch (error) {\n spinner.fail('Failed to update tsconfig.json');\n handleError(error);\n }\n}\n\nasync function copyTemplateFile(\n file: string,\n templatesDir: string,\n targetDir: string,\n spinner: Ora,\n overwriteFlag: boolean\n) {\n const targetPath = path.join(targetDir, file);\n spinner.stop();\n\n if (existsSync(targetPath)) {\n if (!overwriteFlag) {\n logger.info(\n `File already exists: ${chalk.bgCyan(\n file\n )} was skipped. To overwrite, run with the ${chalk.green('--overwrite')} flag.`\n );\n return;\n }\n\n const { overwrite } = await prompts({\n type: 'confirm',\n name: 'overwrite',\n message: `File already exists: ${chalk.yellow(file)}. Would you like to overwrite?`,\n initial: false,\n });\n\n if (!overwrite) {\n logger.info(`Skipped`);\n return;\n }\n }\n\n spinner.start(`Installing ${file}...`);\n await fs.mkdir(path.dirname(targetPath), { recursive: true });\n await fs.copyFile(path.join(templatesDir, file), targetPath);\n}\n\nasync function updateLayoutFile(cwd: string, spinner: Ora) {\n try {\n const layoutFiles = await glob(\n ['app/_layout.{ts,tsx,js,jsx}', '(app)/_layout.{ts,tsx,js,jsx}'],\n {\n cwd,\n ignore: ['node_modules/**'],\n }\n );\n\n if (!layoutFiles.length) {\n spinner.warn('Could not find the root _layout file');\n return;\n }\n\n const layoutPath = path.join(cwd, layoutFiles[0]);\n const content = await fs.readFile(layoutPath, 'utf8');\n\n if (!content.includes('import \"../global.css\"')) {\n spinner.text = 'Updating layout file...';\n await fs.writeFile(layoutPath, `import \"../global.css\";\\n${content}`);\n spinner.succeed(`Updated ${layoutFiles[0]} with global CSS import`);\n }\n } catch (error) {\n spinner.fail('Failed to update layout file');\n handleError(error);\n }\n}\n","#!/usr/bin/env node\n// import { add } from '@/src/commands/add';\nimport { init } from '@/src/commands/init';\n\nimport { Command } from 'commander';\n\nprocess.on('SIGINT', () => process.exit(0));\nprocess.on('SIGTERM', () => process.exit(0));\n\nasync function main() {\n const program = new Command()\n .name('rnr-cli')\n .description('add components and dependencies to your project');\n\n program.addCommand(init);\n // program.addCommand(add);\n\n program.parse();\n}\n\nmain();\n"],"mappings":";AAAA,OAAS,cAAAA,EAAY,YAAYC,MAAU,KAC3C,OAAOC,MAAU,OAEjB,eAAsBC,EAAWC,EAAaC,EAAc,CAC1D,GAAI,CAACL,EAAWI,CAAG,EACjB,MAAM,IAAI,MAAM,iCAAiCA,GAAK,EAGnDJ,EAAWK,CAAI,GAClB,MAAMJ,EAAG,MAAMI,EAAM,CAAE,UAAW,EAAK,CAAC,EAG1C,IAAMC,EAAU,MAAML,EAAG,QAAQG,EAAK,CAAE,cAAe,EAAK,CAAC,EAE7D,QAAWG,KAASD,EAAS,CAC3B,IAAME,EAAUN,EAAK,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AK,CAAC,EAC5D,MAAMlD,EAAG,SAASE,EAAK,KAAKkC,EAAcG,CAAI,EAAGW,CAAU,CAC7D,CAEA,eAAeT,GAAiB3B,EAAaS,EAAc,CACzD,GAAI,CACF,IAAM4B,EAAc,MAAMrD,EACxB,CAAC,8BAA+B,+BAA+B,EAC/D,CACE,IAAAgB,EACA,OAAQ,CAAC,iBAAiB,CAC5B,CACF,EAEA,GAAI,CAACqC,EAAY,OAAQ,CACvB5B,EAAQ,KAAK,sCAAsC,EACnD,OAGF,IAAM6B,EAAalD,EAAK,KAAKY,EAAKqC,EAAY,CAAC,CAAC,EAC1CE,EAAU,MAAMrD,EAAG,SAASoD,EAAY,MAAM,EAE/CC,EAAQ,SAAS,wBAAwB,IAC5C9B,EAAQ,KAAO,0BACf,MAAMvB,EAAG,UAAUoD,EAAY;AAAA,EAA4BC,GAAS,EACpE9B,EAAQ,QAAQ,WAAW4B,EAAY,CAAC,0BAA0B,EAEtE,OAASjC,EAAP,CACAK,EAAQ,KAAK,8BAA8B,EAC3CJ,EAAYD,CAAK,CACnB,CACF,CChVA,OAAS,WAAAoC,OAAe,YAExB,QAAQ,GAAG,SAAU,IAAM,QAAQ,KAAK,CAAC,CAAC,EAC1C,QAAQ,GAAG,UAAW,IAAM,QAAQ,KAAK,CAAC,CAAC,EAE3C,eAAeC,IAAO,CACpB,IAAMC,EAAU,IAAIF,GAAQ,EACzB,KAAK,SAAS,EACd,YAAY,iDAAiD,EAEhEE,EAAQ,WAAWC,CAAI,EAGvBD,EAAQ,MAAM,CAChB,CAEAD,GAAK","names":["existsSync","fs","path","copyFolder","src","dest","entries","entry","srcPath","destPath","createMatchPath","resolveImport","importPath","config","cosmiconfig","loadConfig","z","DEFAULT_COMPONENTS","DEFAULT_LIB","explorer","rawConfigSchema","configSchema","getConfig","cwd","config","getRawConfig","resolveConfigPaths","tsConfig","resolveImport","configResult","chalk","logger","args","handleError","error","logger","chalk","fs","ora","path","prompts","promptForConfig","cwd","highlight","text","options","DEFAULT_COMPONENTS","DEFAULT_LIB","config","rawConfigSchema","proceed","logger","spinner","targetPath","resolveConfigPaths","chalk","execSync","Command","execa","glob","existsSync","fs","ora","path","prompts","fileURLToPath","z","filePath","fileDir","REQUIRED_DEPENDENCIES","TEMPLATE_FILES","initOptionsSchema","init","opts","options","cwd","validateProjectDirectory","checkGitStatus","initializeProject","error","handleError","proceed","logger","projectName","spinner","projectPath","copyFolder","replaceAllInJsonFile","packageManager","searchValue","replaceValue","replacedValue","shouldPromptGitWarning","overwrite","config","getConfig","promptForConfig","templatesDir","installDependencies","updateTsConfig","file","copyTemplateFile","updateLayoutFile","NON_PATH_ALIAS_BASES","tsconfigPath","tsconfig","componentBase","libBase","tsconfigPaths","targetDir","overwriteFlag","targetPath","layoutFiles","layoutPath","content","Command","main","program","init"]}
|