@react-native-reusables/cli 0.6.1 → 0.6.2

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 (2) hide show
  1. package/bin.cjs +131 -62
  2. package/package.json +1 -1
package/bin.cjs CHANGED
@@ -55406,9 +55406,8 @@ var path4 = Options_exports.text("path").pipe(Options_exports.withDefault(""), O
55406
55406
  var template = Options_exports.text("template").pipe(Options_exports.withAlias("t"), Options_exports.withDefault(""));
55407
55407
 
55408
55408
  // src/project-manifest.ts
55409
- var DEPENDENCIES = [
55409
+ var CORE_DEPENDENCIES = [
55410
55410
  "expo",
55411
- "nativewind",
55412
55411
  "react-native-reanimated",
55413
55412
  "react-native-safe-area-context",
55414
55413
  "tailwindcss-animate",
@@ -55416,6 +55415,10 @@ var DEPENDENCIES = [
55416
55415
  "clsx",
55417
55416
  "tailwind-merge"
55418
55417
  ];
55418
+ var DEPENDENCIES = {
55419
+ nativewind: [...CORE_DEPENDENCIES, "nativewind"],
55420
+ uniwind: [...CORE_DEPENDENCIES, "uniwind"]
55421
+ };
55419
55422
  var DEV_DEPENDENCIES = ["tailwindcss@^3.4.14"];
55420
55423
  var FILE_CHECKS = [
55421
55424
  {
@@ -55428,7 +55431,8 @@ var FILE_CHECKS = [
55428
55431
  message: "jsxImportSource or nativewind/babel is missing",
55429
55432
  docs: "https://www.nativewind.dev/docs/getting-started/installation#3-add-the-babel-preset"
55430
55433
  }
55431
- ]
55434
+ ],
55435
+ stylingLibraries: ["nativewind"]
55432
55436
  },
55433
55437
  {
55434
55438
  name: "Metro Config",
@@ -55445,7 +55449,21 @@ var FILE_CHECKS = [
55445
55449
  message: "The 'inlineRem: 16' is missing",
55446
55450
  docs: "https://reactnativereusables.com/docs/installation/manual#update-the-default-inlined-rem-value"
55447
55451
  }
55448
- ]
55452
+ ],
55453
+ stylingLibraries: ["nativewind"]
55454
+ },
55455
+ {
55456
+ name: "Metro Config",
55457
+ fileNames: ["metro.config.js", "metro.config.ts"],
55458
+ docs: "https://www.nativewind.dev/docs/getting-started/installation#4-create-or-modify-your-metroconfigjs",
55459
+ includes: [
55460
+ {
55461
+ content: ["withUniwindConfig("],
55462
+ message: "The withUniwindConfig function is missing",
55463
+ docs: "https://docs.uniwind.dev/api/metro-config#metro-config-js"
55464
+ }
55465
+ ],
55466
+ stylingLibraries: ["uniwind"]
55449
55467
  },
55450
55468
  {
55451
55469
  name: "Root Layout",
@@ -55463,7 +55481,8 @@ var FILE_CHECKS = [
55463
55481
  message: "The PortalHost component is missing",
55464
55482
  docs: "https://reactnativereusables.com/docs/installation/manual#add-the-portal-host-to-your-root-layout"
55465
55483
  }
55466
- ]
55484
+ ],
55485
+ stylingLibraries: ["nativewind", "uniwind"]
55467
55486
  }
55468
55487
  ];
55469
55488
  var DEPRECATED_FROM_LIB = [
@@ -55557,7 +55576,8 @@ var CUSTOM_FILE_CHECKS = {
55557
55576
  message: "At least one of the color css variables is missing",
55558
55577
  docs: "https://reactnativereusables.com/docs/installation/manual#configure-your-styles"
55559
55578
  }
55560
- ]
55579
+ ],
55580
+ stylingLibraries: ["nativewind"]
55561
55581
  },
55562
55582
  theme: {
55563
55583
  name: "Theme",
@@ -55574,7 +55594,8 @@ var CUSTOM_FILE_CHECKS = {
55574
55594
  message: "The NAV_THEME is missing",
55575
55595
  docs: "https://reactnativereusables.com/docs/installation/manual#configure-your-styles"
55576
55596
  }
55577
- ]
55597
+ ],
55598
+ stylingLibraries: ["nativewind", "uniwind"]
55578
55599
  },
55579
55600
  nativewindEnv: {
55580
55601
  name: "Nativewind Env",
@@ -55585,7 +55606,8 @@ var CUSTOM_FILE_CHECKS = {
55585
55606
  message: "The nativewind types are missing",
55586
55607
  docs: "https://www.nativewind.dev/docs/getting-started/installation#7-typescript-setup-optional"
55587
55608
  }
55588
- ]
55609
+ ],
55610
+ stylingLibraries: ["nativewind"]
55589
55611
  },
55590
55612
  uniwindTypes: {
55591
55613
  name: "Uniwind Types",
@@ -55597,7 +55619,8 @@ var CUSTOM_FILE_CHECKS = {
55597
55619
  message: "The uniwind types are missing",
55598
55620
  docs: "https://docs.uniwind.dev/api/metro-config#dtsfile"
55599
55621
  }
55600
- ]
55622
+ ],
55623
+ stylingLibraries: ["uniwind"]
55601
55624
  },
55602
55625
  utils: {
55603
55626
  name: "Utils",
@@ -55609,7 +55632,8 @@ var CUSTOM_FILE_CHECKS = {
55609
55632
  message: "The cn function is missing",
55610
55633
  docs: "https://reactnativereusables.com/docs/installation/manual#add-a-cn-helper"
55611
55634
  }
55612
- ]
55635
+ ],
55636
+ stylingLibraries: ["nativewind", "uniwind"]
55613
55637
  },
55614
55638
  css: {
55615
55639
  name: "CSS",
@@ -55626,7 +55650,26 @@ var CUSTOM_FILE_CHECKS = {
55626
55650
  message: "At least one of the color css variables is missing",
55627
55651
  docs: "https://reactnativereusables.com/docs/installation/manual#configure-your-styles"
55628
55652
  }
55629
- ]
55653
+ ],
55654
+ stylingLibraries: ["nativewind"]
55655
+ },
55656
+ uniwindCss: {
55657
+ name: "CSS",
55658
+ defaultFileNames: ["globals.css", "src/global.css"],
55659
+ docs: "https://reactnativereusables.com/docs/installation/manual#configure-your-styles",
55660
+ includes: [
55661
+ {
55662
+ content: ["tailwindcss", "uniwind"],
55663
+ message: "The tailwind layer directives are missing",
55664
+ docs: "https://reactnativereusables.com/docs/installation/manual#configure-your-styles"
55665
+ },
55666
+ {
55667
+ content: CSS_VARIABLE_NAMES,
55668
+ message: "At least one of the color css variables is missing",
55669
+ docs: "https://reactnativereusables.com/docs/installation/manual#configure-your-styles"
55670
+ }
55671
+ ],
55672
+ stylingLibraries: ["uniwind"]
55630
55673
  }
55631
55674
  };
55632
55675
  var NATIVEWIND_ENV_FILE = "nativewind-env.d.ts";
@@ -55693,6 +55736,9 @@ var PROJECT_MANIFEST = {
55693
55736
  templates: TEMPLATES
55694
55737
  };
55695
55738
 
55739
+ // src/utils/retry-with.ts
55740
+ var retryWith = (fn2, inputs) => inputs.slice(1).reduce((acc, input) => acc.pipe(Effect_exports.orElse(() => fn2(input))), fn2(inputs[0]));
55741
+
55696
55742
  // ../../node_modules/log-symbols/symbols.js
55697
55743
  var symbols_exports = {};
55698
55744
  __export(symbols_exports, {
@@ -55827,13 +55873,27 @@ var ProjectConfig = class extends Effect_exports.Service()("ProjectConfig", {
55827
55873
  yield* Effect_exports.logDebug(`componentJsonConfig: ${JSON.stringify(componentJsonConfig, null, 2)}`);
55828
55874
  return config2;
55829
55875
  });
55830
- const getStylingLibrary = () => Effect_exports.gen(function* () {
55831
- const nativewindEnvExists = yield* fs2.exists(path8.join(options3.cwd, "nativewind-env.d.ts"));
55832
- const uniwindTypesExists = yield* fs2.exists(path8.join(options3.cwd, "uniwind-types.d.ts"));
55833
- if (nativewindEnvExists) {
55834
- return "nativewind";
55876
+ const getUniwindDtsPath = () => Effect_exports.gen(function* () {
55877
+ const metroConfigPaths = ["metro.config.js", "metro.config.ts"].map((p3) => path8.join(options3.cwd, p3));
55878
+ const metroContent = yield* retryWith((filePath) => fs2.readFileString(filePath), metroConfigPaths).pipe(
55879
+ Effect_exports.catchAll(() => Effect_exports.succeed(null))
55880
+ );
55881
+ if (!metroContent?.includes("withUniwindConfig")) {
55882
+ return null;
55883
+ }
55884
+ const dtsFileMatch = metroContent.match(/dtsFile\s*:\s*["']([^"']+)["']/);
55885
+ if (dtsFileMatch?.[1]) {
55886
+ const dtsPath = dtsFileMatch[1].replace(/^\.\//, "");
55887
+ return path8.join(options3.cwd, dtsPath);
55835
55888
  }
55836
- if (uniwindTypesExists) {
55889
+ return path8.join(options3.cwd, PROJECT_MANIFEST.uniwindTypesFile);
55890
+ });
55891
+ const getStylingLibrary = () => Effect_exports.gen(function* () {
55892
+ const metroConfigPaths = ["metro.config.js", "metro.config.ts"].map((p3) => path8.join(options3.cwd, p3));
55893
+ const metroContent = yield* retryWith((filePath) => fs2.readFileString(filePath), metroConfigPaths).pipe(
55894
+ Effect_exports.catchAll(() => Effect_exports.succeed(null))
55895
+ );
55896
+ if (metroContent?.includes("withUniwindConfig")) {
55837
55897
  return "uniwind";
55838
55898
  }
55839
55899
  return "nativewind";
@@ -55974,15 +56034,13 @@ var ProjectConfig = class extends Effect_exports.Service()("ProjectConfig", {
55974
56034
  getComponentJson,
55975
56035
  getTsConfig,
55976
56036
  resolvePathFromAlias,
55977
- getStylingLibrary
56037
+ getStylingLibrary,
56038
+ getUniwindDtsPath
55978
56039
  };
55979
56040
  })
55980
56041
  }) {
55981
56042
  };
55982
56043
 
55983
- // src/utils/retry-with.ts
55984
- var retryWith = (fn2, inputs) => inputs.slice(1).reduce((acc, input) => acc.pipe(Effect_exports.orElse(() => fn2(input))), fn2(inputs[0]));
55985
-
55986
56044
  // src/services/required-files-checker.ts
55987
56045
  var RequiredFileError = class extends Data_exports.TaggedError("RequiredFileError") {
55988
56046
  };
@@ -55992,11 +56050,11 @@ var RequiredFilesChecker = class extends Effect_exports.Service()("RequiredFiles
55992
56050
  const path8 = yield* Path_exports.Path;
55993
56051
  const options3 = yield* CliOptions;
55994
56052
  const projectConfig = yield* ProjectConfig;
55995
- const checkFiles = (fileChecks) => Effect_exports.gen(function* () {
56053
+ const checkFiles = (fileChecks, stylingLibrary) => Effect_exports.gen(function* () {
55996
56054
  const missingFiles = [];
55997
56055
  const missingIncludes = [];
55998
56056
  const filesWithContent = yield* Effect_exports.forEach(
55999
- fileChecks,
56057
+ fileChecks.filter((file7) => file7.stylingLibraries.includes(stylingLibrary)),
56000
56058
  (file7) => retryWith(
56001
56059
  (filePath) => Effect_exports.gen(function* () {
56002
56060
  const fileContents = yield* fs2.readFileString(filePath);
@@ -56092,7 +56150,7 @@ var RequiredFilesChecker = class extends Effect_exports.Service()("RequiredFiles
56092
56150
  );
56093
56151
  return [...existingDeprecatedFromLibs, ...existingDeprecatedFromUi];
56094
56152
  });
56095
- const checkCustomFiles = (customFileChecks) => Effect_exports.gen(function* () {
56153
+ const checkCustomFiles = (customFileChecks, stylingLibrary) => Effect_exports.gen(function* () {
56096
56154
  const componentJson = yield* projectConfig.getComponentJson();
56097
56155
  const aliasForLib = componentJson.aliases.lib ?? `${componentJson.aliases.utils}/lib`;
56098
56156
  const missingFiles = [];
@@ -56115,7 +56173,8 @@ var RequiredFilesChecker = class extends Effect_exports.Service()("RequiredFiles
56115
56173
  )
56116
56174
  )
56117
56175
  );
56118
- for (const include of customFileChecks.css.includes) {
56176
+ const cssShouldInclude = stylingLibrary === "uniwind" ? customFileChecks.uniwindCss.includes : customFileChecks.css.includes;
56177
+ for (const include of cssShouldInclude) {
56119
56178
  if (include.content.every((str) => cssContent.includes(str))) {
56120
56179
  yield* Effect_exports.logDebug(
56121
56180
  `${symbols_exports.success} ${customFileChecks.css.name} has ${include.content.join(", ")}`
@@ -56127,48 +56186,51 @@ var RequiredFilesChecker = class extends Effect_exports.Service()("RequiredFiles
56127
56186
  );
56128
56187
  missingIncludes.push({ ...include, fileName: customFileChecks.css.name });
56129
56188
  }
56130
- let stylingLibrary = "nativewind";
56131
56189
  if (componentJson.tsx !== false) {
56132
56190
  const missingTypeFiles = [];
56133
- const nativewindEnvContent = yield* fs2.readFileString(path8.join(options3.cwd, PROJECT_MANIFEST.nativewindEnvFile)).pipe(
56134
- Effect_exports.catchAll(() => {
56135
- missingTypeFiles.push(customFileChecks.nativewindEnv);
56136
- return Effect_exports.succeed(null);
56137
- })
56138
- );
56139
- const uniwindTypesContent = yield* fs2.readFileString(path8.join(options3.cwd, PROJECT_MANIFEST.uniwindTypesFile)).pipe(
56140
- Effect_exports.catchAll(() => {
56141
- missingTypeFiles.push(customFileChecks.uniwindTypes);
56142
- return Effect_exports.succeed(null);
56143
- })
56144
- );
56145
- if (nativewindEnvContent) {
56146
- for (const include of customFileChecks.nativewindEnv.includes) {
56147
- if (include.content.every((str) => nativewindEnvContent.includes(str))) {
56191
+ if (stylingLibrary === "nativewind") {
56192
+ const nativewindEnvContent = yield* fs2.readFileString(path8.join(options3.cwd, PROJECT_MANIFEST.nativewindEnvFile)).pipe(
56193
+ Effect_exports.catchAll(() => {
56194
+ missingTypeFiles.push(customFileChecks.nativewindEnv);
56195
+ return Effect_exports.succeed(null);
56196
+ })
56197
+ );
56198
+ if (nativewindEnvContent) {
56199
+ for (const include of customFileChecks.nativewindEnv.includes) {
56200
+ if (include.content.every((str) => nativewindEnvContent.includes(str))) {
56201
+ yield* Effect_exports.logDebug(
56202
+ `${symbols_exports.success} ${customFileChecks.nativewindEnv.name} has ${include.content.join(", ")}`
56203
+ );
56204
+ continue;
56205
+ }
56148
56206
  yield* Effect_exports.logDebug(
56149
- `${symbols_exports.success} ${customFileChecks.nativewindEnv.name} has ${include.content.join(", ")}`
56207
+ `${symbols_exports.error} ${customFileChecks.nativewindEnv.name} missing ${include.content.join(", ")}`
56150
56208
  );
56151
- continue;
56209
+ missingIncludes.push({ ...include, fileName: customFileChecks.nativewindEnv.name });
56152
56210
  }
56153
- yield* Effect_exports.logDebug(
56154
- `${symbols_exports.error} ${customFileChecks.nativewindEnv.name} missing ${include.content.join(", ")}`
56155
- );
56156
- missingIncludes.push({ ...include, fileName: customFileChecks.nativewindEnv.name });
56157
56211
  }
56158
56212
  }
56159
- if (uniwindTypesContent) {
56160
- stylingLibrary = "uniwind";
56161
- for (const include of customFileChecks.uniwindTypes.includes) {
56162
- if (include.content.every((str) => uniwindTypesContent.includes(str))) {
56213
+ if (stylingLibrary === "uniwind") {
56214
+ const uniwindDtsPath = yield* projectConfig.getUniwindDtsPath();
56215
+ const uniwindTypesContent = uniwindDtsPath ? yield* fs2.readFileString(uniwindDtsPath).pipe(
56216
+ Effect_exports.catchAll(() => {
56217
+ missingTypeFiles.push(customFileChecks.uniwindTypes);
56218
+ return Effect_exports.succeed(null);
56219
+ })
56220
+ ) : null;
56221
+ if (uniwindTypesContent) {
56222
+ for (const include of customFileChecks.uniwindTypes.includes) {
56223
+ if (include.content.every((str) => uniwindTypesContent.includes(str))) {
56224
+ yield* Effect_exports.logDebug(
56225
+ `${symbols_exports.success} ${customFileChecks.uniwindTypes.name} has ${include.content.join(", ")}`
56226
+ );
56227
+ continue;
56228
+ }
56163
56229
  yield* Effect_exports.logDebug(
56164
- `${symbols_exports.success} ${customFileChecks.uniwindTypes.name} has ${include.content.join(", ")}`
56230
+ `${symbols_exports.error} ${customFileChecks.uniwindTypes.name} missing ${include.content.join(", ")}`
56165
56231
  );
56166
- continue;
56232
+ missingIncludes.push({ ...include, fileName: customFileChecks.uniwindTypes.name });
56167
56233
  }
56168
- yield* Effect_exports.logDebug(
56169
- `${symbols_exports.error} ${customFileChecks.uniwindTypes.name} missing ${include.content.join(", ")}`
56170
- );
56171
- missingIncludes.push({ ...include, fileName: customFileChecks.uniwindTypes.name });
56172
56234
  }
56173
56235
  }
56174
56236
  if (missingTypeFiles.length === 2) {
@@ -56264,11 +56326,12 @@ var RequiredFilesChecker = class extends Effect_exports.Service()("RequiredFiles
56264
56326
  customFileChecks,
56265
56327
  deprecatedFromLib,
56266
56328
  deprecatedFromUi,
56267
- fileChecks
56329
+ fileChecks,
56330
+ stylingLibrary
56268
56331
  }) => Effect_exports.gen(function* () {
56269
56332
  const [fileResults, customFileResults, deprecatedFileResults] = yield* Effect_exports.all([
56270
- checkFiles(fileChecks),
56271
- checkCustomFiles(customFileChecks),
56333
+ checkFiles(fileChecks, stylingLibrary),
56334
+ checkCustomFiles(customFileChecks, stylingLibrary),
56272
56335
  checkDeprecatedFiles(deprecatedFromLib, deprecatedFromUi)
56273
56336
  ]);
56274
56337
  return { fileResults, customFileResults, deprecatedFileResults };
@@ -58209,6 +58272,11 @@ var Doctor = class extends Effect_exports.Service()("Doctor", {
58209
58272
  const path8 = yield* Path_exports.Path;
58210
58273
  const requiredFileChecker = yield* RequiredFilesChecker;
58211
58274
  const spinner = yield* Spinner;
58275
+ const projectConfig = yield* ProjectConfig;
58276
+ const stylingLibrary = yield* projectConfig.getStylingLibrary();
58277
+ console.log(
58278
+ `\x1B[2m${symbols_exports.info} Styling Library: ${stylingLibrary === "uniwind" ? "Uniwind" : "Nativewind"}\x1B[0m`
58279
+ );
58212
58280
  const checkRequiredDependencies = ({
58213
58281
  dependencies,
58214
58282
  devDependencies
@@ -58250,14 +58318,15 @@ var Doctor = class extends Effect_exports.Service()("Doctor", {
58250
58318
  run: (options4) => Effect_exports.gen(function* () {
58251
58319
  yield* Effect_exports.logDebug(`Doctor options: ${JSON.stringify(options4, null, 2)}`);
58252
58320
  const { uninstalledDependencies, uninstalledDevDependencies } = yield* checkRequiredDependencies({
58253
- dependencies: PROJECT_MANIFEST.dependencies,
58321
+ dependencies: PROJECT_MANIFEST.dependencies[stylingLibrary],
58254
58322
  devDependencies: PROJECT_MANIFEST.devDependencies
58255
58323
  });
58256
58324
  const { customFileResults, deprecatedFileResults, fileResults } = yield* requiredFileChecker.run({
58257
58325
  customFileChecks: PROJECT_MANIFEST.customFileChecks,
58258
58326
  deprecatedFromLib: PROJECT_MANIFEST.deprecatedFromLib,
58259
58327
  deprecatedFromUi: PROJECT_MANIFEST.deprecatedFromUi,
58260
- fileChecks: PROJECT_MANIFEST.fileChecks
58328
+ fileChecks: PROJECT_MANIFEST.fileChecks,
58329
+ stylingLibrary
58261
58330
  });
58262
58331
  const result = {
58263
58332
  missingFiles: [...fileResults.missingFiles, ...customFileResults.missingFiles],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-reusables/cli",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "type": "module",
5
5
  "description": "A CLI for React Native Reusables",
6
6
  "main": "bin.cjs",