@swell/cli 2.0.1-alpha.13 → 2.0.1-alpha.16

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.
Files changed (48) hide show
  1. package/dist/commands/app/install.d.ts +5 -2
  2. package/dist/commands/app/install.js +41 -38
  3. package/dist/commands/app/push.d.ts +3 -3
  4. package/dist/commands/app/push.js +46 -47
  5. package/dist/commands/app/version.js +3 -3
  6. package/dist/commands/create/app.d.ts +8 -8
  7. package/dist/commands/create/app.js +74 -71
  8. package/dist/commands/create/content.d.ts +2 -2
  9. package/dist/commands/create/content.js +10 -10
  10. package/dist/commands/create/function.d.ts +1 -1
  11. package/dist/commands/create/function.js +20 -20
  12. package/dist/commands/create/model.d.ts +2 -2
  13. package/dist/commands/create/model.js +11 -11
  14. package/dist/commands/create/notification.d.ts +2 -2
  15. package/dist/commands/create/notification.js +36 -38
  16. package/dist/commands/login.d.ts +1 -1
  17. package/dist/commands/login.js +7 -6
  18. package/dist/commands/logs.js +2 -0
  19. package/dist/create-collection-command.d.ts +6 -6
  20. package/dist/create-collection-command.js +19 -19
  21. package/dist/create-command.js +6 -4
  22. package/dist/lib/api.d.ts +3 -2
  23. package/dist/lib/api.js +11 -8
  24. package/dist/lib/app-config.d.ts +1 -0
  25. package/dist/lib/app-config.js +5 -3
  26. package/dist/lib/apps/index.d.ts +1 -1
  27. package/dist/lib/apps/index.js +1 -1
  28. package/dist/lib/apps/paths.d.ts +1 -1
  29. package/dist/lib/apps/paths.js +1 -1
  30. package/dist/lib/bundle.js +4 -5
  31. package/dist/lib/constants.js +2 -3
  32. package/dist/lib/create/content.d.ts +1 -1
  33. package/dist/lib/create/content.js +1 -1
  34. package/dist/lib/create/function.d.ts +2 -2
  35. package/dist/lib/create/function.js +2 -2
  36. package/dist/lib/create/index.d.ts +1 -1
  37. package/dist/lib/create/index.js +6 -6
  38. package/dist/lib/create/model.d.ts +2 -2
  39. package/dist/lib/create/notification.d.ts +2 -2
  40. package/dist/lib/sessions.js +2 -2
  41. package/dist/lib/stores.d.ts +4 -1
  42. package/dist/lib/stores.js +6 -3
  43. package/dist/lib/swell-function-wrapper.d.ts +2 -2
  44. package/dist/lib/swell-function-wrapper.js +2 -2
  45. package/dist/remote-app-command.d.ts +2 -2
  46. package/dist/remote-app-command.js +18 -18
  47. package/oclif.manifest.json +60 -57
  48. package/package.json +2 -1
@@ -25,11 +25,6 @@ export default class CreateContent extends CreateCollectionCommand {
25
25
  },
26
26
  ];
27
27
  static flags = {
28
- label: Flags.string({
29
- char: 'l',
30
- default: '',
31
- description: 'content model label',
32
- }),
33
28
  description: Flags.string({
34
29
  char: 'd',
35
30
  default: '',
@@ -40,21 +35,26 @@ export default class CreateContent extends CreateCollectionCommand {
40
35
  default: '',
41
36
  description: 'list of content model fields delimited by commas',
42
37
  }),
43
- views: Flags.string({
44
- char: 'v',
38
+ label: Flags.string({
39
+ char: 'l',
45
40
  default: '',
46
- description: 'list of content model views delimited by commas, i.e. list,edit,new',
41
+ description: 'content model label',
47
42
  }),
48
43
  overwrite: Flags.boolean({
49
44
  default: false,
50
45
  description: 'overwrite existing content model configuration file',
51
46
  }),
47
+ views: Flags.string({
48
+ char: 'v',
49
+ default: '',
50
+ description: 'list of content model views delimited by commas, i.e. list,edit,new',
51
+ }),
52
52
  };
53
53
  static summary = 'Initialize a content UI model config file with properties in the content folder.';
54
54
  createType = ConfigType.CONTENT;
55
55
  async run() {
56
56
  const { flags } = await this.parse(CreateContent);
57
- const { label, description, collection } = await this.promptCollection();
57
+ const { collection, description, label } = await this.promptCollection();
58
58
  const fileName = toFileName(collection);
59
59
  const fileBody = {
60
60
  collection,
@@ -70,12 +70,12 @@ export default class CreateContent extends CreateCollectionCommand {
70
70
  }
71
71
  else {
72
72
  const viewsInput = await checkbox({
73
- message: 'Which views does your content have?',
74
73
  choices: [
75
74
  { name: 'List view', value: 'list' },
76
75
  { name: 'Edit view', value: 'edit' },
77
76
  { name: 'New view', value: 'new' },
78
77
  ],
78
+ message: 'Which views does your content have?',
79
79
  });
80
80
  fileBody.views = parseViews(viewsInput);
81
81
  }
@@ -13,9 +13,9 @@ export default class CreateFunction extends CreateCommand {
13
13
  static flags: {
14
14
  description: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
15
15
  events: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
16
+ overwrite: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
16
17
  route: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
17
18
  schedule: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
18
- overwrite: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
19
19
  };
20
20
  static summary: string;
21
21
  createType: ConfigType;
@@ -45,6 +45,10 @@ export default class CreateFunction extends CreateCommand {
45
45
  default: '',
46
46
  description: 'list of data model events used with model trigger, delimited by commas',
47
47
  }),
48
+ overwrite: Flags.boolean({
49
+ default: false,
50
+ description: 'overwrite existing function file',
51
+ }),
48
52
  route: Flags.string({
49
53
  char: 'r',
50
54
  default: 'public',
@@ -56,25 +60,21 @@ export default class CreateFunction extends CreateCommand {
56
60
  default: '',
57
61
  description: 'crontab value used with cron trigger',
58
62
  }),
59
- overwrite: Flags.boolean({
60
- default: false,
61
- description: 'overwrite existing function file',
62
- }),
63
63
  };
64
64
  static summary = 'Initialize a functions script in JavaScript or TypeScript.';
65
65
  createType = ConfigType.FUNCTION;
66
66
  async run() {
67
67
  const { args, flags } = await this.parse(CreateFunction);
68
68
  const { functionName, trigger } = args;
69
- const { description, events, route, schedule, overwrite } = flags;
69
+ const { description, events, overwrite, route, schedule } = flags;
70
70
  let writeFunctionFileParams = {
71
71
  description,
72
72
  events,
73
- route,
74
73
  functionName: functionName || '',
75
74
  language: (functionName?.includes('.ts')
76
75
  ? 'ts'
77
76
  : 'js'),
77
+ route,
78
78
  schedule,
79
79
  trigger: trigger,
80
80
  };
@@ -85,7 +85,7 @@ export default class CreateFunction extends CreateCommand {
85
85
  await this.writeFunctionFile(writeFunctionFileParams, overwrite);
86
86
  }
87
87
  async gatherInput(params) {
88
- let language = params.language;
88
+ let { language } = params;
89
89
  if (!language) {
90
90
  language = await select({
91
91
  choices: [
@@ -101,7 +101,7 @@ export default class CreateFunction extends CreateCommand {
101
101
  message: 'What language are you using?',
102
102
  });
103
103
  }
104
- let trigger = params.trigger;
104
+ let { trigger } = params;
105
105
  if (!trigger) {
106
106
  trigger = await select({
107
107
  choices: [
@@ -121,41 +121,41 @@ export default class CreateFunction extends CreateCommand {
121
121
  message: 'How will your function be triggered?',
122
122
  });
123
123
  }
124
- let events = params.events;
124
+ let { events } = params;
125
125
  if (trigger === 'model' && !events) {
126
126
  events = await input({
127
- message: 'Enter event types separated by a comma',
128
127
  default: 'product.created, etc...',
128
+ message: 'Enter event types separated by a comma',
129
129
  });
130
130
  if (events === 'product.created, etc...') {
131
131
  events = '';
132
132
  }
133
133
  }
134
- let schedule = params.schedule;
134
+ let { schedule } = params;
135
135
  if (trigger === 'cron' && !schedule) {
136
136
  schedule = await input({
137
- message: 'Enter the crontab value',
138
137
  default: '0 0 * * *',
138
+ message: 'Enter the crontab value',
139
139
  });
140
140
  }
141
- let route = params.route;
141
+ let { route } = params;
142
142
  if (trigger === 'route' && !route) {
143
143
  route = await select({
144
- message: 'Should tbe route be public (public_key) or private (secret_key)?',
145
144
  choices: [
146
145
  { name: 'Public', value: 'public' },
147
146
  { name: 'Private', value: 'private' },
148
147
  ],
148
+ message: 'Should tbe route be public (public_key) or private (secret_key)?',
149
149
  });
150
150
  }
151
- let functionName = params.functionName;
151
+ let { functionName } = params;
152
152
  if (!functionName) {
153
153
  functionName = await input({
154
- message: 'What will the endpoint be?',
155
154
  default: functionName,
155
+ message: 'What will the endpoint be?',
156
156
  });
157
157
  }
158
- let description = params.description;
158
+ const { description } = params;
159
159
  if (!description) {
160
160
  await input({
161
161
  default: 'Does a thing when another other thing happens',
@@ -165,23 +165,23 @@ export default class CreateFunction extends CreateCommand {
165
165
  return {
166
166
  description,
167
167
  events: events || '',
168
- route: route || '',
169
168
  functionName,
170
169
  language,
170
+ route: route || '',
171
171
  schedule: schedule || '',
172
172
  trigger,
173
173
  };
174
174
  }
175
- async writeFunctionFile({ description, events, route, functionName, language, schedule, trigger, }, overwrite) {
175
+ async writeFunctionFile({ description, events, functionName, language, route, schedule, trigger, }, overwrite) {
176
176
  const fileName = toFunctionFileName(functionName);
177
177
  await this.createFile({
178
178
  extension: language,
179
179
  fileBody: getFunctionTemplate({
180
180
  description,
181
181
  events,
182
- route,
183
182
  functionName,
184
183
  language,
184
+ route,
185
185
  schedule,
186
186
  trigger,
187
187
  }),
@@ -7,10 +7,10 @@ export default class CreateModel extends CreateCollectionCommand {
7
7
  description: string;
8
8
  }[];
9
9
  static flags: {
10
- label: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
11
10
  description: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
12
- fields: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
13
11
  events: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
12
+ fields: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
13
+ label: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
14
14
  overwrite: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
15
15
  };
16
16
  static summary: string;
@@ -25,25 +25,25 @@ export default class CreateModel extends CreateCollectionCommand {
25
25
  },
26
26
  ];
27
27
  static flags = {
28
- label: Flags.string({
29
- char: 'l',
30
- default: '',
31
- description: 'data model label, i.e. Products',
32
- }),
33
28
  description: Flags.string({
34
29
  char: 'd',
35
30
  default: '',
36
31
  description: 'data model description',
37
32
  }),
33
+ events: Flags.string({
34
+ char: 'e',
35
+ default: 'created,updated,deleted',
36
+ description: 'list of data model events delimited by commas',
37
+ }),
38
38
  fields: Flags.string({
39
39
  char: 'f',
40
40
  default: '',
41
41
  description: 'list of data model fields delimited by commas',
42
42
  }),
43
- events: Flags.string({
44
- char: 'e',
45
- default: 'created,updated,deleted',
46
- description: 'list of data model events delimited by commas',
43
+ label: Flags.string({
44
+ char: 'l',
45
+ default: '',
46
+ description: 'data model label, i.e. Products',
47
47
  }),
48
48
  overwrite: Flags.boolean({
49
49
  default: false,
@@ -54,7 +54,7 @@ export default class CreateModel extends CreateCollectionCommand {
54
54
  createType = ConfigType.MODEL;
55
55
  async run() {
56
56
  const { flags } = await this.parse(CreateModel);
57
- const { label, description, collection } = await this.promptCollection();
57
+ const { collection, description, label } = await this.promptCollection();
58
58
  const fileName = toFileName(collection);
59
59
  const fileBody = {
60
60
  collection,
@@ -70,12 +70,12 @@ export default class CreateModel extends CreateCollectionCommand {
70
70
  }
71
71
  else {
72
72
  const eventsInput = await checkbox({
73
- message: 'Which events should be captured by default?',
74
73
  choices: [
75
74
  { name: 'created', value: 'created' },
76
75
  { name: 'updated', value: 'updated' },
77
76
  { name: 'deleted', value: 'deleted' },
78
77
  ],
78
+ message: 'Which events should be captured by default?',
79
79
  });
80
80
  fileBody.events = parseEvents(eventsInput);
81
81
  }
@@ -11,12 +11,12 @@ export default class CreateNotification extends CreateCommand {
11
11
  description: string;
12
12
  }[];
13
13
  static flags: {
14
+ admin: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
14
15
  description: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
15
- subject: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
16
16
  event: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
17
- admin: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
18
17
  once: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
19
18
  overwrite: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
19
+ subject: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
20
20
  };
21
21
  static summary: string;
22
22
  createType: ConfigType;
@@ -1,6 +1,6 @@
1
1
  import { input, select } from '@inquirer/prompts';
2
2
  import { Args, Flags } from '@oclif/core';
3
- import { singularize, capitalize } from 'inflection';
3
+ import { capitalize, singularize } from 'inflection';
4
4
  import { CreateCommand } from '../../create-command.js';
5
5
  import { ConfigType } from '../../lib/apps/index.js';
6
6
  import { toFileName, toNotificationLabel } from '../../lib/create/index.js';
@@ -29,25 +29,20 @@ export default class CreateNotification extends CreateCommand {
29
29
  },
30
30
  ];
31
31
  static flags = {
32
+ admin: Flags.boolean({
33
+ char: 'a',
34
+ description: 'indicate when the notification is sent to store admins only',
35
+ }),
32
36
  description: Flags.string({
33
37
  char: 'd',
34
38
  default: '',
35
39
  description: 'notification description',
36
40
  }),
37
- subject: Flags.string({
38
- char: 's',
39
- default: '',
40
- description: 'notification email subject',
41
- }),
42
41
  event: Flags.string({
43
42
  char: 'e',
44
43
  default: '',
45
44
  description: 'data model event to trigger the notification event, i.e. created',
46
45
  }),
47
- admin: Flags.boolean({
48
- char: 'a',
49
- description: 'indicate when the notification is sent to store admins only',
50
- }),
51
46
  once: Flags.boolean({
52
47
  char: 'o',
53
48
  description: 'indicate the notification should be sent only once when conditions are met, instead of repeating',
@@ -55,6 +50,11 @@ export default class CreateNotification extends CreateCommand {
55
50
  overwrite: Flags.boolean({
56
51
  description: 'overwrite existing notification configuration file',
57
52
  }),
53
+ subject: Flags.string({
54
+ char: 's',
55
+ default: '',
56
+ description: 'notification email subject',
57
+ }),
58
58
  };
59
59
  static summary = 'Initialize notification files and configuration with properties in the notifications folder.';
60
60
  createType = ConfigType.NOTIFICATION;
@@ -67,19 +67,19 @@ export default class CreateNotification extends CreateCommand {
67
67
  event: flags.event,
68
68
  model: args.model,
69
69
  name: `${singularize(args.model)}-${args.name.replace(singularize(args.model), '')}`,
70
- subject: flags.subject,
71
70
  once: flags.once,
71
+ subject: flags.subject,
72
72
  }, false);
73
73
  }
74
74
  else {
75
- let admin = flags.admin;
75
+ let { admin } = flags;
76
76
  if (admin === undefined) {
77
- const choice = await await select({
78
- message: 'Who will be notified?',
77
+ const choice = await select({
79
78
  choices: [
80
79
  { name: 'Admins', value: 'admin' },
81
80
  { name: 'Customers', value: 'customer' },
82
81
  ],
82
+ message: 'Who will be notified?',
83
83
  });
84
84
  if (choice === 'admin') {
85
85
  admin = true;
@@ -87,35 +87,28 @@ export default class CreateNotification extends CreateCommand {
87
87
  }
88
88
  const collections = await this.getCollectionOptions();
89
89
  const model = await select({
90
+ choices: collections.map((collectionName) => ({
91
+ name: collectionName,
92
+ value: collectionName,
93
+ })),
94
+ loop: false,
90
95
  message: 'Which model will trigger the notification?',
91
- choices: [
92
- ...collections.map((collectionName) => ({
93
- name: collectionName,
94
- value: collectionName,
95
- })),
96
- ],
97
96
  pageSize: 25,
98
- loop: false,
99
97
  });
100
98
  const event = await input({
101
- message: 'Event to trigger the notification',
102
99
  default: 'created',
100
+ message: 'Event to trigger the notification',
103
101
  });
104
102
  const answers = {
105
- name: await input({
106
- message: 'Name of the notification',
107
- default: `${singularize(model)}-${event}`,
108
- }),
109
- subject: await input({
110
- message: 'Subject of the notification email',
111
- default: `Something happened with ${model}`,
112
- }),
113
103
  description: await input({
114
- message: 'Describe what the notification does',
115
104
  default: `Notify ${admin ? 'admin' : 'customer'} when ${singularize(model)}...`,
105
+ message: 'Describe what the notification does',
106
+ }),
107
+ name: await input({
108
+ default: `${singularize(model)}-${event}`,
109
+ message: 'Name of the notification',
116
110
  }),
117
111
  once: await select({
118
- message: 'When should we send this notification?',
119
112
  choices: [
120
113
  {
121
114
  name: 'Every time conditions are met',
@@ -126,23 +119,28 @@ export default class CreateNotification extends CreateCommand {
126
119
  value: true,
127
120
  },
128
121
  ],
122
+ message: 'When should we send this notification?',
123
+ }),
124
+ subject: await input({
125
+ default: `Something happened with ${model}`,
126
+ message: 'Subject of the notification email',
129
127
  }),
130
128
  };
131
- const { description, name, subject, once } = answers;
132
- await this.writeNotificationFile({ admin, description, event, model, name, subject, once }, false);
129
+ const { description, name, once, subject } = answers;
130
+ await this.writeNotificationFile({ admin, description, event, model, name, once, subject }, false);
133
131
  }
134
132
  }
135
- async writeNotificationFile({ admin, description, event, model, name, subject, once, }, overwrite) {
133
+ async writeNotificationFile({ admin, description, event, model, name, once, subject, }, overwrite) {
136
134
  const label = [name].map((val) => capitalize(val).trim()).join(' ');
137
135
  const fileName = toFileName(label);
138
136
  const noteLabel = toNotificationLabel(name);
139
137
  const fileBody = {
140
138
  collection: model,
141
- label: noteLabel,
142
- subject: subject || `${noteLabel}...`,
143
- event: event || 'created',
144
139
  conditions: {},
140
+ event: event || 'created',
141
+ label: noteLabel,
145
142
  method: 'email',
143
+ subject: subject || `${noteLabel}...`,
146
144
  };
147
145
  fileBody.description = description;
148
146
  if (admin) {
@@ -3,8 +3,8 @@ import { SwellCommand } from '../swell-command.js';
3
3
  export default class Login extends SwellCommand {
4
4
  static description: string;
5
5
  static flags: {
6
- store: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
7
6
  force: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
7
+ store: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
8
  };
9
9
  static summary: string;
10
10
  constructor(argv: string[], config: Config);
@@ -11,14 +11,14 @@ Swell Admin login page, otherwise it will show you the stores you still
11
11
  have available for logging in to.
12
12
  `;
13
13
  static flags = {
14
- store: Flags.string({
15
- char: 's',
16
- description: 'store to login to',
17
- }),
18
14
  force: Flags.boolean({
19
15
  char: 'f',
20
16
  description: 'show all available stores and switch the current session if needed',
21
17
  }),
18
+ store: Flags.string({
19
+ char: 's',
20
+ description: 'store to login to',
21
+ }),
22
22
  };
23
23
  static summary = 'Login to your Swell user account.';
24
24
  constructor(argv, config) {
@@ -28,14 +28,14 @@ have available for logging in to.
28
28
  async run() {
29
29
  const { flags } = await this.parse(Login);
30
30
  const { force, store } = flags;
31
- let currentStoreId = config.getDefaultStore();
31
+ const currentStoreId = config.getDefaultStore();
32
32
  let user;
33
33
  if (currentStoreId && !force) {
34
34
  try {
35
35
  user = await this.api.get({ adminPath: 'user' });
36
36
  config.setUser(user);
37
37
  }
38
- catch (err) {
38
+ catch {
39
39
  // noop
40
40
  }
41
41
  }
@@ -46,6 +46,7 @@ have available for logging in to.
46
46
  await modifyDefaultStore({ currentStoreId, storeId });
47
47
  config.setUser(user);
48
48
  this.log(`You are now logged in to ${style.storeId(storeId)} as ${style.currentUser(user.username)}.`);
49
+ // eslint-disable-next-line no-process-exit, unicorn/no-process-exit
49
50
  process.env.NODE_ENV !== 'test' && process.exit(0);
50
51
  }
51
52
  /**
@@ -51,10 +51,12 @@ function buildLogRequestBody(flags) {
51
51
  }
52
52
  const { after, before, env, startPolling } = flags;
53
53
  if (env) {
54
+ // eslint-disable-next-line camelcase
54
55
  andConditions.push({ environment_id: env });
55
56
  }
56
57
  else {
57
58
  // Default to test env
59
+ // eslint-disable-next-line camelcase
58
60
  andConditions.push({ environment_id: 'test' });
59
61
  }
60
62
  // if we are polling, we want to get logs after the last date we received
@@ -7,20 +7,20 @@ import { CreateCommand } from './create-command.js';
7
7
  * - promptCollection: Get collection name and description
8
8
  */
9
9
  export declare abstract class CreateCollectionCommand extends CreateCommand {
10
- static baseFlags: {
11
- 'app-path': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
12
- };
13
10
  static args: {
14
11
  collection: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
15
12
  };
13
+ static baseFlags: {
14
+ 'app-path': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
15
+ };
16
16
  static flags: {
17
- label: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
18
17
  description: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
18
+ label: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
19
19
  overwrite: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
20
20
  };
21
21
  promptCollection(): Promise<{
22
- label: string;
23
- description: string;
24
22
  collection: string;
23
+ description: string;
24
+ label: string;
25
25
  }>;
26
26
  }
@@ -1,7 +1,7 @@
1
- import { input, select, Separator } from '@inquirer/prompts';
1
+ import { Separator, input, select } from '@inquirer/prompts';
2
2
  import { Args, Flags } from '@oclif/core';
3
3
  import { CreateCommand } from './create-command.js';
4
- import { toCollectionName, toCollectionLabel } from './lib/create/index.js';
4
+ import { toCollectionLabel, toCollectionName } from './lib/create/index.js';
5
5
  /**
6
6
  * A base class for Swell CLI Create [content|models] command input.
7
7
  *
@@ -11,29 +11,29 @@ import { toCollectionName, toCollectionLabel } from './lib/create/index.js';
11
11
  */
12
12
  export class CreateCollectionCommand extends CreateCommand {
13
13
  // base flags for all AppCommands
14
+ static args = {
15
+ collection: Args.string({
16
+ default: '',
17
+ description: 'collection to create or apply to, i.e. products',
18
+ }),
19
+ };
14
20
  // needs to be in a ES2021 format: https://github.com/oclif/oclif/issues/1100
15
21
  static baseFlags = {
16
22
  'app-path': Flags.string({
17
23
  description: 'path to the app directory',
18
24
  }),
19
25
  };
20
- static args = {
21
- collection: Args.string({
26
+ static flags = {
27
+ description: Flags.string({
28
+ char: 'd',
22
29
  default: '',
23
- description: 'collection to create or apply to, i.e. products',
30
+ description: 'the collection description',
24
31
  }),
25
- };
26
- static flags = {
27
32
  label: Flags.string({
28
33
  char: 'l',
29
34
  default: '',
30
35
  description: 'the collection label',
31
36
  }),
32
- description: Flags.string({
33
- char: 'd',
34
- default: '',
35
- description: 'the collection description',
36
- }),
37
37
  overwrite: Flags.boolean({
38
38
  char: 'o',
39
39
  default: false,
@@ -42,14 +42,13 @@ export class CreateCollectionCommand extends CreateCommand {
42
42
  };
43
43
  async promptCollection() {
44
44
  const { args, flags } = await this.parse(CreateCollectionCommand);
45
- let { label, description } = flags;
45
+ let { description, label } = flags;
46
46
  let { collection } = args;
47
47
  let isStandardCollection = false;
48
48
  let collectionInput = collection;
49
49
  if (!collection) {
50
50
  const collections = await this.getCollectionOptions();
51
51
  collectionInput = await select({
52
- message: 'Where will content be stored?',
53
52
  choices: [
54
53
  { name: 'Create a new collection', value: '' },
55
54
  new Separator(),
@@ -58,6 +57,7 @@ export class CreateCollectionCommand extends CreateCommand {
58
57
  value: collectionName,
59
58
  })),
60
59
  ],
60
+ message: 'Where will content be stored?',
61
61
  pageSize: 25,
62
62
  });
63
63
  if (collectionInput) {
@@ -65,8 +65,8 @@ export class CreateCollectionCommand extends CreateCommand {
65
65
  }
66
66
  else {
67
67
  collectionInput = await input({
68
- message: 'Collection name',
69
68
  default: 'special-things',
69
+ message: 'Collection name',
70
70
  });
71
71
  }
72
72
  // we replace unwanted characters with underscores to make things easier
@@ -75,23 +75,23 @@ export class CreateCollectionCommand extends CreateCommand {
75
75
  }
76
76
  if (!label && !isStandardCollection) {
77
77
  label = await input({
78
- message: 'Collection label',
79
78
  default: toCollectionLabel(collection),
79
+ message: 'Collection label',
80
80
  });
81
81
  label = toCollectionLabel(label);
82
82
  }
83
83
  description =
84
84
  description ||
85
85
  (await input({
86
+ default: 'Special things for special people',
86
87
  message: isStandardCollection
87
88
  ? `Describe the purpose of fields being added to ${collection}`
88
89
  : 'Describe what this collection is for',
89
- default: 'Special things for special people',
90
90
  }));
91
91
  return {
92
- label,
93
- description,
94
92
  collection,
93
+ description,
94
+ label,
95
95
  };
96
96
  }
97
97
  }