@youcan/cli-kit 2.8.0 → 2.8.2

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,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ export { __exportAll };
@@ -1,16 +1,20 @@
1
- import { paramCase } from 'change-case';
2
-
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { paramCase } from "change-case";
3
+ //#region lib/common/string.ts
4
+ var string_exports = /* @__PURE__ */ __exportAll({
5
+ hyphenate: () => hyphenate,
6
+ isJson: () => isJson
7
+ });
3
8
  function hyphenate(value) {
4
- return paramCase(value);
9
+ return paramCase(value);
5
10
  }
6
11
  function isJson(subject) {
7
- try {
8
- JSON.parse(subject);
9
- return true;
10
- }
11
- catch (err) {
12
- return false;
13
- }
12
+ try {
13
+ JSON.parse(subject);
14
+ return true;
15
+ } catch (err) {
16
+ return false;
17
+ }
14
18
  }
15
-
16
- export { hyphenate, isJson };
19
+ //#endregion
20
+ export { hyphenate, isJson, string_exports };
package/dist/index.js CHANGED
@@ -1,37 +1,20 @@
1
- import * as string from './common/string.js';
2
- export { string as String };
3
- import * as callback from './node/callback.js';
4
- export { callback as Callback };
5
- import * as cli from './node/cli.js';
6
- export { cli as Cli };
7
- import * as config from './node/config.js';
8
- export { config as Config };
9
- import * as crypto from './node/crypto.js';
10
- export { crypto as Crypto };
11
- import * as env from './node/env.js';
12
- export { env as Env };
13
- import * as filesystem from './node/filesystem.js';
14
- export { filesystem as Filesystem };
15
- import * as form from './node/form.js';
16
- export { form as Form };
17
- import * as git from './node/git.js';
18
- export { git as Git };
19
- import * as github from './node/github.js';
20
- export { github as Github };
21
- import * as http from './node/http.js';
22
- export { http as Http };
23
- import * as path from './node/path.js';
24
- export { path as Path };
25
- import * as session from './node/session.js';
26
- export { session as Session };
27
- import * as system from './node/system.js';
28
- export { system as System };
29
- import * as tasks from './node/tasks.js';
30
- export { tasks as Tasks };
31
- import * as worker from './node/worker.js';
32
- export { worker as Worker };
33
- import * as index from './services/index.js';
34
- export { index as Services };
35
- import * as index$1 from './ui/index.js';
36
- export { index$1 as UI };
37
- export { default as Color } from 'kleur';
1
+ import { string_exports } from "./common/string.js";
2
+ import { callback_exports } from "./node/callback.js";
3
+ import { cli_exports } from "./node/cli.js";
4
+ import { config_exports } from "./node/config.js";
5
+ import { crypto_exports } from "./node/crypto.js";
6
+ import { env_exports } from "./node/env.js";
7
+ import { filesystem_exports } from "./node/filesystem.js";
8
+ import { form_exports } from "./node/form.js";
9
+ import { system_exports } from "./node/system.js";
10
+ import { git_exports } from "./node/git.js";
11
+ import { github_exports } from "./node/github.js";
12
+ import { http_exports } from "./node/http.js";
13
+ import { path_exports } from "./node/path.js";
14
+ import { session_exports } from "./node/session.js";
15
+ import { tasks_exports } from "./node/tasks.js";
16
+ import { worker_exports } from "./node/worker.js";
17
+ import { services_exports } from "./services/index.js";
18
+ import { ui_exports } from "./ui/index.js";
19
+ import Color from "kleur";
20
+ export { callback_exports as Callback, cli_exports as Cli, Color, config_exports as Config, crypto_exports as Crypto, env_exports as Env, filesystem_exports as Filesystem, form_exports as Form, git_exports as Git, github_exports as Github, http_exports as Http, path_exports as Path, services_exports as Services, session_exports as Session, string_exports as String, system_exports as System, tasks_exports as Tasks, ui_exports as UI, worker_exports as Worker };
@@ -1,16 +1,14 @@
1
- import process from 'node:process';
2
- import envpaths from 'env-paths';
3
-
4
- const identifier = 'youcan-cli';
1
+ import process from "node:process";
2
+ import envpaths from "env-paths";
3
+ //#region lib/internal/node/constants.ts
4
+ const identifier = "youcan-cli";
5
5
  function cachedir() {
6
- if (process.env.XDG_CACHE_HOME) {
7
- return process.env.XDG_CACHE_HOME;
8
- }
9
- return envpaths(identifier).cache;
6
+ if (process.env.XDG_CACHE_HOME) return process.env.XDG_CACHE_HOME;
7
+ return envpaths(identifier).cache;
10
8
  }
11
9
  const ENV_VARS = {
12
- ENV: 'YC_CLI_ENV',
13
- HOST_ENV: 'YC_CLI_HOST_ENV',
10
+ ENV: "YC_CLI_ENV",
11
+ HOST_ENV: "YC_CLI_HOST_ENV"
14
12
  };
15
-
13
+ //#endregion
16
14
  export { ENV_VARS, cachedir };
@@ -1,47 +1,58 @@
1
- import process from 'node:process';
2
- import kleur from 'kleur';
3
-
4
- class Loader {
5
- message;
6
- timer;
7
- constructor(message) {
8
- this.message = message;
9
- this.message = message;
10
- this.timer = null;
11
- }
12
- start() {
13
- process.stdout.write('\x1B[?25l');
14
- const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
15
- let i = 0;
16
- this.timer = setInterval(() => {
17
- process.stdout.write(`\r${frames[i = ++i % frames.length]} ${this.message}`);
18
- }, 100);
19
- return this;
20
- }
21
- flush() {
22
- process.stdout.write('\x1B[?25h');
23
- if (this.timer) {
24
- clearInterval(this.timer);
25
- this.timer = null;
26
- }
27
- }
28
- stop() {
29
- this.flush();
30
- process.stdout.write('\r');
31
- process.stdout.write(kleur.green(`✔ ${this.message}\n`));
32
- return this;
33
- }
34
- error(message = null) {
35
- this.flush();
36
- process.stdout.write('\r');
37
- process.stdout.write(kleur.red(`✖ ${message ?? this.message}\n`));
38
- return this;
39
- }
40
- static async exec(message, closure) {
41
- const loader = new Loader(message).start();
42
- await closure(loader);
43
- loader.timer && loader.stop();
44
- }
45
- }
46
-
1
+ import process from "node:process";
2
+ import kleur from "kleur";
3
+ //#region lib/internal/node/ui.ts
4
+ var Loader = class Loader {
5
+ message;
6
+ timer;
7
+ constructor(message) {
8
+ this.message = message;
9
+ this.message = message;
10
+ this.timer = null;
11
+ }
12
+ start() {
13
+ process.stdout.write("\x1B[?25l");
14
+ const frames = [
15
+ "⠋",
16
+ "⠙",
17
+ "⠹",
18
+ "⠸",
19
+ "⠼",
20
+ "⠴",
21
+ "⠦",
22
+ "⠧",
23
+ "⠇",
24
+ "⠏"
25
+ ];
26
+ let i = 0;
27
+ this.timer = setInterval(() => {
28
+ process.stdout.write(`\r${frames[i = ++i % frames.length]} ${this.message}`);
29
+ }, 100);
30
+ return this;
31
+ }
32
+ flush() {
33
+ process.stdout.write("\x1B[?25h");
34
+ if (this.timer) {
35
+ clearInterval(this.timer);
36
+ this.timer = null;
37
+ }
38
+ }
39
+ stop() {
40
+ this.flush();
41
+ process.stdout.write("\r");
42
+ process.stdout.write(kleur.green(`✔ ${this.message}\n`));
43
+ return this;
44
+ }
45
+ error(message = null) {
46
+ this.flush();
47
+ process.stdout.write("\r");
48
+ process.stdout.write(kleur.red(`✖ ${message ?? this.message}\n`));
49
+ return this;
50
+ }
51
+ static async exec(message, closure) {
52
+ const loader = new Loader(message).start();
53
+ await closure(loader);
54
+ loader.timer && loader.stop();
55
+ }
56
+ };
57
+ //#endregion
47
58
  export { Loader };
@@ -1,58 +1,63 @@
1
- import { createServer } from 'node:http';
2
-
3
- class CallbackListener {
4
- port;
5
- host;
6
- server;
7
- constructor(options) {
8
- this.port = options.port;
9
- this.host = options.host;
10
- this.server = this.create(options.callback);
11
- }
12
- start() {
13
- this.server.listen({ port: this.port, host: this.host }, () => { });
14
- }
15
- stop() {
16
- this.server.close();
17
- }
18
- create(callback) {
19
- const server = async (request, response) => {
20
- const respond = async (contents, error, state, code) => {
21
- response.write(contents);
22
- response.end();
23
- return callback(this, error, state, code);
24
- };
25
- const query = new URL(request.url, `http://${request.headers.host}`).searchParams;
26
- if (!query.has('code')) {
27
- return respond('missing code in authorization callback');
28
- }
29
- if (!query.has('state')) {
30
- return respond('missing state in authorization callback');
31
- }
32
- return respond('Successfully authenticated, you can now close this window.', undefined, query.get('code'), query.get('state'));
33
- };
34
- return createServer(server);
35
- }
36
- }
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { createServer } from "node:http";
3
+ //#region lib/node/callback.ts
4
+ var callback_exports = /* @__PURE__ */ __exportAll({ listen: () => listen });
5
+ var CallbackListener = class {
6
+ port;
7
+ host;
8
+ server;
9
+ constructor(options) {
10
+ this.port = options.port;
11
+ this.host = options.host;
12
+ this.server = this.create(options.callback);
13
+ }
14
+ start() {
15
+ this.server.listen({
16
+ port: this.port,
17
+ host: this.host
18
+ }, () => {});
19
+ }
20
+ stop() {
21
+ this.server.close();
22
+ }
23
+ create(callback) {
24
+ const server = async (request, response) => {
25
+ const respond = async (contents, error, state, code) => {
26
+ response.write(contents);
27
+ response.end();
28
+ return callback(this, error, state, code);
29
+ };
30
+ const query = new URL(request.url, `http://${request.headers.host}`).searchParams;
31
+ if (!query.has("code")) return respond("missing code in authorization callback");
32
+ if (!query.has("state")) return respond("missing state in authorization callback");
33
+ return respond("Successfully authenticated, you can now close this window.", void 0, query.get("code"), query.get("state"));
34
+ };
35
+ return createServer(server);
36
+ }
37
+ };
37
38
  async function listen(command, host, port, url) {
38
- return await new Promise((resolve, reject) => {
39
- const timeout = setTimeout(() => {
40
- command.output.info('Auto-open timed out, click below to open the login page:');
41
- command.output.url('Log in to YouCan Partners', url);
42
- }, 10_000);
43
- const callback = (listener, error, code, state) => {
44
- clearTimeout(timeout);
45
- setTimeout(() => {
46
- listener.stop();
47
- if (error) {
48
- return reject(error);
49
- }
50
- return resolve({ code: code, state: state });
51
- }, 500);
52
- };
53
- const listener = new CallbackListener({ host, port, callback });
54
- listener.start();
55
- });
39
+ return await new Promise((resolve, reject) => {
40
+ const timeout = setTimeout(() => {
41
+ command.output.info("Auto-open timed out, click below to open the login page:");
42
+ command.output.url("Log in to YouCan Partners", url);
43
+ }, 1e4);
44
+ const callback = (listener, error, code, state) => {
45
+ clearTimeout(timeout);
46
+ setTimeout(() => {
47
+ listener.stop();
48
+ if (error) return reject(error);
49
+ return resolve({
50
+ code,
51
+ state
52
+ });
53
+ }, 500);
54
+ };
55
+ new CallbackListener({
56
+ host,
57
+ port,
58
+ callback
59
+ }).start();
60
+ });
56
61
  }
57
-
58
- export { listen };
62
+ //#endregion
63
+ export { callback_exports, listen };
package/dist/node/cli.js CHANGED
@@ -1,106 +1,82 @@
1
- import process from 'node:process';
2
- import { Flags, Command as Command$1, ux } from '@oclif/core';
3
- import prompts from 'prompts';
4
- import 'change-case';
5
- import 'conf';
6
- import 'env-paths';
7
- import './filesystem.js';
8
- import 'formdata-node';
9
- import 'formdata-node/file-from-path';
10
- import 'simple-git';
11
- import 'execa';
12
- import 'find-process';
13
- import 'get-port';
14
- import 'tcp-port-used';
15
- import 'node-fetch';
16
- import 'ramda';
17
- import 'kleur';
18
- import 'dayjs';
19
- import '../ui/components/DevOutput.js';
20
- import { renderError } from '../ui/components/Error.js';
21
- import 'react';
22
- import 'ink';
23
- import { truthy } from './context/helpers.js';
24
- import { isDevelopment } from './context/local.js';
25
-
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { truthy } from "./context/helpers.js";
3
+ import { isDevelopment } from "./context/local.js";
4
+ import { renderError } from "../ui/components/Error.js";
5
+ import "../index.js";
6
+ import process from "node:process";
7
+ import { Command as Command$1, Flags, ux } from "@oclif/core";
8
+ import prompts from "prompts";
9
+ //#region lib/node/cli.ts
10
+ var cli_exports = /* @__PURE__ */ __exportAll({
11
+ Command: () => Command,
12
+ CommandError: () => CommandError,
13
+ commonFlags: () => commonFlags,
14
+ exec: () => exec,
15
+ execCreate: () => execCreate
16
+ });
26
17
  function setupEnvVars(options) {
27
- if (process.argv.includes('--verbose')) {
28
- process.env.DEBUG = process.env.DEBUG ?? '*';
29
- }
30
- if (options.development) {
31
- process.env.YC_CLI_ENV ??= 'development';
32
- }
18
+ if (process.argv.includes("--verbose")) process.env.DEBUG = process.env.DEBUG ?? "*";
19
+ if (options.development) process.env.YC_CLI_ENV ??= "development";
33
20
  }
34
21
  function setupColorMode() {
35
- if (process.argv.includes('--no-color')
36
- || truthy(process.env.NO_COLOR)
37
- || truthy(process.env.YC_FLAG_NO_COLOR)
38
- || process.env.TERM === 'dumb') {
39
- process.env.FORCE_COLOR = '0';
40
- }
22
+ if (process.argv.includes("--no-color") || truthy(process.env.NO_COLOR) || truthy(process.env.YC_FLAG_NO_COLOR) || process.env.TERM === "dumb") process.env.FORCE_COLOR = "0";
41
23
  }
42
24
  function handleError(error) {
43
- let suggestions = [];
44
- const message = error.message;
45
- if (error instanceof CommandError && error.suggestions) {
46
- suggestions = error.suggestions;
47
- }
48
- renderError({ message, suggestions });
49
- process.exit(1);
25
+ let suggestions = [];
26
+ const message = error.message;
27
+ if (error instanceof CommandError && error.suggestions) suggestions = error.suggestions;
28
+ renderError({
29
+ message,
30
+ suggestions
31
+ });
32
+ process.exit(1);
50
33
  }
51
34
  async function exec(options) {
52
- setupEnvVars(options);
53
- setupColorMode();
54
- const { run, settings, flush } = await import('@oclif/core');
55
- if (isDevelopment()) {
56
- settings.debug = true;
57
- }
58
- run(undefined, options.moduleUrl)
59
- .then(() => flush())
60
- .catch(handleError);
35
+ setupEnvVars(options);
36
+ setupColorMode();
37
+ const { run, settings, flush } = await import("@oclif/core");
38
+ if (isDevelopment()) settings.debug = true;
39
+ run(void 0, options.moduleUrl).then(() => flush()).catch(handleError);
61
40
  }
62
- process.on('uncaughtException', handleError);
41
+ process.on("uncaughtException", handleError);
63
42
  async function execCreate(cmdlet, options) {
64
- setupEnvVars(options);
65
- const initIndex = process.argv
66
- .findIndex(arg => arg.includes('init'));
67
- if (initIndex === -1) {
68
- const initIndex = process.argv
69
- .findIndex(arg => arg.match(new RegExp(`bin(\\/|\\\\)+(create-${cmdlet}|dev|exec)`))) + 1;
70
- process.argv.splice(initIndex, 0, 'init');
71
- }
72
- await exec(options);
43
+ setupEnvVars(options);
44
+ if (process.argv.findIndex((arg) => arg.includes("init")) === -1) {
45
+ const initIndex = process.argv.findIndex((arg) => arg.match(new RegExp(`bin(\\/|\\\\)+(create-${cmdlet}|dev|exec)`))) + 1;
46
+ process.argv.splice(initIndex, 0, "init");
47
+ }
48
+ await exec(options);
73
49
  }
74
50
  const commonFlags = {
75
- 'no-color': Flags.boolean({
76
- hidden: false,
77
- description: 'Disable color output.',
78
- env: 'YC_FLAG_NO_COLOR',
79
- }),
80
- 'verbose': Flags.boolean({
81
- hidden: false,
82
- description: 'Increase the verbosity of the logs.',
83
- env: 'YC_FLAG_VERBOSE',
84
- }),
51
+ "no-color": Flags.boolean({
52
+ hidden: false,
53
+ description: "Disable color output.",
54
+ env: "YC_FLAG_NO_COLOR"
55
+ }),
56
+ "verbose": Flags.boolean({
57
+ hidden: false,
58
+ description: "Increase the verbosity of the logs.",
59
+ env: "YC_FLAG_VERBOSE"
60
+ })
85
61
  };
86
- class Command extends Command$1 {
87
- output = ux;
88
- prompt = prompts;
89
- controller = new AbortController();
90
- clear() {
91
- console.clear();
92
- }
93
- exit(code) {
94
- this.controller.abort();
95
- return process.exit(code);
96
- }
97
- }
98
- class CommandError extends Error {
99
- suggestions;
100
- constructor(message, suggestions) {
101
- super(message);
102
- this.suggestions = suggestions;
103
- }
104
- }
105
-
106
- export { Command, CommandError, commonFlags, exec, execCreate };
62
+ var Command = class extends Command$1 {
63
+ output = ux;
64
+ prompt = prompts;
65
+ controller = new AbortController();
66
+ clear() {
67
+ console.clear();
68
+ }
69
+ exit(code) {
70
+ this.controller.abort();
71
+ return process.exit(code);
72
+ }
73
+ };
74
+ var CommandError = class extends Error {
75
+ suggestions;
76
+ constructor(message, suggestions) {
77
+ super(message);
78
+ this.suggestions = suggestions;
79
+ }
80
+ };
81
+ //#endregion
82
+ export { Command, CommandError, cli_exports, commonFlags, exec, execCreate };
@@ -1,25 +1,27 @@
1
- import Conf from 'conf';
2
-
3
- class Manager {
4
- store;
5
- constructor(options) {
6
- this.store = new Conf(options);
7
- }
8
- get(key) {
9
- return this.store.get(key);
10
- }
11
- set(key, value) {
12
- this.store.set(key, value);
13
- }
14
- delete(key) {
15
- this.store.delete(key);
16
- }
17
- clear() {
18
- this.store.clear();
19
- }
20
- }
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import Conf from "conf";
3
+ //#region lib/node/config.ts
4
+ var config_exports = /* @__PURE__ */ __exportAll({ manager: () => manager });
5
+ var Manager = class {
6
+ store;
7
+ constructor(options) {
8
+ this.store = new Conf(options);
9
+ }
10
+ get(key) {
11
+ return this.store.get(key);
12
+ }
13
+ set(key, value) {
14
+ this.store.set(key, value);
15
+ }
16
+ delete(key) {
17
+ this.store.delete(key);
18
+ }
19
+ clear() {
20
+ this.store.clear();
21
+ }
22
+ };
21
23
  function manager(options) {
22
- return new Manager(options);
24
+ return new Manager(options);
23
25
  }
24
-
25
- export { manager };
26
+ //#endregion
27
+ export { config_exports, manager };
@@ -1,8 +1,15 @@
1
+ //#region lib/node/context/helpers.ts
1
2
  function truthy(val) {
2
- if (!val) {
3
- return false;
4
- }
5
- return ['1', 'true', 'TRUE', 'yes', 'YES', 'y', 'Y'].includes(val);
3
+ if (!val) return false;
4
+ return [
5
+ "1",
6
+ "true",
7
+ "TRUE",
8
+ "yes",
9
+ "YES",
10
+ "y",
11
+ "Y"
12
+ ].includes(val);
6
13
  }
7
-
14
+ //#endregion
8
15
  export { truthy };
@@ -1,8 +1,8 @@
1
- import process from 'node:process';
2
- import { ENV_VARS } from '../../internal/node/constants.js';
3
-
1
+ import { ENV_VARS } from "../../internal/node/constants.js";
2
+ import process from "node:process";
3
+ //#region lib/node/context/local.ts
4
4
  function isDevelopment(env = process.env) {
5
- return env[ENV_VARS.ENV] === 'development';
5
+ return env[ENV_VARS.ENV] === "development";
6
6
  }
7
-
7
+ //#endregion
8
8
  export { isDevelopment };