@hintoai/cli 0.3.4 → 0.4.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/dist/api/articles.d.ts +1 -0
- package/dist/commands/articles.js +8 -2
- package/dist/config.d.ts +1 -1
- package/dist/config.js +14 -6
- package/package.json +1 -1
package/dist/api/articles.d.ts
CHANGED
|
@@ -110,18 +110,24 @@ function registerArticles(program, client) {
|
|
|
110
110
|
.description('Update an article')
|
|
111
111
|
.option('--title <title>', 'New title')
|
|
112
112
|
.option('--slug <slug>', 'New slug')
|
|
113
|
+
.option('--content <content>', 'New Markdown content (string or @filepath) — replaces the body')
|
|
113
114
|
.option('--meta-description <text>', 'SEO meta description')
|
|
114
115
|
.option('--meta-keywords <keywords>', 'Comma-separated SEO keywords')
|
|
115
116
|
.option('--json', 'Output as JSON')
|
|
116
117
|
.action(async (id, opts) => {
|
|
117
118
|
try {
|
|
118
|
-
if (!opts.title &&
|
|
119
|
-
|
|
119
|
+
if (!opts.title &&
|
|
120
|
+
!opts.slug &&
|
|
121
|
+
!opts.content &&
|
|
122
|
+
!opts.metaDescription &&
|
|
123
|
+
!opts.metaKeywords) {
|
|
124
|
+
(0, errors_1.exitWithError)('Provide at least one field to update: --title, --slug, --content, --meta-description, or --meta-keywords');
|
|
120
125
|
return;
|
|
121
126
|
}
|
|
122
127
|
const data = await api.update(id, {
|
|
123
128
|
...(opts.title !== undefined && { title: opts.title }),
|
|
124
129
|
...(opts.slug !== undefined && { slug: opts.slug }),
|
|
130
|
+
...(opts.content !== undefined && { content: resolveContent(opts.content) }),
|
|
125
131
|
...(opts.metaDescription !== undefined && { metaDescription: opts.metaDescription }),
|
|
126
132
|
...(opts.metaKeywords !== undefined && {
|
|
127
133
|
metaKeywords: opts.metaKeywords
|
package/dist/config.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export interface HintoConfig {
|
|
|
2
2
|
apiKey: string;
|
|
3
3
|
baseUrl: string;
|
|
4
4
|
}
|
|
5
|
-
export declare
|
|
5
|
+
export declare function configPath(): string;
|
|
6
6
|
export declare function saveConfig(config: HintoConfig): void;
|
|
7
7
|
export declare function loadConfig(): HintoConfig;
|
package/dist/config.js
CHANGED
|
@@ -3,27 +3,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.configPath = configPath;
|
|
7
7
|
exports.saveConfig = saveConfig;
|
|
8
8
|
exports.loadConfig = loadConfig;
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const os_1 = __importDefault(require("os"));
|
|
11
11
|
const path_1 = __importDefault(require("path"));
|
|
12
|
-
|
|
12
|
+
// Evaluated lazily (not at module import) so the location always reflects the
|
|
13
|
+
// current environment. Tests redirect it with HINTO_CONFIG_DIR to avoid touching
|
|
14
|
+
// the real ~/.hinto/config.json.
|
|
15
|
+
function configPath() {
|
|
16
|
+
const dir = process.env.HINTO_CONFIG_DIR ?? path_1.default.join(os_1.default.homedir(), '.hinto');
|
|
17
|
+
return path_1.default.join(dir, 'config.json');
|
|
18
|
+
}
|
|
13
19
|
function saveConfig(config) {
|
|
14
|
-
const
|
|
20
|
+
const file = configPath();
|
|
21
|
+
const dir = path_1.default.dirname(file);
|
|
15
22
|
if (!fs_1.default.existsSync(dir))
|
|
16
23
|
fs_1.default.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
17
|
-
fs_1.default.writeFileSync(
|
|
24
|
+
fs_1.default.writeFileSync(file, JSON.stringify(config, null, 2), {
|
|
18
25
|
encoding: 'utf-8',
|
|
19
26
|
mode: 0o600,
|
|
20
27
|
});
|
|
21
28
|
}
|
|
22
29
|
function loadConfig() {
|
|
23
|
-
|
|
30
|
+
const file = configPath();
|
|
31
|
+
if (!fs_1.default.existsSync(file)) {
|
|
24
32
|
throw new Error('Run `hinto init --key <your-api-key>` to get started.');
|
|
25
33
|
}
|
|
26
|
-
const raw = JSON.parse(fs_1.default.readFileSync(
|
|
34
|
+
const raw = JSON.parse(fs_1.default.readFileSync(file, 'utf-8'));
|
|
27
35
|
return {
|
|
28
36
|
...raw,
|
|
29
37
|
apiKey: process.env.HINTO_API_KEY ?? raw.apiKey,
|