@youcan/cli-kit 2.1.4 → 2.3.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/dist/common/string.d.ts +2 -2
- package/dist/common/string.js +11 -11
- package/dist/index.d.ts +19 -17
- package/dist/index.js +4 -0
- package/dist/internal/node/constants.d.ts +5 -5
- package/dist/internal/node/constants.js +10 -10
- package/dist/internal/node/ui.d.ts +11 -11
- package/dist/internal/node/ui.js +41 -40
- package/dist/node/callback.d.ts +5 -5
- package/dist/node/callback.js +53 -53
- package/dist/node/cli.d.ts +25 -21
- package/dist/node/cli.js +97 -62
- package/dist/node/config.d.ts +20 -20
- package/dist/node/config.js +20 -22
- package/dist/node/context/helpers.d.ts +1 -1
- package/dist/node/context/helpers.js +5 -5
- package/dist/node/context/local.d.ts +2 -2
- package/dist/node/context/local.js +2 -2
- package/dist/node/crypto.d.ts +12 -9
- package/dist/node/crypto.js +23 -23
- package/dist/node/env.d.ts +5 -6
- package/dist/node/env.js +36 -47
- package/dist/node/filesystem.d.ts +34 -29
- package/dist/node/filesystem.js +112 -82
- package/dist/node/form.d.ts +9 -9
- package/dist/node/form.js +39 -39
- package/dist/node/git.d.ts +10 -10
- package/dist/node/git.js +46 -46
- package/dist/node/github.d.ts +6 -6
- package/dist/node/github.js +8 -8
- package/dist/node/http.d.ts +4 -4
- package/dist/node/http.js +37 -34
- package/dist/node/path.d.ts +5 -5
- package/dist/node/path.js +14 -14
- package/dist/node/session.d.ts +8 -8
- package/dist/node/session.js +92 -78
- package/dist/node/system.d.ts +26 -21
- package/dist/node/system.js +87 -60
- package/dist/node/tasks.d.ts +8 -7
- package/dist/node/tasks.js +33 -25
- package/dist/node/worker.d.ts +16 -19
- package/dist/node/worker.js +43 -30
- package/dist/services/cloudflared.d.ts +12 -0
- package/dist/services/cloudflared.js +206 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +1 -0
- package/dist/ui/components/DevOutput.d.ts +27 -0
- package/dist/ui/components/DevOutput.js +60 -0
- package/dist/ui/components/Error.d.ts +6 -0
- package/dist/ui/components/Error.js +18 -0
- package/dist/ui/components/HotKeys.d.ts +12 -0
- package/dist/ui/components/HotKeys.js +25 -0
- package/dist/ui/components/utils/symbols.d.ts +3 -0
- package/dist/ui/components/utils/symbols.js +7 -0
- package/dist/ui/index.d.ts +3 -0
- package/dist/ui/index.js +3 -0
- package/package.json +7 -2
package/dist/common/string.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function hyphenate(value: string): string;
|
|
2
|
-
export declare function isJson(subject: string): boolean;
|
|
1
|
+
export declare function hyphenate(value: string): string;
|
|
2
|
+
export declare function isJson(subject: string): boolean;
|
package/dist/common/string.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { paramCase } from 'change-case';
|
|
2
2
|
|
|
3
|
-
function hyphenate(value) {
|
|
4
|
-
return paramCase(value);
|
|
5
|
-
}
|
|
6
|
-
function isJson(subject) {
|
|
7
|
-
try {
|
|
8
|
-
JSON.parse(subject);
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
catch (err) {
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
3
|
+
function hyphenate(value) {
|
|
4
|
+
return paramCase(value);
|
|
5
|
+
}
|
|
6
|
+
function isJson(subject) {
|
|
7
|
+
try {
|
|
8
|
+
JSON.parse(subject);
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
catch (err) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export { hyphenate, isJson };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
export * as Cli from './node/cli';
|
|
2
|
-
export * as Git from './node/git';
|
|
3
|
-
export * as Env from './node/env';
|
|
4
|
-
export * as Path from './node/path';
|
|
5
|
-
export * as Http from './node/http';
|
|
6
|
-
export * as Form from './node/form';
|
|
7
|
-
export * as Tasks from './node/tasks';
|
|
8
|
-
export * as Github from './node/github';
|
|
9
|
-
export * as System from './node/system';
|
|
10
|
-
export * as Config from './node/config';
|
|
11
|
-
export * as Crypto from './node/crypto';
|
|
12
|
-
export * as Worker from './node/worker';
|
|
13
|
-
export * as Session from './node/session';
|
|
14
|
-
export * as Callback from './node/callback';
|
|
15
|
-
export * as Filesystem from './node/filesystem';
|
|
16
|
-
export * as
|
|
17
|
-
export
|
|
1
|
+
export * as Cli from './node/cli';
|
|
2
|
+
export * as Git from './node/git';
|
|
3
|
+
export * as Env from './node/env';
|
|
4
|
+
export * as Path from './node/path';
|
|
5
|
+
export * as Http from './node/http';
|
|
6
|
+
export * as Form from './node/form';
|
|
7
|
+
export * as Tasks from './node/tasks';
|
|
8
|
+
export * as Github from './node/github';
|
|
9
|
+
export * as System from './node/system';
|
|
10
|
+
export * as Config from './node/config';
|
|
11
|
+
export * as Crypto from './node/crypto';
|
|
12
|
+
export * as Worker from './node/worker';
|
|
13
|
+
export * as Session from './node/session';
|
|
14
|
+
export * as Callback from './node/callback';
|
|
15
|
+
export * as Filesystem from './node/filesystem';
|
|
16
|
+
export * as UI from './ui';
|
|
17
|
+
export * as Services from './services';
|
|
18
|
+
export * as String from './common/string';
|
|
19
|
+
export { default as Color } from 'kleur';
|
package/dist/index.js
CHANGED
|
@@ -28,6 +28,10 @@ import * as callback from './node/callback.js';
|
|
|
28
28
|
export { callback as Callback };
|
|
29
29
|
import * as filesystem from './node/filesystem.js';
|
|
30
30
|
export { filesystem as Filesystem };
|
|
31
|
+
import * as index from './ui/index.js';
|
|
32
|
+
export { index as UI };
|
|
33
|
+
import * as index$1 from './services/index.js';
|
|
34
|
+
export { index$1 as Services };
|
|
31
35
|
import * as string from './common/string.js';
|
|
32
36
|
export { string as String };
|
|
33
37
|
export { default as Color } from 'kleur';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare function cachedir(): string;
|
|
2
|
-
export declare const ENV_VARS: {
|
|
3
|
-
ENV: string;
|
|
4
|
-
HOST_ENV: string;
|
|
5
|
-
};
|
|
1
|
+
export declare function cachedir(): string;
|
|
2
|
+
export declare const ENV_VARS: {
|
|
3
|
+
ENV: string;
|
|
4
|
+
HOST_ENV: string;
|
|
5
|
+
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import envpaths from 'env-paths';
|
|
2
2
|
|
|
3
|
-
const identifier = 'youcan-cli';
|
|
4
|
-
function cachedir() {
|
|
5
|
-
if (process.env.XDG_CACHE_HOME) {
|
|
6
|
-
return process.env.XDG_CACHE_HOME;
|
|
7
|
-
}
|
|
8
|
-
return envpaths(identifier).cache;
|
|
9
|
-
}
|
|
10
|
-
const ENV_VARS = {
|
|
11
|
-
ENV: 'YC_CLI_ENV',
|
|
12
|
-
HOST_ENV: 'YC_CLI_HOST_ENV',
|
|
3
|
+
const identifier = 'youcan-cli';
|
|
4
|
+
function cachedir() {
|
|
5
|
+
if (process.env.XDG_CACHE_HOME) {
|
|
6
|
+
return process.env.XDG_CACHE_HOME;
|
|
7
|
+
}
|
|
8
|
+
return envpaths(identifier).cache;
|
|
9
|
+
}
|
|
10
|
+
const ENV_VARS = {
|
|
11
|
+
ENV: 'YC_CLI_ENV',
|
|
12
|
+
HOST_ENV: 'YC_CLI_HOST_ENV',
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export { ENV_VARS, cachedir };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
export declare class Loader {
|
|
3
|
-
private message;
|
|
4
|
-
timer: NodeJS.Timeout | null;
|
|
5
|
-
constructor(message: string);
|
|
6
|
-
start(): this;
|
|
7
|
-
private flush;
|
|
8
|
-
stop(): this;
|
|
9
|
-
error(message?: string | null): this;
|
|
10
|
-
static exec(message: string, closure: (loader: Loader) => Promise<void>): Promise<void>;
|
|
11
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare class Loader {
|
|
3
|
+
private message;
|
|
4
|
+
timer: NodeJS.Timeout | null;
|
|
5
|
+
constructor(message: string);
|
|
6
|
+
start(): this;
|
|
7
|
+
private flush;
|
|
8
|
+
stop(): this;
|
|
9
|
+
error(message?: string | null): this;
|
|
10
|
+
static exec(message: string, closure: (loader: Loader) => Promise<void>): Promise<void>;
|
|
11
|
+
}
|
package/dist/internal/node/ui.js
CHANGED
|
@@ -1,45 +1,46 @@
|
|
|
1
1
|
import kleur from 'kleur';
|
|
2
2
|
|
|
3
|
-
class Loader {
|
|
4
|
-
message;
|
|
5
|
-
timer;
|
|
6
|
-
constructor(message) {
|
|
7
|
-
this.message = message;
|
|
8
|
-
this.message = message;
|
|
9
|
-
this.timer = null;
|
|
10
|
-
}
|
|
11
|
-
start() {
|
|
12
|
-
process.stdout.write('\x1B[?25l');
|
|
13
|
-
const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
14
|
-
let i = 0;
|
|
15
|
-
this.timer = setInterval(() => {
|
|
16
|
-
process.stdout.write(`\r${frames[i = ++i % frames.length]} ${this.message}`);
|
|
17
|
-
}, 100);
|
|
18
|
-
return this;
|
|
19
|
-
}
|
|
20
|
-
flush() {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.timer
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
process.stdout.write(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
process.stdout.write(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
3
|
+
class Loader {
|
|
4
|
+
message;
|
|
5
|
+
timer;
|
|
6
|
+
constructor(message) {
|
|
7
|
+
this.message = message;
|
|
8
|
+
this.message = message;
|
|
9
|
+
this.timer = null;
|
|
10
|
+
}
|
|
11
|
+
start() {
|
|
12
|
+
process.stdout.write('\x1B[?25l');
|
|
13
|
+
const frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];
|
|
14
|
+
let i = 0;
|
|
15
|
+
this.timer = setInterval(() => {
|
|
16
|
+
process.stdout.write(`\r${frames[i = ++i % frames.length]} ${this.message}`);
|
|
17
|
+
}, 100);
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
flush() {
|
|
21
|
+
process.stdout.write('\x1B[?25h');
|
|
22
|
+
if (this.timer) {
|
|
23
|
+
clearInterval(this.timer);
|
|
24
|
+
this.timer = null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
stop() {
|
|
28
|
+
this.flush();
|
|
29
|
+
process.stdout.write('\r');
|
|
30
|
+
process.stdout.write(kleur.green(`✔ ${this.message}\n`));
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
error(message = null) {
|
|
34
|
+
this.flush();
|
|
35
|
+
process.stdout.write('\r');
|
|
36
|
+
process.stdout.write(kleur.red(`✖ ${message ?? this.message}\n`));
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
static async exec(message, closure) {
|
|
40
|
+
const loader = new Loader(message).start();
|
|
41
|
+
await closure(loader);
|
|
42
|
+
loader.timer && loader.stop();
|
|
43
|
+
}
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
export { Loader };
|
package/dist/node/callback.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Cli } from '..';
|
|
2
|
-
export declare function listen(command: Cli.Command, host: string, port: number, url: string): Promise<{
|
|
3
|
-
code: string;
|
|
4
|
-
state: string;
|
|
5
|
-
}>;
|
|
1
|
+
import type { Cli } from '..';
|
|
2
|
+
export declare function listen(command: Cli.Command, host: string, port: number, url: string): Promise<{
|
|
3
|
+
code: string;
|
|
4
|
+
state: string;
|
|
5
|
+
}>;
|
package/dist/node/callback.js
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
1
|
import { createServer } from 'node:http';
|
|
2
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
|
-
}
|
|
37
|
-
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
|
-
});
|
|
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
|
+
}
|
|
37
|
+
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
|
+
});
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
export { listen };
|
package/dist/node/cli.d.ts
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Command as BaseCommand, ux } from '@oclif/core';
|
|
3
|
-
import prompts from 'prompts';
|
|
4
|
-
interface ExecOptions {
|
|
5
|
-
moduleUrl: string;
|
|
6
|
-
development: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare function exec(options: ExecOptions): Promise<void>;
|
|
9
|
-
export declare function execCreate(cmdlet: string, options: ExecOptions): Promise<void>;
|
|
10
|
-
export declare const commonFlags: {
|
|
11
|
-
'no-color': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
|
-
verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
|
-
};
|
|
14
|
-
export declare abstract class Command extends BaseCommand {
|
|
15
|
-
output: typeof ux;
|
|
16
|
-
prompt: typeof prompts;
|
|
17
|
-
controller: AbortController;
|
|
18
|
-
clear(): void;
|
|
19
|
-
exit(code?: number
|
|
20
|
-
}
|
|
21
|
-
export {
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Command as BaseCommand, ux } from '@oclif/core';
|
|
3
|
+
import prompts from 'prompts';
|
|
4
|
+
interface ExecOptions {
|
|
5
|
+
moduleUrl: string;
|
|
6
|
+
development: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function exec(options: ExecOptions): Promise<void>;
|
|
9
|
+
export declare function execCreate(cmdlet: string, options: ExecOptions): Promise<void>;
|
|
10
|
+
export declare const commonFlags: {
|
|
11
|
+
'no-color': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
verbose: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
13
|
+
};
|
|
14
|
+
export declare abstract class Command extends BaseCommand {
|
|
15
|
+
output: typeof ux;
|
|
16
|
+
prompt: typeof prompts;
|
|
17
|
+
controller: AbortController;
|
|
18
|
+
clear(): void;
|
|
19
|
+
exit(code?: number): never;
|
|
20
|
+
}
|
|
21
|
+
export declare class CommandError extends Error {
|
|
22
|
+
readonly suggestions?: string[] | undefined;
|
|
23
|
+
constructor(message: string, suggestions?: string[] | undefined);
|
|
24
|
+
}
|
|
25
|
+
export {};
|
package/dist/node/cli.js
CHANGED
|
@@ -1,69 +1,104 @@
|
|
|
1
1
|
import { Flags, Command as Command$1, ux } from '@oclif/core';
|
|
2
2
|
import prompts from 'prompts';
|
|
3
|
+
import 'simple-git';
|
|
4
|
+
import 'find-process';
|
|
5
|
+
import 'tcp-port-used';
|
|
6
|
+
import 'execa';
|
|
7
|
+
import 'env-paths';
|
|
8
|
+
import 'node-fetch';
|
|
9
|
+
import 'ramda';
|
|
10
|
+
import 'change-case';
|
|
11
|
+
import 'formdata-node';
|
|
12
|
+
import 'formdata-node/file-from-path';
|
|
13
|
+
import 'kleur';
|
|
14
|
+
import 'conf';
|
|
15
|
+
import 'dayjs';
|
|
16
|
+
import './filesystem.js';
|
|
17
|
+
import '../ui/components/DevOutput.js';
|
|
18
|
+
import 'react';
|
|
19
|
+
import 'ink';
|
|
20
|
+
import { renderError } from '../ui/components/Error.js';
|
|
3
21
|
import { truthy } from './context/helpers.js';
|
|
4
22
|
import { isDevelopment } from './context/local.js';
|
|
5
23
|
|
|
6
|
-
function setupEnvVars(options) {
|
|
7
|
-
if (process.argv.includes('--verbose')) {
|
|
8
|
-
process.env.DEBUG = process.env.DEBUG ?? '*';
|
|
9
|
-
}
|
|
10
|
-
if (options.development) {
|
|
11
|
-
process.env.YC_CLI_ENV ??= 'development';
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function setupColorMode() {
|
|
15
|
-
if (process.argv.includes('--no-color')
|
|
16
|
-
|| truthy(process.env.NO_COLOR)
|
|
17
|
-
|| truthy(process.env.YC_FLAG_NO_COLOR)
|
|
18
|
-
|| process.env.TERM === 'dumb') {
|
|
19
|
-
process.env.FORCE_COLOR = '0';
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
24
|
+
function setupEnvVars(options) {
|
|
25
|
+
if (process.argv.includes('--verbose')) {
|
|
26
|
+
process.env.DEBUG = process.env.DEBUG ?? '*';
|
|
27
|
+
}
|
|
28
|
+
if (options.development) {
|
|
29
|
+
process.env.YC_CLI_ENV ??= 'development';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function setupColorMode() {
|
|
33
|
+
if (process.argv.includes('--no-color')
|
|
34
|
+
|| truthy(process.env.NO_COLOR)
|
|
35
|
+
|| truthy(process.env.YC_FLAG_NO_COLOR)
|
|
36
|
+
|| process.env.TERM === 'dumb') {
|
|
37
|
+
process.env.FORCE_COLOR = '0';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function errorHandler(error) {
|
|
41
|
+
let suggestions = ['Run the command again'];
|
|
42
|
+
const message = error.message;
|
|
43
|
+
if (error instanceof CommandError && error.suggestions) {
|
|
44
|
+
suggestions = error.suggestions;
|
|
45
|
+
}
|
|
46
|
+
renderError({ message, suggestions });
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
async function exec(options) {
|
|
50
|
+
setupEnvVars(options);
|
|
51
|
+
setupColorMode();
|
|
52
|
+
const { run, settings, flush } = await import('@oclif/core');
|
|
53
|
+
if (isDevelopment()) {
|
|
54
|
+
settings.debug = true;
|
|
55
|
+
}
|
|
56
|
+
run(undefined, options.moduleUrl)
|
|
57
|
+
.then(() => flush())
|
|
58
|
+
.catch(errorHandler);
|
|
59
|
+
}
|
|
60
|
+
process.on('uncaughtException', errorHandler);
|
|
61
|
+
async function execCreate(cmdlet, options) {
|
|
62
|
+
setupEnvVars(options);
|
|
63
|
+
const initIndex = process.argv
|
|
64
|
+
.findIndex(arg => arg.includes('init'));
|
|
65
|
+
if (initIndex === -1) {
|
|
66
|
+
const initIndex = process.argv
|
|
67
|
+
.findIndex(arg => arg.match(new RegExp(`bin(\\/|\\\\)+(create-${cmdlet}|dev|exec)`))) + 1;
|
|
68
|
+
process.argv.splice(initIndex, 0, 'init');
|
|
69
|
+
}
|
|
70
|
+
await exec(options);
|
|
71
|
+
}
|
|
72
|
+
const commonFlags = {
|
|
73
|
+
'no-color': Flags.boolean({
|
|
74
|
+
hidden: false,
|
|
75
|
+
description: 'Disable color output.',
|
|
76
|
+
env: 'YC_FLAG_NO_COLOR',
|
|
77
|
+
}),
|
|
78
|
+
'verbose': Flags.boolean({
|
|
79
|
+
hidden: false,
|
|
80
|
+
description: 'Increase the verbosity of the logs.',
|
|
81
|
+
env: 'YC_FLAG_VERBOSE',
|
|
82
|
+
}),
|
|
83
|
+
};
|
|
84
|
+
class Command extends Command$1 {
|
|
85
|
+
output = ux;
|
|
86
|
+
prompt = prompts;
|
|
87
|
+
controller = new AbortController();
|
|
88
|
+
clear() {
|
|
89
|
+
console.clear();
|
|
90
|
+
}
|
|
91
|
+
exit(code) {
|
|
92
|
+
this.controller.abort();
|
|
93
|
+
return process.exit(code);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
class CommandError extends Error {
|
|
97
|
+
suggestions;
|
|
98
|
+
constructor(message, suggestions) {
|
|
99
|
+
super(message);
|
|
100
|
+
this.suggestions = suggestions;
|
|
101
|
+
}
|
|
67
102
|
}
|
|
68
103
|
|
|
69
|
-
export { Command, commonFlags, exec, execCreate };
|
|
104
|
+
export { Command, CommandError, commonFlags, exec, execCreate };
|
package/dist/node/config.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
declare class Manager<T extends {
|
|
2
|
-
[key: string]: any;
|
|
3
|
-
}> {
|
|
4
|
-
private readonly store;
|
|
5
|
-
constructor(options: {
|
|
6
|
-
projectName?: string;
|
|
7
|
-
cwd?: string;
|
|
8
|
-
});
|
|
9
|
-
get<TKey extends keyof T>(key: TKey): T[TKey];
|
|
10
|
-
set<TKey extends keyof T>(key: TKey, value?: T[TKey]): void;
|
|
11
|
-
delete<TKey extends keyof T>(key: TKey): void;
|
|
12
|
-
clear(): void;
|
|
13
|
-
}
|
|
14
|
-
export declare function manager(options: {
|
|
15
|
-
projectName?: string;
|
|
16
|
-
cwd?: string;
|
|
17
|
-
}): Manager<{
|
|
18
|
-
[key: string]: any;
|
|
19
|
-
}>;
|
|
20
|
-
export {};
|
|
1
|
+
declare class Manager<T extends {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
}> {
|
|
4
|
+
private readonly store;
|
|
5
|
+
constructor(options: {
|
|
6
|
+
projectName?: string;
|
|
7
|
+
cwd?: string;
|
|
8
|
+
});
|
|
9
|
+
get<TKey extends keyof T>(key: TKey): T[TKey];
|
|
10
|
+
set<TKey extends keyof T>(key: TKey, value?: T[TKey]): void;
|
|
11
|
+
delete<TKey extends keyof T>(key: TKey): void;
|
|
12
|
+
clear(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare function manager(options: {
|
|
15
|
+
projectName?: string;
|
|
16
|
+
cwd?: string;
|
|
17
|
+
}): Manager<{
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}>;
|
|
20
|
+
export {};
|