@swell/cli 2.5.4 → 2.5.6

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/bin/run.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env ts-node
1
+ #!/usr/bin/env node
2
2
 
3
3
  // eslint-disable-next-line unicorn/prefer-top-level-await, node/shebang
4
4
  (async () => {
@@ -66,6 +66,10 @@ export default class AppDev extends PushAppCommand {
66
66
  if (!noPush) {
67
67
  await this.pushAppConfigs();
68
68
  }
69
+ // Ensure storefront is resolved for local preview URL (may not be set with --no-push)
70
+ if (this.app.type === 'storefront' && !this.storefront) {
71
+ this.storefront = await this.getAppStorefront({});
72
+ }
69
73
  this.saveCurrentStorefront();
70
74
  const spinner = ora();
71
75
  spinner.start(`Starting app dev server...\n`);
@@ -87,7 +91,7 @@ export default class AppDev extends PushAppCommand {
87
91
  // Ignore errors during cleanup
88
92
  }
89
93
  this.log();
90
- // eslint-disable-next-line no-process-exit
94
+ // eslint-disable-next-line no-process-exit, unicorn/no-process-exit
91
95
  process.exit();
92
96
  }
93
97
  async runAppFrontendDevIfApplicable(frontendPort) {
@@ -100,7 +104,9 @@ export default class AppDev extends PushAppCommand {
100
104
  // Store frontend port for function router to use for fallback routing
101
105
  this.frontendPort = proxyPort;
102
106
  this.argv.push('--proxy-port', String(proxyPort));
103
- this.config.runCommand('app:frontend:dev', this.argv).catch((error) => {
107
+ this.config
108
+ .runCommand('app:frontend:dev', this.argv)
109
+ .catch((error) => {
104
110
  // SIGTERM/SIGINT during dev server shutdown is expected
105
111
  if (error?.signal === 'SIGTERM' || error?.signal === 'SIGINT')
106
112
  return;
@@ -13,7 +13,7 @@ export default class AppThemeDev extends PushAppCommand {
13
13
  };
14
14
  static summary: string;
15
15
  appType: string;
16
- logAppLocalUrl(storeId: string, sessionId: string): void;
16
+ logAppLocalUrl(storeId: string, localId: string): void;
17
17
  run(): Promise<void>;
18
18
  private findAndInstallDependencies;
19
19
  private findAndTryScriptCommands;
@@ -48,8 +48,8 @@ export default class AppThemeDev extends PushAppCommand {
48
48
  };
49
49
  static summary = `Run a theme in dev mode from your local machine.`;
50
50
  appType = 'theme';
51
- logAppLocalUrl(storeId, sessionId) {
52
- this.log(`View it at ${style.link(this.localFrontendUrl(storeId, sessionId))}\n`);
51
+ logAppLocalUrl(storeId, localId) {
52
+ this.log(`View it at ${style.link(this.localFrontendUrl(storeId, localId))}\n`);
53
53
  }
54
54
  async run() {
55
55
  const { flags } = await this.parse(AppThemeDev);
@@ -62,12 +62,11 @@ export default class AppThemeDev extends PushAppCommand {
62
62
  if (!(await this.ensureAppExists(undefined, false))) {
63
63
  return;
64
64
  }
65
+ await this.getStorefrontToPush(flags);
65
66
  if (local) {
66
67
  const currentStore = localConfig.getDefaultStore();
67
- const sessionId = localConfig.getSessionId(currentStore);
68
- this.storefrontLocalUrl = this.localFrontendUrl(currentStore, sessionId);
68
+ this.storefrontLocalUrl = this.localFrontendUrl(currentStore, this.storefront.id);
69
69
  }
70
- await this.getStorefrontToPush(flags);
71
70
  await this.logOrientation({ env: this.api.envId || 'live' });
72
71
  this.logStorefrontConnected();
73
72
  this.saveCurrentStorefront();
@@ -6,4 +6,4 @@ export declare function getFrontendApiBaseUrl(storeId: string): any;
6
6
  export declare function getLoginHost(storeId?: string): any;
7
7
  export declare function getAppFrontendHost(storeId: string, installedAppId: string): any;
8
8
  export declare function getStorefrontFrontendHost(storefrontSlug: string, branchId?: string): any;
9
- export declare function getLocalFrontendHost(storeId: string, sessionId: string): any;
9
+ export declare function getLocalFrontendHost(storeId: string, localId: string): any;
@@ -35,8 +35,8 @@ export function getAppFrontendHost(storeId, installedAppId) {
35
35
  export function getStorefrontFrontendHost(storefrontSlug, branchId) {
36
36
  return STOREFRONT_FRONTEND_HOST.replace('${STOREFRONT_SLUG}', storefrontSlug).replace('${BRANCH_PREFIX}', branchId ? `${branchId}.` : '');
37
37
  }
38
- export function getLocalFrontendHost(storeId, sessionId) {
38
+ export function getLocalFrontendHost(storeId, localId) {
39
39
  return APP_PAGES_HOST.replace('${STORE_ID}', storeId)
40
- .replace('${APP_ID}', sessionId)
40
+ .replace('${APP_ID}', localId)
41
41
  .replace('${ENV}', 'local');
42
42
  }
@@ -784,11 +784,13 @@ export class PushAppCommand extends RemoteAppCommand {
784
784
  return;
785
785
  }
786
786
  const currentStore = localConfig.getDefaultStore();
787
- const sessionId = localConfig.getSessionId(currentStore);
787
+ const localId = this.app.type === 'storefront' && this.storefront?.id
788
+ ? this.storefront.id
789
+ : localConfig.getSessionId(currentStore);
788
790
  const frontendAppRoute = this.app.type === 'storefront' && this.app.storefront?.external
789
791
  ? `/${this.app.private_id}`
790
792
  : '';
791
- this.log(`View it at ${style.link(`${this.localFrontendUrl(currentStore, sessionId)}${frontendAppRoute}`)}\n`);
793
+ this.log(`View it at ${style.link(`${this.localFrontendUrl(currentStore, localId)}${frontendAppRoute}`)}\n`);
792
794
  this.hasLoggedLocalPreviewUrl = true;
793
795
  }
794
796
  async setWatchingFiles() {
@@ -31,7 +31,7 @@ export declare abstract class RemoteAppCommand extends AppCommand {
31
31
  init(): Promise<void>;
32
32
  protected installApp(version: string, spinner?: any): Promise<any>;
33
33
  isConfigDeprecated(config: AppConfig): boolean;
34
- localFrontendUrl(storeId: string, sessionId: string): string;
34
+ localFrontendUrl(storeId: string, localId: string): string;
35
35
  logOrientation(orientation?: AppCommandOrientation): Promise<void>;
36
36
  postConfigData(configJson: any): Promise<any>;
37
37
  protected pullAppConfigs(force?: boolean, confirmRemove?: boolean): Promise<{
@@ -324,8 +324,8 @@ export class RemoteAppCommand extends AppCommand {
324
324
  isConfigDeprecated(config) {
325
325
  return !config.file_path;
326
326
  }
327
- localFrontendUrl(storeId, sessionId) {
328
- return getLocalFrontendHost(storeId, sessionId);
327
+ localFrontendUrl(storeId, localId) {
328
+ return getLocalFrontendHost(storeId, localId);
329
329
  }
330
330
  async logOrientation(orientation) {
331
331
  const klass = this.ctor;
@@ -2969,5 +2969,5 @@
2969
2969
  ]
2970
2970
  }
2971
2971
  },
2972
- "version": "2.5.4"
2972
+ "version": "2.5.6"
2973
2973
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swell/cli",
3
- "version": "2.5.4",
3
+ "version": "2.5.6",
4
4
  "type": "module",
5
5
  "description": "Swell's command line interface/utility",
6
6
  "keywords": [
@@ -113,7 +113,6 @@
113
113
  }
114
114
  },
115
115
  "scripts": {
116
- "preinstall": "npm i -g ts-node",
117
116
  "build": "shx rm -rf dist && shx rm -f tsconfig.tsbuildinfo && tsc -b",
118
117
  "lint": "eslint . --ext .ts --config .eslintrc",
119
118
  "postpack": "shx rm -f oclif.manifest.json",