@metacells/mcellui-cli 0.1.4 → 0.1.5
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/README.md +3 -3
- package/dist/index.js +120 -123
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ nativeui init
|
|
|
25
25
|
npx @nativeui/cli init
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
This creates a `
|
|
28
|
+
This creates a `mcellui.config.ts` with your theme preferences.
|
|
29
29
|
|
|
30
30
|
2. **Add components:**
|
|
31
31
|
|
|
@@ -58,7 +58,7 @@ Initialize nativeui in your project.
|
|
|
58
58
|
npx @nativeui/cli init
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
Creates `
|
|
61
|
+
Creates `mcellui.config.ts` with theme configuration.
|
|
62
62
|
|
|
63
63
|
### `add <components...>`
|
|
64
64
|
|
|
@@ -126,7 +126,7 @@ Templates: `basic`, `animated`, `pressable`, `input`
|
|
|
126
126
|
|
|
127
127
|
## Configuration
|
|
128
128
|
|
|
129
|
-
`
|
|
129
|
+
`mcellui.config.ts`:
|
|
130
130
|
|
|
131
131
|
```ts
|
|
132
132
|
import { defineConfig } from '@nativeui/cli';
|
package/dist/index.js
CHANGED
|
@@ -212,27 +212,38 @@ async function detectProjectType(projectRoot) {
|
|
|
212
212
|
return "unknown";
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
+
var CONFIG_FILES = [
|
|
216
|
+
"mcellui.config.ts",
|
|
217
|
+
"mcellui.config.js",
|
|
218
|
+
"mcellui.config.json",
|
|
219
|
+
"nativeui.config.ts",
|
|
220
|
+
// Legacy
|
|
221
|
+
"nativeui.config.js",
|
|
222
|
+
// Legacy
|
|
223
|
+
"nativeui.config.json"
|
|
224
|
+
// Legacy
|
|
225
|
+
];
|
|
215
226
|
async function getConfig(projectRoot) {
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
227
|
+
for (const fileName of CONFIG_FILES) {
|
|
228
|
+
const configPath = path.join(projectRoot, fileName);
|
|
229
|
+
if (await fs.pathExists(configPath)) {
|
|
230
|
+
if (fileName.endsWith(".ts")) {
|
|
231
|
+
return loadTsConfig(configPath);
|
|
232
|
+
} else if (fileName.endsWith(".js")) {
|
|
233
|
+
return loadJsConfig(configPath);
|
|
234
|
+
} else if (fileName.endsWith(".json")) {
|
|
235
|
+
try {
|
|
236
|
+
const rawConfig = await fs.readJson(configPath);
|
|
237
|
+
const validatedConfig = validateConfigOrThrow(rawConfig, configPath);
|
|
238
|
+
return resolveConfig(validatedConfig);
|
|
239
|
+
} catch (error) {
|
|
240
|
+
if (error instanceof Error && error.message.includes("Invalid configuration")) {
|
|
241
|
+
console.error(chalk.red(error.message));
|
|
242
|
+
throw error;
|
|
243
|
+
}
|
|
244
|
+
throw error;
|
|
245
|
+
}
|
|
234
246
|
}
|
|
235
|
-
throw error;
|
|
236
247
|
}
|
|
237
248
|
}
|
|
238
249
|
return null;
|
|
@@ -294,7 +305,7 @@ async function detectPackageManager(projectRoot) {
|
|
|
294
305
|
}
|
|
295
306
|
|
|
296
307
|
// src/commands/init.ts
|
|
297
|
-
var initCommand = new Command().name("init").description("Initialize
|
|
308
|
+
var initCommand = new Command().name("init").description("Initialize mcellui in your project").option("-y, --yes", "Skip prompts and use defaults").option("--cwd <path>", "Working directory", process.cwd()).action(async (options) => {
|
|
298
309
|
const spinner = ora();
|
|
299
310
|
try {
|
|
300
311
|
const cwd = path2.resolve(options.cwd);
|
|
@@ -305,17 +316,24 @@ var initCommand = new Command().name("init").description("Initialize nativeui in
|
|
|
305
316
|
process.exit(1);
|
|
306
317
|
}
|
|
307
318
|
console.log();
|
|
308
|
-
console.log(chalk2.bold("Welcome to
|
|
319
|
+
console.log(chalk2.bold("Welcome to mcellui!"));
|
|
309
320
|
console.log(chalk2.dim("The copy-paste component library for Expo/React Native"));
|
|
310
321
|
console.log();
|
|
311
322
|
const projectType = await detectProjectType(projectRoot);
|
|
312
323
|
console.log(chalk2.dim(`Detected: ${projectType}`));
|
|
313
|
-
const configPath = path2.join(projectRoot, "
|
|
324
|
+
const configPath = path2.join(projectRoot, "mcellui.config.ts");
|
|
325
|
+
const legacyConfigPath = path2.join(projectRoot, "nativeui.config.ts");
|
|
314
326
|
if (await fs2.pathExists(configPath)) {
|
|
315
327
|
console.log(chalk2.yellow("Project already initialized."));
|
|
316
328
|
console.log(chalk2.dim(`Config found at: ${configPath}`));
|
|
317
329
|
return;
|
|
318
330
|
}
|
|
331
|
+
if (await fs2.pathExists(legacyConfigPath)) {
|
|
332
|
+
console.log(chalk2.yellow("Project already initialized with legacy config."));
|
|
333
|
+
console.log(chalk2.dim(`Config found at: ${legacyConfigPath}`));
|
|
334
|
+
console.log(chalk2.dim("Consider renaming to mcellui.config.ts"));
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
319
337
|
let config = {
|
|
320
338
|
componentsPath: "./components/ui",
|
|
321
339
|
utilsPath: "./lib/utils",
|
|
@@ -454,14 +472,14 @@ export function cn(...inputs: StyleInput[]): Style {
|
|
|
454
472
|
);
|
|
455
473
|
spinner.succeed("Utilities installed");
|
|
456
474
|
console.log();
|
|
457
|
-
console.log(chalk2.green("Success!") + "
|
|
475
|
+
console.log(chalk2.green("Success!") + " mcellui initialized.");
|
|
458
476
|
console.log();
|
|
459
477
|
console.log("Next steps:");
|
|
460
478
|
console.log(chalk2.dim(" 1."), "Add your first component:");
|
|
461
|
-
console.log(chalk2.cyan(" npx
|
|
479
|
+
console.log(chalk2.cyan(" npx mcellui add button"));
|
|
462
480
|
console.log();
|
|
463
481
|
console.log(chalk2.dim(" 2."), "Browse available components:");
|
|
464
|
-
console.log(chalk2.cyan(" npx
|
|
482
|
+
console.log(chalk2.cyan(" npx mcellui list"));
|
|
465
483
|
console.log();
|
|
466
484
|
} catch (error) {
|
|
467
485
|
spinner.fail("Failed to initialize");
|
|
@@ -485,7 +503,8 @@ import { fileURLToPath as fileURLToPath2 } from "url";
|
|
|
485
503
|
var __filename3 = fileURLToPath2(import.meta.url);
|
|
486
504
|
var __dirname2 = path3.dirname(__filename3);
|
|
487
505
|
var DEFAULT_REGISTRY_URL = "https://raw.githubusercontent.com/metacells-development/mcellui/main/packages/registry";
|
|
488
|
-
var
|
|
506
|
+
var hasEnvOverride = "MCELLUI_REGISTRY_URL" in process.env || "NATIVEUI_REGISTRY_URL" in process.env;
|
|
507
|
+
var REGISTRY_URL = hasEnvOverride ? process.env.MCELLUI_REGISTRY_URL || process.env.NATIVEUI_REGISTRY_URL || "" : DEFAULT_REGISTRY_URL;
|
|
489
508
|
function getLocalRegistryPath() {
|
|
490
509
|
return path3.resolve(__dirname2, "..", "..", "registry");
|
|
491
510
|
}
|
|
@@ -621,6 +640,25 @@ function formatCircularError(chain) {
|
|
|
621
640
|
// src/utils/installed.ts
|
|
622
641
|
import fs4 from "fs-extra";
|
|
623
642
|
import path4 from "path";
|
|
643
|
+
|
|
644
|
+
// src/utils/imports.ts
|
|
645
|
+
function transformToInstalled(code, config) {
|
|
646
|
+
if (!config) return code;
|
|
647
|
+
let result = code;
|
|
648
|
+
const utilsAlias = config.aliases?.utils || "@/lib/utils";
|
|
649
|
+
if (utilsAlias !== "@/lib/utils") {
|
|
650
|
+
result = result.replace(
|
|
651
|
+
/from ['"]@\/lib\/utils['"]/g,
|
|
652
|
+
`from '${utilsAlias}'`
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
return result;
|
|
656
|
+
}
|
|
657
|
+
function normalizeForComparison(content) {
|
|
658
|
+
return content.replace(/\r\n/g, "\n").replace(/\s+$/gm, "").trim();
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
// src/utils/installed.ts
|
|
624
662
|
async function getInstalledFiles(componentsDir) {
|
|
625
663
|
if (!await fs4.pathExists(componentsDir)) {
|
|
626
664
|
return [];
|
|
@@ -637,24 +675,6 @@ async function getInstalledFiles(componentsDir) {
|
|
|
637
675
|
}
|
|
638
676
|
return componentFiles.sort();
|
|
639
677
|
}
|
|
640
|
-
function normalizeContent(content) {
|
|
641
|
-
return content.replace(/\r\n/g, "\n").replace(/\s+$/gm, "").trim();
|
|
642
|
-
}
|
|
643
|
-
function transformImports(code, config) {
|
|
644
|
-
let transformed = code;
|
|
645
|
-
transformed = transformed.replace(
|
|
646
|
-
/from ['"]@nativeui\/core['"]/g,
|
|
647
|
-
`from '@metacells/mcellui-core'`
|
|
648
|
-
);
|
|
649
|
-
const utilsAlias = config.aliases?.utils || "@/lib/utils";
|
|
650
|
-
if (utilsAlias !== "@/lib/utils") {
|
|
651
|
-
transformed = transformed.replace(
|
|
652
|
-
/from ['"]@\/lib\/utils['"]/g,
|
|
653
|
-
`from '${utilsAlias}'`
|
|
654
|
-
);
|
|
655
|
-
}
|
|
656
|
-
return transformed;
|
|
657
|
-
}
|
|
658
678
|
async function getInstallStatus(installedFiles, registry, config) {
|
|
659
679
|
const results = [];
|
|
660
680
|
const registryMap = /* @__PURE__ */ new Map();
|
|
@@ -700,10 +720,8 @@ async function getInstallStatus(installedFiles, registry, config) {
|
|
|
700
720
|
continue;
|
|
701
721
|
}
|
|
702
722
|
const localContent = await fs4.readFile(localFile, "utf-8");
|
|
703
|
-
const normalizedLocal =
|
|
704
|
-
const normalizedRegistry =
|
|
705
|
-
transformImports(registryFile.content, config)
|
|
706
|
-
);
|
|
723
|
+
const normalizedLocal = normalizeForComparison(localContent);
|
|
724
|
+
const normalizedRegistry = normalizeForComparison(registryFile.content);
|
|
707
725
|
results.push({
|
|
708
726
|
name: registryItem.name,
|
|
709
727
|
fileName,
|
|
@@ -829,7 +847,7 @@ var addCommand = new Command2().name("add").description("Add a component to your
|
|
|
829
847
|
continue;
|
|
830
848
|
}
|
|
831
849
|
await fs5.ensureDir(targetDir);
|
|
832
|
-
const transformedContent =
|
|
850
|
+
const transformedContent = transformToInstalled(file.content, config);
|
|
833
851
|
await fs5.writeFile(targetPath, transformedContent);
|
|
834
852
|
}
|
|
835
853
|
spinner.succeed(`Added ${componentName}`);
|
|
@@ -864,18 +882,6 @@ var addCommand = new Command2().name("add").description("Add a component to your
|
|
|
864
882
|
process.exit(1);
|
|
865
883
|
}
|
|
866
884
|
});
|
|
867
|
-
function transformImports2(code, config) {
|
|
868
|
-
let transformed = code;
|
|
869
|
-
const utilsAlias = config.aliases?.utils || "@/lib/utils";
|
|
870
|
-
if (utilsAlias === "@/lib/utils") {
|
|
871
|
-
return transformed;
|
|
872
|
-
}
|
|
873
|
-
transformed = transformed.replace(
|
|
874
|
-
/from ['"]@\/lib\/utils['"]/g,
|
|
875
|
-
`from '${utilsAlias}'`
|
|
876
|
-
);
|
|
877
|
-
return transformed;
|
|
878
|
-
}
|
|
879
885
|
|
|
880
886
|
// src/commands/list.ts
|
|
881
887
|
import { Command as Command3 } from "commander";
|
|
@@ -1030,7 +1036,7 @@ var REQUIRED_PEER_DEPS = [
|
|
|
1030
1036
|
{ name: "react-native-safe-area-context", minVersion: "4.0.0" }
|
|
1031
1037
|
];
|
|
1032
1038
|
var RECOMMENDED_DEPS = [
|
|
1033
|
-
{ name: "@
|
|
1039
|
+
{ name: "@metacells/mcellui-core", reason: "Theme system and utilities" }
|
|
1034
1040
|
];
|
|
1035
1041
|
function parseVersion(version) {
|
|
1036
1042
|
const cleaned = version.replace(/^[\^~>=<]+/, "").replace(/^workspace:\*?/, "");
|
|
@@ -1075,7 +1081,7 @@ async function checkProjectType(projectRoot) {
|
|
|
1075
1081
|
name: "Project Type",
|
|
1076
1082
|
status: "fail",
|
|
1077
1083
|
message: "Not an Expo or React Native project",
|
|
1078
|
-
fix: "
|
|
1084
|
+
fix: "mcellui requires Expo or React Native"
|
|
1079
1085
|
};
|
|
1080
1086
|
}
|
|
1081
1087
|
return {
|
|
@@ -1086,23 +1092,39 @@ async function checkProjectType(projectRoot) {
|
|
|
1086
1092
|
}
|
|
1087
1093
|
async function checkInitialized(projectRoot) {
|
|
1088
1094
|
const configFiles = [
|
|
1095
|
+
"mcellui.config.ts",
|
|
1096
|
+
"mcellui.config.js",
|
|
1097
|
+
"mcellui.config.json",
|
|
1089
1098
|
"nativeui.config.ts",
|
|
1099
|
+
// Legacy
|
|
1090
1100
|
"nativeui.config.js",
|
|
1101
|
+
// Legacy
|
|
1091
1102
|
"nativeui.config.json"
|
|
1103
|
+
// Legacy
|
|
1092
1104
|
];
|
|
1093
1105
|
let foundConfig = null;
|
|
1106
|
+
let isLegacy = false;
|
|
1094
1107
|
for (const file of configFiles) {
|
|
1095
1108
|
if (await fs6.pathExists(path7.join(projectRoot, file))) {
|
|
1096
1109
|
foundConfig = file;
|
|
1110
|
+
isLegacy = file.startsWith("nativeui.");
|
|
1097
1111
|
break;
|
|
1098
1112
|
}
|
|
1099
1113
|
}
|
|
1100
1114
|
if (!foundConfig) {
|
|
1101
1115
|
return {
|
|
1102
|
-
name: "
|
|
1116
|
+
name: "mcellui Config",
|
|
1103
1117
|
status: "fail",
|
|
1104
|
-
message: "
|
|
1105
|
-
fix: "Run: npx
|
|
1118
|
+
message: "mcellui.config.ts not found",
|
|
1119
|
+
fix: "Run: npx mcellui init"
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
if (isLegacy) {
|
|
1123
|
+
return {
|
|
1124
|
+
name: "mcellui Config",
|
|
1125
|
+
status: "warn",
|
|
1126
|
+
message: `Found legacy config: ${foundConfig}`,
|
|
1127
|
+
fix: "Consider renaming to mcellui.config.ts"
|
|
1106
1128
|
};
|
|
1107
1129
|
}
|
|
1108
1130
|
try {
|
|
@@ -1113,7 +1135,7 @@ async function checkInitialized(projectRoot) {
|
|
|
1113
1135
|
const hasExport = content.includes("export default");
|
|
1114
1136
|
if (!hasExport) {
|
|
1115
1137
|
return {
|
|
1116
|
-
name: "
|
|
1138
|
+
name: "mcellui Config",
|
|
1117
1139
|
status: "warn",
|
|
1118
1140
|
message: "Config file missing default export",
|
|
1119
1141
|
fix: "Add: export default defineConfig({ ... })"
|
|
@@ -1121,7 +1143,7 @@ async function checkInitialized(projectRoot) {
|
|
|
1121
1143
|
}
|
|
1122
1144
|
if (!hasDefineConfig) {
|
|
1123
1145
|
return {
|
|
1124
|
-
name: "
|
|
1146
|
+
name: "mcellui Config",
|
|
1125
1147
|
status: "warn",
|
|
1126
1148
|
message: "Config not using defineConfig helper",
|
|
1127
1149
|
fix: "Wrap config with: defineConfig({ ... })"
|
|
@@ -1133,21 +1155,21 @@ async function checkInitialized(projectRoot) {
|
|
|
1133
1155
|
JSON.parse(content);
|
|
1134
1156
|
} catch {
|
|
1135
1157
|
return {
|
|
1136
|
-
name: "
|
|
1158
|
+
name: "mcellui Config",
|
|
1137
1159
|
status: "fail",
|
|
1138
1160
|
message: "Invalid JSON in config file",
|
|
1139
|
-
fix: "Check JSON syntax in
|
|
1161
|
+
fix: "Check JSON syntax in mcellui.config.json"
|
|
1140
1162
|
};
|
|
1141
1163
|
}
|
|
1142
1164
|
}
|
|
1143
1165
|
return {
|
|
1144
|
-
name: "
|
|
1166
|
+
name: "mcellui Config",
|
|
1145
1167
|
status: "pass",
|
|
1146
1168
|
message: `Found ${foundConfig}`
|
|
1147
1169
|
};
|
|
1148
1170
|
} catch (error) {
|
|
1149
1171
|
return {
|
|
1150
|
-
name: "
|
|
1172
|
+
name: "mcellui Config",
|
|
1151
1173
|
status: "fail",
|
|
1152
1174
|
message: "Could not read config file",
|
|
1153
1175
|
fix: error instanceof Error ? error.message : "Check file permissions"
|
|
@@ -1159,7 +1181,14 @@ async function checkPaths(projectRoot) {
|
|
|
1159
1181
|
const defaultUtilsPath = "./lib/utils";
|
|
1160
1182
|
let componentsPathValue = defaultComponentsPath;
|
|
1161
1183
|
let utilsPathValue = defaultUtilsPath;
|
|
1162
|
-
const configFiles = [
|
|
1184
|
+
const configFiles = [
|
|
1185
|
+
"mcellui.config.ts",
|
|
1186
|
+
"mcellui.config.js",
|
|
1187
|
+
"mcellui.config.json",
|
|
1188
|
+
"nativeui.config.ts",
|
|
1189
|
+
"nativeui.config.js",
|
|
1190
|
+
"nativeui.config.json"
|
|
1191
|
+
];
|
|
1163
1192
|
for (const file of configFiles) {
|
|
1164
1193
|
const configPath = path7.join(projectRoot, file);
|
|
1165
1194
|
if (await fs6.pathExists(configPath)) {
|
|
@@ -1183,7 +1212,7 @@ async function checkPaths(projectRoot) {
|
|
|
1183
1212
|
name: "Component Paths",
|
|
1184
1213
|
status: "warn",
|
|
1185
1214
|
message: "Component and utils directories not created yet",
|
|
1186
|
-
fix: `Add a component: npx
|
|
1215
|
+
fix: `Add a component: npx mcellui add button`
|
|
1187
1216
|
};
|
|
1188
1217
|
}
|
|
1189
1218
|
if (!componentsExist) {
|
|
@@ -1191,7 +1220,7 @@ async function checkPaths(projectRoot) {
|
|
|
1191
1220
|
name: "Component Paths",
|
|
1192
1221
|
status: "warn",
|
|
1193
1222
|
message: `Components directory not found: ${componentsPathValue}`,
|
|
1194
|
-
fix: "Add a component to create it: npx
|
|
1223
|
+
fix: "Add a component to create it: npx mcellui add button"
|
|
1195
1224
|
};
|
|
1196
1225
|
}
|
|
1197
1226
|
return {
|
|
@@ -1379,7 +1408,7 @@ async function checkExpoGo(projectRoot) {
|
|
|
1379
1408
|
}
|
|
1380
1409
|
function printReport(report) {
|
|
1381
1410
|
console.log();
|
|
1382
|
-
console.log(chalk5.bold("
|
|
1411
|
+
console.log(chalk5.bold("mcellui Doctor"));
|
|
1383
1412
|
console.log(chalk5.dim("Checking your project setup..."));
|
|
1384
1413
|
console.log();
|
|
1385
1414
|
console.log(chalk5.dim("Project:"), report.projectRoot);
|
|
@@ -1560,10 +1589,8 @@ var diffCommand = new Command5().name("diff").description("Compare locally insta
|
|
|
1560
1589
|
continue;
|
|
1561
1590
|
}
|
|
1562
1591
|
const localContent = await fs7.readFile(localFile, "utf-8");
|
|
1563
|
-
const normalizedLocal =
|
|
1564
|
-
const normalizedRegistry =
|
|
1565
|
-
transformImports(registryFile.content, config)
|
|
1566
|
-
);
|
|
1592
|
+
const normalizedLocal = normalizeForComparison(localContent);
|
|
1593
|
+
const normalizedRegistry = normalizeForComparison(registryFile.content);
|
|
1567
1594
|
if (normalizedLocal === normalizedRegistry) {
|
|
1568
1595
|
results.push({
|
|
1569
1596
|
name: registryItem.name,
|
|
@@ -1674,7 +1701,6 @@ import ora5 from "ora";
|
|
|
1674
1701
|
import prompts3 from "prompts";
|
|
1675
1702
|
import fs8 from "fs-extra";
|
|
1676
1703
|
import path9 from "path";
|
|
1677
|
-
import crypto from "crypto";
|
|
1678
1704
|
var updateCommand = new Command6().name("update").description("Update installed components to latest registry versions").argument("[components...]", "Specific components to update (default: all outdated)").option("-y, --yes", "Skip confirmation prompt").option("--all", "Update all components (including up-to-date)").option("--dry-run", "Show what would be updated without making changes").option("--cwd <path>", "Working directory", process.cwd()).action(async (components, options) => {
|
|
1679
1705
|
const spinner = ora5();
|
|
1680
1706
|
try {
|
|
@@ -1758,7 +1784,7 @@ var updateCommand = new Command6().name("update").description("Update installed
|
|
|
1758
1784
|
for (const file of component.files) {
|
|
1759
1785
|
const targetPath = path9.join(targetDir, file.name);
|
|
1760
1786
|
await fs8.ensureDir(targetDir);
|
|
1761
|
-
const transformedContent =
|
|
1787
|
+
const transformedContent = transformToInstalled(file.content, config);
|
|
1762
1788
|
await fs8.writeFile(targetPath, transformedContent);
|
|
1763
1789
|
}
|
|
1764
1790
|
spinner.succeed(`Updated ${comp.name}`);
|
|
@@ -1842,30 +1868,13 @@ async function checkForUpdate(localFile, registryItem, config) {
|
|
|
1842
1868
|
const registryFile = component.files.find((f) => f.name === fileName);
|
|
1843
1869
|
if (!registryFile) return false;
|
|
1844
1870
|
const localContent = await fs8.readFile(localFile, "utf-8");
|
|
1845
|
-
const
|
|
1846
|
-
const
|
|
1847
|
-
|
|
1848
|
-
return localHash !== registryHash;
|
|
1871
|
+
const normalizedLocal = normalizeForComparison(localContent);
|
|
1872
|
+
const normalizedRegistry = normalizeForComparison(registryFile.content);
|
|
1873
|
+
return normalizedLocal !== normalizedRegistry;
|
|
1849
1874
|
} catch {
|
|
1850
1875
|
return false;
|
|
1851
1876
|
}
|
|
1852
1877
|
}
|
|
1853
|
-
function hashContent(content) {
|
|
1854
|
-
const normalized = content.replace(/\r\n/g, "\n").replace(/\s+$/gm, "").trim();
|
|
1855
|
-
return crypto.createHash("md5").update(normalized).digest("hex");
|
|
1856
|
-
}
|
|
1857
|
-
function transformImports3(code, config) {
|
|
1858
|
-
let transformed = code;
|
|
1859
|
-
const utilsAlias = config.aliases?.utils || "@/lib/utils";
|
|
1860
|
-
if (utilsAlias === "@/lib/utils") {
|
|
1861
|
-
return transformed;
|
|
1862
|
-
}
|
|
1863
|
-
transformed = transformed.replace(
|
|
1864
|
-
/from ['"]@\/lib\/utils['"]/g,
|
|
1865
|
-
`from '${utilsAlias}'`
|
|
1866
|
-
);
|
|
1867
|
-
return transformed;
|
|
1868
|
-
}
|
|
1869
1878
|
|
|
1870
1879
|
// src/commands/create.ts
|
|
1871
1880
|
import { Command as Command7 } from "commander";
|
|
@@ -1955,7 +1964,7 @@ function generateBasicComponent(name, forwardRef) {
|
|
|
1955
1964
|
if (forwardRef) {
|
|
1956
1965
|
return `import React, { forwardRef } from 'react';
|
|
1957
1966
|
import { View, Text, StyleSheet, ViewProps } from 'react-native';
|
|
1958
|
-
import { useTheme } from '@
|
|
1967
|
+
import { useTheme } from '@metacells/mcellui-core';
|
|
1959
1968
|
|
|
1960
1969
|
export interface ${name}Props extends ViewProps {
|
|
1961
1970
|
/**
|
|
@@ -2015,7 +2024,7 @@ const styles = StyleSheet.create({
|
|
|
2015
2024
|
}
|
|
2016
2025
|
return `import React from 'react';
|
|
2017
2026
|
import { View, Text, StyleSheet, ViewProps } from 'react-native';
|
|
2018
|
-
import { useTheme } from '@
|
|
2027
|
+
import { useTheme } from '@metacells/mcellui-core';
|
|
2019
2028
|
|
|
2020
2029
|
export interface ${name}Props extends ViewProps {
|
|
2021
2030
|
/**
|
|
@@ -2082,7 +2091,7 @@ import Animated, {
|
|
|
2082
2091
|
useSharedValue,
|
|
2083
2092
|
withSpring,
|
|
2084
2093
|
} from 'react-native-reanimated';
|
|
2085
|
-
import { useTheme } from '@
|
|
2094
|
+
import { useTheme } from '@metacells/mcellui-core';
|
|
2086
2095
|
|
|
2087
2096
|
export interface ${name}Props extends ViewProps {
|
|
2088
2097
|
/**
|
|
@@ -2151,7 +2160,7 @@ import Animated, {
|
|
|
2151
2160
|
useSharedValue,
|
|
2152
2161
|
withTiming,
|
|
2153
2162
|
} from 'react-native-reanimated';
|
|
2154
|
-
import { useTheme } from '@
|
|
2163
|
+
import { useTheme } from '@metacells/mcellui-core';
|
|
2155
2164
|
|
|
2156
2165
|
const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
|
|
2157
2166
|
|
|
@@ -2244,7 +2253,7 @@ import Animated, {
|
|
|
2244
2253
|
useSharedValue,
|
|
2245
2254
|
withTiming,
|
|
2246
2255
|
} from 'react-native-reanimated';
|
|
2247
|
-
import { useTheme } from '@
|
|
2256
|
+
import { useTheme } from '@metacells/mcellui-core';
|
|
2248
2257
|
|
|
2249
2258
|
const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
|
|
2250
2259
|
|
|
@@ -2334,7 +2343,7 @@ import Animated, {
|
|
|
2334
2343
|
useSharedValue,
|
|
2335
2344
|
withTiming,
|
|
2336
2345
|
} from 'react-native-reanimated';
|
|
2337
|
-
import { useTheme } from '@
|
|
2346
|
+
import { useTheme } from '@metacells/mcellui-core';
|
|
2338
2347
|
|
|
2339
2348
|
export interface ${name}Props extends TextInputProps {
|
|
2340
2349
|
/**
|
|
@@ -2459,7 +2468,7 @@ import Animated, {
|
|
|
2459
2468
|
useSharedValue,
|
|
2460
2469
|
withTiming,
|
|
2461
2470
|
} from 'react-native-reanimated';
|
|
2462
|
-
import { useTheme } from '@
|
|
2471
|
+
import { useTheme } from '@metacells/mcellui-core';
|
|
2463
2472
|
|
|
2464
2473
|
export interface ${name}Props extends TextInputProps {
|
|
2465
2474
|
/**
|
|
@@ -2636,18 +2645,6 @@ function formatComponentChoice(item, installed) {
|
|
|
2636
2645
|
disabled: isInstalled
|
|
2637
2646
|
};
|
|
2638
2647
|
}
|
|
2639
|
-
function transformImports4(code, config) {
|
|
2640
|
-
let transformed = code;
|
|
2641
|
-
const utilsAlias = config.aliases?.utils || "@/lib/utils";
|
|
2642
|
-
if (utilsAlias === "@/lib/utils") {
|
|
2643
|
-
return transformed;
|
|
2644
|
-
}
|
|
2645
|
-
transformed = transformed.replace(
|
|
2646
|
-
/from ['"]@\/lib\/utils['"]/g,
|
|
2647
|
-
`from '${utilsAlias}'`
|
|
2648
|
-
);
|
|
2649
|
-
return transformed;
|
|
2650
|
-
}
|
|
2651
2648
|
var pickCommand = new Command8().name("pick").description("Interactively browse and select components to add").option("--all", "Show all components without category selection").option("-o, --overwrite", "Overwrite existing files").option("--cwd <path>", "Working directory", process.cwd()).action(async (options) => {
|
|
2652
2649
|
console.log(chalk9.bold("\n\u{1F3A8} nativeui Component Picker\n"));
|
|
2653
2650
|
const cwd = path11.resolve(options.cwd);
|
|
@@ -2763,7 +2760,7 @@ ${installed.size} already installed, ${availableCount} available
|
|
|
2763
2760
|
continue;
|
|
2764
2761
|
}
|
|
2765
2762
|
await fs10.ensureDir(targetDir);
|
|
2766
|
-
const transformedContent =
|
|
2763
|
+
const transformedContent = transformToInstalled(file.content, config);
|
|
2767
2764
|
await fs10.writeFile(targetPath, transformedContent);
|
|
2768
2765
|
}
|
|
2769
2766
|
installSpinner.succeed(`Installed ${chalk9.green(name)}`);
|
|
@@ -2810,7 +2807,7 @@ ${installed.size} already installed, ${availableCount} available
|
|
|
2810
2807
|
|
|
2811
2808
|
// src/index.ts
|
|
2812
2809
|
var program = new Command9();
|
|
2813
|
-
program.name("
|
|
2810
|
+
program.name("mcellui").description("Add beautiful UI components to your Expo/React Native project").version("0.1.4");
|
|
2814
2811
|
program.addCommand(initCommand);
|
|
2815
2812
|
program.addCommand(addCommand);
|
|
2816
2813
|
program.addCommand(listCommand);
|