directify-cli 1.1.1 → 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "directify-cli",
3
- "version": "1.1.1",
3
+ "version": "1.3.0",
4
4
  "description": "Official CLI tool for Directify - manage your directories, listings, categories, tags, and articles from the command line.",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -63,6 +63,7 @@ categories
63
63
  .option('--icon <icon>', 'Icon (emoji or URL)')
64
64
  .option('--parent-id <id>', 'Parent category ID')
65
65
  .option('--order <n>', 'Sort order', parseInt)
66
+ .option('--head-html <html>', 'Custom HTML for the <head> of the category page (e.g. hreflang tags)')
66
67
  .option('--inactive', 'Create as inactive')
67
68
  .option('-d, --directory <id>', 'Directory ID')
68
69
  .action(async (opts) => {
@@ -77,6 +78,7 @@ categories
77
78
  ...(opts.icon && { icon: opts.icon }),
78
79
  ...(opts.parentId && { parent_id: parseInt(opts.parentId) }),
79
80
  ...(opts.order !== undefined && { order: opts.order }),
81
+ ...(opts.headHtml && { head_html: opts.headHtml }),
80
82
  is_active: !opts.inactive,
81
83
  };
82
84
  const data = await api.post(`/directories/${dir}/categories`, body);
@@ -100,6 +102,7 @@ categories
100
102
  .option('--parent-id <id>', 'Parent category ID')
101
103
  .option('--order <n>', 'Sort order', parseInt)
102
104
  .option('--active <bool>', 'Active status (true/false)')
105
+ .option('--head-html <html>', 'Custom HTML for the <head> of the category page (e.g. hreflang tags)')
103
106
  .option('-d, --directory <id>', 'Directory ID')
104
107
  .action(async (id, opts) => {
105
108
  const spinner = ora('Updating category...').start();
@@ -114,6 +117,7 @@ categories
114
117
  if (opts.parentId) body.parent_id = parseInt(opts.parentId);
115
118
  if (opts.order !== undefined) body.order = opts.order;
116
119
  if (opts.active !== undefined) body.is_active = opts.active === 'true';
120
+ if (opts.headHtml) body.head_html = opts.headHtml;
117
121
 
118
122
  const data = await api.put(`/directories/${dir}/categories/${id}`, body);
119
123
  spinner.stop();
@@ -0,0 +1,148 @@
1
+ import { Command } from 'commander';
2
+ import { api, resolveDirectory } from '../utils/api.js';
3
+ import { printTable, printJson, printSuccess, printError } from '../utils/output.js';
4
+ import ora from 'ora';
5
+
6
+ const organizers = new Command('organizers').alias('orgs').description('Manage organizers');
7
+
8
+ organizers
9
+ .command('list')
10
+ .alias('ls')
11
+ .description('List all organizers')
12
+ .option('-d, --directory <id>', 'Directory ID')
13
+ .option('--json', 'Output as JSON')
14
+ .action(async (opts) => {
15
+ const spinner = ora('Fetching organizers...').start();
16
+ try {
17
+ const dir = resolveDirectory(opts);
18
+ const data = await api.get(`/directories/${dir}/organizers`);
19
+ spinner.stop();
20
+ if (opts.json) {
21
+ printJson(data.data || data);
22
+ } else {
23
+ printTable(data.data || data, [
24
+ { key: 'id', label: 'ID' },
25
+ { key: 'name', label: 'Name', maxWidth: 30 },
26
+ { key: 'slug', label: 'Slug', maxWidth: 25 },
27
+ { key: 'email', label: 'Email', maxWidth: 30 },
28
+ { key: 'is_active', label: 'Active' },
29
+ { key: 'user_id', label: 'User ID' },
30
+ ]);
31
+ }
32
+ } catch (err) {
33
+ spinner.stop();
34
+ printError(err.message);
35
+ process.exit(1);
36
+ }
37
+ });
38
+
39
+ organizers
40
+ .command('get <id>')
41
+ .description('Get a specific organizer')
42
+ .option('-d, --directory <id>', 'Directory ID')
43
+ .action(async (id, opts) => {
44
+ try {
45
+ const dir = resolveDirectory(opts);
46
+ const data = await api.get(`/directories/${dir}/organizers/${id}`);
47
+ printJson(data.data || data);
48
+ } catch (err) {
49
+ printError(err.message);
50
+ process.exit(1);
51
+ }
52
+ });
53
+
54
+ organizers
55
+ .command('create')
56
+ .description('Create a new organizer')
57
+ .requiredOption('--name <name>', 'Organizer name')
58
+ .option('--slug <slug>', 'URL slug (auto-generated from name if not provided)')
59
+ .option('--description <text>', 'Description')
60
+ .option('--email <email>', 'Contact email')
61
+ .option('--phone <phone>', 'Contact phone')
62
+ .option('--website <url>', 'Website URL')
63
+ .option('--user-id <id>', 'Assign to a user (submitter) by ID')
64
+ .option('--inactive', 'Create as inactive')
65
+ .option('--order <n>', 'Sort order', '0')
66
+ .option('-d, --directory <id>', 'Directory ID')
67
+ .action(async (opts) => {
68
+ const spinner = ora('Creating organizer...').start();
69
+ try {
70
+ const dir = resolveDirectory(opts);
71
+ const body = {
72
+ name: opts.name,
73
+ ...(opts.slug && { slug: opts.slug }),
74
+ ...(opts.description && { description: opts.description }),
75
+ ...(opts.email && { email: opts.email }),
76
+ ...(opts.phone && { phone: opts.phone }),
77
+ ...(opts.website && { website_url: opts.website }),
78
+ ...(opts.userId && { user_id: Number(opts.userId) }),
79
+ is_active: !opts.inactive,
80
+ order: Number(opts.order),
81
+ };
82
+ const data = await api.post(`/directories/${dir}/organizers`, body);
83
+ spinner.stop();
84
+ printSuccess(`Organizer created: ${data.data?.name || data.name} (ID: ${data.data?.id || data.id})`);
85
+ } catch (err) {
86
+ spinner.stop();
87
+ printError(err.message);
88
+ process.exit(1);
89
+ }
90
+ });
91
+
92
+ organizers
93
+ .command('update <id>')
94
+ .description('Update an organizer')
95
+ .option('--name <name>', 'Organizer name')
96
+ .option('--slug <slug>', 'URL slug')
97
+ .option('--description <text>', 'Description')
98
+ .option('--email <email>', 'Contact email')
99
+ .option('--phone <phone>', 'Contact phone')
100
+ .option('--website <url>', 'Website URL')
101
+ .option('--user-id <id>', 'Assign to a user (submitter) by ID')
102
+ .option('--active <bool>', 'Active status (true/false)')
103
+ .option('--order <n>', 'Sort order')
104
+ .option('-d, --directory <id>', 'Directory ID')
105
+ .action(async (id, opts) => {
106
+ const spinner = ora('Updating organizer...').start();
107
+ try {
108
+ const dir = resolveDirectory(opts);
109
+ const body = {};
110
+ if (opts.name) body.name = opts.name;
111
+ if (opts.slug) body.slug = opts.slug;
112
+ if (opts.description) body.description = opts.description;
113
+ if (opts.email) body.email = opts.email;
114
+ if (opts.phone) body.phone = opts.phone;
115
+ if (opts.website) body.website_url = opts.website;
116
+ if (opts.userId) body.user_id = Number(opts.userId);
117
+ if (opts.active !== undefined) body.is_active = opts.active === 'true';
118
+ if (opts.order !== undefined) body.order = Number(opts.order);
119
+
120
+ const data = await api.put(`/directories/${dir}/organizers/${id}`, body);
121
+ spinner.stop();
122
+ printSuccess(`Organizer updated: ${data.data?.name || data.name}`);
123
+ } catch (err) {
124
+ spinner.stop();
125
+ printError(err.message);
126
+ process.exit(1);
127
+ }
128
+ });
129
+
130
+ organizers
131
+ .command('delete <id>')
132
+ .description('Delete an organizer')
133
+ .option('-d, --directory <id>', 'Directory ID')
134
+ .action(async (id, opts) => {
135
+ const spinner = ora('Deleting organizer...').start();
136
+ try {
137
+ const dir = resolveDirectory(opts);
138
+ await api.delete(`/directories/${dir}/organizers/${id}`);
139
+ spinner.stop();
140
+ printSuccess(`Organizer ${id} deleted.`);
141
+ } catch (err) {
142
+ spinner.stop();
143
+ printError(err.message);
144
+ process.exit(1);
145
+ }
146
+ });
147
+
148
+ export default organizers;
package/src/index.js CHANGED
@@ -10,6 +10,7 @@ import fields from './commands/fields.js';
10
10
  import listings from './commands/listings.js';
11
11
  import articles from './commands/articles.js';
12
12
  import pages from './commands/pages.js';
13
+ import organizers from './commands/organizers.js';
13
14
 
14
15
  const program = new Command();
15
16
 
@@ -27,5 +28,6 @@ program.addCommand(fields);
27
28
  program.addCommand(listings);
28
29
  program.addCommand(articles);
29
30
  program.addCommand(pages);
31
+ program.addCommand(organizers);
30
32
 
31
33
  program.parse();