@aristobyte-ui/cli 1.0.112 → 2.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/bin/aristobyte-ui.js +3 -0
- package/dist/es/main/commands/add.js +106 -0
- package/dist/es/main/commands/doctor.js +166 -0
- package/dist/es/main/commands/env.js +175 -0
- package/dist/es/main/commands/init.js +180 -0
- package/dist/es/main/commands/list.js +195 -0
- package/dist/es/main/commands/remove.js +100 -0
- package/dist/es/main/commands/upgrade.js +122 -0
- package/dist/es/main/index.js +212 -0
- package/dist/es/main/utils/checkVersion.js +8 -0
- package/dist/es/main/utils/colors.js +77 -0
- package/dist/es/main/utils/compareVersions.js +11 -0
- package/dist/es/main/utils/getBanner.js +30 -0
- package/dist/es/main/utils/getCurrentPackageManager.js +55 -0
- package/dist/es/main/utils/getDescription.js +21 -0
- package/dist/es/main/utils/getTip.js +21 -0
- package/dist/es/main/utils/installPackage.js +75 -0
- package/dist/es/main/utils/parseHelp.js +22 -0
- package/dist/es/main/utils/typography.js +9 -0
- package/dist/lib/main/commands/add.js +112 -0
- package/dist/lib/main/commands/doctor.js +172 -0
- package/dist/lib/main/commands/env.js +181 -0
- package/dist/lib/main/commands/init.js +186 -0
- package/dist/lib/main/commands/list.js +202 -0
- package/dist/lib/main/commands/remove.js +106 -0
- package/dist/lib/main/commands/upgrade.js +128 -0
- package/dist/lib/main/index.js +217 -0
- package/dist/lib/main/utils/checkVersion.js +14 -0
- package/dist/lib/main/utils/colors.js +96 -0
- package/dist/lib/main/utils/compareVersions.js +14 -0
- package/dist/lib/main/utils/getBanner.js +33 -0
- package/dist/lib/main/utils/getCurrentPackageManager.js +61 -0
- package/dist/lib/main/utils/getDescription.js +24 -0
- package/dist/lib/main/utils/getTip.js +24 -0
- package/dist/lib/main/utils/installPackage.js +78 -0
- package/dist/lib/main/utils/parseHelp.js +25 -0
- package/dist/lib/main/utils/typography.js +13 -0
- package/package.json +12 -33
- package/dist/index.js +0 -1222
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -1221
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { spinner, text } from '@clack/prompts';
|
|
38
|
+
import { getCurrentPackageManager } from '../utils/getCurrentPackageManager';
|
|
39
|
+
import color from 'picocolors';
|
|
40
|
+
import { installPackage } from '../utils/installPackage';
|
|
41
|
+
import { list } from './list';
|
|
42
|
+
var DEFAULT_PACKAGE = 'all';
|
|
43
|
+
export function add(component, options) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
+
var pkgManager, s, packageName, pkgManager_1, pkgName, err_1;
|
|
46
|
+
return __generator(this, function (_a) {
|
|
47
|
+
switch (_a.label) {
|
|
48
|
+
case 0:
|
|
49
|
+
if (!options.list) return [3, 2];
|
|
50
|
+
return [4, list({ all: true }, true)];
|
|
51
|
+
case 1:
|
|
52
|
+
_a.sent();
|
|
53
|
+
_a.label = 2;
|
|
54
|
+
case 2:
|
|
55
|
+
pkgManager = getCurrentPackageManager();
|
|
56
|
+
if (options.packageManager) {
|
|
57
|
+
console.log("".concat(color.cyan('Current package manager:'), "\n").concat(color.green('◇'), " ").concat(pkgManager));
|
|
58
|
+
process.exit(0);
|
|
59
|
+
}
|
|
60
|
+
s = spinner();
|
|
61
|
+
packageName = DEFAULT_PACKAGE;
|
|
62
|
+
if (!!component) return [3, 5];
|
|
63
|
+
console.log("".concat(color.green('◇'), " ").concat(color.white('You did not specify, which package should be added'), "\n").concat(color.gray('|'), " ").concat(color.gray('Please select one of the packages below listed to proceed.'), "\n").concat(color.gray('|')));
|
|
64
|
+
return [4, list({ all: true })];
|
|
65
|
+
case 3:
|
|
66
|
+
_a.sent();
|
|
67
|
+
return [4, text({
|
|
68
|
+
message: 'Component name to add (Enter to install all components)',
|
|
69
|
+
placeholder: DEFAULT_PACKAGE,
|
|
70
|
+
defaultValue: DEFAULT_PACKAGE,
|
|
71
|
+
})];
|
|
72
|
+
case 4:
|
|
73
|
+
packageName = (_a.sent());
|
|
74
|
+
return [3, 6];
|
|
75
|
+
case 5:
|
|
76
|
+
packageName = component;
|
|
77
|
+
_a.label = 6;
|
|
78
|
+
case 6:
|
|
79
|
+
_a.trys.push([6, 10, , 11]);
|
|
80
|
+
s.start("Installing ".concat(packageName, "..."));
|
|
81
|
+
pkgManager_1 = getCurrentPackageManager();
|
|
82
|
+
if (!(packageName === 'all')) return [3, 8];
|
|
83
|
+
return [4, installPackage(pkgManager_1, '@aristobyte-ui/react')];
|
|
84
|
+
case 7:
|
|
85
|
+
_a.sent();
|
|
86
|
+
s.stop();
|
|
87
|
+
console.log(color.green('✔ All components installed!'));
|
|
88
|
+
return [2];
|
|
89
|
+
case 8:
|
|
90
|
+
pkgName = "@aristobyte-ui/".concat(packageName);
|
|
91
|
+
return [4, installPackage(pkgManager_1, pkgName)];
|
|
92
|
+
case 9:
|
|
93
|
+
_a.sent();
|
|
94
|
+
s.stop();
|
|
95
|
+
console.log(color.green("\u2714 Component ".concat(packageName, " installed!")));
|
|
96
|
+
return [3, 11];
|
|
97
|
+
case 10:
|
|
98
|
+
err_1 = _a.sent();
|
|
99
|
+
s.stop();
|
|
100
|
+
console.error(color.red("\u00D7 Failed to install package ".concat(packageName)), err_1);
|
|
101
|
+
return [3, 11];
|
|
102
|
+
case 11: return [2];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import fs from 'fs';
|
|
38
|
+
import path from 'path';
|
|
39
|
+
import os from 'os';
|
|
40
|
+
import { execSync } from 'child_process';
|
|
41
|
+
import { spinner } from '@clack/prompts';
|
|
42
|
+
import color from 'picocolors';
|
|
43
|
+
import { checkVersion } from '../utils/checkVersion';
|
|
44
|
+
import { getCurrentPackageManager } from '../utils/getCurrentPackageManager';
|
|
45
|
+
var MIN_VERSIONS = {
|
|
46
|
+
node: '20.19.0',
|
|
47
|
+
pnpm: '10.15.1',
|
|
48
|
+
npm: '10.8.2',
|
|
49
|
+
yarn: '1.22.22',
|
|
50
|
+
bun: '1.2.21',
|
|
51
|
+
};
|
|
52
|
+
function getVersion(command, name) {
|
|
53
|
+
try {
|
|
54
|
+
return execSync(command).toString().trim();
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
console.error(color.red("\u00D7 Failed to detect ".concat(name, " version:")), err);
|
|
58
|
+
return 'unknown';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function hasProjectPackage(name) {
|
|
62
|
+
try {
|
|
63
|
+
var pkgJson = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
|
|
64
|
+
return ((pkgJson.dependencies && pkgJson.dependencies[name]) || (pkgJson.devDependencies && pkgJson.devDependencies[name]));
|
|
65
|
+
}
|
|
66
|
+
catch (_a) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function detectUISetup() {
|
|
71
|
+
var configPaths = ['tailwind.config.js', 'tailwind.config.ts', 'postcss.config.js', 'postcss.config.ts'];
|
|
72
|
+
return configPaths.filter(function (p) { return fs.existsSync(path.resolve(p)); });
|
|
73
|
+
}
|
|
74
|
+
function checkNetwork() {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
+
var res, _a;
|
|
77
|
+
return __generator(this, function (_b) {
|
|
78
|
+
switch (_b.label) {
|
|
79
|
+
case 0:
|
|
80
|
+
_b.trys.push([0, 2, , 3]);
|
|
81
|
+
return [4, fetch('https://registry.npmjs.org/-/org/aristobyte-ui/package', { method: 'HEAD' })];
|
|
82
|
+
case 1:
|
|
83
|
+
res = _b.sent();
|
|
84
|
+
return [2, res.ok];
|
|
85
|
+
case 2:
|
|
86
|
+
_a = _b.sent();
|
|
87
|
+
return [2, false];
|
|
88
|
+
case 3: return [2];
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
export function doctor(options) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
95
|
+
var s, system, pkgManager, pmVersion, uiInstalled, pluginInstalled, configs, networkOnline, payload, err_1;
|
|
96
|
+
return __generator(this, function (_a) {
|
|
97
|
+
switch (_a.label) {
|
|
98
|
+
case 0:
|
|
99
|
+
s = spinner();
|
|
100
|
+
_a.label = 1;
|
|
101
|
+
case 1:
|
|
102
|
+
_a.trys.push([1, 4, , 5]);
|
|
103
|
+
s.start('Running doctor diagnostics…');
|
|
104
|
+
console.log("".concat(color.green('◇'), " ").concat(color.cyan('Doctor Diagnostics'), "\n").concat(color.gray('|')));
|
|
105
|
+
system = {
|
|
106
|
+
os: "".concat(os.type(), " ").concat(os.release(), " (").concat(os.platform(), ")"),
|
|
107
|
+
cpu: os.cpus()[0].model,
|
|
108
|
+
memoryMB: Math.round(os.totalmem() / 1024 / 1024),
|
|
109
|
+
node: getVersion('node -v', 'Node'),
|
|
110
|
+
};
|
|
111
|
+
pkgManager = getCurrentPackageManager();
|
|
112
|
+
pmVersion = getVersion("".concat(pkgManager, " -v"), pkgManager);
|
|
113
|
+
uiInstalled = hasProjectPackage('@aristobyte-ui/react');
|
|
114
|
+
pluginInstalled = hasProjectPackage('@aristobyte-ui/plugin');
|
|
115
|
+
configs = detectUISetup();
|
|
116
|
+
networkOnline = void 0;
|
|
117
|
+
if (!(options.network || options.all || Object.keys(options).length === 0)) return [3, 3];
|
|
118
|
+
return [4, checkNetwork()];
|
|
119
|
+
case 2:
|
|
120
|
+
networkOnline = _a.sent();
|
|
121
|
+
_a.label = 3;
|
|
122
|
+
case 3:
|
|
123
|
+
payload = {
|
|
124
|
+
system: system,
|
|
125
|
+
packageManager: { name: pkgManager, version: pmVersion },
|
|
126
|
+
installedPackages: { ui: uiInstalled, plugin: pluginInstalled },
|
|
127
|
+
configs: configs,
|
|
128
|
+
network: networkOnline,
|
|
129
|
+
};
|
|
130
|
+
if (options.json) {
|
|
131
|
+
console.log("".concat(color.gray('|'), "\n").concat(color.gray('◇ ------ JSON start ------ ◇'), "\n").concat(JSON.stringify(payload, null, 2), "\n").concat(color.gray('◇ ------ JSON end ------ ◇'), "\n").concat(color.gray('|')));
|
|
132
|
+
}
|
|
133
|
+
if (options.system || options.all || Object.keys(options).length === 0) {
|
|
134
|
+
console.log("".concat(options.system ? '' : '\n').concat(color.gray('|'), "\n").concat(color.green('◇'), " ").concat(color.cyan('System:'), "\n").concat(color.gray('|'), " ").concat(color.white('OS:'), " ").concat(color.green(system.os), "\n").concat(color.gray('|'), " ").concat(color.white('CPU:'), " ").concat(color.green(system.cpu), "\n").concat(color.gray('|'), " ").concat(color.white('Memory:'), " ").concat(color.green("".concat(system.memoryMB, " MB")), "\n").concat(color.gray('|'), " ").concat(color.white('Node:'), " ").concat(checkVersion('Node', system.node, MIN_VERSIONS.node)));
|
|
135
|
+
}
|
|
136
|
+
if (options.pm || options.all || Object.keys(options).length === 0) {
|
|
137
|
+
console.log("".concat(color.gray('|'), "\n").concat(color.green('◇'), " ").concat(color.cyan('Package Manager:'), "\n").concat(color.gray('|'), " ").concat(color.white('Current:'), " ").concat(color.green(pkgManager), "\n").concat(color.gray('|'), " ").concat(color.white('Version:'), " ").concat(checkVersion(pkgManager, pmVersion, MIN_VERSIONS[pkgManager])));
|
|
138
|
+
}
|
|
139
|
+
if (options.deps || options.all || Object.keys(options).length === 0) {
|
|
140
|
+
console.log("".concat(color.gray('|'), "\n").concat(color.green('◇'), " ").concat(color.cyan('Project Dependencies:'), "\n").concat(color.gray('|'), " ").concat(color.white('@aristobyte-ui/react:'), " ").concat(uiInstalled ? color.green('✔ Installed') : color.red('× Missing'), "\n").concat(color.gray('|'), " ").concat(color.white('@aristobyte-ui/plugin:'), " ").concat(pluginInstalled ? color.green('✔ Installed') : color.red('× Missing')));
|
|
141
|
+
}
|
|
142
|
+
if (options.configs || options.all || Object.keys(options).length === 0) {
|
|
143
|
+
console.log("".concat(color.gray('|'), "\n").concat(color.green('◇'), " ").concat(color.cyan('Config Files:')));
|
|
144
|
+
if (!configs.length) {
|
|
145
|
+
console.log("".concat(color.gray('|'), " ").concat(color.red('× No config files detected')));
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
configs.forEach(function (cfg) { return console.log("".concat(color.gray('|'), " ").concat(color.green('✔'), " ").concat(color.white(cfg))); });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if ((options.network || options.all || Object.keys(options).length === 0) && networkOnline !== undefined) {
|
|
152
|
+
console.log("".concat(options.network ? '\n' : '').concat(color.gray('|'), "\n").concat(color.green('◇'), " ").concat(color.cyan('Network:'), "\n").concat(color.gray('|'), " ").concat(networkOnline ? "".concat(color.green('✔'), " ").concat(color.white('Registry reachable')) : "".concat(color.red('×'), " ").concat(color.white('Registry unreachable'))));
|
|
153
|
+
}
|
|
154
|
+
console.log(color.gray('|'));
|
|
155
|
+
s.stop(color.green('✔ Doctor diagnostics finished successfully!'));
|
|
156
|
+
return [3, 5];
|
|
157
|
+
case 4:
|
|
158
|
+
err_1 = _a.sent();
|
|
159
|
+
s.stop(color.red('× Doctor diagnostics failed'));
|
|
160
|
+
console.error(color.red('× Diagnostics crashed'), err_1);
|
|
161
|
+
return [3, 5];
|
|
162
|
+
case 5: return [2];
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import os from 'os';
|
|
38
|
+
import fs from 'fs';
|
|
39
|
+
import { execSync } from 'child_process';
|
|
40
|
+
import { spinner } from '@clack/prompts';
|
|
41
|
+
import { checkVersion } from '../utils/checkVersion';
|
|
42
|
+
import { getCurrentPackageManager } from '../utils/getCurrentPackageManager';
|
|
43
|
+
import color from 'picocolors';
|
|
44
|
+
var MIN_VERSIONS = {
|
|
45
|
+
node: '20.19.0',
|
|
46
|
+
pnpm: '10.15.1',
|
|
47
|
+
npm: '10.8.2',
|
|
48
|
+
yarn: '1.22.22',
|
|
49
|
+
bun: '1.2.21',
|
|
50
|
+
};
|
|
51
|
+
function getVersion(command, name) {
|
|
52
|
+
try {
|
|
53
|
+
return execSync(command).toString().trim();
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
console.error(color.red("\u00D7 Failed to detect ".concat(name, " version:")), err);
|
|
57
|
+
return 'unknown';
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function getSystemInfo() {
|
|
61
|
+
return {
|
|
62
|
+
os: "".concat(os.type(), " ").concat(os.release(), " (").concat(os.platform(), ")"),
|
|
63
|
+
cpu: os.cpus()[0].model,
|
|
64
|
+
memoryMB: Math.round(os.totalmem() / 1024 / 1024),
|
|
65
|
+
node: getVersion('node -v', 'Node'),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function getPackageManagerInfo() {
|
|
69
|
+
var current = getCurrentPackageManager();
|
|
70
|
+
return {
|
|
71
|
+
packageManager: current,
|
|
72
|
+
version: getVersion("".concat(current, " -v"), current),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function getInstalledPackages() {
|
|
76
|
+
try {
|
|
77
|
+
var pkgJson = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
|
|
78
|
+
var deps = pkgJson.dependencies || {};
|
|
79
|
+
return Object.keys(deps)
|
|
80
|
+
.filter(function (d) { return d.startsWith('@aristobyte-ui/'); })
|
|
81
|
+
.map(function (dep) { return (dep.includes('react') ? 'all' : dep.split('/')[1]); });
|
|
82
|
+
}
|
|
83
|
+
catch (_a) {
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function checkNetwork() {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
89
|
+
var url, res, _a;
|
|
90
|
+
return __generator(this, function (_b) {
|
|
91
|
+
switch (_b.label) {
|
|
92
|
+
case 0:
|
|
93
|
+
url = 'https://registry.npmjs.org/-/org/aristobyte-ui/package';
|
|
94
|
+
_b.label = 1;
|
|
95
|
+
case 1:
|
|
96
|
+
_b.trys.push([1, 3, , 4]);
|
|
97
|
+
return [4, fetch(url, { method: 'HEAD' })];
|
|
98
|
+
case 2:
|
|
99
|
+
res = _b.sent();
|
|
100
|
+
return [2, res.ok];
|
|
101
|
+
case 3:
|
|
102
|
+
_a = _b.sent();
|
|
103
|
+
return [2, false];
|
|
104
|
+
case 4: return [2];
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
export function env(options) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
111
|
+
var s, system, pm, installed, networkOnline, _a, payload, err_1;
|
|
112
|
+
return __generator(this, function (_b) {
|
|
113
|
+
switch (_b.label) {
|
|
114
|
+
case 0:
|
|
115
|
+
s = spinner();
|
|
116
|
+
_b.label = 1;
|
|
117
|
+
case 1:
|
|
118
|
+
_b.trys.push([1, 5, , 6]);
|
|
119
|
+
s.start('Collecting environment diagnostics…');
|
|
120
|
+
console.log("".concat(color.green('◇'), " ").concat(color.cyan('Environment Diagnostics'), "\n").concat(color.gray('|')));
|
|
121
|
+
system = getSystemInfo();
|
|
122
|
+
pm = getPackageManagerInfo();
|
|
123
|
+
installed = options.packages || options.all || Object.keys(options).length === 0 ? getInstalledPackages() : [];
|
|
124
|
+
if (!(options.network || options.all || Object.keys(options).length === 0)) return [3, 3];
|
|
125
|
+
return [4, checkNetwork()];
|
|
126
|
+
case 2:
|
|
127
|
+
_a = _b.sent();
|
|
128
|
+
return [3, 4];
|
|
129
|
+
case 3:
|
|
130
|
+
_a = undefined;
|
|
131
|
+
_b.label = 4;
|
|
132
|
+
case 4:
|
|
133
|
+
networkOnline = _a;
|
|
134
|
+
payload = {
|
|
135
|
+
system: system,
|
|
136
|
+
packageManager: pm,
|
|
137
|
+
installedPackages: installed,
|
|
138
|
+
network: networkOnline,
|
|
139
|
+
};
|
|
140
|
+
if (options.json) {
|
|
141
|
+
console.log("".concat(color.gray('|'), "\n").concat(color.gray('◇ ------ JSON file start ------ ◇'), "\n").concat(JSON.stringify(payload, null, 2), "\n").concat(color.gray('◇ ------ JSON file end ------ ◇'), "\n").concat(color.gray('|')));
|
|
142
|
+
}
|
|
143
|
+
if (options.system || options.all || Object.keys(options).length === 0) {
|
|
144
|
+
console.log("".concat(options.all || Object.keys(options).length === 0 ? '\n' : '').concat(color.gray('|'), " \n").concat(color.green('◇'), " ").concat(color.cyan('System:'), "\n").concat(color.gray('|'), " ").concat(color.white('OS:'), " ").concat(color.green("".concat(system.os)), "\n").concat(color.gray('|'), " ").concat(color.white('CPU:'), " ").concat(color.green("".concat(system.cpu)), "\n").concat(color.gray('|'), " ").concat(color.white('Memory:'), " ").concat(color.green("".concat(system.memoryMB, " MB")), "\n").concat(color.gray('|'), " ").concat(color.white('Node:'), " ").concat(checkVersion('Node', system.node, MIN_VERSIONS.node)));
|
|
145
|
+
}
|
|
146
|
+
if (options.pm || options.all || Object.keys(options).length === 0) {
|
|
147
|
+
console.log("".concat(color.gray('|'), "\n").concat(color.green('◇'), " ").concat(color.cyan('Package Manager:'), "\n").concat(color.gray('|'), " ").concat(color.white('Current:'), " ").concat(color.green(pm.packageManager), "\n").concat(color.gray('|'), " ").concat(color.white('Version:'), " ").concat(color.green(checkVersion(pm.packageManager, pm.version, MIN_VERSIONS[pm.packageManager]))));
|
|
148
|
+
}
|
|
149
|
+
if (options.packages || options.all || Object.keys(options).length === 0) {
|
|
150
|
+
console.log("".concat(color.gray('|'), "\n").concat(color.green('◇'), " ").concat(color.cyan('Installed AristoByteUI Packages:')));
|
|
151
|
+
if (!installed.length) {
|
|
152
|
+
console.log(color.gray(' (none detected)'));
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
installed.forEach(function (p) { return console.log("".concat(color.gray('|'), " ").concat(color.green('-'), " ").concat(color.white(p))); });
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (options.network || options.all || Object.keys(options).length === 0) {
|
|
159
|
+
console.log("".concat(options.network ? '\n' : '').concat(color.gray('|'), "\n").concat(color.green('◇'), " ").concat(color.cyan('Network:'), "\n").concat(color.gray('|'), " ").concat(networkOnline
|
|
160
|
+
? "".concat(color.green('✔'), " ").concat(color.white('Registry reachable"'))
|
|
161
|
+
: "".concat(color.red('×'), " ").concat(color.white('Registry unreachable'))));
|
|
162
|
+
}
|
|
163
|
+
console.log(color.gray('|'));
|
|
164
|
+
s.stop(color.green('✔ Environment diagnostics finished with success!'));
|
|
165
|
+
return [3, 6];
|
|
166
|
+
case 5:
|
|
167
|
+
err_1 = _b.sent();
|
|
168
|
+
s.stop(color.red('× Environment diagnostics finished with failure :('));
|
|
169
|
+
console.error(color.red('× Environment diagnostics failed'), err_1);
|
|
170
|
+
return [3, 6];
|
|
171
|
+
case 6: return [2];
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { execa } from 'execa';
|
|
38
|
+
import { select, text, spinner } from "@clack/prompts";
|
|
39
|
+
import color from "picocolors";
|
|
40
|
+
var TEMPLATES = [
|
|
41
|
+
{
|
|
42
|
+
id: "aristobyte-ui-template-nextjs-15-app-router",
|
|
43
|
+
name: "Next App Router",
|
|
44
|
+
desc: "A Next.js 15 with app-router directory template pre-configured with AristoByteUI.",
|
|
45
|
+
repo: "https://github.com/aristobyte-team/aristobyte-ui-template-nextjs-15-app-router.git",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: "aristobyte-ui-template-nextjs-15-pages",
|
|
49
|
+
name: "Next Pages",
|
|
50
|
+
desc: "A Next.js 15 with pages directory template pre-configured with AristoByteUI.",
|
|
51
|
+
repo: "https://github.com/aristobyte-team/aristobyte-ui-template-nextjs-15-pages.git",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: "aristobyte-ui-template-vite",
|
|
55
|
+
name: "Vite",
|
|
56
|
+
desc: "A Vite template pre-configured with AristoByteUI.",
|
|
57
|
+
repo: "https://github.com/aristobyte-team/aristobyte-ui-template-vite.git",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: "aristobyte-ui-template-vike",
|
|
61
|
+
name: "Vike",
|
|
62
|
+
desc: "A Vike template pre-configured with AristoByteUI.",
|
|
63
|
+
repo: "https://github.com/aristobyte-team/aristobyte-ui-template-vike.git",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "aristobyte-ui-template-astro",
|
|
67
|
+
name: "Astro",
|
|
68
|
+
desc: "An Astro template pre-configured with AristoByteUI.",
|
|
69
|
+
repo: "https://github.com/aristobyte-team/aristobyte-ui-template-astro.git",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
id: "aristobyte-ui-template-rsbuild",
|
|
73
|
+
name: "RS Build",
|
|
74
|
+
desc: "An RS Build template pre-configured with AristoByteUI.",
|
|
75
|
+
repo: "https://github.com/aristobyte-team/aristobyte-ui-template-rsbuild.git",
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
var PACKAGE_MANAGERS = ["npm", "yarn", "pnpm", "bun"];
|
|
79
|
+
var DEFAULT_NAME = "aristobyte-ui-app";
|
|
80
|
+
export function init(myProjectName, options) {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
82
|
+
var projectName, template, templateIndex, packageManager, packageManagerIndex, s, err_1;
|
|
83
|
+
return __generator(this, function (_a) {
|
|
84
|
+
switch (_a.label) {
|
|
85
|
+
case 0:
|
|
86
|
+
if (options.listTemplates) {
|
|
87
|
+
console.log("".concat(color.cyan("Available templates:"), "\n").concat(TEMPLATES.map(function (t) {
|
|
88
|
+
return "".concat(color.green("◇"), " ").concat(t.id.split("aristobyte-ui-template-")[1], " - ").concat(color.gray(t.desc));
|
|
89
|
+
}).join("\n")));
|
|
90
|
+
process.exit(0);
|
|
91
|
+
}
|
|
92
|
+
if (options.listPackageManagers) {
|
|
93
|
+
console.log("".concat(color.cyan("Available package managers:"), "\n").concat(PACKAGE_MANAGERS.map(function (pm) { return "".concat(color.green("◇"), " ").concat(pm); }).join("\n")));
|
|
94
|
+
process.exit(0);
|
|
95
|
+
}
|
|
96
|
+
console.log(color.cyan("┌ Create a new project"));
|
|
97
|
+
projectName = myProjectName || DEFAULT_NAME;
|
|
98
|
+
if (!!myProjectName) return [3, 2];
|
|
99
|
+
return [4, text({
|
|
100
|
+
message: "New project name (Enter to skip with default name)",
|
|
101
|
+
placeholder: DEFAULT_NAME,
|
|
102
|
+
defaultValue: DEFAULT_NAME,
|
|
103
|
+
})];
|
|
104
|
+
case 1:
|
|
105
|
+
projectName = (_a.sent());
|
|
106
|
+
return [3, 3];
|
|
107
|
+
case 2:
|
|
108
|
+
console.log("".concat(color.gray("│"), "\n").concat(color.green("◇"), " ").concat(color.white("Your project name is:"), "\n").concat(color.gray("│"), " ").concat(color.green(projectName)));
|
|
109
|
+
_a.label = 3;
|
|
110
|
+
case 3:
|
|
111
|
+
template = TEMPLATES.find(function (t) {
|
|
112
|
+
var _a, _b;
|
|
113
|
+
return t.id ===
|
|
114
|
+
"aristobyte-ui-template-".concat((_b = (_a = options === null || options === void 0 ? void 0 : options.template) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.replaceAll(" ", ""));
|
|
115
|
+
});
|
|
116
|
+
if (!!template) return [3, 5];
|
|
117
|
+
return [4, select({
|
|
118
|
+
message: "Select a template (Enter to select)",
|
|
119
|
+
options: TEMPLATES.map(function (t, i) { return ({
|
|
120
|
+
value: i.toString(),
|
|
121
|
+
label: "".concat(t.name, " (").concat(t.desc, ")"),
|
|
122
|
+
}); }),
|
|
123
|
+
})];
|
|
124
|
+
case 4:
|
|
125
|
+
templateIndex = _a.sent();
|
|
126
|
+
template = TEMPLATES[Number(templateIndex)];
|
|
127
|
+
return [3, 6];
|
|
128
|
+
case 5:
|
|
129
|
+
console.log("".concat(color.gray("│"), "\n").concat(color.green("◇"), " ").concat(color.white("Template selected:"), "\n").concat(color.gray("│"), " ").concat(color.green(template.name)));
|
|
130
|
+
_a.label = 6;
|
|
131
|
+
case 6:
|
|
132
|
+
packageManager = PACKAGE_MANAGERS.find(function (pm) { var _a; return pm.toLowerCase() === ((_a = options.packageManager) === null || _a === void 0 ? void 0 : _a.toLowerCase()); });
|
|
133
|
+
if (!!packageManager) return [3, 8];
|
|
134
|
+
return [4, select({
|
|
135
|
+
message: "Select a package manager (Enter to select)",
|
|
136
|
+
options: PACKAGE_MANAGERS.map(function (pm, i) { return ({
|
|
137
|
+
value: i.toString(),
|
|
138
|
+
label: pm,
|
|
139
|
+
}); }),
|
|
140
|
+
})];
|
|
141
|
+
case 7:
|
|
142
|
+
packageManagerIndex = _a.sent();
|
|
143
|
+
packageManager = PACKAGE_MANAGERS[Number(packageManagerIndex)];
|
|
144
|
+
return [3, 9];
|
|
145
|
+
case 8:
|
|
146
|
+
console.log("".concat(color.gray("│"), "\n").concat(color.green("◇"), " ").concat(color.white("Package manager selected:"), "\n").concat(color.gray("│"), " ").concat(color.green(packageManager)));
|
|
147
|
+
_a.label = 9;
|
|
148
|
+
case 9:
|
|
149
|
+
console.log("".concat(color.gray("│"), "\n").concat(color.green("◇"), " ").concat(color.cyan("Template created successfully!"), "\n").concat(color.gray("│")));
|
|
150
|
+
s = spinner();
|
|
151
|
+
_a.label = 10;
|
|
152
|
+
case 10:
|
|
153
|
+
_a.trys.push([10, 13, , 14]);
|
|
154
|
+
s.start("Preparing '".concat(template.name, "' with ").concat(packageManager, " configuration..."));
|
|
155
|
+
return [4, execa("git", [
|
|
156
|
+
"clone",
|
|
157
|
+
"--branch",
|
|
158
|
+
packageManager,
|
|
159
|
+
"--single-branch",
|
|
160
|
+
template.repo,
|
|
161
|
+
projectName,
|
|
162
|
+
], { stdio: "ignore" })];
|
|
163
|
+
case 11:
|
|
164
|
+
_a.sent();
|
|
165
|
+
return [4, execa("rm", ["-rf", ".git"], { cwd: projectName, stdio: "ignore" })];
|
|
166
|
+
case 12:
|
|
167
|
+
_a.sent();
|
|
168
|
+
s.stop("".concat(color.green("✔ Project initialized successfully!")));
|
|
169
|
+
console.log("\n".concat(color.gray("│"), "\n").concat(color.green("◇"), " ").concat(color.cyan("To get started:"), "\n").concat(color.gray("│"), "\n").concat(color.gray("├─"), " ").concat(color.white("cd " + projectName), "\n").concat(color.gray("├─"), " ").concat(color.white("".concat(packageManager, " install")), "\n").concat(color.gray("├─"), " ").concat(color.white("".concat(packageManager, " run dev"))));
|
|
170
|
+
return [3, 14];
|
|
171
|
+
case 13:
|
|
172
|
+
err_1 = _a.sent();
|
|
173
|
+
s.stop();
|
|
174
|
+
console.error(color.red("× Failed to initialize project"), err_1);
|
|
175
|
+
return [3, 14];
|
|
176
|
+
case 14: return [2];
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
}
|