@youcan/cli-kit 2.3.1 → 2.3.3
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/index.d.ts +11 -11
- package/dist/index.js +24 -24
- package/dist/internal/node/constants.js +1 -0
- package/dist/internal/node/ui.js +1 -0
- package/dist/node/cli.js +14 -12
- package/dist/node/context/local.js +1 -0
- package/dist/node/crypto.d.ts +2 -1
- package/dist/node/env.js +1 -0
- package/dist/node/filesystem.d.ts +2 -1
- package/dist/node/filesystem.js +12 -11
- package/dist/node/form.d.ts +1 -1
- package/dist/node/http.js +9 -8
- package/dist/node/path.js +1 -0
- package/dist/node/session.js +11 -8
- package/dist/node/system.d.ts +2 -2
- package/dist/node/system.js +37 -7
- package/dist/node/tasks.js +1 -1
- package/dist/node/worker.d.ts +3 -3
- package/dist/node/worker.js +9 -7
- package/dist/scripts/install-cloudflared.d.ts +1 -0
- package/dist/scripts/install-cloudflared.js +25 -0
- package/dist/services/cloudflared.d.ts +1 -1
- package/dist/services/cloudflared.js +11 -10
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +1 -1
- package/package.json +4 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
+
export * as String from './common/string';
|
|
2
|
+
export * as Callback from './node/callback';
|
|
1
3
|
export * as Cli from './node/cli';
|
|
2
|
-
export * as
|
|
4
|
+
export * as Config from './node/config';
|
|
5
|
+
export * as Crypto from './node/crypto';
|
|
3
6
|
export * as Env from './node/env';
|
|
4
|
-
export * as
|
|
5
|
-
export * as Http from './node/http';
|
|
7
|
+
export * as Filesystem from './node/filesystem';
|
|
6
8
|
export * as Form from './node/form';
|
|
7
|
-
export * as
|
|
9
|
+
export * as Git from './node/git';
|
|
8
10
|
export * as Github from './node/github';
|
|
11
|
+
export * as Http from './node/http';
|
|
12
|
+
export * as Path from './node/path';
|
|
13
|
+
export * as Session from './node/session';
|
|
9
14
|
export * as System from './node/system';
|
|
10
|
-
export * as
|
|
11
|
-
export * as Crypto from './node/crypto';
|
|
15
|
+
export * as Tasks from './node/tasks';
|
|
12
16
|
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
17
|
export * as Services from './services';
|
|
18
|
-
export * as
|
|
18
|
+
export * as UI from './ui';
|
|
19
19
|
export { default as Color } from 'kleur';
|
package/dist/index.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
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 };
|
|
1
5
|
import * as cli from './node/cli.js';
|
|
2
6
|
export { cli as Cli };
|
|
3
|
-
import * as
|
|
4
|
-
export {
|
|
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 };
|
|
5
11
|
import * as env from './node/env.js';
|
|
6
12
|
export { env as Env };
|
|
7
|
-
import * as
|
|
8
|
-
export {
|
|
9
|
-
import * as http from './node/http.js';
|
|
10
|
-
export { http as Http };
|
|
13
|
+
import * as filesystem from './node/filesystem.js';
|
|
14
|
+
export { filesystem as Filesystem };
|
|
11
15
|
import * as form from './node/form.js';
|
|
12
16
|
export { form as Form };
|
|
13
|
-
import * as
|
|
14
|
-
export {
|
|
17
|
+
import * as git from './node/git.js';
|
|
18
|
+
export { git as Git };
|
|
15
19
|
import * as github from './node/github.js';
|
|
16
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 };
|
|
17
27
|
import * as system from './node/system.js';
|
|
18
28
|
export { system as System };
|
|
19
|
-
import * as
|
|
20
|
-
export {
|
|
21
|
-
import * as crypto from './node/crypto.js';
|
|
22
|
-
export { crypto as Crypto };
|
|
29
|
+
import * as tasks from './node/tasks.js';
|
|
30
|
+
export { tasks as Tasks };
|
|
23
31
|
import * as worker from './node/worker.js';
|
|
24
32
|
export { worker as Worker };
|
|
25
|
-
import * as
|
|
26
|
-
export {
|
|
27
|
-
import * as
|
|
28
|
-
export {
|
|
29
|
-
import * as filesystem from './node/filesystem.js';
|
|
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 };
|
|
35
|
-
import * as string from './common/string.js';
|
|
36
|
-
export { string as String };
|
|
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
37
|
export { default as Color } from 'kleur';
|
package/dist/internal/node/ui.js
CHANGED
package/dist/node/cli.js
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
1
2
|
import { Flags, Command as Command$1, ux } from '@oclif/core';
|
|
2
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';
|
|
3
10
|
import 'simple-git';
|
|
11
|
+
import 'execa';
|
|
4
12
|
import 'find-process';
|
|
13
|
+
import 'get-port';
|
|
5
14
|
import 'tcp-port-used';
|
|
6
|
-
import 'execa';
|
|
7
|
-
import 'env-paths';
|
|
8
15
|
import 'node-fetch';
|
|
9
16
|
import 'ramda';
|
|
10
|
-
import 'change-case';
|
|
11
|
-
import 'formdata-node';
|
|
12
|
-
import 'formdata-node/file-from-path';
|
|
13
17
|
import 'kleur';
|
|
14
|
-
import 'conf';
|
|
15
18
|
import 'dayjs';
|
|
16
|
-
import './filesystem.js';
|
|
17
19
|
import '../ui/components/DevOutput.js';
|
|
20
|
+
import { renderError } from '../ui/components/Error.js';
|
|
18
21
|
import 'react';
|
|
19
22
|
import 'ink';
|
|
20
|
-
import { renderError } from '../ui/components/Error.js';
|
|
21
23
|
import { truthy } from './context/helpers.js';
|
|
22
24
|
import { isDevelopment } from './context/local.js';
|
|
23
25
|
|
|
@@ -37,8 +39,8 @@ function setupColorMode() {
|
|
|
37
39
|
process.env.FORCE_COLOR = '0';
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
|
-
function
|
|
41
|
-
let suggestions = [
|
|
42
|
+
function handleError(error) {
|
|
43
|
+
let suggestions = [];
|
|
42
44
|
const message = error.message;
|
|
43
45
|
if (error instanceof CommandError && error.suggestions) {
|
|
44
46
|
suggestions = error.suggestions;
|
|
@@ -55,9 +57,9 @@ async function exec(options) {
|
|
|
55
57
|
}
|
|
56
58
|
run(undefined, options.moduleUrl)
|
|
57
59
|
.then(() => flush())
|
|
58
|
-
.catch(
|
|
60
|
+
.catch(handleError);
|
|
59
61
|
}
|
|
60
|
-
process.on('uncaughtException',
|
|
62
|
+
process.on('uncaughtException', handleError);
|
|
61
63
|
async function execCreate(cmdlet, options) {
|
|
62
64
|
setupEnvVars(options);
|
|
63
65
|
const initIndex = process.argv
|
package/dist/node/crypto.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
/// <reference types="node" />
|
|
4
|
-
import type {
|
|
4
|
+
import type { Buffer } from 'node:buffer';
|
|
5
|
+
import type { BinaryLike } from 'node:crypto';
|
|
5
6
|
export declare function randomHex(size: number): string;
|
|
6
7
|
export declare function base64URLEncode(str: Buffer): string;
|
|
7
8
|
export declare function sha256(str: BinaryLike): Buffer;
|
package/dist/node/env.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
/// <reference types="node" />
|
|
4
|
-
import type { Mode, OpenMode, PathLike, Stats } from 'fs';
|
|
5
4
|
import type { GlobOptions } from 'glob';
|
|
5
|
+
import type { Buffer } from 'node:buffer';
|
|
6
|
+
import type { Mode, OpenMode, PathLike, Stats } from 'node:fs';
|
|
6
7
|
export declare function exists(path: string): Promise<boolean>;
|
|
7
8
|
export declare function isExecutable(path: string): Promise<boolean>;
|
|
8
9
|
export declare function isDirectory(path: string): Promise<boolean>;
|
package/dist/node/filesystem.js
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
|
+
import { createWriteStream, createReadStream } from 'node:fs';
|
|
1
2
|
import FilesystemPromises from 'node:fs/promises';
|
|
2
|
-
import { createGunzip } from 'node:zlib';
|
|
3
3
|
import { pipeline } from 'node:stream/promises';
|
|
4
|
-
import {
|
|
5
|
-
import { temporaryDirectoryTask } from 'tempy';
|
|
6
|
-
import FsExtra from 'fs-extra';
|
|
4
|
+
import { createGunzip } from 'node:zlib';
|
|
7
5
|
import archiver from 'archiver';
|
|
8
6
|
import chokidar from 'chokidar';
|
|
7
|
+
import FsExtra from 'fs-extra';
|
|
9
8
|
import { glob as glob$1 } from 'glob';
|
|
10
9
|
import * as tar from 'tar';
|
|
10
|
+
import { temporaryDirectoryTask } from 'tempy';
|
|
11
|
+
import 'change-case';
|
|
11
12
|
import './cli.js';
|
|
13
|
+
import 'conf';
|
|
14
|
+
import 'env-paths';
|
|
15
|
+
import 'formdata-node';
|
|
16
|
+
import 'formdata-node/file-from-path';
|
|
12
17
|
import 'simple-git';
|
|
18
|
+
import 'execa';
|
|
13
19
|
import 'find-process';
|
|
20
|
+
import 'get-port';
|
|
14
21
|
import 'tcp-port-used';
|
|
15
|
-
import 'execa';
|
|
16
|
-
import 'env-paths';
|
|
17
|
-
import { resolve } from './path.js';
|
|
18
22
|
import 'node-fetch';
|
|
19
23
|
import 'ramda';
|
|
20
|
-
import '
|
|
21
|
-
import 'formdata-node';
|
|
22
|
-
import 'formdata-node/file-from-path';
|
|
24
|
+
import { resolve } from './path.js';
|
|
23
25
|
import 'kleur';
|
|
24
|
-
import 'conf';
|
|
25
26
|
import 'dayjs';
|
|
26
27
|
import '../ui/components/DevOutput.js';
|
|
27
28
|
import 'react';
|
package/dist/node/form.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { FormData } from 'formdata-node';
|
|
3
2
|
import type { FormDataEntryValue } from 'formdata-node';
|
|
3
|
+
import { FormData } from 'formdata-node';
|
|
4
4
|
import { fileFromPath } from 'formdata-node/file-from-path';
|
|
5
5
|
export type FormDataResolvable = Array<FormDataResolvable> | {
|
|
6
6
|
[key: string]: FormDataResolvable;
|
package/dist/node/http.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
+
import { isJson } from '../common/string.js';
|
|
1
2
|
import fetch from 'node-fetch';
|
|
2
3
|
import { is, mergeDeepLeft } from 'ramda';
|
|
3
4
|
import './cli.js';
|
|
4
|
-
import '
|
|
5
|
-
import 'find-process';
|
|
6
|
-
import 'tcp-port-used';
|
|
7
|
-
import 'execa';
|
|
5
|
+
import 'conf';
|
|
8
6
|
import { get as get$1 } from './env.js';
|
|
7
|
+
import './filesystem.js';
|
|
9
8
|
import 'formdata-node';
|
|
10
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 { get as get$2 } from './session.js';
|
|
11
16
|
import 'kleur';
|
|
12
|
-
import 'conf';
|
|
13
17
|
import 'dayjs';
|
|
14
|
-
import { get as get$2 } from './session.js';
|
|
15
|
-
import './filesystem.js';
|
|
16
18
|
import '../ui/components/DevOutput.js';
|
|
17
19
|
import 'react';
|
|
18
20
|
import 'ink';
|
|
19
|
-
import { isJson } from '../common/string.js';
|
|
20
21
|
|
|
21
22
|
function scheme() {
|
|
22
23
|
return get$1('HOST_ENV') === 'dev' ? 'http' : 'https';
|
package/dist/node/path.js
CHANGED
package/dist/node/session.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
+
import 'change-case';
|
|
2
|
+
import { listen } from './callback.js';
|
|
1
3
|
import './cli.js';
|
|
2
|
-
import '
|
|
3
|
-
import {
|
|
4
|
+
import { manager } from './config.js';
|
|
5
|
+
import { randomHex, sha256, base64URLEncode } from './crypto.js';
|
|
4
6
|
import { apiHostname, oauthClientId, sellerAreaHostname } from './env.js';
|
|
5
|
-
import
|
|
7
|
+
import './filesystem.js';
|
|
6
8
|
import 'formdata-node';
|
|
7
9
|
import 'formdata-node/file-from-path';
|
|
10
|
+
import 'simple-git';
|
|
11
|
+
import { isPortAvailable, getPortProcessName, killPortProcess, open } from './system.js';
|
|
12
|
+
import { get as get$1, post } from './http.js';
|
|
8
13
|
import 'kleur';
|
|
9
|
-
import { manager } from './config.js';
|
|
10
|
-
import { randomHex, sha256, base64URLEncode } from './crypto.js';
|
|
11
14
|
import 'dayjs';
|
|
12
|
-
import { listen } from './callback.js';
|
|
13
|
-
import './filesystem.js';
|
|
14
15
|
import '../ui/components/DevOutput.js';
|
|
15
16
|
import 'react';
|
|
16
17
|
import 'ink';
|
|
17
|
-
import 'change-case';
|
|
18
18
|
|
|
19
19
|
const LS_PORT = 3000;
|
|
20
20
|
const LS_HOST = 'localhost';
|
|
@@ -95,6 +95,9 @@ async function authenticate(command) {
|
|
|
95
95
|
const { code, verifier } = await authorize(command);
|
|
96
96
|
const accessToken = await exchange(code, verifier);
|
|
97
97
|
const store = await get$1(`${apiHostname()}/me`, { headers: { Authorization: `Bearer ${accessToken}` } });
|
|
98
|
+
if (!store.is_dev) {
|
|
99
|
+
throw new Error('The CLI can only be used with dev stores, you create one through YouCan Partners.');
|
|
100
|
+
}
|
|
98
101
|
const session = {
|
|
99
102
|
slug: store.slug,
|
|
100
103
|
id: store.id,
|
package/dist/node/system.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import type { Readable, Writable } from 'stream';
|
|
4
3
|
import type { ExecaError } from 'execa';
|
|
4
|
+
import type { Readable, Writable } from 'node:stream';
|
|
5
5
|
export interface ExecOptions {
|
|
6
6
|
cwd?: string;
|
|
7
7
|
env?: {
|
|
@@ -17,7 +17,7 @@ export interface ExecOptions {
|
|
|
17
17
|
}
|
|
18
18
|
export declare function exec(command: string, args: string[], options?: ExecOptions): Promise<void>;
|
|
19
19
|
export declare function isPortAvailable(port: number): Promise<boolean>;
|
|
20
|
-
export declare function
|
|
20
|
+
export declare function getPortOrNextOrRandom(port: number): Promise<number>;
|
|
21
21
|
export declare function getPortProcessName(port: number): Promise<string>;
|
|
22
22
|
export declare function killPortProcess(port: number): Promise<void>;
|
|
23
23
|
export declare function open(url: string): Promise<void>;
|
package/dist/node/system.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
import { execa } from 'execa';
|
|
1
3
|
import findProcess from 'find-process';
|
|
4
|
+
import getPort, { portNumbers } from 'get-port';
|
|
2
5
|
import tpu from 'tcp-port-used';
|
|
3
|
-
import { execa } from 'execa';
|
|
4
6
|
|
|
5
7
|
function buildExec(command, args, options) {
|
|
6
8
|
const env = options?.env ?? process.env;
|
|
@@ -26,10 +28,41 @@ async function exec(command, args, options) {
|
|
|
26
28
|
commandProcess.stdout?.pipe(options.stdout, { end: false });
|
|
27
29
|
}
|
|
28
30
|
let aborted = false;
|
|
31
|
+
process.once('SIGINT', () => {
|
|
32
|
+
if (commandProcess.pid) {
|
|
33
|
+
try {
|
|
34
|
+
commandProcess.kill('SIGTERM');
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
process.once('SIGTERM', () => {
|
|
41
|
+
if (commandProcess.pid) {
|
|
42
|
+
try {
|
|
43
|
+
commandProcess.kill('SIGTERM');
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
29
49
|
options?.signal?.addEventListener('abort', () => {
|
|
30
50
|
const pid = commandProcess.pid;
|
|
31
51
|
if (pid) {
|
|
32
52
|
aborted = true;
|
|
53
|
+
try {
|
|
54
|
+
const killProcess = () => {
|
|
55
|
+
try {
|
|
56
|
+
commandProcess.kill('SIGKILL');
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
commandProcess.kill('SIGTERM');
|
|
62
|
+
setTimeout(killProcess, 500);
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
}
|
|
33
66
|
}
|
|
34
67
|
});
|
|
35
68
|
try {
|
|
@@ -49,11 +82,8 @@ async function exec(command, args, options) {
|
|
|
49
82
|
async function isPortAvailable(port) {
|
|
50
83
|
return !await tpu.check(port);
|
|
51
84
|
}
|
|
52
|
-
async function
|
|
53
|
-
|
|
54
|
-
return port;
|
|
55
|
-
}
|
|
56
|
-
return await getNextAvailablePort(port + 1);
|
|
85
|
+
async function getPortOrNextOrRandom(port) {
|
|
86
|
+
return await getPort({ port: portNumbers(port, port + 1000) });
|
|
57
87
|
}
|
|
58
88
|
async function getPortProcessName(port) {
|
|
59
89
|
const info = await findProcess('port', port);
|
|
@@ -88,4 +118,4 @@ function inferUserPackageManager() {
|
|
|
88
118
|
return defaultPackageManager;
|
|
89
119
|
}
|
|
90
120
|
|
|
91
|
-
export { exec,
|
|
121
|
+
export { exec, getPortOrNextOrRandom, getPortProcessName, inferUserPackageManager, isPortAvailable, killPortProcess, open, sleep };
|
package/dist/node/tasks.js
CHANGED
package/dist/node/worker.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Writable } from 'stream';
|
|
2
|
+
import { Writable } from 'node:stream';
|
|
3
3
|
export interface Interface {
|
|
4
|
-
run()
|
|
5
|
-
boot()
|
|
4
|
+
run: () => Promise<void>;
|
|
5
|
+
boot: () => Promise<void>;
|
|
6
6
|
}
|
|
7
7
|
export declare class Logger extends Writable {
|
|
8
8
|
private readonly type;
|
package/dist/node/worker.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
1
2
|
import { Writable } from 'node:stream';
|
|
2
3
|
import dayjs from 'dayjs';
|
|
4
|
+
import 'change-case';
|
|
3
5
|
import './cli.js';
|
|
6
|
+
import 'conf';
|
|
7
|
+
import 'env-paths';
|
|
8
|
+
import './filesystem.js';
|
|
9
|
+
import 'formdata-node';
|
|
10
|
+
import 'formdata-node/file-from-path';
|
|
4
11
|
import 'simple-git';
|
|
12
|
+
import 'execa';
|
|
5
13
|
import 'find-process';
|
|
14
|
+
import 'get-port';
|
|
6
15
|
import 'tcp-port-used';
|
|
7
|
-
import 'execa';
|
|
8
|
-
import 'env-paths';
|
|
9
16
|
import 'node-fetch';
|
|
10
17
|
import 'ramda';
|
|
11
|
-
import 'change-case';
|
|
12
|
-
import 'formdata-node';
|
|
13
|
-
import 'formdata-node/file-from-path';
|
|
14
18
|
import 'kleur';
|
|
15
|
-
import 'conf';
|
|
16
|
-
import './filesystem.js';
|
|
17
19
|
import { renderDevOutput } from '../ui/components/DevOutput.js';
|
|
18
20
|
import 'react';
|
|
19
21
|
import 'ink';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import 'change-case';
|
|
2
|
+
import '../node/cli.js';
|
|
3
|
+
import 'conf';
|
|
4
|
+
import 'env-paths';
|
|
5
|
+
import '../node/filesystem.js';
|
|
6
|
+
import 'formdata-node';
|
|
7
|
+
import 'formdata-node/file-from-path';
|
|
8
|
+
import 'simple-git';
|
|
9
|
+
import 'execa';
|
|
10
|
+
import 'find-process';
|
|
11
|
+
import 'get-port';
|
|
12
|
+
import 'tcp-port-used';
|
|
13
|
+
import 'node-fetch';
|
|
14
|
+
import 'ramda';
|
|
15
|
+
import 'kleur';
|
|
16
|
+
import 'dayjs';
|
|
17
|
+
import { Cloudflared } from '../services/cloudflared.js';
|
|
18
|
+
import '../ui/components/DevOutput.js';
|
|
19
|
+
import 'react';
|
|
20
|
+
import 'ink';
|
|
21
|
+
|
|
22
|
+
const cloudflared = new Cloudflared();
|
|
23
|
+
console.log('Installing Cloudflared...');
|
|
24
|
+
await cloudflared.install();
|
|
25
|
+
console.log('Successfully Installed Cloudflared');
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
+
import { Buffer } from 'node:buffer';
|
|
2
|
+
import { createWriteStream } from 'node:fs';
|
|
3
|
+
import process from 'node:process';
|
|
1
4
|
import { Writable, Readable } from 'node:stream';
|
|
2
5
|
import { pipeline } from 'node:stream/promises';
|
|
3
|
-
import { createWriteStream } from 'node:fs';
|
|
4
6
|
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import 'change-case';
|
|
5
8
|
import '../node/cli.js';
|
|
9
|
+
import 'conf';
|
|
10
|
+
import 'env-paths';
|
|
11
|
+
import { isExecutable, tapIntoTmp, mkdir, decompressGzip, extractTar, move } from '../node/filesystem.js';
|
|
12
|
+
import 'formdata-node';
|
|
13
|
+
import 'formdata-node/file-from-path';
|
|
6
14
|
import 'simple-git';
|
|
7
15
|
import { exec } from '../node/system.js';
|
|
8
|
-
import 'env-paths';
|
|
9
|
-
import { join, dirname, basename, resolve } from '../node/path.js';
|
|
10
16
|
import 'node-fetch';
|
|
11
17
|
import 'ramda';
|
|
12
|
-
import '
|
|
13
|
-
import 'formdata-node';
|
|
14
|
-
import 'formdata-node/file-from-path';
|
|
18
|
+
import { join, dirname, basename, resolve } from '../node/path.js';
|
|
15
19
|
import 'kleur';
|
|
16
|
-
import 'conf';
|
|
17
20
|
import 'dayjs';
|
|
18
|
-
import { isExecutable, tapIntoTmp, mkdir, decompressGzip, extractTar, move } from '../node/filesystem.js';
|
|
19
21
|
import '../ui/components/DevOutput.js';
|
|
20
22
|
import 'react';
|
|
21
23
|
import 'ink';
|
|
@@ -127,7 +129,7 @@ class OutputStream extends Writable {
|
|
|
127
129
|
return true;
|
|
128
130
|
}
|
|
129
131
|
extractTunnelUrl() {
|
|
130
|
-
const regex = /https:\/\/(?!api\.trycloudflare\.com)
|
|
132
|
+
const regex = /https:\/\/(?!api\.trycloudflare\.com)\S+\.trycloudflare\.com/;
|
|
131
133
|
return this.buffer.match(regex)?.[0] || null;
|
|
132
134
|
}
|
|
133
135
|
extractError() {
|
|
@@ -162,7 +164,6 @@ class Cloudflared {
|
|
|
162
164
|
this.system = { platform, arch };
|
|
163
165
|
}
|
|
164
166
|
async tunnel(port, host = 'localhost') {
|
|
165
|
-
await this.install();
|
|
166
167
|
const { bin, args } = this.composeTunnelingCommand(port, host);
|
|
167
168
|
this.exec(bin, args);
|
|
168
169
|
}
|
package/dist/ui/index.d.ts
CHANGED
package/dist/ui/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@youcan/cli-kit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.3.
|
|
4
|
+
"version": "2.3.3",
|
|
5
5
|
"description": "Utilities for the YouCan CLI",
|
|
6
6
|
"author": "YouCan <contact@youcan.shop> (https://youcan.shop)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"find-process": "^1.4.7",
|
|
31
31
|
"formdata-node": "^6.0.3",
|
|
32
32
|
"fs-extra": "^11.1.1",
|
|
33
|
+
"get-port": "^7.1.0",
|
|
33
34
|
"glob": "^11.0.0",
|
|
34
35
|
"ink": "^5.1.0",
|
|
35
36
|
"kill-port-process": "^3.2.0",
|
|
@@ -60,6 +61,7 @@
|
|
|
60
61
|
"build": "shx rm -rf dist && tsc --noEmit && rollup --config rollup.config.js",
|
|
61
62
|
"dev": "shx rm -rf dist && rollup --config rollup.config.js --watch",
|
|
62
63
|
"release": "pnpm publish --access public",
|
|
63
|
-
"type-check": "tsc --noEmit"
|
|
64
|
+
"type-check": "tsc --noEmit",
|
|
65
|
+
"postinstall": "node -e \"import('fs').then(fs => { if (fs.existsSync('./dist/scripts/install-cloudflared.js')) import('./dist/scripts/install-cloudflared.js'); });\""
|
|
64
66
|
}
|
|
65
67
|
}
|