@youcan/cli-kit 1.2.0-beta.6 → 1.2.0-beta.8

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 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 '8';
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 '8';
22
+ return 'UkNttuRvqjPtX08nSzwGssnKPb21Kg0s0NJNKMAo';
23
23
  case 'prod':
24
24
  default:
25
25
  return 'eCU2eKdDyMlLf1A6LweWL6BjDMixok4IV86rUm3u';
@@ -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 {
@@ -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 };
@@ -8,6 +8,7 @@ import 'formdata-node/file-from-path';
8
8
  import 'kleur';
9
9
  import { manager } from './config.js';
10
10
  import { randomHex } from './crypto.js';
11
+ import 'dayjs';
11
12
  import { listen } from './callback.js';
12
13
  import './filesystem.js';
13
14
  import 'change-case';
@@ -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.6",
4
+ "version": "1.2.0-beta.8",
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",