directify-cli 1.2.0 → 1.3.1
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 +1 -1
- package/src/commands/organizers.js +156 -0
- package/src/index.js +2 -0
package/package.json
CHANGED
|
@@ -0,0 +1,156 @@
|
|
|
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>', 'Short description')
|
|
60
|
+
.option('--content <text>', 'Long-form content (markdown supported)')
|
|
61
|
+
.option('--email <email>', 'Contact email')
|
|
62
|
+
.option('--phone <phone>', 'Contact phone')
|
|
63
|
+
.option('--address <address>', 'Physical address')
|
|
64
|
+
.option('--website <url>', 'Website URL')
|
|
65
|
+
.option('--user-id <id>', 'Assign to a user (submitter) by ID')
|
|
66
|
+
.option('--inactive', 'Create as inactive')
|
|
67
|
+
.option('--order <n>', 'Sort order', '0')
|
|
68
|
+
.option('-d, --directory <id>', 'Directory ID')
|
|
69
|
+
.action(async (opts) => {
|
|
70
|
+
const spinner = ora('Creating organizer...').start();
|
|
71
|
+
try {
|
|
72
|
+
const dir = resolveDirectory(opts);
|
|
73
|
+
const body = {
|
|
74
|
+
name: opts.name,
|
|
75
|
+
...(opts.slug && { slug: opts.slug }),
|
|
76
|
+
...(opts.description && { description: opts.description }),
|
|
77
|
+
...(opts.content && { content: opts.content }),
|
|
78
|
+
...(opts.email && { email: opts.email }),
|
|
79
|
+
...(opts.phone && { phone: opts.phone }),
|
|
80
|
+
...(opts.address && { address: opts.address }),
|
|
81
|
+
...(opts.website && { website_url: opts.website }),
|
|
82
|
+
...(opts.userId && { user_id: Number(opts.userId) }),
|
|
83
|
+
is_active: !opts.inactive,
|
|
84
|
+
order: Number(opts.order),
|
|
85
|
+
};
|
|
86
|
+
const data = await api.post(`/directories/${dir}/organizers`, body);
|
|
87
|
+
spinner.stop();
|
|
88
|
+
printSuccess(`Organizer created: ${data.data?.name || data.name} (ID: ${data.data?.id || data.id})`);
|
|
89
|
+
} catch (err) {
|
|
90
|
+
spinner.stop();
|
|
91
|
+
printError(err.message);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
organizers
|
|
97
|
+
.command('update <id>')
|
|
98
|
+
.description('Update an organizer')
|
|
99
|
+
.option('--name <name>', 'Organizer name')
|
|
100
|
+
.option('--slug <slug>', 'URL slug')
|
|
101
|
+
.option('--description <text>', 'Short description')
|
|
102
|
+
.option('--content <text>', 'Long-form content (markdown supported)')
|
|
103
|
+
.option('--email <email>', 'Contact email')
|
|
104
|
+
.option('--phone <phone>', 'Contact phone')
|
|
105
|
+
.option('--address <address>', 'Physical address')
|
|
106
|
+
.option('--website <url>', 'Website URL')
|
|
107
|
+
.option('--user-id <id>', 'Assign to a user (submitter) by ID')
|
|
108
|
+
.option('--active <bool>', 'Active status (true/false)')
|
|
109
|
+
.option('--order <n>', 'Sort order')
|
|
110
|
+
.option('-d, --directory <id>', 'Directory ID')
|
|
111
|
+
.action(async (id, opts) => {
|
|
112
|
+
const spinner = ora('Updating organizer...').start();
|
|
113
|
+
try {
|
|
114
|
+
const dir = resolveDirectory(opts);
|
|
115
|
+
const body = {};
|
|
116
|
+
if (opts.name) body.name = opts.name;
|
|
117
|
+
if (opts.slug) body.slug = opts.slug;
|
|
118
|
+
if (opts.description) body.description = opts.description;
|
|
119
|
+
if (opts.content) body.content = opts.content;
|
|
120
|
+
if (opts.email) body.email = opts.email;
|
|
121
|
+
if (opts.phone) body.phone = opts.phone;
|
|
122
|
+
if (opts.address) body.address = opts.address;
|
|
123
|
+
if (opts.website) body.website_url = opts.website;
|
|
124
|
+
if (opts.userId) body.user_id = Number(opts.userId);
|
|
125
|
+
if (opts.active !== undefined) body.is_active = opts.active === 'true';
|
|
126
|
+
if (opts.order !== undefined) body.order = Number(opts.order);
|
|
127
|
+
|
|
128
|
+
const data = await api.put(`/directories/${dir}/organizers/${id}`, body);
|
|
129
|
+
spinner.stop();
|
|
130
|
+
printSuccess(`Organizer updated: ${data.data?.name || data.name}`);
|
|
131
|
+
} catch (err) {
|
|
132
|
+
spinner.stop();
|
|
133
|
+
printError(err.message);
|
|
134
|
+
process.exit(1);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
organizers
|
|
139
|
+
.command('delete <id>')
|
|
140
|
+
.description('Delete an organizer')
|
|
141
|
+
.option('-d, --directory <id>', 'Directory ID')
|
|
142
|
+
.action(async (id, opts) => {
|
|
143
|
+
const spinner = ora('Deleting organizer...').start();
|
|
144
|
+
try {
|
|
145
|
+
const dir = resolveDirectory(opts);
|
|
146
|
+
await api.delete(`/directories/${dir}/organizers/${id}`);
|
|
147
|
+
spinner.stop();
|
|
148
|
+
printSuccess(`Organizer ${id} deleted.`);
|
|
149
|
+
} catch (err) {
|
|
150
|
+
spinner.stop();
|
|
151
|
+
printError(err.message);
|
|
152
|
+
process.exit(1);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
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();
|