@aakaar/cli 0.0.1
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/LICENSE.md +21 -0
- package/dist/index.cjs +237 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +236 -0
- package/package.json +44 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Aakaar UI Framework
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
// src/index.ts
|
|
5
|
+
var import_commander4 = require("commander");
|
|
6
|
+
|
|
7
|
+
// src/lib/operations/commands/add.ts
|
|
8
|
+
var import_node_fs2 = require("fs");
|
|
9
|
+
var import_commander = require("commander");
|
|
10
|
+
var import_execa = require("execa");
|
|
11
|
+
|
|
12
|
+
// src/lib/operations/utils/config.ts
|
|
13
|
+
var import_node_fs = require("fs");
|
|
14
|
+
var CONFIG_FILE = "./aakaar.json";
|
|
15
|
+
var config = (0, import_node_fs.existsSync)(CONFIG_FILE) ? JSON.parse((0, import_node_fs.readFileSync)(CONFIG_FILE, "utf-8")) : {
|
|
16
|
+
tokens: {
|
|
17
|
+
color: "006875",
|
|
18
|
+
output: "./css"
|
|
19
|
+
},
|
|
20
|
+
react: {
|
|
21
|
+
output: "./react/components"
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// src/lib/operations/utils/pm.ts
|
|
26
|
+
var import_ni = require("@antfu/ni");
|
|
27
|
+
async function getPackageManager(targetDir) {
|
|
28
|
+
const packageManager = await (0, import_ni.detect)({ programmatic: true, cwd: targetDir });
|
|
29
|
+
if (packageManager === "yarn@berry") return "yarn";
|
|
30
|
+
if (packageManager === "pnpm@6") return "pnpm";
|
|
31
|
+
if (packageManager === "bun") return "bun";
|
|
32
|
+
return packageManager ?? "npm";
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/lib/operations/commands/add.ts
|
|
36
|
+
var hostUrl = config.host ?? "https://aakaar.navnote.com";
|
|
37
|
+
var baseUrl = `${hostUrl}/registry`;
|
|
38
|
+
var add = new import_commander.Command().name("add").description("add component to your project").argument("<component>", "Component name to add. Example button, card, etc.").option("-o, --output <output>", "Output path for generated tokens.").action(async (component, { output }) => {
|
|
39
|
+
const cwd = process.cwd();
|
|
40
|
+
const packageManager = await getPackageManager(cwd);
|
|
41
|
+
console.log(`Using package manager: ${packageManager}`);
|
|
42
|
+
const finalOutput = output || config.react.output;
|
|
43
|
+
const finalComponentOutput = `${finalOutput}/${component}`;
|
|
44
|
+
if (!(0, import_node_fs2.existsSync)(finalComponentOutput)) {
|
|
45
|
+
console.log("Creating directory: ", finalComponentOutput);
|
|
46
|
+
(0, import_node_fs2.mkdirSync)(finalComponentOutput, {
|
|
47
|
+
recursive: true
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const componentUrl = `${baseUrl}/${component}.json`;
|
|
51
|
+
console.log(`Fetching component from ${componentUrl}`);
|
|
52
|
+
const response = await fetch(componentUrl);
|
|
53
|
+
const componentConfig = await response.json();
|
|
54
|
+
if (componentConfig.dependencies) {
|
|
55
|
+
await (0, import_execa.execa)(
|
|
56
|
+
packageManager,
|
|
57
|
+
[
|
|
58
|
+
packageManager === "npm" ? "install" : "add",
|
|
59
|
+
...componentConfig.dependencies
|
|
60
|
+
],
|
|
61
|
+
{
|
|
62
|
+
cwd
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
if (componentConfig.files.length > 0) {
|
|
67
|
+
for (const file of componentConfig.files) {
|
|
68
|
+
const filePath = `${finalComponentOutput}/${file.name}`;
|
|
69
|
+
console.log(`Writing file: ${filePath}`);
|
|
70
|
+
file.content = file.content.replace(
|
|
71
|
+
"../../core/core",
|
|
72
|
+
`${config.core.import}`
|
|
73
|
+
);
|
|
74
|
+
(0, import_node_fs2.writeFileSync)(filePath, file.content, {
|
|
75
|
+
encoding: "utf8",
|
|
76
|
+
flag: "w"
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// src/lib/operations/commands/setup.ts
|
|
83
|
+
var import_node_fs4 = require("fs");
|
|
84
|
+
var import_node_readline = require("readline");
|
|
85
|
+
var import_commander2 = require("commander");
|
|
86
|
+
|
|
87
|
+
// src/lib/operations/utils/verify.ts
|
|
88
|
+
var import_node_fs3 = require("fs");
|
|
89
|
+
|
|
90
|
+
// src/lib/operations/constants.ts
|
|
91
|
+
var REQUIRED_PACKAGES = [
|
|
92
|
+
"tailwindcss",
|
|
93
|
+
"@tailwindcss/vite",
|
|
94
|
+
"class-variance-authority",
|
|
95
|
+
"clsx",
|
|
96
|
+
"tailwind-merge",
|
|
97
|
+
"react",
|
|
98
|
+
"react-dom"
|
|
99
|
+
];
|
|
100
|
+
|
|
101
|
+
// src/lib/operations/utils/verify.ts
|
|
102
|
+
var verify = async () => {
|
|
103
|
+
console.log("Verifying the required packages");
|
|
104
|
+
const cwd = process.cwd();
|
|
105
|
+
const packageManager = await getPackageManager(cwd);
|
|
106
|
+
console.log(`Using package manager: ${packageManager}`);
|
|
107
|
+
const packageJson = JSON.parse((0, import_node_fs3.readFileSync)("./package.json", "utf8"));
|
|
108
|
+
const dependencies = packageJson.dependencies;
|
|
109
|
+
const devDependencies = packageJson.devDependencies;
|
|
110
|
+
const allDependencies = { ...dependencies, ...devDependencies };
|
|
111
|
+
const missingDependencies = REQUIRED_PACKAGES.filter(
|
|
112
|
+
(dependency) => !allDependencies[dependency]
|
|
113
|
+
);
|
|
114
|
+
if (missingDependencies.length > 0) {
|
|
115
|
+
console.log("Missing dependencies:");
|
|
116
|
+
console.log(missingDependencies);
|
|
117
|
+
} else {
|
|
118
|
+
console.log("All required packages are installed");
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// src/lib/operations/commands/setup.ts
|
|
123
|
+
var setup = new import_commander2.Command().name("setup").description("setup the aakaar ui").action(async () => {
|
|
124
|
+
await verify();
|
|
125
|
+
const aakaarJson = {
|
|
126
|
+
host: "http://aakaar.navnote.com",
|
|
127
|
+
core: {
|
|
128
|
+
path: "src/design",
|
|
129
|
+
import: "../../core"
|
|
130
|
+
},
|
|
131
|
+
tokens: {
|
|
132
|
+
color: "a42700",
|
|
133
|
+
output: "src/design/css"
|
|
134
|
+
},
|
|
135
|
+
react: {
|
|
136
|
+
output: "src/design/components"
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
const finalAakaarJson = (0, import_node_fs4.existsSync)("aakaar.json") ? JSON.parse((0, import_node_fs4.readFileSync)("aakaar.json", "utf-8")) : aakaarJson;
|
|
140
|
+
if (!(0, import_node_fs4.existsSync)("aakaar.json")) {
|
|
141
|
+
(0, import_node_fs4.writeFileSync)("aakaar.json", JSON.stringify(aakaarJson, null, 2));
|
|
142
|
+
} else {
|
|
143
|
+
console.log("aakaar.json already exists");
|
|
144
|
+
}
|
|
145
|
+
const proceed = await new Promise((resolve) => {
|
|
146
|
+
const readline = (0, import_node_readline.createInterface)({
|
|
147
|
+
input: process.stdin,
|
|
148
|
+
output: process.stdout
|
|
149
|
+
});
|
|
150
|
+
console.log("Current aakaar.json configuration:");
|
|
151
|
+
console.log(
|
|
152
|
+
`Host: ${finalAakaarJson.host} - The server URL where components are hosted`
|
|
153
|
+
);
|
|
154
|
+
console.log(
|
|
155
|
+
`Core path: ${finalAakaarJson.core.path} - Where core design system files will be created`
|
|
156
|
+
);
|
|
157
|
+
console.log(
|
|
158
|
+
`Core import: ${finalAakaarJson.core.import} - How components will import core design system files`
|
|
159
|
+
);
|
|
160
|
+
console.log(
|
|
161
|
+
`Token color: ${finalAakaarJson.tokens.color} - Primary brand color in hex format`
|
|
162
|
+
);
|
|
163
|
+
console.log(
|
|
164
|
+
`Token output: ${finalAakaarJson.tokens.output} - Where CSS design tokens will be generated`
|
|
165
|
+
);
|
|
166
|
+
console.log(
|
|
167
|
+
`React components output: ${finalAakaarJson.react.output} - Where React components will be created`
|
|
168
|
+
);
|
|
169
|
+
readline.question(
|
|
170
|
+
"Press y to proceed with the paths specified in aakaar.json or n to cancel and edit aakaar.json: ",
|
|
171
|
+
(answer) => {
|
|
172
|
+
readline.close();
|
|
173
|
+
resolve(answer.toLowerCase());
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
});
|
|
177
|
+
if (proceed !== "y") {
|
|
178
|
+
console.log(
|
|
179
|
+
"Setup cancelled. Run the setup command again to configure the project. You can also edit the aakaar.json file to change the paths, it will not be overwritten."
|
|
180
|
+
);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const hostUrl2 = finalAakaarJson.host;
|
|
184
|
+
const coreFile = await fetch(`${hostUrl2}/registry/core.json`);
|
|
185
|
+
const coreFileJson = await coreFile.json();
|
|
186
|
+
const firstCoreFile = coreFileJson.files[0];
|
|
187
|
+
const corePath = `${finalAakaarJson.core.path}`;
|
|
188
|
+
if (!(0, import_node_fs4.existsSync)(corePath)) {
|
|
189
|
+
(0, import_node_fs4.mkdirSync)(corePath, { recursive: true });
|
|
190
|
+
}
|
|
191
|
+
(0, import_node_fs4.writeFileSync)(`${corePath}/${firstCoreFile.name}`, firstCoreFile.content, {
|
|
192
|
+
encoding: "utf-8",
|
|
193
|
+
flag: "w"
|
|
194
|
+
});
|
|
195
|
+
console.log("Core file created successfully");
|
|
196
|
+
console.log("Setup completed successfully");
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
// src/lib/operations/commands/token.ts
|
|
200
|
+
var import_node_fs5 = require("fs");
|
|
201
|
+
var import_dictionary = require("@aakaar/dictionary");
|
|
202
|
+
var import_commander3 = require("commander");
|
|
203
|
+
var token = new import_commander3.Command().name("token").description("build design tokens for your project").option(
|
|
204
|
+
"-c, --color <color>",
|
|
205
|
+
"Hex code of the source color, example, 006875. If it is not provided, the default color is used i.e. 006875"
|
|
206
|
+
).option("-o, --output <output>", "Output path for generated tokens.").action(async ({ color, output }) => {
|
|
207
|
+
verify();
|
|
208
|
+
const finalColor = color || config.tokens.color;
|
|
209
|
+
const finalOutput = output || config.tokens.output;
|
|
210
|
+
console.log(`Generating tokens for color: ${finalColor}`);
|
|
211
|
+
const cssOutput = (0, import_dictionary.runCss)(`#${finalColor}`);
|
|
212
|
+
if (!(0, import_node_fs5.existsSync)(finalOutput)) {
|
|
213
|
+
(0, import_node_fs5.mkdirSync)(finalOutput, {
|
|
214
|
+
recursive: true
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
(0, import_node_fs5.writeFileSync)(`${finalOutput}/tokens.css`, cssOutput, {
|
|
218
|
+
encoding: "utf8",
|
|
219
|
+
flag: "w"
|
|
220
|
+
});
|
|
221
|
+
console.log(`Tokens generated at ${finalOutput}/tokens.css \u{1F680}`);
|
|
222
|
+
console.log(`Don't forget to include the generated CSS in your project!`);
|
|
223
|
+
console.log(`@import './<path>/tokens.css';
|
|
224
|
+
`);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
// src/index.ts
|
|
228
|
+
process.on("SIGINT", () => process.exit(0));
|
|
229
|
+
process.on("SIGTERM", () => process.exit(0));
|
|
230
|
+
async function main() {
|
|
231
|
+
const program = new import_commander4.Command().name("Aakaar UI").description("Build design system for your project");
|
|
232
|
+
program.addCommand(token);
|
|
233
|
+
program.addCommand(add);
|
|
234
|
+
program.addCommand(setup);
|
|
235
|
+
program.parse();
|
|
236
|
+
}
|
|
237
|
+
main();
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { Command as Command4 } from "commander";
|
|
5
|
+
|
|
6
|
+
// src/lib/operations/commands/add.ts
|
|
7
|
+
import { existsSync as existsSync2, mkdirSync, writeFileSync } from "fs";
|
|
8
|
+
import { Command } from "commander";
|
|
9
|
+
import { execa } from "execa";
|
|
10
|
+
|
|
11
|
+
// src/lib/operations/utils/config.ts
|
|
12
|
+
import { existsSync, readFileSync } from "fs";
|
|
13
|
+
var CONFIG_FILE = "./aakaar.json";
|
|
14
|
+
var config = existsSync(CONFIG_FILE) ? JSON.parse(readFileSync(CONFIG_FILE, "utf-8")) : {
|
|
15
|
+
tokens: {
|
|
16
|
+
color: "006875",
|
|
17
|
+
output: "./css"
|
|
18
|
+
},
|
|
19
|
+
react: {
|
|
20
|
+
output: "./react/components"
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// src/lib/operations/utils/pm.ts
|
|
25
|
+
import { detect } from "@antfu/ni";
|
|
26
|
+
async function getPackageManager(targetDir) {
|
|
27
|
+
const packageManager = await detect({ programmatic: true, cwd: targetDir });
|
|
28
|
+
if (packageManager === "yarn@berry") return "yarn";
|
|
29
|
+
if (packageManager === "pnpm@6") return "pnpm";
|
|
30
|
+
if (packageManager === "bun") return "bun";
|
|
31
|
+
return packageManager ?? "npm";
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/lib/operations/commands/add.ts
|
|
35
|
+
var hostUrl = config.host ?? "https://aakaar.navnote.com";
|
|
36
|
+
var baseUrl = `${hostUrl}/registry`;
|
|
37
|
+
var add = new Command().name("add").description("add component to your project").argument("<component>", "Component name to add. Example button, card, etc.").option("-o, --output <output>", "Output path for generated tokens.").action(async (component, { output }) => {
|
|
38
|
+
const cwd = process.cwd();
|
|
39
|
+
const packageManager = await getPackageManager(cwd);
|
|
40
|
+
console.log(`Using package manager: ${packageManager}`);
|
|
41
|
+
const finalOutput = output || config.react.output;
|
|
42
|
+
const finalComponentOutput = `${finalOutput}/${component}`;
|
|
43
|
+
if (!existsSync2(finalComponentOutput)) {
|
|
44
|
+
console.log("Creating directory: ", finalComponentOutput);
|
|
45
|
+
mkdirSync(finalComponentOutput, {
|
|
46
|
+
recursive: true
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const componentUrl = `${baseUrl}/${component}.json`;
|
|
50
|
+
console.log(`Fetching component from ${componentUrl}`);
|
|
51
|
+
const response = await fetch(componentUrl);
|
|
52
|
+
const componentConfig = await response.json();
|
|
53
|
+
if (componentConfig.dependencies) {
|
|
54
|
+
await execa(
|
|
55
|
+
packageManager,
|
|
56
|
+
[
|
|
57
|
+
packageManager === "npm" ? "install" : "add",
|
|
58
|
+
...componentConfig.dependencies
|
|
59
|
+
],
|
|
60
|
+
{
|
|
61
|
+
cwd
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
if (componentConfig.files.length > 0) {
|
|
66
|
+
for (const file of componentConfig.files) {
|
|
67
|
+
const filePath = `${finalComponentOutput}/${file.name}`;
|
|
68
|
+
console.log(`Writing file: ${filePath}`);
|
|
69
|
+
file.content = file.content.replace(
|
|
70
|
+
"../../core/core",
|
|
71
|
+
`${config.core.import}`
|
|
72
|
+
);
|
|
73
|
+
writeFileSync(filePath, file.content, {
|
|
74
|
+
encoding: "utf8",
|
|
75
|
+
flag: "w"
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// src/lib/operations/commands/setup.ts
|
|
82
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "fs";
|
|
83
|
+
import { createInterface } from "readline";
|
|
84
|
+
import { Command as Command2 } from "commander";
|
|
85
|
+
|
|
86
|
+
// src/lib/operations/utils/verify.ts
|
|
87
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
88
|
+
|
|
89
|
+
// src/lib/operations/constants.ts
|
|
90
|
+
var REQUIRED_PACKAGES = [
|
|
91
|
+
"tailwindcss",
|
|
92
|
+
"@tailwindcss/vite",
|
|
93
|
+
"class-variance-authority",
|
|
94
|
+
"clsx",
|
|
95
|
+
"tailwind-merge",
|
|
96
|
+
"react",
|
|
97
|
+
"react-dom"
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
// src/lib/operations/utils/verify.ts
|
|
101
|
+
var verify = async () => {
|
|
102
|
+
console.log("Verifying the required packages");
|
|
103
|
+
const cwd = process.cwd();
|
|
104
|
+
const packageManager = await getPackageManager(cwd);
|
|
105
|
+
console.log(`Using package manager: ${packageManager}`);
|
|
106
|
+
const packageJson = JSON.parse(readFileSync2("./package.json", "utf8"));
|
|
107
|
+
const dependencies = packageJson.dependencies;
|
|
108
|
+
const devDependencies = packageJson.devDependencies;
|
|
109
|
+
const allDependencies = { ...dependencies, ...devDependencies };
|
|
110
|
+
const missingDependencies = REQUIRED_PACKAGES.filter(
|
|
111
|
+
(dependency) => !allDependencies[dependency]
|
|
112
|
+
);
|
|
113
|
+
if (missingDependencies.length > 0) {
|
|
114
|
+
console.log("Missing dependencies:");
|
|
115
|
+
console.log(missingDependencies);
|
|
116
|
+
} else {
|
|
117
|
+
console.log("All required packages are installed");
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
// src/lib/operations/commands/setup.ts
|
|
122
|
+
var setup = new Command2().name("setup").description("setup the aakaar ui").action(async () => {
|
|
123
|
+
await verify();
|
|
124
|
+
const aakaarJson = {
|
|
125
|
+
host: "http://aakaar.navnote.com",
|
|
126
|
+
core: {
|
|
127
|
+
path: "src/design",
|
|
128
|
+
import: "../../core"
|
|
129
|
+
},
|
|
130
|
+
tokens: {
|
|
131
|
+
color: "a42700",
|
|
132
|
+
output: "src/design/css"
|
|
133
|
+
},
|
|
134
|
+
react: {
|
|
135
|
+
output: "src/design/components"
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const finalAakaarJson = existsSync3("aakaar.json") ? JSON.parse(readFileSync3("aakaar.json", "utf-8")) : aakaarJson;
|
|
139
|
+
if (!existsSync3("aakaar.json")) {
|
|
140
|
+
writeFileSync2("aakaar.json", JSON.stringify(aakaarJson, null, 2));
|
|
141
|
+
} else {
|
|
142
|
+
console.log("aakaar.json already exists");
|
|
143
|
+
}
|
|
144
|
+
const proceed = await new Promise((resolve) => {
|
|
145
|
+
const readline = createInterface({
|
|
146
|
+
input: process.stdin,
|
|
147
|
+
output: process.stdout
|
|
148
|
+
});
|
|
149
|
+
console.log("Current aakaar.json configuration:");
|
|
150
|
+
console.log(
|
|
151
|
+
`Host: ${finalAakaarJson.host} - The server URL where components are hosted`
|
|
152
|
+
);
|
|
153
|
+
console.log(
|
|
154
|
+
`Core path: ${finalAakaarJson.core.path} - Where core design system files will be created`
|
|
155
|
+
);
|
|
156
|
+
console.log(
|
|
157
|
+
`Core import: ${finalAakaarJson.core.import} - How components will import core design system files`
|
|
158
|
+
);
|
|
159
|
+
console.log(
|
|
160
|
+
`Token color: ${finalAakaarJson.tokens.color} - Primary brand color in hex format`
|
|
161
|
+
);
|
|
162
|
+
console.log(
|
|
163
|
+
`Token output: ${finalAakaarJson.tokens.output} - Where CSS design tokens will be generated`
|
|
164
|
+
);
|
|
165
|
+
console.log(
|
|
166
|
+
`React components output: ${finalAakaarJson.react.output} - Where React components will be created`
|
|
167
|
+
);
|
|
168
|
+
readline.question(
|
|
169
|
+
"Press y to proceed with the paths specified in aakaar.json or n to cancel and edit aakaar.json: ",
|
|
170
|
+
(answer) => {
|
|
171
|
+
readline.close();
|
|
172
|
+
resolve(answer.toLowerCase());
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
});
|
|
176
|
+
if (proceed !== "y") {
|
|
177
|
+
console.log(
|
|
178
|
+
"Setup cancelled. Run the setup command again to configure the project. You can also edit the aakaar.json file to change the paths, it will not be overwritten."
|
|
179
|
+
);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const hostUrl2 = finalAakaarJson.host;
|
|
183
|
+
const coreFile = await fetch(`${hostUrl2}/registry/core.json`);
|
|
184
|
+
const coreFileJson = await coreFile.json();
|
|
185
|
+
const firstCoreFile = coreFileJson.files[0];
|
|
186
|
+
const corePath = `${finalAakaarJson.core.path}`;
|
|
187
|
+
if (!existsSync3(corePath)) {
|
|
188
|
+
mkdirSync2(corePath, { recursive: true });
|
|
189
|
+
}
|
|
190
|
+
writeFileSync2(`${corePath}/${firstCoreFile.name}`, firstCoreFile.content, {
|
|
191
|
+
encoding: "utf-8",
|
|
192
|
+
flag: "w"
|
|
193
|
+
});
|
|
194
|
+
console.log("Core file created successfully");
|
|
195
|
+
console.log("Setup completed successfully");
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
// src/lib/operations/commands/token.ts
|
|
199
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
200
|
+
import { runCss } from "@aakaar/dictionary";
|
|
201
|
+
import { Command as Command3 } from "commander";
|
|
202
|
+
var token = new Command3().name("token").description("build design tokens for your project").option(
|
|
203
|
+
"-c, --color <color>",
|
|
204
|
+
"Hex code of the source color, example, 006875. If it is not provided, the default color is used i.e. 006875"
|
|
205
|
+
).option("-o, --output <output>", "Output path for generated tokens.").action(async ({ color, output }) => {
|
|
206
|
+
verify();
|
|
207
|
+
const finalColor = color || config.tokens.color;
|
|
208
|
+
const finalOutput = output || config.tokens.output;
|
|
209
|
+
console.log(`Generating tokens for color: ${finalColor}`);
|
|
210
|
+
const cssOutput = runCss(`#${finalColor}`);
|
|
211
|
+
if (!existsSync4(finalOutput)) {
|
|
212
|
+
mkdirSync3(finalOutput, {
|
|
213
|
+
recursive: true
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
writeFileSync3(`${finalOutput}/tokens.css`, cssOutput, {
|
|
217
|
+
encoding: "utf8",
|
|
218
|
+
flag: "w"
|
|
219
|
+
});
|
|
220
|
+
console.log(`Tokens generated at ${finalOutput}/tokens.css \u{1F680}`);
|
|
221
|
+
console.log(`Don't forget to include the generated CSS in your project!`);
|
|
222
|
+
console.log(`@import './<path>/tokens.css';
|
|
223
|
+
`);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
// src/index.ts
|
|
227
|
+
process.on("SIGINT", () => process.exit(0));
|
|
228
|
+
process.on("SIGTERM", () => process.exit(0));
|
|
229
|
+
async function main() {
|
|
230
|
+
const program = new Command4().name("Aakaar UI").description("Build design system for your project");
|
|
231
|
+
program.addCommand(token);
|
|
232
|
+
program.addCommand(add);
|
|
233
|
+
program.addCommand(setup);
|
|
234
|
+
program.parse();
|
|
235
|
+
}
|
|
236
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aakaar/cli",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"aakaar": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.cjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@antfu/ni": "^0.23.2",
|
|
23
|
+
"commander": "^12.1.0",
|
|
24
|
+
"execa": "^9.6.0",
|
|
25
|
+
"signal-exit": "^4.1.0",
|
|
26
|
+
"@aakaar/dictionary": "0.0.1",
|
|
27
|
+
"@aakaar/global": "0.0.1"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@biomejs/biome": "^1.9.4",
|
|
31
|
+
"@tsconfig/node22": "^22.0.2",
|
|
32
|
+
"tsup": "^8.0.0",
|
|
33
|
+
"typescript": "^5.0.0"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
37
|
+
"clean": "rm -rf dist",
|
|
38
|
+
"clean:nm": "rm -rf node_modules",
|
|
39
|
+
"dev": "tsup src/index.ts --watch --format esm,cjs --dts",
|
|
40
|
+
"ts": "tsc --noEmit",
|
|
41
|
+
"publish:internet": "pnpm publish --access public",
|
|
42
|
+
"publish:local": "pnpm publish --registry http://localhost:4873"
|
|
43
|
+
}
|
|
44
|
+
}
|