@aristobyte-ui/cli 2.13.2 → 2.14.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/.tsbuildinfo +1 -0
- package/CHANGELOG.md +229 -0
- package/LICENSE +21 -0
- package/commands/add.js +51 -0
- package/commands/doctor.js +105 -0
- package/commands/env.js +122 -0
- package/commands/init.js +130 -0
- package/commands/list.js +95 -0
- package/commands/remove.js +46 -0
- package/commands/upgrade.js +38 -0
- package/index.js +140 -0
- package/package.json +7 -22
- package/utils/checkVersion.js +8 -0
- package/utils/colors.js +58 -0
- package/{es/utils → utils}/compareVersions.js +3 -3
- package/utils/getBanner.js +92 -0
- package/utils/getCurrentPackageManager.js +16 -0
- package/utils/installPackage.js +27 -0
- package/utils/parseHelp.js +31 -0
- package/utils/typography.js +9 -0
- package/es/.tsbuildinfo +0 -1
- package/es/commands/add.js +0 -106
- package/es/commands/doctor.js +0 -166
- package/es/commands/env.js +0 -175
- package/es/commands/init.js +0 -180
- package/es/commands/list.js +0 -195
- package/es/commands/remove.js +0 -100
- package/es/commands/upgrade.js +0 -122
- package/es/index.js +0 -212
- package/es/utils/checkVersion.js +0 -8
- package/es/utils/colors.js +0 -77
- package/es/utils/getBanner.js +0 -30
- package/es/utils/getCurrentPackageManager.js +0 -55
- package/es/utils/installPackage.js +0 -75
- package/es/utils/parseHelp.js +0 -22
- package/es/utils/typography.js +0 -9
- package/lib/.tsbuildinfo +0 -1
- package/lib/commands/add.d.ts +0 -1
- package/lib/commands/add.js +0 -112
- package/lib/commands/doctor.d.ts +0 -1
- package/lib/commands/doctor.js +0 -172
- package/lib/commands/env.d.ts +0 -1
- package/lib/commands/env.js +0 -181
- package/lib/commands/init.d.ts +0 -1
- package/lib/commands/init.js +0 -186
- package/lib/commands/list.d.ts +0 -2
- package/lib/commands/list.js +0 -202
- package/lib/commands/remove.d.ts +0 -1
- package/lib/commands/remove.js +0 -106
- package/lib/commands/upgrade.d.ts +0 -1
- package/lib/commands/upgrade.js +0 -128
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -217
- package/lib/utils/checkVersion.d.ts +0 -1
- package/lib/utils/checkVersion.js +0 -14
- package/lib/utils/colors.d.ts +0 -14
- package/lib/utils/colors.js +0 -96
- package/lib/utils/compareVersions.d.ts +0 -1
- package/lib/utils/compareVersions.js +0 -14
- package/lib/utils/getBanner.d.ts +0 -1
- package/lib/utils/getBanner.js +0 -33
- package/lib/utils/getCurrentPackageManager.d.ts +0 -2
- package/lib/utils/getCurrentPackageManager.js +0 -61
- package/lib/utils/getDescription.d.ts +0 -1
- package/lib/utils/getDescription.js +0 -24
- package/lib/utils/getTip.d.ts +0 -1
- package/lib/utils/getTip.js +0 -24
- package/lib/utils/installPackage.d.ts +0 -1
- package/lib/utils/installPackage.js +0 -78
- package/lib/utils/parseHelp.d.ts +0 -2
- package/lib/utils/parseHelp.js +0 -25
- package/lib/utils/typography.d.ts +0 -2
- package/lib/utils/typography.js +0 -13
- /package/{es/commands → commands}/add.d.ts +0 -0
- /package/{es/commands → commands}/doctor.d.ts +0 -0
- /package/{es/commands → commands}/env.d.ts +0 -0
- /package/{es/commands → commands}/init.d.ts +0 -0
- /package/{es/commands → commands}/list.d.ts +0 -0
- /package/{es/commands → commands}/remove.d.ts +0 -0
- /package/{es/commands → commands}/upgrade.d.ts +0 -0
- /package/{es/index.d.ts → index.d.ts} +0 -0
- /package/{es/utils → utils}/checkVersion.d.ts +0 -0
- /package/{es/utils → utils}/colors.d.ts +0 -0
- /package/{es/utils → utils}/compareVersions.d.ts +0 -0
- /package/{es/utils → utils}/getBanner.d.ts +0 -0
- /package/{es/utils → utils}/getCurrentPackageManager.d.ts +0 -0
- /package/{es/utils → utils}/getDescription.d.ts +0 -0
- /package/{es/utils → utils}/getDescription.js +0 -0
- /package/{es/utils → utils}/getTip.d.ts +0 -0
- /package/{es/utils → utils}/getTip.js +0 -0
- /package/{es/utils → utils}/installPackage.d.ts +0 -0
- /package/{es/utils → utils}/parseHelp.d.ts +0 -0
- /package/{es/utils → utils}/typography.d.ts +0 -0
package/commands/init.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { execa } from 'execa';
|
|
2
|
+
import { select, text, spinner } from "@clack/prompts";
|
|
3
|
+
import color from "picocolors";
|
|
4
|
+
const TEMPLATES = [
|
|
5
|
+
{
|
|
6
|
+
id: "aristobyte-ui-template-nextjs-15-app-router",
|
|
7
|
+
name: "Next App Router",
|
|
8
|
+
desc: "A Next.js 15 with app-router directory template pre-configured with AristoByteUI.",
|
|
9
|
+
repo: "https://github.com/aristobyte-team/aristobyte-ui-template-nextjs-15-app-router.git",
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
id: "aristobyte-ui-template-nextjs-15-pages",
|
|
13
|
+
name: "Next Pages",
|
|
14
|
+
desc: "A Next.js 15 with pages directory template pre-configured with AristoByteUI.",
|
|
15
|
+
repo: "https://github.com/aristobyte-team/aristobyte-ui-template-nextjs-15-pages.git",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: "aristobyte-ui-template-vite",
|
|
19
|
+
name: "Vite",
|
|
20
|
+
desc: "A Vite template pre-configured with AristoByteUI.",
|
|
21
|
+
repo: "https://github.com/aristobyte-team/aristobyte-ui-template-vite.git",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: "aristobyte-ui-template-vike",
|
|
25
|
+
name: "Vike",
|
|
26
|
+
desc: "A Vike template pre-configured with AristoByteUI.",
|
|
27
|
+
repo: "https://github.com/aristobyte-team/aristobyte-ui-template-vike.git",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "aristobyte-ui-template-astro",
|
|
31
|
+
name: "Astro",
|
|
32
|
+
desc: "An Astro template pre-configured with AristoByteUI.",
|
|
33
|
+
repo: "https://github.com/aristobyte-team/aristobyte-ui-template-astro.git",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: "aristobyte-ui-template-rsbuild",
|
|
37
|
+
name: "RS Build",
|
|
38
|
+
desc: "An RS Build template pre-configured with AristoByteUI.",
|
|
39
|
+
repo: "https://github.com/aristobyte-team/aristobyte-ui-template-rsbuild.git",
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
const PACKAGE_MANAGERS = ["npm", "yarn", "pnpm", "bun"];
|
|
43
|
+
const DEFAULT_NAME = "aristobyte-ui-app";
|
|
44
|
+
export async function init(myProjectName, options) {
|
|
45
|
+
if (options.listTemplates) {
|
|
46
|
+
console.log(`${color.cyan("Available templates:")}
|
|
47
|
+
${TEMPLATES.map((t) => `${color.green("◇")} ${t.id.split("aristobyte-ui-template-")[1]} - ${color.gray(t.desc)}`).join("\n")}`);
|
|
48
|
+
process.exit(0);
|
|
49
|
+
}
|
|
50
|
+
if (options.listPackageManagers) {
|
|
51
|
+
console.log(`${color.cyan("Available package managers:")}
|
|
52
|
+
${PACKAGE_MANAGERS.map((pm) => `${color.green("◇")} ${pm}`).join("\n")}`);
|
|
53
|
+
process.exit(0);
|
|
54
|
+
}
|
|
55
|
+
console.log(color.cyan("┌ Create a new project"));
|
|
56
|
+
let projectName = myProjectName || DEFAULT_NAME;
|
|
57
|
+
if (!myProjectName) {
|
|
58
|
+
projectName = (await text({
|
|
59
|
+
message: "New project name (Enter to skip with default name)",
|
|
60
|
+
placeholder: DEFAULT_NAME,
|
|
61
|
+
defaultValue: DEFAULT_NAME,
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
console.log(`${color.gray("│")}
|
|
66
|
+
${color.green("◇")} ${color.white("Your project name is:")}
|
|
67
|
+
${color.gray("│")} ${color.green(projectName)}`);
|
|
68
|
+
}
|
|
69
|
+
let template = TEMPLATES.find((t) => t.id ===
|
|
70
|
+
`aristobyte-ui-template-${options?.template?.toLowerCase()?.replaceAll(" ", "")}`);
|
|
71
|
+
if (!template) {
|
|
72
|
+
const templateIndex = await select({
|
|
73
|
+
message: "Select a template (Enter to select)",
|
|
74
|
+
options: TEMPLATES.map((t, i) => ({
|
|
75
|
+
value: i.toString(),
|
|
76
|
+
label: `${t.name} (${t.desc})`,
|
|
77
|
+
})),
|
|
78
|
+
});
|
|
79
|
+
template = TEMPLATES[Number(templateIndex)];
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
console.log(`${color.gray("│")}
|
|
83
|
+
${color.green("◇")} ${color.white("Template selected:")}
|
|
84
|
+
${color.gray("│")} ${color.green(template.name)}`);
|
|
85
|
+
}
|
|
86
|
+
let packageManager = PACKAGE_MANAGERS.find((pm) => pm.toLowerCase() === options.packageManager?.toLowerCase());
|
|
87
|
+
if (!packageManager) {
|
|
88
|
+
const packageManagerIndex = await select({
|
|
89
|
+
message: "Select a package manager (Enter to select)",
|
|
90
|
+
options: PACKAGE_MANAGERS.map((pm, i) => ({
|
|
91
|
+
value: i.toString(),
|
|
92
|
+
label: pm,
|
|
93
|
+
})),
|
|
94
|
+
});
|
|
95
|
+
packageManager = PACKAGE_MANAGERS[Number(packageManagerIndex)];
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
console.log(`${color.gray("│")}
|
|
99
|
+
${color.green("◇")} ${color.white("Package manager selected:")}
|
|
100
|
+
${color.gray("│")} ${color.green(packageManager)}`);
|
|
101
|
+
}
|
|
102
|
+
console.log(`${color.gray("│")}
|
|
103
|
+
${color.green("◇")} ${color.cyan("Template created successfully!")}
|
|
104
|
+
${color.gray("│")}`);
|
|
105
|
+
const s = spinner();
|
|
106
|
+
try {
|
|
107
|
+
s.start(`Preparing '${template.name}' with ${packageManager} configuration...`);
|
|
108
|
+
await execa("git", [
|
|
109
|
+
"clone",
|
|
110
|
+
"--branch",
|
|
111
|
+
packageManager,
|
|
112
|
+
"--single-branch",
|
|
113
|
+
template.repo,
|
|
114
|
+
projectName,
|
|
115
|
+
], { stdio: "ignore" });
|
|
116
|
+
await execa("rm", ["-rf", ".git"], { cwd: projectName, stdio: "ignore" });
|
|
117
|
+
s.stop(`${color.green("✔ Project initialized successfully!")}`);
|
|
118
|
+
console.log(`
|
|
119
|
+
${color.gray("│")}
|
|
120
|
+
${color.green("◇")} ${color.cyan("To get started:")}
|
|
121
|
+
${color.gray("│")}
|
|
122
|
+
${color.gray("├─")} ${color.white("cd " + projectName)}
|
|
123
|
+
${color.gray("├─")} ${color.white(`${packageManager} install`)}
|
|
124
|
+
${color.gray("├─")} ${color.white(`${packageManager} run dev`)}`);
|
|
125
|
+
}
|
|
126
|
+
catch (err) {
|
|
127
|
+
s.stop();
|
|
128
|
+
console.error(color.red("× Failed to initialize project"), err);
|
|
129
|
+
}
|
|
130
|
+
}
|
package/commands/list.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import color from 'picocolors';
|
|
3
|
+
import { getCurrentPackageManager } from '../utils/getCurrentPackageManager.js';
|
|
4
|
+
export async function remoteList() { }
|
|
5
|
+
export async function list(options, endBlock) {
|
|
6
|
+
let handled = false;
|
|
7
|
+
if (options.all) {
|
|
8
|
+
handled = true;
|
|
9
|
+
const url = 'https://registry.npmjs.org/-/org/aristobyte-ui/package';
|
|
10
|
+
const omit = ['cli', 'react'];
|
|
11
|
+
try {
|
|
12
|
+
const res = await fetch(url);
|
|
13
|
+
if (!res.ok)
|
|
14
|
+
throw new Error(`Registry request failed: ${res.status}`);
|
|
15
|
+
const data = await res.json();
|
|
16
|
+
const packages = Object.keys(data)
|
|
17
|
+
.map((dep) => dep.split('/')[1])
|
|
18
|
+
.filter((dep) => !omit.includes(dep))
|
|
19
|
+
.sort();
|
|
20
|
+
console.log(`${color.green('◇')} ${color.white('Listing AristoByteUI packages:')}
|
|
21
|
+
${packages.map((dep) => `${color.gray('|')} ${color.cyan(dep)}`).join('\n')}`);
|
|
22
|
+
}
|
|
23
|
+
catch (err) {
|
|
24
|
+
console.error(color.red('× Failed to fetch package list from npm registry'));
|
|
25
|
+
console.error(color.dim(String(err)));
|
|
26
|
+
}
|
|
27
|
+
if (endBlock)
|
|
28
|
+
console.log(color.green('◇'));
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
31
|
+
if (options.installed) {
|
|
32
|
+
handled = true;
|
|
33
|
+
try {
|
|
34
|
+
const pkgJson = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
|
|
35
|
+
const deps = pkgJson.dependencies || {};
|
|
36
|
+
const aristobyteDeps = Object.keys(deps)
|
|
37
|
+
.filter((d) => d.startsWith('@aristobyte-ui/'))
|
|
38
|
+
.map((dep) => (dep.includes('react') ? 'all' : dep.split('/')[1]));
|
|
39
|
+
console.log(`${color.green('◇')} ${color.white('Listing installed AristoByteUI packages:')}
|
|
40
|
+
${aristobyteDeps.map((dep) => `${color.gray('|')} ${color.cyan(dep)}`).join('\n')}`);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
console.error(color.red('× Failed to list packages'), err);
|
|
44
|
+
}
|
|
45
|
+
if (endBlock)
|
|
46
|
+
console.log(color.green('◇'));
|
|
47
|
+
process.exit(0);
|
|
48
|
+
}
|
|
49
|
+
if (options.outdated) {
|
|
50
|
+
handled = true;
|
|
51
|
+
const packagesToUpdate = [];
|
|
52
|
+
try {
|
|
53
|
+
const pkgJson = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
|
|
54
|
+
const deps = pkgJson.dependencies || {};
|
|
55
|
+
const installed = Object.keys(deps).filter((d) => d.startsWith('@aristobyte-ui/'));
|
|
56
|
+
if (installed.length === 0) {
|
|
57
|
+
console.log(color.yellow('No AristoByteUI packages installed.'));
|
|
58
|
+
process.exit(0);
|
|
59
|
+
}
|
|
60
|
+
console.log(`${color.green('◇')} ${color.white('Checking for outdated AristoByteUI packages...')}`);
|
|
61
|
+
for (const pkg of installed) {
|
|
62
|
+
const localVersion = deps[pkg].replace(/^[^\d]*/, '');
|
|
63
|
+
const registryUrl = `https://registry.npmjs.org/${pkg}`;
|
|
64
|
+
try {
|
|
65
|
+
const res = await fetch(registryUrl);
|
|
66
|
+
if (!res.ok)
|
|
67
|
+
throw new Error(`Registry request failed: ${res.status}`);
|
|
68
|
+
const data = await res.json();
|
|
69
|
+
const latest = data['dist-tags']?.latest;
|
|
70
|
+
if (!latest)
|
|
71
|
+
continue;
|
|
72
|
+
if (latest !== localVersion) {
|
|
73
|
+
const p = pkg.replace('@aristobyte-ui/', '');
|
|
74
|
+
packagesToUpdate.push([p, latest]);
|
|
75
|
+
console.log(`${color.gray('|')} ${color.cyan(p)} ` + `${color.red(localVersion)} → ${color.green(latest)}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
console.error(color.red(`× Failed to check ${pkg} on npm registry`), err);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (err) {
|
|
84
|
+
console.error(color.red('× Failed to check outdated packages'), err);
|
|
85
|
+
}
|
|
86
|
+
const pkgManager = getCurrentPackageManager();
|
|
87
|
+
if (endBlock)
|
|
88
|
+
console.log(`${color.gray('|')}
|
|
89
|
+
${color.green('◇')} ${packagesToUpdate.length > 0 ? color.gray(`Tip: run '${pkgManager} upgrade ${packagesToUpdate.map((p) => `${p[0]}@${p[1]}`).join(' ')}'`) : color.green('✔ Everything is up to date!')}`);
|
|
90
|
+
process.exit(0);
|
|
91
|
+
}
|
|
92
|
+
if (!handled) {
|
|
93
|
+
console.log(color.gray("No option provided. Use 'aristobyte-ui list --help' for usage."));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { getCurrentPackageManager } from '../utils/getCurrentPackageManager.js';
|
|
2
|
+
import { spinner, text } from '@clack/prompts';
|
|
3
|
+
import { execa } from 'execa';
|
|
4
|
+
import color from 'picocolors';
|
|
5
|
+
import { list } from './list.js';
|
|
6
|
+
export async function remove(component, options) {
|
|
7
|
+
if (options.list) {
|
|
8
|
+
await list({ installed: true }, true);
|
|
9
|
+
}
|
|
10
|
+
const pkgManager = getCurrentPackageManager();
|
|
11
|
+
if (options.packageManager) {
|
|
12
|
+
console.log(`${color.cyan('Current package manager:')}
|
|
13
|
+
${color.green('◇')} ${pkgManager}`);
|
|
14
|
+
process.exit(0);
|
|
15
|
+
}
|
|
16
|
+
const s = spinner();
|
|
17
|
+
let packageName;
|
|
18
|
+
if (!component) {
|
|
19
|
+
console.log(`${color.green('◇')} ${color.white('You did not specify, which package should be removed')}
|
|
20
|
+
${color.gray('|')} ${color.gray('Please select one of the installed packages below to proceed.')}
|
|
21
|
+
${color.gray('|')}`);
|
|
22
|
+
await list({ installed: true });
|
|
23
|
+
packageName = (await text({
|
|
24
|
+
message: `Component name to remove (Required filled)`,
|
|
25
|
+
placeholder: '<package-name>',
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
packageName = component;
|
|
30
|
+
}
|
|
31
|
+
if (!packageName) {
|
|
32
|
+
console.log(color.red(`Invalid Package name. <package-name> should be specified:\naristobyte-ui remove <package-name>`));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const pkgName = packageName === 'all' ? '@aristobyte-ui/react' : `@aristobyte-ui/${packageName}`;
|
|
37
|
+
s.start(`Removing ${pkgName}...`);
|
|
38
|
+
await execa(pkgManager, ['remove', pkgName], { stdio: 'inherit' });
|
|
39
|
+
s.stop();
|
|
40
|
+
console.log(color.green(`✔ ${pkgName} removed successfully!`));
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
s.stop();
|
|
44
|
+
console.error(color.red(`× Failed to remove component ${packageName}`), err);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getCurrentPackageManager } from '../utils/getCurrentPackageManager.js';
|
|
2
|
+
import { spinner } from '@clack/prompts';
|
|
3
|
+
import { execa } from 'execa';
|
|
4
|
+
import color from 'picocolors';
|
|
5
|
+
export async function upgrade(component, options) {
|
|
6
|
+
if (!component && !options.all) {
|
|
7
|
+
console.error(color.red('× No component specified for upgrade.'));
|
|
8
|
+
console.log(color.gray("Use: 'aristobyte-ui upgrade <component>' or 'aristobyte-ui upgrade --all'"));
|
|
9
|
+
process.exit(0);
|
|
10
|
+
}
|
|
11
|
+
const s = spinner();
|
|
12
|
+
const pkgManager = getCurrentPackageManager();
|
|
13
|
+
try {
|
|
14
|
+
const isAll = options.all || component === 'all';
|
|
15
|
+
const targets = isAll ? ['@aristobyte-ui/react'] : component ? [`@aristobyte-ui/${component}`] : [];
|
|
16
|
+
if (targets.length === 0) {
|
|
17
|
+
console.error(color.red('× No component specified for upgrade.'));
|
|
18
|
+
console.log(color.gray('Use: aristobyte-ui upgrade <component> or --all'));
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
const versionSuffix = options.to ? `@${options.to}` : '';
|
|
22
|
+
const sLabel = isAll ? 'Upgrading all AristoByteUI components...' : `Upgrading ${targets.join(', ')}...`;
|
|
23
|
+
s.start(sLabel);
|
|
24
|
+
for (const pkg of targets) {
|
|
25
|
+
const fullSpecifier = `${pkg}${versionSuffix}`;
|
|
26
|
+
await execa(pkgManager, ['upgrade', fullSpecifier], {
|
|
27
|
+
stdio: 'inherit',
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
s.stop();
|
|
31
|
+
console.log(color.green(`✔ Upgrade complete${options.to ? ` → version ${options.to}` : ''}!`));
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
s.stop();
|
|
35
|
+
console.error(color.red(`× Upgrade failed.`));
|
|
36
|
+
console.error(color.dim(String(err)));
|
|
37
|
+
}
|
|
38
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
|
+
import { resolve, dirname } from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { add } from './commands/add.js';
|
|
7
|
+
import { init } from './commands/init.js';
|
|
8
|
+
import { remove } from './commands/remove.js';
|
|
9
|
+
import { upgrade } from './commands/upgrade.js';
|
|
10
|
+
import { list } from './commands/list.js';
|
|
11
|
+
import { doctor } from './commands/doctor.js';
|
|
12
|
+
import { env } from './commands/env.js';
|
|
13
|
+
import { logoSmallGradient, logo3, logo4, darkGrey, lightGrey } from './utils/colors.js';
|
|
14
|
+
import { usage } from './utils/typography.js';
|
|
15
|
+
import { parseHelp } from './utils/parseHelp.js';
|
|
16
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
17
|
+
const __dirname = dirname(__filename);
|
|
18
|
+
const pkgPath = resolve(__dirname, '../package.json');
|
|
19
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
20
|
+
const COMMANDS = ['init', 'add', 'remove', 'upgrade', 'list', 'doctor', 'env', 'help'];
|
|
21
|
+
const aristobyteui = new Command();
|
|
22
|
+
aristobyteui
|
|
23
|
+
.name('aristobyte-ui')
|
|
24
|
+
.usage(usage(['command', 'options']))
|
|
25
|
+
.description('Create new AristoByteUI projects or manage existing projects with full control\n over components, dependencies, and UI stack configuration. Supports initialization,\n addition, removal, upgrading of components, and project diagnostics.')
|
|
26
|
+
.version(pkg.version ?? '0.0.0', '-V, --version', 'Output the CLI version')
|
|
27
|
+
.helpOption('-H, --help', 'Show help information')
|
|
28
|
+
.configureHelp({
|
|
29
|
+
formatHelp: (cmd, helper) => parseHelp(cmd, helper),
|
|
30
|
+
});
|
|
31
|
+
aristobyteui
|
|
32
|
+
.command('init [myProjectName]')
|
|
33
|
+
.usage(usage(['options', 'myProjectName']))
|
|
34
|
+
.description('Initialize a new AristoByteUI project')
|
|
35
|
+
.option('-LT, --list-templates', 'Display a list of available templates')
|
|
36
|
+
.option('-LPM, --list-package-managers', 'Display a list of available package managers')
|
|
37
|
+
.option('-T, --template <templateName>', 'Specify a template to use')
|
|
38
|
+
.option('-P, --package-manager <packageManager>', 'Select a package manager (npm, yarn, pnpm, bun)')
|
|
39
|
+
.configureHelp({
|
|
40
|
+
formatHelp: (cmd, helper) => parseHelp(cmd, helper),
|
|
41
|
+
})
|
|
42
|
+
.action(init);
|
|
43
|
+
aristobyteui
|
|
44
|
+
.command('add [component]')
|
|
45
|
+
.usage(usage(['options', 'components...']))
|
|
46
|
+
.description('Add a UI component')
|
|
47
|
+
.option('-L, --list', 'Display a list of available packages, to be added')
|
|
48
|
+
.option('-P, --package-manager', 'Show the package manager used in current project')
|
|
49
|
+
.configureHelp({
|
|
50
|
+
formatHelp: (cmd, helper) => parseHelp(cmd, helper),
|
|
51
|
+
})
|
|
52
|
+
.action(add);
|
|
53
|
+
aristobyteui
|
|
54
|
+
.command('remove [component]')
|
|
55
|
+
.usage(usage(['options', 'components...']))
|
|
56
|
+
.description('Remove a UI component')
|
|
57
|
+
.option('-L, --list', 'Display a list of installed packages, to be removed')
|
|
58
|
+
.option('-P, --package-manager', 'Show the package manager used in current project')
|
|
59
|
+
.configureHelp({
|
|
60
|
+
formatHelp: (cmd, helper) => parseHelp(cmd, helper),
|
|
61
|
+
})
|
|
62
|
+
.action(remove);
|
|
63
|
+
aristobyteui
|
|
64
|
+
.command('upgrade [component]')
|
|
65
|
+
.usage(usage(['options', 'components...']))
|
|
66
|
+
.description('Upgrade a UI component')
|
|
67
|
+
.option('-A, --all', 'Upgrade all AristoByteUI components')
|
|
68
|
+
.option('-T, --to <version>', 'Upgrade to a specific version')
|
|
69
|
+
.configureHelp({
|
|
70
|
+
formatHelp: (cmd, helper) => parseHelp(cmd, helper),
|
|
71
|
+
})
|
|
72
|
+
.action(upgrade);
|
|
73
|
+
aristobyteui
|
|
74
|
+
.command('list')
|
|
75
|
+
.usage(usage(['options']))
|
|
76
|
+
.description('List installed components')
|
|
77
|
+
.option('-A, --all', 'Display the list of all packages')
|
|
78
|
+
.option('-I, --installed', 'Display the list of installed packages')
|
|
79
|
+
.option('-O, --outdated', 'Check for available updates')
|
|
80
|
+
.configureHelp({
|
|
81
|
+
formatHelp: (cmd, helper) => parseHelp(cmd, helper),
|
|
82
|
+
})
|
|
83
|
+
.action((options) => list(options, true));
|
|
84
|
+
aristobyteui
|
|
85
|
+
.command('doctor')
|
|
86
|
+
.usage(usage(['options']))
|
|
87
|
+
.description('Check system and project health')
|
|
88
|
+
.option('-A, --all', 'Run all diagnostics')
|
|
89
|
+
.option('-C, --configs', 'Validate project config files')
|
|
90
|
+
.option('-D, --deps', 'Validate installed AristoByteUI dependencies')
|
|
91
|
+
.option('-J, --json', 'Output diagnostics as JSON')
|
|
92
|
+
.option('-N, --network', 'Verify registry/network connectivity')
|
|
93
|
+
.option('-P, --pm', 'Check package manager state')
|
|
94
|
+
.option('-S, --system', 'Check system environment')
|
|
95
|
+
.configureHelp({
|
|
96
|
+
formatHelp: (cmd, helper) => parseHelp(cmd, helper),
|
|
97
|
+
})
|
|
98
|
+
.action(doctor);
|
|
99
|
+
aristobyteui
|
|
100
|
+
.command('env')
|
|
101
|
+
.usage(usage(['options']))
|
|
102
|
+
.description('Display environment info')
|
|
103
|
+
.option('-A, --all', 'Display all environment diagnostics')
|
|
104
|
+
.option('-J, --json', 'Output environment info as JSON')
|
|
105
|
+
.option('-M, --pm', 'Show package manager details')
|
|
106
|
+
.option('-N, --network', 'Check registry/network connectivity')
|
|
107
|
+
.option('-P, --packages', 'Show installed AristoByteUI packages')
|
|
108
|
+
.option('-S, --system', 'Show system information')
|
|
109
|
+
.configureHelp({
|
|
110
|
+
formatHelp: (cmd, helper) => parseHelp(cmd, helper),
|
|
111
|
+
})
|
|
112
|
+
.action(env);
|
|
113
|
+
aristobyteui
|
|
114
|
+
.command('help')
|
|
115
|
+
.usage(usage(['options']))
|
|
116
|
+
.description('Display help for command')
|
|
117
|
+
.action(env);
|
|
118
|
+
aristobyteui.command('help', { hidden: true });
|
|
119
|
+
aristobyteui.exitOverride(async (err) => {
|
|
120
|
+
if (err.code === 'commander.unknownCommand') {
|
|
121
|
+
console.error(logoSmallGradient(' ◆ Possible commands are: \n'), ...COMMANDS.map((cmd) => cmd === err.message.split('Did you mean ')[1].split('?')[0]
|
|
122
|
+
? `${logoSmallGradient('│ ')}${logo4('● aristobyte-ui')} ${logo4(`${cmd}`)}\n`
|
|
123
|
+
: `${logoSmallGradient('│ ○ aristobyte-ui')} ${logo3(`${cmd}`)}\n`));
|
|
124
|
+
}
|
|
125
|
+
process.exit(1);
|
|
126
|
+
});
|
|
127
|
+
(async () => {
|
|
128
|
+
const args = process.argv.slice(2);
|
|
129
|
+
if (args.length === 0) {
|
|
130
|
+
aristobyteui.outputHelp();
|
|
131
|
+
process.exit(0);
|
|
132
|
+
}
|
|
133
|
+
try {
|
|
134
|
+
await aristobyteui.parseAsync(args, { from: 'user' });
|
|
135
|
+
}
|
|
136
|
+
catch (err) {
|
|
137
|
+
console.error(darkGrey('Error:'), lightGrey(err.message));
|
|
138
|
+
process.exit(1);
|
|
139
|
+
}
|
|
140
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aristobyte-ui/cli",
|
|
3
3
|
"description": "The official AristoByteUI CLI — initialize projects, install, upgrade, remove, and manage UI components seamlessly.",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.14.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
7
7
|
"author": "AristoByte <info@aristobyte.com>",
|
|
@@ -30,39 +30,24 @@
|
|
|
30
30
|
"project-bootstrap",
|
|
31
31
|
"package-management"
|
|
32
32
|
],
|
|
33
|
-
"files": [
|
|
34
|
-
"es",
|
|
35
|
-
"lib",
|
|
36
|
-
"bin"
|
|
37
|
-
],
|
|
38
33
|
"publishConfig": {
|
|
39
34
|
"access": "public"
|
|
40
35
|
},
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"types": "es/index.d.ts",
|
|
36
|
+
"type": "module",
|
|
37
|
+
"main": "index.js",
|
|
44
38
|
"bin": {
|
|
45
|
-
"aristobyte-ui": "
|
|
46
|
-
},
|
|
47
|
-
"peerDependencies": {
|
|
48
|
-
"react": "^19.1.0",
|
|
49
|
-
"react-dom": "^19.1.0",
|
|
50
|
-
"sass": "^1.97.3"
|
|
39
|
+
"aristobyte-ui": "index.js"
|
|
51
40
|
},
|
|
52
41
|
"dependencies": {
|
|
53
42
|
"@clack/prompts": "^0.11.0",
|
|
54
|
-
"axios": "^1.6.0",
|
|
55
43
|
"chalk": "^4.1.2",
|
|
56
44
|
"commander": "^10",
|
|
57
45
|
"execa": "^7",
|
|
58
46
|
"gradient-string": "^3.0.0"
|
|
59
47
|
},
|
|
60
48
|
"exports": {
|
|
61
|
-
".":
|
|
62
|
-
"types": "./es/index.d.ts",
|
|
63
|
-
"import": "./es/index.js",
|
|
64
|
-
"require": "./lib/index.js"
|
|
65
|
-
},
|
|
49
|
+
".": "./index.js",
|
|
66
50
|
"./package.json": "./package.json"
|
|
67
|
-
}
|
|
51
|
+
},
|
|
52
|
+
"types": "index.d.ts"
|
|
68
53
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { compareVersions } from "./compareVersions.js";
|
|
2
|
+
import color from "picocolors";
|
|
3
|
+
export function checkVersion(name, version, minVersion) {
|
|
4
|
+
if (version === "unknown" || compareVersions(version, minVersion) < 0) {
|
|
5
|
+
return color.red(`× ${name} >= ${minVersion} required`);
|
|
6
|
+
}
|
|
7
|
+
return color.green(`✔ ${version}`);
|
|
8
|
+
}
|
package/utils/colors.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
import gradient from "gradient-string";
|
|
3
|
+
const LOGO_COLORS = ["#ffee27", "#fec800", "#f18e35", "#e95f32", "#e2312d"];
|
|
4
|
+
export function logo1(text) {
|
|
5
|
+
return chalk.hex(LOGO_COLORS[0])(text);
|
|
6
|
+
}
|
|
7
|
+
export function logo2(text) {
|
|
8
|
+
return chalk.hex(LOGO_COLORS[1])(text);
|
|
9
|
+
}
|
|
10
|
+
export function logo3(text) {
|
|
11
|
+
return chalk.hex(LOGO_COLORS[2])(text);
|
|
12
|
+
}
|
|
13
|
+
export function logo4(text) {
|
|
14
|
+
return chalk.hex(LOGO_COLORS[3])(text);
|
|
15
|
+
}
|
|
16
|
+
export function logo5(text) {
|
|
17
|
+
return chalk.hex(LOGO_COLORS[4])(text);
|
|
18
|
+
}
|
|
19
|
+
export function reset(text) {
|
|
20
|
+
return chalk.reset(text);
|
|
21
|
+
}
|
|
22
|
+
export function red(text) {
|
|
23
|
+
return chalk.redBright(text);
|
|
24
|
+
}
|
|
25
|
+
export function lightGrey(text) {
|
|
26
|
+
return chalk.hex("#afbfff")(text);
|
|
27
|
+
}
|
|
28
|
+
export function darkGrey(text) {
|
|
29
|
+
return chalk.hex("#7580aa")(text);
|
|
30
|
+
}
|
|
31
|
+
export function white(text) {
|
|
32
|
+
return chalk.hex("#cfd5edff")(text);
|
|
33
|
+
}
|
|
34
|
+
export function yellow(text) {
|
|
35
|
+
return chalk.yellow(text);
|
|
36
|
+
}
|
|
37
|
+
export function redBright(text) {
|
|
38
|
+
return chalk.redBright(text);
|
|
39
|
+
}
|
|
40
|
+
export function logoGradient(text) {
|
|
41
|
+
return gradient([
|
|
42
|
+
...LOGO_COLORS,
|
|
43
|
+
...LOGO_COLORS.reverse(),
|
|
44
|
+
...LOGO_COLORS,
|
|
45
|
+
...LOGO_COLORS.reverse(),
|
|
46
|
+
...LOGO_COLORS,
|
|
47
|
+
]).multiline(text);
|
|
48
|
+
}
|
|
49
|
+
export function logoSmallGradient(text) {
|
|
50
|
+
return gradient([
|
|
51
|
+
LOGO_COLORS[0],
|
|
52
|
+
LOGO_COLORS[1],
|
|
53
|
+
LOGO_COLORS[1],
|
|
54
|
+
LOGO_COLORS[0],
|
|
55
|
+
LOGO_COLORS[0],
|
|
56
|
+
LOGO_COLORS[1],
|
|
57
|
+
]).multiline(text);
|
|
58
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export function compareVersions(v1, v2) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
for (
|
|
2
|
+
const a = v1.replace(/^v/, "").split(".").map(Number);
|
|
3
|
+
const b = v2.replace(/^v/, "").split(".").map(Number);
|
|
4
|
+
for (let i = 0; i < 3; i++) {
|
|
5
5
|
if (a[i] > b[i])
|
|
6
6
|
return 1;
|
|
7
7
|
if (a[i] < b[i])
|