frakment 2.0.3 → 3.0.0
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 +8 -8
- package/dist/bin/index.js +1 -5
- package/dist/package.json +6 -7
- package/dist/src/commands/add.js +4 -16
- package/dist/src/commands/init.js +1 -123
- package/package.json +5 -6
- package/dist/templates/expo/components.json +0 -20
- package/dist/templates/expo/lib/theme.ts +0 -63
- package/dist/templates/expo/lib/utils.ts +0 -5
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
Monochrome design system and component registry CLI.
|
|
7
7
|
|
|
8
|
-
Frakment is
|
|
8
|
+
Frakment-authored CLI code is licensed under MIT, which permits commercial use, modification, distribution, and sublicensing. Third-party dependencies retain their own licenses; see the [repository third-party notices](https://github.com/frakment/ui/blob/main/docs/legal/THIRD_PARTY_NOTICES.md).
|
|
9
9
|
|
|
10
10
|
## Requirements
|
|
11
11
|
|
|
@@ -16,12 +16,12 @@ Frakment is open source under the MIT License. Commercial use, modification, dis
|
|
|
16
16
|
|
|
17
17
|
The commands below use `npx`. Every package manager works.
|
|
18
18
|
|
|
19
|
-
| Package manager | Run
|
|
20
|
-
|
|
|
21
|
-
| npm
|
|
22
|
-
| pnpm
|
|
23
|
-
| yarn
|
|
24
|
-
| bun
|
|
19
|
+
| Package manager | Run |
|
|
20
|
+
| :-------------- | :----------------------------------- |
|
|
21
|
+
| npm | `npx frakment@latest <command>` |
|
|
22
|
+
| pnpm | `pnpm dlx frakment@latest <command>` |
|
|
23
|
+
| yarn | `yarn dlx frakment@latest <command>` |
|
|
24
|
+
| bun | `bunx frakment@latest <command>` |
|
|
25
25
|
|
|
26
26
|
The CLI auto-detects your package manager from the project lockfile when installing dependencies.
|
|
27
27
|
|
|
@@ -112,4 +112,4 @@ If your `globals.css` lives at `src/app/globals.css`, component files are writte
|
|
|
112
112
|
|
|
113
113
|
## License
|
|
114
114
|
|
|
115
|
-
MIT licensed
|
|
115
|
+
The CLI's own source is MIT licensed; see [LICENSE](./LICENSE). Third-party dependencies retain their respective licenses.
|
package/dist/bin/index.js
CHANGED
|
@@ -16,23 +16,19 @@ program
|
|
|
16
16
|
.addHelpText("after", `
|
|
17
17
|
Examples:
|
|
18
18
|
${chalk.dim("$ frakment init")}
|
|
19
|
-
${chalk.dim("$ frakment init --expo")}
|
|
20
19
|
${chalk.dim("$ frakment add button")}
|
|
21
|
-
${chalk.dim("$ frakment add button --expo")}
|
|
22
20
|
${chalk.dim("$ frakment add button bubble")}
|
|
23
21
|
${chalk.dim("$ frakment list")}
|
|
24
22
|
`);
|
|
25
23
|
program
|
|
26
24
|
.command("init")
|
|
27
25
|
.description("Initialize frakment in your project")
|
|
28
|
-
.
|
|
29
|
-
.action((...args) => init(args.at(-1).opts()));
|
|
26
|
+
.action(() => init());
|
|
30
27
|
program
|
|
31
28
|
.command("add <components...>")
|
|
32
29
|
.description("Add one or more components from the frakment registry")
|
|
33
30
|
.option("--dry-run", "Show planned file and dependency changes without writing")
|
|
34
31
|
.option("--registry <url>", "Custom registry URL")
|
|
35
|
-
.option("--expo", "Use the Expo / React Native registry")
|
|
36
32
|
.option("--skip-dependencies", "Do not install missing npm dependencies")
|
|
37
33
|
.option("--overwrite", "Overwrite existing files", false)
|
|
38
34
|
.action(add);
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "frakment",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "MIT-licensed CLI and design system for the Frakment component registry",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
],
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/
|
|
14
|
+
"url": "git+https://github.com/frakment/ui.git",
|
|
15
15
|
"directory": "packages/cli"
|
|
16
16
|
},
|
|
17
17
|
"license": "MIT",
|
|
18
|
-
"author": "The Frakment Authors (https://github.com/
|
|
18
|
+
"author": "The Frakment Authors (https://github.com/frakment/ui)",
|
|
19
19
|
"type": "module",
|
|
20
20
|
"bin": {
|
|
21
21
|
"frakment": "./dist/bin/index.js"
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"LICENSE"
|
|
26
26
|
],
|
|
27
27
|
"scripts": {
|
|
28
|
-
"build": "tsc -p tsconfig.build.json && node ../../scripts/copy-runtime-package.
|
|
29
|
-
"prepack": "
|
|
28
|
+
"build": "tsc -p tsconfig.build.json && node ../../scripts/copy-runtime-package.ts",
|
|
29
|
+
"prepack": "node ../../scripts/run-package-script.ts build",
|
|
30
30
|
"typecheck": "tsc --noEmit"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
@@ -41,8 +41,7 @@
|
|
|
41
41
|
"@types/react": "19.3.0",
|
|
42
42
|
"clsx": "^2.1.1",
|
|
43
43
|
"react": "19.3.1",
|
|
44
|
-
"
|
|
45
|
-
"tailwind-merge": "^3.7.0"
|
|
44
|
+
"tailwind-merge": "^3.7.1"
|
|
46
45
|
},
|
|
47
46
|
"engines": {
|
|
48
47
|
"node": ">=22.18.0"
|
package/dist/src/commands/add.js
CHANGED
|
@@ -23,7 +23,6 @@ const componentNamePattern = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
|
|
|
23
23
|
const dependencyPattern = /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*(?:@[0-9A-Za-z*~^<>=|.+_-]+)?$/u;
|
|
24
24
|
const maxRegistryPayloadBytes = 10 * 1024 * 1024;
|
|
25
25
|
const defaultWebRegistry = "https://www.arrafi.dev/frakment/r";
|
|
26
|
-
const defaultExpoRegistry = "https://www.arrafi.dev/frakment/r/expo";
|
|
27
26
|
const defaultAliases = {
|
|
28
27
|
components: "@/components",
|
|
29
28
|
ui: "@/components/ui",
|
|
@@ -154,10 +153,7 @@ export function resolveRegistryUrl(config, options = {}) {
|
|
|
154
153
|
? configRecord.registry
|
|
155
154
|
: undefined;
|
|
156
155
|
const web = typeof registries.web === "string" ? registries.web : undefined;
|
|
157
|
-
const
|
|
158
|
-
const configured = options.expo
|
|
159
|
-
? (expo !== null && expo !== void 0 ? expo : defaultExpoRegistry)
|
|
160
|
-
: ((_a = registry !== null && registry !== void 0 ? registry : web) !== null && _a !== void 0 ? _a : defaultWebRegistry);
|
|
156
|
+
const configured = (_a = registry !== null && registry !== void 0 ? registry : web) !== null && _a !== void 0 ? _a : defaultWebRegistry;
|
|
161
157
|
return getRegistryUrl((_b = options.registry) !== null && _b !== void 0 ? _b : configured);
|
|
162
158
|
}
|
|
163
159
|
async function fetchComponent(name, registryUrl, spinner) {
|
|
@@ -370,17 +366,9 @@ export async function add(componentNamesInput, options = {}) {
|
|
|
370
366
|
const s = ora("Installing dependencies").start();
|
|
371
367
|
const packages = missing.map(([, dependency]) => dependency);
|
|
372
368
|
try {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
stdio: "ignore",
|
|
377
|
-
});
|
|
378
|
-
}
|
|
379
|
-
else {
|
|
380
|
-
const pm = detectPackageManager(cwd);
|
|
381
|
-
const args = pm === "npm" ? ["install", ...packages] : ["add", ...packages];
|
|
382
|
-
await execa(pm, args, { cwd, stdio: "ignore" });
|
|
383
|
-
}
|
|
369
|
+
const pm = detectPackageManager(cwd);
|
|
370
|
+
const args = pm === "npm" ? ["install", ...packages] : ["add", ...packages];
|
|
371
|
+
await execa(pm, args, { cwd, stdio: "ignore" });
|
|
384
372
|
s.succeed(`Installed ${missing.length} package(s).`);
|
|
385
373
|
}
|
|
386
374
|
catch (error) {
|
|
@@ -16,129 +16,7 @@ const themeMarkerEnd = "/* ==== FRAKMENT THEME END ==== */";
|
|
|
16
16
|
function escapeRegex(s) {
|
|
17
17
|
return s.replaceAll(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
18
18
|
}
|
|
19
|
-
async function
|
|
20
|
-
var _a, _b;
|
|
21
|
-
let cwd;
|
|
22
|
-
const preflight = ora("Expo preflight checks").start();
|
|
23
|
-
try {
|
|
24
|
-
cwd = findProjectRoot(process.cwd());
|
|
25
|
-
}
|
|
26
|
-
catch (error) {
|
|
27
|
-
preflight.fail(error instanceof Error ? error.message : "Unknown error");
|
|
28
|
-
process.exit(1);
|
|
29
|
-
}
|
|
30
|
-
const pkgPath = path.join(cwd, "package.json");
|
|
31
|
-
let pkg;
|
|
32
|
-
try {
|
|
33
|
-
const raw = await readFile(pkgPath, "utf-8");
|
|
34
|
-
pkg = JSON.parse(raw.replace(/^\uFEFF/u, ""));
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
preflight.fail("Could not read package.json.");
|
|
38
|
-
logger.error(error instanceof Error ? error.message : "Unknown error");
|
|
39
|
-
process.exit(1);
|
|
40
|
-
}
|
|
41
|
-
const allDeps = Object.assign(Object.assign({}, pkg.dependencies), pkg.devDependencies);
|
|
42
|
-
const required = ["expo", "react-native", "nativewind", "tailwindcss"];
|
|
43
|
-
const missingFramework = required.filter((name) => !allDeps[name]);
|
|
44
|
-
if (missingFramework.length > 0) {
|
|
45
|
-
preflight.fail("Expo project prerequisites are missing.");
|
|
46
|
-
logger.error("frakment init --expo requires Expo, React Native, NativeWind, and Tailwind CSS.");
|
|
47
|
-
logger.info(`Missing: ${missingFramework.join(", ")}`);
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
preflight.succeed("Found Expo + React Native + NativeWind project.");
|
|
51
|
-
const cssCandidates = [
|
|
52
|
-
"global.css",
|
|
53
|
-
"app/global.css",
|
|
54
|
-
"src/global.css",
|
|
55
|
-
"src/app/global.css",
|
|
56
|
-
"styles/global.css",
|
|
57
|
-
];
|
|
58
|
-
const cssPath = cssCandidates.find((candidate) => existsSync(path.join(cwd, candidate)));
|
|
59
|
-
if (!cssPath) {
|
|
60
|
-
logger.error("Could not find the NativeWind stylesheet, for example global.css.");
|
|
61
|
-
process.exit(1);
|
|
62
|
-
}
|
|
63
|
-
const css = (await readFile(path.join(cwd, cssPath), "utf-8")).replace(/^\uFEFF/u, "");
|
|
64
|
-
if (!/@import\s+["']nativewind\/theme["'];?/u.test(css)) {
|
|
65
|
-
logger.error("The stylesheet must import nativewind/theme. Configure NativeWind first.");
|
|
66
|
-
process.exit(1);
|
|
67
|
-
}
|
|
68
|
-
const configPath = path.join(cwd, configFile);
|
|
69
|
-
let shouldWriteConfig = !existsSync(configPath);
|
|
70
|
-
if (!shouldWriteConfig) {
|
|
71
|
-
const { overwrite } = await prompts({
|
|
72
|
-
initial: false,
|
|
73
|
-
message: `${configFile} already exists. Overwrite?`,
|
|
74
|
-
name: "overwrite",
|
|
75
|
-
type: "confirm",
|
|
76
|
-
});
|
|
77
|
-
if (overwrite === undefined) {
|
|
78
|
-
logger.break();
|
|
79
|
-
logger.info("Cancelled.");
|
|
80
|
-
process.exit(0);
|
|
81
|
-
}
|
|
82
|
-
shouldWriteConfig = overwrite === true;
|
|
83
|
-
if (!shouldWriteConfig) {
|
|
84
|
-
logger.info(`Keeping existing ${configFile}.`);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
if (shouldWriteConfig) {
|
|
88
|
-
const spinner = ora("Writing Expo components.json").start();
|
|
89
|
-
const templatePath = path.join(templatesDir, "expo", configFile);
|
|
90
|
-
const templateRaw = await readFile(templatePath, "utf-8");
|
|
91
|
-
const template = JSON.parse(templateRaw.replace(/^\uFEFF/u, ""));
|
|
92
|
-
if (template.platform !== "expo" || !((_a = template.registries) === null || _a === void 0 ? void 0 : _a.expo)) {
|
|
93
|
-
spinner.fail("Expo CLI template is missing its Expo registry.");
|
|
94
|
-
process.exit(1);
|
|
95
|
-
}
|
|
96
|
-
const config = Object.assign(Object.assign({}, template), { registry: (_b = template.registries.web) !== null && _b !== void 0 ? _b : defaultRegistry, tailwind: Object.assign(Object.assign({}, template.tailwind), { css: cssPath }) });
|
|
97
|
-
await writeFile(configPath, `${JSON.stringify(config, null, 2)}\n`);
|
|
98
|
-
spinner.succeed(`Created ${configFile}.`);
|
|
99
|
-
}
|
|
100
|
-
for (const name of ["utils.ts", "theme.ts"]) {
|
|
101
|
-
const target = path.join(cwd, "lib", name);
|
|
102
|
-
if (existsSync(target)) {
|
|
103
|
-
logger.info(`Keeping existing lib/${name}.`);
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
const source = path.join(templatesDir, "expo", "lib", name);
|
|
107
|
-
const content = await readFile(source, "utf-8");
|
|
108
|
-
await mkdir(path.dirname(target), { recursive: true });
|
|
109
|
-
await writeFile(target, content);
|
|
110
|
-
logger.log(`Created lib/${name}.`);
|
|
111
|
-
}
|
|
112
|
-
const baseDependencies = [
|
|
113
|
-
"clsx",
|
|
114
|
-
"tailwind-merge",
|
|
115
|
-
"class-variance-authority",
|
|
116
|
-
];
|
|
117
|
-
const missing = baseDependencies.filter((name) => !allDeps[name]);
|
|
118
|
-
if (missing.length > 0) {
|
|
119
|
-
const spinner = ora("Installing Expo dependencies").start();
|
|
120
|
-
try {
|
|
121
|
-
await execa("npx", ["expo", "install", ...missing], {
|
|
122
|
-
cwd,
|
|
123
|
-
stdio: "ignore",
|
|
124
|
-
});
|
|
125
|
-
spinner.succeed(`Installed ${missing.length} package(s).`);
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
spinner.fail("Failed to install Expo dependencies.");
|
|
129
|
-
logger.warn(error instanceof Error ? error.message : "Unknown error");
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
logger.break();
|
|
133
|
-
logger.log(chalk.green("Success!") +
|
|
134
|
-
" Expo initialization completed. Use frakment add <component> --expo for native components.");
|
|
135
|
-
logger.break();
|
|
136
|
-
}
|
|
137
|
-
export async function init(options = {}) {
|
|
138
|
-
if (options.expo) {
|
|
139
|
-
await initExpo();
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
19
|
+
export async function init() {
|
|
142
20
|
let cwd;
|
|
143
21
|
const preflight = ora("Preflight checks").start();
|
|
144
22
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "frakment",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "MIT-licensed CLI and design system for the Frakment component registry",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
],
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/
|
|
14
|
+
"url": "git+https://github.com/frakment/ui.git",
|
|
15
15
|
"directory": "packages/cli"
|
|
16
16
|
},
|
|
17
17
|
"license": "MIT",
|
|
18
|
-
"author": "The Frakment Authors (https://github.com/
|
|
18
|
+
"author": "The Frakment Authors (https://github.com/frakment/ui)",
|
|
19
19
|
"type": "module",
|
|
20
20
|
"bin": {
|
|
21
21
|
"frakment": "./dist/bin/index.js"
|
|
@@ -36,14 +36,13 @@
|
|
|
36
36
|
"@types/react": "19.3.0",
|
|
37
37
|
"clsx": "^2.1.1",
|
|
38
38
|
"react": "19.3.1",
|
|
39
|
-
"
|
|
40
|
-
"tailwind-merge": "^3.7.0"
|
|
39
|
+
"tailwind-merge": "^3.7.1"
|
|
41
40
|
},
|
|
42
41
|
"engines": {
|
|
43
42
|
"node": ">=22.18.0"
|
|
44
43
|
},
|
|
45
44
|
"scripts": {
|
|
46
|
-
"build": "tsc -p tsconfig.build.json && node ../../scripts/copy-runtime-package.
|
|
45
|
+
"build": "tsc -p tsconfig.build.json && node ../../scripts/copy-runtime-package.ts",
|
|
47
46
|
"typecheck": "tsc --noEmit"
|
|
48
47
|
}
|
|
49
48
|
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://www.arrafi.dev/frakment/schema/frakment.json",
|
|
3
|
-
"platform": "expo",
|
|
4
|
-
"registry": "https://www.arrafi.dev/frakment/r",
|
|
5
|
-
"registries": {
|
|
6
|
-
"web": "https://www.arrafi.dev/frakment/r",
|
|
7
|
-
"expo": "https://www.arrafi.dev/frakment/r/expo"
|
|
8
|
-
},
|
|
9
|
-
"aliases": {
|
|
10
|
-
"components": "@/components",
|
|
11
|
-
"ui": "@/components/ui",
|
|
12
|
-
"utils": "@/lib/utils",
|
|
13
|
-
"lib": "@/lib",
|
|
14
|
-
"hooks": "@/hooks"
|
|
15
|
-
},
|
|
16
|
-
"tailwind": {
|
|
17
|
-
"config": "",
|
|
18
|
-
"css": "global.css"
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { useColorScheme } from "react-native";
|
|
2
|
-
|
|
3
|
-
export interface ThemeColors {
|
|
4
|
-
accent: string;
|
|
5
|
-
accentForeground: string;
|
|
6
|
-
background: string;
|
|
7
|
-
border: string;
|
|
8
|
-
destructive: string;
|
|
9
|
-
destructiveForeground: string;
|
|
10
|
-
destructiveHover: string;
|
|
11
|
-
foreground: string;
|
|
12
|
-
input: string;
|
|
13
|
-
mutedForeground: string;
|
|
14
|
-
primary: string;
|
|
15
|
-
primaryForeground: string;
|
|
16
|
-
primaryHover: string;
|
|
17
|
-
secondary: string;
|
|
18
|
-
secondaryForeground: string;
|
|
19
|
-
secondaryHover: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const lightColors: ThemeColors = {
|
|
23
|
-
accent: "rgba(245, 245, 245, 1)",
|
|
24
|
-
accentForeground: "rgba(23, 23, 23, 1)",
|
|
25
|
-
background: "rgba(255, 255, 255, 1)",
|
|
26
|
-
border: "rgba(229, 229, 229, 1)",
|
|
27
|
-
destructive: "rgba(239, 68, 68, 1)",
|
|
28
|
-
destructiveForeground: "rgba(255, 255, 255, 1)",
|
|
29
|
-
destructiveHover: "rgba(240, 86, 86, 1)",
|
|
30
|
-
foreground: "rgba(10, 10, 10, 1)",
|
|
31
|
-
input: "rgba(227, 227, 227, 1)",
|
|
32
|
-
mutedForeground: "rgba(102, 102, 102, 1)",
|
|
33
|
-
primary: "rgba(23, 23, 23, 1)",
|
|
34
|
-
primaryForeground: "rgba(250, 250, 250, 1)",
|
|
35
|
-
primaryHover: "rgba(46, 46, 46, 1)",
|
|
36
|
-
secondary: "rgba(245, 245, 245, 1)",
|
|
37
|
-
secondaryForeground: "rgba(23, 23, 23, 1)",
|
|
38
|
-
secondaryHover: "rgba(247, 247, 247, 1)",
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const darkColors: ThemeColors = {
|
|
42
|
-
accent: "rgba(64, 64, 64, 1)",
|
|
43
|
-
accentForeground: "rgba(250, 250, 250, 1)",
|
|
44
|
-
background: "rgba(10, 10, 10, 1)",
|
|
45
|
-
border: "rgba(255, 255, 255, 0.1)",
|
|
46
|
-
destructive: "rgba(248, 113, 113, 1)",
|
|
47
|
-
destructiveForeground: "rgba(255, 255, 255, 1)",
|
|
48
|
-
destructiveHover: "rgba(224, 102, 102, 1)",
|
|
49
|
-
foreground: "rgba(250, 250, 250, 1)",
|
|
50
|
-
input: "rgba(255, 255, 255, 0.15)",
|
|
51
|
-
mutedForeground: "rgba(163, 163, 163, 1)",
|
|
52
|
-
primary: "rgba(229, 229, 229, 1)",
|
|
53
|
-
primaryForeground: "rgba(23, 23, 23, 1)",
|
|
54
|
-
primaryHover: "rgba(207, 207, 207, 1)",
|
|
55
|
-
secondary: "rgba(38, 38, 38, 1)",
|
|
56
|
-
secondaryForeground: "rgba(250, 250, 250, 1)",
|
|
57
|
-
secondaryHover: "rgba(33, 33, 33, 1)",
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export function useThemeColors(): ThemeColors {
|
|
61
|
-
const scheme = useColorScheme();
|
|
62
|
-
return scheme === "dark" ? darkColors : lightColors;
|
|
63
|
-
}
|