@vercube/cli 0.0.3 → 0.0.5

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.
@@ -0,0 +1 @@
1
+ export { };
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  import { defineCommand, runMain } from "citty";
3
3
  import { build, createDevServer, createVercube, watch } from "@vercube/devkit";
4
4
  import { consola } from "consola";
5
- import * as tty from "node:tty";
5
+ import { colors } from "consola/utils";
6
6
  import { hasTTY } from "std-env";
7
7
  import { relative, resolve } from "pathe";
8
8
  import { existsSync } from "node:fs";
@@ -10,11 +10,11 @@ import { downloadTemplate, startShell } from "giget";
10
10
  import { installDependencies } from "nypm";
11
11
  import { x } from "tinyexec";
12
12
 
13
- //#region packages/cli/package.json
14
- var version = "0.0.2";
13
+ //#region package.json
14
+ var version = "0.0.4";
15
15
 
16
16
  //#endregion
17
- //#region packages/cli/src/commands/build.ts
17
+ //#region src/commands/build.ts
18
18
  const buildCommand = defineCommand({
19
19
  meta: {
20
20
  name: "build",
@@ -27,7 +27,7 @@ const buildCommand = defineCommand({
27
27
  });
28
28
 
29
29
  //#endregion
30
- //#region packages/cli/src/commands/dev.ts
30
+ //#region src/commands/dev.ts
31
31
  const devCommand = defineCommand({
32
32
  meta: {
33
33
  name: "dev",
@@ -41,78 +41,7 @@ const devCommand = defineCommand({
41
41
  });
42
42
 
43
43
  //#endregion
44
- //#region node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs
45
- const { env = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
46
- const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
47
- const isForced = "FORCE_COLOR" in env || argv.includes("--color");
48
- const isWindows = platform === "win32";
49
- const isDumbTerminal = env.TERM === "dumb";
50
- const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal;
51
- const isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
52
- const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
53
- function replaceClose(index, string, close, replace, head = string.slice(0, Math.max(0, index)) + replace, tail = string.slice(Math.max(0, index + close.length)), next = tail.indexOf(close)) {
54
- return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
55
- }
56
- function clearBleed(index, string, open, close, replace) {
57
- return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
58
- }
59
- function filterEmpty(open, close, replace = open, at = open.length + 1) {
60
- return (string) => string || !(string === "" || string === void 0) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
61
- }
62
- function init(open, close, replace) {
63
- return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
64
- }
65
- const colorDefs = {
66
- reset: init(0, 0),
67
- bold: init(1, 22, "\x1B[22m\x1B[1m"),
68
- dim: init(2, 22, "\x1B[22m\x1B[2m"),
69
- italic: init(3, 23),
70
- underline: init(4, 24),
71
- inverse: init(7, 27),
72
- hidden: init(8, 28),
73
- strikethrough: init(9, 29),
74
- black: init(30, 39),
75
- red: init(31, 39),
76
- green: init(32, 39),
77
- yellow: init(33, 39),
78
- blue: init(34, 39),
79
- magenta: init(35, 39),
80
- cyan: init(36, 39),
81
- white: init(37, 39),
82
- gray: init(90, 39),
83
- bgBlack: init(40, 49),
84
- bgRed: init(41, 49),
85
- bgGreen: init(42, 49),
86
- bgYellow: init(43, 49),
87
- bgBlue: init(44, 49),
88
- bgMagenta: init(45, 49),
89
- bgCyan: init(46, 49),
90
- bgWhite: init(47, 49),
91
- blackBright: init(90, 39),
92
- redBright: init(91, 39),
93
- greenBright: init(92, 39),
94
- yellowBright: init(93, 39),
95
- blueBright: init(94, 39),
96
- magentaBright: init(95, 39),
97
- cyanBright: init(96, 39),
98
- whiteBright: init(97, 39),
99
- bgBlackBright: init(100, 49),
100
- bgRedBright: init(101, 49),
101
- bgGreenBright: init(102, 49),
102
- bgYellowBright: init(103, 49),
103
- bgBlueBright: init(104, 49),
104
- bgMagentaBright: init(105, 49),
105
- bgCyanBright: init(106, 49),
106
- bgWhiteBright: init(107, 49)
107
- };
108
- function createColors(useColor = isColorSupported) {
109
- return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
110
- }
111
- const colors = createColors();
112
- const ansiRegex = [String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`, String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`].join("|");
113
-
114
- //#endregion
115
- //#region packages/cli/src/utils/logo.ts
44
+ //#region src/utils/logo.ts
116
45
  const startColor = {
117
46
  r: 149,
118
47
  g: 100,
@@ -150,7 +79,7 @@ function applyGradient(icon$1, startColor$1, endColor$1) {
150
79
  const vercubeIcon = applyGradient(icon, startColor, endColor);
151
80
 
152
81
  //#endregion
153
- //#region packages/cli/src/commands/init.ts
82
+ //#region src/commands/init.ts
154
83
  const logger = consola.withTag(colors.whiteBright(colors.bold(colors.bgGreenBright(" vercube "))));
155
84
  const DEFAULT_REGISTRY = "https://raw.githubusercontent.com/vercube/starter/main/templates";
156
85
  const DEFAULT_TEMPLATE_NAME = "vercube";
@@ -295,7 +224,7 @@ const initCommand = defineCommand({
295
224
  });
296
225
 
297
226
  //#endregion
298
- //#region packages/cli/src/index.ts
227
+ //#region src/index.ts
299
228
  const main = defineCommand({
300
229
  meta: {
301
230
  name: "Vercube",
package/package.json CHANGED
@@ -1,27 +1,21 @@
1
1
  {
2
2
  "name": "@vercube/cli",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "CLI module for Vercube framework",
5
5
  "repository": "@vercube/cli",
6
6
  "license": "MIT",
7
7
  "sideEffects": false,
8
8
  "type": "module",
9
9
  "exports": {
10
- ".": {
11
- "types": "./dist/index.d.ts",
12
- "import": "./dist/index.mjs",
13
- "require": "./dist/index.cjs"
14
- }
10
+ ".": "./dist/index.mjs"
15
11
  },
16
- "main": "./dist/index.cjs",
17
- "module": "./dist/index.mjs",
18
- "types": "./dist/index.d.ts",
12
+ "types": "./dist/index.d.mts",
19
13
  "files": [
20
14
  "dist",
21
15
  "README.md"
22
16
  ],
23
17
  "bin": {
24
- "vercube": "./dist/index.cjs"
18
+ "vercube": "./dist/index.mjs"
25
19
  },
26
20
  "dependencies": {
27
21
  "citty": "0.1.6",
@@ -31,7 +25,7 @@
31
25
  "pathe": "2.0.3",
32
26
  "std-env": "3.9.0",
33
27
  "tinyexec": "1.0.1",
34
- "@vercube/devkit": "0.0.3"
28
+ "@vercube/devkit": "0.0.5"
35
29
  },
36
30
  "publishConfig": {
37
31
  "access": "public"
@@ -1,2 +0,0 @@
1
- import { type CommandDef } from "citty";
2
- export declare const buildCommand: CommandDef;
@@ -1,2 +0,0 @@
1
- import { type CommandDef } from "citty";
2
- export declare const devCommand: CommandDef;
@@ -1,4 +0,0 @@
1
- import { type CommandDef } from "citty";
2
- import { type ConsolaInstance } from "consola";
3
- export declare const logger: ConsolaInstance;
4
- export declare const initCommand: CommandDef;
package/dist/index.cjs DELETED
@@ -1,337 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- //#region rolldown:runtime
4
- var __create = Object.create;
5
- var __defProp = Object.defineProperty;
6
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
- var __getOwnPropNames = Object.getOwnPropertyNames;
8
- var __getProtoOf = Object.getPrototypeOf;
9
- var __hasOwnProp = Object.prototype.hasOwnProperty;
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
- key = keys[i];
13
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
21
- value: mod,
22
- enumerable: true
23
- }) : target, mod));
24
-
25
- //#endregion
26
- const citty = __toESM(require("citty"));
27
- const __vercube_devkit = __toESM(require("@vercube/devkit"));
28
- const consola = __toESM(require("consola"));
29
- const node_tty = __toESM(require("node:tty"));
30
- const std_env = __toESM(require("std-env"));
31
- const pathe = __toESM(require("pathe"));
32
- const node_fs = __toESM(require("node:fs"));
33
- const giget = __toESM(require("giget"));
34
- const nypm = __toESM(require("nypm"));
35
- const tinyexec = __toESM(require("tinyexec"));
36
-
37
- //#region packages/cli/package.json
38
- var version = "0.0.2";
39
-
40
- //#endregion
41
- //#region packages/cli/src/commands/build.ts
42
- const buildCommand = (0, citty.defineCommand)({
43
- meta: {
44
- name: "build",
45
- description: "Build the project"
46
- },
47
- run: async () => {
48
- const app = await (0, __vercube_devkit.createVercube)();
49
- await (0, __vercube_devkit.build)(app);
50
- }
51
- });
52
-
53
- //#endregion
54
- //#region packages/cli/src/commands/dev.ts
55
- const devCommand = (0, citty.defineCommand)({
56
- meta: {
57
- name: "dev",
58
- description: "Start development server"
59
- },
60
- async run() {
61
- const app = await (0, __vercube_devkit.createVercube)();
62
- (0, __vercube_devkit.createDevServer)(app);
63
- await (0, __vercube_devkit.watch)(app);
64
- }
65
- });
66
-
67
- //#endregion
68
- //#region node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs
69
- const { env = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
70
- const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
71
- const isForced = "FORCE_COLOR" in env || argv.includes("--color");
72
- const isWindows = platform === "win32";
73
- const isDumbTerminal = env.TERM === "dumb";
74
- const isCompatibleTerminal = node_tty && node_tty.isatty && node_tty.isatty(1) && env.TERM && !isDumbTerminal;
75
- const isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
76
- const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
77
- function replaceClose(index, string, close, replace, head = string.slice(0, Math.max(0, index)) + replace, tail = string.slice(Math.max(0, index + close.length)), next = tail.indexOf(close)) {
78
- return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
79
- }
80
- function clearBleed(index, string, open, close, replace) {
81
- return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
82
- }
83
- function filterEmpty(open, close, replace = open, at = open.length + 1) {
84
- return (string) => string || !(string === "" || string === void 0) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
85
- }
86
- function init(open, close, replace) {
87
- return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
88
- }
89
- const colorDefs = {
90
- reset: init(0, 0),
91
- bold: init(1, 22, "\x1B[22m\x1B[1m"),
92
- dim: init(2, 22, "\x1B[22m\x1B[2m"),
93
- italic: init(3, 23),
94
- underline: init(4, 24),
95
- inverse: init(7, 27),
96
- hidden: init(8, 28),
97
- strikethrough: init(9, 29),
98
- black: init(30, 39),
99
- red: init(31, 39),
100
- green: init(32, 39),
101
- yellow: init(33, 39),
102
- blue: init(34, 39),
103
- magenta: init(35, 39),
104
- cyan: init(36, 39),
105
- white: init(37, 39),
106
- gray: init(90, 39),
107
- bgBlack: init(40, 49),
108
- bgRed: init(41, 49),
109
- bgGreen: init(42, 49),
110
- bgYellow: init(43, 49),
111
- bgBlue: init(44, 49),
112
- bgMagenta: init(45, 49),
113
- bgCyan: init(46, 49),
114
- bgWhite: init(47, 49),
115
- blackBright: init(90, 39),
116
- redBright: init(91, 39),
117
- greenBright: init(92, 39),
118
- yellowBright: init(93, 39),
119
- blueBright: init(94, 39),
120
- magentaBright: init(95, 39),
121
- cyanBright: init(96, 39),
122
- whiteBright: init(97, 39),
123
- bgBlackBright: init(100, 49),
124
- bgRedBright: init(101, 49),
125
- bgGreenBright: init(102, 49),
126
- bgYellowBright: init(103, 49),
127
- bgBlueBright: init(104, 49),
128
- bgMagentaBright: init(105, 49),
129
- bgCyanBright: init(106, 49),
130
- bgWhiteBright: init(107, 49)
131
- };
132
- function createColors(useColor = isColorSupported) {
133
- return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
134
- }
135
- const colors = createColors();
136
- const ansiRegex = [String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`, String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`].join("|");
137
-
138
- //#endregion
139
- //#region packages/cli/src/utils/logo.ts
140
- const startColor = {
141
- r: 149,
142
- g: 100,
143
- b: 245
144
- };
145
- const endColor = {
146
- r: 111,
147
- g: 114,
148
- b: 245
149
- };
150
- const icon = [
151
- " _ ",
152
- " | | ",
153
- " __ _____ _ __ ___ _ _| |__ ___ ",
154
- " \\ \\ / / _ \\ '__/ __| | | | '_ \\ / _ \\",
155
- String.raw` \ V / __/ | | (__| |_| | |_) | __/`,
156
- String.raw` \_/ \___|_| \___|\__,_|_.__/ \___|`,
157
- " ",
158
- " "
159
- ];
160
- function interpolateColor(startColor$1, endColor$1, factor) {
161
- const r = Math.round(startColor$1.r + factor * (endColor$1.r - startColor$1.r));
162
- const g = Math.round(startColor$1.g + factor * (endColor$1.g - startColor$1.g));
163
- const b = Math.round(startColor$1.b + factor * (endColor$1.b - startColor$1.b));
164
- return `\u001B[38;2;${r};${g};${b}m`;
165
- }
166
- function applyGradient(icon$1, startColor$1, endColor$1) {
167
- const totalLines = icon$1.length;
168
- return icon$1.map((line, index) => {
169
- const factor = index / (totalLines - 1);
170
- const color = interpolateColor(startColor$1, endColor$1, factor);
171
- return color + line;
172
- }).join("\n");
173
- }
174
- const vercubeIcon = applyGradient(icon, startColor, endColor);
175
-
176
- //#endregion
177
- //#region packages/cli/src/commands/init.ts
178
- const logger = consola.consola.withTag(colors.whiteBright(colors.bold(colors.bgGreenBright(" vercube "))));
179
- const DEFAULT_REGISTRY = "https://raw.githubusercontent.com/vercube/starter/main/templates";
180
- const DEFAULT_TEMPLATE_NAME = "vercube";
181
- const pms = {
182
- npm: void 0,
183
- pnpm: void 0,
184
- yarn: void 0,
185
- bun: void 0,
186
- deno: void 0
187
- };
188
- const packageManagerOptions = Object.keys(pms);
189
- const initCommand = (0, citty.defineCommand)({
190
- meta: {
191
- name: "init",
192
- description: "Initialize a new Vercube app"
193
- },
194
- args: {
195
- dir: {
196
- type: "positional",
197
- description: "Project directory",
198
- default: ""
199
- },
200
- force: {
201
- type: "boolean",
202
- alias: "f",
203
- description: "Override existing directory"
204
- },
205
- install: {
206
- type: "boolean",
207
- default: true,
208
- description: "Skip installing dependencies"
209
- },
210
- gitInit: {
211
- type: "boolean",
212
- description: "Initialize git repository",
213
- default: true
214
- },
215
- packageManager: {
216
- type: "string",
217
- description: "Package manager choice (npm, pnpm, yarn, bun)",
218
- default: "pnpm"
219
- }
220
- },
221
- async run(ctx) {
222
- if (std_env.hasTTY) process.stdout.write(`\n${vercubeIcon}\n\n`);
223
- consola.consola.info(`Welcome to ${colors.bold("Vercube")}!`);
224
- if (ctx.args.dir === "") ctx.args.dir = await logger.prompt("Where would you like to create your project?", {
225
- placeholder: "./vercube-app",
226
- type: "text",
227
- default: "vercube-app",
228
- cancel: "reject"
229
- }).catch(() => process.exit(1));
230
- const cwd = (0, pathe.resolve)(process.cwd());
231
- let templateDownloadPath = (0, pathe.resolve)(cwd, ctx.args.dir);
232
- logger.info(`Creating a new project in ${colors.cyan((0, pathe.relative)(cwd, templateDownloadPath) || templateDownloadPath)}.`);
233
- let shouldForce = Boolean(ctx.args.force);
234
- const shouldVerify = !shouldForce && (0, node_fs.existsSync)(templateDownloadPath);
235
- if (shouldVerify) {
236
- const selectedAction = await logger.prompt(`The directory ${colors.cyan(templateDownloadPath)} already exists. What would you like to do?`, {
237
- type: "select",
238
- options: [
239
- "Override its contents",
240
- "Select different directory",
241
- "Abort"
242
- ]
243
- });
244
- switch (selectedAction) {
245
- case "Override its contents": {
246
- shouldForce = true;
247
- break;
248
- }
249
- case "Select different directory": {
250
- templateDownloadPath = (0, pathe.resolve)(cwd, await logger.prompt("Please specify a different directory:", {
251
- type: "text",
252
- cancel: "reject"
253
- }).catch(() => process.exit(1)));
254
- break;
255
- }
256
- default: process.exit(1);
257
- }
258
- }
259
- let template;
260
- try {
261
- template = await (0, giget.downloadTemplate)(DEFAULT_TEMPLATE_NAME, {
262
- dir: templateDownloadPath,
263
- force: shouldForce,
264
- offline: Boolean(ctx.args.offline),
265
- preferOffline: Boolean(ctx.args.preferOffline),
266
- registry: DEFAULT_REGISTRY
267
- });
268
- } catch (error_) {
269
- if (process.env.DEBUG) throw error_;
270
- logger.error(error_.toString());
271
- process.exit(1);
272
- }
273
- const packageManagerArg = ctx.args.packageManager;
274
- const selectedPackageManager = packageManagerOptions.includes(packageManagerArg) ? packageManagerArg : await logger.prompt("Which package manager would you like to use?", {
275
- type: "select",
276
- options: packageManagerOptions,
277
- cancel: "reject"
278
- }).catch(() => process.exit(1));
279
- if (ctx.args.install === false) logger.info("Skipping install dependencies step.");
280
- else {
281
- logger.start("Installing dependencies...");
282
- try {
283
- await (0, nypm.installDependencies)({
284
- cwd: template.dir,
285
- packageManager: {
286
- name: selectedPackageManager,
287
- command: selectedPackageManager
288
- }
289
- });
290
- } catch (error_) {
291
- if (process.env.DEBUG) throw error_;
292
- logger.error(error_.toString());
293
- process.exit(1);
294
- }
295
- logger.success("Installation completed.");
296
- }
297
- if (ctx.args.gitInit === void 0) ctx.args.gitInit = await logger.prompt("Initialize git repository?", {
298
- type: "confirm",
299
- cancel: "reject"
300
- }).catch(() => process.exit(1));
301
- if (ctx.args.gitInit) {
302
- logger.info("Initializing git repository...\n");
303
- try {
304
- await (0, tinyexec.x)("git", ["init", template.dir], {
305
- throwOnError: true,
306
- nodeOptions: { stdio: "inherit" }
307
- });
308
- } catch (error_) {
309
- logger.warn(`Failed to initialize git repository: ${error_}`);
310
- }
311
- }
312
- logger.log("\n✨ Vercube project has been created! Next steps:");
313
- const relativeTemplateDir = (0, pathe.relative)(process.cwd(), template.dir) || ".";
314
- const runCmd = selectedPackageManager === "deno" ? "task" : "run";
315
- const nextSteps = [!ctx.args.shell && relativeTemplateDir.length > 1 && `\`cd ${relativeTemplateDir}\``, `Start development server with \`${selectedPackageManager} ${runCmd} dev\``].filter(Boolean);
316
- for (const step of nextSteps) logger.log(` › ${step}`);
317
- if (ctx.args.shell) (0, giget.startShell)(template.dir);
318
- }
319
- });
320
-
321
- //#endregion
322
- //#region packages/cli/src/index.ts
323
- const main = (0, citty.defineCommand)({
324
- meta: {
325
- name: "Vercube",
326
- version,
327
- description: "Vercube CLI"
328
- },
329
- subCommands: {
330
- build: buildCommand,
331
- dev: devCommand,
332
- init: initCommand
333
- }
334
- });
335
- (0, citty.runMain)(main);
336
-
337
- //#endregion
package/dist/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export declare const vercubeIcon: string;