@aristobyte-ui/cli 2.3.5 → 2.4.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/es/package.json +58 -0
- package/es/src/main/commands/add.js +106 -0
- package/es/src/main/commands/doctor.js +166 -0
- package/es/src/main/commands/env.js +175 -0
- package/es/src/main/commands/init.js +180 -0
- package/es/src/main/commands/list.js +195 -0
- package/es/src/main/commands/remove.js +100 -0
- package/es/src/main/commands/upgrade.js +122 -0
- package/es/src/main/index.js +212 -0
- package/es/src/main/utils/checkVersion.js +8 -0
- package/es/src/main/utils/colors.js +77 -0
- package/es/src/main/utils/compareVersions.js +11 -0
- package/es/src/main/utils/getBanner.js +30 -0
- package/es/src/main/utils/getCurrentPackageManager.js +55 -0
- package/es/src/main/utils/getDescription.js +21 -0
- package/es/src/main/utils/getTip.js +21 -0
- package/es/src/main/utils/installPackage.js +75 -0
- package/es/src/main/utils/parseHelp.js +22 -0
- package/es/src/main/utils/typography.js +9 -0
- package/lib/package.json +58 -0
- package/lib/src/main/commands/add.js +112 -0
- package/lib/src/main/commands/doctor.js +172 -0
- package/lib/src/main/commands/env.js +181 -0
- package/lib/src/main/commands/init.js +186 -0
- package/lib/src/main/commands/list.js +202 -0
- package/lib/src/main/commands/remove.js +106 -0
- package/lib/src/main/commands/upgrade.js +128 -0
- package/lib/src/main/index.js +217 -0
- package/lib/src/main/utils/checkVersion.js +14 -0
- package/lib/src/main/utils/colors.js +96 -0
- package/lib/src/main/utils/compareVersions.js +14 -0
- package/lib/src/main/utils/getBanner.js +33 -0
- package/lib/src/main/utils/getCurrentPackageManager.js +61 -0
- package/lib/src/main/utils/getDescription.js +24 -0
- package/lib/src/main/utils/getTip.js +24 -0
- package/lib/src/main/utils/installPackage.js +78 -0
- package/lib/src/main/utils/parseHelp.js +25 -0
- package/lib/src/main/utils/typography.js +13 -0
- package/package.json +1 -1
- package/README.md +0 -11
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
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
|
+
var __values = (this && this.__values) || function(o) {
|
|
38
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
39
|
+
if (m) return m.call(o);
|
|
40
|
+
if (o && typeof o.length === "number") return {
|
|
41
|
+
next: function () {
|
|
42
|
+
if (o && i >= o.length) o = void 0;
|
|
43
|
+
return { value: o && o[i++], done: !o };
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
47
|
+
};
|
|
48
|
+
import fs from 'fs';
|
|
49
|
+
import color from 'picocolors';
|
|
50
|
+
import { getCurrentPackageManager } from '../utils/getCurrentPackageManager';
|
|
51
|
+
export function remoteList() {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
53
|
+
return [2];
|
|
54
|
+
}); });
|
|
55
|
+
}
|
|
56
|
+
export function list(options, endBlock) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
+
var handled, url, omit_1, res, data, packages, err_1, pkgJson, deps, aristobyteDeps, packagesToUpdate, pkgJson, deps, installed, installed_1, installed_1_1, pkg, localVersion, registryUrl, res, data, latest, p, err_2, e_1_1, err_3, pkgManager;
|
|
59
|
+
var e_1, _a;
|
|
60
|
+
var _b;
|
|
61
|
+
return __generator(this, function (_c) {
|
|
62
|
+
switch (_c.label) {
|
|
63
|
+
case 0:
|
|
64
|
+
handled = false;
|
|
65
|
+
if (!options.all) return [3, 6];
|
|
66
|
+
handled = true;
|
|
67
|
+
url = 'https://registry.npmjs.org/-/org/aristobyte-ui/package';
|
|
68
|
+
omit_1 = ['cli', 'react'];
|
|
69
|
+
_c.label = 1;
|
|
70
|
+
case 1:
|
|
71
|
+
_c.trys.push([1, 4, , 5]);
|
|
72
|
+
return [4, fetch(url)];
|
|
73
|
+
case 2:
|
|
74
|
+
res = _c.sent();
|
|
75
|
+
if (!res.ok)
|
|
76
|
+
throw new Error("Registry request failed: ".concat(res.status));
|
|
77
|
+
return [4, res.json()];
|
|
78
|
+
case 3:
|
|
79
|
+
data = _c.sent();
|
|
80
|
+
packages = Object.keys(data)
|
|
81
|
+
.map(function (dep) { return dep.split('/')[1]; })
|
|
82
|
+
.filter(function (dep) { return !omit_1.includes(dep); })
|
|
83
|
+
.sort();
|
|
84
|
+
console.log("".concat(color.green('◇'), " ").concat(color.white('Listing AristoByteUI packages:'), "\n").concat(packages.map(function (dep) { return "".concat(color.gray('|'), " ").concat(color.cyan(dep)); }).join('\n')));
|
|
85
|
+
return [3, 5];
|
|
86
|
+
case 4:
|
|
87
|
+
err_1 = _c.sent();
|
|
88
|
+
console.error(color.red('× Failed to fetch package list from npm registry'));
|
|
89
|
+
console.error(color.dim(String(err_1)));
|
|
90
|
+
return [3, 5];
|
|
91
|
+
case 5:
|
|
92
|
+
if (endBlock)
|
|
93
|
+
console.log(color.green('◇'));
|
|
94
|
+
process.exit(0);
|
|
95
|
+
_c.label = 6;
|
|
96
|
+
case 6:
|
|
97
|
+
if (options.installed) {
|
|
98
|
+
handled = true;
|
|
99
|
+
try {
|
|
100
|
+
pkgJson = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
|
|
101
|
+
deps = pkgJson.dependencies || {};
|
|
102
|
+
aristobyteDeps = Object.keys(deps)
|
|
103
|
+
.filter(function (d) { return d.startsWith('@aristobyte-ui/'); })
|
|
104
|
+
.map(function (dep) { return (dep.includes('react') ? 'all' : dep.split('/')[1]); });
|
|
105
|
+
console.log("".concat(color.green('◇'), " ").concat(color.white('Listing installed AristoByteUI packages:'), "\n").concat(aristobyteDeps.map(function (dep) { return "".concat(color.gray('|'), " ").concat(color.cyan(dep)); }).join('\n')));
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
console.error(color.red('× Failed to list packages'), err);
|
|
109
|
+
}
|
|
110
|
+
if (endBlock)
|
|
111
|
+
console.log(color.green('◇'));
|
|
112
|
+
process.exit(0);
|
|
113
|
+
}
|
|
114
|
+
if (!options.outdated) return [3, 21];
|
|
115
|
+
handled = true;
|
|
116
|
+
packagesToUpdate = [];
|
|
117
|
+
_c.label = 7;
|
|
118
|
+
case 7:
|
|
119
|
+
_c.trys.push([7, 19, , 20]);
|
|
120
|
+
pkgJson = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
|
|
121
|
+
deps = pkgJson.dependencies || {};
|
|
122
|
+
installed = Object.keys(deps).filter(function (d) { return d.startsWith('@aristobyte-ui/'); });
|
|
123
|
+
if (installed.length === 0) {
|
|
124
|
+
console.log(color.yellow('No AristoByteUI packages installed.'));
|
|
125
|
+
process.exit(0);
|
|
126
|
+
}
|
|
127
|
+
console.log("".concat(color.green('◇'), " ").concat(color.white('Checking for outdated AristoByteUI packages...')));
|
|
128
|
+
_c.label = 8;
|
|
129
|
+
case 8:
|
|
130
|
+
_c.trys.push([8, 16, 17, 18]);
|
|
131
|
+
installed_1 = __values(installed), installed_1_1 = installed_1.next();
|
|
132
|
+
_c.label = 9;
|
|
133
|
+
case 9:
|
|
134
|
+
if (!!installed_1_1.done) return [3, 15];
|
|
135
|
+
pkg = installed_1_1.value;
|
|
136
|
+
localVersion = deps[pkg].replace(/^[^\d]*/, '');
|
|
137
|
+
registryUrl = "https://registry.npmjs.org/".concat(pkg);
|
|
138
|
+
_c.label = 10;
|
|
139
|
+
case 10:
|
|
140
|
+
_c.trys.push([10, 13, , 14]);
|
|
141
|
+
return [4, fetch(registryUrl)];
|
|
142
|
+
case 11:
|
|
143
|
+
res = _c.sent();
|
|
144
|
+
if (!res.ok)
|
|
145
|
+
throw new Error("Registry request failed: ".concat(res.status));
|
|
146
|
+
return [4, res.json()];
|
|
147
|
+
case 12:
|
|
148
|
+
data = _c.sent();
|
|
149
|
+
latest = (_b = data['dist-tags']) === null || _b === void 0 ? void 0 : _b.latest;
|
|
150
|
+
if (!latest)
|
|
151
|
+
return [3, 14];
|
|
152
|
+
if (latest !== localVersion) {
|
|
153
|
+
p = pkg.replace('@aristobyte-ui/', '');
|
|
154
|
+
packagesToUpdate.push([p, latest]);
|
|
155
|
+
console.log("".concat(color.gray('|'), " ").concat(color.cyan(p), " ") + "".concat(color.red(localVersion), " \u2192 ").concat(color.green(latest)));
|
|
156
|
+
}
|
|
157
|
+
return [3, 14];
|
|
158
|
+
case 13:
|
|
159
|
+
err_2 = _c.sent();
|
|
160
|
+
console.error(color.red("\u00D7 Failed to check ".concat(pkg, " on npm registry")), err_2);
|
|
161
|
+
return [3, 14];
|
|
162
|
+
case 14:
|
|
163
|
+
installed_1_1 = installed_1.next();
|
|
164
|
+
return [3, 9];
|
|
165
|
+
case 15: return [3, 18];
|
|
166
|
+
case 16:
|
|
167
|
+
e_1_1 = _c.sent();
|
|
168
|
+
e_1 = { error: e_1_1 };
|
|
169
|
+
return [3, 18];
|
|
170
|
+
case 17:
|
|
171
|
+
try {
|
|
172
|
+
if (installed_1_1 && !installed_1_1.done && (_a = installed_1.return)) _a.call(installed_1);
|
|
173
|
+
}
|
|
174
|
+
finally { if (e_1) throw e_1.error; }
|
|
175
|
+
return [7];
|
|
176
|
+
case 18: return [3, 20];
|
|
177
|
+
case 19:
|
|
178
|
+
err_3 = _c.sent();
|
|
179
|
+
console.error(color.red('× Failed to check outdated packages'), err_3);
|
|
180
|
+
return [3, 20];
|
|
181
|
+
case 20:
|
|
182
|
+
pkgManager = getCurrentPackageManager();
|
|
183
|
+
if (endBlock)
|
|
184
|
+
console.log("".concat(color.gray('|'), "\n").concat(color.green('◇'), " ").concat(packagesToUpdate.length > 0 ? color.gray("Tip: run '".concat(pkgManager, " upgrade ").concat(packagesToUpdate.map(function (p) { return "".concat(p[0], "@").concat(p[1]); }).join(' '), "'")) : color.green('✔ Everything is up to date!')));
|
|
185
|
+
process.exit(0);
|
|
186
|
+
_c.label = 21;
|
|
187
|
+
case 21:
|
|
188
|
+
if (!handled) {
|
|
189
|
+
console.log(color.gray("No option provided. Use 'aristobyte-ui list --help' for usage."));
|
|
190
|
+
}
|
|
191
|
+
return [2];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
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 { getCurrentPackageManager } from '../utils/getCurrentPackageManager';
|
|
38
|
+
import { spinner, text } from '@clack/prompts';
|
|
39
|
+
import { execa } from 'execa';
|
|
40
|
+
import color from 'picocolors';
|
|
41
|
+
import { list } from './list';
|
|
42
|
+
export function remove(component, options) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
+
var pkgManager, s, packageName, pkgName, err_1;
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
switch (_a.label) {
|
|
47
|
+
case 0:
|
|
48
|
+
if (!options.list) return [3, 2];
|
|
49
|
+
return [4, list({ installed: true }, true)];
|
|
50
|
+
case 1:
|
|
51
|
+
_a.sent();
|
|
52
|
+
_a.label = 2;
|
|
53
|
+
case 2:
|
|
54
|
+
pkgManager = getCurrentPackageManager();
|
|
55
|
+
if (options.packageManager) {
|
|
56
|
+
console.log("".concat(color.cyan('Current package manager:'), "\n").concat(color.green('◇'), " ").concat(pkgManager));
|
|
57
|
+
process.exit(0);
|
|
58
|
+
}
|
|
59
|
+
s = spinner();
|
|
60
|
+
if (!!component) return [3, 5];
|
|
61
|
+
console.log("".concat(color.green('◇'), " ").concat(color.white('You did not specify, which package should be removed'), "\n").concat(color.gray('|'), " ").concat(color.gray('Please select one of the installed packages below to proceed.'), "\n").concat(color.gray('|')));
|
|
62
|
+
return [4, list({ installed: true })];
|
|
63
|
+
case 3:
|
|
64
|
+
_a.sent();
|
|
65
|
+
return [4, text({
|
|
66
|
+
message: "Component name to remove (Required filled)",
|
|
67
|
+
placeholder: '<package-name>',
|
|
68
|
+
})];
|
|
69
|
+
case 4:
|
|
70
|
+
packageName = (_a.sent());
|
|
71
|
+
return [3, 6];
|
|
72
|
+
case 5:
|
|
73
|
+
packageName = component;
|
|
74
|
+
_a.label = 6;
|
|
75
|
+
case 6:
|
|
76
|
+
if (!packageName) {
|
|
77
|
+
console.log(color.red("Invalid Package name. <package-name> should be specified:\naristobyte-ui remove <package-name>"));
|
|
78
|
+
return [2];
|
|
79
|
+
}
|
|
80
|
+
_a.label = 7;
|
|
81
|
+
case 7:
|
|
82
|
+
_a.trys.push([7, 9, , 10]);
|
|
83
|
+
pkgName = packageName === 'all' ? '@aristobyte-ui/react' : "@aristobyte-ui/".concat(packageName);
|
|
84
|
+
s.start("Removing ".concat(pkgName, "..."));
|
|
85
|
+
return [4, execa(pkgManager, ['remove', pkgName], { stdio: 'inherit' })];
|
|
86
|
+
case 8:
|
|
87
|
+
_a.sent();
|
|
88
|
+
s.stop();
|
|
89
|
+
console.log(color.green("\u2714 ".concat(pkgName, " removed successfully!")));
|
|
90
|
+
return [3, 10];
|
|
91
|
+
case 9:
|
|
92
|
+
err_1 = _a.sent();
|
|
93
|
+
s.stop();
|
|
94
|
+
console.error(color.red("\u00D7 Failed to remove component ".concat(packageName)), err_1);
|
|
95
|
+
return [3, 10];
|
|
96
|
+
case 10: return [2];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
var __values = (this && this.__values) || function(o) {
|
|
38
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
39
|
+
if (m) return m.call(o);
|
|
40
|
+
if (o && typeof o.length === "number") return {
|
|
41
|
+
next: function () {
|
|
42
|
+
if (o && i >= o.length) o = void 0;
|
|
43
|
+
return { value: o && o[i++], done: !o };
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
47
|
+
};
|
|
48
|
+
import { getCurrentPackageManager } from '../utils/getCurrentPackageManager';
|
|
49
|
+
import { spinner } from '@clack/prompts';
|
|
50
|
+
import { execa } from 'execa';
|
|
51
|
+
import color from 'picocolors';
|
|
52
|
+
export function upgrade(component, options) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
+
var s, pkgManager, isAll, targets, versionSuffix, sLabel, targets_1, targets_1_1, pkg, fullSpecifier, e_1_1, err_1;
|
|
55
|
+
var e_1, _a;
|
|
56
|
+
return __generator(this, function (_b) {
|
|
57
|
+
switch (_b.label) {
|
|
58
|
+
case 0:
|
|
59
|
+
if (!component && !options.all) {
|
|
60
|
+
console.error(color.red('× No component specified for upgrade.'));
|
|
61
|
+
console.log(color.gray("Use: 'aristobyte-ui upgrade <component>' or 'aristobyte-ui upgrade --all'"));
|
|
62
|
+
process.exit(0);
|
|
63
|
+
}
|
|
64
|
+
s = spinner();
|
|
65
|
+
pkgManager = getCurrentPackageManager();
|
|
66
|
+
_b.label = 1;
|
|
67
|
+
case 1:
|
|
68
|
+
_b.trys.push([1, 10, , 11]);
|
|
69
|
+
isAll = options.all || component === 'all';
|
|
70
|
+
targets = isAll ? ['@aristobyte-ui/react'] : component ? ["@aristobyte-ui/".concat(component)] : [];
|
|
71
|
+
if (targets.length === 0) {
|
|
72
|
+
console.error(color.red('× No component specified for upgrade.'));
|
|
73
|
+
console.log(color.gray('Use: aristobyte-ui upgrade <component> or --all'));
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
versionSuffix = options.to ? "@".concat(options.to) : '';
|
|
77
|
+
sLabel = isAll ? 'Upgrading all AristoByteUI components...' : "Upgrading ".concat(targets.join(', '), "...");
|
|
78
|
+
s.start(sLabel);
|
|
79
|
+
_b.label = 2;
|
|
80
|
+
case 2:
|
|
81
|
+
_b.trys.push([2, 7, 8, 9]);
|
|
82
|
+
targets_1 = __values(targets), targets_1_1 = targets_1.next();
|
|
83
|
+
_b.label = 3;
|
|
84
|
+
case 3:
|
|
85
|
+
if (!!targets_1_1.done) return [3, 6];
|
|
86
|
+
pkg = targets_1_1.value;
|
|
87
|
+
fullSpecifier = "".concat(pkg).concat(versionSuffix);
|
|
88
|
+
return [4, execa(pkgManager, ['upgrade', fullSpecifier], {
|
|
89
|
+
stdio: 'inherit',
|
|
90
|
+
})];
|
|
91
|
+
case 4:
|
|
92
|
+
_b.sent();
|
|
93
|
+
_b.label = 5;
|
|
94
|
+
case 5:
|
|
95
|
+
targets_1_1 = targets_1.next();
|
|
96
|
+
return [3, 3];
|
|
97
|
+
case 6: return [3, 9];
|
|
98
|
+
case 7:
|
|
99
|
+
e_1_1 = _b.sent();
|
|
100
|
+
e_1 = { error: e_1_1 };
|
|
101
|
+
return [3, 9];
|
|
102
|
+
case 8:
|
|
103
|
+
try {
|
|
104
|
+
if (targets_1_1 && !targets_1_1.done && (_a = targets_1.return)) _a.call(targets_1);
|
|
105
|
+
}
|
|
106
|
+
finally { if (e_1) throw e_1.error; }
|
|
107
|
+
return [7];
|
|
108
|
+
case 9:
|
|
109
|
+
s.stop();
|
|
110
|
+
console.log(color.green("\u2714 Upgrade complete".concat(options.to ? " \u2192 version ".concat(options.to) : '', "!")));
|
|
111
|
+
return [3, 11];
|
|
112
|
+
case 10:
|
|
113
|
+
err_1 = _b.sent();
|
|
114
|
+
s.stop();
|
|
115
|
+
console.error(color.red("\u00D7 Upgrade failed."));
|
|
116
|
+
console.error(color.dim(String(err_1)));
|
|
117
|
+
return [3, 11];
|
|
118
|
+
case 11: return [2];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
}
|