@theholocron/cli 1.0.0 → 1.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/LICENSE +21 -674
- package/README.md +19 -8
- package/dist/capabilities/index.d.mts +2 -0
- package/dist/capabilities/index.mjs +2 -0
- package/dist/capabilities-QjjhVlDd.mjs +43 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +852 -0
- package/dist/config-DWlIfFZm.mjs +113 -0
- package/dist/index-CSxf0Yc7.d.mts +485 -0
- package/dist/index.d.mts +58 -0
- package/dist/index.mjs +3 -0
- package/package.json +46 -53
- package/.alexignore +0 -3
- package/.editorconfig +0 -24
- package/.editorconfig-checker.json +0 -20
- package/.env +0 -3
- package/.gitattributes +0 -12
- package/.github/CODEOWNERS +0 -1
- package/.github/dependabot.yml +0 -6
- package/.github/labeler.yml +0 -21
- package/.github/workflows/bookkeeping-pr.yml +0 -32
- package/.github/workflows/greetings.yml +0 -32
- package/.github/workflows/lint.yml +0 -96
- package/.github/workflows/publish.yml +0 -71
- package/.github/workflows/review.yml +0 -72
- package/.github/workflows/stale.yml +0 -25
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -13
- package/.husky/prepare-commit-msg +0 -18
- package/commitlint.config.js +0 -9
- package/eslint.config.js +0 -9
- package/media/README.md +0 -11
- package/media/error.mp3 +0 -0
- package/media/success.mp3 +0 -0
- package/media/warning.mp3 +0 -0
- package/prettier.config.js +0 -11
- package/src/cli.ts +0 -65
- package/src/commands/README.md +0 -13
- package/src/commands/bootstrap.ts +0 -102
- package/src/commands/conf/README.md +0 -45
- package/src/commands/conf/add.ts +0 -49
- package/src/commands/conf/edit.ts +0 -12
- package/src/commands/conf/view.ts +0 -40
- package/src/commands/conf.ts +0 -10
- package/src/commands/log.ts +0 -91
- package/src/const.ts +0 -19
- package/src/tasks/README.md +0 -33
- package/src/tasks/find/README.md +0 -49
- package/src/tasks/find/find-project.example.ts +0 -23
- package/src/tasks/find/find-project.ts +0 -76
- package/src/tasks/find/index.ts +0 -1
- package/src/tasks/index.ts +0 -2
- package/src/tasks/replace/README.md +0 -61
- package/src/tasks/replace/index.ts +0 -1
- package/src/tasks/replace/replace.example.ts +0 -31
- package/src/tasks/replace/replace.ts +0 -95
- package/src/ui/README.md +0 -8
- package/src/ui/index.ts +0 -2
- package/src/ui/open/README.md +0 -58
- package/src/ui/open/index.ts +0 -7
- package/src/ui/open/open-browser.ts +0 -25
- package/src/ui/open/open-editor.example.ts +0 -14
- package/src/ui/open/open-editor.ts +0 -30
- package/src/ui/prompts/README.md +0 -36
- package/src/ui/prompts/autocomplete.prompt.ts +0 -18
- package/src/ui/prompts/confirm.prompt.ts +0 -21
- package/src/ui/prompts/index.ts +0 -17
- package/src/ui/prompts/input.prompt.ts +0 -15
- package/src/ui/prompts/search.prompt.ts +0 -33
- package/src/ui/prompts/select.prompt.ts +0 -17
- package/src/ui/prompts/types.ts +0 -8
- package/src/ui/prompts/utils.ts +0 -11
- package/src/utils/$/README.md +0 -87
- package/src/utils/$/command.test.ts +0 -48
- package/src/utils/$/command.ts +0 -21
- package/src/utils/$/directory.ts +0 -108
- package/src/utils/$/file.ts +0 -98
- package/src/utils/$/index.example.ts +0 -37
- package/src/utils/$/index.ts +0 -22
- package/src/utils/$/path.ts +0 -13
- package/src/utils/$/remove.ts +0 -47
- package/src/utils/$/spawn.ts +0 -26
- package/src/utils/$/utils.ts +0 -21
- package/src/utils/README.md +0 -15
- package/src/utils/config/README.md +0 -41
- package/src/utils/config/config.ts +0 -26
- package/src/utils/config/index.ts +0 -1
- package/src/utils/config/preferences.conf.ts +0 -45
- package/src/utils/env/README.md +0 -52
- package/src/utils/env/env.example.ts +0 -21
- package/src/utils/env/env.ts +0 -57
- package/src/utils/env/index.ts +0 -1
- package/src/utils/index.ts +0 -5
- package/src/utils/log/README.md +0 -117
- package/src/utils/log/index.ts +0 -2
- package/src/utils/log/log.example.ts +0 -13
- package/src/utils/log/log.ts +0 -58
- package/src/utils/log/logger.ts +0 -28
- package/src/utils/log/sound.ts +0 -35
- package/src/utils/node/README.md +0 -23
- package/src/utils/node/index.ts +0 -5
- package/src/utils/node/package.ts +0 -12
- package/tsconfig.json +0 -15
- package/yamllint.config.yml +0 -20
package/src/utils/log/README.md
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
# Log
|
|
2
|
-
|
|
3
|
-
A logger with different levels and formatting options.
|
|
4
|
-
|
|
5
|
-
This provides functions for logging messages with different log levels (error, info, success, warning). Each log level has its own formatting for better readability.
|
|
6
|
-
|
|
7
|
-
## Usage
|
|
8
|
-
|
|
9
|
-
```javascript
|
|
10
|
-
import { log } from "@/utils";
|
|
11
|
-
|
|
12
|
-
const FN = "func";
|
|
13
|
-
const options = { debug: true };
|
|
14
|
-
|
|
15
|
-
console.log(log.style.bold("this message is bold"));
|
|
16
|
-
|
|
17
|
-
log.data(FN, "key", { test: "value"}, options);
|
|
18
|
-
log.error(FN, "This is an error message", options);
|
|
19
|
-
log.info(FN, "This is an info message", options);
|
|
20
|
-
log.process(FN, "this is a processing message", options);
|
|
21
|
-
log.success(FN, "This is a success message", options);
|
|
22
|
-
log.warning(FN, "This is a warning message", options);
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## API
|
|
26
|
-
|
|
27
|
-
All functions take `CLIOptions` as the last argument, which allow you to pass in an object with `debug` as a boolean to allow you to print to the console and `sound` as a boolean to allow sound as feedback.
|
|
28
|
-
|
|
29
|
-
### `.data(prefix: string, key: string, message: any, options: CLIOptions)`
|
|
30
|
-
|
|
31
|
-
Logs data with a function prefix.
|
|
32
|
-
|
|
33
|
-
#### prefix
|
|
34
|
-
|
|
35
|
-
The function name to be identified in the logs.
|
|
36
|
-
|
|
37
|
-
Type: `string`
|
|
38
|
-
|
|
39
|
-
#### key
|
|
40
|
-
|
|
41
|
-
A name for the data.
|
|
42
|
-
|
|
43
|
-
Type: `string`
|
|
44
|
-
|
|
45
|
-
#### message
|
|
46
|
-
|
|
47
|
-
Type: `any`
|
|
48
|
-
|
|
49
|
-
### `.error(prefix: string, message: string)`
|
|
50
|
-
|
|
51
|
-
Logs an error message with a function prefix.
|
|
52
|
-
|
|
53
|
-
#### prefix
|
|
54
|
-
|
|
55
|
-
The function name to be identified in the logs.
|
|
56
|
-
|
|
57
|
-
Type: `string`
|
|
58
|
-
|
|
59
|
-
#### message
|
|
60
|
-
|
|
61
|
-
Type: `string`
|
|
62
|
-
|
|
63
|
-
### `.info(prefix: string, message: string)`
|
|
64
|
-
|
|
65
|
-
Logs an info message with a function prefix.
|
|
66
|
-
|
|
67
|
-
#### prefix
|
|
68
|
-
|
|
69
|
-
The function name to be identified in the logs.
|
|
70
|
-
|
|
71
|
-
Type: `string`
|
|
72
|
-
|
|
73
|
-
#### message
|
|
74
|
-
|
|
75
|
-
Type: `string`
|
|
76
|
-
|
|
77
|
-
### `.process(prefix: string, message: string)`
|
|
78
|
-
|
|
79
|
-
Logs a message for a running process with a function prefix.
|
|
80
|
-
|
|
81
|
-
#### prefix
|
|
82
|
-
|
|
83
|
-
The function name to be identified in the logs.
|
|
84
|
-
|
|
85
|
-
Type: `string`
|
|
86
|
-
|
|
87
|
-
#### message
|
|
88
|
-
|
|
89
|
-
Type: `string`
|
|
90
|
-
|
|
91
|
-
### `.success(prefix: string, message: string)`
|
|
92
|
-
|
|
93
|
-
Logs a success message with a function prefix.
|
|
94
|
-
|
|
95
|
-
#### prefix
|
|
96
|
-
|
|
97
|
-
The function name to be identified in the logs.
|
|
98
|
-
|
|
99
|
-
Type: `string`
|
|
100
|
-
|
|
101
|
-
#### message
|
|
102
|
-
|
|
103
|
-
Type: `string`
|
|
104
|
-
|
|
105
|
-
### `.warning(prefix: string, message: string)`
|
|
106
|
-
|
|
107
|
-
Logs a warning message with a function prefix.
|
|
108
|
-
|
|
109
|
-
#### prefix
|
|
110
|
-
|
|
111
|
-
The function name to be identified in the logs.
|
|
112
|
-
|
|
113
|
-
Type: `string`
|
|
114
|
-
|
|
115
|
-
#### message
|
|
116
|
-
|
|
117
|
-
Type: `string`
|
package/src/utils/log/index.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { log } from "@/utils";
|
|
2
|
-
|
|
3
|
-
const FN = "func";
|
|
4
|
-
const options = { debug: true };
|
|
5
|
-
|
|
6
|
-
console.log(log.style.bold("this message is bold"));
|
|
7
|
-
|
|
8
|
-
log.data(FN, "key", { test: "value" }, options);
|
|
9
|
-
log.error(FN, "This is an error message", options);
|
|
10
|
-
log.info(FN, "This is an info message", options);
|
|
11
|
-
log.process(FN, "this is a processing message", options);
|
|
12
|
-
log.success(FN, "This is a success message", options);
|
|
13
|
-
log.warning(FN, "This is a warning message", options);
|
package/src/utils/log/log.ts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import chalk from "chalk";
|
|
2
|
-
import { type CLIOptions } from "@/cli";
|
|
3
|
-
import { logger } from "./logger";
|
|
4
|
-
import { sound } from "./sound";
|
|
5
|
-
|
|
6
|
-
type LoggerFunction = (prefix: string, message: string, options?: CLIOptions) => void;
|
|
7
|
-
|
|
8
|
-
const bold = (str: string) => chalk.magenta.bold(str);
|
|
9
|
-
|
|
10
|
-
const data = (prefix: string, key: string, message: any, options: CLIOptions) => {
|
|
11
|
-
options?.debug && console.log(chalk.cyan(`[${prefix}]:`), chalk.bgWhiteBright(`${key}:`), message);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const error: LoggerFunction = (prefix, message, options) => {
|
|
15
|
-
logger.error(`[${prefix}] error: ${message}`);
|
|
16
|
-
|
|
17
|
-
console.log(chalk.red.bold(message));
|
|
18
|
-
options?.sound && sound.error();
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const info: LoggerFunction = (prefix, message, options) => {
|
|
22
|
-
logger.info(`[${prefix}] info: ${message}`);
|
|
23
|
-
|
|
24
|
-
options?.debug && console.log(chalk.cyan(`[${prefix}]:`), message);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const processing: LoggerFunction = (prefix, message, options) => {
|
|
28
|
-
logger.info(`[${prefix}] processing: ${message}`);
|
|
29
|
-
|
|
30
|
-
options?.debug && console.log(chalk.magenta(`[${prefix}]:`), message);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const success: LoggerFunction = (prefix, message, options) => {
|
|
34
|
-
logger.info(`[${prefix}] success: ${message}`);
|
|
35
|
-
|
|
36
|
-
console.log(chalk.green.bold(message));
|
|
37
|
-
options?.sound && sound.success();
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const warning: LoggerFunction = (prefix, message, options) => {
|
|
41
|
-
logger.warn(`[${prefix}] warning: ${message}`);
|
|
42
|
-
|
|
43
|
-
console.log(chalk.yellow.bold(message));
|
|
44
|
-
options?.sound && sound.warning();
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export const log = {
|
|
48
|
-
bold,
|
|
49
|
-
data,
|
|
50
|
-
error,
|
|
51
|
-
info,
|
|
52
|
-
process: processing,
|
|
53
|
-
success,
|
|
54
|
-
style: {
|
|
55
|
-
bold,
|
|
56
|
-
},
|
|
57
|
-
warning,
|
|
58
|
-
};
|
package/src/utils/log/logger.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import winston from "winston";
|
|
4
|
-
import { config } from "@/utils";
|
|
5
|
-
|
|
6
|
-
const LOGS = config.get("preferences.logs");
|
|
7
|
-
|
|
8
|
-
if (!fs.existsSync(LOGS)) {
|
|
9
|
-
fs.mkdirSync(LOGS, { recursive: true });
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export type LogLevel = "error" | "warn" | "info" | "verbose" | "debug" | "all";
|
|
13
|
-
|
|
14
|
-
export const logger = winston.createLogger({
|
|
15
|
-
level: "info" as LogLevel,
|
|
16
|
-
format: winston.format.combine(
|
|
17
|
-
winston.format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }),
|
|
18
|
-
winston.format.printf(({ timestamp, level, message }) => `${timestamp} ${level}: ${message}`)
|
|
19
|
-
),
|
|
20
|
-
transports: [
|
|
21
|
-
new winston.transports.File({ filename: path.join(LOGS, "error.log"), level: "error" as LogLevel }),
|
|
22
|
-
new winston.transports.File({ filename: path.join(LOGS, "warn.log"), level: "warn" as LogLevel }),
|
|
23
|
-
new winston.transports.File({ filename: path.join(LOGS, "info.log"), level: "info" as LogLevel }),
|
|
24
|
-
new winston.transports.File({ filename: path.join(LOGS, "verbose.log"), level: "verbose" as LogLevel }),
|
|
25
|
-
new winston.transports.File({ filename: path.join(LOGS, "debug.log"), level: "debug" as LogLevel }),
|
|
26
|
-
new winston.transports.File({ filename: path.join(LOGS, "log") }), // General log file
|
|
27
|
-
],
|
|
28
|
-
});
|
package/src/utils/log/sound.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import play from "play-sound";
|
|
2
|
-
|
|
3
|
-
const player = play();
|
|
4
|
-
|
|
5
|
-
async function playSound(soundPath: string): Promise<void> {
|
|
6
|
-
return new Promise((resolve, reject) => {
|
|
7
|
-
player.play(soundPath, (err: Error | null) => {
|
|
8
|
-
if (err) {
|
|
9
|
-
reject(err);
|
|
10
|
-
} else {
|
|
11
|
-
resolve();
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
type FeedbackFunction = () => Promise<void>;
|
|
18
|
-
|
|
19
|
-
const error: FeedbackFunction = async () => {
|
|
20
|
-
await playSound("./media/error.mp3");
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const success: FeedbackFunction = async () => {
|
|
24
|
-
await playSound("./media/success.mp3");
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const warning: FeedbackFunction = async () => {
|
|
28
|
-
await playSound("./media/warning.mp3");
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const sound = {
|
|
32
|
-
error,
|
|
33
|
-
success,
|
|
34
|
-
warning,
|
|
35
|
-
};
|
package/src/utils/node/README.md
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# Node
|
|
2
|
-
|
|
3
|
-
Interact with node packages.
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
```javascript
|
|
8
|
-
import { node } from "@/utils";
|
|
9
|
-
|
|
10
|
-
const name = node.pkg("~/code/foo");
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## API
|
|
14
|
-
|
|
15
|
-
### `.pkg(dirPath: string)`
|
|
16
|
-
|
|
17
|
-
Grabs the data from the package in parsed JSON.
|
|
18
|
-
|
|
19
|
-
#### dirPath
|
|
20
|
-
|
|
21
|
-
The pathway to the `package.json`.
|
|
22
|
-
|
|
23
|
-
Type: `string`
|
package/src/utils/node/index.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { promises as fs } from "node:fs";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
|
|
4
|
-
export async function getPackage(dirPath: string): Promise<string | null> {
|
|
5
|
-
try {
|
|
6
|
-
const pkg = await fs.readFile(path.join(dirPath, "package.json"), "utf-8");
|
|
7
|
-
|
|
8
|
-
return [null, JSON.parse(pkg)];
|
|
9
|
-
} catch (error) {
|
|
10
|
-
return [error];
|
|
11
|
-
}
|
|
12
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"display": "Holocron CLI",
|
|
3
|
-
"extends": "@tsconfig/node-lts/tsconfig.json",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"baseUrl": "./",
|
|
6
|
-
"outDir": "./dist",
|
|
7
|
-
"paths": {
|
|
8
|
-
"@/media": ["./media/*"],
|
|
9
|
-
"@/package": ["./package.json"],
|
|
10
|
-
"@/*": ["./src/*"]
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
"include": ["**/*.ts"],
|
|
14
|
-
"exclude": ["./node_modules"]
|
|
15
|
-
}
|
package/yamllint.config.yml
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
|
|
3
|
-
extends: default
|
|
4
|
-
|
|
5
|
-
rules:
|
|
6
|
-
comments:
|
|
7
|
-
min-spaces-from-content: 1
|
|
8
|
-
require-starting-space: true
|
|
9
|
-
|
|
10
|
-
comments-indentation: {}
|
|
11
|
-
|
|
12
|
-
document-start:
|
|
13
|
-
ignore: |
|
|
14
|
-
.github/*.yml
|
|
15
|
-
|
|
16
|
-
indentation:
|
|
17
|
-
spaces: consistent
|
|
18
|
-
indent-sequences: consistent
|
|
19
|
-
|
|
20
|
-
line-length: disable
|