@swell/cli 2.0.1-alpha.10 → 2.0.1-alpha.12

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.
@@ -50,7 +50,10 @@ ${Object.values(ConfigPaths)
50
50
  const file = fileArg || fileFlag;
51
51
  const currentStore = swellConfig.getDefaultStore();
52
52
  this.api.setStoreEnv(currentStore, 'test');
53
- this.app = await this.getAppWithConfig('', false);
53
+ this.app = await this.getAppWithConfig('').catch((_err) => {
54
+ // Ignore so we can continue to create it
55
+ return {};
56
+ });
54
57
  const confirmExistingApp = await this.confirmRemoveInstalledApp(currentStore);
55
58
  if (confirmExistingApp === false) {
56
59
  return;
@@ -39,21 +39,14 @@ have available for logging in to.
39
39
  // noop
40
40
  }
41
41
  }
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(' '));
42
+ const [sessionId, storeId] = await getSessionIdOrLoginInBrowser(store);
43
+ this.api.setStoreEnv(storeId);
44
+ user = await this.api.get({ adminPath: 'user' }, { sessionId });
45
+ await this.getAndSetStoreConfig({ sessionId, storeId });
46
+ await modifyDefaultStore({ currentStoreId, storeId });
47
+ config.setUser(user);
48
+ this.log(`You are now logged in to ${style.storeId(storeId)} as ${style.currentUser(user.username)}.`);
49
+ process.exit(0);
57
50
  }
58
51
  /**
59
52
  * Use the /user/switch API request to either get the session id for the
@@ -13,5 +13,5 @@ export function getAdminApiBaseUrl(storeId) {
13
13
  return ADMIN_API_BASE_URL.replace('${STORE_ID}', storeId);
14
14
  }
15
15
  export function getLoginHost(storeId) {
16
- return LOGIN_HOST.replace('${STORE_ID}', storeId || 'app');
16
+ return LOGIN_HOST.replace('${STORE_ID}', storeId || 'login');
17
17
  }
@@ -12,7 +12,7 @@ export declare abstract class RemoteAppCommand extends AppCommand {
12
12
  }, storeId?: string): string;
13
13
  protected deleteConfig(configId: string): Promise<any>;
14
14
  protected getApp(id?: string): Promise<App>;
15
- protected getAppWithConfig(id?: string, errorNotFound?: boolean): Promise<App>;
15
+ protected getAppWithConfig(id?: string): Promise<App>;
16
16
  protected getCreateUpdateApp(updateApp?: App): Promise<App>;
17
17
  protected handleRequestErrors(request: () => any, spinnerError?: () => void): Promise<any>;
18
18
  init(): Promise<void>;
@@ -51,7 +51,7 @@ export class RemoteAppCommand extends AppCommand {
51
51
  this.debugJson('getApp: remote app', app);
52
52
  return app;
53
53
  }
54
- async getAppWithConfig(id = '', errorNotFound = true) {
54
+ async getAppWithConfig(id = '') {
55
55
  const swellId = this.app?.id;
56
56
  const appConfigId = this.appConfig.get('id');
57
57
  if (!appConfigId) {
@@ -90,7 +90,7 @@ export class RemoteAppCommand extends AppCommand {
90
90
  // we don't create a loop.
91
91
  //
92
92
  // we don't throw an error ever sometimes, like when pushing an app
93
- const shouldThrow = !errorNotFound && (errorJson.error.message !== 'App not found' || id);
93
+ const shouldThrow = errorJson.error.message !== 'App not found' || id;
94
94
  if (shouldThrow) {
95
95
  const errorMessage = typeof errorJson.error === 'string'
96
96
  ? errorJson.error
@@ -201,6 +201,10 @@ export class RemoteAppCommand extends AppCommand {
201
201
  this.showErrors(jsonError, spinnerError);
202
202
  this.error('API request failed');
203
203
  }
204
+ else if (typeof error.message === 'string') {
205
+ this.showErrors(error, spinnerError);
206
+ this.error(error.message);
207
+ }
204
208
  throw error;
205
209
  }
206
210
  }
@@ -1086,5 +1086,5 @@
1086
1086
  ]
1087
1087
  }
1088
1088
  },
1089
- "version": "2.0.1-alpha.10"
1089
+ "version": "2.0.1-alpha.12"
1090
1090
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swell/cli",
3
- "version": "2.0.1-alpha.10",
3
+ "version": "2.0.1-alpha.12",
4
4
  "type": "module",
5
5
  "description": "Swell's command line interface/utility",
6
6
  "keywords": [