@swell/cli 2.0.1-alpha.9 → 2.0.2

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 (102) hide show
  1. package/dist/app-command.d.ts +1 -1
  2. package/dist/app-command.js +9 -9
  3. package/dist/commands/app/dev.d.ts +16 -0
  4. package/dist/commands/app/dev.js +28 -0
  5. package/dist/commands/app/frontend/deploy.d.ts +15 -0
  6. package/dist/commands/app/frontend/deploy.js +41 -0
  7. package/dist/commands/app/frontend/dev.d.ts +19 -0
  8. package/dist/commands/app/frontend/dev.js +108 -0
  9. package/dist/commands/app/info.js +14 -9
  10. package/dist/commands/app/init.d.ts +12 -0
  11. package/dist/commands/app/init.js +34 -0
  12. package/dist/commands/app/install.d.ts +4 -4
  13. package/dist/commands/app/install.js +36 -42
  14. package/dist/commands/app/pull.d.ts +15 -0
  15. package/dist/commands/app/pull.js +50 -0
  16. package/dist/commands/app/push.d.ts +11 -14
  17. package/dist/commands/app/push.js +64 -138
  18. package/dist/commands/app/release.d.ts +13 -0
  19. package/dist/commands/app/release.js +148 -0
  20. package/dist/commands/app/version.d.ts +5 -4
  21. package/dist/commands/app/version.js +63 -42
  22. package/dist/commands/app/watch.d.ts +2 -4
  23. package/dist/commands/app/watch.js +3 -83
  24. package/dist/commands/create/app.d.ts +35 -11
  25. package/dist/commands/create/app.js +143 -137
  26. package/dist/commands/create/content.d.ts +2 -2
  27. package/dist/commands/create/content.js +10 -10
  28. package/dist/commands/create/frontend.d.ts +12 -0
  29. package/dist/commands/create/frontend.js +38 -0
  30. package/dist/commands/create/function.d.ts +3 -3
  31. package/dist/commands/create/function.js +22 -22
  32. package/dist/commands/create/model.d.ts +2 -2
  33. package/dist/commands/create/model.js +11 -11
  34. package/dist/commands/create/notification.d.ts +4 -4
  35. package/dist/commands/create/notification.js +38 -40
  36. package/dist/commands/env.d.ts +12 -0
  37. package/dist/commands/env.js +31 -0
  38. package/dist/commands/login.d.ts +1 -1
  39. package/dist/commands/login.js +18 -24
  40. package/dist/commands/logs.js +0 -1
  41. package/dist/commands/theme/dev.d.ts +21 -0
  42. package/dist/commands/theme/dev.js +164 -0
  43. package/dist/commands/theme/init.d.ts +9 -0
  44. package/dist/commands/theme/init.js +15 -0
  45. package/dist/commands/theme/pull.d.ts +20 -0
  46. package/dist/commands/theme/pull.js +65 -0
  47. package/dist/commands/theme/push.d.ts +19 -0
  48. package/dist/commands/theme/push.js +89 -0
  49. package/dist/create-app-command.d.ts +20 -0
  50. package/dist/create-app-command.js +253 -0
  51. package/dist/create-collection-command.d.ts +9 -9
  52. package/dist/create-collection-command.js +23 -23
  53. package/dist/{create-command.d.ts → create-config-command.d.ts} +1 -1
  54. package/dist/{create-command.js → create-config-command.js} +7 -7
  55. package/dist/env/local.d.ts +8 -0
  56. package/dist/env/local.js +7 -0
  57. package/dist/env/production.d.ts +8 -0
  58. package/dist/env/production.js +7 -0
  59. package/dist/env/review.d.ts +8 -0
  60. package/dist/env/review.js +7 -0
  61. package/dist/env/staging.d.ts +8 -0
  62. package/dist/env/staging.js +7 -0
  63. package/dist/lib/api.d.ts +4 -2
  64. package/dist/lib/api.js +50 -21
  65. package/dist/lib/app-config.d.ts +13 -5
  66. package/dist/lib/app-config.js +62 -24
  67. package/dist/lib/apps/app-config.d.ts +17 -3
  68. package/dist/lib/apps/app-config.js +194 -66
  69. package/dist/lib/apps/index.d.ts +93 -12
  70. package/dist/lib/apps/index.js +155 -50
  71. package/dist/lib/apps/paths.d.ts +14 -7
  72. package/dist/lib/apps/paths.js +73 -28
  73. package/dist/lib/bundle.js +15 -3
  74. package/dist/lib/config.d.ts +9 -2
  75. package/dist/lib/config.js +49 -1
  76. package/dist/lib/constants.d.ts +5 -0
  77. package/dist/lib/constants.js +24 -6
  78. package/dist/lib/create/content.d.ts +2 -2
  79. package/dist/lib/create/content.js +1 -1
  80. package/dist/lib/create/function.d.ts +2 -2
  81. package/dist/lib/create/function.js +2 -2
  82. package/dist/lib/create/index.d.ts +1 -1
  83. package/dist/lib/create/index.js +11 -7
  84. package/dist/lib/create/model.d.ts +2 -2
  85. package/dist/lib/create/notification.d.ts +2 -2
  86. package/dist/lib/info.js +2 -2
  87. package/dist/lib/logs/index.js +1 -1
  88. package/dist/lib/sessions.js +2 -2
  89. package/dist/lib/stores.d.ts +9 -4
  90. package/dist/lib/stores.js +13 -8
  91. package/dist/lib/style.d.ts +2 -0
  92. package/dist/lib/style.js +2 -0
  93. package/dist/lib/swell-function-wrapper.d.ts +40 -1
  94. package/dist/lib/swell-function-wrapper.js +107 -22
  95. package/dist/push-app-command.d.ts +73 -0
  96. package/dist/push-app-command.js +743 -0
  97. package/dist/remote-app-command.d.ts +37 -11
  98. package/dist/remote-app-command.js +432 -169
  99. package/oclif.manifest.json +872 -123
  100. package/package.json +14 -1
  101. package/dist/commands/app/_pull.d.ts +0 -8
  102. package/dist/commands/app/_pull.js +0 -45
@@ -1,11 +1,11 @@
1
1
  import { input, select } from '@inquirer/prompts';
2
2
  import { Args, Flags } from '@oclif/core';
3
- import { CreateCommand } from '../../create-command.js';
3
+ import { CreateConfigCommand } from '../../create-config-command.js';
4
4
  import { ConfigType } from '../../lib/apps/index.js';
5
5
  import { getFunctionTemplate, } from '../../lib/create/function.js';
6
6
  import { toFunctionFileName } from '../../lib/create/index.js';
7
7
  const PERMITTED_TRIGGERS = ['cron', 'model', 'route'];
8
- export default class CreateFunction extends CreateCommand {
8
+ export default class CreateFunction extends CreateConfigCommand {
9
9
  static args = {
10
10
  functionName: Args.string({
11
11
  description: 'function name, used in an http route if applicable',
@@ -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
  }
@@ -1,6 +1,6 @@
1
- import { CreateCommand } from '../../create-command.js';
1
+ import { CreateConfigCommand } from '../../create-config-command.js';
2
2
  import { ConfigType } from '../../lib/apps/index.js';
3
- export default class CreateNotification extends CreateCommand {
3
+ export default class CreateNotification extends CreateConfigCommand {
4
4
  static args: {
5
5
  model: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
6
6
  name: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
@@ -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,10 +1,10 @@
1
1
  import { input, select } from '@inquirer/prompts';
2
2
  import { Args, Flags } from '@oclif/core';
3
- import { singularize, capitalize } from 'inflection';
4
- import { CreateCommand } from '../../create-command.js';
3
+ import { capitalize, singularize } from 'inflection';
4
+ import { CreateConfigCommand } from '../../create-config-command.js';
5
5
  import { ConfigType } from '../../lib/apps/index.js';
6
6
  import { toFileName, toNotificationLabel } from '../../lib/create/index.js';
7
- export default class CreateNotification extends CreateCommand {
7
+ export default class CreateNotification extends CreateConfigCommand {
8
8
  static args = {
9
9
  model: Args.string({
10
10
  description: 'data model to trigger the notification by',
@@ -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) {
@@ -0,0 +1,12 @@
1
+ import { Config } from '@oclif/core';
2
+ import { SwellCommand } from '../swell-command.js';
3
+ export default class Env extends SwellCommand {
4
+ static args: {
5
+ name: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
6
+ reviewBranch: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
7
+ };
8
+ static description: string;
9
+ static hidden: boolean;
10
+ constructor(argv: string[], config: Config);
11
+ run(): Promise<void>;
12
+ }
@@ -0,0 +1,31 @@
1
+ import { Args } from '@oclif/core';
2
+ import { env, setEnv } from '../lib/config.js';
3
+ import style from '../lib/style.js';
4
+ import { SwellCommand } from '../swell-command.js';
5
+ export default class Env extends SwellCommand {
6
+ static args = {
7
+ name: Args.string({
8
+ description: 'name of the environment (production, staging, local, review)',
9
+ }),
10
+ reviewBranch: Args.string({
11
+ description: 'name of a review branch',
12
+ }),
13
+ };
14
+ static description = `Internal: Display the current environment configuration.`;
15
+ static hidden = true;
16
+ constructor(argv, config) {
17
+ super(argv, config);
18
+ this.requiresAuth = false;
19
+ }
20
+ async run() {
21
+ const { args } = await this.parse(Env);
22
+ const { name, reviewBranch } = args;
23
+ if (name) {
24
+ const newEnv = setEnv(name, reviewBranch);
25
+ this.log(`Environment set to ${style.appEnv(name)}:`, JSON.stringify(newEnv, null, 2));
26
+ }
27
+ else {
28
+ this.log('Current environment:', JSON.stringify(env.store, null, 2));
29
+ }
30
+ }
31
+ }
@@ -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,32 +28,28 @@ 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
+ this.log(`You are already logged in to ${style.storeId(currentStoreId)} as ${style.currentUser(user.username)}. Use --force to login again, or \`swell switch\` to switch stores.`);
38
+ // eslint-disable-next-line no-process-exit, unicorn/no-process-exit
39
+ process.env.NODE_ENV !== 'test' && process.exit(0);
40
+ return;
37
41
  }
38
- catch (err) {
42
+ catch {
39
43
  // noop
40
44
  }
41
45
  }
42
- if (!user) {
43
- const [sessionId, storeId] = await getSessionIdOrLoginInBrowser(store);
44
- this.api.setStoreEnv(storeId);
45
- user = await this.api.get({ adminPath: 'user' }, { sessionId });
46
- await this.getAndSetStoreConfig({ sessionId, storeId });
47
- await modifyDefaultStore({ currentStoreId, storeId });
48
- config.setUser(user);
49
- this.log(`You are now logged in to ${style.storeId(storeId)} as ${style.currentUser(user.username)}.`);
50
- process.exit(0);
51
- }
52
- this.log(`You are already logged in as ${style.currentUser(user.username)}.`);
53
- this.log([
54
- `Use ${style.command('swell switch')}`,
55
- 'to login to another account.',
56
- ].join(' '));
46
+ const [sessionId, storeId] = await getSessionIdOrLoginInBrowser(store);
47
+ this.api.setStoreEnv(storeId);
48
+ user = await this.api.get({ adminPath: 'user' }, { sessionId });
49
+ await this.getAndSetStoreConfig({ sessionId, storeId });
50
+ await modifyDefaultStore({ currentStoreId, storeId }, force);
51
+ config.setUser(user);
52
+ this.log(`\nYou are now logged in to ${style.storeId(storeId)} as ${style.currentUser(user.username)}.`);
57
53
  }
58
54
  /**
59
55
  * Use the /user/switch API request to either get the session id for the
@@ -65,9 +61,7 @@ have available for logging in to.
65
61
  * @returns void
66
62
  */
67
63
  async getAndSetStoreConfig({ sessionId, storeId, }) {
68
- const switchResponse = await this.api.post({ adminPath: '/user/switch' },
69
- // eslint-disable-next-line camelcase
70
- { body: { client_id: storeId }, sessionId });
64
+ const switchResponse = await this.api.post({ adminPath: '/user/switch' }, { body: { client_id: storeId }, sessionId });
71
65
  // ensure we have the attribute names as we expect before saving
72
66
  switchResponse.sessionId = switchResponse.session_id;
73
67
  switchResponse.storeId = switchResponse.client_id;
@@ -189,7 +189,6 @@ export default class Logs extends SwellCommand {
189
189
  }
190
190
  async getLogs(flags) {
191
191
  const body = buildLogRequestBody(flags);
192
- this.debug('getLogs body', body);
193
192
  const response = await this.api.post({ adminPath: `/data/$get/:logs` }, { body });
194
193
  return response?.results?.reverse() || [];
195
194
  }
@@ -0,0 +1,21 @@
1
+ import { PushAppCommand } from '../../push-app-command.js';
2
+ export default class AppThemeDev extends PushAppCommand {
3
+ static examples: string[];
4
+ static flags: {
5
+ bundle: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
6
+ local: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
7
+ 'no-push': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
8
+ 'storefront-id': import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
+ 'storefront-select': import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
10
+ };
11
+ static orientation: {
12
+ env: string;
13
+ };
14
+ static summary: string;
15
+ appType: string;
16
+ logAppLocalUrl(storeId: string, sessionId: string): void;
17
+ run(): Promise<void>;
18
+ private findAndInstallDependencies;
19
+ private findAndTryScriptCommands;
20
+ private startThemeDevServer;
21
+ }