@aristobyte-ui/cli 2.3.6 → 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,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
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);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.init = init;
|
|
43
|
+
var execa_1 = require("execa");
|
|
44
|
+
var prompts_1 = require("@clack/prompts");
|
|
45
|
+
var picocolors_1 = __importDefault(require("picocolors"));
|
|
46
|
+
var TEMPLATES = [
|
|
47
|
+
{
|
|
48
|
+
id: "aristobyte-ui-template-nextjs-15-app-router",
|
|
49
|
+
name: "Next App Router",
|
|
50
|
+
desc: "A Next.js 15 with app-router directory template pre-configured with AristoByteUI.",
|
|
51
|
+
repo: "https://github.com/aristobyte-team/aristobyte-ui-template-nextjs-15-app-router.git",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: "aristobyte-ui-template-nextjs-15-pages",
|
|
55
|
+
name: "Next Pages",
|
|
56
|
+
desc: "A Next.js 15 with pages directory template pre-configured with AristoByteUI.",
|
|
57
|
+
repo: "https://github.com/aristobyte-team/aristobyte-ui-template-nextjs-15-pages.git",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: "aristobyte-ui-template-vite",
|
|
61
|
+
name: "Vite",
|
|
62
|
+
desc: "A Vite template pre-configured with AristoByteUI.",
|
|
63
|
+
repo: "https://github.com/aristobyte-team/aristobyte-ui-template-vite.git",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "aristobyte-ui-template-vike",
|
|
67
|
+
name: "Vike",
|
|
68
|
+
desc: "A Vike template pre-configured with AristoByteUI.",
|
|
69
|
+
repo: "https://github.com/aristobyte-team/aristobyte-ui-template-vike.git",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
id: "aristobyte-ui-template-astro",
|
|
73
|
+
name: "Astro",
|
|
74
|
+
desc: "An Astro template pre-configured with AristoByteUI.",
|
|
75
|
+
repo: "https://github.com/aristobyte-team/aristobyte-ui-template-astro.git",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: "aristobyte-ui-template-rsbuild",
|
|
79
|
+
name: "RS Build",
|
|
80
|
+
desc: "An RS Build template pre-configured with AristoByteUI.",
|
|
81
|
+
repo: "https://github.com/aristobyte-team/aristobyte-ui-template-rsbuild.git",
|
|
82
|
+
},
|
|
83
|
+
];
|
|
84
|
+
var PACKAGE_MANAGERS = ["npm", "yarn", "pnpm", "bun"];
|
|
85
|
+
var DEFAULT_NAME = "aristobyte-ui-app";
|
|
86
|
+
function init(myProjectName, options) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
88
|
+
var projectName, template, templateIndex, packageManager, packageManagerIndex, s, err_1;
|
|
89
|
+
return __generator(this, function (_a) {
|
|
90
|
+
switch (_a.label) {
|
|
91
|
+
case 0:
|
|
92
|
+
if (options.listTemplates) {
|
|
93
|
+
console.log("".concat(picocolors_1.default.cyan("Available templates:"), "\n").concat(TEMPLATES.map(function (t) {
|
|
94
|
+
return "".concat(picocolors_1.default.green("◇"), " ").concat(t.id.split("aristobyte-ui-template-")[1], " - ").concat(picocolors_1.default.gray(t.desc));
|
|
95
|
+
}).join("\n")));
|
|
96
|
+
process.exit(0);
|
|
97
|
+
}
|
|
98
|
+
if (options.listPackageManagers) {
|
|
99
|
+
console.log("".concat(picocolors_1.default.cyan("Available package managers:"), "\n").concat(PACKAGE_MANAGERS.map(function (pm) { return "".concat(picocolors_1.default.green("◇"), " ").concat(pm); }).join("\n")));
|
|
100
|
+
process.exit(0);
|
|
101
|
+
}
|
|
102
|
+
console.log(picocolors_1.default.cyan("┌ Create a new project"));
|
|
103
|
+
projectName = myProjectName || DEFAULT_NAME;
|
|
104
|
+
if (!!myProjectName) return [3, 2];
|
|
105
|
+
return [4, (0, prompts_1.text)({
|
|
106
|
+
message: "New project name (Enter to skip with default name)",
|
|
107
|
+
placeholder: DEFAULT_NAME,
|
|
108
|
+
defaultValue: DEFAULT_NAME,
|
|
109
|
+
})];
|
|
110
|
+
case 1:
|
|
111
|
+
projectName = (_a.sent());
|
|
112
|
+
return [3, 3];
|
|
113
|
+
case 2:
|
|
114
|
+
console.log("".concat(picocolors_1.default.gray("│"), "\n").concat(picocolors_1.default.green("◇"), " ").concat(picocolors_1.default.white("Your project name is:"), "\n").concat(picocolors_1.default.gray("│"), " ").concat(picocolors_1.default.green(projectName)));
|
|
115
|
+
_a.label = 3;
|
|
116
|
+
case 3:
|
|
117
|
+
template = TEMPLATES.find(function (t) {
|
|
118
|
+
var _a, _b;
|
|
119
|
+
return t.id ===
|
|
120
|
+
"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(" ", ""));
|
|
121
|
+
});
|
|
122
|
+
if (!!template) return [3, 5];
|
|
123
|
+
return [4, (0, prompts_1.select)({
|
|
124
|
+
message: "Select a template (Enter to select)",
|
|
125
|
+
options: TEMPLATES.map(function (t, i) { return ({
|
|
126
|
+
value: i.toString(),
|
|
127
|
+
label: "".concat(t.name, " (").concat(t.desc, ")"),
|
|
128
|
+
}); }),
|
|
129
|
+
})];
|
|
130
|
+
case 4:
|
|
131
|
+
templateIndex = _a.sent();
|
|
132
|
+
template = TEMPLATES[Number(templateIndex)];
|
|
133
|
+
return [3, 6];
|
|
134
|
+
case 5:
|
|
135
|
+
console.log("".concat(picocolors_1.default.gray("│"), "\n").concat(picocolors_1.default.green("◇"), " ").concat(picocolors_1.default.white("Template selected:"), "\n").concat(picocolors_1.default.gray("│"), " ").concat(picocolors_1.default.green(template.name)));
|
|
136
|
+
_a.label = 6;
|
|
137
|
+
case 6:
|
|
138
|
+
packageManager = PACKAGE_MANAGERS.find(function (pm) { var _a; return pm.toLowerCase() === ((_a = options.packageManager) === null || _a === void 0 ? void 0 : _a.toLowerCase()); });
|
|
139
|
+
if (!!packageManager) return [3, 8];
|
|
140
|
+
return [4, (0, prompts_1.select)({
|
|
141
|
+
message: "Select a package manager (Enter to select)",
|
|
142
|
+
options: PACKAGE_MANAGERS.map(function (pm, i) { return ({
|
|
143
|
+
value: i.toString(),
|
|
144
|
+
label: pm,
|
|
145
|
+
}); }),
|
|
146
|
+
})];
|
|
147
|
+
case 7:
|
|
148
|
+
packageManagerIndex = _a.sent();
|
|
149
|
+
packageManager = PACKAGE_MANAGERS[Number(packageManagerIndex)];
|
|
150
|
+
return [3, 9];
|
|
151
|
+
case 8:
|
|
152
|
+
console.log("".concat(picocolors_1.default.gray("│"), "\n").concat(picocolors_1.default.green("◇"), " ").concat(picocolors_1.default.white("Package manager selected:"), "\n").concat(picocolors_1.default.gray("│"), " ").concat(picocolors_1.default.green(packageManager)));
|
|
153
|
+
_a.label = 9;
|
|
154
|
+
case 9:
|
|
155
|
+
console.log("".concat(picocolors_1.default.gray("│"), "\n").concat(picocolors_1.default.green("◇"), " ").concat(picocolors_1.default.cyan("Template created successfully!"), "\n").concat(picocolors_1.default.gray("│")));
|
|
156
|
+
s = (0, prompts_1.spinner)();
|
|
157
|
+
_a.label = 10;
|
|
158
|
+
case 10:
|
|
159
|
+
_a.trys.push([10, 13, , 14]);
|
|
160
|
+
s.start("Preparing '".concat(template.name, "' with ").concat(packageManager, " configuration..."));
|
|
161
|
+
return [4, (0, execa_1.execa)("git", [
|
|
162
|
+
"clone",
|
|
163
|
+
"--branch",
|
|
164
|
+
packageManager,
|
|
165
|
+
"--single-branch",
|
|
166
|
+
template.repo,
|
|
167
|
+
projectName,
|
|
168
|
+
], { stdio: "ignore" })];
|
|
169
|
+
case 11:
|
|
170
|
+
_a.sent();
|
|
171
|
+
return [4, (0, execa_1.execa)("rm", ["-rf", ".git"], { cwd: projectName, stdio: "ignore" })];
|
|
172
|
+
case 12:
|
|
173
|
+
_a.sent();
|
|
174
|
+
s.stop("".concat(picocolors_1.default.green("✔ Project initialized successfully!")));
|
|
175
|
+
console.log("\n".concat(picocolors_1.default.gray("│"), "\n").concat(picocolors_1.default.green("◇"), " ").concat(picocolors_1.default.cyan("To get started:"), "\n").concat(picocolors_1.default.gray("│"), "\n").concat(picocolors_1.default.gray("├─"), " ").concat(picocolors_1.default.white("cd " + projectName), "\n").concat(picocolors_1.default.gray("├─"), " ").concat(picocolors_1.default.white("".concat(packageManager, " install")), "\n").concat(picocolors_1.default.gray("├─"), " ").concat(picocolors_1.default.white("".concat(packageManager, " run dev"))));
|
|
176
|
+
return [3, 14];
|
|
177
|
+
case 13:
|
|
178
|
+
err_1 = _a.sent();
|
|
179
|
+
s.stop();
|
|
180
|
+
console.error(picocolors_1.default.red("× Failed to initialize project"), err_1);
|
|
181
|
+
return [3, 14];
|
|
182
|
+
case 14: return [2];
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
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);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __values = (this && this.__values) || function(o) {
|
|
39
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
+
if (m) return m.call(o);
|
|
41
|
+
if (o && typeof o.length === "number") return {
|
|
42
|
+
next: function () {
|
|
43
|
+
if (o && i >= o.length) o = void 0;
|
|
44
|
+
return { value: o && o[i++], done: !o };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.remoteList = remoteList;
|
|
54
|
+
exports.list = list;
|
|
55
|
+
var fs_1 = __importDefault(require("fs"));
|
|
56
|
+
var picocolors_1 = __importDefault(require("picocolors"));
|
|
57
|
+
var getCurrentPackageManager_1 = require("../utils/getCurrentPackageManager");
|
|
58
|
+
function remoteList() {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
60
|
+
return [2];
|
|
61
|
+
}); });
|
|
62
|
+
}
|
|
63
|
+
function list(options, endBlock) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
+
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;
|
|
66
|
+
var e_1, _a;
|
|
67
|
+
var _b;
|
|
68
|
+
return __generator(this, function (_c) {
|
|
69
|
+
switch (_c.label) {
|
|
70
|
+
case 0:
|
|
71
|
+
handled = false;
|
|
72
|
+
if (!options.all) return [3, 6];
|
|
73
|
+
handled = true;
|
|
74
|
+
url = 'https://registry.npmjs.org/-/org/aristobyte-ui/package';
|
|
75
|
+
omit_1 = ['cli', 'react'];
|
|
76
|
+
_c.label = 1;
|
|
77
|
+
case 1:
|
|
78
|
+
_c.trys.push([1, 4, , 5]);
|
|
79
|
+
return [4, fetch(url)];
|
|
80
|
+
case 2:
|
|
81
|
+
res = _c.sent();
|
|
82
|
+
if (!res.ok)
|
|
83
|
+
throw new Error("Registry request failed: ".concat(res.status));
|
|
84
|
+
return [4, res.json()];
|
|
85
|
+
case 3:
|
|
86
|
+
data = _c.sent();
|
|
87
|
+
packages = Object.keys(data)
|
|
88
|
+
.map(function (dep) { return dep.split('/')[1]; })
|
|
89
|
+
.filter(function (dep) { return !omit_1.includes(dep); })
|
|
90
|
+
.sort();
|
|
91
|
+
console.log("".concat(picocolors_1.default.green('◇'), " ").concat(picocolors_1.default.white('Listing AristoByteUI packages:'), "\n").concat(packages.map(function (dep) { return "".concat(picocolors_1.default.gray('|'), " ").concat(picocolors_1.default.cyan(dep)); }).join('\n')));
|
|
92
|
+
return [3, 5];
|
|
93
|
+
case 4:
|
|
94
|
+
err_1 = _c.sent();
|
|
95
|
+
console.error(picocolors_1.default.red('× Failed to fetch package list from npm registry'));
|
|
96
|
+
console.error(picocolors_1.default.dim(String(err_1)));
|
|
97
|
+
return [3, 5];
|
|
98
|
+
case 5:
|
|
99
|
+
if (endBlock)
|
|
100
|
+
console.log(picocolors_1.default.green('◇'));
|
|
101
|
+
process.exit(0);
|
|
102
|
+
_c.label = 6;
|
|
103
|
+
case 6:
|
|
104
|
+
if (options.installed) {
|
|
105
|
+
handled = true;
|
|
106
|
+
try {
|
|
107
|
+
pkgJson = JSON.parse(fs_1.default.readFileSync('package.json', 'utf-8'));
|
|
108
|
+
deps = pkgJson.dependencies || {};
|
|
109
|
+
aristobyteDeps = Object.keys(deps)
|
|
110
|
+
.filter(function (d) { return d.startsWith('@aristobyte-ui/'); })
|
|
111
|
+
.map(function (dep) { return (dep.includes('react') ? 'all' : dep.split('/')[1]); });
|
|
112
|
+
console.log("".concat(picocolors_1.default.green('◇'), " ").concat(picocolors_1.default.white('Listing installed AristoByteUI packages:'), "\n").concat(aristobyteDeps.map(function (dep) { return "".concat(picocolors_1.default.gray('|'), " ").concat(picocolors_1.default.cyan(dep)); }).join('\n')));
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
console.error(picocolors_1.default.red('× Failed to list packages'), err);
|
|
116
|
+
}
|
|
117
|
+
if (endBlock)
|
|
118
|
+
console.log(picocolors_1.default.green('◇'));
|
|
119
|
+
process.exit(0);
|
|
120
|
+
}
|
|
121
|
+
if (!options.outdated) return [3, 21];
|
|
122
|
+
handled = true;
|
|
123
|
+
packagesToUpdate = [];
|
|
124
|
+
_c.label = 7;
|
|
125
|
+
case 7:
|
|
126
|
+
_c.trys.push([7, 19, , 20]);
|
|
127
|
+
pkgJson = JSON.parse(fs_1.default.readFileSync('package.json', 'utf-8'));
|
|
128
|
+
deps = pkgJson.dependencies || {};
|
|
129
|
+
installed = Object.keys(deps).filter(function (d) { return d.startsWith('@aristobyte-ui/'); });
|
|
130
|
+
if (installed.length === 0) {
|
|
131
|
+
console.log(picocolors_1.default.yellow('No AristoByteUI packages installed.'));
|
|
132
|
+
process.exit(0);
|
|
133
|
+
}
|
|
134
|
+
console.log("".concat(picocolors_1.default.green('◇'), " ").concat(picocolors_1.default.white('Checking for outdated AristoByteUI packages...')));
|
|
135
|
+
_c.label = 8;
|
|
136
|
+
case 8:
|
|
137
|
+
_c.trys.push([8, 16, 17, 18]);
|
|
138
|
+
installed_1 = __values(installed), installed_1_1 = installed_1.next();
|
|
139
|
+
_c.label = 9;
|
|
140
|
+
case 9:
|
|
141
|
+
if (!!installed_1_1.done) return [3, 15];
|
|
142
|
+
pkg = installed_1_1.value;
|
|
143
|
+
localVersion = deps[pkg].replace(/^[^\d]*/, '');
|
|
144
|
+
registryUrl = "https://registry.npmjs.org/".concat(pkg);
|
|
145
|
+
_c.label = 10;
|
|
146
|
+
case 10:
|
|
147
|
+
_c.trys.push([10, 13, , 14]);
|
|
148
|
+
return [4, fetch(registryUrl)];
|
|
149
|
+
case 11:
|
|
150
|
+
res = _c.sent();
|
|
151
|
+
if (!res.ok)
|
|
152
|
+
throw new Error("Registry request failed: ".concat(res.status));
|
|
153
|
+
return [4, res.json()];
|
|
154
|
+
case 12:
|
|
155
|
+
data = _c.sent();
|
|
156
|
+
latest = (_b = data['dist-tags']) === null || _b === void 0 ? void 0 : _b.latest;
|
|
157
|
+
if (!latest)
|
|
158
|
+
return [3, 14];
|
|
159
|
+
if (latest !== localVersion) {
|
|
160
|
+
p = pkg.replace('@aristobyte-ui/', '');
|
|
161
|
+
packagesToUpdate.push([p, latest]);
|
|
162
|
+
console.log("".concat(picocolors_1.default.gray('|'), " ").concat(picocolors_1.default.cyan(p), " ") + "".concat(picocolors_1.default.red(localVersion), " \u2192 ").concat(picocolors_1.default.green(latest)));
|
|
163
|
+
}
|
|
164
|
+
return [3, 14];
|
|
165
|
+
case 13:
|
|
166
|
+
err_2 = _c.sent();
|
|
167
|
+
console.error(picocolors_1.default.red("\u00D7 Failed to check ".concat(pkg, " on npm registry")), err_2);
|
|
168
|
+
return [3, 14];
|
|
169
|
+
case 14:
|
|
170
|
+
installed_1_1 = installed_1.next();
|
|
171
|
+
return [3, 9];
|
|
172
|
+
case 15: return [3, 18];
|
|
173
|
+
case 16:
|
|
174
|
+
e_1_1 = _c.sent();
|
|
175
|
+
e_1 = { error: e_1_1 };
|
|
176
|
+
return [3, 18];
|
|
177
|
+
case 17:
|
|
178
|
+
try {
|
|
179
|
+
if (installed_1_1 && !installed_1_1.done && (_a = installed_1.return)) _a.call(installed_1);
|
|
180
|
+
}
|
|
181
|
+
finally { if (e_1) throw e_1.error; }
|
|
182
|
+
return [7];
|
|
183
|
+
case 18: return [3, 20];
|
|
184
|
+
case 19:
|
|
185
|
+
err_3 = _c.sent();
|
|
186
|
+
console.error(picocolors_1.default.red('× Failed to check outdated packages'), err_3);
|
|
187
|
+
return [3, 20];
|
|
188
|
+
case 20:
|
|
189
|
+
pkgManager = (0, getCurrentPackageManager_1.getCurrentPackageManager)();
|
|
190
|
+
if (endBlock)
|
|
191
|
+
console.log("".concat(picocolors_1.default.gray('|'), "\n").concat(picocolors_1.default.green('◇'), " ").concat(packagesToUpdate.length > 0 ? picocolors_1.default.gray("Tip: run '".concat(pkgManager, " upgrade ").concat(packagesToUpdate.map(function (p) { return "".concat(p[0], "@").concat(p[1]); }).join(' '), "'")) : picocolors_1.default.green('✔ Everything is up to date!')));
|
|
192
|
+
process.exit(0);
|
|
193
|
+
_c.label = 21;
|
|
194
|
+
case 21:
|
|
195
|
+
if (!handled) {
|
|
196
|
+
console.log(picocolors_1.default.gray("No option provided. Use 'aristobyte-ui list --help' for usage."));
|
|
197
|
+
}
|
|
198
|
+
return [2];
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
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);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.remove = remove;
|
|
43
|
+
var getCurrentPackageManager_1 = require("../utils/getCurrentPackageManager");
|
|
44
|
+
var prompts_1 = require("@clack/prompts");
|
|
45
|
+
var execa_1 = require("execa");
|
|
46
|
+
var picocolors_1 = __importDefault(require("picocolors"));
|
|
47
|
+
var list_1 = require("./list");
|
|
48
|
+
function remove(component, options) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
50
|
+
var pkgManager, s, packageName, pkgName, err_1;
|
|
51
|
+
return __generator(this, function (_a) {
|
|
52
|
+
switch (_a.label) {
|
|
53
|
+
case 0:
|
|
54
|
+
if (!options.list) return [3, 2];
|
|
55
|
+
return [4, (0, list_1.list)({ installed: true }, true)];
|
|
56
|
+
case 1:
|
|
57
|
+
_a.sent();
|
|
58
|
+
_a.label = 2;
|
|
59
|
+
case 2:
|
|
60
|
+
pkgManager = (0, getCurrentPackageManager_1.getCurrentPackageManager)();
|
|
61
|
+
if (options.packageManager) {
|
|
62
|
+
console.log("".concat(picocolors_1.default.cyan('Current package manager:'), "\n").concat(picocolors_1.default.green('◇'), " ").concat(pkgManager));
|
|
63
|
+
process.exit(0);
|
|
64
|
+
}
|
|
65
|
+
s = (0, prompts_1.spinner)();
|
|
66
|
+
if (!!component) return [3, 5];
|
|
67
|
+
console.log("".concat(picocolors_1.default.green('◇'), " ").concat(picocolors_1.default.white('You did not specify, which package should be removed'), "\n").concat(picocolors_1.default.gray('|'), " ").concat(picocolors_1.default.gray('Please select one of the installed packages below to proceed.'), "\n").concat(picocolors_1.default.gray('|')));
|
|
68
|
+
return [4, (0, list_1.list)({ installed: true })];
|
|
69
|
+
case 3:
|
|
70
|
+
_a.sent();
|
|
71
|
+
return [4, (0, prompts_1.text)({
|
|
72
|
+
message: "Component name to remove (Required filled)",
|
|
73
|
+
placeholder: '<package-name>',
|
|
74
|
+
})];
|
|
75
|
+
case 4:
|
|
76
|
+
packageName = (_a.sent());
|
|
77
|
+
return [3, 6];
|
|
78
|
+
case 5:
|
|
79
|
+
packageName = component;
|
|
80
|
+
_a.label = 6;
|
|
81
|
+
case 6:
|
|
82
|
+
if (!packageName) {
|
|
83
|
+
console.log(picocolors_1.default.red("Invalid Package name. <package-name> should be specified:\naristobyte-ui remove <package-name>"));
|
|
84
|
+
return [2];
|
|
85
|
+
}
|
|
86
|
+
_a.label = 7;
|
|
87
|
+
case 7:
|
|
88
|
+
_a.trys.push([7, 9, , 10]);
|
|
89
|
+
pkgName = packageName === 'all' ? '@aristobyte-ui/react' : "@aristobyte-ui/".concat(packageName);
|
|
90
|
+
s.start("Removing ".concat(pkgName, "..."));
|
|
91
|
+
return [4, (0, execa_1.execa)(pkgManager, ['remove', pkgName], { stdio: 'inherit' })];
|
|
92
|
+
case 8:
|
|
93
|
+
_a.sent();
|
|
94
|
+
s.stop();
|
|
95
|
+
console.log(picocolors_1.default.green("\u2714 ".concat(pkgName, " removed successfully!")));
|
|
96
|
+
return [3, 10];
|
|
97
|
+
case 9:
|
|
98
|
+
err_1 = _a.sent();
|
|
99
|
+
s.stop();
|
|
100
|
+
console.error(picocolors_1.default.red("\u00D7 Failed to remove component ".concat(packageName)), err_1);
|
|
101
|
+
return [3, 10];
|
|
102
|
+
case 10: return [2];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
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);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __values = (this && this.__values) || function(o) {
|
|
39
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
+
if (m) return m.call(o);
|
|
41
|
+
if (o && typeof o.length === "number") return {
|
|
42
|
+
next: function () {
|
|
43
|
+
if (o && i >= o.length) o = void 0;
|
|
44
|
+
return { value: o && o[i++], done: !o };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.upgrade = upgrade;
|
|
54
|
+
var getCurrentPackageManager_1 = require("../utils/getCurrentPackageManager");
|
|
55
|
+
var prompts_1 = require("@clack/prompts");
|
|
56
|
+
var execa_1 = require("execa");
|
|
57
|
+
var picocolors_1 = __importDefault(require("picocolors"));
|
|
58
|
+
function upgrade(component, options) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
+
var s, pkgManager, isAll, targets, versionSuffix, sLabel, targets_1, targets_1_1, pkg, fullSpecifier, e_1_1, err_1;
|
|
61
|
+
var e_1, _a;
|
|
62
|
+
return __generator(this, function (_b) {
|
|
63
|
+
switch (_b.label) {
|
|
64
|
+
case 0:
|
|
65
|
+
if (!component && !options.all) {
|
|
66
|
+
console.error(picocolors_1.default.red('× No component specified for upgrade.'));
|
|
67
|
+
console.log(picocolors_1.default.gray("Use: 'aristobyte-ui upgrade <component>' or 'aristobyte-ui upgrade --all'"));
|
|
68
|
+
process.exit(0);
|
|
69
|
+
}
|
|
70
|
+
s = (0, prompts_1.spinner)();
|
|
71
|
+
pkgManager = (0, getCurrentPackageManager_1.getCurrentPackageManager)();
|
|
72
|
+
_b.label = 1;
|
|
73
|
+
case 1:
|
|
74
|
+
_b.trys.push([1, 10, , 11]);
|
|
75
|
+
isAll = options.all || component === 'all';
|
|
76
|
+
targets = isAll ? ['@aristobyte-ui/react'] : component ? ["@aristobyte-ui/".concat(component)] : [];
|
|
77
|
+
if (targets.length === 0) {
|
|
78
|
+
console.error(picocolors_1.default.red('× No component specified for upgrade.'));
|
|
79
|
+
console.log(picocolors_1.default.gray('Use: aristobyte-ui upgrade <component> or --all'));
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
versionSuffix = options.to ? "@".concat(options.to) : '';
|
|
83
|
+
sLabel = isAll ? 'Upgrading all AristoByteUI components...' : "Upgrading ".concat(targets.join(', '), "...");
|
|
84
|
+
s.start(sLabel);
|
|
85
|
+
_b.label = 2;
|
|
86
|
+
case 2:
|
|
87
|
+
_b.trys.push([2, 7, 8, 9]);
|
|
88
|
+
targets_1 = __values(targets), targets_1_1 = targets_1.next();
|
|
89
|
+
_b.label = 3;
|
|
90
|
+
case 3:
|
|
91
|
+
if (!!targets_1_1.done) return [3, 6];
|
|
92
|
+
pkg = targets_1_1.value;
|
|
93
|
+
fullSpecifier = "".concat(pkg).concat(versionSuffix);
|
|
94
|
+
return [4, (0, execa_1.execa)(pkgManager, ['upgrade', fullSpecifier], {
|
|
95
|
+
stdio: 'inherit',
|
|
96
|
+
})];
|
|
97
|
+
case 4:
|
|
98
|
+
_b.sent();
|
|
99
|
+
_b.label = 5;
|
|
100
|
+
case 5:
|
|
101
|
+
targets_1_1 = targets_1.next();
|
|
102
|
+
return [3, 3];
|
|
103
|
+
case 6: return [3, 9];
|
|
104
|
+
case 7:
|
|
105
|
+
e_1_1 = _b.sent();
|
|
106
|
+
e_1 = { error: e_1_1 };
|
|
107
|
+
return [3, 9];
|
|
108
|
+
case 8:
|
|
109
|
+
try {
|
|
110
|
+
if (targets_1_1 && !targets_1_1.done && (_a = targets_1.return)) _a.call(targets_1);
|
|
111
|
+
}
|
|
112
|
+
finally { if (e_1) throw e_1.error; }
|
|
113
|
+
return [7];
|
|
114
|
+
case 9:
|
|
115
|
+
s.stop();
|
|
116
|
+
console.log(picocolors_1.default.green("\u2714 Upgrade complete".concat(options.to ? " \u2192 version ".concat(options.to) : '', "!")));
|
|
117
|
+
return [3, 11];
|
|
118
|
+
case 10:
|
|
119
|
+
err_1 = _b.sent();
|
|
120
|
+
s.stop();
|
|
121
|
+
console.error(picocolors_1.default.red("\u00D7 Upgrade failed."));
|
|
122
|
+
console.error(picocolors_1.default.dim(String(err_1)));
|
|
123
|
+
return [3, 11];
|
|
124
|
+
case 11: return [2];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|