@nemo-cli/shared 0.0.5 → 0.1.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/README.md +1 -1
- package/dist/index.d.ts +289 -20
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3078 -14
- package/dist/index.js.map +1 -0
- package/package.json +40 -30
- package/dist/.tsBuildInfoFile.json +0 -1
- package/dist/constants.d.ts +0 -2
- package/dist/constants.js +0 -2
- package/dist/createInquirer.d.ts +0 -10
- package/dist/createInquirer.js +0 -20
- package/dist/utils/Inquirer.d.ts +0 -10
- package/dist/utils/Inquirer.js +0 -20
- package/dist/utils/command.d.ts +0 -3
- package/dist/utils/command.js +0 -14
- package/dist/utils/common.d.ts +0 -2
- package/dist/utils/common.js +0 -16
- package/dist/utils/config.d.ts +0 -7
- package/dist/utils/config.js +0 -15
- package/dist/utils/createInquirer.d.ts +0 -10
- package/dist/utils/createInquirer.js +0 -20
- package/dist/utils/env.d.ts +0 -1
- package/dist/utils/env.js +0 -1
- package/dist/utils/file.d.ts +0 -25
- package/dist/utils/file.js +0 -54
- package/dist/utils/log.d.ts +0 -61
- package/dist/utils/log.js +0 -94
- package/dist/utils/npminfo.d.ts +0 -7
- package/dist/utils/npminfo.js +0 -10
- package/dist/utils/pathname.d.ts +0 -6
- package/dist/utils/pathname.js +0 -4
- package/dist/utils/promise.d.ts +0 -1
- package/dist/utils/promise.js +0 -9
- package/dist/utils/spinner.d.ts +0 -2
- package/dist/utils/spinner.js +0 -15
- package/dist/utils/types.d.ts +0 -19
- package/dist/utils/types.js +0 -22
package/dist/utils/log.d.ts
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import npmlog from 'npmlog';
|
|
2
|
-
declare const DEFAULT_OPTIONS: {
|
|
3
|
-
heading: string;
|
|
4
|
-
level: string;
|
|
5
|
-
};
|
|
6
|
-
export declare const log: {
|
|
7
|
-
init: (customOptions?: typeof DEFAULT_OPTIONS) => void;
|
|
8
|
-
lever: undefined;
|
|
9
|
-
stopDebug(): void;
|
|
10
|
-
debug(): void;
|
|
11
|
-
timing(prefix: string | undefined, time: string | number): void;
|
|
12
|
-
error(prefix?: string, ...messages: any[]): void;
|
|
13
|
-
verbose(prefix?: string, ...message: any[]): void;
|
|
14
|
-
success(prefix?: string, ...messages: any[]): void;
|
|
15
|
-
clearScreen(): void;
|
|
16
|
-
clearTerminal(): void;
|
|
17
|
-
beep(): void;
|
|
18
|
-
scrollDown(): void;
|
|
19
|
-
scrollUp(): void;
|
|
20
|
-
eraseEndLine(): void;
|
|
21
|
-
level: string;
|
|
22
|
-
record: npmlog.MessageObject[];
|
|
23
|
-
maxRecordSize: number;
|
|
24
|
-
prefixStyle: npmlog.StyleObject;
|
|
25
|
-
headingStyle: npmlog.StyleObject;
|
|
26
|
-
heading: string;
|
|
27
|
-
stream: any;
|
|
28
|
-
log(level: string, prefix: string, message: string, ...args: any[]): void;
|
|
29
|
-
silly(prefix: string, message: string, ...args: any[]): void;
|
|
30
|
-
info(prefix: string, message: string, ...args: any[]): void;
|
|
31
|
-
http(prefix: string, message: string, ...args: any[]): void;
|
|
32
|
-
notice(prefix: string, message: string, ...args: any[]): void;
|
|
33
|
-
warn(prefix: string, message: string, ...args: any[]): void;
|
|
34
|
-
silent(prefix: string, message: string, ...args: any[]): void;
|
|
35
|
-
enableColor(): void;
|
|
36
|
-
disableColor(): void;
|
|
37
|
-
enableProgress(): void;
|
|
38
|
-
disableProgress(): void;
|
|
39
|
-
progressEnabled(): boolean;
|
|
40
|
-
enableUnicode(): void;
|
|
41
|
-
disableUnicode(): void;
|
|
42
|
-
pause(): void;
|
|
43
|
-
resume(): void;
|
|
44
|
-
addLevel(level: string, n: number, style?: npmlog.StyleObject | undefined, disp?: string | undefined): void;
|
|
45
|
-
addListener(eventName: string | symbol, listener: (...args: any[]) => void): npmlog.Logger;
|
|
46
|
-
on(eventName: string | symbol, listener: (...args: any[]) => void): npmlog.Logger;
|
|
47
|
-
once(eventName: string | symbol, listener: (...args: any[]) => void): npmlog.Logger;
|
|
48
|
-
removeListener(eventName: string | symbol, listener: (...args: any[]) => void): npmlog.Logger;
|
|
49
|
-
off(eventName: string | symbol, listener: (...args: any[]) => void): npmlog.Logger;
|
|
50
|
-
removeAllListeners(event?: string | symbol | undefined): npmlog.Logger;
|
|
51
|
-
setMaxListeners(n: number): npmlog.Logger;
|
|
52
|
-
getMaxListeners(): number;
|
|
53
|
-
listeners(eventName: string | symbol): Function[];
|
|
54
|
-
rawListeners(eventName: string | symbol): Function[];
|
|
55
|
-
emit(eventName: string | symbol, ...args: any[]): boolean;
|
|
56
|
-
listenerCount(eventName: string | symbol): number;
|
|
57
|
-
prependListener(eventName: string | symbol, listener: (...args: any[]) => void): npmlog.Logger;
|
|
58
|
-
prependOnceListener(eventName: string | symbol, listener: (...args: any[]) => void): npmlog.Logger;
|
|
59
|
-
eventNames(): (string | symbol)[];
|
|
60
|
-
};
|
|
61
|
-
export {};
|
package/dist/utils/log.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
import npmlog from 'npmlog';
|
|
3
|
-
import ansiEscapes from 'ansi-escapes';
|
|
4
|
-
import { isString } from './types.js';
|
|
5
|
-
// type LogLevels = "silly" | "verbose" | "info" | "timing" | "http" | "notice" | "warn" | "error" | "silent";
|
|
6
|
-
const DEFAULT_OPTIONS = {
|
|
7
|
-
heading: '@nemo-cli',
|
|
8
|
-
level: 'warn'
|
|
9
|
-
};
|
|
10
|
-
const init = (customOptions) => {
|
|
11
|
-
const options = { ...DEFAULT_OPTIONS, ...customOptions };
|
|
12
|
-
npmlog.heading = options.heading;
|
|
13
|
-
npmlog.level = options.level;
|
|
14
|
-
npmlog.addLevel('success', 8000, {
|
|
15
|
-
fg: 'green',
|
|
16
|
-
bg: 'black',
|
|
17
|
-
bold: true,
|
|
18
|
-
bell: true
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
init();
|
|
22
|
-
const transformMessage = (messages) => {
|
|
23
|
-
for (let i = 0; i < messages.length; i++) {
|
|
24
|
-
const [current, next] = [messages[i], messages[i + 1]];
|
|
25
|
-
if (isString(current) && isString(next)) {
|
|
26
|
-
messages.splice(i, 2, `${current}${next}`);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return messages;
|
|
30
|
-
};
|
|
31
|
-
export const log = {
|
|
32
|
-
...npmlog,
|
|
33
|
-
init,
|
|
34
|
-
set lever(v) {
|
|
35
|
-
throw new Error('use setLevel');
|
|
36
|
-
},
|
|
37
|
-
stopDebug() {
|
|
38
|
-
npmlog.level = 'warn';
|
|
39
|
-
npmlog.warn('current npmlog level', npmlog.level);
|
|
40
|
-
},
|
|
41
|
-
debug() {
|
|
42
|
-
npmlog.level = 'silly';
|
|
43
|
-
npmlog.warn('current npmlog level', npmlog.level);
|
|
44
|
-
},
|
|
45
|
-
timing(prefix = '', time) {
|
|
46
|
-
npmlog.timing(prefix, `${time}`);
|
|
47
|
-
},
|
|
48
|
-
error(prefix = '', ...messages) {
|
|
49
|
-
transformMessage(messages).forEach((message) => {
|
|
50
|
-
if (isString(message)) {
|
|
51
|
-
npmlog.error(prefix, chalk.red.bgBlack(message));
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
console.log(message);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
},
|
|
58
|
-
verbose(prefix = '', ...message) {
|
|
59
|
-
message.forEach((msg) => {
|
|
60
|
-
npmlog.verbose(prefix, isString(msg) ? msg : JSON.stringify(msg));
|
|
61
|
-
});
|
|
62
|
-
},
|
|
63
|
-
success(prefix = '', ...messages) {
|
|
64
|
-
transformMessage(messages).forEach((message) => {
|
|
65
|
-
if (isString(message)) {
|
|
66
|
-
npmlog.success(prefix, chalk.green.bgBlack(message));
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
console.log(message);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
},
|
|
73
|
-
clearScreen() {
|
|
74
|
-
process.stdout.write(ansiEscapes.clearScreen);
|
|
75
|
-
},
|
|
76
|
-
clearTerminal() {
|
|
77
|
-
process.stdout.write(ansiEscapes.clearTerminal);
|
|
78
|
-
},
|
|
79
|
-
beep() {
|
|
80
|
-
process.stdout.write(ansiEscapes.beep);
|
|
81
|
-
},
|
|
82
|
-
scrollDown() {
|
|
83
|
-
process.stdout.write(ansiEscapes.scrollDown);
|
|
84
|
-
},
|
|
85
|
-
scrollUp() {
|
|
86
|
-
process.stdout.write(ansiEscapes.scrollUp);
|
|
87
|
-
},
|
|
88
|
-
eraseEndLine() {
|
|
89
|
-
// process.stdout.moveCursor(0, -1)
|
|
90
|
-
// process.stdout.clearLine(0)
|
|
91
|
-
process.stdout.write(ansiEscapes.cursorPrevLine);
|
|
92
|
-
process.stdout.write(ansiEscapes.eraseLine);
|
|
93
|
-
}
|
|
94
|
-
};
|
package/dist/utils/npminfo.d.ts
DELETED
package/dist/utils/npminfo.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { log } from './log.js';
|
|
2
|
-
export const getNpmInfo = (npmName, register) => {
|
|
3
|
-
const url = new URL(npmName, register);
|
|
4
|
-
return fetch(url.toString())
|
|
5
|
-
.then((data) => data.json())
|
|
6
|
-
.catch((err) => {
|
|
7
|
-
log.error('network', err.message);
|
|
8
|
-
throw new Error(err);
|
|
9
|
-
});
|
|
10
|
-
};
|
package/dist/utils/pathname.d.ts
DELETED
package/dist/utils/pathname.js
DELETED
package/dist/utils/promise.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const tryPromise: <T>(promise: Promise<T>) => Promise<[Error & T, T]>;
|
package/dist/utils/promise.js
DELETED
package/dist/utils/spinner.d.ts
DELETED
package/dist/utils/spinner.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import instance from 'ora';
|
|
2
|
-
import { isString } from './types.js';
|
|
3
|
-
const BASE_OPTIONS = {
|
|
4
|
-
timeout: 10000
|
|
5
|
-
};
|
|
6
|
-
export const ora = (options) => {
|
|
7
|
-
if (!isString(options))
|
|
8
|
-
return instance(options);
|
|
9
|
-
// TODO: add logo...
|
|
10
|
-
const spinner = instance({
|
|
11
|
-
// spinner: {},
|
|
12
|
-
text: options
|
|
13
|
-
});
|
|
14
|
-
return spinner;
|
|
15
|
-
};
|
package/dist/utils/types.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
declare const hasOwn: (target: unknown, key: PropertyKey) => boolean;
|
|
2
|
-
declare const has: <T extends object, K extends PropertyKey>(target: T, key: K) => boolean;
|
|
3
|
-
declare const isLocal: (url?: string) => boolean;
|
|
4
|
-
declare const isString: <T1 extends string = string>(obj: unknown) => obj is T1;
|
|
5
|
-
declare const isNumber: <T1 extends number = number>(obj: unknown) => obj is T1;
|
|
6
|
-
declare const isBoolean: <T1 extends boolean = boolean>(obj: unknown) => obj is T1;
|
|
7
|
-
declare const isNull: <T1 extends null = null>(obj: unknown) => obj is T1;
|
|
8
|
-
declare const isUndefined: <T1 extends undefined = undefined>(obj: unknown) => obj is T1;
|
|
9
|
-
declare const isError: <T1 extends Error = Error>(obj: unknown) => obj is T1;
|
|
10
|
-
declare const isPromise: <T1 extends Promise<unknown> = Promise<unknown>>(obj: unknown) => obj is T1;
|
|
11
|
-
declare const isPlainObject: <T1 extends Record<string, unknown> = Record<string, unknown>>(obj: unknown) => obj is T1;
|
|
12
|
-
declare const isArray: <T1 extends unknown[] = unknown[]>(obj: unknown) => obj is T1;
|
|
13
|
-
declare const isDate: <T1 extends Date = Date>(obj: unknown) => obj is T1;
|
|
14
|
-
declare const isSymbol: <T1 extends symbol = symbol>(obj: unknown) => obj is T1;
|
|
15
|
-
declare const isSet: <T1 extends Set<unknown> = Set<unknown>>(obj: unknown) => obj is T1;
|
|
16
|
-
declare const isMap: <T1 extends Map<unknown, unknown> = Map<unknown, unknown>>(obj: unknown) => obj is T1;
|
|
17
|
-
declare const isFormData: <T1 extends FormData = FormData>(obj: unknown) => obj is T1;
|
|
18
|
-
declare const isURLSearchParams: <T1 extends URLSearchParams = URLSearchParams>(obj: unknown) => obj is T1;
|
|
19
|
-
export { hasOwn, has, isString, isNumber, isBoolean, isNull, isUndefined, isError, isPromise, isPlainObject, isArray, isDate, isSymbol, isSet, isMap, isFormData, isURLSearchParams, isLocal };
|
package/dist/utils/types.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const { toString, hasOwnProperty } = Object.prototype;
|
|
2
|
-
const hasOwn = (target, key) => hasOwnProperty.call(target, key);
|
|
3
|
-
const has = (target, key) => Reflect.has(target, key);
|
|
4
|
-
const localRegExp = /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/;
|
|
5
|
-
const isLocal = (url = window.location.hostname) => url === 'localhost' || url === '[::1]' || url.match(localRegExp) !== null;
|
|
6
|
-
const isType = (type) => (obj) => toString.call(obj) === `[object ${type}]`;
|
|
7
|
-
const isString = isType('String');
|
|
8
|
-
const isNumber = isType('Number');
|
|
9
|
-
const isBoolean = isType('Boolean');
|
|
10
|
-
const isNull = isType('Null');
|
|
11
|
-
const isUndefined = isType('Undefined');
|
|
12
|
-
const isError = isType('Error');
|
|
13
|
-
const isPromise = isType('Promise');
|
|
14
|
-
const isPlainObject = isType('Object');
|
|
15
|
-
const isArray = isType('Array');
|
|
16
|
-
const isDate = isType('Date');
|
|
17
|
-
const isSymbol = isType('Symbol');
|
|
18
|
-
const isSet = isType('Set');
|
|
19
|
-
const isMap = isType('Map');
|
|
20
|
-
const isFormData = isType('FormData');
|
|
21
|
-
const isURLSearchParams = isType('URLSearchParams');
|
|
22
|
-
export { hasOwn, has, isString, isNumber, isBoolean, isNull, isUndefined, isError, isPromise, isPlainObject, isArray, isDate, isSymbol, isSet, isMap, isFormData, isURLSearchParams, isLocal };
|