@youcan/cli-kit 1.2.0-beta.1 → 1.2.0-beta.11
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 +1 -0
- package/dist/index.js +2 -0
- package/dist/node/env.js +2 -2
- package/dist/node/filesystem.d.ts +3 -2
- package/dist/node/filesystem.js +10 -3
- package/dist/node/http.d.ts +1 -0
- package/dist/node/http.js +2 -1
- package/dist/node/session.js +1 -0
- package/dist/node/worker.d.ts +19 -0
- package/dist/node/worker.js +36 -0
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export * as Github from './node/github';
|
|
|
9
9
|
export * as System from './node/system';
|
|
10
10
|
export * as Config from './node/config';
|
|
11
11
|
export * as Crypto from './node/crypto';
|
|
12
|
+
export * as Worker from './node/worker';
|
|
12
13
|
export * as Session from './node/session';
|
|
13
14
|
export * as Callback from './node/callback';
|
|
14
15
|
export * as Filesystem from './node/filesystem';
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,8 @@ import * as config from './node/config.js';
|
|
|
20
20
|
export { config as Config };
|
|
21
21
|
import * as crypto from './node/crypto.js';
|
|
22
22
|
export { crypto as Crypto };
|
|
23
|
+
import * as worker from './node/worker.js';
|
|
24
|
+
export { worker as Worker };
|
|
23
25
|
import * as session from './node/session.js';
|
|
24
26
|
export { session as Session };
|
|
25
27
|
import * as callback from './node/callback.js';
|
package/dist/node/env.js
CHANGED
|
@@ -8,7 +8,7 @@ function oauthClientId() {
|
|
|
8
8
|
case 'dev':
|
|
9
9
|
return '3';
|
|
10
10
|
case 'test':
|
|
11
|
-
return '
|
|
11
|
+
return '11';
|
|
12
12
|
case 'prod':
|
|
13
13
|
default:
|
|
14
14
|
return '7';
|
|
@@ -19,7 +19,7 @@ function oauthClientSecret() {
|
|
|
19
19
|
case 'dev':
|
|
20
20
|
return 'kvvtjXFCeuvvNX2nwD30SAfh7DMbVXm16E0MPCTu';
|
|
21
21
|
case 'test':
|
|
22
|
-
return '
|
|
22
|
+
return 'UkNttuRvqjPtX08nSzwGssnKPb21Kg0s0NJNKMAo';
|
|
23
23
|
case 'prod':
|
|
24
24
|
default:
|
|
25
25
|
return 'eCU2eKdDyMlLf1A6LweWL6BjDMixok4IV86rUm3u';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import type { Mode, OpenMode, PathLike } from 'fs';
|
|
3
|
+
import type { Mode, OpenMode, PathLike, Stats } from 'fs';
|
|
4
4
|
import type { Options as GlobOptions, Pattern } from 'fast-glob';
|
|
5
5
|
import chokidar from 'chokidar';
|
|
6
6
|
export declare function exists(path: string): Promise<boolean>;
|
|
@@ -21,8 +21,9 @@ export declare function writeFile(path: PathLike, data: string, options?: {
|
|
|
21
21
|
export declare function readJsonFile<T = Record<string, unknown>>(path: PathLike): Promise<T>;
|
|
22
22
|
export declare function writeJsonFile(path: PathLike, data: Record<string, unknown>): Promise<void>;
|
|
23
23
|
export declare function glob(pattern: Pattern | Pattern[], options?: GlobOptions): Promise<string[]>;
|
|
24
|
-
export declare function archived(path: string, name: string): Promise<string>;
|
|
24
|
+
export declare function archived(path: string, name: string, glob?: string): Promise<string>;
|
|
25
25
|
export declare function unlink(path: string): Promise<void>;
|
|
26
26
|
export declare function readdir(path: string): Promise<string[]>;
|
|
27
|
+
export declare function stat(path: string): Promise<Stats>;
|
|
27
28
|
export declare const watch: typeof chokidar.watch;
|
|
28
29
|
export {};
|
package/dist/node/filesystem.js
CHANGED
|
@@ -18,6 +18,7 @@ import 'formdata-node';
|
|
|
18
18
|
import 'formdata-node/file-from-path';
|
|
19
19
|
import 'kleur';
|
|
20
20
|
import 'conf';
|
|
21
|
+
import 'dayjs';
|
|
21
22
|
|
|
22
23
|
async function exists(path) {
|
|
23
24
|
try {
|
|
@@ -58,7 +59,7 @@ async function glob(pattern, options) {
|
|
|
58
59
|
}
|
|
59
60
|
return _glob(pattern, _options);
|
|
60
61
|
}
|
|
61
|
-
async function archived(path$1, name) {
|
|
62
|
+
async function archived(path$1, name, glob = '**/*') {
|
|
62
63
|
return new Promise((resolve$1, reject) => {
|
|
63
64
|
try {
|
|
64
65
|
const archivePath = resolve(path$1, `${name}.zip`);
|
|
@@ -67,7 +68,10 @@ async function archived(path$1, name) {
|
|
|
67
68
|
output.on('close', () => resolve$1(archivePath));
|
|
68
69
|
_archiver.on('error', () => (err) => reject(err));
|
|
69
70
|
_archiver.pipe(output);
|
|
70
|
-
_archiver.
|
|
71
|
+
_archiver.glob(glob, {
|
|
72
|
+
ignore: [`${name}.zip`],
|
|
73
|
+
cwd: path$1,
|
|
74
|
+
});
|
|
71
75
|
_archiver.finalize();
|
|
72
76
|
}
|
|
73
77
|
catch (err) {
|
|
@@ -83,6 +87,9 @@ async function unlink(path) {
|
|
|
83
87
|
async function readdir(path) {
|
|
84
88
|
return await FilesystemPromises.readdir(path);
|
|
85
89
|
}
|
|
90
|
+
async function stat(path) {
|
|
91
|
+
return await FilesystemPromises.stat(path);
|
|
92
|
+
}
|
|
86
93
|
const watch = chokidar.watch;
|
|
87
94
|
|
|
88
|
-
export { archived, exists, glob, mkdir, move, readFile, readJsonFile, readdir, tapIntoTmp, unlink, watch, writeFile, writeJsonFile };
|
|
95
|
+
export { archived, exists, glob, mkdir, move, readFile, readJsonFile, readdir, stat, tapIntoTmp, unlink, watch, writeFile, writeJsonFile };
|
package/dist/node/http.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { RequestInit } from 'node-fetch';
|
|
2
|
+
export declare function scheme(): 'http' | 'https';
|
|
2
3
|
export declare function get<T>(endpoint: string, options?: RequestInit): Promise<T>;
|
|
3
4
|
export declare function post<T>(endpoint: string, options?: RequestInit): Promise<T>;
|
package/dist/node/http.js
CHANGED
|
@@ -10,6 +10,7 @@ import 'formdata-node';
|
|
|
10
10
|
import 'formdata-node/file-from-path';
|
|
11
11
|
import 'kleur';
|
|
12
12
|
import 'conf';
|
|
13
|
+
import 'dayjs';
|
|
13
14
|
import { get as get$2 } from './session.js';
|
|
14
15
|
import './filesystem.js';
|
|
15
16
|
import { isJson } from '../common/string.js';
|
|
@@ -48,4 +49,4 @@ async function post(endpoint, options = {}) {
|
|
|
48
49
|
return request(`${scheme()}://${endpoint}`, { ...options, method: 'POST' });
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
export { get, post };
|
|
52
|
+
export { get, post, scheme };
|
package/dist/node/session.js
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Writable } from 'stream';
|
|
3
|
+
import type { Color } from '..';
|
|
4
|
+
export interface Interface {
|
|
5
|
+
run(): Promise<void>;
|
|
6
|
+
boot(): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
export declare class Logger extends Writable {
|
|
9
|
+
private channel;
|
|
10
|
+
private type;
|
|
11
|
+
private color;
|
|
12
|
+
constructor(channel: 'stdout' | 'stderr', type: string, color: Color.Color);
|
|
13
|
+
write(chunk: unknown): boolean;
|
|
14
|
+
private pad;
|
|
15
|
+
}
|
|
16
|
+
export declare abstract class Abstract implements Interface {
|
|
17
|
+
abstract boot(): Promise<void>;
|
|
18
|
+
abstract run(): Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Writable } from 'node:stream';
|
|
2
|
+
import { stdout, stderr } from 'node:process';
|
|
3
|
+
import dayjs from 'dayjs';
|
|
4
|
+
|
|
5
|
+
class Logger extends Writable {
|
|
6
|
+
channel;
|
|
7
|
+
type;
|
|
8
|
+
color;
|
|
9
|
+
constructor(channel, type, color) {
|
|
10
|
+
super();
|
|
11
|
+
this.channel = channel;
|
|
12
|
+
this.type = type;
|
|
13
|
+
this.color = color;
|
|
14
|
+
}
|
|
15
|
+
write(chunk) {
|
|
16
|
+
if (!(chunk instanceof Buffer) && typeof chunk !== 'string') {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const channel = this.channel === 'stdout' ? stdout : stderr;
|
|
20
|
+
const time = dayjs().format('HH:mm:ss:SSS');
|
|
21
|
+
const lines = chunk.toString().split('\n').map(s => s.trim()).filter(s => s !== '');
|
|
22
|
+
for (let i = 0; i < lines.length; i++) {
|
|
23
|
+
i === 0
|
|
24
|
+
? channel.write(this.color(`${time} | ${this.pad(this.type, 10)} | ${lines[i]}\n`))
|
|
25
|
+
: channel.write(this.color(` | ${lines[i]}\n`));
|
|
26
|
+
}
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
pad(subject, length, char = ' ') {
|
|
30
|
+
return subject.padEnd(length, char);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
class Abstract {
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { Abstract, Logger };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@youcan/cli-kit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.2.0-beta.
|
|
4
|
+
"version": "1.2.0-beta.11",
|
|
5
5
|
"description": "Utilities for the YouCan CLI",
|
|
6
6
|
"author": "YouCan <contact@youcan.shop> (https://youcan.shop)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"change-case": "^4.1.2",
|
|
25
25
|
"chokidar": "^3.5.3",
|
|
26
26
|
"conf": "^11.0.2",
|
|
27
|
+
"dayjs": "^1.11.10",
|
|
27
28
|
"env-paths": "^3.0.0",
|
|
28
29
|
"execa": "^6.1.0",
|
|
29
30
|
"fast-glob": "^3.3.1",
|